openfox 2.0.17 → 2.0.20

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.
Files changed (32) hide show
  1. package/dist/agent-defaults/builder.agent.md +1 -2
  2. package/dist/agent-defaults/code-reviewer.agent.md +1 -1
  3. package/dist/agent-defaults/planner.agent.md +4 -1
  4. package/dist/agent-defaults/verifier.agent.md +1 -1
  5. package/dist/{chat-handler-DTMB43CD.js → chat-handler-KNDSH5WR.js} +7 -7
  6. package/dist/{chunk-BC7R4HLY.js → chunk-3QQ4QKAU.js} +74 -573
  7. package/dist/{chunk-LX66KJPL.js → chunk-6PLAWCHQ.js} +31 -56
  8. package/dist/{chunk-FWJ6YXGA.js → chunk-ASM2Z7JU.js} +3 -3
  9. package/dist/{chunk-L7TDUIQY.js → chunk-DX37WNM7.js} +28 -3
  10. package/dist/{chunk-J7KOV4ST.js → chunk-GI24G4OW.js} +3 -3
  11. package/dist/{chunk-5ANV7YUX.js → chunk-T67KB6ZS.js} +8 -8
  12. package/dist/{chunk-KYR4NVNX.js → chunk-TVQTTZYW.js} +93 -55
  13. package/dist/{chunk-MS3PEYZK.js → chunk-VDC2QL2O.js} +5 -5
  14. package/dist/{chunk-SYG2ENUQ.js → chunk-YBWY4DKY.js} +2 -2
  15. package/dist/{chunk-YGNOTMV7.js → chunk-YYXOZJYE.js} +2 -2
  16. package/dist/cli/dev.js +1 -1
  17. package/dist/cli/index.js +1 -1
  18. package/dist/{compactor-R7GRFBOU.js → compactor-EOQYEOFS.js} +5 -5
  19. package/dist/{events-4K52FKPR.js → events-JKPHAR5W.js} +3 -3
  20. package/dist/{folding-QIBNKYA6.js → folding-PI67HWBR.js} +2 -2
  21. package/dist/{orchestrator-FNAU26B6.js → orchestrator-ZVPFU2ZF.js} +6 -6
  22. package/dist/package.json +1 -1
  23. package/dist/{processor-3YZVK4JT.js → processor-DKAYI3PV.js} +7 -7
  24. package/dist/{serve-CRZ7NHSP.js → serve-24IV7E3C.js} +9 -9
  25. package/dist/server/index.js +8 -8
  26. package/dist/{server-JKNV2NCJ.js → server-CN7ML6XN.js} +8 -8
  27. package/dist/{tools-YWC3AJ66.js → tools-ZUOBYTVD.js} +5 -5
  28. package/dist/web/assets/index-00migM5L.js +301 -0
  29. package/dist/web/index.html +1 -1
  30. package/dist/web/sw.js +1 -1
  31. package/package.json +1 -1
  32. package/dist/web/assets/index-e6TyhL8M.js +0 -301
@@ -0,0 +1,301 @@
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 s2=Object.defineProperty;var i2=Object.getPrototypeOf;var a2=Reflect.get;var rv=e=>{throw TypeError(e)};var o2=(e,t,n)=>t in e?s2(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var me=(e,t,n)=>o2(e,typeof t!="symbol"?t+"":t,n),kf=(e,t,n)=>t.has(e)||rv("Cannot "+n);var kn=(e,t,n)=>(kf(e,t,"read from private field"),n?n.call(e):t.get(e)),mi=(e,t,n)=>t.has(e)?rv("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),xr=(e,t,n,s)=>(kf(e,t,"write to private field"),s?s.call(e,n):t.set(e,n),n),Ef=(e,t,n)=>(kf(e,t,"access private method"),n);var sv=(e,t,n)=>a2(i2(e),n,t);function l2(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 Mu(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var jf={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 iv;function c2(){if(iv)return Bo;iv=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 av;function u2(){return av||(av=1,jf.exports=c2()),jf.exports}var o=u2(),Nf={exports:{}},Ge={};/**
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 ov;function d2(){if(ov)return Ge;ov=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"),d=Symbol.for("react.suspense"),f=Symbol.for("react.memo"),m=Symbol.for("react.lazy"),p=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(){}},C=Object.assign,v={};function S($,F,P){this.props=$,this.context=F,this.refs=v,this.updater=P||w}S.prototype.isReactComponent={},S.prototype.setState=function($,F){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,$,F,"setState")},S.prototype.forceUpdate=function($){this.updater.enqueueForceUpdate(this,$,"forceUpdate")};function b(){}b.prototype=S.prototype;function y($,F,P){this.props=$,this.context=F,this.refs=v,this.updater=P||w}var E=y.prototype=new b;E.constructor=y,C(E,S.prototype),E.isPureReactComponent=!0;var N=Array.isArray;function T(){}var L={H:null,A:null,T:null,S:null},A=Object.prototype.hasOwnProperty;function R($,F,P){var ee=P.ref;return{$$typeof:e,type:$,key:F,ref:ee!==void 0?ee:null,props:P}}function M($,F){return R($.type,F,$.props)}function G($){return typeof $=="object"&&$!==null&&$.$$typeof===e}function W($){var F={"=":"=0",":":"=2"};return"$"+$.replace(/[=:]/g,function(P){return F[P]})}var O=/\/+/g;function U($,F){return typeof $=="object"&&$!==null&&$.key!=null?W(""+$.key):F.toString(36)}function V($){switch($.status){case"fulfilled":return $.value;case"rejected":throw $.reason;default:switch(typeof $.status=="string"?$.then(T,T):($.status="pending",$.then(function(F){$.status==="pending"&&($.status="fulfilled",$.value=F)},function(F){$.status==="pending"&&($.status="rejected",$.reason=F)})),$.status){case"fulfilled":return $.value;case"rejected":throw $.reason}}throw $}function z($,F,P,ee,J){var re=typeof $;(re==="undefined"||re==="boolean")&&($=null);var Y=!1;if($===null)Y=!0;else switch(re){case"bigint":case"string":case"number":Y=!0;break;case"object":switch($.$$typeof){case e:case t:Y=!0;break;case m:return Y=$._init,z(Y($._payload),F,P,ee,J)}}if(Y)return J=J($),Y=ee===""?"."+U($,0):ee,N(J)?(P="",Y!=null&&(P=Y.replace(O,"$&/")+"/"),z(J,F,P,"",function(ae){return ae})):J!=null&&(G(J)&&(J=M(J,P+(J.key==null||$&&$.key===J.key?"":(""+J.key).replace(O,"$&/")+"/")+Y)),F.push(J)),1;Y=0;var q=ee===""?".":ee+":";if(N($))for(var Z=0;Z<$.length;Z++)ee=$[Z],re=q+U(ee,Z),Y+=z(ee,F,P,re,J);else if(Z=x($),typeof Z=="function")for($=Z.call($),Z=0;!(ee=$.next()).done;)ee=ee.value,re=q+U(ee,Z++),Y+=z(ee,F,P,re,J);else if(re==="object"){if(typeof $.then=="function")return z(V($),F,P,ee,J);throw F=String($),Error("Objects are not valid as a React child (found: "+(F==="[object Object]"?"object with keys {"+Object.keys($).join(", ")+"}":F)+"). If you meant to render a collection of children, use an array instead.")}return Y}function X($,F,P){if($==null)return $;var ee=[],J=0;return z($,ee,"","",function(re){return F.call(P,re,J++)}),ee}function te($){if($._status===-1){var F=$._result;F=F(),F.then(function(P){($._status===0||$._status===-1)&&($._status=1,$._result=P)},function(P){($._status===0||$._status===-1)&&($._status=2,$._result=P)}),$._status===-1&&($._status=0,$._result=F)}if($._status===1)return $._result.default;throw $._result}var H=typeof reportError=="function"?reportError:function($){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var F=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof $=="object"&&$!==null&&typeof $.message=="string"?String($.message):String($),error:$});if(!window.dispatchEvent(F))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",$);return}console.error($)},I={map:X,forEach:function($,F,P){X($,function(){F.apply(this,arguments)},P)},count:function($){var F=0;return X($,function(){F++}),F},toArray:function($){return X($,function(F){return F})||[]},only:function($){if(!G($))throw Error("React.Children.only expected to receive a single React element child.");return $}};return Ge.Activity=p,Ge.Children=I,Ge.Component=S,Ge.Fragment=n,Ge.Profiler=a,Ge.PureComponent=y,Ge.StrictMode=s,Ge.Suspense=d,Ge.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=L,Ge.__COMPILER_RUNTIME={__proto__:null,c:function($){return L.H.useMemoCache($)}},Ge.cache=function($){return function(){return $.apply(null,arguments)}},Ge.cacheSignal=function(){return null},Ge.cloneElement=function($,F,P){if($==null)throw Error("The argument must be a React element, but you passed "+$+".");var ee=C({},$.props),J=$.key;if(F!=null)for(re in F.key!==void 0&&(J=""+F.key),F)!A.call(F,re)||re==="key"||re==="__self"||re==="__source"||re==="ref"&&F.ref===void 0||(ee[re]=F[re]);var re=arguments.length-2;if(re===1)ee.children=P;else if(1<re){for(var Y=Array(re),q=0;q<re;q++)Y[q]=arguments[q+2];ee.children=Y}return R($.type,J,ee)},Ge.createContext=function($){return $={$$typeof:u,_currentValue:$,_currentValue2:$,_threadCount:0,Provider:null,Consumer:null},$.Provider=$,$.Consumer={$$typeof:l,_context:$},$},Ge.createElement=function($,F,P){var ee,J={},re=null;if(F!=null)for(ee in F.key!==void 0&&(re=""+F.key),F)A.call(F,ee)&&ee!=="key"&&ee!=="__self"&&ee!=="__source"&&(J[ee]=F[ee]);var Y=arguments.length-2;if(Y===1)J.children=P;else if(1<Y){for(var q=Array(Y),Z=0;Z<Y;Z++)q[Z]=arguments[Z+2];J.children=q}if($&&$.defaultProps)for(ee in Y=$.defaultProps,Y)J[ee]===void 0&&(J[ee]=Y[ee]);return R($,re,J)},Ge.createRef=function(){return{current:null}},Ge.forwardRef=function($){return{$$typeof:c,render:$}},Ge.isValidElement=G,Ge.lazy=function($){return{$$typeof:m,_payload:{_status:-1,_result:$},_init:te}},Ge.memo=function($,F){return{$$typeof:f,type:$,compare:F===void 0?null:F}},Ge.startTransition=function($){var F=L.T,P={};L.T=P;try{var ee=$(),J=L.S;J!==null&&J(P,ee),typeof ee=="object"&&ee!==null&&typeof ee.then=="function"&&ee.then(T,H)}catch(re){H(re)}finally{F!==null&&P.types!==null&&(F.types=P.types),L.T=F}},Ge.unstable_useCacheRefresh=function(){return L.H.useCacheRefresh()},Ge.use=function($){return L.H.use($)},Ge.useActionState=function($,F,P){return L.H.useActionState($,F,P)},Ge.useCallback=function($,F){return L.H.useCallback($,F)},Ge.useContext=function($){return L.H.useContext($)},Ge.useDebugValue=function(){},Ge.useDeferredValue=function($,F){return L.H.useDeferredValue($,F)},Ge.useEffect=function($,F){return L.H.useEffect($,F)},Ge.useEffectEvent=function($){return L.H.useEffectEvent($)},Ge.useId=function(){return L.H.useId()},Ge.useImperativeHandle=function($,F,P){return L.H.useImperativeHandle($,F,P)},Ge.useInsertionEffect=function($,F){return L.H.useInsertionEffect($,F)},Ge.useLayoutEffect=function($,F){return L.H.useLayoutEffect($,F)},Ge.useMemo=function($,F){return L.H.useMemo($,F)},Ge.useOptimistic=function($,F){return L.H.useOptimistic($,F)},Ge.useReducer=function($,F,P){return L.H.useReducer($,F,P)},Ge.useRef=function($){return L.H.useRef($)},Ge.useState=function($){return L.H.useState($)},Ge.useSyncExternalStore=function($,F,P){return L.H.useSyncExternalStore($,F,P)},Ge.useTransition=function(){return L.H.useTransition()},Ge.version="19.2.4",Ge}var lv;function Iu(){return lv||(lv=1,Nf.exports=d2()),Nf.exports}var D=Iu();const Us=Mu(D),h2=l2({__proto__:null,default:Us},[D]);var Tf={exports:{}},zo={},Af={exports:{}},Lf={};/**
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 cv;function f2(){return cv||(cv=1,(function(e){function t(z,X){var te=z.length;z.push(X);e:for(;0<te;){var H=te-1>>>1,I=z[H];if(0<a(I,X))z[H]=X,z[te]=I,te=H;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],te=z.pop();if(te!==X){z[0]=te;e:for(var H=0,I=z.length,$=I>>>1;H<$;){var F=2*(H+1)-1,P=z[F],ee=F+1,J=z[ee];if(0>a(P,te))ee<I&&0>a(J,P)?(z[H]=J,z[ee]=te,H=ee):(z[H]=P,z[F]=te,H=F);else if(ee<I&&0>a(J,te))z[H]=J,z[ee]=te,H=ee;else break e}}return X}function a(z,X){var te=z.sortIndex-X.sortIndex;return te!==0?te: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 d=[],f=[],m=1,p=null,_=3,x=!1,w=!1,C=!1,v=!1,S=typeof setTimeout=="function"?setTimeout:null,b=typeof clearTimeout=="function"?clearTimeout:null,y=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(d,X);else break;X=n(f)}}function N(z){if(C=!1,E(z),!w)if(n(d)!==null)w=!0,T||(T=!0,W());else{var X=n(f);X!==null&&V(N,X.startTime-z)}}var T=!1,L=-1,A=5,R=-1;function M(){return v?!0:!(e.unstable_now()-R<A)}function G(){if(v=!1,T){var z=e.unstable_now();R=z;var X=!0;try{e:{w=!1,C&&(C=!1,b(L),L=-1),x=!0;var te=_;try{t:{for(E(z),p=n(d);p!==null&&!(p.expirationTime>z&&M());){var H=p.callback;if(typeof H=="function"){p.callback=null,_=p.priorityLevel;var I=H(p.expirationTime<=z);if(z=e.unstable_now(),typeof I=="function"){p.callback=I,E(z),X=!0;break t}p===n(d)&&s(d),E(z)}else s(d);p=n(d)}if(p!==null)X=!0;else{var $=n(f);$!==null&&V(N,$.startTime-z),X=!1}}break e}finally{p=null,_=te,x=!1}X=void 0}}finally{X?W():T=!1}}}var W;if(typeof y=="function")W=function(){y(G)};else if(typeof MessageChannel<"u"){var O=new MessageChannel,U=O.port2;O.port1.onmessage=G,W=function(){U.postMessage(null)}}else W=function(){S(G,0)};function V(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 te=_;_=X;try{return z()}finally{_=te}},e.unstable_requestPaint=function(){v=!0},e.unstable_runWithPriority=function(z,X){switch(z){case 1:case 2:case 3:case 4:case 5:break;default:z=3}var te=_;_=z;try{return X()}finally{_=te}},e.unstable_scheduleCallback=function(z,X,te){var H=e.unstable_now();switch(typeof te=="object"&&te!==null?(te=te.delay,te=typeof te=="number"&&0<te?H+te:H):te=H,z){case 1:var I=-1;break;case 2:I=250;break;case 5:I=1073741823;break;case 4:I=1e4;break;default:I=5e3}return I=te+I,z={id:m++,callback:X,priorityLevel:z,startTime:te,expirationTime:I,sortIndex:-1},te>H?(z.sortIndex=te,t(f,z),n(d)===null&&z===n(f)&&(C?(b(L),L=-1):C=!0,V(N,te-H))):(z.sortIndex=I,t(d,z),w||x||(w=!0,T||(T=!0,W()))),z},e.unstable_shouldYield=M,e.unstable_wrapCallback=function(z){var X=_;return function(){var te=_;_=X;try{return z.apply(this,arguments)}finally{_=te}}}})(Lf)),Lf}var uv;function m2(){return uv||(uv=1,Af.exports=f2()),Af.exports}var Df={exports:{}},yn={};/**
27
+ * @license React
28
+ * react-dom.production.js
29
+ *
30
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
31
+ *
32
+ * This source code is licensed under the MIT license found in the
33
+ * LICENSE file in the root directory of this source tree.
34
+ */var dv;function p2(){if(dv)return yn;dv=1;var e=Iu();function t(d){var f="https://react.dev/errors/"+d;if(1<arguments.length){f+="?args[]="+encodeURIComponent(arguments[1]);for(var m=2;m<arguments.length;m++)f+="&args[]="+encodeURIComponent(arguments[m])}return"Minified React error #"+d+"; 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(d,f,m){var p=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:p==null?null:""+p,children:d,containerInfo:f,implementation:m}}var u=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function c(d,f){if(d==="font")return"";if(typeof f=="string")return f==="use-credentials"?f:""}return yn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=s,yn.createPortal=function(d,f){var m=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(d,f,null,m)},yn.flushSync=function(d){var f=u.T,m=s.p;try{if(u.T=null,s.p=2,d)return d()}finally{u.T=f,s.p=m,s.d.f()}},yn.preconnect=function(d,f){typeof d=="string"&&(f?(f=f.crossOrigin,f=typeof f=="string"?f==="use-credentials"?f:"":void 0):f=null,s.d.C(d,f))},yn.prefetchDNS=function(d){typeof d=="string"&&s.d.D(d)},yn.preinit=function(d,f){if(typeof d=="string"&&f&&typeof f.as=="string"){var m=f.as,p=c(m,f.crossOrigin),_=typeof f.integrity=="string"?f.integrity:void 0,x=typeof f.fetchPriority=="string"?f.fetchPriority:void 0;m==="style"?s.d.S(d,typeof f.precedence=="string"?f.precedence:void 0,{crossOrigin:p,integrity:_,fetchPriority:x}):m==="script"&&s.d.X(d,{crossOrigin:p,integrity:_,fetchPriority:x,nonce:typeof f.nonce=="string"?f.nonce:void 0})}},yn.preinitModule=function(d,f){if(typeof d=="string")if(typeof f=="object"&&f!==null){if(f.as==null||f.as==="script"){var m=c(f.as,f.crossOrigin);s.d.M(d,{crossOrigin:m,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0})}}else f==null&&s.d.M(d)},yn.preload=function(d,f){if(typeof d=="string"&&typeof f=="object"&&f!==null&&typeof f.as=="string"){var m=f.as,p=c(m,f.crossOrigin);s.d.L(d,m,{crossOrigin:p,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})}},yn.preloadModule=function(d,f){if(typeof d=="string")if(f){var m=c(f.as,f.crossOrigin);s.d.m(d,{as:typeof f.as=="string"&&f.as!=="script"?f.as:void 0,crossOrigin:m,integrity:typeof f.integrity=="string"?f.integrity:void 0})}else s.d.m(d)},yn.requestFormReset=function(d){s.d.r(d)},yn.unstable_batchedUpdates=function(d,f){return d(f)},yn.useFormState=function(d,f,m){return u.H.useFormState(d,f,m)},yn.useFormStatus=function(){return u.H.useHostTransitionStatus()},yn.version="19.2.4",yn}var hv;function iS(){if(hv)return Df.exports;hv=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(),Df.exports=p2(),Df.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 fv;function g2(){if(fv)return zo;fv=1;var e=m2(),t=Iu(),n=iS();function s(r){var i="https://react.dev/errors/"+r;if(1<arguments.length){i+="?args[]="+encodeURIComponent(arguments[1]);for(var h=2;h<arguments.length;h++)i+="&args[]="+encodeURIComponent(arguments[h])}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,h=r;if(r.alternate)for(;i.return;)i=i.return;else{r=i;do i=r,(i.flags&4098)!==0&&(h=i.return),r=i.return;while(r)}return i.tag===3?h: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 d(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 h=r,g=i;;){var k=h.return;if(k===null)break;var j=k.alternate;if(j===null){if(g=k.return,g!==null){h=g;continue}break}if(k.child===j.child){for(j=k.child;j;){if(j===h)return d(k),r;if(j===g)return d(k),i;j=j.sibling}throw Error(s(188))}if(h.return!==g.return)h=k,g=j;else{for(var B=!1,K=k.child;K;){if(K===h){B=!0,h=k,g=j;break}if(K===g){B=!0,g=k,h=j;break}K=K.sibling}if(!B){for(K=j.child;K;){if(K===h){B=!0,h=j,g=k;break}if(K===g){B=!0,g=j,h=k;break}K=K.sibling}if(!B)throw Error(s(189))}}if(h.alternate!==g)throw Error(s(190))}if(h.tag!==3)throw Error(s(188));return h.stateNode.current===h?r:i}function m(r){var i=r.tag;if(i===5||i===26||i===27||i===6)return r;for(r=r.child;r!==null;){if(i=m(r),i!==null)return i;r=r.sibling}return null}var p=Object.assign,_=Symbol.for("react.element"),x=Symbol.for("react.transitional.element"),w=Symbol.for("react.portal"),C=Symbol.for("react.fragment"),v=Symbol.for("react.strict_mode"),S=Symbol.for("react.profiler"),b=Symbol.for("react.consumer"),y=Symbol.for("react.context"),E=Symbol.for("react.forward_ref"),N=Symbol.for("react.suspense"),T=Symbol.for("react.suspense_list"),L=Symbol.for("react.memo"),A=Symbol.for("react.lazy"),R=Symbol.for("react.activity"),M=Symbol.for("react.memo_cache_sentinel"),G=Symbol.iterator;function W(r){return r===null||typeof r!="object"?null:(r=G&&r[G]||r["@@iterator"],typeof r=="function"?r:null)}var O=Symbol.for("react.client.reference");function U(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 C:return"Fragment";case S:return"Profiler";case v:return"StrictMode";case N:return"Suspense";case T:return"SuspenseList";case R:return"Activity"}if(typeof r=="object")switch(r.$$typeof){case w:return"Portal";case y:return r.displayName||"Context";case b: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:U(r.type)||"Memo";case A:i=r._payload,r=r._init;try{return U(r(i))}catch{}}return null}var V=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,te={pending:!1,data:null,method:null,action:null},H=[],I=-1;function $(r){return{current:r}}function F(r){0>I||(r.current=H[I],H[I]=null,I--)}function P(r,i){I++,H[I]=r.current,r.current=i}var ee=$(null),J=$(null),re=$(null),Y=$(null);function q(r,i){switch(P(re,i),P(J,r),P(ee,null),i.nodeType){case 9:case 11:r=(r=i.documentElement)&&(r=r.namespaceURI)?Ey(r):0;break;default:if(r=i.tagName,i=i.namespaceURI)i=Ey(i),r=jy(i,r);else switch(r){case"svg":r=1;break;case"math":r=2;break;default:r=0}}F(ee),P(ee,r)}function Z(){F(ee),F(J),F(re)}function ae(r){r.memoizedState!==null&&P(Y,r);var i=ee.current,h=jy(i,r.type);i!==h&&(P(J,r),P(ee,h))}function se(r){J.current===r&&(F(ee),F(J)),Y.current===r&&(F(Y),Oo._currentValue=te)}var oe,je;function Le(r){if(oe===void 0)try{throw Error()}catch(h){var i=h.stack.trim().match(/\n( *(at )?)/);oe=i&&i[1]||"",je=-1<h.stack.indexOf(`
43
+ at`)?" (<anonymous>)":-1<h.stack.indexOf("@")?"@unknown:0:0":""}return`
44
+ `+oe+r+je}var De=!1;function Re(r,i){if(!r||De)return"";De=!0;var h=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 he=fe}Reflect.construct(r,[],be)}else{try{be.call()}catch(fe){he=fe}r.call(be.prototype)}}else{try{throw Error()}catch(fe){he=fe}(be=r())&&typeof be.catch=="function"&&be.catch(function(){})}}catch(fe){if(fe&&he&&typeof fe.stack=="string")return[fe.stack,he.stack]}return[null,null]}};g.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var k=Object.getOwnPropertyDescriptor(g.DetermineComponentFrameRoot,"name");k&&k.configurable&&Object.defineProperty(g.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var j=g.DetermineComponentFrameRoot(),B=j[0],K=j[1];if(B&&K){var ne=B.split(`
45
+ `),de=K.split(`
46
+ `);for(k=g=0;g<ne.length&&!ne[g].includes("DetermineComponentFrameRoot");)g++;for(;k<de.length&&!de[k].includes("DetermineComponentFrameRoot");)k++;if(g===ne.length||k===de.length)for(g=ne.length-1,k=de.length-1;1<=g&&0<=k&&ne[g]!==de[k];)k--;for(;1<=g&&0<=k;g--,k--)if(ne[g]!==de[k]){if(g!==1||k!==1)do if(g--,k--,0>k||ne[g]!==de[k]){var xe=`
47
+ `+ne[g].replace(" at new "," at ");return r.displayName&&xe.includes("<anonymous>")&&(xe=xe.replace("<anonymous>",r.displayName)),xe}while(1<=g&&0<=k);break}}}finally{De=!1,Error.prepareStackTrace=h}return(h=r?r.displayName||r.name:"")?Le(h):""}function Te(r,i){switch(r.tag){case 26:case 27:case 5:return Le(r.type);case 16:return Le("Lazy");case 13:return r.child!==i&&i!==null?Le("Suspense Fallback"):Le("Suspense");case 19:return Le("SuspenseList");case 0:case 15:return Re(r.type,!1);case 11:return Re(r.type.render,!1);case 1:return Re(r.type,!0);case 31:return Le("Activity");default:return""}}function Ae(r){try{var i="",h=null;do i+=Te(r,h),h=r,r=r.return;while(r);return i}catch(g){return`
48
+ Error generating stack: `+g.message+`
49
+ `+g.stack}}var pe=Object.prototype.hasOwnProperty,ce=e.unstable_scheduleCallback,Se=e.unstable_cancelCallback,Ze=e.unstable_shouldYield,_t=e.unstable_requestPaint,dt=e.unstable_now,tn=e.unstable_getCurrentPriorityLevel,ge=e.unstable_ImmediatePriority,Ce=e.unstable_UserBlockingPriority,Ie=e.unstable_NormalPriority,Fe=e.unstable_LowPriority,Ve=e.unstable_IdlePriority,St=e.log,Ye=e.unstable_setDisableYieldValue,wt=null,ct=null;function nn(r){if(typeof St=="function"&&Ye(r),ct&&typeof ct.setStrictMode=="function")try{ct.setStrictMode(wt,r)}catch{}}var ht=Math.clz32?Math.clz32:ot,jn=Math.log,_n=Math.LN2;function ot(r){return r>>>=0,r===0?32:31-(jn(r)/_n|0)|0}var fr=256,Oi=262144,Mi=4194304;function Cr(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,h){var g=r.pendingLanes;if(g===0)return 0;var k=0,j=r.suspendedLanes,B=r.pingedLanes;r=r.warmLanes;var K=g&134217727;return K!==0?(g=K&~j,g!==0?k=Cr(g):(B&=K,B!==0?k=Cr(B):h||(h=K&~r,h!==0&&(k=Cr(h))))):(K=g&~j,K!==0?k=Cr(K):B!==0?k=Cr(B):h||(h=g&~r,h!==0&&(k=Cr(h)))),k===0?0:i!==0&&i!==k&&(i&j)===0&&(j=k&-k,h=i&-i,j>=h||j===32&&(h&4194048)!==0)?i:k}function Xs(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 Nl(){var r=Mi;return Mi<<=1,(Mi&62914560)===0&&(Mi=4194304),r}function Pi(r){for(var i=[],h=0;31>h;h++)i.push(r);return i}function fs(r,i){r.pendingLanes|=i,i!==268435456&&(r.suspendedLanes=0,r.pingedLanes=0,r.warmLanes=0)}function _e(r,i,h,g,k,j){var B=r.pendingLanes;r.pendingLanes=h,r.suspendedLanes=0,r.pingedLanes=0,r.warmLanes=0,r.expiredLanes&=h,r.entangledLanes&=h,r.errorRecoveryDisabledLanes&=h,r.shellSuspendCounter=0;var K=r.entanglements,ne=r.expirationTimes,de=r.hiddenUpdates;for(h=B&~h;0<h;){var xe=31-ht(h),be=1<<xe;K[xe]=0,ne[xe]=-1;var he=de[xe];if(he!==null)for(de[xe]=null,xe=0;xe<he.length;xe++){var fe=he[xe];fe!==null&&(fe.lane&=-536870913)}h&=~be}g!==0&&ve(r,g,0),j!==0&&k===0&&r.tag!==0&&(r.suspendedLanes|=j&~(B&~i))}function ve(r,i,h){r.pendingLanes|=i,r.suspendedLanes&=~i;var g=31-ht(i);r.entangledLanes|=i,r.entanglements[g]=r.entanglements[g]|1073741824|h&261930}function Oe(r,i){var h=r.entangledLanes|=i;for(r=r.entanglements;h;){var g=31-ht(h),k=1<<g;k&i|r[g]&i&&(r[g]|=i),h&=~k}}function $e(r,i){var h=i&-i;return h=(h&42)!==0?1:et(h),(h&(r.suspendedLanes|i))!==0?0:h}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 We(r){return r&=-r,2<r?8<r?(r&134217727)!==0?32:268435456:8:2}function ft(){var r=X.p;return r!==0?r:(r=window.event,r===void 0?32:Xy(r.type))}function fn(r,i){var h=X.p;try{return X.p=r,i()}finally{X.p=h}}var Pt=Math.random().toString(36).slice(2),yt="__reactFiber$"+Pt,Nn="__reactProps$"+Pt,Bi="__reactContainer$"+Pt,pd="__reactEvents$"+Pt,qC="__reactListeners$"+Pt,KC="__reactHandles$"+Pt,fg="__reactResources$"+Pt,Ka="__reactMarker$"+Pt;function gd(r){delete r[yt],delete r[Nn],delete r[pd],delete r[qC],delete r[KC]}function zi(r){var i=r[yt];if(i)return i;for(var h=r.parentNode;h;){if(i=h[Bi]||h[yt]){if(h=i.alternate,i.child!==null||h!==null&&h.child!==null)for(r=Oy(r);r!==null;){if(h=r[yt])return h;r=Oy(r)}return i}r=h,h=r.parentNode}return null}function $i(r){if(r=r[yt]||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 Hi(r){var i=r[fg];return i||(i=r[fg]={hoistableStyles:new Map,hoistableScripts:new Map}),i}function cn(r){r[Ka]=!0}var mg=new Set,pg={};function Qs(r,i){Ui(r,i),Ui(r+"Capture",i)}function Ui(r,i){for(pg[r]=i,r=0;r<i.length;r++)mg.add(i[r])}var YC=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]*$"),gg={},xg={};function XC(r){return pe.call(xg,r)?!0:pe.call(gg,r)?!1:YC.test(r)?xg[r]=!0:(gg[r]=!0,!1)}function Tl(r,i,h){if(XC(i))if(h===null)r.removeAttribute(i);else{switch(typeof h){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,""+h)}}function Al(r,i,h){if(h===null)r.removeAttribute(i);else{switch(typeof h){case"undefined":case"function":case"symbol":case"boolean":r.removeAttribute(i);return}r.setAttribute(i,""+h)}}function zr(r,i,h,g){if(g===null)r.removeAttribute(h);else{switch(typeof g){case"undefined":case"function":case"symbol":case"boolean":r.removeAttribute(h);return}r.setAttributeNS(i,h,""+g)}}function Xn(r){switch(typeof r){case"bigint":case"boolean":case"number":case"string":case"undefined":return r;case"object":return r;default:return""}}function _g(r){var i=r.type;return(r=r.nodeName)&&r.toLowerCase()==="input"&&(i==="checkbox"||i==="radio")}function QC(r,i,h){var g=Object.getOwnPropertyDescriptor(r.constructor.prototype,i);if(!r.hasOwnProperty(i)&&typeof g<"u"&&typeof g.get=="function"&&typeof g.set=="function"){var k=g.get,j=g.set;return Object.defineProperty(r,i,{configurable:!0,get:function(){return k.call(this)},set:function(B){h=""+B,j.call(this,B)}}),Object.defineProperty(r,i,{enumerable:g.enumerable}),{getValue:function(){return h},setValue:function(B){h=""+B},stopTracking:function(){r._valueTracker=null,delete r[i]}}}}function xd(r){if(!r._valueTracker){var i=_g(r)?"checked":"value";r._valueTracker=QC(r,i,""+r[i])}}function yg(r){if(!r)return!1;var i=r._valueTracker;if(!i)return!0;var h=i.getValue(),g="";return r&&(g=_g(r)?r.checked?"true":"false":r.value),r=g,r!==h?(i.setValue(r),!0):!1}function Ll(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 JC=/[\n"\\]/g;function Qn(r){return r.replace(JC,function(i){return"\\"+i.charCodeAt(0).toString(16)+" "})}function _d(r,i,h,g,k,j,B,K){r.name="",B!=null&&typeof B!="function"&&typeof B!="symbol"&&typeof B!="boolean"?r.type=B:r.removeAttribute("type"),i!=null?B==="number"?(i===0&&r.value===""||r.value!=i)&&(r.value=""+Xn(i)):r.value!==""+Xn(i)&&(r.value=""+Xn(i)):B!=="submit"&&B!=="reset"||r.removeAttribute("value"),i!=null?yd(r,B,Xn(i)):h!=null?yd(r,B,Xn(h)):g!=null&&r.removeAttribute("value"),k==null&&j!=null&&(r.defaultChecked=!!j),k!=null&&(r.checked=k&&typeof k!="function"&&typeof k!="symbol"),K!=null&&typeof K!="function"&&typeof K!="symbol"&&typeof K!="boolean"?r.name=""+Xn(K):r.removeAttribute("name")}function vg(r,i,h,g,k,j,B,K){if(j!=null&&typeof j!="function"&&typeof j!="symbol"&&typeof j!="boolean"&&(r.type=j),i!=null||h!=null){if(!(j!=="submit"&&j!=="reset"||i!=null)){xd(r);return}h=h!=null?""+Xn(h):"",i=i!=null?""+Xn(i):h,K||i===r.value||(r.value=i),r.defaultValue=i}g=g??k,g=typeof g!="function"&&typeof g!="symbol"&&!!g,r.checked=K?r.checked:!!g,r.defaultChecked=!!g,B!=null&&typeof B!="function"&&typeof B!="symbol"&&typeof B!="boolean"&&(r.name=B),xd(r)}function yd(r,i,h){i==="number"&&Ll(r.ownerDocument)===r||r.defaultValue===""+h||(r.defaultValue=""+h)}function Fi(r,i,h,g){if(r=r.options,i){i={};for(var k=0;k<h.length;k++)i["$"+h[k]]=!0;for(h=0;h<r.length;h++)k=i.hasOwnProperty("$"+r[h].value),r[h].selected!==k&&(r[h].selected=k),k&&g&&(r[h].defaultSelected=!0)}else{for(h=""+Xn(h),i=null,k=0;k<r.length;k++){if(r[k].value===h){r[k].selected=!0,g&&(r[k].defaultSelected=!0);return}i!==null||r[k].disabled||(i=r[k])}i!==null&&(i.selected=!0)}}function bg(r,i,h){if(i!=null&&(i=""+Xn(i),i!==r.value&&(r.value=i),h==null)){r.defaultValue!==i&&(r.defaultValue=i);return}r.defaultValue=h!=null?""+Xn(h):""}function Sg(r,i,h,g){if(i==null){if(g!=null){if(h!=null)throw Error(s(92));if(V(g)){if(1<g.length)throw Error(s(93));g=g[0]}h=g}h==null&&(h=""),i=h}h=Xn(i),r.defaultValue=h,g=r.textContent,g===h&&g!==""&&g!==null&&(r.value=g),xd(r)}function Vi(r,i){if(i){var h=r.firstChild;if(h&&h===r.lastChild&&h.nodeType===3){h.nodeValue=i;return}}r.textContent=i}var ZC=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 wg(r,i,h){var g=i.indexOf("--")===0;h==null||typeof h=="boolean"||h===""?g?r.setProperty(i,""):i==="float"?r.cssFloat="":r[i]="":g?r.setProperty(i,h):typeof h!="number"||h===0||ZC.has(i)?i==="float"?r.cssFloat=h:r[i]=(""+h).trim():r[i]=h+"px"}function Cg(r,i,h){if(i!=null&&typeof i!="object")throw Error(s(62));if(r=r.style,h!=null){for(var g in h)!h.hasOwnProperty(g)||i!=null&&i.hasOwnProperty(g)||(g.indexOf("--")===0?r.setProperty(g,""):g==="float"?r.cssFloat="":r[g]="");for(var k in i)g=i[k],i.hasOwnProperty(k)&&h[k]!==g&&wg(r,k,g)}else for(var j in i)i.hasOwnProperty(j)&&wg(r,j,i[j])}function vd(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 ek=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"]]),tk=/^[\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 Dl(r){return tk.test(""+r)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":r}function $r(){}var bd=null;function Sd(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 kg(r){var i=$i(r);if(i&&(r=i.stateNode)){var h=r[Nn]||null;e:switch(r=i.stateNode,i.type){case"input":if(_d(r,h.value,h.defaultValue,h.defaultValue,h.checked,h.defaultChecked,h.type,h.name),i=h.name,h.type==="radio"&&i!=null){for(h=r;h.parentNode;)h=h.parentNode;for(h=h.querySelectorAll('input[name="'+Qn(""+i)+'"][type="radio"]'),i=0;i<h.length;i++){var g=h[i];if(g!==r&&g.form===r.form){var k=g[Nn]||null;if(!k)throw Error(s(90));_d(g,k.value,k.defaultValue,k.defaultValue,k.checked,k.defaultChecked,k.type,k.name)}}for(i=0;i<h.length;i++)g=h[i],g.form===r.form&&yg(g)}break e;case"textarea":bg(r,h.value,h.defaultValue);break e;case"select":i=h.value,i!=null&&Fi(r,!!h.multiple,i,!1)}}}var wd=!1;function Eg(r,i,h){if(wd)return r(i,h);wd=!0;try{var g=r(i);return g}finally{if(wd=!1,(Gi!==null||Wi!==null)&&(yc(),Gi&&(i=Gi,r=Wi,Wi=Gi=null,kg(i),r)))for(i=0;i<r.length;i++)kg(r[i])}}function Xa(r,i){var h=r.stateNode;if(h===null)return null;var g=h[Nn]||null;if(g===null)return null;h=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(h&&typeof h!="function")throw Error(s(231,i,typeof h));return h}var Hr=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Cd=!1;if(Hr)try{var Qa={};Object.defineProperty(Qa,"passive",{get:function(){Cd=!0}}),window.addEventListener("test",Qa,Qa),window.removeEventListener("test",Qa,Qa)}catch{Cd=!1}var ms=null,kd=null,Rl=null;function jg(){if(Rl)return Rl;var r,i=kd,h=i.length,g,k="value"in ms?ms.value:ms.textContent,j=k.length;for(r=0;r<h&&i[r]===k[r];r++);var B=h-r;for(g=1;g<=B&&i[h-g]===k[j-g];g++);return Rl=k.slice(r,1<g?1-g:void 0)}function Ol(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 Ml(){return!0}function Ng(){return!1}function Tn(r){function i(h,g,k,j,B){this._reactName=h,this._targetInst=k,this.type=g,this.nativeEvent=j,this.target=B,this.currentTarget=null;for(var K in r)r.hasOwnProperty(K)&&(h=r[K],this[K]=h?h(j):j[K]);return this.isDefaultPrevented=(j.defaultPrevented!=null?j.defaultPrevented:j.returnValue===!1)?Ml:Ng,this.isPropagationStopped=Ng,this}return p(i.prototype,{preventDefault:function(){this.defaultPrevented=!0;var h=this.nativeEvent;h&&(h.preventDefault?h.preventDefault():typeof h.returnValue!="unknown"&&(h.returnValue=!1),this.isDefaultPrevented=Ml)},stopPropagation:function(){var h=this.nativeEvent;h&&(h.stopPropagation?h.stopPropagation():typeof h.cancelBubble!="unknown"&&(h.cancelBubble=!0),this.isPropagationStopped=Ml)},persist:function(){},isPersistent:Ml}),i}var Js={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(r){return r.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Il=Tn(Js),Ja=p({},Js,{view:0,detail:0}),nk=Tn(Ja),Ed,jd,Za,Pl=p({},Ja,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Td,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"?(Ed=r.screenX-Za.screenX,jd=r.screenY-Za.screenY):jd=Ed=0,Za=r),Ed)},movementY:function(r){return"movementY"in r?r.movementY:jd}}),Tg=Tn(Pl),rk=p({},Pl,{dataTransfer:0}),sk=Tn(rk),ik=p({},Ja,{relatedTarget:0}),Nd=Tn(ik),ak=p({},Js,{animationName:0,elapsedTime:0,pseudoElement:0}),ok=Tn(ak),lk=p({},Js,{clipboardData:function(r){return"clipboardData"in r?r.clipboardData:window.clipboardData}}),ck=Tn(lk),uk=p({},Js,{data:0}),Ag=Tn(uk),dk={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},hk={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"},fk={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function mk(r){var i=this.nativeEvent;return i.getModifierState?i.getModifierState(r):(r=fk[r])?!!i[r]:!1}function Td(){return mk}var pk=p({},Ja,{key:function(r){if(r.key){var i=dk[r.key]||r.key;if(i!=="Unidentified")return i}return r.type==="keypress"?(r=Ol(r),r===13?"Enter":String.fromCharCode(r)):r.type==="keydown"||r.type==="keyup"?hk[r.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Td,charCode:function(r){return r.type==="keypress"?Ol(r):0},keyCode:function(r){return r.type==="keydown"||r.type==="keyup"?r.keyCode:0},which:function(r){return r.type==="keypress"?Ol(r):r.type==="keydown"||r.type==="keyup"?r.keyCode:0}}),gk=Tn(pk),xk=p({},Pl,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Lg=Tn(xk),_k=p({},Ja,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Td}),yk=Tn(_k),vk=p({},Js,{propertyName:0,elapsedTime:0,pseudoElement:0}),bk=Tn(vk),Sk=p({},Pl,{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}),wk=Tn(Sk),Ck=p({},Js,{newState:0,oldState:0}),kk=Tn(Ck),Ek=[9,13,27,32],Ad=Hr&&"CompositionEvent"in window,eo=null;Hr&&"documentMode"in document&&(eo=document.documentMode);var jk=Hr&&"TextEvent"in window&&!eo,Dg=Hr&&(!Ad||eo&&8<eo&&11>=eo),Rg=" ",Og=!1;function Mg(r,i){switch(r){case"keyup":return Ek.indexOf(i.keyCode)!==-1;case"keydown":return i.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ig(r){return r=r.detail,typeof r=="object"&&"data"in r?r.data:null}var qi=!1;function Nk(r,i){switch(r){case"compositionend":return Ig(i);case"keypress":return i.which!==32?null:(Og=!0,Rg);case"textInput":return r=i.data,r===Rg&&Og?null:r;default:return null}}function Tk(r,i){if(qi)return r==="compositionend"||!Ad&&Mg(r,i)?(r=jg(),Rl=kd=ms=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 Dg&&i.locale!=="ko"?null:i.data;default:return null}}var Ak={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 Pg(r){var i=r&&r.nodeName&&r.nodeName.toLowerCase();return i==="input"?!!Ak[r.type]:i==="textarea"}function Bg(r,i,h,g){Gi?Wi?Wi.push(g):Wi=[g]:Gi=g,i=Ec(i,"onChange"),0<i.length&&(h=new Il("onChange","change",null,h,g),r.push({event:h,listeners:i}))}var to=null,no=null;function Lk(r){vy(r,0)}function Bl(r){var i=Ya(r);if(yg(i))return r}function zg(r,i){if(r==="change")return i}var $g=!1;if(Hr){var Ld;if(Hr){var Dd="oninput"in document;if(!Dd){var Hg=document.createElement("div");Hg.setAttribute("oninput","return;"),Dd=typeof Hg.oninput=="function"}Ld=Dd}else Ld=!1;$g=Ld&&(!document.documentMode||9<document.documentMode)}function Ug(){to&&(to.detachEvent("onpropertychange",Fg),no=to=null)}function Fg(r){if(r.propertyName==="value"&&Bl(no)){var i=[];Bg(i,no,r,Sd(r)),Eg(Lk,i)}}function Dk(r,i,h){r==="focusin"?(Ug(),to=i,no=h,to.attachEvent("onpropertychange",Fg)):r==="focusout"&&Ug()}function Rk(r){if(r==="selectionchange"||r==="keyup"||r==="keydown")return Bl(no)}function Ok(r,i){if(r==="click")return Bl(i)}function Mk(r,i){if(r==="input"||r==="change")return Bl(i)}function Ik(r,i){return r===i&&(r!==0||1/r===1/i)||r!==r&&i!==i}var Bn=typeof Object.is=="function"?Object.is:Ik;function ro(r,i){if(Bn(r,i))return!0;if(typeof r!="object"||r===null||typeof i!="object"||i===null)return!1;var h=Object.keys(r),g=Object.keys(i);if(h.length!==g.length)return!1;for(g=0;g<h.length;g++){var k=h[g];if(!pe.call(i,k)||!Bn(r[k],i[k]))return!1}return!0}function Vg(r){for(;r&&r.firstChild;)r=r.firstChild;return r}function Gg(r,i){var h=Vg(r);r=0;for(var g;h;){if(h.nodeType===3){if(g=r+h.textContent.length,r<=i&&g>=i)return{node:h,offset:i-r};r=g}e:{for(;h;){if(h.nextSibling){h=h.nextSibling;break e}h=h.parentNode}h=void 0}h=Vg(h)}}function Wg(r,i){return r&&i?r===i?!0:r&&r.nodeType===3?!1:i&&i.nodeType===3?Wg(r,i.parentNode):"contains"in r?r.contains(i):r.compareDocumentPosition?!!(r.compareDocumentPosition(i)&16):!1:!1}function qg(r){r=r!=null&&r.ownerDocument!=null&&r.ownerDocument.defaultView!=null?r.ownerDocument.defaultView:window;for(var i=Ll(r.document);i instanceof r.HTMLIFrameElement;){try{var h=typeof i.contentWindow.location.href=="string"}catch{h=!1}if(h)r=i.contentWindow;else break;i=Ll(r.document)}return i}function Rd(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 Pk=Hr&&"documentMode"in document&&11>=document.documentMode,Ki=null,Od=null,so=null,Md=!1;function Kg(r,i,h){var g=h.window===h?h.document:h.nodeType===9?h:h.ownerDocument;Md||Ki==null||Ki!==Ll(g)||(g=Ki,"selectionStart"in g&&Rd(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=Ec(Od,"onSelect"),0<g.length&&(i=new Il("onSelect","select",null,i,h),r.push({event:i,listeners:g}),i.target=Ki)))}function Zs(r,i){var h={};return h[r.toLowerCase()]=i.toLowerCase(),h["Webkit"+r]="webkit"+i,h["Moz"+r]="moz"+i,h}var Yi={animationend:Zs("Animation","AnimationEnd"),animationiteration:Zs("Animation","AnimationIteration"),animationstart:Zs("Animation","AnimationStart"),transitionrun:Zs("Transition","TransitionRun"),transitionstart:Zs("Transition","TransitionStart"),transitioncancel:Zs("Transition","TransitionCancel"),transitionend:Zs("Transition","TransitionEnd")},Id={},Yg={};Hr&&(Yg=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 ei(r){if(Id[r])return Id[r];if(!Yi[r])return r;var i=Yi[r],h;for(h in i)if(i.hasOwnProperty(h)&&h in Yg)return Id[r]=i[h];return r}var Xg=ei("animationend"),Qg=ei("animationiteration"),Jg=ei("animationstart"),Bk=ei("transitionrun"),zk=ei("transitionstart"),$k=ei("transitioncancel"),Zg=ei("transitionend"),ex=new Map,Pd="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(" ");Pd.push("scrollEnd");function mr(r,i){ex.set(r,i),Qs(i,[r])}var zl=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)},Jn=[],Xi=0,Bd=0;function $l(){for(var r=Xi,i=Bd=Xi=0;i<r;){var h=Jn[i];Jn[i++]=null;var g=Jn[i];Jn[i++]=null;var k=Jn[i];Jn[i++]=null;var j=Jn[i];if(Jn[i++]=null,g!==null&&k!==null){var B=g.pending;B===null?k.next=k:(k.next=B.next,B.next=k),g.pending=k}j!==0&&tx(h,k,j)}}function Hl(r,i,h,g){Jn[Xi++]=r,Jn[Xi++]=i,Jn[Xi++]=h,Jn[Xi++]=g,Bd|=g,r.lanes|=g,r=r.alternate,r!==null&&(r.lanes|=g)}function zd(r,i,h,g){return Hl(r,i,h,g),Ul(r)}function ti(r,i){return Hl(r,null,null,i),Ul(r)}function tx(r,i,h){r.lanes|=h;var g=r.alternate;g!==null&&(g.lanes|=h);for(var k=!1,j=r.return;j!==null;)j.childLanes|=h,g=j.alternate,g!==null&&(g.childLanes|=h),j.tag===22&&(r=j.stateNode,r===null||r._visibility&1||(k=!0)),r=j,j=j.return;return r.tag===3?(j=r.stateNode,k&&i!==null&&(k=31-ht(h),r=j.hiddenUpdates,g=r[k],g===null?r[k]=[i]:g.push(i),i.lane=h|536870912),j):null}function Ul(r){if(50<jo)throw jo=0,Kh=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 Hk(r,i,h,g){this.tag=r,this.key=h,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 zn(r,i,h,g){return new Hk(r,i,h,g)}function $d(r){return r=r.prototype,!(!r||!r.isReactComponent)}function Ur(r,i){var h=r.alternate;return h===null?(h=zn(r.tag,i,r.key,r.mode),h.elementType=r.elementType,h.type=r.type,h.stateNode=r.stateNode,h.alternate=r,r.alternate=h):(h.pendingProps=i,h.type=r.type,h.flags=0,h.subtreeFlags=0,h.deletions=null),h.flags=r.flags&65011712,h.childLanes=r.childLanes,h.lanes=r.lanes,h.child=r.child,h.memoizedProps=r.memoizedProps,h.memoizedState=r.memoizedState,h.updateQueue=r.updateQueue,i=r.dependencies,h.dependencies=i===null?null:{lanes:i.lanes,firstContext:i.firstContext},h.sibling=r.sibling,h.index=r.index,h.ref=r.ref,h.refCleanup=r.refCleanup,h}function nx(r,i){r.flags&=65011714;var h=r.alternate;return h===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=h.childLanes,r.lanes=h.lanes,r.child=h.child,r.subtreeFlags=0,r.deletions=null,r.memoizedProps=h.memoizedProps,r.memoizedState=h.memoizedState,r.updateQueue=h.updateQueue,r.type=h.type,i=h.dependencies,r.dependencies=i===null?null:{lanes:i.lanes,firstContext:i.firstContext}),r}function Fl(r,i,h,g,k,j){var B=0;if(g=r,typeof r=="function")$d(r)&&(B=1);else if(typeof r=="string")B=WE(r,h,ee.current)?26:r==="html"||r==="head"||r==="body"?27:5;else e:switch(r){case R:return r=zn(31,h,i,k),r.elementType=R,r.lanes=j,r;case C:return ni(h.children,k,j,i);case v:B=8,k|=24;break;case S:return r=zn(12,h,i,k|2),r.elementType=S,r.lanes=j,r;case N:return r=zn(13,h,i,k),r.elementType=N,r.lanes=j,r;case T:return r=zn(19,h,i,k),r.elementType=T,r.lanes=j,r;default:if(typeof r=="object"&&r!==null)switch(r.$$typeof){case y:B=10;break e;case b:B=9;break e;case E:B=11;break e;case L:B=14;break e;case A:B=16,g=null;break e}B=29,h=Error(s(130,r===null?"null":typeof r,"")),g=null}return i=zn(B,h,i,k),i.elementType=r,i.type=g,i.lanes=j,i}function ni(r,i,h,g){return r=zn(7,r,g,i),r.lanes=h,r}function Hd(r,i,h){return r=zn(6,r,null,i),r.lanes=h,r}function rx(r){var i=zn(18,null,null,0);return i.stateNode=r,i}function Ud(r,i,h){return i=zn(4,r.children!==null?r.children:[],r.key,i),i.lanes=h,i.stateNode={containerInfo:r.containerInfo,pendingChildren:null,implementation:r.implementation},i}var sx=new WeakMap;function Zn(r,i){if(typeof r=="object"&&r!==null){var h=sx.get(r);return h!==void 0?h:(i={value:r,source:i,stack:Ae(i)},sx.set(r,i),i)}return{value:r,source:i,stack:Ae(i)}}var Ji=[],Zi=0,Vl=null,io=0,er=[],tr=0,ps=null,kr=1,Er="";function Fr(r,i){Ji[Zi++]=io,Ji[Zi++]=Vl,Vl=r,io=i}function ix(r,i,h){er[tr++]=kr,er[tr++]=Er,er[tr++]=ps,ps=r;var g=kr;r=Er;var k=32-ht(g)-1;g&=~(1<<k),h+=1;var j=32-ht(i)+k;if(30<j){var B=k-k%5;j=(g&(1<<B)-1).toString(32),g>>=B,k-=B,kr=1<<32-ht(i)+k|h<<k|g,Er=j+r}else kr=1<<j|h<<k|g,Er=r}function Fd(r){r.return!==null&&(Fr(r,1),ix(r,1,0))}function Vd(r){for(;r===Vl;)Vl=Ji[--Zi],Ji[Zi]=null,io=Ji[--Zi],Ji[Zi]=null;for(;r===ps;)ps=er[--tr],er[tr]=null,Er=er[--tr],er[tr]=null,kr=er[--tr],er[tr]=null}function ax(r,i){er[tr++]=kr,er[tr++]=Er,er[tr++]=ps,kr=i.id,Er=i.overflow,ps=r}var mn=null,Mt=null,lt=!1,gs=null,nr=!1,Gd=Error(s(519));function xs(r){var i=Error(s(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw ao(Zn(i,r)),Gd}function ox(r){var i=r.stateNode,h=r.type,g=r.memoizedProps;switch(i[yt]=r,i[Nn]=g,h){case"dialog":rt("cancel",i),rt("close",i);break;case"iframe":case"object":case"embed":rt("load",i);break;case"video":case"audio":for(h=0;h<To.length;h++)rt(To[h],i);break;case"source":rt("error",i);break;case"img":case"image":case"link":rt("error",i),rt("load",i);break;case"details":rt("toggle",i);break;case"input":rt("invalid",i),vg(i,g.value,g.defaultValue,g.checked,g.defaultChecked,g.type,g.name,!0);break;case"select":rt("invalid",i);break;case"textarea":rt("invalid",i),Sg(i,g.value,g.defaultValue,g.children)}h=g.children,typeof h!="string"&&typeof h!="number"&&typeof h!="bigint"||i.textContent===""+h||g.suppressHydrationWarning===!0||Cy(i.textContent,h)?(g.popover!=null&&(rt("beforetoggle",i),rt("toggle",i)),g.onScroll!=null&&rt("scroll",i),g.onScrollEnd!=null&&rt("scrollend",i),g.onClick!=null&&(i.onclick=$r),i=!0):i=!1,i||xs(r,!0)}function lx(r){for(mn=r.return;mn;)switch(mn.tag){case 5:case 31:case 13:nr=!1;return;case 27:case 3:nr=!0;return;default:mn=mn.return}}function ea(r){if(r!==mn)return!1;if(!lt)return lx(r),lt=!0,!1;var i=r.tag,h;if((h=i!==3&&i!==27)&&((h=i===5)&&(h=r.type,h=!(h!=="form"&&h!=="button")||uf(r.type,r.memoizedProps)),h=!h),h&&Mt&&xs(r),lx(r),i===13){if(r=r.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(s(317));Mt=Ry(r)}else if(i===31){if(r=r.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(s(317));Mt=Ry(r)}else i===27?(i=Mt,Ls(r.type)?(r=pf,pf=null,Mt=r):Mt=i):Mt=mn?sr(r.stateNode.nextSibling):null;return!0}function ri(){Mt=mn=null,lt=!1}function Wd(){var r=gs;return r!==null&&(Rn===null?Rn=r:Rn.push.apply(Rn,r),gs=null),r}function ao(r){gs===null?gs=[r]:gs.push(r)}var qd=$(null),si=null,Vr=null;function _s(r,i,h){P(qd,i._currentValue),i._currentValue=h}function Gr(r){r._currentValue=qd.current,F(qd)}function Kd(r,i,h){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===h)break;r=r.return}}function Yd(r,i,h,g){var k=r.child;for(k!==null&&(k.return=r);k!==null;){var j=k.dependencies;if(j!==null){var B=k.child;j=j.firstContext;e:for(;j!==null;){var K=j;j=k;for(var ne=0;ne<i.length;ne++)if(K.context===i[ne]){j.lanes|=h,K=j.alternate,K!==null&&(K.lanes|=h),Kd(j.return,h,r),g||(B=null);break e}j=K.next}}else if(k.tag===18){if(B=k.return,B===null)throw Error(s(341));B.lanes|=h,j=B.alternate,j!==null&&(j.lanes|=h),Kd(B,h,r),B=null}else B=k.child;if(B!==null)B.return=k;else for(B=k;B!==null;){if(B===r){B=null;break}if(k=B.sibling,k!==null){k.return=B.return,B=k;break}B=B.return}k=B}}function ta(r,i,h,g){r=null;for(var k=i,j=!1;k!==null;){if(!j){if((k.flags&524288)!==0)j=!0;else if((k.flags&262144)!==0)break}if(k.tag===10){var B=k.alternate;if(B===null)throw Error(s(387));if(B=B.memoizedProps,B!==null){var K=k.type;Bn(k.pendingProps.value,B.value)||(r!==null?r.push(K):r=[K])}}else if(k===Y.current){if(B=k.alternate,B===null)throw Error(s(387));B.memoizedState.memoizedState!==k.memoizedState.memoizedState&&(r!==null?r.push(Oo):r=[Oo])}k=k.return}r!==null&&Yd(i,r,h,g),i.flags|=262144}function Gl(r){for(r=r.firstContext;r!==null;){if(!Bn(r.context._currentValue,r.memoizedValue))return!0;r=r.next}return!1}function ii(r){si=r,Vr=null,r=r.dependencies,r!==null&&(r.firstContext=null)}function pn(r){return cx(si,r)}function Wl(r,i){return si===null&&ii(r),cx(r,i)}function cx(r,i){var h=i._currentValue;if(i={context:i,memoizedValue:h,next:null},Vr===null){if(r===null)throw Error(s(308));Vr=i,r.dependencies={lanes:0,firstContext:i},r.flags|=524288}else Vr=Vr.next=i;return h}var Uk=typeof AbortController<"u"?AbortController:function(){var r=[],i=this.signal={aborted:!1,addEventListener:function(h,g){r.push(g)}};this.abort=function(){i.aborted=!0,r.forEach(function(h){return h()})}},Fk=e.unstable_scheduleCallback,Vk=e.unstable_NormalPriority,Kt={$$typeof:y,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Xd(){return{controller:new Uk,data:new Map,refCount:0}}function oo(r){r.refCount--,r.refCount===0&&Fk(Vk,function(){r.controller.abort()})}var lo=null,Qd=0,na=0,ra=null;function Gk(r,i){if(lo===null){var h=lo=[];Qd=0,na=ef(),ra={status:"pending",value:void 0,then:function(g){h.push(g)}}}return Qd++,i.then(ux,ux),i}function ux(){if(--Qd===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 Wk(r,i){var h=[],g={status:"pending",value:null,reason:null,then:function(k){h.push(k)}};return r.then(function(){g.status="fulfilled",g.value=i;for(var k=0;k<h.length;k++)(0,h[k])(i)},function(k){for(g.status="rejected",g.reason=k,k=0;k<h.length;k++)(0,h[k])(void 0)}),g}var dx=z.S;z.S=function(r,i){K_=dt(),typeof i=="object"&&i!==null&&typeof i.then=="function"&&Gk(r,i),dx!==null&&dx(r,i)};var ai=$(null);function Jd(){var r=ai.current;return r!==null?r:Nt.pooledCache}function ql(r,i){i===null?P(ai,ai.current):P(ai,i.pool)}function hx(){var r=Jd();return r===null?null:{parent:Kt._currentValue,pool:r}}var sa=Error(s(460)),Zd=Error(s(474)),Kl=Error(s(542)),Yl={then:function(){}};function fx(r){return r=r.status,r==="fulfilled"||r==="rejected"}function mx(r,i,h){switch(h=r[h],h===void 0?r.push(i):h!==i&&(i.then($r,$r),i=h),i.status){case"fulfilled":return i.value;case"rejected":throw r=i.reason,gx(r),r;default:if(typeof i.status=="string")i.then($r,$r);else{if(r=Nt,r!==null&&100<r.shellSuspendCounter)throw Error(s(482));r=i,r.status="pending",r.then(function(g){if(i.status==="pending"){var k=i;k.status="fulfilled",k.value=g}},function(g){if(i.status==="pending"){var k=i;k.status="rejected",k.reason=g}})}switch(i.status){case"fulfilled":return i.value;case"rejected":throw r=i.reason,gx(r),r}throw li=i,sa}}function oi(r){try{var i=r._init;return i(r._payload)}catch(h){throw h!==null&&typeof h=="object"&&typeof h.then=="function"?(li=h,sa):h}}var li=null;function px(){if(li===null)throw Error(s(459));var r=li;return li=null,r}function gx(r){if(r===sa||r===Kl)throw Error(s(483))}var ia=null,co=0;function Xl(r){var i=co;return co+=1,ia===null&&(ia=[]),mx(ia,r,i)}function uo(r,i){i=i.props.ref,r.ref=i!==void 0?i:null}function Ql(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 xx(r){function i(le,ie){if(r){var ue=le.deletions;ue===null?(le.deletions=[ie],le.flags|=16):ue.push(ie)}}function h(le,ie){if(!r)return null;for(;ie!==null;)i(le,ie),ie=ie.sibling;return null}function g(le){for(var ie=new Map;le!==null;)le.key!==null?ie.set(le.key,le):ie.set(le.index,le),le=le.sibling;return ie}function k(le,ie){return le=Ur(le,ie),le.index=0,le.sibling=null,le}function j(le,ie,ue){return le.index=ue,r?(ue=le.alternate,ue!==null?(ue=ue.index,ue<ie?(le.flags|=67108866,ie):ue):(le.flags|=67108866,ie)):(le.flags|=1048576,ie)}function B(le){return r&&le.alternate===null&&(le.flags|=67108866),le}function K(le,ie,ue,ye){return ie===null||ie.tag!==6?(ie=Hd(ue,le.mode,ye),ie.return=le,ie):(ie=k(ie,ue),ie.return=le,ie)}function ne(le,ie,ue,ye){var Be=ue.type;return Be===C?xe(le,ie,ue.props.children,ye,ue.key):ie!==null&&(ie.elementType===Be||typeof Be=="object"&&Be!==null&&Be.$$typeof===A&&oi(Be)===ie.type)?(ie=k(ie,ue.props),uo(ie,ue),ie.return=le,ie):(ie=Fl(ue.type,ue.key,ue.props,null,le.mode,ye),uo(ie,ue),ie.return=le,ie)}function de(le,ie,ue,ye){return ie===null||ie.tag!==4||ie.stateNode.containerInfo!==ue.containerInfo||ie.stateNode.implementation!==ue.implementation?(ie=Ud(ue,le.mode,ye),ie.return=le,ie):(ie=k(ie,ue.children||[]),ie.return=le,ie)}function xe(le,ie,ue,ye,Be){return ie===null||ie.tag!==7?(ie=ni(ue,le.mode,ye,Be),ie.return=le,ie):(ie=k(ie,ue),ie.return=le,ie)}function be(le,ie,ue){if(typeof ie=="string"&&ie!==""||typeof ie=="number"||typeof ie=="bigint")return ie=Hd(""+ie,le.mode,ue),ie.return=le,ie;if(typeof ie=="object"&&ie!==null){switch(ie.$$typeof){case x:return ue=Fl(ie.type,ie.key,ie.props,null,le.mode,ue),uo(ue,ie),ue.return=le,ue;case w:return ie=Ud(ie,le.mode,ue),ie.return=le,ie;case A:return ie=oi(ie),be(le,ie,ue)}if(V(ie)||W(ie))return ie=ni(ie,le.mode,ue,null),ie.return=le,ie;if(typeof ie.then=="function")return be(le,Xl(ie),ue);if(ie.$$typeof===y)return be(le,Wl(le,ie),ue);Ql(le,ie)}return null}function he(le,ie,ue,ye){var Be=ie!==null?ie.key:null;if(typeof ue=="string"&&ue!==""||typeof ue=="number"||typeof ue=="bigint")return Be!==null?null:K(le,ie,""+ue,ye);if(typeof ue=="object"&&ue!==null){switch(ue.$$typeof){case x:return ue.key===Be?ne(le,ie,ue,ye):null;case w:return ue.key===Be?de(le,ie,ue,ye):null;case A:return ue=oi(ue),he(le,ie,ue,ye)}if(V(ue)||W(ue))return Be!==null?null:xe(le,ie,ue,ye,null);if(typeof ue.then=="function")return he(le,ie,Xl(ue),ye);if(ue.$$typeof===y)return he(le,ie,Wl(le,ue),ye);Ql(le,ue)}return null}function fe(le,ie,ue,ye,Be){if(typeof ye=="string"&&ye!==""||typeof ye=="number"||typeof ye=="bigint")return le=le.get(ue)||null,K(ie,le,""+ye,Be);if(typeof ye=="object"&&ye!==null){switch(ye.$$typeof){case x:return le=le.get(ye.key===null?ue:ye.key)||null,ne(ie,le,ye,Be);case w:return le=le.get(ye.key===null?ue:ye.key)||null,de(ie,le,ye,Be);case A:return ye=oi(ye),fe(le,ie,ue,ye,Be)}if(V(ye)||W(ye))return le=le.get(ue)||null,xe(ie,le,ye,Be,null);if(typeof ye.then=="function")return fe(le,ie,ue,Xl(ye),Be);if(ye.$$typeof===y)return fe(le,ie,ue,Wl(ie,ye),Be);Ql(ie,ye)}return null}function Me(le,ie,ue,ye){for(var Be=null,mt=null,Pe=ie,Xe=ie=0,at=null;Pe!==null&&Xe<ue.length;Xe++){Pe.index>Xe?(at=Pe,Pe=null):at=Pe.sibling;var pt=he(le,Pe,ue[Xe],ye);if(pt===null){Pe===null&&(Pe=at);break}r&&Pe&&pt.alternate===null&&i(le,Pe),ie=j(pt,ie,Xe),mt===null?Be=pt:mt.sibling=pt,mt=pt,Pe=at}if(Xe===ue.length)return h(le,Pe),lt&&Fr(le,Xe),Be;if(Pe===null){for(;Xe<ue.length;Xe++)Pe=be(le,ue[Xe],ye),Pe!==null&&(ie=j(Pe,ie,Xe),mt===null?Be=Pe:mt.sibling=Pe,mt=Pe);return lt&&Fr(le,Xe),Be}for(Pe=g(Pe);Xe<ue.length;Xe++)at=fe(Pe,le,Xe,ue[Xe],ye),at!==null&&(r&&at.alternate!==null&&Pe.delete(at.key===null?Xe:at.key),ie=j(at,ie,Xe),mt===null?Be=at:mt.sibling=at,mt=at);return r&&Pe.forEach(function(Is){return i(le,Is)}),lt&&Fr(le,Xe),Be}function Ue(le,ie,ue,ye){if(ue==null)throw Error(s(151));for(var Be=null,mt=null,Pe=ie,Xe=ie=0,at=null,pt=ue.next();Pe!==null&&!pt.done;Xe++,pt=ue.next()){Pe.index>Xe?(at=Pe,Pe=null):at=Pe.sibling;var Is=he(le,Pe,pt.value,ye);if(Is===null){Pe===null&&(Pe=at);break}r&&Pe&&Is.alternate===null&&i(le,Pe),ie=j(Is,ie,Xe),mt===null?Be=Is:mt.sibling=Is,mt=Is,Pe=at}if(pt.done)return h(le,Pe),lt&&Fr(le,Xe),Be;if(Pe===null){for(;!pt.done;Xe++,pt=ue.next())pt=be(le,pt.value,ye),pt!==null&&(ie=j(pt,ie,Xe),mt===null?Be=pt:mt.sibling=pt,mt=pt);return lt&&Fr(le,Xe),Be}for(Pe=g(Pe);!pt.done;Xe++,pt=ue.next())pt=fe(Pe,le,Xe,pt.value,ye),pt!==null&&(r&&pt.alternate!==null&&Pe.delete(pt.key===null?Xe:pt.key),ie=j(pt,ie,Xe),mt===null?Be=pt:mt.sibling=pt,mt=pt);return r&&Pe.forEach(function(r2){return i(le,r2)}),lt&&Fr(le,Xe),Be}function Et(le,ie,ue,ye){if(typeof ue=="object"&&ue!==null&&ue.type===C&&ue.key===null&&(ue=ue.props.children),typeof ue=="object"&&ue!==null){switch(ue.$$typeof){case x:e:{for(var Be=ue.key;ie!==null;){if(ie.key===Be){if(Be=ue.type,Be===C){if(ie.tag===7){h(le,ie.sibling),ye=k(ie,ue.props.children),ye.return=le,le=ye;break e}}else if(ie.elementType===Be||typeof Be=="object"&&Be!==null&&Be.$$typeof===A&&oi(Be)===ie.type){h(le,ie.sibling),ye=k(ie,ue.props),uo(ye,ue),ye.return=le,le=ye;break e}h(le,ie);break}else i(le,ie);ie=ie.sibling}ue.type===C?(ye=ni(ue.props.children,le.mode,ye,ue.key),ye.return=le,le=ye):(ye=Fl(ue.type,ue.key,ue.props,null,le.mode,ye),uo(ye,ue),ye.return=le,le=ye)}return B(le);case w:e:{for(Be=ue.key;ie!==null;){if(ie.key===Be)if(ie.tag===4&&ie.stateNode.containerInfo===ue.containerInfo&&ie.stateNode.implementation===ue.implementation){h(le,ie.sibling),ye=k(ie,ue.children||[]),ye.return=le,le=ye;break e}else{h(le,ie);break}else i(le,ie);ie=ie.sibling}ye=Ud(ue,le.mode,ye),ye.return=le,le=ye}return B(le);case A:return ue=oi(ue),Et(le,ie,ue,ye)}if(V(ue))return Me(le,ie,ue,ye);if(W(ue)){if(Be=W(ue),typeof Be!="function")throw Error(s(150));return ue=Be.call(ue),Ue(le,ie,ue,ye)}if(typeof ue.then=="function")return Et(le,ie,Xl(ue),ye);if(ue.$$typeof===y)return Et(le,ie,Wl(le,ue),ye);Ql(le,ue)}return typeof ue=="string"&&ue!==""||typeof ue=="number"||typeof ue=="bigint"?(ue=""+ue,ie!==null&&ie.tag===6?(h(le,ie.sibling),ye=k(ie,ue),ye.return=le,le=ye):(h(le,ie),ye=Hd(ue,le.mode,ye),ye.return=le,le=ye),B(le)):h(le,ie)}return function(le,ie,ue,ye){try{co=0;var Be=Et(le,ie,ue,ye);return ia=null,Be}catch(Pe){if(Pe===sa||Pe===Kl)throw Pe;var mt=zn(29,Pe,null,le.mode);return mt.lanes=ye,mt.return=le,mt}finally{}}}var ci=xx(!0),_x=xx(!1),ys=!1;function eh(r){r.updateQueue={baseState:r.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function th(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 vs(r){return{lane:r,tag:0,payload:null,callback:null,next:null}}function bs(r,i,h){var g=r.updateQueue;if(g===null)return null;if(g=g.shared,(xt&2)!==0){var k=g.pending;return k===null?i.next=i:(i.next=k.next,k.next=i),g.pending=i,i=Ul(r),tx(r,null,h),i}return Hl(r,g,i,h),Ul(r)}function ho(r,i,h){if(i=i.updateQueue,i!==null&&(i=i.shared,(h&4194048)!==0)){var g=i.lanes;g&=r.pendingLanes,h|=g,i.lanes=h,Oe(r,h)}}function nh(r,i){var h=r.updateQueue,g=r.alternate;if(g!==null&&(g=g.updateQueue,h===g)){var k=null,j=null;if(h=h.firstBaseUpdate,h!==null){do{var B={lane:h.lane,tag:h.tag,payload:h.payload,callback:null,next:null};j===null?k=j=B:j=j.next=B,h=h.next}while(h!==null);j===null?k=j=i:j=j.next=i}else k=j=i;h={baseState:g.baseState,firstBaseUpdate:k,lastBaseUpdate:j,shared:g.shared,callbacks:g.callbacks},r.updateQueue=h;return}r=h.lastBaseUpdate,r===null?h.firstBaseUpdate=i:r.next=i,h.lastBaseUpdate=i}var rh=!1;function fo(){if(rh){var r=ra;if(r!==null)throw r}}function mo(r,i,h,g){rh=!1;var k=r.updateQueue;ys=!1;var j=k.firstBaseUpdate,B=k.lastBaseUpdate,K=k.shared.pending;if(K!==null){k.shared.pending=null;var ne=K,de=ne.next;ne.next=null,B===null?j=de:B.next=de,B=ne;var xe=r.alternate;xe!==null&&(xe=xe.updateQueue,K=xe.lastBaseUpdate,K!==B&&(K===null?xe.firstBaseUpdate=de:K.next=de,xe.lastBaseUpdate=ne))}if(j!==null){var be=k.baseState;B=0,xe=de=ne=null,K=j;do{var he=K.lane&-536870913,fe=he!==K.lane;if(fe?(it&he)===he:(g&he)===he){he!==0&&he===na&&(rh=!0),xe!==null&&(xe=xe.next={lane:0,tag:K.tag,payload:K.payload,callback:null,next:null});e:{var Me=r,Ue=K;he=i;var Et=h;switch(Ue.tag){case 1:if(Me=Ue.payload,typeof Me=="function"){be=Me.call(Et,be,he);break e}be=Me;break e;case 3:Me.flags=Me.flags&-65537|128;case 0:if(Me=Ue.payload,he=typeof Me=="function"?Me.call(Et,be,he):Me,he==null)break e;be=p({},be,he);break e;case 2:ys=!0}}he=K.callback,he!==null&&(r.flags|=64,fe&&(r.flags|=8192),fe=k.callbacks,fe===null?k.callbacks=[he]:fe.push(he))}else fe={lane:he,tag:K.tag,payload:K.payload,callback:K.callback,next:null},xe===null?(de=xe=fe,ne=be):xe=xe.next=fe,B|=he;if(K=K.next,K===null){if(K=k.shared.pending,K===null)break;fe=K,K=fe.next,fe.next=null,k.lastBaseUpdate=fe,k.shared.pending=null}}while(!0);xe===null&&(ne=be),k.baseState=ne,k.firstBaseUpdate=de,k.lastBaseUpdate=xe,j===null&&(k.shared.lanes=0),Es|=B,r.lanes=B,r.memoizedState=be}}function yx(r,i){if(typeof r!="function")throw Error(s(191,r));r.call(i)}function vx(r,i){var h=r.callbacks;if(h!==null)for(r.callbacks=null,r=0;r<h.length;r++)yx(h[r],i)}var aa=$(null),Jl=$(0);function bx(r,i){r=es,P(Jl,r),P(aa,i),es=r|i.baseLanes}function sh(){P(Jl,es),P(aa,aa.current)}function ih(){es=Jl.current,F(aa),F(Jl)}var $n=$(null),rr=null;function Ss(r){var i=r.alternate;P(Vt,Vt.current&1),P($n,r),rr===null&&(i===null||aa.current!==null||i.memoizedState!==null)&&(rr=r)}function ah(r){P(Vt,Vt.current),P($n,r),rr===null&&(rr=r)}function Sx(r){r.tag===22?(P(Vt,Vt.current),P($n,r),rr===null&&(rr=r)):ws()}function ws(){P(Vt,Vt.current),P($n,$n.current)}function Hn(r){F($n),rr===r&&(rr=null),F(Vt)}var Vt=$(0);function Zl(r){for(var i=r;i!==null;){if(i.tag===13){var h=i.memoizedState;if(h!==null&&(h=h.dehydrated,h===null||ff(h)||mf(h)))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 Wr=0,Ke=null,Ct=null,Yt=null,ec=!1,oa=!1,ui=!1,tc=0,po=0,la=null,qk=0;function Ht(){throw Error(s(321))}function oh(r,i){if(i===null)return!1;for(var h=0;h<i.length&&h<r.length;h++)if(!Bn(r[h],i[h]))return!1;return!0}function lh(r,i,h,g,k,j){return Wr=j,Ke=i,i.memoizedState=null,i.updateQueue=null,i.lanes=0,z.H=r===null||r.memoizedState===null?i_:wh,ui=!1,j=h(g,k),ui=!1,oa&&(j=Cx(i,h,g,k)),wx(r),j}function wx(r){z.H=_o;var i=Ct!==null&&Ct.next!==null;if(Wr=0,Yt=Ct=Ke=null,ec=!1,po=0,la=null,i)throw Error(s(300));r===null||Xt||(r=r.dependencies,r!==null&&Gl(r)&&(Xt=!0))}function Cx(r,i,h,g){Ke=r;var k=0;do{if(oa&&(la=null),po=0,oa=!1,25<=k)throw Error(s(301));if(k+=1,Yt=Ct=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=a_,j=i(h,g)}while(oa);return j}function Kk(){var r=z.H,i=r.useState()[0];return i=typeof i.then=="function"?go(i):i,r=r.useState()[0],(Ct!==null?Ct.memoizedState:null)!==r&&(Ke.flags|=1024),i}function ch(){var r=tc!==0;return tc=0,r}function uh(r,i,h){i.updateQueue=r.updateQueue,i.flags&=-2053,r.lanes&=~h}function dh(r){if(ec){for(r=r.memoizedState;r!==null;){var i=r.queue;i!==null&&(i.pending=null),r=r.next}ec=!1}Wr=0,Yt=Ct=Ke=null,oa=!1,po=tc=0,la=null}function Cn(){var r={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Yt===null?Ke.memoizedState=Yt=r:Yt=Yt.next=r,Yt}function Gt(){if(Ct===null){var r=Ke.alternate;r=r!==null?r.memoizedState:null}else r=Ct.next;var i=Yt===null?Ke.memoizedState:Yt.next;if(i!==null)Yt=i,Ct=r;else{if(r===null)throw Ke.alternate===null?Error(s(467)):Error(s(310));Ct=r,r={memoizedState:Ct.memoizedState,baseState:Ct.baseState,baseQueue:Ct.baseQueue,queue:Ct.queue,next:null},Yt===null?Ke.memoizedState=Yt=r:Yt=Yt.next=r}return Yt}function nc(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function go(r){var i=po;return po+=1,la===null&&(la=[]),r=mx(la,r,i),i=Ke,(Yt===null?i.memoizedState:Yt.next)===null&&(i=i.alternate,z.H=i===null||i.memoizedState===null?i_:wh),r}function rc(r){if(r!==null&&typeof r=="object"){if(typeof r.then=="function")return go(r);if(r.$$typeof===y)return pn(r)}throw Error(s(438,String(r)))}function hh(r){var i=null,h=Ke.updateQueue;if(h!==null&&(i=h.memoCache),i==null){var g=Ke.alternate;g!==null&&(g=g.updateQueue,g!==null&&(g=g.memoCache,g!=null&&(i={data:g.data.map(function(k){return k.slice()}),index:0})))}if(i==null&&(i={data:[],index:0}),h===null&&(h=nc(),Ke.updateQueue=h),h.memoCache=i,h=i.data[i.index],h===void 0)for(h=i.data[i.index]=Array(r),g=0;g<r;g++)h[g]=M;return i.index++,h}function qr(r,i){return typeof i=="function"?i(r):i}function sc(r){var i=Gt();return fh(i,Ct,r)}function fh(r,i,h){var g=r.queue;if(g===null)throw Error(s(311));g.lastRenderedReducer=h;var k=r.baseQueue,j=g.pending;if(j!==null){if(k!==null){var B=k.next;k.next=j.next,j.next=B}i.baseQueue=k=j,g.pending=null}if(j=r.baseState,k===null)r.memoizedState=j;else{i=k.next;var K=B=null,ne=null,de=i,xe=!1;do{var be=de.lane&-536870913;if(be!==de.lane?(it&be)===be:(Wr&be)===be){var he=de.revertLane;if(he===0)ne!==null&&(ne=ne.next={lane:0,revertLane:0,gesture:null,action:de.action,hasEagerState:de.hasEagerState,eagerState:de.eagerState,next:null}),be===na&&(xe=!0);else if((Wr&he)===he){de=de.next,he===na&&(xe=!0);continue}else be={lane:0,revertLane:de.revertLane,gesture:null,action:de.action,hasEagerState:de.hasEagerState,eagerState:de.eagerState,next:null},ne===null?(K=ne=be,B=j):ne=ne.next=be,Ke.lanes|=he,Es|=he;be=de.action,ui&&h(j,be),j=de.hasEagerState?de.eagerState:h(j,be)}else he={lane:be,revertLane:de.revertLane,gesture:de.gesture,action:de.action,hasEagerState:de.hasEagerState,eagerState:de.eagerState,next:null},ne===null?(K=ne=he,B=j):ne=ne.next=he,Ke.lanes|=be,Es|=be;de=de.next}while(de!==null&&de!==i);if(ne===null?B=j:ne.next=K,!Bn(j,r.memoizedState)&&(Xt=!0,xe&&(h=ra,h!==null)))throw h;r.memoizedState=j,r.baseState=B,r.baseQueue=ne,g.lastRenderedState=j}return k===null&&(g.lanes=0),[r.memoizedState,g.dispatch]}function mh(r){var i=Gt(),h=i.queue;if(h===null)throw Error(s(311));h.lastRenderedReducer=r;var g=h.dispatch,k=h.pending,j=i.memoizedState;if(k!==null){h.pending=null;var B=k=k.next;do j=r(j,B.action),B=B.next;while(B!==k);Bn(j,i.memoizedState)||(Xt=!0),i.memoizedState=j,i.baseQueue===null&&(i.baseState=j),h.lastRenderedState=j}return[j,g]}function kx(r,i,h){var g=Ke,k=Gt(),j=lt;if(j){if(h===void 0)throw Error(s(407));h=h()}else h=i();var B=!Bn((Ct||k).memoizedState,h);if(B&&(k.memoizedState=h,Xt=!0),k=k.queue,xh(Nx.bind(null,g,k,r),[r]),k.getSnapshot!==i||B||Yt!==null&&Yt.memoizedState.tag&1){if(g.flags|=2048,ca(9,{destroy:void 0},jx.bind(null,g,k,h,i),null),Nt===null)throw Error(s(349));j||(Wr&127)!==0||Ex(g,i,h)}return h}function Ex(r,i,h){r.flags|=16384,r={getSnapshot:i,value:h},i=Ke.updateQueue,i===null?(i=nc(),Ke.updateQueue=i,i.stores=[r]):(h=i.stores,h===null?i.stores=[r]:h.push(r))}function jx(r,i,h,g){i.value=h,i.getSnapshot=g,Tx(i)&&Ax(r)}function Nx(r,i,h){return h(function(){Tx(i)&&Ax(r)})}function Tx(r){var i=r.getSnapshot;r=r.value;try{var h=i();return!Bn(r,h)}catch{return!0}}function Ax(r){var i=ti(r,2);i!==null&&On(i,r,2)}function ph(r){var i=Cn();if(typeof r=="function"){var h=r;if(r=h(),ui){nn(!0);try{h()}finally{nn(!1)}}}return i.memoizedState=i.baseState=r,i.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:qr,lastRenderedState:r},i}function Lx(r,i,h,g){return r.baseState=h,fh(r,Ct,typeof g=="function"?g:qr)}function Yk(r,i,h,g,k){if(oc(r))throw Error(s(485));if(r=i.action,r!==null){var j={payload:k,action:r,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(B){j.listeners.push(B)}};z.T!==null?h(!0):j.isTransition=!1,g(j),h=i.pending,h===null?(j.next=i.pending=j,Dx(i,j)):(j.next=h.next,i.pending=h.next=j)}}function Dx(r,i){var h=i.action,g=i.payload,k=r.state;if(i.isTransition){var j=z.T,B={};z.T=B;try{var K=h(k,g),ne=z.S;ne!==null&&ne(B,K),Rx(r,i,K)}catch(de){gh(r,i,de)}finally{j!==null&&B.types!==null&&(j.types=B.types),z.T=j}}else try{j=h(k,g),Rx(r,i,j)}catch(de){gh(r,i,de)}}function Rx(r,i,h){h!==null&&typeof h=="object"&&typeof h.then=="function"?h.then(function(g){Ox(r,i,g)},function(g){return gh(r,i,g)}):Ox(r,i,h)}function Ox(r,i,h){i.status="fulfilled",i.value=h,Mx(i),r.state=h,i=r.pending,i!==null&&(h=i.next,h===i?r.pending=null:(h=h.next,i.next=h,Dx(r,h)))}function gh(r,i,h){var g=r.pending;if(r.pending=null,g!==null){g=g.next;do i.status="rejected",i.reason=h,Mx(i),i=i.next;while(i!==g)}r.action=null}function Mx(r){r=r.listeners;for(var i=0;i<r.length;i++)(0,r[i])()}function Ix(r,i){return i}function Px(r,i){if(lt){var h=Nt.formState;if(h!==null){e:{var g=Ke;if(lt){if(Mt){t:{for(var k=Mt,j=nr;k.nodeType!==8;){if(!j){k=null;break t}if(k=sr(k.nextSibling),k===null){k=null;break t}}j=k.data,k=j==="F!"||j==="F"?k:null}if(k){Mt=sr(k.nextSibling),g=k.data==="F!";break e}}xs(g)}g=!1}g&&(i=h[0])}}return h=Cn(),h.memoizedState=h.baseState=i,g={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Ix,lastRenderedState:i},h.queue=g,h=n_.bind(null,Ke,g),g.dispatch=h,g=ph(!1),j=Sh.bind(null,Ke,!1,g.queue),g=Cn(),k={state:i,dispatch:null,action:r,pending:null},g.queue=k,h=Yk.bind(null,Ke,k,j,h),k.dispatch=h,g.memoizedState=r,[i,h,!1]}function Bx(r){var i=Gt();return zx(i,Ct,r)}function zx(r,i,h){if(i=fh(r,i,Ix)[0],r=sc(qr)[0],typeof i=="object"&&i!==null&&typeof i.then=="function")try{var g=go(i)}catch(B){throw B===sa?Kl:B}else g=i;i=Gt();var k=i.queue,j=k.dispatch;return h!==i.memoizedState&&(Ke.flags|=2048,ca(9,{destroy:void 0},Xk.bind(null,k,h),null)),[g,j,r]}function Xk(r,i){r.action=i}function $x(r){var i=Gt(),h=Ct;if(h!==null)return zx(i,h,r);Gt(),i=i.memoizedState,h=Gt();var g=h.queue.dispatch;return h.memoizedState=r,[i,g,!1]}function ca(r,i,h,g){return r={tag:r,create:h,deps:g,inst:i,next:null},i=Ke.updateQueue,i===null&&(i=nc(),Ke.updateQueue=i),h=i.lastEffect,h===null?i.lastEffect=r.next=r:(g=h.next,h.next=r,r.next=g,i.lastEffect=r),r}function Hx(){return Gt().memoizedState}function ic(r,i,h,g){var k=Cn();Ke.flags|=r,k.memoizedState=ca(1|i,{destroy:void 0},h,g===void 0?null:g)}function ac(r,i,h,g){var k=Gt();g=g===void 0?null:g;var j=k.memoizedState.inst;Ct!==null&&g!==null&&oh(g,Ct.memoizedState.deps)?k.memoizedState=ca(i,j,h,g):(Ke.flags|=r,k.memoizedState=ca(1|i,j,h,g))}function Ux(r,i){ic(8390656,8,r,i)}function xh(r,i){ac(2048,8,r,i)}function Qk(r){Ke.flags|=4;var i=Ke.updateQueue;if(i===null)i=nc(),Ke.updateQueue=i,i.events=[r];else{var h=i.events;h===null?i.events=[r]:h.push(r)}}function Fx(r){var i=Gt().memoizedState;return Qk({ref:i,nextImpl:r}),function(){if((xt&2)!==0)throw Error(s(440));return i.impl.apply(void 0,arguments)}}function Vx(r,i){return ac(4,2,r,i)}function Gx(r,i){return ac(4,4,r,i)}function Wx(r,i){if(typeof i=="function"){r=r();var h=i(r);return function(){typeof h=="function"?h():i(null)}}if(i!=null)return r=r(),i.current=r,function(){i.current=null}}function qx(r,i,h){h=h!=null?h.concat([r]):null,ac(4,4,Wx.bind(null,i,r),h)}function _h(){}function Kx(r,i){var h=Gt();i=i===void 0?null:i;var g=h.memoizedState;return i!==null&&oh(i,g[1])?g[0]:(h.memoizedState=[r,i],r)}function Yx(r,i){var h=Gt();i=i===void 0?null:i;var g=h.memoizedState;if(i!==null&&oh(i,g[1]))return g[0];if(g=r(),ui){nn(!0);try{r()}finally{nn(!1)}}return h.memoizedState=[g,i],g}function yh(r,i,h){return h===void 0||(Wr&1073741824)!==0&&(it&261930)===0?r.memoizedState=i:(r.memoizedState=h,r=X_(),Ke.lanes|=r,Es|=r,h)}function Xx(r,i,h,g){return Bn(h,i)?h:aa.current!==null?(r=yh(r,h,g),Bn(r,i)||(Xt=!0),r):(Wr&42)===0||(Wr&1073741824)!==0&&(it&261930)===0?(Xt=!0,r.memoizedState=h):(r=X_(),Ke.lanes|=r,Es|=r,i)}function Qx(r,i,h,g,k){var j=X.p;X.p=j!==0&&8>j?j:8;var B=z.T,K={};z.T=K,Sh(r,!1,i,h);try{var ne=k(),de=z.S;if(de!==null&&de(K,ne),ne!==null&&typeof ne=="object"&&typeof ne.then=="function"){var xe=Wk(ne,g);xo(r,i,xe,Vn(r))}else xo(r,i,g,Vn(r))}catch(be){xo(r,i,{then:function(){},status:"rejected",reason:be},Vn())}finally{X.p=j,B!==null&&K.types!==null&&(B.types=K.types),z.T=B}}function Jk(){}function vh(r,i,h,g){if(r.tag!==5)throw Error(s(476));var k=Jx(r).queue;Qx(r,k,i,te,h===null?Jk:function(){return Zx(r),h(g)})}function Jx(r){var i=r.memoizedState;if(i!==null)return i;i={memoizedState:te,baseState:te,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:qr,lastRenderedState:te},next:null};var h={};return i.next={memoizedState:h,baseState:h,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:qr,lastRenderedState:h},next:null},r.memoizedState=i,r=r.alternate,r!==null&&(r.memoizedState=i),i}function Zx(r){var i=Jx(r);i.next===null&&(i=r.alternate.memoizedState),xo(r,i.next.queue,{},Vn())}function bh(){return pn(Oo)}function e_(){return Gt().memoizedState}function t_(){return Gt().memoizedState}function Zk(r){for(var i=r.return;i!==null;){switch(i.tag){case 24:case 3:var h=Vn();r=vs(h);var g=bs(i,r,h);g!==null&&(On(g,i,h),ho(g,i,h)),i={cache:Xd()},r.payload=i;return}i=i.return}}function eE(r,i,h){var g=Vn();h={lane:g,revertLane:0,gesture:null,action:h,hasEagerState:!1,eagerState:null,next:null},oc(r)?r_(i,h):(h=zd(r,i,h,g),h!==null&&(On(h,r,g),s_(h,i,g)))}function n_(r,i,h){var g=Vn();xo(r,i,h,g)}function xo(r,i,h,g){var k={lane:g,revertLane:0,gesture:null,action:h,hasEagerState:!1,eagerState:null,next:null};if(oc(r))r_(i,k);else{var j=r.alternate;if(r.lanes===0&&(j===null||j.lanes===0)&&(j=i.lastRenderedReducer,j!==null))try{var B=i.lastRenderedState,K=j(B,h);if(k.hasEagerState=!0,k.eagerState=K,Bn(K,B))return Hl(r,i,k,0),Nt===null&&$l(),!1}catch{}finally{}if(h=zd(r,i,k,g),h!==null)return On(h,r,g),s_(h,i,g),!0}return!1}function Sh(r,i,h,g){if(g={lane:2,revertLane:ef(),gesture:null,action:g,hasEagerState:!1,eagerState:null,next:null},oc(r)){if(i)throw Error(s(479))}else i=zd(r,h,g,2),i!==null&&On(i,r,2)}function oc(r){var i=r.alternate;return r===Ke||i!==null&&i===Ke}function r_(r,i){oa=ec=!0;var h=r.pending;h===null?i.next=i:(i.next=h.next,h.next=i),r.pending=i}function s_(r,i,h){if((h&4194048)!==0){var g=i.lanes;g&=r.pendingLanes,h|=g,i.lanes=h,Oe(r,h)}}var _o={readContext:pn,use:rc,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 i_={readContext:pn,use:rc,useCallback:function(r,i){return Cn().memoizedState=[r,i===void 0?null:i],r},useContext:pn,useEffect:Ux,useImperativeHandle:function(r,i,h){h=h!=null?h.concat([r]):null,ic(4194308,4,Wx.bind(null,i,r),h)},useLayoutEffect:function(r,i){return ic(4194308,4,r,i)},useInsertionEffect:function(r,i){ic(4,2,r,i)},useMemo:function(r,i){var h=Cn();i=i===void 0?null:i;var g=r();if(ui){nn(!0);try{r()}finally{nn(!1)}}return h.memoizedState=[g,i],g},useReducer:function(r,i,h){var g=Cn();if(h!==void 0){var k=h(i);if(ui){nn(!0);try{h(i)}finally{nn(!1)}}}else k=i;return g.memoizedState=g.baseState=k,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:r,lastRenderedState:k},g.queue=r,r=r.dispatch=eE.bind(null,Ke,r),[g.memoizedState,r]},useRef:function(r){var i=Cn();return r={current:r},i.memoizedState=r},useState:function(r){r=ph(r);var i=r.queue,h=n_.bind(null,Ke,i);return i.dispatch=h,[r.memoizedState,h]},useDebugValue:_h,useDeferredValue:function(r,i){var h=Cn();return yh(h,r,i)},useTransition:function(){var r=ph(!1);return r=Qx.bind(null,Ke,r.queue,!0,!1),Cn().memoizedState=r,[!1,r]},useSyncExternalStore:function(r,i,h){var g=Ke,k=Cn();if(lt){if(h===void 0)throw Error(s(407));h=h()}else{if(h=i(),Nt===null)throw Error(s(349));(it&127)!==0||Ex(g,i,h)}k.memoizedState=h;var j={value:h,getSnapshot:i};return k.queue=j,Ux(Nx.bind(null,g,j,r),[r]),g.flags|=2048,ca(9,{destroy:void 0},jx.bind(null,g,j,h,i),null),h},useId:function(){var r=Cn(),i=Nt.identifierPrefix;if(lt){var h=Er,g=kr;h=(g&~(1<<32-ht(g)-1)).toString(32)+h,i="_"+i+"R_"+h,h=tc++,0<h&&(i+="H"+h.toString(32)),i+="_"}else h=qk++,i="_"+i+"r_"+h.toString(32)+"_";return r.memoizedState=i},useHostTransitionStatus:bh,useFormState:Px,useActionState:Px,useOptimistic:function(r){var i=Cn();i.memoizedState=i.baseState=r;var h={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return i.queue=h,i=Sh.bind(null,Ke,!0,h),h.dispatch=i,[r,i]},useMemoCache:hh,useCacheRefresh:function(){return Cn().memoizedState=Zk.bind(null,Ke)},useEffectEvent:function(r){var i=Cn(),h={impl:r};return i.memoizedState=h,function(){if((xt&2)!==0)throw Error(s(440));return h.impl.apply(void 0,arguments)}}},wh={readContext:pn,use:rc,useCallback:Kx,useContext:pn,useEffect:xh,useImperativeHandle:qx,useInsertionEffect:Vx,useLayoutEffect:Gx,useMemo:Yx,useReducer:sc,useRef:Hx,useState:function(){return sc(qr)},useDebugValue:_h,useDeferredValue:function(r,i){var h=Gt();return Xx(h,Ct.memoizedState,r,i)},useTransition:function(){var r=sc(qr)[0],i=Gt().memoizedState;return[typeof r=="boolean"?r:go(r),i]},useSyncExternalStore:kx,useId:e_,useHostTransitionStatus:bh,useFormState:Bx,useActionState:Bx,useOptimistic:function(r,i){var h=Gt();return Lx(h,Ct,r,i)},useMemoCache:hh,useCacheRefresh:t_};wh.useEffectEvent=Fx;var a_={readContext:pn,use:rc,useCallback:Kx,useContext:pn,useEffect:xh,useImperativeHandle:qx,useInsertionEffect:Vx,useLayoutEffect:Gx,useMemo:Yx,useReducer:mh,useRef:Hx,useState:function(){return mh(qr)},useDebugValue:_h,useDeferredValue:function(r,i){var h=Gt();return Ct===null?yh(h,r,i):Xx(h,Ct.memoizedState,r,i)},useTransition:function(){var r=mh(qr)[0],i=Gt().memoizedState;return[typeof r=="boolean"?r:go(r),i]},useSyncExternalStore:kx,useId:e_,useHostTransitionStatus:bh,useFormState:$x,useActionState:$x,useOptimistic:function(r,i){var h=Gt();return Ct!==null?Lx(h,Ct,r,i):(h.baseState=r,[r,h.queue.dispatch])},useMemoCache:hh,useCacheRefresh:t_};a_.useEffectEvent=Fx;function Ch(r,i,h,g){i=r.memoizedState,h=h(g,i),h=h==null?i:p({},i,h),r.memoizedState=h,r.lanes===0&&(r.updateQueue.baseState=h)}var kh={enqueueSetState:function(r,i,h){r=r._reactInternals;var g=Vn(),k=vs(g);k.payload=i,h!=null&&(k.callback=h),i=bs(r,k,g),i!==null&&(On(i,r,g),ho(i,r,g))},enqueueReplaceState:function(r,i,h){r=r._reactInternals;var g=Vn(),k=vs(g);k.tag=1,k.payload=i,h!=null&&(k.callback=h),i=bs(r,k,g),i!==null&&(On(i,r,g),ho(i,r,g))},enqueueForceUpdate:function(r,i){r=r._reactInternals;var h=Vn(),g=vs(h);g.tag=2,i!=null&&(g.callback=i),i=bs(r,g,h),i!==null&&(On(i,r,h),ho(i,r,h))}};function o_(r,i,h,g,k,j,B){return r=r.stateNode,typeof r.shouldComponentUpdate=="function"?r.shouldComponentUpdate(g,j,B):i.prototype&&i.prototype.isPureReactComponent?!ro(h,g)||!ro(k,j):!0}function l_(r,i,h,g){r=i.state,typeof i.componentWillReceiveProps=="function"&&i.componentWillReceiveProps(h,g),typeof i.UNSAFE_componentWillReceiveProps=="function"&&i.UNSAFE_componentWillReceiveProps(h,g),i.state!==r&&kh.enqueueReplaceState(i,i.state,null)}function di(r,i){var h=i;if("ref"in i){h={};for(var g in i)g!=="ref"&&(h[g]=i[g])}if(r=r.defaultProps){h===i&&(h=p({},h));for(var k in r)h[k]===void 0&&(h[k]=r[k])}return h}function c_(r){zl(r)}function u_(r){console.error(r)}function d_(r){zl(r)}function lc(r,i){try{var h=r.onUncaughtError;h(i.value,{componentStack:i.stack})}catch(g){setTimeout(function(){throw g})}}function h_(r,i,h){try{var g=r.onCaughtError;g(h.value,{componentStack:h.stack,errorBoundary:i.tag===1?i.stateNode:null})}catch(k){setTimeout(function(){throw k})}}function Eh(r,i,h){return h=vs(h),h.tag=3,h.payload={element:null},h.callback=function(){lc(r,i)},h}function f_(r){return r=vs(r),r.tag=3,r}function m_(r,i,h,g){var k=h.type.getDerivedStateFromError;if(typeof k=="function"){var j=g.value;r.payload=function(){return k(j)},r.callback=function(){h_(i,h,g)}}var B=h.stateNode;B!==null&&typeof B.componentDidCatch=="function"&&(r.callback=function(){h_(i,h,g),typeof k!="function"&&(js===null?js=new Set([this]):js.add(this));var K=g.stack;this.componentDidCatch(g.value,{componentStack:K!==null?K:""})})}function tE(r,i,h,g,k){if(h.flags|=32768,g!==null&&typeof g=="object"&&typeof g.then=="function"){if(i=h.alternate,i!==null&&ta(i,h,k,!0),h=$n.current,h!==null){switch(h.tag){case 31:case 13:return rr===null?vc():h.alternate===null&&Ut===0&&(Ut=3),h.flags&=-257,h.flags|=65536,h.lanes=k,g===Yl?h.flags|=16384:(i=h.updateQueue,i===null?h.updateQueue=new Set([g]):i.add(g),Qh(r,g,k)),!1;case 22:return h.flags|=65536,g===Yl?h.flags|=16384:(i=h.updateQueue,i===null?(i={transitions:null,markerInstances:null,retryQueue:new Set([g])},h.updateQueue=i):(h=i.retryQueue,h===null?i.retryQueue=new Set([g]):h.add(g)),Qh(r,g,k)),!1}throw Error(s(435,h.tag))}return Qh(r,g,k),vc(),!1}if(lt)return i=$n.current,i!==null?((i.flags&65536)===0&&(i.flags|=256),i.flags|=65536,i.lanes=k,g!==Gd&&(r=Error(s(422),{cause:g}),ao(Zn(r,h)))):(g!==Gd&&(i=Error(s(423),{cause:g}),ao(Zn(i,h))),r=r.current.alternate,r.flags|=65536,k&=-k,r.lanes|=k,g=Zn(g,h),k=Eh(r.stateNode,g,k),nh(r,k),Ut!==4&&(Ut=2)),!1;var j=Error(s(520),{cause:g});if(j=Zn(j,h),Eo===null?Eo=[j]:Eo.push(j),Ut!==4&&(Ut=2),i===null)return!0;g=Zn(g,h),h=i;do{switch(h.tag){case 3:return h.flags|=65536,r=k&-k,h.lanes|=r,r=Eh(h.stateNode,g,r),nh(h,r),!1;case 1:if(i=h.type,j=h.stateNode,(h.flags&128)===0&&(typeof i.getDerivedStateFromError=="function"||j!==null&&typeof j.componentDidCatch=="function"&&(js===null||!js.has(j))))return h.flags|=65536,k&=-k,h.lanes|=k,k=f_(k),m_(k,r,h,g),nh(h,k),!1}h=h.return}while(h!==null);return!1}var jh=Error(s(461)),Xt=!1;function gn(r,i,h,g){i.child=r===null?_x(i,null,h,g):ci(i,r.child,h,g)}function p_(r,i,h,g,k){h=h.render;var j=i.ref;if("ref"in g){var B={};for(var K in g)K!=="ref"&&(B[K]=g[K])}else B=g;return ii(i),g=lh(r,i,h,B,j,k),K=ch(),r!==null&&!Xt?(uh(r,i,k),Kr(r,i,k)):(lt&&K&&Fd(i),i.flags|=1,gn(r,i,g,k),i.child)}function g_(r,i,h,g,k){if(r===null){var j=h.type;return typeof j=="function"&&!$d(j)&&j.defaultProps===void 0&&h.compare===null?(i.tag=15,i.type=j,x_(r,i,j,g,k)):(r=Fl(h.type,null,g,i,i.mode,k),r.ref=i.ref,r.return=i,i.child=r)}if(j=r.child,!Mh(r,k)){var B=j.memoizedProps;if(h=h.compare,h=h!==null?h:ro,h(B,g)&&r.ref===i.ref)return Kr(r,i,k)}return i.flags|=1,r=Ur(j,g),r.ref=i.ref,r.return=i,i.child=r}function x_(r,i,h,g,k){if(r!==null){var j=r.memoizedProps;if(ro(j,g)&&r.ref===i.ref)if(Xt=!1,i.pendingProps=g=j,Mh(r,k))(r.flags&131072)!==0&&(Xt=!0);else return i.lanes=r.lanes,Kr(r,i,k)}return Nh(r,i,h,g,k)}function __(r,i,h,g){var k=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|h:h,r!==null){for(g=i.child=r.child,k=0;g!==null;)k=k|g.lanes|g.childLanes,g=g.sibling;g=k&~j}else g=0,i.child=null;return y_(r,i,j,h,g)}if((h&536870912)!==0)i.memoizedState={baseLanes:0,cachePool:null},r!==null&&ql(i,j!==null?j.cachePool:null),j!==null?bx(i,j):sh(),Sx(i);else return g=i.lanes=536870912,y_(r,i,j!==null?j.baseLanes|h:h,h,g)}else j!==null?(ql(i,j.cachePool),bx(i,j),ws(),i.memoizedState=null):(r!==null&&ql(i,null),sh(),ws());return gn(r,i,k,h),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 y_(r,i,h,g,k){var j=Jd();return j=j===null?null:{parent:Kt._currentValue,pool:j},i.memoizedState={baseLanes:h,cachePool:j},r!==null&&ql(i,null),sh(),Sx(i),r!==null&&ta(r,i,g,!0),i.childLanes=k,null}function cc(r,i){return i=dc({mode:i.mode,children:i.children},r.mode),i.ref=r.ref,r.child=i,i.return=r,i}function v_(r,i,h){return ci(i,r.child,null,h),r=cc(i,i.pendingProps),r.flags|=2,Hn(i),i.memoizedState=null,r}function nE(r,i,h){var g=i.pendingProps,k=(i.flags&128)!==0;if(i.flags&=-129,r===null){if(lt){if(g.mode==="hidden")return r=cc(i,g),i.lanes=536870912,yo(null,r);if(ah(i),(r=Mt)?(r=Dy(r,nr),r=r!==null&&r.data==="&"?r:null,r!==null&&(i.memoizedState={dehydrated:r,treeContext:ps!==null?{id:kr,overflow:Er}:null,retryLane:536870912,hydrationErrors:null},h=rx(r),h.return=i,i.child=h,mn=i,Mt=null)):r=null,r===null)throw xs(i);return i.lanes=536870912,null}return cc(i,g)}var j=r.memoizedState;if(j!==null){var B=j.dehydrated;if(ah(i),k)if(i.flags&256)i.flags&=-257,i=v_(r,i,h);else if(i.memoizedState!==null)i.child=r.child,i.flags|=128,i=null;else throw Error(s(558));else if(Xt||ta(r,i,h,!1),k=(h&r.childLanes)!==0,Xt||k){if(g=Nt,g!==null&&(B=$e(g,h),B!==0&&B!==j.retryLane))throw j.retryLane=B,ti(r,B),On(g,r,B),jh;vc(),i=v_(r,i,h)}else r=j.treeContext,Mt=sr(B.nextSibling),mn=i,lt=!0,gs=null,nr=!1,r!==null&&ax(i,r),i=cc(i,g),i.flags|=4096;return i}return r=Ur(r.child,{mode:g.mode,children:g.children}),r.ref=i.ref,i.child=r,r.return=i,r}function uc(r,i){var h=i.ref;if(h===null)r!==null&&r.ref!==null&&(i.flags|=4194816);else{if(typeof h!="function"&&typeof h!="object")throw Error(s(284));(r===null||r.ref!==h)&&(i.flags|=4194816)}}function Nh(r,i,h,g,k){return ii(i),h=lh(r,i,h,g,void 0,k),g=ch(),r!==null&&!Xt?(uh(r,i,k),Kr(r,i,k)):(lt&&g&&Fd(i),i.flags|=1,gn(r,i,h,k),i.child)}function b_(r,i,h,g,k,j){return ii(i),i.updateQueue=null,h=Cx(i,g,h,k),wx(r),g=ch(),r!==null&&!Xt?(uh(r,i,j),Kr(r,i,j)):(lt&&g&&Fd(i),i.flags|=1,gn(r,i,h,j),i.child)}function S_(r,i,h,g,k){if(ii(i),i.stateNode===null){var j=Qi,B=h.contextType;typeof B=="object"&&B!==null&&(j=pn(B)),j=new h(g,j),i.memoizedState=j.state!==null&&j.state!==void 0?j.state:null,j.updater=kh,i.stateNode=j,j._reactInternals=i,j=i.stateNode,j.props=g,j.state=i.memoizedState,j.refs={},eh(i),B=h.contextType,j.context=typeof B=="object"&&B!==null?pn(B):Qi,j.state=i.memoizedState,B=h.getDerivedStateFromProps,typeof B=="function"&&(Ch(i,h,B,g),j.state=i.memoizedState),typeof h.getDerivedStateFromProps=="function"||typeof j.getSnapshotBeforeUpdate=="function"||typeof j.UNSAFE_componentWillMount!="function"&&typeof j.componentWillMount!="function"||(B=j.state,typeof j.componentWillMount=="function"&&j.componentWillMount(),typeof j.UNSAFE_componentWillMount=="function"&&j.UNSAFE_componentWillMount(),B!==j.state&&kh.enqueueReplaceState(j,j.state,null),mo(i,g,j,k),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,ne=di(h,K);j.props=ne;var de=j.context,xe=h.contextType;B=Qi,typeof xe=="object"&&xe!==null&&(B=pn(xe));var be=h.getDerivedStateFromProps;xe=typeof be=="function"||typeof j.getSnapshotBeforeUpdate=="function",K=i.pendingProps!==K,xe||typeof j.UNSAFE_componentWillReceiveProps!="function"&&typeof j.componentWillReceiveProps!="function"||(K||de!==B)&&l_(i,j,g,B),ys=!1;var he=i.memoizedState;j.state=he,mo(i,g,j,k),fo(),de=i.memoizedState,K||he!==de||ys?(typeof be=="function"&&(Ch(i,h,be,g),de=i.memoizedState),(ne=ys||o_(i,h,ne,g,he,de,B))?(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=de),j.props=g,j.state=de,j.context=B,g=ne):(typeof j.componentDidMount=="function"&&(i.flags|=4194308),g=!1)}else{j=i.stateNode,th(r,i),B=i.memoizedProps,xe=di(h,B),j.props=xe,be=i.pendingProps,he=j.context,de=h.contextType,ne=Qi,typeof de=="object"&&de!==null&&(ne=pn(de)),K=h.getDerivedStateFromProps,(de=typeof K=="function"||typeof j.getSnapshotBeforeUpdate=="function")||typeof j.UNSAFE_componentWillReceiveProps!="function"&&typeof j.componentWillReceiveProps!="function"||(B!==be||he!==ne)&&l_(i,j,g,ne),ys=!1,he=i.memoizedState,j.state=he,mo(i,g,j,k),fo();var fe=i.memoizedState;B!==be||he!==fe||ys||r!==null&&r.dependencies!==null&&Gl(r.dependencies)?(typeof K=="function"&&(Ch(i,h,K,g),fe=i.memoizedState),(xe=ys||o_(i,h,xe,g,he,fe,ne)||r!==null&&r.dependencies!==null&&Gl(r.dependencies))?(de||typeof j.UNSAFE_componentWillUpdate!="function"&&typeof j.componentWillUpdate!="function"||(typeof j.componentWillUpdate=="function"&&j.componentWillUpdate(g,fe,ne),typeof j.UNSAFE_componentWillUpdate=="function"&&j.UNSAFE_componentWillUpdate(g,fe,ne)),typeof j.componentDidUpdate=="function"&&(i.flags|=4),typeof j.getSnapshotBeforeUpdate=="function"&&(i.flags|=1024)):(typeof j.componentDidUpdate!="function"||B===r.memoizedProps&&he===r.memoizedState||(i.flags|=4),typeof j.getSnapshotBeforeUpdate!="function"||B===r.memoizedProps&&he===r.memoizedState||(i.flags|=1024),i.memoizedProps=g,i.memoizedState=fe),j.props=g,j.state=fe,j.context=ne,g=xe):(typeof j.componentDidUpdate!="function"||B===r.memoizedProps&&he===r.memoizedState||(i.flags|=4),typeof j.getSnapshotBeforeUpdate!="function"||B===r.memoizedProps&&he===r.memoizedState||(i.flags|=1024),g=!1)}return j=g,uc(r,i),g=(i.flags&128)!==0,j||g?(j=i.stateNode,h=g&&typeof h.getDerivedStateFromError!="function"?null:j.render(),i.flags|=1,r!==null&&g?(i.child=ci(i,r.child,null,k),i.child=ci(i,null,h,k)):gn(r,i,h,k),i.memoizedState=j.state,r=i.child):r=Kr(r,i,k),r}function w_(r,i,h,g){return ri(),i.flags|=256,gn(r,i,h,g),i.child}var Th={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Ah(r){return{baseLanes:r,cachePool:hx()}}function Lh(r,i,h){return r=r!==null?r.childLanes&~h:0,i&&(r|=Fn),r}function C_(r,i,h){var g=i.pendingProps,k=!1,j=(i.flags&128)!==0,B;if((B=j)||(B=r!==null&&r.memoizedState===null?!1:(Vt.current&2)!==0),B&&(k=!0,i.flags&=-129),B=(i.flags&32)!==0,i.flags&=-33,r===null){if(lt){if(k?Ss(i):ws(),(r=Mt)?(r=Dy(r,nr),r=r!==null&&r.data!=="&"?r:null,r!==null&&(i.memoizedState={dehydrated:r,treeContext:ps!==null?{id:kr,overflow:Er}:null,retryLane:536870912,hydrationErrors:null},h=rx(r),h.return=i,i.child=h,mn=i,Mt=null)):r=null,r===null)throw xs(i);return mf(r)?i.lanes=32:i.lanes=536870912,null}var K=g.children;return g=g.fallback,k?(ws(),k=i.mode,K=dc({mode:"hidden",children:K},k),g=ni(g,k,h,null),K.return=i,g.return=i,K.sibling=g,i.child=K,g=i.child,g.memoizedState=Ah(h),g.childLanes=Lh(r,B,h),i.memoizedState=Th,yo(null,g)):(Ss(i),Dh(i,K))}var ne=r.memoizedState;if(ne!==null&&(K=ne.dehydrated,K!==null)){if(j)i.flags&256?(Ss(i),i.flags&=-257,i=Rh(r,i,h)):i.memoizedState!==null?(ws(),i.child=r.child,i.flags|=128,i=null):(ws(),K=g.fallback,k=i.mode,g=dc({mode:"visible",children:g.children},k),K=ni(K,k,h,null),K.flags|=2,g.return=i,K.return=i,g.sibling=K,i.child=g,ci(i,r.child,null,h),g=i.child,g.memoizedState=Ah(h),g.childLanes=Lh(r,B,h),i.memoizedState=Th,i=yo(null,g));else if(Ss(i),mf(K)){if(B=K.nextSibling&&K.nextSibling.dataset,B)var de=B.dgst;B=de,g=Error(s(419)),g.stack="",g.digest=B,ao({value:g,source:null,stack:null}),i=Rh(r,i,h)}else if(Xt||ta(r,i,h,!1),B=(h&r.childLanes)!==0,Xt||B){if(B=Nt,B!==null&&(g=$e(B,h),g!==0&&g!==ne.retryLane))throw ne.retryLane=g,ti(r,g),On(B,r,g),jh;ff(K)||vc(),i=Rh(r,i,h)}else ff(K)?(i.flags|=192,i.child=r.child,i=null):(r=ne.treeContext,Mt=sr(K.nextSibling),mn=i,lt=!0,gs=null,nr=!1,r!==null&&ax(i,r),i=Dh(i,g.children),i.flags|=4096);return i}return k?(ws(),K=g.fallback,k=i.mode,ne=r.child,de=ne.sibling,g=Ur(ne,{mode:"hidden",children:g.children}),g.subtreeFlags=ne.subtreeFlags&65011712,de!==null?K=Ur(de,K):(K=ni(K,k,h,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=Ah(h):(k=K.cachePool,k!==null?(ne=Kt._currentValue,k=k.parent!==ne?{parent:ne,pool:ne}:k):k=hx(),K={baseLanes:K.baseLanes|h,cachePool:k}),g.memoizedState=K,g.childLanes=Lh(r,B,h),i.memoizedState=Th,yo(r.child,g)):(Ss(i),h=r.child,r=h.sibling,h=Ur(h,{mode:"visible",children:g.children}),h.return=i,h.sibling=null,r!==null&&(B=i.deletions,B===null?(i.deletions=[r],i.flags|=16):B.push(r)),i.child=h,i.memoizedState=null,h)}function Dh(r,i){return i=dc({mode:"visible",children:i},r.mode),i.return=r,r.child=i}function dc(r,i){return r=zn(22,r,null,i),r.lanes=0,r}function Rh(r,i,h){return ci(i,r.child,null,h),r=Dh(i,i.pendingProps.children),r.flags|=2,i.memoizedState=null,r}function k_(r,i,h){r.lanes|=i;var g=r.alternate;g!==null&&(g.lanes|=i),Kd(r.return,i,h)}function Oh(r,i,h,g,k,j){var B=r.memoizedState;B===null?r.memoizedState={isBackwards:i,rendering:null,renderingStartTime:0,last:g,tail:h,tailMode:k,treeForkCount:j}:(B.isBackwards=i,B.rendering=null,B.renderingStartTime=0,B.last=g,B.tail=h,B.tailMode=k,B.treeForkCount=j)}function E_(r,i,h){var g=i.pendingProps,k=g.revealOrder,j=g.tail;g=g.children;var B=Vt.current,K=(B&2)!==0;if(K?(B=B&1|2,i.flags|=128):B&=1,P(Vt,B),gn(r,i,g,h),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&&k_(r,h,i);else if(r.tag===19)k_(r,h,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(k){case"forwards":for(h=i.child,k=null;h!==null;)r=h.alternate,r!==null&&Zl(r)===null&&(k=h),h=h.sibling;h=k,h===null?(k=i.child,i.child=null):(k=h.sibling,h.sibling=null),Oh(i,!1,k,h,j,g);break;case"backwards":case"unstable_legacy-backwards":for(h=null,k=i.child,i.child=null;k!==null;){if(r=k.alternate,r!==null&&Zl(r)===null){i.child=k;break}r=k.sibling,k.sibling=h,h=k,k=r}Oh(i,!0,h,null,j,g);break;case"together":Oh(i,!1,null,null,void 0,g);break;default:i.memoizedState=null}return i.child}function Kr(r,i,h){if(r!==null&&(i.dependencies=r.dependencies),Es|=i.lanes,(h&i.childLanes)===0)if(r!==null){if(ta(r,i,h,!1),(h&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,h=Ur(r,r.pendingProps),i.child=h,h.return=i;r.sibling!==null;)r=r.sibling,h=h.sibling=Ur(r,r.pendingProps),h.return=i;h.sibling=null}return i.child}function Mh(r,i){return(r.lanes&i)!==0?!0:(r=r.dependencies,!!(r!==null&&Gl(r)))}function rE(r,i,h){switch(i.tag){case 3:q(i,i.stateNode.containerInfo),_s(i,Kt,r.memoizedState.cache),ri();break;case 27:case 5:ae(i);break;case 4:q(i,i.stateNode.containerInfo);break;case 10:_s(i,i.type,i.memoizedProps.value);break;case 31:if(i.memoizedState!==null)return i.flags|=128,ah(i),null;break;case 13:var g=i.memoizedState;if(g!==null)return g.dehydrated!==null?(Ss(i),i.flags|=128,null):(h&i.child.childLanes)!==0?C_(r,i,h):(Ss(i),r=Kr(r,i,h),r!==null?r.sibling:null);Ss(i);break;case 19:var k=(r.flags&128)!==0;if(g=(h&i.childLanes)!==0,g||(ta(r,i,h,!1),g=(h&i.childLanes)!==0),k){if(g)return E_(r,i,h);i.flags|=128}if(k=i.memoizedState,k!==null&&(k.rendering=null,k.tail=null,k.lastEffect=null),P(Vt,Vt.current),g)break;return null;case 22:return i.lanes=0,__(r,i,h,i.pendingProps);case 24:_s(i,Kt,r.memoizedState.cache)}return Kr(r,i,h)}function j_(r,i,h){if(r!==null)if(r.memoizedProps!==i.pendingProps)Xt=!0;else{if(!Mh(r,h)&&(i.flags&128)===0)return Xt=!1,rE(r,i,h);Xt=(r.flags&131072)!==0}else Xt=!1,lt&&(i.flags&1048576)!==0&&ix(i,io,i.index);switch(i.lanes=0,i.tag){case 16:e:{var g=i.pendingProps;if(r=oi(i.elementType),i.type=r,typeof r=="function")$d(r)?(g=di(r,g),i.tag=1,i=S_(null,i,r,g,h)):(i.tag=0,i=Nh(null,i,r,g,h));else{if(r!=null){var k=r.$$typeof;if(k===E){i.tag=11,i=p_(null,i,r,g,h);break e}else if(k===L){i.tag=14,i=g_(null,i,r,g,h);break e}}throw i=U(r)||r,Error(s(306,i,""))}}return i;case 0:return Nh(r,i,i.type,i.pendingProps,h);case 1:return g=i.type,k=di(g,i.pendingProps),S_(r,i,g,k,h);case 3:e:{if(q(i,i.stateNode.containerInfo),r===null)throw Error(s(387));g=i.pendingProps;var j=i.memoizedState;k=j.element,th(r,i),mo(i,g,null,h);var B=i.memoizedState;if(g=B.cache,_s(i,Kt,g),g!==j.cache&&Yd(i,[Kt],h,!0),fo(),g=B.element,j.isDehydrated)if(j={element:g,isDehydrated:!1,cache:B.cache},i.updateQueue.baseState=j,i.memoizedState=j,i.flags&256){i=w_(r,i,g,h);break e}else if(g!==k){k=Zn(Error(s(424)),i),ao(k),i=w_(r,i,g,h);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(Mt=sr(r.firstChild),mn=i,lt=!0,gs=null,nr=!0,h=_x(i,null,g,h),i.child=h;h;)h.flags=h.flags&-3|4096,h=h.sibling}else{if(ri(),g===k){i=Kr(r,i,h);break e}gn(r,i,g,h)}i=i.child}return i;case 26:return uc(r,i),r===null?(h=By(i.type,null,i.pendingProps,null))?i.memoizedState=h:lt||(h=i.type,r=i.pendingProps,g=jc(re.current).createElement(h),g[yt]=i,g[Nn]=r,xn(g,h,r),cn(g),i.stateNode=g):i.memoizedState=By(i.type,r.memoizedProps,i.pendingProps,r.memoizedState),null;case 27:return ae(i),r===null&&lt&&(g=i.stateNode=My(i.type,i.pendingProps,re.current),mn=i,nr=!0,k=Mt,Ls(i.type)?(pf=k,Mt=sr(g.firstChild)):Mt=k),gn(r,i,i.pendingProps.children,h),uc(r,i),r===null&&(i.flags|=4194304),i.child;case 5:return r===null&&lt&&((k=g=Mt)&&(g=RE(g,i.type,i.pendingProps,nr),g!==null?(i.stateNode=g,mn=i,Mt=sr(g.firstChild),nr=!1,k=!0):k=!1),k||xs(i)),ae(i),k=i.type,j=i.pendingProps,B=r!==null?r.memoizedProps:null,g=j.children,uf(k,j)?g=null:B!==null&&uf(k,B)&&(i.flags|=32),i.memoizedState!==null&&(k=lh(r,i,Kk,null,null,h),Oo._currentValue=k),uc(r,i),gn(r,i,g,h),i.child;case 6:return r===null&&lt&&((r=h=Mt)&&(h=OE(h,i.pendingProps,nr),h!==null?(i.stateNode=h,mn=i,Mt=null,r=!0):r=!1),r||xs(i)),null;case 13:return C_(r,i,h);case 4:return q(i,i.stateNode.containerInfo),g=i.pendingProps,r===null?i.child=ci(i,null,g,h):gn(r,i,g,h),i.child;case 11:return p_(r,i,i.type,i.pendingProps,h);case 7:return gn(r,i,i.pendingProps,h),i.child;case 8:return gn(r,i,i.pendingProps.children,h),i.child;case 12:return gn(r,i,i.pendingProps.children,h),i.child;case 10:return g=i.pendingProps,_s(i,i.type,g.value),gn(r,i,g.children,h),i.child;case 9:return k=i.type._context,g=i.pendingProps.children,ii(i),k=pn(k),g=g(k),i.flags|=1,gn(r,i,g,h),i.child;case 14:return g_(r,i,i.type,i.pendingProps,h);case 15:return x_(r,i,i.type,i.pendingProps,h);case 19:return E_(r,i,h);case 31:return nE(r,i,h);case 22:return __(r,i,h,i.pendingProps);case 24:return ii(i),g=pn(Kt),r===null?(k=Jd(),k===null&&(k=Nt,j=Xd(),k.pooledCache=j,j.refCount++,j!==null&&(k.pooledCacheLanes|=h),k=j),i.memoizedState={parent:g,cache:k},eh(i),_s(i,Kt,k)):((r.lanes&h)!==0&&(th(r,i),mo(i,null,null,h),fo()),k=r.memoizedState,j=i.memoizedState,k.parent!==g?(k={parent:g,cache:g},i.memoizedState=k,i.lanes===0&&(i.memoizedState=i.updateQueue.baseState=k),_s(i,Kt,g)):(g=j.cache,_s(i,Kt,g),g!==k.cache&&Yd(i,[Kt],h,!0))),gn(r,i,i.pendingProps.children,h),i.child;case 29:throw i.pendingProps}throw Error(s(156,i.tag))}function Yr(r){r.flags|=4}function Ih(r,i,h,g,k){if((i=(r.mode&32)!==0)&&(i=!1),i){if(r.flags|=16777216,(k&335544128)===k)if(r.stateNode.complete)r.flags|=8192;else if(ey())r.flags|=8192;else throw li=Yl,Zd}else r.flags&=-16777217}function N_(r,i){if(i.type!=="stylesheet"||(i.state.loading&4)!==0)r.flags&=-16777217;else if(r.flags|=16777216,!Fy(i))if(ey())r.flags|=8192;else throw li=Yl,Zd}function hc(r,i){i!==null&&(r.flags|=4),r.flags&16384&&(i=r.tag!==22?Nl():536870912,r.lanes|=i,fa|=i)}function vo(r,i){if(!lt)switch(r.tailMode){case"hidden":i=r.tail;for(var h=null;i!==null;)i.alternate!==null&&(h=i),i=i.sibling;h===null?r.tail=null:h.sibling=null;break;case"collapsed":h=r.tail;for(var g=null;h!==null;)h.alternate!==null&&(g=h),h=h.sibling;g===null?i||r.tail===null?r.tail=null:r.tail.sibling=null:g.sibling=null}}function It(r){var i=r.alternate!==null&&r.alternate.child===r.child,h=0,g=0;if(i)for(var k=r.child;k!==null;)h|=k.lanes|k.childLanes,g|=k.subtreeFlags&65011712,g|=k.flags&65011712,k.return=r,k=k.sibling;else for(k=r.child;k!==null;)h|=k.lanes|k.childLanes,g|=k.subtreeFlags,g|=k.flags,k.return=r,k=k.sibling;return r.subtreeFlags|=g,r.childLanes=h,i}function sE(r,i,h){var g=i.pendingProps;switch(Vd(i),i.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return It(i),null;case 1:return It(i),null;case 3:return h=i.stateNode,g=null,r!==null&&(g=r.memoizedState.cache),i.memoizedState.cache!==g&&(i.flags|=2048),Gr(Kt),Z(),h.pendingContext&&(h.context=h.pendingContext,h.pendingContext=null),(r===null||r.child===null)&&(ea(i)?Yr(i):r===null||r.memoizedState.isDehydrated&&(i.flags&256)===0||(i.flags|=1024,Wd())),It(i),null;case 26:var k=i.type,j=i.memoizedState;return r===null?(Yr(i),j!==null?(It(i),N_(i,j)):(It(i),Ih(i,k,null,g,h))):j?j!==r.memoizedState?(Yr(i),It(i),N_(i,j)):(It(i),i.flags&=-16777217):(r=r.memoizedProps,r!==g&&Yr(i),It(i),Ih(i,k,r,g,h)),null;case 27:if(se(i),h=re.current,k=i.type,r!==null&&i.stateNode!=null)r.memoizedProps!==g&&Yr(i);else{if(!g){if(i.stateNode===null)throw Error(s(166));return It(i),null}r=ee.current,ea(i)?ox(i):(r=My(k,g,h),i.stateNode=r,Yr(i))}return It(i),null;case 5:if(se(i),k=i.type,r!==null&&i.stateNode!=null)r.memoizedProps!==g&&Yr(i);else{if(!g){if(i.stateNode===null)throw Error(s(166));return It(i),null}if(j=ee.current,ea(i))ox(i);else{var B=jc(re.current);switch(j){case 1:j=B.createElementNS("http://www.w3.org/2000/svg",k);break;case 2:j=B.createElementNS("http://www.w3.org/1998/Math/MathML",k);break;default:switch(k){case"svg":j=B.createElementNS("http://www.w3.org/2000/svg",k);break;case"math":j=B.createElementNS("http://www.w3.org/1998/Math/MathML",k);break;case"script":j=B.createElement("div"),j.innerHTML="<script><\/script>",j=j.removeChild(j.firstChild);break;case"select":j=typeof g.is=="string"?B.createElement("select",{is:g.is}):B.createElement("select"),g.multiple?j.multiple=!0:g.size&&(j.size=g.size);break;default:j=typeof g.is=="string"?B.createElement(k,{is:g.is}):B.createElement(k)}}j[yt]=i,j[Nn]=g;e:for(B=i.child;B!==null;){if(B.tag===5||B.tag===6)j.appendChild(B.stateNode);else if(B.tag!==4&&B.tag!==27&&B.child!==null){B.child.return=B,B=B.child;continue}if(B===i)break e;for(;B.sibling===null;){if(B.return===null||B.return===i)break e;B=B.return}B.sibling.return=B.return,B=B.sibling}i.stateNode=j;e:switch(xn(j,k,g),k){case"button":case"input":case"select":case"textarea":g=!!g.autoFocus;break e;case"img":g=!0;break e;default:g=!1}g&&Yr(i)}}return It(i),Ih(i,i.type,r===null?null:r.memoizedProps,i.pendingProps,h),null;case 6:if(r&&i.stateNode!=null)r.memoizedProps!==g&&Yr(i);else{if(typeof g!="string"&&i.stateNode===null)throw Error(s(166));if(r=re.current,ea(i)){if(r=i.stateNode,h=i.memoizedProps,g=null,k=mn,k!==null)switch(k.tag){case 27:case 5:g=k.memoizedProps}r[yt]=i,r=!!(r.nodeValue===h||g!==null&&g.suppressHydrationWarning===!0||Cy(r.nodeValue,h)),r||xs(i,!0)}else r=jc(r).createTextNode(g),r[yt]=i,i.stateNode=r}return It(i),null;case 31:if(h=i.memoizedState,r===null||r.memoizedState!==null){if(g=ea(i),h!==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[yt]=i}else ri(),(i.flags&128)===0&&(i.memoizedState=null),i.flags|=4;It(i),r=!1}else h=Wd(),r!==null&&r.memoizedState!==null&&(r.memoizedState.hydrationErrors=h),r=!0;if(!r)return i.flags&256?(Hn(i),i):(Hn(i),null);if((i.flags&128)!==0)throw Error(s(558))}return It(i),null;case 13:if(g=i.memoizedState,r===null||r.memoizedState!==null&&r.memoizedState.dehydrated!==null){if(k=ea(i),g!==null&&g.dehydrated!==null){if(r===null){if(!k)throw Error(s(318));if(k=i.memoizedState,k=k!==null?k.dehydrated:null,!k)throw Error(s(317));k[yt]=i}else ri(),(i.flags&128)===0&&(i.memoizedState=null),i.flags|=4;It(i),k=!1}else k=Wd(),r!==null&&r.memoizedState!==null&&(r.memoizedState.hydrationErrors=k),k=!0;if(!k)return i.flags&256?(Hn(i),i):(Hn(i),null)}return Hn(i),(i.flags&128)!==0?(i.lanes=h,i):(h=g!==null,r=r!==null&&r.memoizedState!==null,h&&(g=i.child,k=null,g.alternate!==null&&g.alternate.memoizedState!==null&&g.alternate.memoizedState.cachePool!==null&&(k=g.alternate.memoizedState.cachePool.pool),j=null,g.memoizedState!==null&&g.memoizedState.cachePool!==null&&(j=g.memoizedState.cachePool.pool),j!==k&&(g.flags|=2048)),h!==r&&h&&(i.child.flags|=8192),hc(i,i.updateQueue),It(i),null);case 4:return Z(),r===null&&sf(i.stateNode.containerInfo),It(i),null;case 10:return Gr(i.type),It(i),null;case 19:if(F(Vt),g=i.memoizedState,g===null)return It(i),null;if(k=(i.flags&128)!==0,j=g.rendering,j===null)if(k)vo(g,!1);else{if(Ut!==0||r!==null&&(r.flags&128)!==0)for(r=i.child;r!==null;){if(j=Zl(r),j!==null){for(i.flags|=128,vo(g,!1),r=j.updateQueue,i.updateQueue=r,hc(i,r),i.subtreeFlags=0,r=h,h=i.child;h!==null;)nx(h,r),h=h.sibling;return P(Vt,Vt.current&1|2),lt&&Fr(i,g.treeForkCount),i.child}r=r.sibling}g.tail!==null&&dt()>xc&&(i.flags|=128,k=!0,vo(g,!1),i.lanes=4194304)}else{if(!k)if(r=Zl(j),r!==null){if(i.flags|=128,k=!0,r=r.updateQueue,i.updateQueue=r,hc(i,r),vo(g,!0),g.tail===null&&g.tailMode==="hidden"&&!j.alternate&&!lt)return It(i),null}else 2*dt()-g.renderingStartTime>xc&&h!==536870912&&(i.flags|=128,k=!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=dt(),r.sibling=null,h=Vt.current,P(Vt,k?h&1|2:h&1),lt&&Fr(i,g.treeForkCount),r):(It(i),null);case 22:case 23:return Hn(i),ih(),g=i.memoizedState!==null,r!==null?r.memoizedState!==null!==g&&(i.flags|=8192):g&&(i.flags|=8192),g?(h&536870912)!==0&&(i.flags&128)===0&&(It(i),i.subtreeFlags&6&&(i.flags|=8192)):It(i),h=i.updateQueue,h!==null&&hc(i,h.retryQueue),h=null,r!==null&&r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(h=r.memoizedState.cachePool.pool),g=null,i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(g=i.memoizedState.cachePool.pool),g!==h&&(i.flags|=2048),r!==null&&F(ai),null;case 24:return h=null,r!==null&&(h=r.memoizedState.cache),i.memoizedState.cache!==h&&(i.flags|=2048),Gr(Kt),It(i),null;case 25:return null;case 30:return null}throw Error(s(156,i.tag))}function iE(r,i){switch(Vd(i),i.tag){case 1:return r=i.flags,r&65536?(i.flags=r&-65537|128,i):null;case 3:return Gr(Kt),Z(),r=i.flags,(r&65536)!==0&&(r&128)===0?(i.flags=r&-65537|128,i):null;case 26:case 27:case 5:return se(i),null;case 31:if(i.memoizedState!==null){if(Hn(i),i.alternate===null)throw Error(s(340));ri()}return r=i.flags,r&65536?(i.flags=r&-65537|128,i):null;case 13:if(Hn(i),r=i.memoizedState,r!==null&&r.dehydrated!==null){if(i.alternate===null)throw Error(s(340));ri()}return r=i.flags,r&65536?(i.flags=r&-65537|128,i):null;case 19:return F(Vt),null;case 4:return Z(),null;case 10:return Gr(i.type),null;case 22:case 23:return Hn(i),ih(),r!==null&&F(ai),r=i.flags,r&65536?(i.flags=r&-65537|128,i):null;case 24:return Gr(Kt),null;case 25:return null;default:return null}}function T_(r,i){switch(Vd(i),i.tag){case 3:Gr(Kt),Z();break;case 26:case 27:case 5:se(i);break;case 4:Z();break;case 31:i.memoizedState!==null&&Hn(i);break;case 13:Hn(i);break;case 19:F(Vt);break;case 10:Gr(i.type);break;case 22:case 23:Hn(i),ih(),r!==null&&F(ai);break;case 24:Gr(Kt)}}function bo(r,i){try{var h=i.updateQueue,g=h!==null?h.lastEffect:null;if(g!==null){var k=g.next;h=k;do{if((h.tag&r)===r){g=void 0;var j=h.create,B=h.inst;g=j(),B.destroy=g}h=h.next}while(h!==k)}}catch(K){bt(i,i.return,K)}}function Cs(r,i,h){try{var g=i.updateQueue,k=g!==null?g.lastEffect:null;if(k!==null){var j=k.next;g=j;do{if((g.tag&r)===r){var B=g.inst,K=B.destroy;if(K!==void 0){B.destroy=void 0,k=i;var ne=h,de=K;try{de()}catch(xe){bt(k,ne,xe)}}}g=g.next}while(g!==j)}}catch(xe){bt(i,i.return,xe)}}function A_(r){var i=r.updateQueue;if(i!==null){var h=r.stateNode;try{vx(i,h)}catch(g){bt(r,r.return,g)}}}function L_(r,i,h){h.props=di(r.type,r.memoizedProps),h.state=r.memoizedState;try{h.componentWillUnmount()}catch(g){bt(r,i,g)}}function So(r,i){try{var h=r.ref;if(h!==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 h=="function"?r.refCleanup=h(g):h.current=g}}catch(k){bt(r,i,k)}}function jr(r,i){var h=r.ref,g=r.refCleanup;if(h!==null)if(typeof g=="function")try{g()}catch(k){bt(r,i,k)}finally{r.refCleanup=null,r=r.alternate,r!=null&&(r.refCleanup=null)}else if(typeof h=="function")try{h(null)}catch(k){bt(r,i,k)}else h.current=null}function D_(r){var i=r.type,h=r.memoizedProps,g=r.stateNode;try{e:switch(i){case"button":case"input":case"select":case"textarea":h.autoFocus&&g.focus();break e;case"img":h.src?g.src=h.src:h.srcSet&&(g.srcset=h.srcSet)}}catch(k){bt(r,r.return,k)}}function Ph(r,i,h){try{var g=r.stateNode;jE(g,r.type,h,i),g[Nn]=i}catch(k){bt(r,r.return,k)}}function R_(r){return r.tag===5||r.tag===3||r.tag===26||r.tag===27&&Ls(r.type)||r.tag===4}function Bh(r){e:for(;;){for(;r.sibling===null;){if(r.return===null||R_(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&&Ls(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 zh(r,i,h){var g=r.tag;if(g===5||g===6)r=r.stateNode,i?(h.nodeType===9?h.body:h.nodeName==="HTML"?h.ownerDocument.body:h).insertBefore(r,i):(i=h.nodeType===9?h.body:h.nodeName==="HTML"?h.ownerDocument.body:h,i.appendChild(r),h=h._reactRootContainer,h!=null||i.onclick!==null||(i.onclick=$r));else if(g!==4&&(g===27&&Ls(r.type)&&(h=r.stateNode,i=null),r=r.child,r!==null))for(zh(r,i,h),r=r.sibling;r!==null;)zh(r,i,h),r=r.sibling}function fc(r,i,h){var g=r.tag;if(g===5||g===6)r=r.stateNode,i?h.insertBefore(r,i):h.appendChild(r);else if(g!==4&&(g===27&&Ls(r.type)&&(h=r.stateNode),r=r.child,r!==null))for(fc(r,i,h),r=r.sibling;r!==null;)fc(r,i,h),r=r.sibling}function O_(r){var i=r.stateNode,h=r.memoizedProps;try{for(var g=r.type,k=i.attributes;k.length;)i.removeAttributeNode(k[0]);xn(i,g,h),i[yt]=r,i[Nn]=h}catch(j){bt(r,r.return,j)}}var Xr=!1,Qt=!1,$h=!1,M_=typeof WeakSet=="function"?WeakSet:Set,un=null;function aE(r,i){if(r=r.containerInfo,lf=Oc,r=qg(r),Rd(r)){if("selectionStart"in r)var h={start:r.selectionStart,end:r.selectionEnd};else e:{h=(h=r.ownerDocument)&&h.defaultView||window;var g=h.getSelection&&h.getSelection();if(g&&g.rangeCount!==0){h=g.anchorNode;var k=g.anchorOffset,j=g.focusNode;g=g.focusOffset;try{h.nodeType,j.nodeType}catch{h=null;break e}var B=0,K=-1,ne=-1,de=0,xe=0,be=r,he=null;t:for(;;){for(var fe;be!==h||k!==0&&be.nodeType!==3||(K=B+k),be!==j||g!==0&&be.nodeType!==3||(ne=B+g),be.nodeType===3&&(B+=be.nodeValue.length),(fe=be.firstChild)!==null;)he=be,be=fe;for(;;){if(be===r)break t;if(he===h&&++de===k&&(K=B),he===j&&++xe===g&&(ne=B),(fe=be.nextSibling)!==null)break;be=he,he=be.parentNode}be=fe}h=K===-1||ne===-1?null:{start:K,end:ne}}else h=null}h=h||{start:0,end:0}}else h=null;for(cf={focusedElem:r,selectionRange:h},Oc=!1,un=i;un!==null;)if(i=un,r=i.child,(i.subtreeFlags&1028)!==0&&r!==null)r.return=i,un=r;else for(;un!==null;){switch(i=un,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(h=0;h<r.length;h++)k=r[h],k.ref.impl=k.nextImpl;break;case 11:case 15:break;case 1:if((r&1024)!==0&&j!==null){r=void 0,h=i,k=j.memoizedProps,j=j.memoizedState,g=h.stateNode;try{var Me=di(h.type,k);r=g.getSnapshotBeforeUpdate(Me,j),g.__reactInternalSnapshotBeforeUpdate=r}catch(Ue){bt(h,h.return,Ue)}}break;case 3:if((r&1024)!==0){if(r=i.stateNode.containerInfo,h=r.nodeType,h===9)hf(r);else if(h===1)switch(r.nodeName){case"HEAD":case"HTML":case"BODY":hf(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,un=r;break}un=i.return}}function I_(r,i,h){var g=h.flags;switch(h.tag){case 0:case 11:case 15:Jr(r,h),g&4&&bo(5,h);break;case 1:if(Jr(r,h),g&4)if(r=h.stateNode,i===null)try{r.componentDidMount()}catch(B){bt(h,h.return,B)}else{var k=di(h.type,i.memoizedProps);i=i.memoizedState;try{r.componentDidUpdate(k,i,r.__reactInternalSnapshotBeforeUpdate)}catch(B){bt(h,h.return,B)}}g&64&&A_(h),g&512&&So(h,h.return);break;case 3:if(Jr(r,h),g&64&&(r=h.updateQueue,r!==null)){if(i=null,h.child!==null)switch(h.child.tag){case 27:case 5:i=h.child.stateNode;break;case 1:i=h.child.stateNode}try{vx(r,i)}catch(B){bt(h,h.return,B)}}break;case 27:i===null&&g&4&&O_(h);case 26:case 5:Jr(r,h),i===null&&g&4&&D_(h),g&512&&So(h,h.return);break;case 12:Jr(r,h);break;case 31:Jr(r,h),g&4&&z_(r,h);break;case 13:Jr(r,h),g&4&&$_(r,h),g&64&&(r=h.memoizedState,r!==null&&(r=r.dehydrated,r!==null&&(h=pE.bind(null,h),ME(r,h))));break;case 22:if(g=h.memoizedState!==null||Xr,!g){i=i!==null&&i.memoizedState!==null||Qt,k=Xr;var j=Qt;Xr=g,(Qt=i)&&!j?Zr(r,h,(h.subtreeFlags&8772)!==0):Jr(r,h),Xr=k,Qt=j}break;case 30:break;default:Jr(r,h)}}function P_(r){var i=r.alternate;i!==null&&(r.alternate=null,P_(i)),r.child=null,r.deletions=null,r.sibling=null,r.tag===5&&(i=r.stateNode,i!==null&&gd(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 Bt=null,An=!1;function Qr(r,i,h){for(h=h.child;h!==null;)B_(r,i,h),h=h.sibling}function B_(r,i,h){if(ct&&typeof ct.onCommitFiberUnmount=="function")try{ct.onCommitFiberUnmount(wt,h)}catch{}switch(h.tag){case 26:Qt||jr(h,i),Qr(r,i,h),h.memoizedState?h.memoizedState.count--:h.stateNode&&(h=h.stateNode,h.parentNode.removeChild(h));break;case 27:Qt||jr(h,i);var g=Bt,k=An;Ls(h.type)&&(Bt=h.stateNode,An=!1),Qr(r,i,h),Lo(h.stateNode),Bt=g,An=k;break;case 5:Qt||jr(h,i);case 6:if(g=Bt,k=An,Bt=null,Qr(r,i,h),Bt=g,An=k,Bt!==null)if(An)try{(Bt.nodeType===9?Bt.body:Bt.nodeName==="HTML"?Bt.ownerDocument.body:Bt).removeChild(h.stateNode)}catch(j){bt(h,i,j)}else try{Bt.removeChild(h.stateNode)}catch(j){bt(h,i,j)}break;case 18:Bt!==null&&(An?(r=Bt,Ay(r.nodeType===9?r.body:r.nodeName==="HTML"?r.ownerDocument.body:r,h.stateNode),ba(r)):Ay(Bt,h.stateNode));break;case 4:g=Bt,k=An,Bt=h.stateNode.containerInfo,An=!0,Qr(r,i,h),Bt=g,An=k;break;case 0:case 11:case 14:case 15:Cs(2,h,i),Qt||Cs(4,h,i),Qr(r,i,h);break;case 1:Qt||(jr(h,i),g=h.stateNode,typeof g.componentWillUnmount=="function"&&L_(h,i,g)),Qr(r,i,h);break;case 21:Qr(r,i,h);break;case 22:Qt=(g=Qt)||h.memoizedState!==null,Qr(r,i,h),Qt=g;break;default:Qr(r,i,h)}}function z_(r,i){if(i.memoizedState===null&&(r=i.alternate,r!==null&&(r=r.memoizedState,r!==null))){r=r.dehydrated;try{ba(r)}catch(h){bt(i,i.return,h)}}}function $_(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(h){bt(i,i.return,h)}}function oE(r){switch(r.tag){case 31:case 13:case 19:var i=r.stateNode;return i===null&&(i=r.stateNode=new M_),i;case 22:return r=r.stateNode,i=r._retryCache,i===null&&(i=r._retryCache=new M_),i;default:throw Error(s(435,r.tag))}}function mc(r,i){var h=oE(r);i.forEach(function(g){if(!h.has(g)){h.add(g);var k=gE.bind(null,r,g);g.then(k,k)}})}function Ln(r,i){var h=i.deletions;if(h!==null)for(var g=0;g<h.length;g++){var k=h[g],j=r,B=i,K=B;e:for(;K!==null;){switch(K.tag){case 27:if(Ls(K.type)){Bt=K.stateNode,An=!1;break e}break;case 5:Bt=K.stateNode,An=!1;break e;case 3:case 4:Bt=K.stateNode.containerInfo,An=!0;break e}K=K.return}if(Bt===null)throw Error(s(160));B_(j,B,k),Bt=null,An=!1,j=k.alternate,j!==null&&(j.return=null),k.return=null}if(i.subtreeFlags&13886)for(i=i.child;i!==null;)H_(i,r),i=i.sibling}var pr=null;function H_(r,i){var h=r.alternate,g=r.flags;switch(r.tag){case 0:case 11:case 14:case 15:Ln(i,r),Dn(r),g&4&&(Cs(3,r,r.return),bo(3,r),Cs(5,r,r.return));break;case 1:Ln(i,r),Dn(r),g&512&&(Qt||h===null||jr(h,h.return)),g&64&&Xr&&(r=r.updateQueue,r!==null&&(g=r.callbacks,g!==null&&(h=r.shared.hiddenCallbacks,r.shared.hiddenCallbacks=h===null?g:h.concat(g))));break;case 26:var k=pr;if(Ln(i,r),Dn(r),g&512&&(Qt||h===null||jr(h,h.return)),g&4){var j=h!==null?h.memoizedState:null;if(g=r.memoizedState,h===null)if(g===null)if(r.stateNode===null){e:{g=r.type,h=r.memoizedProps,k=k.ownerDocument||k;t:switch(g){case"title":j=k.getElementsByTagName("title")[0],(!j||j[Ka]||j[yt]||j.namespaceURI==="http://www.w3.org/2000/svg"||j.hasAttribute("itemprop"))&&(j=k.createElement(g),k.head.insertBefore(j,k.querySelector("head > title"))),xn(j,g,h),j[yt]=r,cn(j),g=j;break e;case"link":var B=Hy("link","href",k).get(g+(h.href||""));if(B){for(var K=0;K<B.length;K++)if(j=B[K],j.getAttribute("href")===(h.href==null||h.href===""?null:h.href)&&j.getAttribute("rel")===(h.rel==null?null:h.rel)&&j.getAttribute("title")===(h.title==null?null:h.title)&&j.getAttribute("crossorigin")===(h.crossOrigin==null?null:h.crossOrigin)){B.splice(K,1);break t}}j=k.createElement(g),xn(j,g,h),k.head.appendChild(j);break;case"meta":if(B=Hy("meta","content",k).get(g+(h.content||""))){for(K=0;K<B.length;K++)if(j=B[K],j.getAttribute("content")===(h.content==null?null:""+h.content)&&j.getAttribute("name")===(h.name==null?null:h.name)&&j.getAttribute("property")===(h.property==null?null:h.property)&&j.getAttribute("http-equiv")===(h.httpEquiv==null?null:h.httpEquiv)&&j.getAttribute("charset")===(h.charSet==null?null:h.charSet)){B.splice(K,1);break t}}j=k.createElement(g),xn(j,g,h),k.head.appendChild(j);break;default:throw Error(s(468,g))}j[yt]=r,cn(j),g=j}r.stateNode=g}else Uy(k,r.type,r.stateNode);else r.stateNode=$y(k,g,r.memoizedProps);else j!==g?(j===null?h.stateNode!==null&&(h=h.stateNode,h.parentNode.removeChild(h)):j.count--,g===null?Uy(k,r.type,r.stateNode):$y(k,g,r.memoizedProps)):g===null&&r.stateNode!==null&&Ph(r,r.memoizedProps,h.memoizedProps)}break;case 27:Ln(i,r),Dn(r),g&512&&(Qt||h===null||jr(h,h.return)),h!==null&&g&4&&Ph(r,r.memoizedProps,h.memoizedProps);break;case 5:if(Ln(i,r),Dn(r),g&512&&(Qt||h===null||jr(h,h.return)),r.flags&32){k=r.stateNode;try{Vi(k,"")}catch(Me){bt(r,r.return,Me)}}g&4&&r.stateNode!=null&&(k=r.memoizedProps,Ph(r,k,h!==null?h.memoizedProps:k)),g&1024&&($h=!0);break;case 6:if(Ln(i,r),Dn(r),g&4){if(r.stateNode===null)throw Error(s(162));g=r.memoizedProps,h=r.stateNode;try{h.nodeValue=g}catch(Me){bt(r,r.return,Me)}}break;case 3:if(Ac=null,k=pr,pr=Nc(i.containerInfo),Ln(i,r),pr=k,Dn(r),g&4&&h!==null&&h.memoizedState.isDehydrated)try{ba(i.containerInfo)}catch(Me){bt(r,r.return,Me)}$h&&($h=!1,U_(r));break;case 4:g=pr,pr=Nc(r.stateNode.containerInfo),Ln(i,r),Dn(r),pr=g;break;case 12:Ln(i,r),Dn(r);break;case 31:Ln(i,r),Dn(r),g&4&&(g=r.updateQueue,g!==null&&(r.updateQueue=null,mc(r,g)));break;case 13:Ln(i,r),Dn(r),r.child.flags&8192&&r.memoizedState!==null!=(h!==null&&h.memoizedState!==null)&&(gc=dt()),g&4&&(g=r.updateQueue,g!==null&&(r.updateQueue=null,mc(r,g)));break;case 22:k=r.memoizedState!==null;var ne=h!==null&&h.memoizedState!==null,de=Xr,xe=Qt;if(Xr=de||k,Qt=xe||ne,Ln(i,r),Qt=xe,Xr=de,Dn(r),g&8192)e:for(i=r.stateNode,i._visibility=k?i._visibility&-2:i._visibility|1,k&&(h===null||ne||Xr||Qt||hi(r)),h=null,i=r;;){if(i.tag===5||i.tag===26){if(h===null){ne=h=i;try{if(j=ne.stateNode,k)B=j.style,typeof B.setProperty=="function"?B.setProperty("display","none","important"):B.display="none";else{K=ne.stateNode;var be=ne.memoizedProps.style,he=be!=null&&be.hasOwnProperty("display")?be.display:null;K.style.display=he==null||typeof he=="boolean"?"":(""+he).trim()}}catch(Me){bt(ne,ne.return,Me)}}}else if(i.tag===6){if(h===null){ne=i;try{ne.stateNode.nodeValue=k?"":ne.memoizedProps}catch(Me){bt(ne,ne.return,Me)}}}else if(i.tag===18){if(h===null){ne=i;try{var fe=ne.stateNode;k?Ly(fe,!0):Ly(ne.stateNode,!1)}catch(Me){bt(ne,ne.return,Me)}}}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;h===i&&(h=null),i=i.return}h===i&&(h=null),i.sibling.return=i.return,i=i.sibling}g&4&&(g=r.updateQueue,g!==null&&(h=g.retryQueue,h!==null&&(g.retryQueue=null,mc(r,h))));break;case 19:Ln(i,r),Dn(r),g&4&&(g=r.updateQueue,g!==null&&(r.updateQueue=null,mc(r,g)));break;case 30:break;case 21:break;default:Ln(i,r),Dn(r)}}function Dn(r){var i=r.flags;if(i&2){try{for(var h,g=r.return;g!==null;){if(R_(g)){h=g;break}g=g.return}if(h==null)throw Error(s(160));switch(h.tag){case 27:var k=h.stateNode,j=Bh(r);fc(r,j,k);break;case 5:var B=h.stateNode;h.flags&32&&(Vi(B,""),h.flags&=-33);var K=Bh(r);fc(r,K,B);break;case 3:case 4:var ne=h.stateNode.containerInfo,de=Bh(r);zh(r,de,ne);break;default:throw Error(s(161))}}catch(xe){bt(r,r.return,xe)}r.flags&=-3}i&4096&&(r.flags&=-4097)}function U_(r){if(r.subtreeFlags&1024)for(r=r.child;r!==null;){var i=r;U_(i),i.tag===5&&i.flags&1024&&i.stateNode.reset(),r=r.sibling}}function Jr(r,i){if(i.subtreeFlags&8772)for(i=i.child;i!==null;)I_(r,i.alternate,i),i=i.sibling}function hi(r){for(r=r.child;r!==null;){var i=r;switch(i.tag){case 0:case 11:case 14:case 15:Cs(4,i,i.return),hi(i);break;case 1:jr(i,i.return);var h=i.stateNode;typeof h.componentWillUnmount=="function"&&L_(i,i.return,h),hi(i);break;case 27:Lo(i.stateNode);case 26:case 5:jr(i,i.return),hi(i);break;case 22:i.memoizedState===null&&hi(i);break;case 30:hi(i);break;default:hi(i)}r=r.sibling}}function Zr(r,i,h){for(h=h&&(i.subtreeFlags&8772)!==0,i=i.child;i!==null;){var g=i.alternate,k=r,j=i,B=j.flags;switch(j.tag){case 0:case 11:case 15:Zr(k,j,h),bo(4,j);break;case 1:if(Zr(k,j,h),g=j,k=g.stateNode,typeof k.componentDidMount=="function")try{k.componentDidMount()}catch(de){bt(g,g.return,de)}if(g=j,k=g.updateQueue,k!==null){var K=g.stateNode;try{var ne=k.shared.hiddenCallbacks;if(ne!==null)for(k.shared.hiddenCallbacks=null,k=0;k<ne.length;k++)yx(ne[k],K)}catch(de){bt(g,g.return,de)}}h&&B&64&&A_(j),So(j,j.return);break;case 27:O_(j);case 26:case 5:Zr(k,j,h),h&&g===null&&B&4&&D_(j),So(j,j.return);break;case 12:Zr(k,j,h);break;case 31:Zr(k,j,h),h&&B&4&&z_(k,j);break;case 13:Zr(k,j,h),h&&B&4&&$_(k,j);break;case 22:j.memoizedState===null&&Zr(k,j,h),So(j,j.return);break;case 30:break;default:Zr(k,j,h)}i=i.sibling}}function Hh(r,i){var h=null;r!==null&&r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(h=r.memoizedState.cachePool.pool),r=null,i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(r=i.memoizedState.cachePool.pool),r!==h&&(r!=null&&r.refCount++,h!=null&&oo(h))}function Uh(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 gr(r,i,h,g){if(i.subtreeFlags&10256)for(i=i.child;i!==null;)F_(r,i,h,g),i=i.sibling}function F_(r,i,h,g){var k=i.flags;switch(i.tag){case 0:case 11:case 15:gr(r,i,h,g),k&2048&&bo(9,i);break;case 1:gr(r,i,h,g);break;case 3:gr(r,i,h,g),k&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(k&2048){gr(r,i,h,g),r=i.stateNode;try{var j=i.memoizedProps,B=j.id,K=j.onPostCommit;typeof K=="function"&&K(B,i.alternate===null?"mount":"update",r.passiveEffectDuration,-0)}catch(ne){bt(i,i.return,ne)}}else gr(r,i,h,g);break;case 31:gr(r,i,h,g);break;case 13:gr(r,i,h,g);break;case 23:break;case 22:j=i.stateNode,B=i.alternate,i.memoizedState!==null?j._visibility&2?gr(r,i,h,g):wo(r,i):j._visibility&2?gr(r,i,h,g):(j._visibility|=2,ua(r,i,h,g,(i.subtreeFlags&10256)!==0||!1)),k&2048&&Hh(B,i);break;case 24:gr(r,i,h,g),k&2048&&Uh(i.alternate,i);break;default:gr(r,i,h,g)}}function ua(r,i,h,g,k){for(k=k&&((i.subtreeFlags&10256)!==0||!1),i=i.child;i!==null;){var j=r,B=i,K=h,ne=g,de=B.flags;switch(B.tag){case 0:case 11:case 15:ua(j,B,K,ne,k),bo(8,B);break;case 23:break;case 22:var xe=B.stateNode;B.memoizedState!==null?xe._visibility&2?ua(j,B,K,ne,k):wo(j,B):(xe._visibility|=2,ua(j,B,K,ne,k)),k&&de&2048&&Hh(B.alternate,B);break;case 24:ua(j,B,K,ne,k),k&&de&2048&&Uh(B.alternate,B);break;default:ua(j,B,K,ne,k)}i=i.sibling}}function wo(r,i){if(i.subtreeFlags&10256)for(i=i.child;i!==null;){var h=r,g=i,k=g.flags;switch(g.tag){case 22:wo(h,g),k&2048&&Hh(g.alternate,g);break;case 24:wo(h,g),k&2048&&Uh(g.alternate,g);break;default:wo(h,g)}i=i.sibling}}var Co=8192;function da(r,i,h){if(r.subtreeFlags&Co)for(r=r.child;r!==null;)V_(r,i,h),r=r.sibling}function V_(r,i,h){switch(r.tag){case 26:da(r,i,h),r.flags&Co&&r.memoizedState!==null&&qE(h,pr,r.memoizedState,r.memoizedProps);break;case 5:da(r,i,h);break;case 3:case 4:var g=pr;pr=Nc(r.stateNode.containerInfo),da(r,i,h),pr=g;break;case 22:r.memoizedState===null&&(g=r.alternate,g!==null&&g.memoizedState!==null?(g=Co,Co=16777216,da(r,i,h),Co=g):da(r,i,h));break;default:da(r,i,h)}}function G_(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 h=0;h<i.length;h++){var g=i[h];un=g,q_(g,r)}G_(r)}if(r.subtreeFlags&10256)for(r=r.child;r!==null;)W_(r),r=r.sibling}function W_(r){switch(r.tag){case 0:case 11:case 15:ko(r),r.flags&2048&&Cs(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,pc(r)):ko(r);break;default:ko(r)}}function pc(r){var i=r.deletions;if((r.flags&16)!==0){if(i!==null)for(var h=0;h<i.length;h++){var g=i[h];un=g,q_(g,r)}G_(r)}for(r=r.child;r!==null;){switch(i=r,i.tag){case 0:case 11:case 15:Cs(8,i,i.return),pc(i);break;case 22:h=i.stateNode,h._visibility&2&&(h._visibility&=-3,pc(i));break;default:pc(i)}r=r.sibling}}function q_(r,i){for(;un!==null;){var h=un;switch(h.tag){case 0:case 11:case 15:Cs(8,h,i);break;case 23:case 22:if(h.memoizedState!==null&&h.memoizedState.cachePool!==null){var g=h.memoizedState.cachePool.pool;g!=null&&g.refCount++}break;case 24:oo(h.memoizedState.cache)}if(g=h.child,g!==null)g.return=h,un=g;else e:for(h=r;un!==null;){g=un;var k=g.sibling,j=g.return;if(P_(g),g===h){un=null;break e}if(k!==null){k.return=j,un=k;break e}un=j}}}var lE={getCacheForType:function(r){var i=pn(Kt),h=i.data.get(r);return h===void 0&&(h=r(),i.data.set(r,h)),h},cacheSignal:function(){return pn(Kt).controller.signal}},cE=typeof WeakMap=="function"?WeakMap:Map,xt=0,Nt=null,nt=null,it=0,vt=0,Un=null,ks=!1,ha=!1,Fh=!1,es=0,Ut=0,Es=0,fi=0,Vh=0,Fn=0,fa=0,Eo=null,Rn=null,Gh=!1,gc=0,K_=0,xc=1/0,_c=null,js=null,rn=0,Ns=null,ma=null,ts=0,Wh=0,qh=null,Y_=null,jo=0,Kh=null;function Vn(){return(xt&2)!==0&&it!==0?it&-it:z.T!==null?ef():ft()}function X_(){if(Fn===0)if((it&536870912)===0||lt){var r=Oi;Oi<<=1,(Oi&3932160)===0&&(Oi=262144),Fn=r}else Fn=536870912;return r=$n.current,r!==null&&(r.flags|=32),Fn}function On(r,i,h){(r===Nt&&(vt===2||vt===9)||r.cancelPendingCommit!==null)&&(pa(r,0),Ts(r,it,Fn,!1)),fs(r,h),((xt&2)===0||r!==Nt)&&(r===Nt&&((xt&2)===0&&(fi|=h),Ut===4&&Ts(r,it,Fn,!1)),Nr(r))}function Q_(r,i,h){if((xt&6)!==0)throw Error(s(327));var g=!h&&(i&127)===0&&(i&r.expiredLanes)===0||Xs(r,i),k=g?hE(r,i):Xh(r,i,!0),j=g;do{if(k===0){ha&&!g&&Ts(r,i,0,!1);break}else{if(h=r.current.alternate,j&&!uE(h)){k=Xh(r,i,!1),j=!1;continue}if(k===2){if(j=i,r.errorRecoveryDisabledLanes&j)var B=0;else B=r.pendingLanes&-536870913,B=B!==0?B:B&536870912?536870912:0;if(B!==0){i=B;e:{var K=r;k=Eo;var ne=K.current.memoizedState.isDehydrated;if(ne&&(pa(K,B).flags|=256),B=Xh(K,B,!1),B!==2){if(Fh&&!ne){K.errorRecoveryDisabledLanes|=j,fi|=j,k=4;break e}j=Rn,Rn=k,j!==null&&(Rn===null?Rn=j:Rn.push.apply(Rn,j))}k=B}if(j=!1,k!==2)continue}}if(k===1){pa(r,0),Ts(r,i,0,!0);break}e:{switch(g=r,j=k,j){case 0:case 1:throw Error(s(345));case 4:if((i&4194048)!==i)break;case 6:Ts(g,i,Fn,!ks);break e;case 2:Rn=null;break;case 3:case 5:break;default:throw Error(s(329))}if((i&62914560)===i&&(k=gc+300-dt(),10<k)){if(Ts(g,i,Fn,!ks),Ii(g,0,!0)!==0)break e;ts=i,g.timeoutHandle=Ny(J_.bind(null,g,h,Rn,_c,Gh,i,Fn,fi,fa,ks,j,"Throttled",-0,0),k);break e}J_(g,h,Rn,_c,Gh,i,Fn,fi,fa,ks,j,null,-0,0)}}break}while(!0);Nr(r)}function J_(r,i,h,g,k,j,B,K,ne,de,xe,be,he,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:$r},V_(i,j,be);var Me=(j&62914560)===j?gc-dt():(j&4194048)===j?K_-dt():0;if(Me=KE(be,Me),Me!==null){ts=j,r.cancelPendingCommit=Me(ay.bind(null,r,i,j,h,g,k,B,K,ne,xe,be,null,he,fe)),Ts(r,j,B,!de);return}}ay(r,i,j,h,g,k,B,K,ne)}function uE(r){for(var i=r;;){var h=i.tag;if((h===0||h===11||h===15)&&i.flags&16384&&(h=i.updateQueue,h!==null&&(h=h.stores,h!==null)))for(var g=0;g<h.length;g++){var k=h[g],j=k.getSnapshot;k=k.value;try{if(!Bn(j(),k))return!1}catch{return!1}}if(h=i.child,i.subtreeFlags&16384&&h!==null)h.return=i,i=h;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 Ts(r,i,h,g){i&=~Vh,i&=~fi,r.suspendedLanes|=i,r.pingedLanes&=~i,g&&(r.warmLanes|=i),g=r.expirationTimes;for(var k=i;0<k;){var j=31-ht(k),B=1<<j;g[j]=-1,k&=~B}h!==0&&ve(r,h,i)}function yc(){return(xt&6)===0?(No(0),!1):!0}function Yh(){if(nt!==null){if(vt===0)var r=nt.return;else r=nt,Vr=si=null,dh(r),ia=null,co=0,r=nt;for(;r!==null;)T_(r.alternate,r),r=r.return;nt=null}}function pa(r,i){var h=r.timeoutHandle;h!==-1&&(r.timeoutHandle=-1,AE(h)),h=r.cancelPendingCommit,h!==null&&(r.cancelPendingCommit=null,h()),ts=0,Yh(),Nt=r,nt=h=Ur(r.current,null),it=i,vt=0,Un=null,ks=!1,ha=Xs(r,i),Fh=!1,fa=Fn=Vh=fi=Es=Ut=0,Rn=Eo=null,Gh=!1,(i&8)!==0&&(i|=i&32);var g=r.entangledLanes;if(g!==0)for(r=r.entanglements,g&=i;0<g;){var k=31-ht(g),j=1<<k;i|=r[k],g&=~j}return es=i,$l(),h}function Z_(r,i){Ke=null,z.H=_o,i===sa||i===Kl?(i=px(),vt=3):i===Zd?(i=px(),vt=4):vt=i===jh?8:i!==null&&typeof i=="object"&&typeof i.then=="function"?6:1,Un=i,nt===null&&(Ut=1,lc(r,Zn(i,r.current)))}function ey(){var r=$n.current;return r===null?!0:(it&4194048)===it?rr===null:(it&62914560)===it||(it&536870912)!==0?r===rr:!1}function ty(){var r=z.H;return z.H=_o,r===null?_o:r}function ny(){var r=z.A;return z.A=lE,r}function vc(){Ut=4,ks||(it&4194048)!==it&&$n.current!==null||(ha=!0),(Es&134217727)===0&&(fi&134217727)===0||Nt===null||Ts(Nt,it,Fn,!1)}function Xh(r,i,h){var g=xt;xt|=2;var k=ty(),j=ny();(Nt!==r||it!==i)&&(_c=null,pa(r,i)),i=!1;var B=Ut;e:do try{if(vt!==0&&nt!==null){var K=nt,ne=Un;switch(vt){case 8:Yh(),B=6;break e;case 3:case 2:case 9:case 6:$n.current===null&&(i=!0);var de=vt;if(vt=0,Un=null,ga(r,K,ne,de),h&&ha){B=0;break e}break;default:de=vt,vt=0,Un=null,ga(r,K,ne,de)}}dE(),B=Ut;break}catch(xe){Z_(r,xe)}while(!0);return i&&r.shellSuspendCounter++,Vr=si=null,xt=g,z.H=k,z.A=j,nt===null&&(Nt=null,it=0,$l()),B}function dE(){for(;nt!==null;)ry(nt)}function hE(r,i){var h=xt;xt|=2;var g=ty(),k=ny();Nt!==r||it!==i?(_c=null,xc=dt()+500,pa(r,i)):ha=Xs(r,i);e:do try{if(vt!==0&&nt!==null){i=nt;var j=Un;t:switch(vt){case 1:vt=0,Un=null,ga(r,i,j,1);break;case 2:case 9:if(fx(j)){vt=0,Un=null,sy(i);break}i=function(){vt!==2&&vt!==9||Nt!==r||(vt=7),Nr(r)},j.then(i,i);break e;case 3:vt=7;break e;case 4:vt=5;break e;case 7:fx(j)?(vt=0,Un=null,sy(i)):(vt=0,Un=null,ga(r,i,j,7));break;case 5:var B=null;switch(nt.tag){case 26:B=nt.memoizedState;case 5:case 27:var K=nt;if(B?Fy(B):K.stateNode.complete){vt=0,Un=null;var ne=K.sibling;if(ne!==null)nt=ne;else{var de=K.return;de!==null?(nt=de,bc(de)):nt=null}break t}}vt=0,Un=null,ga(r,i,j,5);break;case 6:vt=0,Un=null,ga(r,i,j,6);break;case 8:Yh(),Ut=6;break e;default:throw Error(s(462))}}fE();break}catch(xe){Z_(r,xe)}while(!0);return Vr=si=null,z.H=g,z.A=k,xt=h,nt!==null?0:(Nt=null,it=0,$l(),Ut)}function fE(){for(;nt!==null&&!Ze();)ry(nt)}function ry(r){var i=j_(r.alternate,r,es);r.memoizedProps=r.pendingProps,i===null?bc(r):nt=i}function sy(r){var i=r,h=i.alternate;switch(i.tag){case 15:case 0:i=b_(h,i,i.pendingProps,i.type,void 0,it);break;case 11:i=b_(h,i,i.pendingProps,i.type.render,i.ref,it);break;case 5:dh(i);default:T_(h,i),i=nt=nx(i,es),i=j_(h,i,es)}r.memoizedProps=r.pendingProps,i===null?bc(r):nt=i}function ga(r,i,h,g){Vr=si=null,dh(i),ia=null,co=0;var k=i.return;try{if(tE(r,k,i,h,it)){Ut=1,lc(r,Zn(h,r.current)),nt=null;return}}catch(j){if(k!==null)throw nt=k,j;Ut=1,lc(r,Zn(h,r.current)),nt=null;return}i.flags&32768?(lt||g===1?r=!0:ha||(it&536870912)!==0?r=!1:(ks=r=!0,(g===2||g===9||g===3||g===6)&&(g=$n.current,g!==null&&g.tag===13&&(g.flags|=16384))),iy(i,r)):bc(i)}function bc(r){var i=r;do{if((i.flags&32768)!==0){iy(i,ks);return}r=i.return;var h=sE(i.alternate,i,es);if(h!==null){nt=h;return}if(i=i.sibling,i!==null){nt=i;return}nt=i=r}while(i!==null);Ut===0&&(Ut=5)}function iy(r,i){do{var h=iE(r.alternate,r);if(h!==null){h.flags&=32767,nt=h;return}if(h=r.return,h!==null&&(h.flags|=32768,h.subtreeFlags=0,h.deletions=null),!i&&(r=r.sibling,r!==null)){nt=r;return}nt=r=h}while(r!==null);Ut=6,nt=null}function ay(r,i,h,g,k,j,B,K,ne){r.cancelPendingCommit=null;do Sc();while(rn!==0);if((xt&6)!==0)throw Error(s(327));if(i!==null){if(i===r.current)throw Error(s(177));if(j=i.lanes|i.childLanes,j|=Bd,_e(r,h,j,B,K,ne),r===Nt&&(nt=Nt=null,it=0),ma=i,Ns=r,ts=h,Wh=j,qh=k,Y_=g,(i.subtreeFlags&10256)!==0||(i.flags&10256)!==0?(r.callbackNode=null,r.callbackPriority=0,xE(Ie,function(){return dy(),null})):(r.callbackNode=null,r.callbackPriority=0),g=(i.flags&13878)!==0,(i.subtreeFlags&13878)!==0||g){g=z.T,z.T=null,k=X.p,X.p=2,B=xt,xt|=4;try{aE(r,i,h)}finally{xt=B,X.p=k,z.T=g}}rn=1,oy(),ly(),cy()}}function oy(){if(rn===1){rn=0;var r=Ns,i=ma,h=(i.flags&13878)!==0;if((i.subtreeFlags&13878)!==0||h){h=z.T,z.T=null;var g=X.p;X.p=2;var k=xt;xt|=4;try{H_(i,r);var j=cf,B=qg(r.containerInfo),K=j.focusedElem,ne=j.selectionRange;if(B!==K&&K&&K.ownerDocument&&Wg(K.ownerDocument.documentElement,K)){if(ne!==null&&Rd(K)){var de=ne.start,xe=ne.end;if(xe===void 0&&(xe=de),"selectionStart"in K)K.selectionStart=de,K.selectionEnd=Math.min(xe,K.value.length);else{var be=K.ownerDocument||document,he=be&&be.defaultView||window;if(he.getSelection){var fe=he.getSelection(),Me=K.textContent.length,Ue=Math.min(ne.start,Me),Et=ne.end===void 0?Ue:Math.min(ne.end,Me);!fe.extend&&Ue>Et&&(B=Et,Et=Ue,Ue=B);var le=Gg(K,Ue),ie=Gg(K,Et);if(le&&ie&&(fe.rangeCount!==1||fe.anchorNode!==le.node||fe.anchorOffset!==le.offset||fe.focusNode!==ie.node||fe.focusOffset!==ie.offset)){var ue=be.createRange();ue.setStart(le.node,le.offset),fe.removeAllRanges(),Ue>Et?(fe.addRange(ue),fe.extend(ie.node,ie.offset)):(ue.setEnd(ie.node,ie.offset),fe.addRange(ue))}}}}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 ye=be[K];ye.element.scrollLeft=ye.left,ye.element.scrollTop=ye.top}}Oc=!!lf,cf=lf=null}finally{xt=k,X.p=g,z.T=h}}r.current=i,rn=2}}function ly(){if(rn===2){rn=0;var r=Ns,i=ma,h=(i.flags&8772)!==0;if((i.subtreeFlags&8772)!==0||h){h=z.T,z.T=null;var g=X.p;X.p=2;var k=xt;xt|=4;try{I_(r,i.alternate,i)}finally{xt=k,X.p=g,z.T=h}}rn=3}}function cy(){if(rn===4||rn===3){rn=0,_t();var r=Ns,i=ma,h=ts,g=Y_;(i.subtreeFlags&10256)!==0||(i.flags&10256)!==0?rn=5:(rn=0,ma=Ns=null,uy(r,r.pendingLanes));var k=r.pendingLanes;if(k===0&&(js=null),We(h),i=i.stateNode,ct&&typeof ct.onCommitFiberRoot=="function")try{ct.onCommitFiberRoot(wt,i,void 0,(i.current.flags&128)===128)}catch{}if(g!==null){i=z.T,k=X.p,X.p=2,z.T=null;try{for(var j=r.onRecoverableError,B=0;B<g.length;B++){var K=g[B];j(K.value,{componentStack:K.stack})}}finally{z.T=i,X.p=k}}(ts&3)!==0&&Sc(),Nr(r),k=r.pendingLanes,(h&261930)!==0&&(k&42)!==0?r===Kh?jo++:(jo=0,Kh=r):jo=0,No(0)}}function uy(r,i){(r.pooledCacheLanes&=i)===0&&(i=r.pooledCache,i!=null&&(r.pooledCache=null,oo(i)))}function Sc(){return oy(),ly(),cy(),dy()}function dy(){if(rn!==5)return!1;var r=Ns,i=Wh;Wh=0;var h=We(ts),g=z.T,k=X.p;try{X.p=32>h?32:h,z.T=null,h=qh,qh=null;var j=Ns,B=ts;if(rn=0,ma=Ns=null,ts=0,(xt&6)!==0)throw Error(s(331));var K=xt;if(xt|=4,W_(j.current),F_(j,j.current,B,h),xt=K,No(0,!1),ct&&typeof ct.onPostCommitFiberRoot=="function")try{ct.onPostCommitFiberRoot(wt,j)}catch{}return!0}finally{X.p=k,z.T=g,uy(r,i)}}function hy(r,i,h){i=Zn(h,i),i=Eh(r.stateNode,i,2),r=bs(r,i,2),r!==null&&(fs(r,2),Nr(r))}function bt(r,i,h){if(r.tag===3)hy(r,r,h);else for(;i!==null;){if(i.tag===3){hy(i,r,h);break}else if(i.tag===1){var g=i.stateNode;if(typeof i.type.getDerivedStateFromError=="function"||typeof g.componentDidCatch=="function"&&(js===null||!js.has(g))){r=Zn(h,r),h=f_(2),g=bs(i,h,2),g!==null&&(m_(h,g,i,r),fs(g,2),Nr(g));break}}i=i.return}}function Qh(r,i,h){var g=r.pingCache;if(g===null){g=r.pingCache=new cE;var k=new Set;g.set(i,k)}else k=g.get(i),k===void 0&&(k=new Set,g.set(i,k));k.has(h)||(Fh=!0,k.add(h),r=mE.bind(null,r,i,h),i.then(r,r))}function mE(r,i,h){var g=r.pingCache;g!==null&&g.delete(i),r.pingedLanes|=r.suspendedLanes&h,r.warmLanes&=~h,Nt===r&&(it&h)===h&&(Ut===4||Ut===3&&(it&62914560)===it&&300>dt()-gc?(xt&2)===0&&pa(r,0):Vh|=h,fa===it&&(fa=0)),Nr(r)}function fy(r,i){i===0&&(i=Nl()),r=ti(r,i),r!==null&&(fs(r,i),Nr(r))}function pE(r){var i=r.memoizedState,h=0;i!==null&&(h=i.retryLane),fy(r,h)}function gE(r,i){var h=0;switch(r.tag){case 31:case 13:var g=r.stateNode,k=r.memoizedState;k!==null&&(h=k.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),fy(r,h)}function xE(r,i){return ce(r,i)}var wc=null,xa=null,Jh=!1,Cc=!1,Zh=!1,As=0;function Nr(r){r!==xa&&r.next===null&&(xa===null?wc=xa=r:xa=xa.next=r),Cc=!0,Jh||(Jh=!0,yE())}function No(r,i){if(!Zh&&Cc){Zh=!0;do for(var h=!1,g=wc;g!==null;){if(r!==0){var k=g.pendingLanes;if(k===0)var j=0;else{var B=g.suspendedLanes,K=g.pingedLanes;j=(1<<31-ht(42|r)+1)-1,j&=k&~(B&~K),j=j&201326741?j&201326741|1:j?j|2:0}j!==0&&(h=!0,xy(g,j))}else j=it,j=Ii(g,g===Nt?j:0,g.cancelPendingCommit!==null||g.timeoutHandle!==-1),(j&3)===0||Xs(g,j)||(h=!0,xy(g,j));g=g.next}while(h);Zh=!1}}function _E(){my()}function my(){Cc=Jh=!1;var r=0;As!==0&&TE()&&(r=As);for(var i=dt(),h=null,g=wc;g!==null;){var k=g.next,j=py(g,i);j===0?(g.next=null,h===null?wc=k:h.next=k,k===null&&(xa=h)):(h=g,(r!==0||(j&3)!==0)&&(Cc=!0)),g=k}rn!==0&&rn!==5||No(r),As!==0&&(As=0)}function py(r,i){for(var h=r.suspendedLanes,g=r.pingedLanes,k=r.expirationTimes,j=r.pendingLanes&-62914561;0<j;){var B=31-ht(j),K=1<<B,ne=k[B];ne===-1?((K&h)===0||(K&g)!==0)&&(k[B]=qa(K,i)):ne<=i&&(r.expiredLanes|=K),j&=~K}if(i=Nt,h=it,h=Ii(r,r===i?h:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),g=r.callbackNode,h===0||r===i&&(vt===2||vt===9)||r.cancelPendingCommit!==null)return g!==null&&g!==null&&Se(g),r.callbackNode=null,r.callbackPriority=0;if((h&3)===0||Xs(r,h)){if(i=h&-h,i===r.callbackPriority)return i;switch(g!==null&&Se(g),We(h)){case 2:case 8:h=Ce;break;case 32:h=Ie;break;case 268435456:h=Ve;break;default:h=Ie}return g=gy.bind(null,r),h=ce(h,g),r.callbackPriority=i,r.callbackNode=h,i}return g!==null&&g!==null&&Se(g),r.callbackPriority=2,r.callbackNode=null,2}function gy(r,i){if(rn!==0&&rn!==5)return r.callbackNode=null,r.callbackPriority=0,null;var h=r.callbackNode;if(Sc()&&r.callbackNode!==h)return null;var g=it;return g=Ii(r,r===Nt?g:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),g===0?null:(Q_(r,g,i),py(r,dt()),r.callbackNode!=null&&r.callbackNode===h?gy.bind(null,r):null)}function xy(r,i){if(Sc())return null;Q_(r,i,!0)}function yE(){LE(function(){(xt&6)!==0?ce(ge,_E):my()})}function ef(){if(As===0){var r=na;r===0&&(r=fr,fr<<=1,(fr&261888)===0&&(fr=256)),As=r}return As}function _y(r){return r==null||typeof r=="symbol"||typeof r=="boolean"?null:typeof r=="function"?r:Dl(""+r)}function yy(r,i){var h=i.ownerDocument.createElement("input");return h.name=i.name,h.value=i.value,r.id&&h.setAttribute("form",r.id),i.parentNode.insertBefore(h,i),r=new FormData(r),h.parentNode.removeChild(h),r}function vE(r,i,h,g,k){if(i==="submit"&&h&&h.stateNode===k){var j=_y((k[Nn]||null).action),B=g.submitter;B&&(i=(i=B[Nn]||null)?_y(i.formAction):B.getAttribute("formAction"),i!==null&&(j=i,B=null));var K=new Il("action","action",null,g,k);r.push({event:K,listeners:[{instance:null,listener:function(){if(g.defaultPrevented){if(As!==0){var ne=B?yy(k,B):new FormData(k);vh(h,{pending:!0,data:ne,method:k.method,action:j},null,ne)}}else typeof j=="function"&&(K.preventDefault(),ne=B?yy(k,B):new FormData(k),vh(h,{pending:!0,data:ne,method:k.method,action:j},j,ne))},currentTarget:k}]})}}for(var tf=0;tf<Pd.length;tf++){var nf=Pd[tf],bE=nf.toLowerCase(),SE=nf[0].toUpperCase()+nf.slice(1);mr(bE,"on"+SE)}mr(Xg,"onAnimationEnd"),mr(Qg,"onAnimationIteration"),mr(Jg,"onAnimationStart"),mr("dblclick","onDoubleClick"),mr("focusin","onFocus"),mr("focusout","onBlur"),mr(Bk,"onTransitionRun"),mr(zk,"onTransitionStart"),mr($k,"onTransitionCancel"),mr(Zg,"onTransitionEnd"),Ui("onMouseEnter",["mouseout","mouseover"]),Ui("onMouseLeave",["mouseout","mouseover"]),Ui("onPointerEnter",["pointerout","pointerover"]),Ui("onPointerLeave",["pointerout","pointerover"]),Qs("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Qs("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Qs("onBeforeInput",["compositionend","keypress","textInput","paste"]),Qs("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Qs("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Qs("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(" "),wE=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(To));function vy(r,i){i=(i&4)!==0;for(var h=0;h<r.length;h++){var g=r[h],k=g.event;g=g.listeners;e:{var j=void 0;if(i)for(var B=g.length-1;0<=B;B--){var K=g[B],ne=K.instance,de=K.currentTarget;if(K=K.listener,ne!==j&&k.isPropagationStopped())break e;j=K,k.currentTarget=de;try{j(k)}catch(xe){zl(xe)}k.currentTarget=null,j=ne}else for(B=0;B<g.length;B++){if(K=g[B],ne=K.instance,de=K.currentTarget,K=K.listener,ne!==j&&k.isPropagationStopped())break e;j=K,k.currentTarget=de;try{j(k)}catch(xe){zl(xe)}k.currentTarget=null,j=ne}}}}function rt(r,i){var h=i[pd];h===void 0&&(h=i[pd]=new Set);var g=r+"__bubble";h.has(g)||(by(i,r,2,!1),h.add(g))}function rf(r,i,h){var g=0;i&&(g|=4),by(h,r,g,i)}var kc="_reactListening"+Math.random().toString(36).slice(2);function sf(r){if(!r[kc]){r[kc]=!0,mg.forEach(function(h){h!=="selectionchange"&&(wE.has(h)||rf(h,!1,r),rf(h,!0,r))});var i=r.nodeType===9?r:r.ownerDocument;i===null||i[kc]||(i[kc]=!0,rf("selectionchange",!1,i))}}function by(r,i,h,g){switch(Xy(i)){case 2:var k=QE;break;case 8:k=JE;break;default:k=vf}h=k.bind(null,i,h,r),k=void 0,!Cd||i!=="touchstart"&&i!=="touchmove"&&i!=="wheel"||(k=!0),g?k!==void 0?r.addEventListener(i,h,{capture:!0,passive:k}):r.addEventListener(i,h,!0):k!==void 0?r.addEventListener(i,h,{passive:k}):r.addEventListener(i,h,!1)}function af(r,i,h,g,k){var j=g;if((i&1)===0&&(i&2)===0&&g!==null)e:for(;;){if(g===null)return;var B=g.tag;if(B===3||B===4){var K=g.stateNode.containerInfo;if(K===k)break;if(B===4)for(B=g.return;B!==null;){var ne=B.tag;if((ne===3||ne===4)&&B.stateNode.containerInfo===k)return;B=B.return}for(;K!==null;){if(B=zi(K),B===null)return;if(ne=B.tag,ne===5||ne===6||ne===26||ne===27){g=j=B;continue e}K=K.parentNode}}g=g.return}Eg(function(){var de=j,xe=Sd(h),be=[];e:{var he=ex.get(r);if(he!==void 0){var fe=Il,Me=r;switch(r){case"keypress":if(Ol(h)===0)break e;case"keydown":case"keyup":fe=gk;break;case"focusin":Me="focus",fe=Nd;break;case"focusout":Me="blur",fe=Nd;break;case"beforeblur":case"afterblur":fe=Nd;break;case"click":if(h.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":fe=Tg;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":fe=sk;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":fe=yk;break;case Xg:case Qg:case Jg:fe=ok;break;case Zg:fe=bk;break;case"scroll":case"scrollend":fe=nk;break;case"wheel":fe=wk;break;case"copy":case"cut":case"paste":fe=ck;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":fe=Lg;break;case"toggle":case"beforetoggle":fe=kk}var Ue=(i&4)!==0,Et=!Ue&&(r==="scroll"||r==="scrollend"),le=Ue?he!==null?he+"Capture":null:he;Ue=[];for(var ie=de,ue;ie!==null;){var ye=ie;if(ue=ye.stateNode,ye=ye.tag,ye!==5&&ye!==26&&ye!==27||ue===null||le===null||(ye=Xa(ie,le),ye!=null&&Ue.push(Ao(ie,ye,ue))),Et)break;ie=ie.return}0<Ue.length&&(he=new fe(he,Me,null,h,xe),be.push({event:he,listeners:Ue}))}}if((i&7)===0){e:{if(he=r==="mouseover"||r==="pointerover",fe=r==="mouseout"||r==="pointerout",he&&h!==bd&&(Me=h.relatedTarget||h.fromElement)&&(zi(Me)||Me[Bi]))break e;if((fe||he)&&(he=xe.window===xe?xe:(he=xe.ownerDocument)?he.defaultView||he.parentWindow:window,fe?(Me=h.relatedTarget||h.toElement,fe=de,Me=Me?zi(Me):null,Me!==null&&(Et=l(Me),Ue=Me.tag,Me!==Et||Ue!==5&&Ue!==27&&Ue!==6)&&(Me=null)):(fe=null,Me=de),fe!==Me)){if(Ue=Tg,ye="onMouseLeave",le="onMouseEnter",ie="mouse",(r==="pointerout"||r==="pointerover")&&(Ue=Lg,ye="onPointerLeave",le="onPointerEnter",ie="pointer"),Et=fe==null?he:Ya(fe),ue=Me==null?he:Ya(Me),he=new Ue(ye,ie+"leave",fe,h,xe),he.target=Et,he.relatedTarget=ue,ye=null,zi(xe)===de&&(Ue=new Ue(le,ie+"enter",Me,h,xe),Ue.target=ue,Ue.relatedTarget=Et,ye=Ue),Et=ye,fe&&Me)t:{for(Ue=CE,le=fe,ie=Me,ue=0,ye=le;ye;ye=Ue(ye))ue++;ye=0;for(var Be=ie;Be;Be=Ue(Be))ye++;for(;0<ue-ye;)le=Ue(le),ue--;for(;0<ye-ue;)ie=Ue(ie),ye--;for(;ue--;){if(le===ie||ie!==null&&le===ie.alternate){Ue=le;break t}le=Ue(le),ie=Ue(ie)}Ue=null}else Ue=null;fe!==null&&Sy(be,he,fe,Ue,!1),Me!==null&&Et!==null&&Sy(be,Et,Me,Ue,!0)}}e:{if(he=de?Ya(de):window,fe=he.nodeName&&he.nodeName.toLowerCase(),fe==="select"||fe==="input"&&he.type==="file")var mt=zg;else if(Pg(he))if($g)mt=Mk;else{mt=Rk;var Pe=Dk}else fe=he.nodeName,!fe||fe.toLowerCase()!=="input"||he.type!=="checkbox"&&he.type!=="radio"?de&&vd(de.elementType)&&(mt=zg):mt=Ok;if(mt&&(mt=mt(r,de))){Bg(be,mt,h,xe);break e}Pe&&Pe(r,he,de),r==="focusout"&&de&&he.type==="number"&&de.memoizedProps.value!=null&&yd(he,"number",he.value)}switch(Pe=de?Ya(de):window,r){case"focusin":(Pg(Pe)||Pe.contentEditable==="true")&&(Ki=Pe,Od=de,so=null);break;case"focusout":so=Od=Ki=null;break;case"mousedown":Md=!0;break;case"contextmenu":case"mouseup":case"dragend":Md=!1,Kg(be,h,xe);break;case"selectionchange":if(Pk)break;case"keydown":case"keyup":Kg(be,h,xe)}var Xe;if(Ad)e:{switch(r){case"compositionstart":var at="onCompositionStart";break e;case"compositionend":at="onCompositionEnd";break e;case"compositionupdate":at="onCompositionUpdate";break e}at=void 0}else qi?Mg(r,h)&&(at="onCompositionEnd"):r==="keydown"&&h.keyCode===229&&(at="onCompositionStart");at&&(Dg&&h.locale!=="ko"&&(qi||at!=="onCompositionStart"?at==="onCompositionEnd"&&qi&&(Xe=jg()):(ms=xe,kd="value"in ms?ms.value:ms.textContent,qi=!0)),Pe=Ec(de,at),0<Pe.length&&(at=new Ag(at,r,null,h,xe),be.push({event:at,listeners:Pe}),Xe?at.data=Xe:(Xe=Ig(h),Xe!==null&&(at.data=Xe)))),(Xe=jk?Nk(r,h):Tk(r,h))&&(at=Ec(de,"onBeforeInput"),0<at.length&&(Pe=new Ag("onBeforeInput","beforeinput",null,h,xe),be.push({event:Pe,listeners:at}),Pe.data=Xe)),vE(be,r,de,h,xe)}vy(be,i)})}function Ao(r,i,h){return{instance:r,listener:i,currentTarget:h}}function Ec(r,i){for(var h=i+"Capture",g=[];r!==null;){var k=r,j=k.stateNode;if(k=k.tag,k!==5&&k!==26&&k!==27||j===null||(k=Xa(r,h),k!=null&&g.unshift(Ao(r,k,j)),k=Xa(r,i),k!=null&&g.push(Ao(r,k,j))),r.tag===3)return g;r=r.return}return[]}function CE(r){if(r===null)return null;do r=r.return;while(r&&r.tag!==5&&r.tag!==27);return r||null}function Sy(r,i,h,g,k){for(var j=i._reactName,B=[];h!==null&&h!==g;){var K=h,ne=K.alternate,de=K.stateNode;if(K=K.tag,ne!==null&&ne===g)break;K!==5&&K!==26&&K!==27||de===null||(ne=de,k?(de=Xa(h,j),de!=null&&B.unshift(Ao(h,de,ne))):k||(de=Xa(h,j),de!=null&&B.push(Ao(h,de,ne)))),h=h.return}B.length!==0&&r.push({event:i,listeners:B})}var kE=/\r\n?/g,EE=/\u0000|\uFFFD/g;function wy(r){return(typeof r=="string"?r:""+r).replace(kE,`
50
+ `).replace(EE,"")}function Cy(r,i){return i=wy(i),wy(r)===i}function kt(r,i,h,g,k,j){switch(h){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":Al(r,"class",g);break;case"tabIndex":Al(r,"tabindex",g);break;case"dir":case"role":case"viewBox":case"width":case"height":Al(r,h,g);break;case"style":Cg(r,g,j);break;case"data":if(i!=="object"){Al(r,"data",g);break}case"src":case"href":if(g===""&&(i!=="a"||h!=="href")){r.removeAttribute(h);break}if(g==null||typeof g=="function"||typeof g=="symbol"||typeof g=="boolean"){r.removeAttribute(h);break}g=Dl(""+g),r.setAttribute(h,g);break;case"action":case"formAction":if(typeof g=="function"){r.setAttribute(h,"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"&&(h==="formAction"?(i!=="input"&&kt(r,i,"name",k.name,k,null),kt(r,i,"formEncType",k.formEncType,k,null),kt(r,i,"formMethod",k.formMethod,k,null),kt(r,i,"formTarget",k.formTarget,k,null)):(kt(r,i,"encType",k.encType,k,null),kt(r,i,"method",k.method,k,null),kt(r,i,"target",k.target,k,null)));if(g==null||typeof g=="symbol"||typeof g=="boolean"){r.removeAttribute(h);break}g=Dl(""+g),r.setAttribute(h,g);break;case"onClick":g!=null&&(r.onclick=$r);break;case"onScroll":g!=null&&rt("scroll",r);break;case"onScrollEnd":g!=null&&rt("scrollend",r);break;case"dangerouslySetInnerHTML":if(g!=null){if(typeof g!="object"||!("__html"in g))throw Error(s(61));if(h=g.__html,h!=null){if(k.children!=null)throw Error(s(60));r.innerHTML=h}}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}h=Dl(""+g),r.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",h);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(h,""+g):r.removeAttribute(h);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(h,""):r.removeAttribute(h);break;case"capture":case"download":g===!0?r.setAttribute(h,""):g!==!1&&g!=null&&typeof g!="function"&&typeof g!="symbol"?r.setAttribute(h,g):r.removeAttribute(h);break;case"cols":case"rows":case"size":case"span":g!=null&&typeof g!="function"&&typeof g!="symbol"&&!isNaN(g)&&1<=g?r.setAttribute(h,g):r.removeAttribute(h);break;case"rowSpan":case"start":g==null||typeof g=="function"||typeof g=="symbol"||isNaN(g)?r.removeAttribute(h):r.setAttribute(h,g);break;case"popover":rt("beforetoggle",r),rt("toggle",r),Tl(r,"popover",g);break;case"xlinkActuate":zr(r,"http://www.w3.org/1999/xlink","xlink:actuate",g);break;case"xlinkArcrole":zr(r,"http://www.w3.org/1999/xlink","xlink:arcrole",g);break;case"xlinkRole":zr(r,"http://www.w3.org/1999/xlink","xlink:role",g);break;case"xlinkShow":zr(r,"http://www.w3.org/1999/xlink","xlink:show",g);break;case"xlinkTitle":zr(r,"http://www.w3.org/1999/xlink","xlink:title",g);break;case"xlinkType":zr(r,"http://www.w3.org/1999/xlink","xlink:type",g);break;case"xmlBase":zr(r,"http://www.w3.org/XML/1998/namespace","xml:base",g);break;case"xmlLang":zr(r,"http://www.w3.org/XML/1998/namespace","xml:lang",g);break;case"xmlSpace":zr(r,"http://www.w3.org/XML/1998/namespace","xml:space",g);break;case"is":Tl(r,"is",g);break;case"innerText":case"textContent":break;default:(!(2<h.length)||h[0]!=="o"&&h[0]!=="O"||h[1]!=="n"&&h[1]!=="N")&&(h=ek.get(h)||h,Tl(r,h,g))}}function of(r,i,h,g,k,j){switch(h){case"style":Cg(r,g,j);break;case"dangerouslySetInnerHTML":if(g!=null){if(typeof g!="object"||!("__html"in g))throw Error(s(61));if(h=g.__html,h!=null){if(k.children!=null)throw Error(s(60));r.innerHTML=h}}break;case"children":typeof g=="string"?Vi(r,g):(typeof g=="number"||typeof g=="bigint")&&Vi(r,""+g);break;case"onScroll":g!=null&&rt("scroll",r);break;case"onScrollEnd":g!=null&&rt("scrollend",r);break;case"onClick":g!=null&&(r.onclick=$r);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!pg.hasOwnProperty(h))e:{if(h[0]==="o"&&h[1]==="n"&&(k=h.endsWith("Capture"),i=h.slice(2,k?h.length-7:void 0),j=r[Nn]||null,j=j!=null?j[h]:null,typeof j=="function"&&r.removeEventListener(i,j,k),typeof g=="function")){typeof j!="function"&&j!==null&&(h in r?r[h]=null:r.hasAttribute(h)&&r.removeAttribute(h)),r.addEventListener(i,g,k);break e}h in r?r[h]=g:g===!0?r.setAttribute(h,""):Tl(r,h,g)}}}function xn(r,i,h){switch(i){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":rt("error",r),rt("load",r);var g=!1,k=!1,j;for(j in h)if(h.hasOwnProperty(j)){var B=h[j];if(B!=null)switch(j){case"src":g=!0;break;case"srcSet":k=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(s(137,i));default:kt(r,i,j,B,h,null)}}k&&kt(r,i,"srcSet",h.srcSet,h,null),g&&kt(r,i,"src",h.src,h,null);return;case"input":rt("invalid",r);var K=j=B=k=null,ne=null,de=null;for(g in h)if(h.hasOwnProperty(g)){var xe=h[g];if(xe!=null)switch(g){case"name":k=xe;break;case"type":B=xe;break;case"checked":ne=xe;break;case"defaultChecked":de=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:kt(r,i,g,xe,h,null)}}vg(r,j,K,ne,de,B,k,!1);return;case"select":rt("invalid",r),g=B=j=null;for(k in h)if(h.hasOwnProperty(k)&&(K=h[k],K!=null))switch(k){case"value":j=K;break;case"defaultValue":B=K;break;case"multiple":g=K;default:kt(r,i,k,K,h,null)}i=j,h=B,r.multiple=!!g,i!=null?Fi(r,!!g,i,!1):h!=null&&Fi(r,!!g,h,!0);return;case"textarea":rt("invalid",r),j=k=g=null;for(B in h)if(h.hasOwnProperty(B)&&(K=h[B],K!=null))switch(B){case"value":g=K;break;case"defaultValue":k=K;break;case"children":j=K;break;case"dangerouslySetInnerHTML":if(K!=null)throw Error(s(91));break;default:kt(r,i,B,K,h,null)}Sg(r,g,k,j);return;case"option":for(ne in h)if(h.hasOwnProperty(ne)&&(g=h[ne],g!=null))switch(ne){case"selected":r.selected=g&&typeof g!="function"&&typeof g!="symbol";break;default:kt(r,i,ne,g,h,null)}return;case"dialog":rt("beforetoggle",r),rt("toggle",r),rt("cancel",r),rt("close",r);break;case"iframe":case"object":rt("load",r);break;case"video":case"audio":for(g=0;g<To.length;g++)rt(To[g],r);break;case"image":rt("error",r),rt("load",r);break;case"details":rt("toggle",r);break;case"embed":case"source":case"link":rt("error",r),rt("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(de in h)if(h.hasOwnProperty(de)&&(g=h[de],g!=null))switch(de){case"children":case"dangerouslySetInnerHTML":throw Error(s(137,i));default:kt(r,i,de,g,h,null)}return;default:if(vd(i)){for(xe in h)h.hasOwnProperty(xe)&&(g=h[xe],g!==void 0&&of(r,i,xe,g,h,void 0));return}}for(K in h)h.hasOwnProperty(K)&&(g=h[K],g!=null&&kt(r,i,K,g,h,null))}function jE(r,i,h,g){switch(i){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var k=null,j=null,B=null,K=null,ne=null,de=null,xe=null;for(fe in h){var be=h[fe];if(h.hasOwnProperty(fe)&&be!=null)switch(fe){case"checked":break;case"value":break;case"defaultValue":ne=be;default:g.hasOwnProperty(fe)||kt(r,i,fe,null,g,be)}}for(var he in g){var fe=g[he];if(be=h[he],g.hasOwnProperty(he)&&(fe!=null||be!=null))switch(he){case"type":j=fe;break;case"name":k=fe;break;case"checked":de=fe;break;case"defaultChecked":xe=fe;break;case"value":B=fe;break;case"defaultValue":K=fe;break;case"children":case"dangerouslySetInnerHTML":if(fe!=null)throw Error(s(137,i));break;default:fe!==be&&kt(r,i,he,fe,g,be)}}_d(r,B,K,ne,de,xe,j,k);return;case"select":fe=B=K=he=null;for(j in h)if(ne=h[j],h.hasOwnProperty(j)&&ne!=null)switch(j){case"value":break;case"multiple":fe=ne;default:g.hasOwnProperty(j)||kt(r,i,j,null,g,ne)}for(k in g)if(j=g[k],ne=h[k],g.hasOwnProperty(k)&&(j!=null||ne!=null))switch(k){case"value":he=j;break;case"defaultValue":K=j;break;case"multiple":B=j;default:j!==ne&&kt(r,i,k,j,g,ne)}i=K,h=B,g=fe,he!=null?Fi(r,!!h,he,!1):!!g!=!!h&&(i!=null?Fi(r,!!h,i,!0):Fi(r,!!h,h?[]:"",!1));return;case"textarea":fe=he=null;for(K in h)if(k=h[K],h.hasOwnProperty(K)&&k!=null&&!g.hasOwnProperty(K))switch(K){case"value":break;case"children":break;default:kt(r,i,K,null,g,k)}for(B in g)if(k=g[B],j=h[B],g.hasOwnProperty(B)&&(k!=null||j!=null))switch(B){case"value":he=k;break;case"defaultValue":fe=k;break;case"children":break;case"dangerouslySetInnerHTML":if(k!=null)throw Error(s(91));break;default:k!==j&&kt(r,i,B,k,g,j)}bg(r,he,fe);return;case"option":for(var Me in h)if(he=h[Me],h.hasOwnProperty(Me)&&he!=null&&!g.hasOwnProperty(Me))switch(Me){case"selected":r.selected=!1;break;default:kt(r,i,Me,null,g,he)}for(ne in g)if(he=g[ne],fe=h[ne],g.hasOwnProperty(ne)&&he!==fe&&(he!=null||fe!=null))switch(ne){case"selected":r.selected=he&&typeof he!="function"&&typeof he!="symbol";break;default:kt(r,i,ne,he,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 Ue in h)he=h[Ue],h.hasOwnProperty(Ue)&&he!=null&&!g.hasOwnProperty(Ue)&&kt(r,i,Ue,null,g,he);for(de in g)if(he=g[de],fe=h[de],g.hasOwnProperty(de)&&he!==fe&&(he!=null||fe!=null))switch(de){case"children":case"dangerouslySetInnerHTML":if(he!=null)throw Error(s(137,i));break;default:kt(r,i,de,he,g,fe)}return;default:if(vd(i)){for(var Et in h)he=h[Et],h.hasOwnProperty(Et)&&he!==void 0&&!g.hasOwnProperty(Et)&&of(r,i,Et,void 0,g,he);for(xe in g)he=g[xe],fe=h[xe],!g.hasOwnProperty(xe)||he===fe||he===void 0&&fe===void 0||of(r,i,xe,he,g,fe);return}}for(var le in h)he=h[le],h.hasOwnProperty(le)&&he!=null&&!g.hasOwnProperty(le)&&kt(r,i,le,null,g,he);for(be in g)he=g[be],fe=h[be],!g.hasOwnProperty(be)||he===fe||he==null&&fe==null||kt(r,i,be,he,g,fe)}function ky(r){switch(r){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function NE(){if(typeof performance.getEntriesByType=="function"){for(var r=0,i=0,h=performance.getEntriesByType("resource"),g=0;g<h.length;g++){var k=h[g],j=k.transferSize,B=k.initiatorType,K=k.duration;if(j&&K&&ky(B)){for(B=0,K=k.responseEnd,g+=1;g<h.length;g++){var ne=h[g],de=ne.startTime;if(de>K)break;var xe=ne.transferSize,be=ne.initiatorType;xe&&ky(be)&&(ne=ne.responseEnd,B+=xe*(ne<K?1:(K-de)/(ne-de)))}if(--g,i+=8*(j+B)/(k.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 lf=null,cf=null;function jc(r){return r.nodeType===9?r:r.ownerDocument}function Ey(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 jy(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 uf(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 df=null;function TE(){var r=window.event;return r&&r.type==="popstate"?r===df?!1:(df=r,!0):(df=null,!1)}var Ny=typeof setTimeout=="function"?setTimeout:void 0,AE=typeof clearTimeout=="function"?clearTimeout:void 0,Ty=typeof Promise=="function"?Promise:void 0,LE=typeof queueMicrotask=="function"?queueMicrotask:typeof Ty<"u"?function(r){return Ty.resolve(null).then(r).catch(DE)}:Ny;function DE(r){setTimeout(function(){throw r})}function Ls(r){return r==="head"}function Ay(r,i){var h=i,g=0;do{var k=h.nextSibling;if(r.removeChild(h),k&&k.nodeType===8)if(h=k.data,h==="/$"||h==="/&"){if(g===0){r.removeChild(k),ba(i);return}g--}else if(h==="$"||h==="$?"||h==="$~"||h==="$!"||h==="&")g++;else if(h==="html")Lo(r.ownerDocument.documentElement);else if(h==="head"){h=r.ownerDocument.head,Lo(h);for(var j=h.firstChild;j;){var B=j.nextSibling,K=j.nodeName;j[Ka]||K==="SCRIPT"||K==="STYLE"||K==="LINK"&&j.rel.toLowerCase()==="stylesheet"||h.removeChild(j),j=B}}else h==="body"&&Lo(r.ownerDocument.body);h=k}while(h);ba(i)}function Ly(r,i){var h=r;r=0;do{var g=h.nextSibling;if(h.nodeType===1?i?(h._stashedDisplay=h.style.display,h.style.display="none"):(h.style.display=h._stashedDisplay||"",h.getAttribute("style")===""&&h.removeAttribute("style")):h.nodeType===3&&(i?(h._stashedText=h.nodeValue,h.nodeValue=""):h.nodeValue=h._stashedText||""),g&&g.nodeType===8)if(h=g.data,h==="/$"){if(r===0)break;r--}else h!=="$"&&h!=="$?"&&h!=="$~"&&h!=="$!"||r++;h=g}while(h)}function hf(r){var i=r.firstChild;for(i&&i.nodeType===10&&(i=i.nextSibling);i;){var h=i;switch(i=i.nextSibling,h.nodeName){case"HTML":case"HEAD":case"BODY":hf(h),gd(h);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(h.rel.toLowerCase()==="stylesheet")continue}r.removeChild(h)}}function RE(r,i,h,g){for(;r.nodeType===1;){var k=h;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!==k.rel||r.getAttribute("href")!==(k.href==null||k.href===""?null:k.href)||r.getAttribute("crossorigin")!==(k.crossOrigin==null?null:k.crossOrigin)||r.getAttribute("title")!==(k.title==null?null:k.title))break;return r;case"style":if(r.hasAttribute("data-precedence"))break;return r;case"script":if(j=r.getAttribute("src"),(j!==(k.src==null?null:k.src)||r.getAttribute("type")!==(k.type==null?null:k.type)||r.getAttribute("crossorigin")!==(k.crossOrigin==null?null:k.crossOrigin))&&j&&r.hasAttribute("async")&&!r.hasAttribute("itemprop"))break;return r;default:return r}}else if(i==="input"&&r.type==="hidden"){var j=k.name==null?null:""+k.name;if(k.type==="hidden"&&r.getAttribute("name")===j)return r}else return r;if(r=sr(r.nextSibling),r===null)break}return null}function OE(r,i,h){if(i==="")return null;for(;r.nodeType!==3;)if((r.nodeType!==1||r.nodeName!=="INPUT"||r.type!=="hidden")&&!h||(r=sr(r.nextSibling),r===null))return null;return r}function Dy(r,i){for(;r.nodeType!==8;)if((r.nodeType!==1||r.nodeName!=="INPUT"||r.type!=="hidden")&&!i||(r=sr(r.nextSibling),r===null))return null;return r}function ff(r){return r.data==="$?"||r.data==="$~"}function mf(r){return r.data==="$!"||r.data==="$?"&&r.ownerDocument.readyState!=="loading"}function ME(r,i){var h=r.ownerDocument;if(r.data==="$~")r._reactRetry=i;else if(r.data!=="$?"||h.readyState!=="loading")i();else{var g=function(){i(),h.removeEventListener("DOMContentLoaded",g)};h.addEventListener("DOMContentLoaded",g),r._reactRetry=g}}function sr(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 pf=null;function Ry(r){r=r.nextSibling;for(var i=0;r;){if(r.nodeType===8){var h=r.data;if(h==="/$"||h==="/&"){if(i===0)return sr(r.nextSibling);i--}else h!=="$"&&h!=="$!"&&h!=="$?"&&h!=="$~"&&h!=="&"||i++}r=r.nextSibling}return null}function Oy(r){r=r.previousSibling;for(var i=0;r;){if(r.nodeType===8){var h=r.data;if(h==="$"||h==="$!"||h==="$?"||h==="$~"||h==="&"){if(i===0)return r;i--}else h!=="/$"&&h!=="/&"||i++}r=r.previousSibling}return null}function My(r,i,h){switch(i=jc(h),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]);gd(r)}var ir=new Map,Iy=new Set;function Nc(r){return typeof r.getRootNode=="function"?r.getRootNode():r.nodeType===9?r:r.ownerDocument}var ns=X.d;X.d={f:IE,r:PE,D:BE,C:zE,L:$E,m:HE,X:FE,S:UE,M:VE};function IE(){var r=ns.f(),i=yc();return r||i}function PE(r){var i=$i(r);i!==null&&i.tag===5&&i.type==="form"?Zx(i):ns.r(r)}var _a=typeof document>"u"?null:document;function Py(r,i,h){var g=_a;if(g&&typeof i=="string"&&i){var k=Qn(i);k='link[rel="'+r+'"][href="'+k+'"]',typeof h=="string"&&(k+='[crossorigin="'+h+'"]'),Iy.has(k)||(Iy.add(k),r={rel:r,crossOrigin:h,href:i},g.querySelector(k)===null&&(i=g.createElement("link"),xn(i,"link",r),cn(i),g.head.appendChild(i)))}}function BE(r){ns.D(r),Py("dns-prefetch",r,null)}function zE(r,i){ns.C(r,i),Py("preconnect",r,i)}function $E(r,i,h){ns.L(r,i,h);var g=_a;if(g&&r&&i){var k='link[rel="preload"][as="'+Qn(i)+'"]';i==="image"&&h&&h.imageSrcSet?(k+='[imagesrcset="'+Qn(h.imageSrcSet)+'"]',typeof h.imageSizes=="string"&&(k+='[imagesizes="'+Qn(h.imageSizes)+'"]')):k+='[href="'+Qn(r)+'"]';var j=k;switch(i){case"style":j=ya(r);break;case"script":j=va(r)}ir.has(j)||(r=p({rel:"preload",href:i==="image"&&h&&h.imageSrcSet?void 0:r,as:i},h),ir.set(j,r),g.querySelector(k)!==null||i==="style"&&g.querySelector(Do(j))||i==="script"&&g.querySelector(Ro(j))||(i=g.createElement("link"),xn(i,"link",r),cn(i),g.head.appendChild(i)))}}function HE(r,i){ns.m(r,i);var h=_a;if(h&&r){var g=i&&typeof i.as=="string"?i.as:"script",k='link[rel="modulepreload"][as="'+Qn(g)+'"][href="'+Qn(r)+'"]',j=k;switch(g){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":j=va(r)}if(!ir.has(j)&&(r=p({rel:"modulepreload",href:r},i),ir.set(j,r),h.querySelector(k)===null)){switch(g){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(h.querySelector(Ro(j)))return}g=h.createElement("link"),xn(g,"link",r),cn(g),h.head.appendChild(g)}}}function UE(r,i,h){ns.S(r,i,h);var g=_a;if(g&&r){var k=Hi(g).hoistableStyles,j=ya(r);i=i||"default";var B=k.get(j);if(!B){var K={loading:0,preload:null};if(B=g.querySelector(Do(j)))K.loading=5;else{r=p({rel:"stylesheet",href:r,"data-precedence":i},h),(h=ir.get(j))&&gf(r,h);var ne=B=g.createElement("link");cn(ne),xn(ne,"link",r),ne._p=new Promise(function(de,xe){ne.onload=de,ne.onerror=xe}),ne.addEventListener("load",function(){K.loading|=1}),ne.addEventListener("error",function(){K.loading|=2}),K.loading|=4,Tc(B,i,g)}B={type:"stylesheet",instance:B,count:1,state:K},k.set(j,B)}}}function FE(r,i){ns.X(r,i);var h=_a;if(h&&r){var g=Hi(h).hoistableScripts,k=va(r),j=g.get(k);j||(j=h.querySelector(Ro(k)),j||(r=p({src:r,async:!0},i),(i=ir.get(k))&&xf(r,i),j=h.createElement("script"),cn(j),xn(j,"link",r),h.head.appendChild(j)),j={type:"script",instance:j,count:1,state:null},g.set(k,j))}}function VE(r,i){ns.M(r,i);var h=_a;if(h&&r){var g=Hi(h).hoistableScripts,k=va(r),j=g.get(k);j||(j=h.querySelector(Ro(k)),j||(r=p({src:r,async:!0,type:"module"},i),(i=ir.get(k))&&xf(r,i),j=h.createElement("script"),cn(j),xn(j,"link",r),h.head.appendChild(j)),j={type:"script",instance:j,count:1,state:null},g.set(k,j))}}function By(r,i,h,g){var k=(k=re.current)?Nc(k):null;if(!k)throw Error(s(446));switch(r){case"meta":case"title":return null;case"style":return typeof h.precedence=="string"&&typeof h.href=="string"?(i=ya(h.href),h=Hi(k).hoistableStyles,g=h.get(i),g||(g={type:"style",instance:null,count:0,state:null},h.set(i,g)),g):{type:"void",instance:null,count:0,state:null};case"link":if(h.rel==="stylesheet"&&typeof h.href=="string"&&typeof h.precedence=="string"){r=ya(h.href);var j=Hi(k).hoistableStyles,B=j.get(r);if(B||(k=k.ownerDocument||k,B={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},j.set(r,B),(j=k.querySelector(Do(r)))&&!j._p&&(B.instance=j,B.state.loading=5),ir.has(r)||(h={rel:"preload",as:"style",href:h.href,crossOrigin:h.crossOrigin,integrity:h.integrity,media:h.media,hrefLang:h.hrefLang,referrerPolicy:h.referrerPolicy},ir.set(r,h),j||GE(k,r,h,B.state))),i&&g===null)throw Error(s(528,""));return B}if(i&&g!==null)throw Error(s(529,""));return null;case"script":return i=h.async,h=h.src,typeof h=="string"&&i&&typeof i!="function"&&typeof i!="symbol"?(i=va(h),h=Hi(k).hoistableScripts,g=h.get(i),g||(g={type:"script",instance:null,count:0,state:null},h.set(i,g)),g):{type:"void",instance:null,count:0,state:null};default:throw Error(s(444,r))}}function ya(r){return'href="'+Qn(r)+'"'}function Do(r){return'link[rel="stylesheet"]['+r+"]"}function zy(r){return p({},r,{"data-precedence":r.precedence,precedence:null})}function GE(r,i,h,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}),xn(i,"link",h),cn(i),r.head.appendChild(i))}function va(r){return'[src="'+Qn(r)+'"]'}function Ro(r){return"script[async]"+r}function $y(r,i,h){if(i.count++,i.instance===null)switch(i.type){case"style":var g=r.querySelector('style[data-href~="'+Qn(h.href)+'"]');if(g)return i.instance=g,cn(g),g;var k=p({},h,{"data-href":h.href,"data-precedence":h.precedence,href:null,precedence:null});return g=(r.ownerDocument||r).createElement("style"),cn(g),xn(g,"style",k),Tc(g,h.precedence,r),i.instance=g;case"stylesheet":k=ya(h.href);var j=r.querySelector(Do(k));if(j)return i.state.loading|=4,i.instance=j,cn(j),j;g=zy(h),(k=ir.get(k))&&gf(g,k),j=(r.ownerDocument||r).createElement("link"),cn(j);var B=j;return B._p=new Promise(function(K,ne){B.onload=K,B.onerror=ne}),xn(j,"link",g),i.state.loading|=4,Tc(j,h.precedence,r),i.instance=j;case"script":return j=va(h.src),(k=r.querySelector(Ro(j)))?(i.instance=k,cn(k),k):(g=h,(k=ir.get(j))&&(g=p({},h),xf(g,k)),r=r.ownerDocument||r,k=r.createElement("script"),cn(k),xn(k,"link",g),r.head.appendChild(k),i.instance=k);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,Tc(g,h.precedence,r));return i.instance}function Tc(r,i,h){for(var g=h.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),k=g.length?g[g.length-1]:null,j=k,B=0;B<g.length;B++){var K=g[B];if(K.dataset.precedence===i)j=K;else if(j!==k)break}j?j.parentNode.insertBefore(r,j.nextSibling):(i=h.nodeType===9?h.head:h,i.insertBefore(r,i.firstChild))}function gf(r,i){r.crossOrigin==null&&(r.crossOrigin=i.crossOrigin),r.referrerPolicy==null&&(r.referrerPolicy=i.referrerPolicy),r.title==null&&(r.title=i.title)}function xf(r,i){r.crossOrigin==null&&(r.crossOrigin=i.crossOrigin),r.referrerPolicy==null&&(r.referrerPolicy=i.referrerPolicy),r.integrity==null&&(r.integrity=i.integrity)}var Ac=null;function Hy(r,i,h){if(Ac===null){var g=new Map,k=Ac=new Map;k.set(h,g)}else k=Ac,g=k.get(h),g||(g=new Map,k.set(h,g));if(g.has(r))return g;for(g.set(r,null),h=h.getElementsByTagName(r),k=0;k<h.length;k++){var j=h[k];if(!(j[Ka]||j[yt]||r==="link"&&j.getAttribute("rel")==="stylesheet")&&j.namespaceURI!=="http://www.w3.org/2000/svg"){var B=j.getAttribute(i)||"";B=r+B;var K=g.get(B);K?K.push(j):g.set(B,[j])}}return g}function Uy(r,i,h){r=r.ownerDocument||r,r.head.insertBefore(h,i==="title"?r.querySelector("head > title"):null)}function WE(r,i,h){if(h===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 Fy(r){return!(r.type==="stylesheet"&&(r.state.loading&3)===0)}function qE(r,i,h,g){if(h.type==="stylesheet"&&(typeof g.media!="string"||matchMedia(g.media).matches!==!1)&&(h.state.loading&4)===0){if(h.instance===null){var k=ya(g.href),j=i.querySelector(Do(k));if(j){i=j._p,i!==null&&typeof i=="object"&&typeof i.then=="function"&&(r.count++,r=Lc.bind(r),i.then(r,r)),h.state.loading|=4,h.instance=j,cn(j);return}j=i.ownerDocument||i,g=zy(g),(k=ir.get(k))&&gf(g,k),j=j.createElement("link"),cn(j);var B=j;B._p=new Promise(function(K,ne){B.onload=K,B.onerror=ne}),xn(j,"link",g),h.instance=j}r.stylesheets===null&&(r.stylesheets=new Map),r.stylesheets.set(h,i),(i=h.state.preload)&&(h.state.loading&3)===0&&(r.count++,h=Lc.bind(r),i.addEventListener("load",h),i.addEventListener("error",h))}}var _f=0;function KE(r,i){return r.stylesheets&&r.count===0&&Rc(r,r.stylesheets),0<r.count||0<r.imgCount?function(h){var g=setTimeout(function(){if(r.stylesheets&&Rc(r,r.stylesheets),r.unsuspend){var j=r.unsuspend;r.unsuspend=null,j()}},6e4+i);0<r.imgBytes&&_f===0&&(_f=62500*NE());var k=setTimeout(function(){if(r.waitingForImages=!1,r.count===0&&(r.stylesheets&&Rc(r,r.stylesheets),r.unsuspend)){var j=r.unsuspend;r.unsuspend=null,j()}},(r.imgBytes>_f?50:800)+i);return r.unsuspend=h,function(){r.unsuspend=null,clearTimeout(g),clearTimeout(k)}}:null}function Lc(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Rc(this,this.stylesheets);else if(this.unsuspend){var r=this.unsuspend;this.unsuspend=null,r()}}}var Dc=null;function Rc(r,i){r.stylesheets=null,r.unsuspend!==null&&(r.count++,Dc=new Map,i.forEach(YE,r),Dc=null,Lc.call(r))}function YE(r,i){if(!(i.state.loading&4)){var h=Dc.get(r);if(h)var g=h.get(null);else{h=new Map,Dc.set(r,h);for(var k=r.querySelectorAll("link[data-precedence],style[data-precedence]"),j=0;j<k.length;j++){var B=k[j];(B.nodeName==="LINK"||B.getAttribute("media")!=="not all")&&(h.set(B.dataset.precedence,B),g=B)}g&&h.set(null,g)}k=i.instance,B=k.getAttribute("data-precedence"),j=h.get(B)||g,j===g&&h.set(null,k),h.set(B,k),this.count++,g=Lc.bind(this),k.addEventListener("load",g),k.addEventListener("error",g),j?j.parentNode.insertBefore(k,j.nextSibling):(r=r.nodeType===9?r.head:r,r.insertBefore(k,r.firstChild)),i.state.loading|=4}}var Oo={$$typeof:y,Provider:null,Consumer:null,_currentValue:te,_currentValue2:te,_threadCount:0};function XE(r,i,h,g,k,j,B,K,ne){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=k,this.onCaughtError=j,this.onRecoverableError=B,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=ne,this.incompleteTransitions=new Map}function Vy(r,i,h,g,k,j,B,K,ne,de,xe,be){return r=new XE(r,i,h,B,ne,de,xe,be,K),i=1,j===!0&&(i|=24),j=zn(3,null,null,i),r.current=j,j.stateNode=r,i=Xd(),i.refCount++,r.pooledCache=i,i.refCount++,j.memoizedState={element:g,isDehydrated:h,cache:i},eh(j),r}function Gy(r){return r?(r=Qi,r):Qi}function Wy(r,i,h,g,k,j){k=Gy(k),g.context===null?g.context=k:g.pendingContext=k,g=vs(i),g.payload={element:h},j=j===void 0?null:j,j!==null&&(g.callback=j),h=bs(r,g,i),h!==null&&(On(h,r,i),ho(h,r,i))}function qy(r,i){if(r=r.memoizedState,r!==null&&r.dehydrated!==null){var h=r.retryLane;r.retryLane=h!==0&&h<i?h:i}}function yf(r,i){qy(r,i),(r=r.alternate)&&qy(r,i)}function Ky(r){if(r.tag===13||r.tag===31){var i=ti(r,67108864);i!==null&&On(i,r,67108864),yf(r,67108864)}}function Yy(r){if(r.tag===13||r.tag===31){var i=Vn();i=et(i);var h=ti(r,i);h!==null&&On(h,r,i),yf(r,i)}}var Oc=!0;function QE(r,i,h,g){var k=z.T;z.T=null;var j=X.p;try{X.p=2,vf(r,i,h,g)}finally{X.p=j,z.T=k}}function JE(r,i,h,g){var k=z.T;z.T=null;var j=X.p;try{X.p=8,vf(r,i,h,g)}finally{X.p=j,z.T=k}}function vf(r,i,h,g){if(Oc){var k=bf(g);if(k===null)af(r,i,g,Mc,h),Qy(r,g);else if(e2(k,r,i,h,g))g.stopPropagation();else if(Qy(r,g),i&4&&-1<ZE.indexOf(r)){for(;k!==null;){var j=$i(k);if(j!==null)switch(j.tag){case 3:if(j=j.stateNode,j.current.memoizedState.isDehydrated){var B=Cr(j.pendingLanes);if(B!==0){var K=j;for(K.pendingLanes|=2,K.entangledLanes|=2;B;){var ne=1<<31-ht(B);K.entanglements[1]|=ne,B&=~ne}Nr(j),(xt&6)===0&&(xc=dt()+500,No(0))}}break;case 31:case 13:K=ti(j,2),K!==null&&On(K,j,2),yc(),yf(j,2)}if(j=bf(g),j===null&&af(r,i,g,Mc,h),j===k)break;k=j}k!==null&&g.stopPropagation()}else af(r,i,g,null,h)}}function bf(r){return r=Sd(r),Sf(r)}var Mc=null;function Sf(r){if(Mc=null,r=zi(r),r!==null){var i=l(r);if(i===null)r=null;else{var h=i.tag;if(h===13){if(r=u(i),r!==null)return r;r=null}else if(h===31){if(r=c(i),r!==null)return r;r=null}else if(h===3){if(i.stateNode.current.memoizedState.isDehydrated)return i.tag===3?i.stateNode.containerInfo:null;r=null}else i!==r&&(r=null)}}return Mc=r,null}function Xy(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(tn()){case ge:return 2;case Ce:return 8;case Ie:case Fe:return 32;case Ve:return 268435456;default:return 32}default:return 32}}var wf=!1,Ds=null,Rs=null,Os=null,Mo=new Map,Io=new Map,Ms=[],ZE="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 Qy(r,i){switch(r){case"focusin":case"focusout":Ds=null;break;case"dragenter":case"dragleave":Rs=null;break;case"mouseover":case"mouseout":Os=null;break;case"pointerover":case"pointerout":Mo.delete(i.pointerId);break;case"gotpointercapture":case"lostpointercapture":Io.delete(i.pointerId)}}function Po(r,i,h,g,k,j){return r===null||r.nativeEvent!==j?(r={blockedOn:i,domEventName:h,eventSystemFlags:g,nativeEvent:j,targetContainers:[k]},i!==null&&(i=$i(i),i!==null&&Ky(i)),r):(r.eventSystemFlags|=g,i=r.targetContainers,k!==null&&i.indexOf(k)===-1&&i.push(k),r)}function e2(r,i,h,g,k){switch(i){case"focusin":return Ds=Po(Ds,r,i,h,g,k),!0;case"dragenter":return Rs=Po(Rs,r,i,h,g,k),!0;case"mouseover":return Os=Po(Os,r,i,h,g,k),!0;case"pointerover":var j=k.pointerId;return Mo.set(j,Po(Mo.get(j)||null,r,i,h,g,k)),!0;case"gotpointercapture":return j=k.pointerId,Io.set(j,Po(Io.get(j)||null,r,i,h,g,k)),!0}return!1}function Jy(r){var i=zi(r.target);if(i!==null){var h=l(i);if(h!==null){if(i=h.tag,i===13){if(i=u(h),i!==null){r.blockedOn=i,fn(r.priority,function(){Yy(h)});return}}else if(i===31){if(i=c(h),i!==null){r.blockedOn=i,fn(r.priority,function(){Yy(h)});return}}else if(i===3&&h.stateNode.current.memoizedState.isDehydrated){r.blockedOn=h.tag===3?h.stateNode.containerInfo:null;return}}}r.blockedOn=null}function Ic(r){if(r.blockedOn!==null)return!1;for(var i=r.targetContainers;0<i.length;){var h=bf(r.nativeEvent);if(h===null){h=r.nativeEvent;var g=new h.constructor(h.type,h);bd=g,h.target.dispatchEvent(g),bd=null}else return i=$i(h),i!==null&&Ky(i),r.blockedOn=h,!1;i.shift()}return!0}function Zy(r,i,h){Ic(r)&&h.delete(i)}function t2(){wf=!1,Ds!==null&&Ic(Ds)&&(Ds=null),Rs!==null&&Ic(Rs)&&(Rs=null),Os!==null&&Ic(Os)&&(Os=null),Mo.forEach(Zy),Io.forEach(Zy)}function Pc(r,i){r.blockedOn===i&&(r.blockedOn=null,wf||(wf=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,t2)))}var Bc=null;function ev(r){Bc!==r&&(Bc=r,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){Bc===r&&(Bc=null);for(var i=0;i<r.length;i+=3){var h=r[i],g=r[i+1],k=r[i+2];if(typeof g!="function"){if(Sf(g||h)===null)continue;break}var j=$i(h);j!==null&&(r.splice(i,3),i-=3,vh(j,{pending:!0,data:k,method:h.method,action:g},g,k))}}))}function ba(r){function i(ne){return Pc(ne,r)}Ds!==null&&Pc(Ds,r),Rs!==null&&Pc(Rs,r),Os!==null&&Pc(Os,r),Mo.forEach(i),Io.forEach(i);for(var h=0;h<Ms.length;h++){var g=Ms[h];g.blockedOn===r&&(g.blockedOn=null)}for(;0<Ms.length&&(h=Ms[0],h.blockedOn===null);)Jy(h),h.blockedOn===null&&Ms.shift();if(h=(r.ownerDocument||r).$$reactFormReplay,h!=null)for(g=0;g<h.length;g+=3){var k=h[g],j=h[g+1],B=k[Nn]||null;if(typeof j=="function")B||ev(h);else if(B){var K=null;if(j&&j.hasAttribute("formAction")){if(k=j,B=j[Nn]||null)K=B.formAction;else if(Sf(k)!==null)continue}else K=B.action;typeof K=="function"?h[g+1]=K:(h.splice(g,3),g-=3),ev(h)}}}function tv(){function r(j){j.canIntercept&&j.info==="react-transition"&&j.intercept({handler:function(){return new Promise(function(B){return k=B})},focusReset:"manual",scroll:"manual"})}function i(){k!==null&&(k(),k=null),g||setTimeout(h,20)}function h(){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,k=null;return navigation.addEventListener("navigate",r),navigation.addEventListener("navigatesuccess",i),navigation.addEventListener("navigateerror",i),setTimeout(h,100),function(){g=!0,navigation.removeEventListener("navigate",r),navigation.removeEventListener("navigatesuccess",i),navigation.removeEventListener("navigateerror",i),k!==null&&(k(),k=null)}}}function Cf(r){this._internalRoot=r}zc.prototype.render=Cf.prototype.render=function(r){var i=this._internalRoot;if(i===null)throw Error(s(409));var h=i.current,g=Vn();Wy(h,g,r,i,null,null)},zc.prototype.unmount=Cf.prototype.unmount=function(){var r=this._internalRoot;if(r!==null){this._internalRoot=null;var i=r.containerInfo;Wy(r.current,2,null,r,null,null),yc(),i[Bi]=null}};function zc(r){this._internalRoot=r}zc.prototype.unstable_scheduleHydration=function(r){if(r){var i=ft();r={blockedOn:null,target:r,priority:i};for(var h=0;h<Ms.length&&i!==0&&i<Ms[h].priority;h++);Ms.splice(h,0,r),h===0&&Jy(r)}};var nv=t.version;if(nv!=="19.2.4")throw Error(s(527,nv,"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?m(r):null,r=r===null?null:r.stateNode,r};var n2={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:z,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var $c=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!$c.isDisabled&&$c.supportsFiber)try{wt=$c.inject(n2),ct=$c}catch{}}return zo.createRoot=function(r,i){if(!a(r))throw Error(s(299));var h=!1,g="",k=c_,j=u_,B=d_;return i!=null&&(i.unstable_strictMode===!0&&(h=!0),i.identifierPrefix!==void 0&&(g=i.identifierPrefix),i.onUncaughtError!==void 0&&(k=i.onUncaughtError),i.onCaughtError!==void 0&&(j=i.onCaughtError),i.onRecoverableError!==void 0&&(B=i.onRecoverableError)),i=Vy(r,1,!1,null,null,h,g,null,k,j,B,tv),r[Bi]=i.current,sf(r),new Cf(i)},zo.hydrateRoot=function(r,i,h){if(!a(r))throw Error(s(299));var g=!1,k="",j=c_,B=u_,K=d_,ne=null;return h!=null&&(h.unstable_strictMode===!0&&(g=!0),h.identifierPrefix!==void 0&&(k=h.identifierPrefix),h.onUncaughtError!==void 0&&(j=h.onUncaughtError),h.onCaughtError!==void 0&&(B=h.onCaughtError),h.onRecoverableError!==void 0&&(K=h.onRecoverableError),h.formState!==void 0&&(ne=h.formState)),i=Vy(r,1,!0,i,h??null,g,k,ne,j,B,K,tv),i.context=Gy(null),h=i.current,g=Vn(),g=et(g),k=vs(g),k.callback=null,bs(h,k,g),h=g,i.current.lanes=h,fs(i,h),Nr(i),r[Bi]=i.current,sf(r),new zc(i)},zo.version="19.2.4",zo}var mv;function x2(){if(mv)return Tf.exports;mv=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(),Tf.exports=g2(),Tf.exports}var _2=x2();const y2=Mu(_2),pv=e=>{let t;const n=new Set,s=(f,m)=>{const p=typeof f=="function"?f(t):f;if(!Object.is(p,t)){const _=t;t=m??(typeof p!="object"||p===null)?p:Object.assign({},t,p),n.forEach(x=>x(t,_))}},a=()=>t,c={setState:s,getState:a,getInitialState:()=>d,subscribe:f=>(n.add(f),()=>n.delete(f))},d=t=e(s,a,c);return c},v2=(e=>e?pv(e):pv),b2=e=>e;function S2(e,t=b2){const n=Us.useSyncExternalStore(e.subscribe,Us.useCallback(()=>t(e.getState()),[e,t]),Us.useCallback(()=>t(e.getInitialState()),[e,t]));return Us.useDebugValue(n),n}const gv=e=>{const t=v2(e),n=s=>S2(t,s);return Object.assign(n,t),n},Yn=(e=>e?gv(e):gv);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 w2(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 Hc(e,t){return n=>({loading:{...n.loading,[e]:t}})}function xv(e,t){return n=>({settings:{...n.settings,[e]:t},loading:{...n.loading,[e]:!1}})}const aS=[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 Pu(){return{showThinking:on(e=>e.settings[ze.DISPLAY_SHOW_THINKING]??"true")==="true",showVerboseToolOutput:on(e=>e.settings[ze.DISPLAY_SHOW_VERBOSE_TOOL_OUTPUT]??"true")==="true",showStats:on(e=>e.settings[ze.DISPLAY_SHOW_STATS]??"true")==="true",showAgentDefinitions:on(e=>e.settings[ze.DISPLAY_SHOW_AGENT_DEFINITIONS]??"true")==="true",showWorkflowBars:on(e=>e.settings[ze.DISPLAY_SHOW_WORKFLOW_BARS]??"true")==="true",showSyntaxHighlighting:on(e=>e.settings[ze.DISPLAY_SHOW_SYNTAX_HIGHLIGHTING]??"true")==="true"}}const on=Yn(e=>({settings:{},loading:{},getSetting:async t=>{e(Hc(t,!0));try{const s=await(await Ne(`/api/settings/${t}`)).json();return e(xv(t,s.value??"")),s.value}catch{return e(Hc(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(Hc(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(xv(t,a.value??""))}catch{e(Hc(t,!1))}}})),Rf=Object.freeze(Object.defineProperty({__proto__:null,DISPLAY_SETTINGS_KEYS:aS,SETTINGS_KEYS:ze,useDisplaySettings:Pu,useSettingsStore:on},Symbol.toStringTag,{value:"Module"}));function C2(){const[e,t]=D.useState({offsetTop:0,height:window.innerHeight,keyboardVisible:!1}),n=D.useRef(window.innerHeight);return D.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 k2(e,t){if(e instanceof RegExp)return{keys:!1,pattern:e};var n,s,a,l,u=[],c="",d=e.split("/");for(d[0]||d.shift();a=d.shift();)n=a[0],n==="*"?(u.push(n),c+=a[1]==="?"?"(?:/(.*))?":"/(.*)"):n===":"?(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 Of={exports:{}},Mf={};/**
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 _v;function E2(){if(_v)return Mf;_v=1;var e=Iu();function t(p,_){return p===_&&(p!==0||1/p===1/_)||p!==p&&_!==_}var n=typeof Object.is=="function"?Object.is:t,s=e.useState,a=e.useEffect,l=e.useLayoutEffect,u=e.useDebugValue;function c(p,_){var x=_(),w=s({inst:{value:x,getSnapshot:_}}),C=w[0].inst,v=w[1];return l(function(){C.value=x,C.getSnapshot=_,d(C)&&v({inst:C})},[p,x,_]),a(function(){return d(C)&&v({inst:C}),p(function(){d(C)&&v({inst:C})})},[p]),u(x),x}function d(p){var _=p.getSnapshot;p=p.value;try{var x=_();return!n(p,x)}catch{return!0}}function f(p,_){return _()}var m=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:c;return Mf.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:m,Mf}var yv;function j2(){return yv||(yv=1,Of.exports=E2()),Of.exports}var N2=j2();const T2=h2.useInsertionEffect,A2=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",L2=A2?D.useLayoutEffect:D.useEffect,D2=T2||L2,oS=e=>{const t=D.useRef([e,(...n)=>t[0](...n)]).current;return D2(()=>{t[0]=e}),t[1]},R2="popstate",op="pushState",lp="replaceState",O2="hashchange",vv=[R2,op,lp,O2],M2=e=>{for(const t of vv)addEventListener(t,e);return()=>{for(const t of vv)removeEventListener(t,e)}},lS=(e,t)=>N2.useSyncExternalStore(M2,e,t),bv=()=>location.search,I2=({ssrSearch:e}={})=>lS(bv,e!=null?()=>e:bv),Sv=()=>location.pathname,P2=({ssrPath:e}={})=>lS(Sv,e!=null?()=>e:Sv),B2=(e,{replace:t=!1,state:n=null}={})=>history[t?lp:op](n,"",e),z2=(e={})=>[P2(e),B2],wv=Symbol.for("wouter_v3");if(typeof history<"u"&&typeof window[wv]>"u"){for(const e of[op,lp]){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,wv,{value:!0})}const $2=(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())?"~"+t:t.slice(e.length)||"/",cS=(e="")=>e==="/"?"":e,H2=(e,t)=>e[0]==="~"?e.slice(1):cS(t)+e,U2=(e="",t)=>$2(Cv(cS(e)),Cv(t)),Cv=e=>{try{return decodeURI(e)}catch{return e}},uS={hook:z2,searchHook:I2,parser:k2,base:"",ssrPath:void 0,ssrSearch:void 0,ssrContext:void 0,hrefs:e=>e,aroundNav:(e,t,n)=>e(t,n)},dS=D.createContext(uS),$a=()=>D.useContext(dS),hS={},fS=D.createContext(hS),F2=()=>D.useContext(fS),Bu=e=>{const[t,n]=e.hook(e);return[U2(e.base,t),oS((s,a)=>e.aroundNav(n,H2(s,e.base),a))]},hr=()=>Bu($a()),cp=(e,t,n,s)=>{const{pattern:a,keys:l}=t instanceof RegExp?{keys:!1,pattern:t}:e(t||"*",s),u=a.exec(n)||[],[c,...d]=u;return c!==void 0?[!0,(()=>{const f=l!==!1?Object.fromEntries(l.map((p,_)=>[p,d[_]])):u.groups;let m={...d};return f&&Object.assign(m,f),m})(),...s?[c]:[]]:[!1,null]},up=e=>cp($a().parser,e,hr()[0]),V2=({children:e,...t})=>{var m,p,_;const n=$a(),s=t.hook?uS:n;let a=s;const[l,u=t.ssrSearch??""]=((m=t.ssrPath)==null?void 0:m.split("?"))??[];l&&(t.ssrSearch=u,t.ssrPath=l),t.hrefs=t.hrefs??((p=t.hook)==null?void 0:p.hrefs),t.searchHook=t.searchHook??((_=t.hook)==null?void 0:_.searchHook);let c=D.useRef({}),d=c.current,f=d;for(let x in s){const w=x==="base"?s[x]+(t[x]??""):t[x]??s[x];d===f&&w!==f[x]&&(c.current=f={...f}),f[x]=w,(w!==s[x]||w!==a[x])&&(a=f)}return D.createElement(dS.Provider,{value:a,children:e})},kv=({children:e,component:t},n)=>t?D.createElement(t,{params:n}):typeof e=="function"?e(n):e,G2=e=>{let t=D.useRef(hS);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},$o=({path:e,nest:t,match:n,...s})=>{const a=$a(),[l]=Bu(a),[u,c,d]=n??cp(a.parser,e,l,t),f=G2({...F2(),...c});if(!u)return null;const m=d?D.createElement(V2,{base:d},kv(s,f)):kv(s,f);return D.createElement(fS.Provider,{value:f,children:m})},qn=D.forwardRef((e,t)=>{const n=$a(),[s,a]=Bu(n),{to:l="",href:u=l,onClick:c,asChild:d,children:f,className:m,replace:p,state:_,transition:x,...w}=e,C=oS(S=>{S.ctrlKey||S.metaKey||S.altKey||S.shiftKey||S.button!==0||(c==null||c(S),S.defaultPrevented||(S.preventDefault(),a(u,e)))}),v=n.hrefs(u[0]==="~"?u.slice(1):n.base+u,n);return d&&D.isValidElement(f)?D.cloneElement(f,{onClick:C,href:v}):D.createElement("a",{...w,onClick:C,href:v,className:m!=null&&m.call?m(s===u):m,children:f,ref:t})}),mS=e=>Array.isArray(e)?e.flatMap(t=>mS(t&&t.type===D.Fragment?t.props.children:t)):[e],W2=({children:e,location:t})=>{const n=$a(),[s]=Bu(n);for(const a of mS(e)){let l=0;if(D.isValidElement(a)&&(l=cp(n.parser,a.props.path,t||s,a.props.nest))[0])return D.cloneElement(a,{match:l})}return null};function q2(e){return typeof e=="object"&&e!==null&&"type"in e&&"payload"in e}function pS(){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 K2{constructor(t){me(this,"ws",null);me(this,"handlers",new Set);me(this,"statusHandler",null);me(this,"baseUrl");me(this,"isReconnecting",!1);me(this,"connectingPromise",null);me(this,"lastCloseCode",0);me(this,"reconnectAttempts",0);me(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 d;((d=this.ws)==null?void 0:d.readyState)===WebSocket.CONNECTING&&(this.ws.close(),l(new Error("Connection timeout")))},5e3);this.ws.onopen=()=>{var d;clearTimeout(c),this.isReconnecting=!1,this.connectingPromise=null,(d=this.statusHandler)==null||d.call(this,"connected"),a()},this.ws.onclose=d=>{var f,m,p;clearTimeout(c),this.lastCloseCode=d.code,((f=this.ws)==null?void 0:f.readyState)===WebSocket.CONNECTING?(this.connectingPromise=null,(m=this.statusHandler)==null||m.call(this,"disconnected"),l(new Error(`Connection closed: ${d.code}`))):(this.connectingPromise=null,(p=this.statusHandler)==null||p.call(this,"disconnected"),this.attemptReconnect())},this.ws.onerror=d=>{clearTimeout(c),console.error("WebSocket error:",d),this.connectingPromise=null,l(d)},this.ws.onmessage=d=>{try{const f=JSON.parse(d.data);q2(f)&&this.handlers.forEach(m=>m(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=pS(),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 Y2=window.location.protocol==="https:"?"wss:":"ws:";let km=window.location.port;km||(km=window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"?"10469":window.location.protocol==="https:"?"443":"80");const X2=`${Y2}//${window.location.hostname}:${km}/ws`,$t=new K2(X2),Q2=3e4;function dp(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"unknown":return"Other"}}const zt=Yn((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 d=l?l.split("/"):[],f=d[0],m=d.slice(1).join("/")??"";if(f===n&&m)u=m;else{const p=a.find(_=>_.id===n);u=((c=p==null?void 0:p.models[0])==null?void 0:c.id)??""}}e({activeProviderId:n,model:u,defaultModelSelection:`${n}/${u}`,providers:a.map(d=>({...d,isActive:d.id===n}))})},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()},Q2);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}})),Rt=Yn((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})}})),qs=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"}}},zu=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 gS(e){let t=null;function n(){t===null&&(t=requestAnimationFrame(()=>{t=null,e()}))}return n}let Uc=[];const tl=Yn()((e,t)=>{function n(){if(Uc.length===0)return;const a=Uc;Uc=[],e(l=>{const u={...l.logs};for(const c of a){const d=u[c.processId]??[];u[c.processId]=[...d,{offset:d.length,content:c.content,timestamp:Date.now(),stream:c.stream}]}return{logs:u}})}const s=gS(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)=>{Uc.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:d,status:f}=l;e(m=>({processes:[...m.processes,{id:u,sessionId:"",name:c,command:"",cwd:"",pid:d,status:f,exitCode:null,createdAt:Date.now(),startedAt:Date.now(),endedAt:null}]}));break}case"backgroundProcess.output":{const u=l.processId,c=l.stream,d=l.content;t().appendLog(u,c,d);break}case"backgroundProcess.exited":{const u=l.processId,c=l.exitCode;e(d=>({processes:d.processes.map(f=>f.id===u?{...f,status:"exited",exitCode:c}:f)}));break}case"backgroundProcess.removed":{const u=l.processId;t().removeProcess(u);break}}}}}),J2={messageId:null,deltaContent:"",thinkingContent:"",toolOutput:[]};let lu=null;function Z2(e){lu=e}function bi(){return J2}function If(){lu==null||lu()}let Fc=[];const Or=Yn()((e,t)=>{function n(){if(Fc.length===0)return;const a=Fc;Fc=[],e(l=>({logs:[...l.logs,...a]}))}const s=gS(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(d=>({stream:d.stream,content:d.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;Fc.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}}}}}),ej=[{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"}],tj=[{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"}],xS={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"},Fs={soundEnabled:!0,browserNotification:!1,customSoundUrl:null},_S={soundEnabled:!1,browserNotification:!1,customSoundUrl:null},Em={soundEnabled:!0,browserNotificationEnabled:!1,events:{complete:{...Fs},waiting_for_user:{...Fs},phase_done:{...Fs},phase_blocked:{...Fs},new_message:{..._S}},agentOverrides:{}};function yS(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 wi=Yn((e,t)=>({settings:Em,loaded:!1,load:()=>{on.getState().getSetting(ze.NOTIFICATION_SETTINGS);const s=on.subscribe(l=>{const u=l.settings[ze.NOTIFICATION_SETTINGS];if(u!==void 0)try{const c=JSON.parse(u);e({settings:Ev(c),loaded:!0})}catch{e({loaded:!0})}}),a=on.getState().settings[ze.NOTIFICATION_SETTINGS];if(a)try{const l=JSON.parse(a);e({settings:Ev(l),loaded:!0})}catch{e({loaded:!0})}return s},update:n=>{e({settings:n}),Pf(n)},updateEvent:(n,s)=>{const a=t().settings,l={...a,events:{...a.events,[n]:{...a.events[n],...s}}};e({settings:l}),Pf(l)},updateAgentOverride:(n,s,a)=>{var d;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]:{...((d=u[n])==null?void 0:d[s])??{},...a}};const c={...l,agentOverrides:u};e({settings:c}),Pf(c)}}));function Pf(e){on.getState().setSetting(ze.NOTIFICATION_SETTINGS,JSON.stringify(e))}function Ev(e){var t,n,s,a,l;return{soundEnabled:e.soundEnabled??Em.soundEnabled,browserNotificationEnabled:e.browserNotificationEnabled??Em.browserNotificationEnabled,events:{complete:{...Fs,...(t=e.events)==null?void 0:t.complete},waiting_for_user:{...Fs,...(n=e.events)==null?void 0:n.waiting_for_user},phase_done:{...Fs,...(s=e.events)==null?void 0:s.phase_done},phase_blocked:{...Fs,...(a=e.events)==null?void 0:a.phase_blocked},new_message:{..._S,...(l=e.events)==null?void 0:l.new_message}},agentOverrides:e.agentOverrides??{}}}const jv=new Map;function nj(e){let t=jv.get(e);return t||(t=new Audio(e),t.volume=.5,jv.set(e,t)),t}let vS=typeof Notification<"u"?Notification.permission:"denied";function rj(){return typeof Notification>"u"?Promise.resolve("denied"):Notification.requestPermission().then(e=>(vS=e,e))}const sj={complete:"Task Complete",waiting_for_user:"Waiting for Input",phase_done:"Phase Complete",phase_blocked:"Phase Blocked",new_message:"New Message"},ij={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 aj(e){typeof Notification>"u"||vS==="granted"&&(document.hasFocus()||new Notification(sj[e],{body:ij[e],icon:"/fox.svg",tag:`openfox-${e}`}))}function gl(e,t){const{settings:n}=wi.getState(),s=yS(n,e,t);if(n.soundEnabled&&s.soundEnabled){const a=s.customSoundUrl??xS[e],l=nj(a);l.currentTime=0,l.play().catch(()=>{})}n.browserNotificationEnabled&&s.browserNotification&&aj(e)}const oj=e=>gl("complete",e),lj=e=>gl("phase_done",e),cj=e=>gl("phase_blocked",e),Nv=e=>gl("waiting_for_user",e),uj=e=>gl("new_message",e),Tv=new Map;function Jo(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 dj(e,t){if(e.type==="chat.done"){const n=e.payload,s=Jo(t,e.sessionId),a=n.agentType??s;n.reason==="complete"&&oj(a),n.reason==="waiting_for_user"&&Nv(a);return}if(e.type==="chat.path_confirmation"){const n=Jo(t,e.sessionId);Nv(n);return}if(e.type==="task.completed"){const n=Jo(t,e.sessionId);lj(n);return}if(e.type==="phase.changed"&&e.sessionId){const n=e.payload,s=Tv.get(e.sessionId)??null;if(Tv.set(e.sessionId,n.phase),s===n.phase)return;const a=Jo(t,e.sessionId);n.phase==="blocked"&&cj(a)}}const Bf=new Set;function Wt(e,t){return t!==null&&e.sessionId===t}function hj(e,t,n){return e.id!==void 0||Wt(e,t)||n===!0&&e.sessionId!==void 0}function fj(e,t){return e.includes(t)?e:[...e,t]}function Av(e,t){return e.filter(n=>n!==t)}function mj(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 pj(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 Lv(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(d=>({sessions:d.sessions.map(f=>f.id===a?s(f):f)})),!u){const d=n().currentSession;if(d){const f=s(d);t(()=>({currentSession:f}))}}}function Dv(e,t,n){var u,c,d,f,m,p,_,x,w,C,v,S,b,y,E,N,T,L,A,R,M,G,W;const s=n();dj(e,s);const a=((u=s.currentSession)==null?void 0:u.id)??null,l=()=>{const O=e.sessionId;!O||O===a||t(U=>({unreadSessionIds:fj(U.unreadSessionIds,O)}))};switch(e.type){case"session.state":{const O=e.payload;if(!hj(e,a,s.pendingSessionCreate))break;const U=O.messages.find(z=>z.isStreaming)??null,V=n().pendingSessionCreate===!0;if(t({currentSession:O.session,sessions:mj(n().sessions,O.session),unreadSessionIds:Av(n().unreadSessionIds,O.session.id),messages:O.messages,streamingMessageId:(U==null?void 0:U.id)??null,streamingMessage:U,currentTodos:[],pendingPathConfirmations:O.pendingConfirmations??[],pendingQuestions:O.pendingQuestions??[],error:null,...V?{pendingSessionCreate:O.session.id}:{}}),O.session.providerId){const z=zt.getState();z.providers.find(te=>te.id===O.session.providerId)&&z.syncFromSession(O.session.providerId,O.session.providerModel??"")}break}case"session.list":{const O=e.payload;t(U=>({sessions:pj(O.sessions,U.sessions,U.currentSession)}));break}case"session.deleted":{const O=e.payload;t(U=>({unreadSessionIds:Av(U.unreadSessionIds,O.sessionId)})),n().listSessions();break}case"session.deletedAll":{n().listSessions();break}case"session.running":{const O=e.payload;Lv(e,t,n,U=>({...U,isRunning:O.isRunning})),O.isRunning||t({abortInProgress:!1,queuedMessages:[]}),O.isRunning&&t({restoredInput:null});break}case"chat.message":{if(!Wt(e,((c=n().currentSession)==null?void 0:c.id)??null)){l();break}const O=e.payload;t(U=>{if(U.messages.some(z=>z.id===O.message.id))return U;const V=O.message.role==="user";return{messages:[...U.messages,O.message],sessions:U.sessions.map(z=>z.id===e.sessionId&&V?{...z,messageCount:z.messageCount+1}:z),streamingMessageId:O.message.isStreaming?O.message.id:U.streamingMessageId,streamingMessage:O.message.isStreaming?O.message:U.streamingMessage}});break}case"chat.message_updated":{if(!Wt(e,((d=n().currentSession)==null?void 0:d.id)??null)){l();break}const O=e.payload,U=O.updates.isStreaming===!1&&n().streamingMessageId===O.messageId;t(V=>{const z=V.streamingMessage;if(z&&z.id===O.messageId){const X={...z,...O.updates};return{messages:V.messages.map(te=>te.id===O.messageId?X:te),streamingMessageId:U?null:V.streamingMessageId,streamingMessage:U?null:{...z,...O.updates}}}return{messages:V.messages.map(X=>X.id===O.messageId?{...X,...O.updates}:X),streamingMessageId:U?null:V.streamingMessageId}});break}case"chat.delta":{if(!Wt(e,((f=n().currentSession)==null?void 0:f.id)??null)){l();break}const O=e.payload;if(!Bf.has(O.messageId)){Bf.add(O.messageId);const V=O.subAgentType?"sub-agent":Jo(n(),e.sessionId);uj(V)}const U=bi();U.messageId=O.messageId,U.deltaContent+=O.content,If();break}case"chat.thinking":{if(!Wt(e,((m=n().currentSession)==null?void 0:m.id)??null)){l();break}const O=e.payload,U=bi();U.messageId=O.messageId,U.thinkingContent+=O.content,If();break}case"chat.tool_preparing":{if(!Wt(e,((p=n().currentSession)==null?void 0:p.id)??null)){l();break}const O=e.payload,U=n().streamingMessage;if(!U||U.id!==O.messageId||((_=U.toolCalls)==null?void 0:_.find((z,X)=>X===O.index)))return;t(z=>{const X=z.streamingMessage.preparingToolCalls??[],te=X.findIndex(I=>I.index===O.index);let H;return te>=0?H=X.map((I,$)=>$===te?{...I,arguments:O.arguments}:I):H=[...X,{index:O.index,name:O.name,...O.arguments?{arguments:O.arguments}:{}}],{streamingMessage:{...z.streamingMessage,preparingToolCalls:H}}});break}case"chat.tool_call":{if(!Wt(e,((x=n().currentSession)==null?void 0:x.id)??null)){l();break}const O=e.payload,U=V=>{var H;const z=(H=V.preparingToolCalls)==null?void 0:H.filter((I,$)=>{var F;return I.name===O.tool?(F=V.preparingToolCalls)==null?void 0:F.slice(0,$).some(ee=>ee.name===O.tool):!0}),X=bi(),te=X.toolOutput.filter(I=>I.callId===O.callId);return te.length>0&&(X.toolOutput=X.toolOutput.filter(I=>I.callId!==O.callId)),{...V,toolCalls:[...V.toolCalls??[],{id:O.callId,name:O.tool,arguments:O.args,startedAt:Date.now(),...te.length>0?{streamingOutput:te.map(I=>({stream:I.stream,content:I.content,timestamp:Date.now()}))}:{}}],...z&&z.length>0?{preparingToolCalls:z}:{preparingToolCalls:void 0}}};t(V=>{const z=V.streamingMessage;return z&&z.id===O.messageId?{streamingMessage:U(z)}:{messages:V.messages.map(X=>X.id===O.messageId?U(X):X)}});break}case"chat.tool_output":{if(!Wt(e,((w=n().currentSession)==null?void 0:w.id)??null)){l();break}const O=e.payload,U=bi();U.messageId=O.messageId,U.toolOutput.push({messageId:O.messageId,callId:O.callId,stream:O.stream,content:O.output}),If();break}case"chat.tool_result":{if(!Wt(e,((C=n().currentSession)==null?void 0:C.id)??null)){l();break}const O=e.payload,U=V=>{var X;const z=(X=V.toolCalls)==null?void 0:X.map(te=>te.id===O.callId?{...te,result:O.result}:te);return{...V,toolCalls:z}};t(V=>{const z=V.streamingMessage;return z&&z.id===O.messageId?{streamingMessage:U(z)}:{messages:V.messages.map(X=>X.id===O.messageId?U(X):X)}});break}case"chat.vision_fallback":{if(!Wt(e,((v=n().currentSession)==null?void 0:v.id)??null)){l();break}const O=e.payload;t(U=>{const V=`${O.messageId}-${O.attachmentId}`,z={...U.visionFallbackByMessage};return z[V]={type:O.type,attachmentId:O.attachmentId,filename:O.filename,description:O.description},{visionFallbackByMessage:z}});break}case"chat.todo":{if(!Wt(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(!Wt(e,((b=n().currentSession)==null?void 0:b.id)??null)){l();break}const O=e.payload;console.warn("Progress:",O.message,O.phase);break}case"chat.format_retry":{if(!Wt(e,((y=n().currentSession)==null?void 0:y.id)??null)){l();break}const O=e.payload;console.warn("Format retry:",O.attempt,"/",O.maxAttempts);break}case"chat.done":{if(!Wt(e,((E=n().currentSession)==null?void 0:E.id)??null)){l();break}const O=bi();O.messageId=null,O.deltaContent="",O.thinkingContent="",O.toolOutput=[],Bf.delete(e.payload.messageId);const U=e.payload,V=U.stats;t(z=>{const X=z.streamingMessage,te=X&&X.id===U.messageId?{...X,isStreaming:!1,stats:V??X.stats}:null;return{messages:z.messages.map(H=>H.id===U.messageId?te??{...H,isStreaming:!1,stats:V??H.stats,completeReason:U.reason}:H),streamingMessageId:null,streamingMessage:null,visionFallbackByMessage:{}}});break}case"chat.error":{if(!Wt(e,((N=n().currentSession)==null?void 0:N.id)??null)){l();break}const O=bi(),U=e.payload;console.error("Chat error:",U.error,"recoverable:",U.recoverable),U.recoverable||(O.messageId=null,O.deltaContent="",O.thinkingContent="",O.toolOutput=[]),t(V=>({error:{code:"CHAT_ERROR",message:U.error},streamingMessageId:U.recoverable?V.streamingMessageId:null,...U.recoverable?{}:{messages:V.streamingMessage?V.messages.map(z=>z.id===V.streamingMessage.id?V.streamingMessage:z):V.messages,streamingMessage:null}}));break}case"chat.path_confirmation":{if(!Wt(e,((T=n().currentSession)==null?void 0:T.id)??null)){l();break}const O=e.payload,U={callId:O.callId,tool:O.tool,paths:O.paths,workdir:O.workdir,reason:O.reason};t(V=>({pendingPathConfirmations:[...V.pendingPathConfirmations,U]}));break}case"chat.ask_user":{if(!Wt(e,((L=n().currentSession)==null?void 0:L.id)??null)){l();return}const O=e.payload,U={callId:O.callId,question:O.question,type:O.type??"text",options:O.options??void 0};t(V=>({pendingQuestions:[...V.pendingQuestions.filter(z=>z.callId!==O.callId),U]}));break}case"mode.changed":{if(!Wt(e,((A=n().currentSession)==null?void 0:A.id)??null)){l();break}const O=e.payload;t(U=>({currentSession:U.currentSession?{...U.currentSession,mode:O.mode}:null}));break}case"phase.changed":{const O=e.payload;Lv(e,t,n,U=>({...U,phase:O.phase}));break}case"criteria.updated":{if(!Wt(e,((R=n().currentSession)==null?void 0:R.id)??null)){l();break}const O=e.payload;t(U=>({currentSession:U.currentSession?{...U.currentSession,criteria:O.criteria}:null}));break}case"metadata.updated":{if(!Wt(e,((M=n().currentSession)==null?void 0:M.id)??null)){l();break}const O=e.payload;t(U=>({currentSession:U.currentSession?{...U.currentSession,metadataEntries:{...U.currentSession.metadataEntries,[O.key]:O.entries}}:null}));break}case"context.state":{const O=e.payload,U=Wt(e,((G=n().currentSession)==null?void 0:G.id)??null);O.subAgentId?U&&n().updateSubAgentContextState(O.subAgentId,O.context):U?t({contextState:O.context}):l();break}case"session.name_generated":{const O=e.payload,U=e.sessionId,V=(W=n().currentSession)==null?void 0:W.id;t(z=>{const X=z.sessions.map(H=>H.id===U?{...H,title:O.name,updatedAt:new Date().toISOString()}:H),te=V===U?z.currentSession?{...z.currentSession,title:O.name,updatedAt:new Date().toISOString()}:null:z.currentSession;return{sessions:X,currentSession:te}});break}case"queue.state":{const O=e.payload;t({queuedMessages:O.messages??[]});break}case"mcp.servers.changed":{window.dispatchEvent(new CustomEvent("mcp-servers-changed"));break}case"git.status":{const O=e.payload;t({gitStatus:{branch:O.branch,diff:O.diff}});break}case"devServer.output":case"devServer.state":{Or.getState().handleMessage(e);break}case"backgroundProcess.started":case"backgroundProcess.output":case"backgroundProcess.exited":case"backgroundProcess.removed":{tl.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 Ho=!1,Tr=null;const zf=new Set,Vc=new Map;function Rv(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 Ov(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=Yn((e,t)=>(Z2(()=>{const n=bi();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,d=n.toolOutput;n.deltaContent="",n.thinkingContent="",n.toolOutput=[],e(f=>{const m=f.streamingMessage;if(m&&m.id===n.messageId){const p={...m};if(s&&(p.content=p.content+u),a&&(p.thinkingContent=(p.thinkingContent??"")+c),l){const _=new Set;p.toolCalls=Rv(p.toolCalls,d,_);const x=d.filter(w=>!_.has(w.callId));x.length>0&&n.toolOutput.push(...x)}return{streamingMessage:p}}if(l){const p=new Set,_=f.messages.map(w=>w.id!==n.messageId?w:{...w,toolCalls:Rv(w.toolCalls,d,p)}),x=d.filter(w=>!p.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:[],pendingQuestions:[],visionFallbackByMessage:{},gitStatus:null,queuedMessages:[],abortInProgress:!1,restoredInput:null,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&&!$t.hasToken()){e({showPasswordModal:!0,passwordModalRetry:!1,connectionStatus:"reconnecting"});return}$t.onStatusChange(a=>{var l;if(e({connectionStatus:a}),a==="connected"){t().listSessions(void 0),Rt.getState().listProjects();const u=(l=t().currentSession)==null?void 0:l.id;u&&t().loadSession(u)}});try{await $t.connect(),Ho||(Ho=!0,Tr=$t.subscribe(a=>{Dv(a,e,t)}))}catch(a){console.error("Failed to connect:",a);const l=$t.getLastCloseCode();if(!$t.hasToken()&&(l===1006||l===4e3)){e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"});return}Tr&&(Tr(),Tr=null),Ho=!1,e({connectionStatus:"disconnected"})}},reconnect:()=>{$t.disconnect(),Tr&&(Tr(),Tr=null),Ho=!1,e({connectionStatus:"disconnected"}),t().connect()},disconnect:()=>{$t.disconnect(),Tr&&(Tr(),Tr=null),Ho=!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();$t.setToken(a),e({showPasswordModal:!1}),t().connect();const{listProjects:l}=Rt.getState(),{fetchConfig:u}=zt.getState();l(),u(),t().connect()}catch{e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"})}},cancelPassword:()=>{$t.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{$t.send("session.load",{sessionId:u.session.id})}catch{}return u.session}catch{return e({pendingSessionCreate:!1}),null}},loadSession:async n=>{if(!zf.has(n)){zf.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:[],pendingQuestions:[],queuedMessages:[],abortInProgress:!1,restoredInput:null,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??[],pendingQuestions:l.pendingQuestions??[]}),$t.send("session.load",{sessionId:n});try{const u=await Ne(`/api/sessions/${n}/background-processes`);if(u.ok){const c=await u.json();tl.getState().setProcesses(c.processes??[])}}catch{}}catch{}finally{zf.delete(n)}}},listSessions:async(n,s=20)=>{const a=n??"global";if(Vc.has(a))return Vc.get(a);const l=(async()=>{try{const u=new URLSearchParams;u.set("limit",String(s)),n&&u.set("projectId",n);const d=await(await Ne(`/api/sessions?${u.toString()}`)).json(),f=d.sessions??[];e(m=>({sessions:f.map(p=>{var x,w;const _=m.sessions.find(C=>C.id===p.id);return{...p,title:p.title??(_==null?void 0:_.title),mode:((x=m.currentSession)==null?void 0:x.id)===p.id?m.currentSession.mode:(_==null?void 0:_.mode)??p.mode,phase:((w=m.currentSession)==null?void 0:w.id)===p.id?m.currentSession.phase:(_==null?void 0:_.phase)??p.phase,isRunning:p.isRunning&&(_==null?void 0:_.isRunning)!==!1,messageCount:p.messageCount,recentUserPrompts:p.recentUserPrompts}}),sessionsHasMore:n?d.hasMore??!1:!0}))}catch{}finally{Vc.delete(a)}})();return Vc.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(d=>({sessions:[...d.sessions,...c.map(f=>{const m=d.sessions.find(p=>p.id===f.id);return(m==null?void 0:m.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,restoredInput: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 d=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();d.queueState&&e({queuedMessages:d.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{const l=await(await Ne(`/api/sessions/${n}/stop`,{method:"POST"})).json();if(l.queuedMessages&&l.queuedMessages.length>0){const u=l.queuedMessages.map(c=>c.content).join(`
59
+ `);e({restoredInput:u})}}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),$t.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 d;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=(d=t().currentSession)==null?void 0:d.id;c&&Ne(`/api/sessions/${c}/mode`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:"builder"})}).then(()=>{$t.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:()=>{$t.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 d=await c.json();if(e({currentSession:d.session,messages:d.messages??[],contextState:d.contextState}),(l=d.session)!=null&&l.providerId){const f=zt.getState();f.providers.find(p=>p.id===d.session.providerId)&&f.syncFromSession(d.session.providerId,d.session.providerModel??"")}return d.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,a)=>{var u;const l=(u=t().currentSession)==null?void 0:u.id;if(l){try{await Ne(`/api/sessions/${l}/answer`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({callId:n,answer:s,skip:a})})}catch(c){console.error("Error answering question:",c)}e(c=>({pendingQuestions:c.pendingQuestions.filter(d=>d.callId!==n)}))}},queueAsap:async(n,s,a)=>{var u;const l=(u=t().currentSession)==null?void 0:u.id;l&&await Ov(l,n,s,a,e)},queueCompletion:async(n,s,a)=>{var u;const l=(u=t().currentSession)==null?void 0:u.id;l&&await Ov(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})},clearRestoredInput:()=>{e({restoredInput:null})},resetPendingSessionCreate:()=>{e({pendingSessionCreate:!1})},handleServerMessage:n=>{Dv(n,e,t)}}));function $u(){return we(e=>{var t;return((t=e.currentSession)==null?void 0:t.isRunning)??!1})}function gj(){return we(e=>e.abortInProgress)}function xj(){const e=we(s=>s.connect),t=we(s=>s.connectionStatus),n=wi(s=>s.load);return D.useEffect(()=>{e()},[e]),D.useEffect(()=>{t==="connected"&&n()},[t,n]),{connectionStatus:t}}const _j="modulepreload",yj=function(e){return"/"+e},Mv={},Q=function(t,n,s){let a=Promise.resolve();if(n&&n.length>0){let u=function(f){return Promise.all(f.map(m=>Promise.resolve(m).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),d=(c==null?void 0:c.nonce)||(c==null?void 0:c.getAttribute("nonce"));a=u(n.map(f=>{if(f=yj(f),f in Mv)return;Mv[f]=!0;const m=f.endsWith(".css"),p=m?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${p}`))return;const _=document.createElement("link");if(_.rel=m?"stylesheet":_j,m||(_.as="script"),_.crossOrigin="",_.href=f,d&&_.setAttribute("nonce",d),document.head.appendChild(_),m)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)})},vj=[{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"}],bj=[{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"}}],bS={tokens:vj,presets:bj},SS=bS.tokens,Ir=bS.presets;function Iv(){try{const e=localStorage.getItem("openfox:userPresets");if(e)return JSON.parse(e)}catch{}return[]}const Ft=Yn((e,t)=>({currentPreset:"dark",basePreset:"",customTokens:{},isCustom:!1,isCustomizing:!1,userPresets:Iv(),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(Ir.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=Ir.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=Ir.find(f=>f.id===n))==null?void 0:u.tokens)??{},...s};if(a)return{...SS.reduce((d,f)=>({...d,[f.key]:f.defaultValue}),{}),...s};const l=Ir.find(d=>d.id===t().currentPreset);return(l==null?void 0:l.tokens)??((c=Ir[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 Q(async()=>{const{useSettingsStore:a}=await Promise.resolve().then(()=>Rf);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}),Q(async()=>{const{useSettingsStore:s,SETTINGS_KEYS:a}=await Promise.resolve().then(()=>Rf);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:Iv()})},saveUserPresets:()=>{localStorage.setItem("openfox:userPresets",JSON.stringify(t().userPresets)),Q(async()=>{const{useSettingsStore:n}=await Promise.resolve().then(()=>Rf);return{useSettingsStore:n}},void 0).then(({useSettingsStore:n})=>{n.getState().setSetting(ze.DISPLAY_USER_PRESETS,JSON.stringify(t().userPresets)).catch(()=>{})})}}));function Sj({canLoad:e,projectId:t,currentProjectId:n}){const s=Rt(u=>u.loadProject),a=we(u=>u.listSessions),l=we(u=>u.clearSession);D.useEffect(()=>{e&&t&&(n!==t&&s(t),a(t),l())},[e,t,n,s,a,l])}function wj({canLoad:e,projectId:t,sessionId:n,currentProjectId:s,currentSessionId:a}){const l=we(f=>f.loadSession),u=Rt(f=>f.loadProject),c=we(f=>f.listSessions),d=we(f=>f.pendingSessionCreate);D.useEffect(()=>{e&&t&&s!==t&&u(t)},[e,t,s,u]),D.useEffect(()=>{e&&n&&a!==n&&l(n),e&&t&&c(t)},[e,n,a,l,c,d,t])}function Cj({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 hp({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 kj({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 Ej({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 jj({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 Pr({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 dr({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 Nj({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 fp({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 Tj({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 mp({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 fu({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 Hu({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 Aj({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 Lj({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 wS({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 CS({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 Dj({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 Pv({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 kS({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 Rj({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 Oj({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 Ks({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 Mj({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 pp({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 Ij({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 Pj({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 Bj({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 zj({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 ES({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 $j({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 Hj({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 xl({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 gp(){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 Uj({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 jm({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 _l({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 jS({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 Fj({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 Vj({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 Bv({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 Nm(){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 zv(e,t){const n=$t.ws;!n||n.readyState!==WebSocket.OPEN||n.send(JSON.stringify({id:Nm(),type:e,payload:t}))}const yr=Yn((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=$t.ws;if(l&&l.readyState===WebSocket.OPEN)for(const u of a)l.send(JSON.stringify({id:Nm(),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=$t.ws;u&&u.readyState===WebSocket.OPEN&&u.send(JSON.stringify({id:Nm(),type:"terminal.subscribe",payload:{sessionId:l.id}}))}}catch(a){console.error("Failed to create terminal:",a)}},writeSession:(n,s)=>{zv("terminal.write",{sessionId:n,data:s})},resizeSession:(n,s,a)=>{zv("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}}}}));$t.subscribe(e=>{var t;(t=e.type)!=null&&t.startsWith("terminal.")&&yr.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 Tm(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 $v(e){return e.code.startsWith("Digit")?e.code.slice(-1):e.code.startsWith("Key")?e.code.slice(3).toLowerCase():e.key}function NS(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 Gj(e){return e.type==="double-press"}function TS(e){return e.type==="chord"}function Wj(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 AS(e,t){const n=t.modifiers.includes("ctrl"),s=t.modifiers.includes("meta"),a=t.modifiers.includes("alt"),l=t.modifiers.includes("shift");return Wj(e,t.key)&&e.ctrlKey===n&&e.metaKey===s&&e.altKey===a&&e.shiftKey===l}function xp(){const e=on(t=>t.settings[ze.KEYBINDINGS]);return Tm(e)}function qj(e,t,n){const s=D.useRef(0),a=D.useRef(t);a.current=t,D.useEffect(()=>{if(!e)return;const l=e.threshold??300,u=c=>{if(c.key!==e.key)return;const d=e.key==="Control",f=e.key==="Shift",m=e.key==="Alt",p=e.key==="Meta";if(!d&&c.ctrlKey||!f&&c.shiftKey||!m&&c.altKey||!p&&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 Kj(e,t){const n=D.useRef(t);n.current=t,D.useEffect(()=>{if(!e)return;const s=a=>{AS(a,e)&&(a.preventDefault(),n.current())};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[e])}function LS(e,t,n){qj(e&&Gj(e)?e:void 0,t,n),Kj(e&&TS(e)?e:void 0,t)}function Yj(e,t,n){const s=D.useRef(n);s.current=n,D.useEffect(()=>{const a=l=>{for(let u=0;u<e.length;u++){const c=e[u];if(!c)continue;const d=t[u];if(d&&TS(c)&&AS(l,c)){l.preventDefault(),s.current(d.id);return}}};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[e,t])}var Ha=iS();const Uu=D.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})})}));Uu.displayName="IconButton";const Xj="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",Vs=D.forwardRef((e,t)=>o.jsx(Uu,{ref:t,icon:Xj,title:"Edit",...e}));Vs.displayName="EditButton";const Qj="M6 18L18 6M6 6l12 12",_p=D.forwardRef((e,t)=>o.jsx(Uu,{ref:t,icon:Qj,...e}));_p.displayName="CloseButton";const Jj={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 Ot({label:e,title:t,headerRight:n,size:s="md",minHeight:a,children:l,footer:u,className:c,onClose:d,isOpen:f,closeOnBackdropClick:m=!0,closeOnEscape:p=!0,showCloseButton:_=!0}){const[x,w]=D.useState(!1),C=f!==void 0,v=C?f:x,S=D.useCallback(()=>{C||w(!0)},[C]),b=D.useCallback(()=>{C||w(!1),d==null||d()},[C,d]);D.useEffect(()=>{if(!v||!p)return;const E=N=>{N.key==="Escape"&&(N.stopPropagation(),b())};return document.addEventListener("keydown",E),()=>document.removeEventListener("keydown",E)},[v,b,p]);const y=e&&(typeof e=="string"?o.jsx("button",{type:"button",onClick:S,className:c,children:e}):o.jsx("span",{onClick:S,className:c,style:{cursor:"pointer"},children:e}));return o.jsxs(o.Fragment,{children:[y,v&&(typeof document<"u"?Ha.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:m?b:void 0}),o.jsxs("div",{className:`relative w-full ${Jj[s]} max-h-[90vh] bg-bg-secondary border border-border rounded shadow-xl flex flex-col`,children:[(t||n||_)&&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}),o.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[n,_&&o.jsx(_p,{onClick:b,"aria-label":"Close"})]})]}),o.jsx("div",{className:"p-4 overflow-y-auto flex-1 min-h-0",style:a?{minHeight:a}:void 0,children:l}),u&&o.jsx("div",{className:"px-4 py-3 border-t border-border",children:u})]})]}),document.body):null)]})}function Zj({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:tj.map(({url:l,label:u})=>o.jsx("option",{value:l,title:u,children:u.split(" ")[0]},l))}),o.jsx(dr,{className:"absolute right-0.5 top-1/2 -translate-y-1/2 w-3 h-3 pointer-events-none text-text-muted"})]})}const Hv=[{key:"general",label:"General"},{key:"build",label:"Agent"},{key:"sub-agent",label:"Sub-agent"}];function eN(){const e=wi(d=>d.settings),t=wi(d=>d.update),n=wi(d=>d.updateEvent),s=wi(d=>d.updateAgentOverride),a=wi(d=>d.load);D.useEffect(()=>{a()},[a]);const l=async()=>{await rj()==="granted"&&t({...e,browserNotificationEnabled:!0})},u=(d,f,m,p)=>{d==="general"?n(f,{[m]:p}):s(d,f,{[m]:p})},c=(d,f,m)=>{d==="general"?n(f,{customSoundUrl:m}):s(d,f,{customSoundUrl:m})};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(Uv,{label:"Sound notifications",description:"Play sounds when events occur",checked:e.soundEnabled,onChange:d=>t({...e,soundEnabled:d})}),o.jsx(Uv,{label:"Browser notifications",description:"Show desktop notifications when the window is not focused",checked:e.browserNotificationEnabled,onChange:d=>{d&&typeof Notification<"u"&&Notification.permission!=="granted"?l():t({...e,browserNotificationEnabled:d})}}),typeof Notification<"u"&&Notification.permission==="denied"&&e.browserNotificationEnabled&&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"}),Hv.map(d=>o.jsx("th",{className:"text-center px-2 py-2 text-text-primary font-medium",children:d.label},d.key))]})}),o.jsx("tbody",{children:ej.map(d=>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:d.label})}),Hv.map(f=>{const m=yS(e,d.key,f.key==="general"?void 0:f.key),p=xS[d.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:m.soundEnabled,onChange:_=>u(f.key,d.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:m.browserNotification,onChange:_=>u(f.key,d.key,"browserNotification",_.target.checked),disabled:!e.browserNotificationEnabled,className:"rounded border-border",title:"Browser"})})]}),m.soundEnabled&&e.soundEnabled&&o.jsx(Zj,{value:m.customSoundUrl,defaultUrl:p,disabled:!e.soundEnabled,onChange:_=>c(f.key,d.key,_)})]})},f.key)})]},d.key))})]})})]})]})}function Uv({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=D.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"},d={sm:"px-1.5 py-1 text-xs",md:"px-3 py-1.5 text-sm",lg:"px-4 py-2 text-base"};return o.jsx("button",{ref:l,className:`${u} ${c[e]} ${d[t]} ${n}`,...a,children:s})});tt.displayName="Button";async function yp(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 Ar=Yn((e,t)=>({defaults:[],userItems:[],projectItems:[],loading:!1,fetchSkills:async()=>{await yp("/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 qs("POST","/api/skills",{...n,destination:s});return a.success&&await t().fetchSkills(),a},updateSkill:async(n,s)=>{const a=await qs("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)=>zu(`/api/skills/${n}/duplicate`,()=>t().fetchSkills(),s)}));function Fu(){const[e,t]=D.useState({id:null,type:null}),n=D.useCallback(l=>t({id:l,type:"delete"}),[]),s=D.useCallback(()=>t({id:null,type:null}),[]),a=D.useCallback((l,u)=>e.id===l&&e.type===u,[e.id,e.type]);return{requestDelete:n,clearConfirm:s,isConfirming:a}}function vp({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 bp({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(xl,{})})}function mu({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(fp,{})})}function br({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 tN({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 Vu({message:e}){return o.jsx("div",{className:"text-accent-error text-sm px-3 py-2 bg-accent-error/10 rounded",children:e})}function DS({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 RS({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 Sp({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 OS({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(fu,{})}),o.jsx(mu,{onClick:a}),!e&&s&&o.jsx(Vs,{onClick:s}),!e&&(t?o.jsx(vp,{onConfirm:()=>{l==null||l()},onCancel:()=>{}}):o.jsx(bp,{onClick:()=>l==null?void 0:l()}))]})]})}function nN({id:e,name:t,description:n,isBuiltIn:s,isConfirmingDelete:a,onView:l,onEdit:u,onDuplicate:c,onDelete:d}){return o.jsxs(OS,{isBuiltIn:s,isConfirmingDelete:a,onView:l,onEdit:u,onDuplicate:c,onDelete:d,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 wp({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 MS({name:e,id:t,nameLabel:n="Name",idLabel:s="ID",namePlaceholder:a="My Item",idPlaceholder:l="my-item",nameHint:u,readOnlyId:c=!1,readOnlyHint:d="(read-only)",onNameChange:f,onIdChange:m}){return o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsx(br,{label:n,value:e,onChange:f,placeholder:a,hint:u}),o.jsx(br,{label:s,value:t,onChange:m,readOnly:c,placeholder:l,hint:c?d:void 0,mono:!0})]})}function IS(e={}){const{initialData:t={}}=e,[n,s]=D.useState("list"),[a,l]=D.useState(null),[u,c]=D.useState(""),[d,f]=D.useState(!1),[m,p]=D.useState(t),_=D.useCallback(()=>{p(t),c(""),l(null)},[t]),x=D.useCallback(S=>{s(S),S==="list"&&_()},[_]),w=D.useCallback(S=>{p(b=>typeof S=="function"?S(b):S)},[]),C=D.useCallback((S,b={})=>{l(S),s("edit"),p({...b}),c("")},[]),v=D.useCallback(()=>{l(null),s("edit"),p(t),c("")},[t]);return{view:n,editingId:a,formError:u,saving:d,formData:m,setView:x,setEditingId:l,setFormError:c,setFormData:w,setSaving:f,resetForm:_,startEditing:C,startNew:v}}function Fv({skill:e,isBuiltIn:t,isConfirmingDelete:n,onView:s,onEdit:a,onDuplicate:l,onDelete:u}){return o.jsx(nN,{id:e.id,name:e.name,description:e.description,isBuiltIn:t,isConfirmingDelete:n,onView:s,onEdit:a,onDuplicate:l,onDelete:u})}function rN({isOpen:e}){const t=Ar(z=>z.defaults),n=Ar(z=>z.userItems),s=Ar(z=>z.projectItems),a=Ar(z=>z.loading),l=Ar(z=>z.fetchSkills),u=Ar(z=>z.fetchSkill),c=Ar(z=>z.fetchDefaultContent),d=Ar(z=>z.createSkill),f=Ar(z=>z.updateSkill),m=Ar(z=>z.deleteSkill),{view:p,editingId:_,formError:x,saving:w,formData:C,setView:v,setEditingId:S,setFormError:b,setFormData:y,setSaving:E}=IS(),{clearConfirm:N}=Fu();D.useEffect(()=>{e&&(l(),v("list"),S(null),N())},[e,l,N]);const T=(z,X,te,H)=>{y({name:H??z.metadata.name,id:te??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(te=>te.id===z)){const te=await c(z);if(!te)return;T(te,!0),S(z),b(""),v("edit")}else{const te=await u(z);if(!te)return;T(te,!0),S(z),b(""),v("edit")}},A=async z=>{const te=t.some(I=>I.id===z)?await c(z):await u(z);if(!te)return;const H=`${z}-copy-${Date.now()}`;T(te,!1,H,`${te.metadata.name} (copy)`),S(null),b(""),v("edit")},R=()=>{y({name:"",id:"",description:"",version:"1.0.0",prompt:"",isReadOnly:!1,destination:"user"}),v("edit")},M=async z=>{const X=await u(z);X&&(T(X,!1),S(z),b(""),v("edit"))},G=async z=>{await m(z),N()},W=async()=>{const z=_??C.id;if(!z||!C.name||!C.prompt){b("Name, ID, and prompt are required.");return}E(!0),b("");const X={metadata:{id:z,name:C.name,description:C.description,version:C.version},prompt:C.prompt},te=_?await f(_,X):await d(X,C.destination);if(E(!1),!te.success){b(te.error??"Failed to save skill.");return}v("list")},O=z=>{y(X=>({...X,name:z})),_||y(X=>({...X,id:z.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}))},U=C.isReadOnly;if(p==="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:U?C.name:_?"Edit Skill":"New Skill"}),o.jsx("button",{onClick:()=>v("list"),className:"text-text-muted hover:text-text-primary",children:"Cancel"})]}),x&&o.jsx(Vu,{message:x}),o.jsxs("div",{className:"space-y-3 mb-3",children:[o.jsx(MS,{name:C.name,id:C.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(br,{label:"Description",value:C.description,onChange:z=>y(X=>({...X,description:z})),placeholder:"What this skill does...",readOnly:U}),o.jsx(br,{label:"Version",value:C.version,onChange:z=>y(X=>({...X,version:z})),placeholder:"1.0.0",readOnly:U})]})]}),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:C.prompt,onChange:z=>y(X=>({...X,prompt:z.target.value})),readOnly:U,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:C.destination,onChange:z=>y(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:()=>v("list"),children:"Cancel"}),U?o.jsx(tt,{variant:"primary",onClick:()=>{y(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||!C.name||!C.id||!C.prompt,children:w?"Saving...":"Save"})]})]});function V({items:z}){return z.map(X=>o.jsx(Fv,{skill:X,isBuiltIn:!1,isConfirmingDelete:!1,onView:()=>L(X.id),onEdit:()=>M(X.id),onDuplicate:()=>A(X.id),onDelete:()=>G(X.id)},X.id))}return o.jsxs("div",{children:[o.jsx(Sp,{description:"Skills provide domain-specific knowledge that agents can load on demand.",onNew:R}),o.jsxs(wp,{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(Fv,{skill:z,isBuiltIn:!0,isConfirmingDelete:!1,onView:()=>L(z.id),onDuplicate:()=>A(z.id)},z.id))})]}),n.length>0&&o.jsx(RS,{children:o.jsx(V,{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(V,{items:s})})]})]})]})}function Gu(){const e=on(a=>a.settings),t=on(a=>a.loading),n=on(a=>a.getSetting),s=on(a=>a.setSetting);return{settings:e,loading:t,getSetting:n,setSetting:s}}function sN({isOpen:e}){const{settings:t,loading:n,getSetting:s,setSetting:a}=Gu(),l=t[ze.GLOBAL_INSTRUCTIONS]??"",u=n[ze.GLOBAL_INSTRUCTIONS]??!1,[c,d]=D.useState(l),[f,m]=D.useState(!1),[p,_]=D.useState(!1);D.useEffect(()=>{e&&s(ze.GLOBAL_INSTRUCTIONS)},[e,s]),D.useEffect(()=>{d(l),m(!1)},[l]);const x=async()=>{_(!0),await a(ze.GLOBAL_INSTRUCTIONS,c),_(!1),m(!1)},w=()=>{d(l),m(!1)},C=u||p;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:v=>{d(v.target.value),m(!0)},placeholder:"Enter global instructions that apply to all projects...",className:"w-full min-h-80 px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono resize-y focus:outline-none focus:ring-1 focus:ring-accent-primary",disabled:C})]}),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||C,children:p?"Saving...":"Save"})]})]})}function iN(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 Si(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 aN({isOpen:e,isNew:t,basePresetId:n,presetName:s,initialTokens:a,onClose:l,onSave:u}){const[c,d]=D.useState(a),[f,m]=D.useState(s);D.useEffect(()=>{d(a),m(s)},[a,s]);const p=(v,S)=>{const b=S.startsWith("#")?iN(S):S;d(y=>({...y,[v]:b}))},_=()=>{u(f.trim()||"Untitled",{...c})},x=SS.reduce((v,S)=>{const b=S.category;return v[b]||(v[b]=[]),v[b].push(S),v},{}),w={background:"Backgrounds",surface:"Surfaces",text:"Text",accent:"Accents",border:"Border"},C=Ir.find(v=>v.id===n);return o.jsx(Ot,{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:v=>m(v.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:C==null?void 0:C.name})]}),Object.entries(x).map(([v,S])=>o.jsxs("div",{className:"space-y-3",children:[o.jsx("h4",{className:"text-xs font-medium text-text-muted uppercase",children:w[v]??v}),o.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:S.map(b=>o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsx("label",{htmlFor:b.key,className:"text-xs text-text-muted",children:b.label}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("input",{type:"color",id:b.key,value:Si(c[b.key]??b.defaultValue),onChange:y=>p(b.key,y.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[b.key]??b.defaultValue,onChange:y=>p(b.key,y.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"})]})]},b.key))})]},v))]})})}function oN(){const[e,t]=D.useState(null),n=Ft(y=>y.currentPreset),s=Ft(y=>y.isCustom),a=Ft(y=>y.basePreset),l=Ft(y=>y.isSystem),u=Ft(y=>y.applyPreset),c=Ft(y=>y.applyUserPreset),d=Ft(y=>y.deleteUserPreset),f=Ft(y=>y.saveTheme),m=Ft(y=>y.userPresets),p=y=>{y==="system"?(u(y),f(JSON.stringify({preset:"system"})).catch(()=>{})):(u(y),f(JSON.stringify({preset:y})).catch(()=>{}))},_=y=>{c(y)},x=y=>{const E=Ir.find(N=>N.id===y);E&&t({type:"new",presetIndex:m.length,basePresetId:y,presetName:E.name+" Copy",tokens:{...E.tokens}})},w=y=>{const E=m[y];if(!E)return;const N=Ir.find(L=>L.id===E.basePreset),T=N?{...N.tokens,...E.tokens}:E.tokens;t({type:"edit",presetIndex:y,basePresetId:E.basePreset,presetName:E.name,tokens:T})},C=(y,E)=>{if(!e)return;const N=[...m];if(e.type==="new"){const T={id:"custom-"+Date.now(),name:y,basePreset:e.basePresetId,tokens:E};N.push(T);const L=N.length-1;Ft.setState({userPresets:N}),Ft.getState().saveUserPresets(),Ft.getState().applyUserPreset(L)}else{const T=N[e.presetIndex];T&&(N[e.presetIndex]={...T,name:y,tokens:E}),Ft.setState({userPresets:N}),Ft.getState().saveUserPresets(),Ft.getState().applyUserPreset(e.presetIndex)}t(null)},v=()=>{t(null)},S=(y,E)=>{y.stopPropagation(),d(E)},b=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:Ir.map(y=>{const E=y.id===b&&!s;return o.jsxs("div",{className:"relative group",children:[o.jsxs("button",{type:"button",onClick:()=>p(y.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:y.id==="system"?"transparent":Si(y.tokens["color-bg-primary"]??"#000"),borderColor:Si(y.tokens["color-border"]??"#000")},children:y.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:Si(y.tokens["color-text-primary"]??"#fff")}})}),o.jsx("span",{className:"text-xs",children:y.name})]}),y.id!=="system"&&o.jsx("button",{type:"button",onClick:N=>{N.stopPropagation(),x(y.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:"✎"})})]},y.id)})}),m.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:m.map((y,E)=>{const N=Ir.find(L=>L.id===y.basePreset),T=N?{...N.tokens,...y.tokens}:y.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===y.basePreset&&b===y.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:Si(T["color-bg-primary"]??"#000"),borderColor:Si(T["color-border"]??"#000")},children:o.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:Si(T["color-text-primary"]??"#fff")}})}),o.jsx("span",{className:"text-xs truncate w-full text-center",children:y.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(_l,{className:"w-3 h-3"})})]},y.id)})})]}),e&&o.jsx(aN,{isOpen:!0,isNew:e.type==="new",presetIndex:e.presetIndex,basePresetId:e.basePresetId,presetName:e.presetName,initialTokens:e.tokens,onClose:v,onSave:C})]})}function lN(){return o.jsx(oN,{})}function cN(){const{settings:e,loading:t,getSetting:n,setSetting:s}=Gu(),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(m=>[m.key,e[m.key]??"true"])),[c,d]=D.useState(()=>Object.fromEntries(l.map(m=>[m.key,u[m.key]==="true"])));D.useEffect(()=>{l.forEach(m=>n(m.key))},[n]),D.useEffect(()=>{d(Object.fromEntries(l.map(m=>[m.key,u[m.key]==="true"])))},[JSON.stringify(u)]);const f=async m=>{const p=String(!c[m]);d(_=>({..._,[m]:!_[m]})),await s(m,p)};return a?o.jsx("div",{className:"text-sm text-text-muted",children:"Loading..."}):o.jsxs("div",{className:"space-y-6",children:[o.jsx(lN,{}),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:m,label:p,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:p}),o.jsx("div",{className:"text-xs text-text-muted mt-0.5",children:_})]}),o.jsx("button",{type:"button",onClick:()=>f(m),className:`relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors ${c[m]?"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[m]?"translate-x-6":"translate-x-1"}`})})]},m))})]})]})}function PS({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 uN(e){try{return new RegExp(e),!0}catch{return!1}}function dN({value:e,onChange:t}){const[n,s]=D.useState({}),a=(d,f)=>{const m=e.patterns.map((p,_)=>_===d?{...p,...f}:p);t({...e,patterns:m})},l=d=>{const f=e.patterns.filter((m,p)=>p!==d);t({...e,patterns:f})},u=()=>{const d={field:"content",pattern:"",action:"retry",active:!0};t({...e,patterns:[...e.patterns,d]})},c=(d,f)=>{s(m=>({...m,[d]:f.length>0&&!uN(f)})),a(d,{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:d=>{const f=parseInt(d.target.value,10),m=isNaN(f)?10:Math.max(1,Math.min(100,f));t({...e,maxRetriesPerTurn:m})},className:"mt-1 block w-24 px-2 py-1 text-sm bg-bg-secondary border border-border rounded"})]}),e.patterns.length===0?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((d,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:d.active,onChange:()=>a(f,{active:!d.active}),className:"accent-accent-primary","aria-label":`Toggle pattern ${f+1}`})}),o.jsx("td",{className:"py-2 pr-2",children:o.jsxs("select",{value:d.field,onChange:m=>a(f,{field:m.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:d.pattern,onChange:m=>c(f,m.target.value),placeholder:"regex pattern",className:"flex-1 px-2 py-1 bg-bg-secondary border border-border rounded text-sm font-mono"}),d.pattern.length>0&&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 hN({onClose:e}){const[,t]=hr(),{settings:n,getSetting:s,setSetting:a}=Gu(),l=n[ze.DISPLAY_SHOW_OPEN_IN_EDITOR]==="true",u=n[ze.LLM_DYNAMIC_SYSTEM_PROMPT]==="true",[c,d]=D.useState({openInEditor:l,dynamicPrompt:u}),[f,m]=D.useState({patterns:[],maxRetriesPerTurn:10});D.useEffect(()=>{d({openInEditor:l,dynamicPrompt:u})},[l,u]),D.useEffect(()=>{s(ze.DISPLAY_SHOW_OPEN_IN_EDITOR),s(ze.LLM_DYNAMIC_SYSTEM_PROMPT),s(ze.RETRY_PATTERNS)},[s]),D.useEffect(()=>{const C=n[ze.RETRY_PATTERNS];if(C)try{m(JSON.parse(C))}catch{}},[n]);const p=D.useCallback(C=>{m(C),a(ze.RETRY_PATTERNS,JSON.stringify(C))},[a]),_=()=>{const C=!c.openInEditor;d(v=>({...v,openInEditor:C})),a(ze.DISPLAY_SHOW_OPEN_IN_EDITOR,String(C))},x=()=>{const C=!c.dynamicPrompt;d(v=>({...v,dynamicPrompt:C})),a(ze.LLM_DYNAMIC_SYSTEM_PROMPT,String(C))};function w(){e(),t("/onboarding")}return o.jsxs("div",{className:"space-y-6",children:[o.jsx(Vv,{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(dN,{value:f,onChange:p})]}),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(Vv,{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 Vv({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(PS,{enabled:n,onClick:s})})]})}function fN({label:e,binding:t,isRecording:n,onStartRecording:s,onBindingRecorded:a,onCancelRecording:l}){const u=D.useRef(null),c=D.useRef(0),d=D.useRef("");return D.useEffect(()=>{if(!n)return;const f=new Set(["Control","Shift","Alt","Meta"]);let m=[];const p=x=>{if(x.preventDefault(),x.stopPropagation(),x.key==="Escape"){l();return}if(f.has(x.key)){x.ctrlKey&&!m.includes("ctrl")&&m.push("ctrl"),x.metaKey&&!m.includes("meta")&&m.push("meta"),x.altKey&&!m.includes("alt")&&m.push("alt"),x.shiftKey&&!m.includes("shift")&&m.push("shift");return}if(m.length>0||x.ctrlKey||x.metaKey||x.altKey||x.shiftKey){const v=[...m];x.ctrlKey&&!v.includes("ctrl")&&v.push("ctrl"),x.metaKey&&!v.includes("meta")&&v.push("meta"),x.altKey&&!v.includes("alt")&&v.push("alt"),x.shiftKey&&!v.includes("shift")&&v.push("shift"),a({type:"chord",key:$v(x),modifiers:v});return}const w=Date.now(),C=$v(x);if(C===d.current&&w-c.current<400){a({type:"double-press",key:C,threshold:300});return}c.current=w,d.current=C},_=x=>{x.key==="Control"&&(m=m.filter(w=>w!=="ctrl")),x.key==="Shift"&&(m=m.filter(w=>w!=="shift")),x.key==="Alt"&&(m=m.filter(w=>w!=="alt")),x.key==="Meta"&&(m=m.filter(w=>w!=="meta"))};return window.addEventListener("keydown",p,!0),window.addEventListener("keyup",_,!0),()=>{window.removeEventListener("keydown",p,!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:NS(t)})})]})}function mN(){const{settings:e,loading:t,setSetting:n}=Gu(),s=e[ze.KEYBINDINGS],a=t[ze.KEYBINDINGS]??!1,l=Tm(s),[u,c]=D.useState(null),d=[{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(_)},m=D.useCallback(_=>{if(!u)return;const x=Tm(s),w=structuredClone(x);if(u.startsWith("agentSwitching.")){const C=parseInt(u.split(".")[1],10);w.agentSwitching[C]=_}else u==="terminalToggle"?w.terminalToggle=_:u==="quickAction"&&(w.quickAction=_);c(null),n(ze.KEYBINDINGS,JSON.stringify(w))},[u,s,n]),p=()=>{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:p,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:d.map(_=>o.jsx(fN,{label:_.label,binding:_.binding,isRecording:u===_.id,onStartRecording:()=>f(_.id),onBindingRecorded:m,onCancelRecording:()=>c(null)},_.id))})]})}function Gv(e){return e>=1e3?`~${(e/1e3).toFixed(1)}K`:`~${e}`}function pN(){const[e,t]=D.useState([]),[n,s]=D.useState(!0),[a,l]=D.useState(!1),[u,c]=D.useState(new Set),[d,f]=D.useState(new Set),[m,p]=D.useState({name:"",transport:"stdio",command:"",args:"",env:"",url:"",headers:""}),[_,x]=D.useState(""),[w,C]=D.useState(!1),{requestDelete:v,clearConfirm:S,isConfirming:b}=Fu(),y=D.useCallback(async()=>{try{const G=await(await Ne("/api/mcp/servers")).json();t(G.servers??[])}catch{}s(!1)},[]);D.useEffect(()=>{y()},[y]),D.useEffect(()=>{const M=()=>y();return window.addEventListener("mcp-servers-changed",M),()=>window.removeEventListener("mcp-servers-changed",M)},[y]);const E=M=>{c(G=>{const W=new Set(G);return W.has(M)?W.delete(M):W.add(M),W})},N=async()=>{if(x(""),!m.name){x("Name is required");return}if(m.transport==="stdio"&&!m.command){x("Command is required for stdio transport");return}if(m.transport==="http"&&!m.url){x("URL is required for HTTP transport");return}C(!0);try{const M=O=>{const U={};return O.split(`
60
+ `).filter(Boolean).forEach(V=>{const z=V.indexOf("=");z>0&&(U[V.slice(0,z).trim()]=V.slice(z+1).trim())}),U},G={name:m.name,transport:m.transport};if(m.transport==="stdio"){G.command=m.command;const O=m.args?m.args.split(" ").filter(Boolean):void 0;O&&O.length>0&&(G.args=O);const U=M(m.env);Object.keys(U).length>0&&(G.env=U)}else{G.url=m.url;const O=M(m.headers);Object.keys(O).length>0&&(G.headers=O)}const W=await Ne("/api/mcp/servers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(G)});if(!W.ok){const O=await W.json();throw new Error(O.error??"Failed to add server")}l(!1),p({name:"",transport:"stdio",command:"",args:"",env:"",url:"",headers:""}),await y()}catch(M){x(M instanceof Error?M.message:String(M))}finally{C(!1)}},T=async M=>{try{const G=await Ne(`/api/mcp/servers/${encodeURIComponent(M)}`,{method:"DELETE"});if(!G.ok){const W=await G.json();console.error("Failed to remove MCP server:",W.error)}S(),await y()}catch(G){console.error("Failed to remove MCP server:",G)}},L=async(M,G,W)=>{try{const O=await Ne(`/api/mcp/servers/${encodeURIComponent(M)}/tools/${encodeURIComponent(G)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:W})});if(!O.ok){const U=await O.json();console.error("Failed to toggle tool:",U.error)}await y()}catch(O){console.error("Failed to toggle tool:",O)}},A=M=>{switch(M){case"connected":return"text-accent-success";case"error":return"text-accent-error";default:return"text-text-muted"}},R=M=>{switch(M){case"connected":return"●";case"error":return"●";default:return"○"}};return o.jsxs("div",{children:[o.jsx(Sp,{description:"MCP servers provide external tools that extend OpenFox's capabilities.",onNew:()=>l(!0),newLabel:"+ Add Server"}),o.jsx(wp,{loading:n,hasItems:e.length>0,loadingLabel:"Loading MCP servers...",emptyLabel:"No MCP servers configured.",children:e.map(M=>{var G;return o.jsxs("div",{className:"rounded border border-border bg-bg-tertiary overflow-hidden",children:[o.jsxs("div",{className:"flex items-center justify-between p-3 cursor-pointer hover:bg-bg-primary/50 transition-colors",onClick:()=>E(M.name),children:[o.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[o.jsx("span",{className:`text-sm ${A(M.status)}`,children:R(M.status)}),o.jsx("span",{className:"text-sm font-medium text-text-primary",children:M.name}),o.jsx("span",{className:"text-xs text-text-muted",children:M.config.transport}),o.jsxs("span",{className:"text-xs text-text-muted",children:["(",M.tools.length," tools)"]}),o.jsxs("span",{className:"text-xs text-text-muted",children:[Gv(M.estimatedTokens)," tokens"]})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[M.status==="error"&&M.error&&o.jsx("span",{className:"text-xs text-accent-error truncate max-w-[200px]",title:M.error,children:M.error}),o.jsx("span",{className:"text-xs text-text-muted",children:u.has(M.name)?"▲":"▼"})]})]}),u.has(M.name)&&o.jsxs("div",{className:"border-t border-border px-3 py-2 space-y-1.5",children:[M.config.command&&o.jsxs("div",{className:"text-xs text-text-muted font-mono",children:[M.config.command," ",((G=M.config.args)==null?void 0:G.join(" "))??""]}),M.config.url&&o.jsx("div",{className:"text-xs text-text-muted font-mono",children:M.config.url}),M.tools.length===0?o.jsx("div",{className:"text-xs text-text-muted",children:"No tools available"}):o.jsx("div",{className:"space-y-1",children:M.tools.map(W=>o.jsxs("div",{className:"py-1",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"min-w-0 flex-1 mr-2",children:[o.jsx("span",{className:"text-xs text-text-primary font-mono",children:W.name}),W.description&&W.description.length>80?o.jsxs("button",{onClick:()=>{const O=`${M.name}:${W.name}`;f(U=>{const V=new Set(U);return V.has(O)?V.delete(O):V.add(O),V})},className:"inline-flex items-center gap-0.5 text-xs text-text-muted hover:text-text-primary transition-colors ml-2",children:[o.jsx("span",{className:"truncate max-w-[300px]",children:W.description}),o.jsx(dr,{rotate:d.has(`${M.name}:${W.name}`)?180:0,className:"w-3 h-3 flex-shrink-0"})]}):W.description?o.jsx("span",{className:"text-xs text-text-muted ml-2",children:W.description}):null]}),o.jsx("span",{className:"text-xs text-text-muted mr-2 flex-shrink-0",children:Gv(W.estimatedTokens)}),o.jsx(PS,{enabled:W.enabled,onClick:()=>L(M.name,W.name,!W.enabled)})]}),W.description&&W.description.length>80&&d.has(`${M.name}:${W.name}`)&&o.jsx("div",{className:"text-xs text-text-muted mt-1 ml-1",children:W.description})]},W.name))}),o.jsx("div",{className:"pt-2 flex items-center justify-end gap-2",children:b(M.name,"delete")?o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:W=>{W.stopPropagation(),T(M.name)},className:"px-2 py-1 rounded text-xs font-medium hover:opacity-90 transition-colors bg-accent-error/20 text-accent-error hover:bg-accent-error/30",children:"Delete"}),o.jsx("button",{onClick:W=>{W.stopPropagation(),S()},className:"px-2 py-1 rounded text-xs text-text-muted hover:bg-bg-primary transition-colors",children:"Cancel"})]}):o.jsx("button",{onClick:W=>{W.stopPropagation(),v(M.name)},className:"px-2 py-1 rounded text-xs font-medium text-accent-error/80 hover:text-accent-error hover:bg-accent-error/10 transition-colors",children:"Remove server"})})]})]},M.name)})}),a&&o.jsx(Ot,{isOpen:a,onClose:()=>{l(!1),x("")},title:"Add MCP Server",size:"sm",children:o.jsxs("div",{className:"space-y-3",children:[o.jsx(br,{label:"Name",value:m.name,onChange:M=>p({...m,name:M}),placeholder:"e.g. filesystem"}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Transport"}),o.jsxs("div",{className:"flex gap-1",children:[o.jsx("button",{onClick:()=>p({...m,transport:"stdio"}),className:`px-3 py-1.5 rounded text-xs font-medium transition-colors ${m.transport==="stdio"?"bg-accent-primary text-white":"bg-bg-tertiary text-text-secondary hover:bg-bg-primary"}`,children:"Stdio"}),o.jsx("button",{onClick:()=>p({...m,transport:"http"}),className:`px-3 py-1.5 rounded text-xs font-medium transition-colors ${m.transport==="http"?"bg-accent-primary text-white":"bg-bg-tertiary text-text-secondary hover:bg-bg-primary"}`,children:"HTTP"})]})]}),m.transport==="stdio"?o.jsxs(o.Fragment,{children:[o.jsx(br,{label:"Command",value:m.command,onChange:M=>p({...m,command:M}),placeholder:"e.g. npx"}),o.jsx(br,{label:"Arguments",value:m.args,onChange:M=>p({...m,args:M}),placeholder:"space-separated args"}),o.jsxs("div",{children:[o.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:["Environment variables ",o.jsx("span",{className:"text-text-muted",children:"(KEY=VALUE, one per line)"})]}),o.jsx("textarea",{value:m.env,onChange:M=>p({...m,env:M.target.value}),placeholder:"API_KEY=xxx",className:"w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm font-mono resize-none focus:outline-none focus:ring-1 focus:ring-accent-primary",rows:3})]})]}):o.jsxs(o.Fragment,{children:[o.jsx(br,{label:"URL",value:m.url,onChange:M=>p({...m,url:M}),placeholder:"e.g. https://mcp.example.com/mcp"}),o.jsxs("div",{children:[o.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:["Headers ",o.jsx("span",{className:"text-text-muted",children:"(KEY=VALUE, one per line)"})]}),o.jsx("textarea",{value:m.headers,onChange:M=>p({...m,headers:M.target.value}),placeholder:"X-API-Key=xxx",className:"w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm font-mono resize-none focus:outline-none focus:ring-1 focus:ring-accent-primary",rows:3})]})]}),_&&o.jsx(Vu,{message:_}),o.jsxs("div",{className:"flex justify-end gap-2 pt-2 border-t border-border",children:[o.jsx(tt,{variant:"secondary",onClick:()=>{l(!1),x(""),C(!1),p({name:"",transport:"stdio",command:"",args:"",env:"",url:"",headers:""})},disabled:w,children:"Cancel"}),o.jsx(tt,{variant:"primary",onClick:N,disabled:w,children:w?"Adding...":"Add"})]})]})})]})}function gN({isOpen:e,onClose:t}){const[n,s]=D.useState("instructions"),a=()=>{try{$t.send("context.checkDynamic",{})}catch{}t()};return o.jsx(Ot,{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(pi,{label:"Instructions",active:n==="instructions",onClick:()=>s("instructions")}),o.jsx(pi,{label:"Skills",active:n==="skills",onClick:()=>s("skills")}),o.jsx(pi,{label:"Notifications",active:n==="notifications",onClick:()=>s("notifications")}),o.jsx(pi,{label:"Display",active:n==="display",onClick:()=>s("display")}),o.jsx(pi,{label:"Keybindings",active:n==="keybindings",onClick:()=>s("keybindings")}),o.jsx(pi,{label:"MCP",active:n==="mcp",onClick:()=>s("mcp")}),o.jsx(pi,{label:"Advanced",active:n==="advanced",onClick:()=>s("advanced")})]}),n==="instructions"&&o.jsx(sN,{isOpen:e}),n==="skills"&&o.jsx(rN,{isOpen:e}),n==="notifications"&&o.jsx("div",{className:"max-h-[60vh] overflow-y-auto",children:o.jsx(eN,{})}),n==="display"&&o.jsx(cN,{}),n==="keybindings"&&o.jsx(mN,{}),n==="mcp"&&o.jsx("div",{className:"max-h-[60vh] overflow-y-auto",children:o.jsx(pN,{})}),n==="advanced"&&o.jsx(hN,{onClose:t})]})})}function pi({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 $f={exports:{}},Wv;function xN(){return Wv||(Wv=1,(function(e,t){(function(n,s){e.exports=s()})(globalThis,(()=>(()=>{var n={4567:function(u,c,d){var f=this&&this.__decorate||function(b,y,E,N){var T,L=arguments.length,A=L<3?y:N===null?N=Object.getOwnPropertyDescriptor(y,E):N;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(b,y,E,N);else for(var R=b.length-1;R>=0;R--)(T=b[R])&&(A=(L<3?T(A):L>3?T(y,E,A):T(y,E))||A);return L>3&&A&&Object.defineProperty(y,E,A),A},m=this&&this.__param||function(b,y){return function(E,N){y(E,N,b)}};Object.defineProperty(c,"__esModule",{value:!0}),c.AccessibilityManager=void 0;const p=d(9042),_=d(9924),x=d(844),w=d(4725),C=d(2585),v=d(3656);let S=c.AccessibilityManager=class extends x.Disposable{constructor(b,y,E,N){super(),this._terminal=b,this._coreBrowserService=E,this._renderService=N,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=this._coreBrowserService.mainDocument.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=this._coreBrowserService.mainDocument.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let T=0;T<this._terminal.rows;T++)this._rowElements[T]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[T]);if(this._topBoundaryFocusListener=T=>this._handleBoundaryFocus(T,0),this._bottomBoundaryFocusListener=T=>this._handleBoundaryFocus(T,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=this._coreBrowserService.mainDocument.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new _.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize((T=>this._handleResize(T.rows)))),this.register(this._terminal.onRender((T=>this._refreshRows(T.start,T.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((T=>this._handleChar(T)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
61
+ `)))),this.register(this._terminal.onA11yTab((T=>this._handleTab(T)))),this.register(this._terminal.onKey((T=>this._handleKey(T.key)))),this.register(this._terminal.onBlur((()=>this._clearLiveRegion()))),this.register(this._renderService.onDimensionsChange((()=>this._refreshRowsDimensions()))),this.register((0,v.addDisposableDomListener)(document,"selectionchange",(()=>this._handleSelectionChange()))),this.register(this._coreBrowserService.onDprChange((()=>this._refreshRowsDimensions()))),this._refreshRows(),this.register((0,x.toDisposable)((()=>{this._accessibilityContainer.remove(),this._rowElements.length=0})))}_handleTab(b){for(let y=0;y<b;y++)this._handleChar(" ")}_handleChar(b){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==b&&(this._charsToAnnounce+=b):this._charsToAnnounce+=b,b===`
62
+ `&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=p.tooMuchOutput)))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(b){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(b)||this._charsToConsume.push(b)}_refreshRows(b,y){this._liveRegionDebouncer.refresh(b,y,this._terminal.rows)}_renderRows(b,y){const E=this._terminal.buffer,N=E.lines.length.toString();for(let T=b;T<=y;T++){const L=E.lines.get(E.ydisp+T),A=[],R=(L==null?void 0:L.translateToString(!0,void 0,void 0,A))||"",M=(E.ydisp+T+1).toString(),G=this._rowElements[T];G&&(R.length===0?(G.innerText=" ",this._rowColumns.set(G,[0,1])):(G.textContent=R,this._rowColumns.set(G,A)),G.setAttribute("aria-posinset",M),G.setAttribute("aria-setsize",N))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(b,y){const E=b.target,N=this._rowElements[y===0?1:this._rowElements.length-2];if(E.getAttribute("aria-posinset")===(y===0?"1":`${this._terminal.buffer.lines.length}`)||b.relatedTarget!==N)return;let T,L;if(y===0?(T=E,L=this._rowElements.pop(),this._rowContainer.removeChild(L)):(T=this._rowElements.shift(),L=E,this._rowContainer.removeChild(T)),T.removeEventListener("focus",this._topBoundaryFocusListener),L.removeEventListener("focus",this._bottomBoundaryFocusListener),y===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(y===0?-1:1),this._rowElements[y===0?1:this._rowElements.length-2].focus(),b.preventDefault(),b.stopImmediatePropagation()}_handleSelectionChange(){var R;if(this._rowElements.length===0)return;const b=document.getSelection();if(!b)return;if(b.isCollapsed)return void(this._rowContainer.contains(b.anchorNode)&&this._terminal.clearSelection());if(!b.anchorNode||!b.focusNode)return void console.error("anchorNode and/or focusNode are null");let y={node:b.anchorNode,offset:b.anchorOffset},E={node:b.focusNode,offset:b.focusOffset};if((y.node.compareDocumentPosition(E.node)&Node.DOCUMENT_POSITION_PRECEDING||y.node===E.node&&y.offset>E.offset)&&([y,E]=[E,y]),y.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(y={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(y.node))return;const N=this._rowElements.slice(-1)[0];if(E.node.compareDocumentPosition(N)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(E={node:N,offset:((R=N.textContent)==null?void 0:R.length)??0}),!this._rowContainer.contains(E.node))return;const T=({node:M,offset:G})=>{const W=M instanceof Text?M.parentNode:M;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 U=this._rowColumns.get(W);if(!U)return console.warn("columns is null. Race condition?"),null;let V=G<U.length?U[G]:U.slice(-1)[0]+1;return V>=this._terminal.cols&&(++O,V=0),{row:O,column:V}},L=T(y),A=T(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(b){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let y=this._rowContainer.children.length;y<this._terminal.rows;y++)this._rowElements[y]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[y]);for(;this._rowElements.length>b;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const b=this._coreBrowserService.mainDocument.createElement("div");return b.setAttribute("role","listitem"),b.tabIndex=-1,this._refreshRowDimensions(b),b}_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 b=0;b<this._terminal.rows;b++)this._refreshRowDimensions(this._rowElements[b])}}_refreshRowDimensions(b){b.style.height=`${this._renderService.dimensions.css.cell.height}px`}};c.AccessibilityManager=S=f([m(1,C.IInstantiationService),m(2,w.ICoreBrowserService),m(3,w.IRenderService)],S)},3614:(u,c)=>{function d(_){return _.replace(/\r?\n/g,"\r")}function f(_,x){return x?"\x1B[200~"+_+"\x1B[201~":_}function m(_,x,w,C){_=f(_=d(_),w.decPrivateModes.bracketedPasteMode&&C.rawOptions.ignoreBracketedPasteMode!==!0),w.triggerDataEvent(_,!0),x.value=""}function p(_,x,w){const C=w.getBoundingClientRect(),v=_.clientX-C.left-10,S=_.clientY-C.top-10;x.style.width="20px",x.style.height="20px",x.style.left=`${v}px`,x.style.top=`${S}px`,x.style.zIndex="1000",x.focus()}Object.defineProperty(c,"__esModule",{value:!0}),c.rightClickHandler=c.moveTextAreaUnderMouseCursor=c.paste=c.handlePasteEvent=c.copyHandler=c.bracketTextForPaste=c.prepareTextForTerminal=void 0,c.prepareTextForTerminal=d,c.bracketTextForPaste=f,c.copyHandler=function(_,x){_.clipboardData&&_.clipboardData.setData("text/plain",x.selectionText),_.preventDefault()},c.handlePasteEvent=function(_,x,w,C){_.stopPropagation(),_.clipboardData&&m(_.clipboardData.getData("text/plain"),x,w,C)},c.paste=m,c.moveTextAreaUnderMouseCursor=p,c.rightClickHandler=function(_,x,w,C,v){p(_,x,w),v&&C.rightClickSelect(_),x.value=C.selectionText,x.select()}},7239:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.ColorContrastCache=void 0;const f=d(1505);c.ColorContrastCache=class{constructor(){this._color=new f.TwoKeyMap,this._css=new f.TwoKeyMap}setCss(m,p,_){this._css.set(m,p,_)}getCss(m,p){return this._css.get(m,p)}setColor(m,p,_){this._color.set(m,p,_)}getColor(m,p){return this._color.get(m,p)}clear(){this._color.clear(),this._css.clear()}}},3656:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.addDisposableDomListener=void 0,c.addDisposableDomListener=function(d,f,m,p){d.addEventListener(f,m,p);let _=!1;return{dispose:()=>{_||(_=!0,d.removeEventListener(f,m,p))}}}},3551:function(u,c,d){var f=this&&this.__decorate||function(S,b,y,E){var N,T=arguments.length,L=T<3?b:E===null?E=Object.getOwnPropertyDescriptor(b,y):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")L=Reflect.decorate(S,b,y,E);else for(var A=S.length-1;A>=0;A--)(N=S[A])&&(L=(T<3?N(L):T>3?N(b,y,L):N(b,y))||L);return T>3&&L&&Object.defineProperty(b,y,L),L},m=this&&this.__param||function(S,b){return function(y,E){b(y,E,S)}};Object.defineProperty(c,"__esModule",{value:!0}),c.Linkifier=void 0;const p=d(3656),_=d(8460),x=d(844),w=d(2585),C=d(4725);let v=c.Linkifier=class extends x.Disposable{get currentLink(){return this._currentLink}constructor(S,b,y,E,N){super(),this._element=S,this._mouseService=b,this._renderService=y,this._bufferService=E,this._linkProviderService=N,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 T;this._lastMouseEvent=void 0,(T=this._activeProviderReplies)==null||T.clear()}))),this.register(this._bufferService.onResize((()=>{this._clearCurrentLink(),this._wasResized=!0}))),this.register((0,p.addDisposableDomListener)(this._element,"mouseleave",(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this.register((0,p.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,p.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,p.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_handleMouseMove(S){this._lastMouseEvent=S;const b=this._positionFromMouseEvent(S,this._element,this._mouseService);if(!b)return;this._isMouseOut=!1;const y=S.composedPath();for(let E=0;E<y.length;E++){const N=y[E];if(N.classList.contains("xterm"))break;if(N.classList.contains("xterm-hover"))return}this._lastBufferCell&&b.x===this._lastBufferCell.x&&b.y===this._lastBufferCell.y||(this._handleHover(b),this._lastBufferCell=b)}_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,b){var E,N;this._activeProviderReplies&&b||((E=this._activeProviderReplies)==null||E.forEach((T=>{T==null||T.forEach((L=>{L.link.dispose&&L.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=S.y);let y=!1;for(const[T,L]of this._linkProviderService.linkProviders.entries())b?(N=this._activeProviderReplies)!=null&&N.get(T)&&(y=this._checkLinkProviderResult(T,S,y)):L.provideLinks(S.y,(A=>{var M,G;if(this._isMouseOut)return;const R=A==null?void 0:A.map((W=>({link:W})));(M=this._activeProviderReplies)==null||M.set(T,R),y=this._checkLinkProviderResult(T,S,y),((G=this._activeProviderReplies)==null?void 0:G.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(S.y,this._activeProviderReplies)}))}_removeIntersectingLinks(S,b){const y=new Set;for(let E=0;E<b.size;E++){const N=b.get(E);if(N)for(let T=0;T<N.length;T++){const L=N[T],A=L.link.range.start.y<S?0:L.link.range.start.x,R=L.link.range.end.y>S?this._bufferService.cols:L.link.range.end.x;for(let M=A;M<=R;M++){if(y.has(M)){N.splice(T--,1);break}y.add(M)}}}}_checkLinkProviderResult(S,b,y){var T;if(!this._activeProviderReplies)return y;const E=this._activeProviderReplies.get(S);let N=!1;for(let L=0;L<S;L++)this._activeProviderReplies.has(L)&&!this._activeProviderReplies.get(L)||(N=!0);if(!N&&E){const L=E.find((A=>this._linkAtPosition(A.link,b)));L&&(y=!0,this._handleNewLink(L))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!y)for(let L=0;L<this._activeProviderReplies.size;L++){const A=(T=this._activeProviderReplies.get(L))==null?void 0:T.find((R=>this._linkAtPosition(R.link,b)));if(A){y=!0,this._handleNewLink(A);break}}return y}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(S){if(!this._currentLink)return;const b=this._positionFromMouseEvent(S,this._element,this._mouseService);b&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,b)&&this._currentLink.link.activate(S,this._currentLink.link.text)}_clearCurrentLink(S,b){this._currentLink&&this._lastMouseEvent&&(!S||!b||this._currentLink.link.range.start.y>=S&&this._currentLink.link.range.end.y<=b)&&(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 b=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);b&&this._linkAtPosition(S.link,b)&&(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 y,E;return(E=(y=this._currentLink)==null?void 0:y.state)==null?void 0:E.decorations.pointerCursor},set:y=>{var E;(E=this._currentLink)!=null&&E.state&&this._currentLink.state.decorations.pointerCursor!==y&&(this._currentLink.state.decorations.pointerCursor=y,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",y))}},underline:{get:()=>{var y,E;return(E=(y=this._currentLink)==null?void 0:y.state)==null?void 0:E.decorations.underline},set:y=>{var E,N,T;(E=this._currentLink)!=null&&E.state&&((T=(N=this._currentLink)==null?void 0:N.state)==null?void 0:T.decorations.underline)!==y&&(this._currentLink.state.decorations.underline=y,this._currentLink.state.isHovered&&this._fireUnderlineEvent(S.link,y))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((y=>{if(!this._currentLink)return;const E=y.start===0?0:y.start+1+this._bufferService.buffer.ydisp,N=this._bufferService.buffer.ydisp+1+y.end;if(this._currentLink.link.range.start.y>=E&&this._currentLink.link.range.end.y<=N&&(this._clearCurrentLink(E,N),this._lastMouseEvent)){const T=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);T&&this._askForLink(T,!1)}}))))}_linkHover(S,b,y){var E;(E=this._currentLink)!=null&&E.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(b,!0),this._currentLink.state.decorations.pointerCursor&&S.classList.add("xterm-cursor-pointer")),b.hover&&b.hover(y,b.text)}_fireUnderlineEvent(S,b){const y=S.range,E=this._bufferService.buffer.ydisp,N=this._createLinkUnderlineEvent(y.start.x-1,y.start.y-E-1,y.end.x,y.end.y-E-1,void 0);(b?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(N)}_linkLeave(S,b,y){var E;(E=this._currentLink)!=null&&E.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(b,!1),this._currentLink.state.decorations.pointerCursor&&S.classList.remove("xterm-cursor-pointer")),b.leave&&b.leave(y,b.text)}_linkAtPosition(S,b){const y=S.range.start.y*this._bufferService.cols+S.range.start.x,E=S.range.end.y*this._bufferService.cols+S.range.end.x,N=b.y*this._bufferService.cols+b.x;return y<=N&&N<=E}_positionFromMouseEvent(S,b,y){const E=y.getCoords(S,b,this._bufferService.cols,this._bufferService.rows);if(E)return{x:E[0],y:E[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(S,b,y,E,N){return{x1:S,y1:b,x2:y,y2:E,cols:this._bufferService.cols,fg:N}}};c.Linkifier=v=f([m(1,C.IMouseService),m(2,C.IRenderService),m(3,w.IBufferService),m(4,C.ILinkProviderService)],v)},9042:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.tooMuchOutput=c.promptLabel=void 0,c.promptLabel="Terminal input",c.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},3730:function(u,c,d){var f=this&&this.__decorate||function(C,v,S,b){var y,E=arguments.length,N=E<3?v:b===null?b=Object.getOwnPropertyDescriptor(v,S):b;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")N=Reflect.decorate(C,v,S,b);else for(var T=C.length-1;T>=0;T--)(y=C[T])&&(N=(E<3?y(N):E>3?y(v,S,N):y(v,S))||N);return E>3&&N&&Object.defineProperty(v,S,N),N},m=this&&this.__param||function(C,v){return function(S,b){v(S,b,C)}};Object.defineProperty(c,"__esModule",{value:!0}),c.OscLinkProvider=void 0;const p=d(511),_=d(2585);let x=c.OscLinkProvider=class{constructor(C,v,S){this._bufferService=C,this._optionsService=v,this._oscLinkService=S}provideLinks(C,v){var R;const S=this._bufferService.buffer.lines.get(C-1);if(!S)return void v(void 0);const b=[],y=this._optionsService.rawOptions.linkHandler,E=new p.CellData,N=S.getTrimmedLength();let T=-1,L=-1,A=!1;for(let M=0;M<N;M++)if(L!==-1||S.hasContent(M)){if(S.loadCell(M,E),E.hasExtendedAttrs()&&E.extended.urlId){if(L===-1){L=M,T=E.extended.urlId;continue}A=E.extended.urlId!==T}else L!==-1&&(A=!0);if(A||L!==-1&&M===N-1){const G=(R=this._oscLinkService.getLinkData(T))==null?void 0:R.uri;if(G){const W={start:{x:L+1,y:C},end:{x:M+(A||M!==N-1?0:1),y:C}};let O=!1;if(!(y!=null&&y.allowNonHttpProtocols))try{const U=new URL(G);["http:","https:"].includes(U.protocol)||(O=!0)}catch{O=!0}O||b.push({text:G,range:W,activate:(U,V)=>y?y.activate(U,V,W):w(0,V),hover:(U,V)=>{var z;return(z=y==null?void 0:y.hover)==null?void 0:z.call(y,U,V,W)},leave:(U,V)=>{var z;return(z=y==null?void 0:y.leave)==null?void 0:z.call(y,U,V,W)}})}A=!1,E.hasExtendedAttrs()&&E.extended.urlId?(L=M,T=E.extended.urlId):(L=-1,T=-1)}}v(b)}};function w(C,v){if(confirm(`Do you want to navigate to ${v}?
63
+
64
+ WARNING: This link could potentially be dangerous`)){const S=window.open();if(S){try{S.opener=null}catch{}S.location.href=v}else console.warn("Opening link blocked as opener could not be cleared")}}c.OscLinkProvider=x=f([m(0,_.IBufferService),m(1,_.IOptionsService),m(2,_.IOscLinkService)],x)},6193:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.RenderDebouncer=void 0,c.RenderDebouncer=class{constructor(d,f){this._renderCallback=d,this._coreBrowserService=f,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(d){return this._refreshCallbacks.push(d),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh()))),this._animationFrame}refresh(d,f,m){this._rowCount=m,d=d!==void 0?d:0,f=f!==void 0?f:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,d):d,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,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 d=Math.max(this._rowStart,0),f=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(d,f),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(const d of this._refreshCallbacks)d(0);this._refreshCallbacks=[]}}},3236:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.Terminal=void 0;const f=d(3614),m=d(3656),p=d(3551),_=d(9042),x=d(3730),w=d(1680),C=d(3107),v=d(5744),S=d(2950),b=d(1296),y=d(428),E=d(4269),N=d(5114),T=d(8934),L=d(3230),A=d(9312),R=d(4725),M=d(6731),G=d(8055),W=d(8969),O=d(8460),U=d(844),V=d(6114),z=d(8437),X=d(2584),te=d(7399),H=d(5941),I=d(9074),$=d(2585),F=d(5435),P=d(4567),ee=d(779);class J 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=V,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this.register(new U.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(I.DecorationService),this._instantiationService.setService($.IDecorationService,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(ee.LinkProviderService),this._instantiationService.setService(R.ILinkProviderService,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(x.OscLinkProvider)),this.register(this._inputHandler.onRequestBell((()=>this._onBell.fire()))),this.register(this._inputHandler.onRequestRefreshRows(((q,Z)=>this.refresh(q,Z)))),this.register(this._inputHandler.onRequestSendFocus((()=>this._reportFocus()))),this.register(this._inputHandler.onRequestReset((()=>this.reset()))),this.register(this._inputHandler.onRequestWindowsOptionsReport((q=>this._reportWindowsOptions(q)))),this.register(this._inputHandler.onColor((q=>this._handleColorEvent(q)))),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((q=>this._afterResize(q.cols,q.rows)))),this.register((0,U.toDisposable)((()=>{var q,Z;this._customKeyEventHandler=void 0,(Z=(q=this.element)==null?void 0:q.parentNode)==null||Z.removeChild(this.element)})))}_handleColorEvent(Y){if(this._themeService)for(const q of Y){let Z,ae="";switch(q.index){case 256:Z="foreground",ae="10";break;case 257:Z="background",ae="11";break;case 258:Z="cursor",ae="12";break;default:Z="ansi",ae="4;"+q.index}switch(q.type){case 0:const se=G.color.toColorRGB(Z==="ansi"?this._themeService.colors.ansi[q.index]:this._themeService.colors[Z]);this.coreService.triggerDataEvent(`${X.C0.ESC}]${ae};${(0,H.toRgbString)(se)}${X.C1_ESCAPED.ST}`);break;case 1:if(Z==="ansi")this._themeService.modifyColors((oe=>oe.ansi[q.index]=G.channels.toColor(...q.color)));else{const oe=Z;this._themeService.modifyColors((je=>je[oe]=G.channels.toColor(...q.color)))}break;case 2:this._themeService.restoreColor(q.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(P.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,q=this.buffer.lines.get(Y);if(!q)return;const Z=Math.min(this.buffer.x,this.cols-1),ae=this._renderService.dimensions.css.cell.height,se=q.getWidth(Z),oe=this._renderService.dimensions.css.cell.width*se,je=this.buffer.y*this._renderService.dimensions.css.cell.height,Le=Z*this._renderService.dimensions.css.cell.width;this.textarea.style.left=Le+"px",this.textarea.style.top=je+"px",this.textarea.style.width=oe+"px",this.textarea.style.height=ae+"px",this.textarea.style.lineHeight=ae+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this.register((0,m.addDisposableDomListener)(this.element,"copy",(q=>{this.hasSelection()&&(0,f.copyHandler)(q,this._selectionService)})));const Y=q=>(0,f.handlePasteEvent)(q,this.textarea,this.coreService,this.optionsService);this.register((0,m.addDisposableDomListener)(this.textarea,"paste",Y)),this.register((0,m.addDisposableDomListener)(this.element,"paste",Y)),V.isFirefox?this.register((0,m.addDisposableDomListener)(this.element,"mousedown",(q=>{q.button===2&&(0,f.rightClickHandler)(q,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))):this.register((0,m.addDisposableDomListener)(this.element,"contextmenu",(q=>{(0,f.rightClickHandler)(q,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))),V.isLinux&&this.register((0,m.addDisposableDomListener)(this.element,"auxclick",(q=>{q.button===1&&(0,f.moveTextAreaUnderMouseCursor)(q,this.textarea,this.screenElement)})))}_bindKeys(){this.register((0,m.addDisposableDomListener)(this.textarea,"keyup",(Y=>this._keyUp(Y)),!0)),this.register((0,m.addDisposableDomListener)(this.textarea,"keydown",(Y=>this._keyDown(Y)),!0)),this.register((0,m.addDisposableDomListener)(this.textarea,"keypress",(Y=>this._keyPress(Y)),!0)),this.register((0,m.addDisposableDomListener)(this.textarea,"compositionstart",(()=>this._compositionHelper.compositionstart()))),this.register((0,m.addDisposableDomListener)(this.textarea,"compositionupdate",(Y=>this._compositionHelper.compositionupdate(Y)))),this.register((0,m.addDisposableDomListener)(this.textarea,"compositionend",(()=>this._compositionHelper.compositionend()))),this.register((0,m.addDisposableDomListener)(this.textarea,"input",(Y=>this._inputEvent(Y)),!0)),this.register(this.onRender((()=>this._compositionHelper.updateCompositionElements())))}open(Y){var Z;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"),((Z=this.element)==null?void 0:Z.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 q=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),q.appendChild(this._viewportElement),this._viewportScrollArea=this._document.createElement("div"),this._viewportScrollArea.classList.add("xterm-scroll-area"),this._viewportElement.appendChild(this._viewportScrollArea),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this.register((0,m.addDisposableDomListener)(this.screenElement,"mousemove",(ae=>this.updateCursorStyle(ae)))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),q.appendChild(this.screenElement),this.textarea=this._document.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",_.promptLabel),V.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(N.CoreBrowserService,this.textarea,Y.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(R.ICoreBrowserService,this._coreBrowserService),this.register((0,m.addDisposableDomListener)(this.textarea,"focus",(ae=>this._handleTextAreaFocus(ae)))),this.register((0,m.addDisposableDomListener)(this.textarea,"blur",(()=>this._handleTextAreaBlur()))),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(y.CharSizeService,this._document,this._helperContainer),this._instantiationService.setService(R.ICharSizeService,this._charSizeService),this._themeService=this._instantiationService.createInstance(M.ThemeService),this._instantiationService.setService(R.IThemeService,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(E.CharacterJoinerService),this._instantiationService.setService(R.ICharacterJoinerService,this._characterJoinerService),this._renderService=this.register(this._instantiationService.createInstance(L.RenderService,this.rows,this.screenElement)),this._instantiationService.setService(R.IRenderService,this._renderService),this.register(this._renderService.onRenderedViewportChange((ae=>this._onRender.fire(ae)))),this.onResize((ae=>this._renderService.resize(ae.cols,ae.rows))),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(S.CompositionHelper,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(T.MouseService),this._instantiationService.setService(R.IMouseService,this._mouseService),this.linkifier=this.register(this._instantiationService.createInstance(p.Linkifier,this.screenElement)),this.element.appendChild(q);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((ae=>this.scrollLines(ae.amount,ae.suppressScrollEvent,1))),this.register(this._inputHandler.onRequestSyncScrollBar((()=>this.viewport.syncScrollArea()))),this.register(this.viewport),this.register(this.onCursorMove((()=>{this._renderService.handleCursorMove(),this._syncTextArea()}))),this.register(this.onResize((()=>this._renderService.handleResize(this.cols,this.rows)))),this.register(this.onBlur((()=>this._renderService.handleBlur()))),this.register(this.onFocus((()=>this._renderService.handleFocus()))),this.register(this._renderService.onDimensionsChange((()=>this.viewport.syncScrollArea()))),this._selectionService=this.register(this._instantiationService.createInstance(A.SelectionService,this.element,this.screenElement,this.linkifier)),this._instantiationService.setService(R.ISelectionService,this._selectionService),this.register(this._selectionService.onRequestScrollLines((ae=>this.scrollLines(ae.amount,ae.suppressScrollEvent)))),this.register(this._selectionService.onSelectionChange((()=>this._onSelectionChange.fire()))),this.register(this._selectionService.onRequestRedraw((ae=>this._renderService.handleSelectionChanged(ae.start,ae.end,ae.columnSelectMode)))),this.register(this._selectionService.onLinuxMouseSelection((ae=>{this.textarea.value=ae,this.textarea.focus(),this.textarea.select()}))),this.register(this._onScroll.event((ae=>{this.viewport.syncScrollArea(),this._selectionService.refresh()}))),this.register((0,m.addDisposableDomListener)(this._viewportElement,"scroll",(()=>this._selectionService.refresh()))),this.register(this._instantiationService.createInstance(C.BufferDecorationRenderer,this.screenElement)),this.register((0,m.addDisposableDomListener)(this.element,"mousedown",(ae=>this._selectionService.handleMouseDown(ae)))),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(P.AccessibilityManager,this)),this.register(this.optionsService.onSpecificOptionChange("screenReaderMode",(ae=>this._handleScreenReaderModeOptionChange(ae)))),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(v.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRulerWidth",(ae=>{!this._overviewRulerRenderer&&ae&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(v.OverviewRulerRenderer,this._viewportElement,this.screenElement)))})),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(b.DomRenderer,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){const Y=this,q=this.element;function Z(oe){const je=Y._mouseService.getMouseReportCoords(oe,Y.screenElement);if(!je)return!1;let Le,De;switch(oe.overrideType||oe.type){case"mousemove":De=32,oe.buttons===void 0?(Le=3,oe.button!==void 0&&(Le=oe.button<3?oe.button:3)):Le=1&oe.buttons?0:4&oe.buttons?1:2&oe.buttons?2:3;break;case"mouseup":De=0,Le=oe.button<3?oe.button:3;break;case"mousedown":De=1,Le=oe.button<3?oe.button:3;break;case"wheel":if(Y._customWheelEventHandler&&Y._customWheelEventHandler(oe)===!1||Y.viewport.getLinesScrolled(oe)===0)return!1;De=oe.deltaY<0?0:1,Le=4;break;default:return!1}return!(De===void 0||Le===void 0||Le>4)&&Y.coreMouseService.triggerMouseEvent({col:je.col,row:je.row,x:je.x,y:je.y,button:Le,action:De,ctrl:oe.ctrlKey,alt:oe.altKey,shift:oe.shiftKey})}const ae={mouseup:null,wheel:null,mousedrag:null,mousemove:null},se={mouseup:oe=>(Z(oe),oe.buttons||(this._document.removeEventListener("mouseup",ae.mouseup),ae.mousedrag&&this._document.removeEventListener("mousemove",ae.mousedrag)),this.cancel(oe)),wheel:oe=>(Z(oe),this.cancel(oe,!0)),mousedrag:oe=>{oe.buttons&&Z(oe)},mousemove:oe=>{oe.buttons||Z(oe)}};this.register(this.coreMouseService.onProtocolChange((oe=>{oe?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(oe)),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&oe?ae.mousemove||(q.addEventListener("mousemove",se.mousemove),ae.mousemove=se.mousemove):(q.removeEventListener("mousemove",ae.mousemove),ae.mousemove=null),16&oe?ae.wheel||(q.addEventListener("wheel",se.wheel,{passive:!1}),ae.wheel=se.wheel):(q.removeEventListener("wheel",ae.wheel),ae.wheel=null),2&oe?ae.mouseup||(ae.mouseup=se.mouseup):(this._document.removeEventListener("mouseup",ae.mouseup),ae.mouseup=null),4&oe?ae.mousedrag||(ae.mousedrag=se.mousedrag):(this._document.removeEventListener("mousemove",ae.mousedrag),ae.mousedrag=null)}))),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,m.addDisposableDomListener)(q,"mousedown",(oe=>{if(oe.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(oe))return Z(oe),ae.mouseup&&this._document.addEventListener("mouseup",ae.mouseup),ae.mousedrag&&this._document.addEventListener("mousemove",ae.mousedrag),this.cancel(oe)}))),this.register((0,m.addDisposableDomListener)(q,"wheel",(oe=>{if(!ae.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(oe)===!1)return!1;if(!this.buffer.hasScrollback){const je=this.viewport.getLinesScrolled(oe);if(je===0)return;const Le=X.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(oe.deltaY<0?"A":"B");let De="";for(let Re=0;Re<Math.abs(je);Re++)De+=Le;return this.coreService.triggerDataEvent(De,!0),this.cancel(oe,!0)}return this.viewport.handleWheel(oe)?this.cancel(oe):void 0}}),{passive:!1})),this.register((0,m.addDisposableDomListener)(q,"touchstart",(oe=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(oe),this.cancel(oe)}),{passive:!0})),this.register((0,m.addDisposableDomListener)(q,"touchmove",(oe=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(oe)?void 0:this.cancel(oe)}),{passive:!1}))}refresh(Y,q){var Z;(Z=this._renderService)==null||Z.refreshRows(Y,q)}updateCursorStyle(Y){var q;(q=this._selectionService)!=null&&q.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,q,Z=0){var ae;Z===1?(super.scrollLines(Y,q,Z),this.refresh(0,this.rows-1)):(ae=this.viewport)==null||ae.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 q=this._characterJoinerService.register(Y);return this.refresh(0,this.rows-1),q}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,q,Z){this._selectionService.setSelection(Y,q,Z)}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,q){var Z;(Z=this._selectionService)==null||Z.selectLines(Y,q)}_keyDown(Y){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(Y)===!1)return!1;const q=this.browser.isMac&&this.options.macOptionIsMeta&&Y.altKey;if(!q&&!this._compositionHelper.keydown(Y))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;q||Y.key!=="Dead"&&Y.key!=="AltGraph"||(this._unprocessedDeadKey=!0);const Z=(0,te.evaluateKeyboardEvent)(Y,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(Y),Z.type===3||Z.type===2){const ae=this.rows-1;return this.scrollLines(Z.type===2?-ae:ae),this.cancel(Y,!0)}return Z.type===1&&this.selectAll(),!!this._isThirdLevelShift(this.browser,Y)||(Z.cancel&&this.cancel(Y,!0),!Z.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):(Z.key!==X.C0.ETX&&Z.key!==X.C0.CR||(this.textarea.value=""),this._onKey.fire({key:Z.key,domEvent:Y}),this._showCursor(),this.coreService.triggerDataEvent(Z.key,!0),!this.optionsService.rawOptions.screenReaderMode||Y.altKey||Y.ctrlKey?this.cancel(Y,!0):void(this._keyDownHandled=!0))))}_isThirdLevelShift(Y,q){const Z=Y.isMac&&!this.options.macOptionIsMeta&&q.altKey&&!q.ctrlKey&&!q.metaKey||Y.isWindows&&q.altKey&&q.ctrlKey&&!q.metaKey||Y.isWindows&&q.getModifierState("AltGraph");return q.type==="keypress"?Z:Z&&(!q.keyCode||q.keyCode>47)}_keyUp(Y){this._keyDownSeen=!1,this._customKeyEventHandler&&this._customKeyEventHandler(Y)===!1||((function(q){return q.keyCode===16||q.keyCode===17||q.keyCode===18})(Y)||this.focus(),this.updateCursorStyle(Y),this._keyPressHandled=!1)}_keyPress(Y){let q;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(Y)===!1)return!1;if(this.cancel(Y),Y.charCode)q=Y.charCode;else if(Y.which===null||Y.which===void 0)q=Y.keyCode;else{if(Y.which===0||Y.charCode===0)return!1;q=Y.which}return!(!q||(Y.altKey||Y.ctrlKey||Y.metaKey)&&!this._isThirdLevelShift(this.browser,Y)||(q=String.fromCharCode(q),this._onKey.fire({key:q,domEvent:Y}),this._showCursor(),this.coreService.triggerDataEvent(q,!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 q=Y.data;return this.coreService.triggerDataEvent(q,!0),this.cancel(Y),!0}return!1}resize(Y,q){Y!==this.cols||q!==this.rows?super.resize(Y,q):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(Y,q){var Z,ae;(Z=this._charSizeService)==null||Z.measure(),(ae=this.viewport)==null||ae.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 q=1;q<this.rows;q++)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 q,Z;this.options.rows=this.rows,this.options.cols=this.cols;const Y=this._customKeyEventHandler;this._setup(),super.reset(),(q=this._selectionService)==null||q.reset(),this._decorationService.reset(),(Z=this.viewport)==null||Z.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 F.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:const q=this._renderService.dimensions.css.canvas.width.toFixed(0),Z=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${X.C0.ESC}[4;${Z};${q}t`);break;case F.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:const ae=this._renderService.dimensions.css.cell.width.toFixed(0),se=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${X.C0.ESC}[6;${se};${ae}t`)}}cancel(Y,q){if(this.options.cancelEvents||q)return Y.preventDefault(),Y.stopPropagation(),!1}}c.Terminal=J},9924:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.TimeBasedDebouncer=void 0,c.TimeBasedDebouncer=class{constructor(d,f=1e3){this._renderCallback=d,this._debounceThresholdMS=f,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(d,f,m){this._rowCount=m,d=d!==void 0?d:0,f=f!==void 0?f:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,d):d,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,f):f;const p=Date.now();if(p-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=p,this._innerRefresh();else if(!this._additionalRefreshRequested){const _=p-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 d=Math.max(this._rowStart,0),f=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(d,f)}}},1680:function(u,c,d){var f=this&&this.__decorate||function(S,b,y,E){var N,T=arguments.length,L=T<3?b:E===null?E=Object.getOwnPropertyDescriptor(b,y):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")L=Reflect.decorate(S,b,y,E);else for(var A=S.length-1;A>=0;A--)(N=S[A])&&(L=(T<3?N(L):T>3?N(b,y,L):N(b,y))||L);return T>3&&L&&Object.defineProperty(b,y,L),L},m=this&&this.__param||function(S,b){return function(y,E){b(y,E,S)}};Object.defineProperty(c,"__esModule",{value:!0}),c.Viewport=void 0;const p=d(3656),_=d(4725),x=d(8460),w=d(844),C=d(2585);let v=c.Viewport=class extends w.Disposable{constructor(S,b,y,E,N,T,L,A){super(),this._viewportElement=S,this._scrollArea=b,this._bufferService=y,this._optionsService=E,this._charSizeService=N,this._renderService=T,this._coreBrowserService=L,this.scrollBarWidth=0,this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._wheelPartialScroll=0,this._refreshAnimationFrame=null,this._ignoreNextScrollEvent=!1,this._smoothScrollState={startTime:0,origin:-1,target:-1},this._onRequestScrollLines=this.register(new x.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this.scrollBarWidth=this._viewportElement.offsetWidth-this._scrollArea.offsetWidth||15,this.register((0,p.addDisposableDomListener)(this._viewportElement,"scroll",this._handleScroll.bind(this))),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((R=>this._activeBuffer=R.activeBuffer))),this._renderDimensions=this._renderService.dimensions,this.register(this._renderService.onDimensionsChange((R=>this._renderDimensions=R))),this._handleThemeChange(A.colors),this.register(A.onChangeColors((R=>this._handleThemeChange(R)))),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.syncScrollArea()))),setTimeout((()=>this.syncScrollArea()))}_handleThemeChange(S){this._viewportElement.style.backgroundColor=S.background.css}reset(){this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._coreBrowserService.window.requestAnimationFrame((()=>this.syncScrollArea()))}_refresh(S){if(S)return this._innerRefresh(),void(this._refreshAnimationFrame!==null&&this._coreBrowserService.window.cancelAnimationFrame(this._refreshAnimationFrame));this._refreshAnimationFrame===null&&(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._charSizeService.height>0){this._currentRowHeight=this._renderDimensions.device.cell.height/this._coreBrowserService.dpr,this._currentDeviceCellHeight=this._renderDimensions.device.cell.height,this._lastRecordedViewportHeight=this._viewportElement.offsetHeight;const b=Math.round(this._currentRowHeight*this._lastRecordedBufferLength)+(this._lastRecordedViewportHeight-this._renderDimensions.css.canvas.height);this._lastRecordedBufferHeight!==b&&(this._lastRecordedBufferHeight=b,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 b=Math.round(this._lastScrollTop/this._currentRowHeight)-this._bufferService.buffer.ydisp;this._onRequestScrollLines.fire({amount:b,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,b){const y=this._viewportElement.scrollTop+this._lastRecordedViewportHeight;return!(b<0&&this._viewportElement.scrollTop!==0||b>0&&y<this._lastRecordedBufferHeight)||(S.cancelable&&S.preventDefault(),!1)}handleWheel(S){const b=this._getPixelsScrolled(S);return b!==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+b:this._smoothScrollState.target+=b,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()):this._viewportElement.scrollTop+=b,this._bubbleScroll(S,b))}scrollLines(S){if(S!==0)if(this._optionsService.rawOptions.smoothScrollDuration){const b=S*this._currentRowHeight;this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target=this._smoothScrollState.origin+b,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 b=this._applyScrollModifier(S.deltaY,S);return S.deltaMode===WheelEvent.DOM_DELTA_LINE?b*=this._currentRowHeight:S.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(b*=this._currentRowHeight*this._bufferService.rows),b}getBufferElements(S,b){var A;let y,E="";const N=[],T=b??this._bufferService.buffer.lines.length,L=this._bufferService.buffer.lines;for(let R=S;R<T;R++){const M=L.get(R);if(!M)continue;const G=(A=L.get(R+1))==null?void 0:A.isWrapped;if(E+=M.translateToString(!G),!G||R===L.length-1){const W=document.createElement("div");W.textContent=E,N.push(W),E.length>0&&(y=W),E=""}}return{bufferElements:N,cursorElement:y}}getLinesScrolled(S){if(S.deltaY===0||S.shiftKey)return 0;let b=this._applyScrollModifier(S.deltaY,S);return S.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(b/=this._currentRowHeight+0,this._wheelPartialScroll+=b,b=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):S.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(b*=this._bufferService.rows),b}_applyScrollModifier(S,b){const y=this._optionsService.rawOptions.fastScrollModifier;return y==="alt"&&b.altKey||y==="ctrl"&&b.ctrlKey||y==="shift"&&b.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 b=this._lastTouchY-S.touches[0].pageY;return this._lastTouchY=S.touches[0].pageY,b!==0&&(this._viewportElement.scrollTop+=b,this._bubbleScroll(S,b))}};c.Viewport=v=f([m(2,C.IBufferService),m(3,C.IOptionsService),m(4,_.ICharSizeService),m(5,_.IRenderService),m(6,_.ICoreBrowserService),m(7,_.IThemeService)],v)},3107:function(u,c,d){var f=this&&this.__decorate||function(C,v,S,b){var y,E=arguments.length,N=E<3?v:b===null?b=Object.getOwnPropertyDescriptor(v,S):b;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")N=Reflect.decorate(C,v,S,b);else for(var T=C.length-1;T>=0;T--)(y=C[T])&&(N=(E<3?y(N):E>3?y(v,S,N):y(v,S))||N);return E>3&&N&&Object.defineProperty(v,S,N),N},m=this&&this.__param||function(C,v){return function(S,b){v(S,b,C)}};Object.defineProperty(c,"__esModule",{value:!0}),c.BufferDecorationRenderer=void 0;const p=d(4725),_=d(844),x=d(2585);let w=c.BufferDecorationRenderer=class extends _.Disposable{constructor(C,v,S,b,y){super(),this._screenElement=C,this._bufferService=v,this._coreBrowserService=S,this._decorationService=b,this._renderService=y,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 C of this._decorationService.decorations)this._renderDecoration(C);this._dimensionsChanged=!1}_renderDecoration(C){this._refreshStyle(C),this._dimensionsChanged&&this._refreshXPosition(C)}_createElement(C){var b;const v=this._coreBrowserService.mainDocument.createElement("div");v.classList.add("xterm-decoration"),v.classList.toggle("xterm-decoration-top-layer",((b=C==null?void 0:C.options)==null?void 0:b.layer)==="top"),v.style.width=`${Math.round((C.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,v.style.height=(C.options.height||1)*this._renderService.dimensions.css.cell.height+"px",v.style.top=(C.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height+"px",v.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;const S=C.options.x??0;return S&&S>this._bufferService.cols&&(v.style.display="none"),this._refreshXPosition(C,v),v}_refreshStyle(C){const v=C.marker.line-this._bufferService.buffers.active.ydisp;if(v<0||v>=this._bufferService.rows)C.element&&(C.element.style.display="none",C.onRenderEmitter.fire(C.element));else{let S=this._decorationElements.get(C);S||(S=this._createElement(C),C.element=S,this._decorationElements.set(C,S),this._container.appendChild(S),C.onDispose((()=>{this._decorationElements.delete(C),S.remove()}))),S.style.top=v*this._renderService.dimensions.css.cell.height+"px",S.style.display=this._altBufferIsActive?"none":"block",C.onRenderEmitter.fire(S)}}_refreshXPosition(C,v=C.element){if(!v)return;const S=C.options.x??0;(C.options.anchor||"left")==="right"?v.style.right=S?S*this._renderService.dimensions.css.cell.width+"px":"":v.style.left=S?S*this._renderService.dimensions.css.cell.width+"px":""}_removeDecoration(C){var v;(v=this._decorationElements.get(C))==null||v.remove(),this._decorationElements.delete(C),C.dispose()}};c.BufferDecorationRenderer=w=f([m(1,x.IBufferService),m(2,p.ICoreBrowserService),m(3,x.IDecorationService),m(4,p.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(d){if(d.options.overviewRulerOptions){for(const f of this._zones)if(f.color===d.options.overviewRulerOptions.color&&f.position===d.options.overviewRulerOptions.position){if(this._lineIntersectsZone(f,d.marker.line))return;if(this._lineAdjacentToZone(f,d.marker.line,d.options.overviewRulerOptions.position))return void this._addLineToZone(f,d.marker.line)}if(this._zonePoolIndex<this._zonePool.length)return this._zonePool[this._zonePoolIndex].color=d.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=d.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=d.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=d.marker.line,void this._zones.push(this._zonePool[this._zonePoolIndex++]);this._zones.push({color:d.options.overviewRulerOptions.color,position:d.options.overviewRulerOptions.position,startBufferLine:d.marker.line,endBufferLine:d.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(d){this._linePadding=d}_lineIntersectsZone(d,f){return f>=d.startBufferLine&&f<=d.endBufferLine}_lineAdjacentToZone(d,f,m){return f>=d.startBufferLine-this._linePadding[m||"full"]&&f<=d.endBufferLine+this._linePadding[m||"full"]}_addLineToZone(d,f){d.startBufferLine=Math.min(d.startBufferLine,f),d.endBufferLine=Math.max(d.endBufferLine,f)}}},5744:function(u,c,d){var f=this&&this.__decorate||function(y,E,N,T){var L,A=arguments.length,R=A<3?E:T===null?T=Object.getOwnPropertyDescriptor(E,N):T;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(y,E,N,T);else for(var M=y.length-1;M>=0;M--)(L=y[M])&&(R=(A<3?L(R):A>3?L(E,N,R):L(E,N))||R);return A>3&&R&&Object.defineProperty(E,N,R),R},m=this&&this.__param||function(y,E){return function(N,T){E(N,T,y)}};Object.defineProperty(c,"__esModule",{value:!0}),c.OverviewRulerRenderer=void 0;const p=d(5871),_=d(4725),x=d(844),w=d(2585),C={full:0,left:0,center:0,right:0},v={full:0,left:0,center:0,right:0},S={full:0,left:0,center:0,right:0};let b=c.OverviewRulerRenderer=class extends x.Disposable{get _width(){return this._optionsService.options.overviewRulerWidth||0}constructor(y,E,N,T,L,A,R){var G;super(),this._viewportElement=y,this._screenElement=E,this._bufferService=N,this._decorationService=T,this._renderService=L,this._optionsService=A,this._coreBrowserService=R,this._colorZoneStore=new p.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(),(G=this._viewportElement.parentElement)==null||G.insertBefore(this._canvas,this._viewportElement);const M=this._canvas.getContext("2d");if(!M)throw new Error("Ctx cannot be null");this._ctx=M,this._registerDecorationListeners(),this._registerBufferChangeListeners(),this._registerDimensionChangeListeners(),this.register((0,x.toDisposable)((()=>{var 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 y=Math.floor(this._canvas.width/3),E=Math.ceil(this._canvas.width/3);v.full=this._canvas.width,v.left=y,v.center=E,v.right=y,this._refreshDrawHeightConstants(),S.full=0,S.left=0,S.center=v.left,S.right=v.left+v.center}_refreshDrawHeightConstants(){C.full=Math.round(2*this._coreBrowserService.dpr);const y=this._canvas.height/this._bufferService.buffer.lines.length,E=Math.round(Math.max(Math.min(y,12),6)*this._coreBrowserService.dpr);C.left=E,C.center=E,C.right=E}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*C.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*C.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*C.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*C.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(const E of this._decorationService.decorations)this._colorZoneStore.addDecoration(E);this._ctx.lineWidth=1;const y=this._colorZoneStore.zones;for(const E of y)E.position!=="full"&&this._renderColorZone(E);for(const E of y)E.position==="full"&&this._renderColorZone(E);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderColorZone(y){this._ctx.fillStyle=y.color,this._ctx.fillRect(S[y.position||"full"],Math.round((this._canvas.height-1)*(y.startBufferLine/this._bufferService.buffers.active.lines.length)-C[y.position||"full"]/2),v[y.position||"full"],Math.round((this._canvas.height-1)*((y.endBufferLine-y.startBufferLine)/this._bufferService.buffers.active.lines.length)+C[y.position||"full"]))}_queueRefresh(y,E){this._shouldUpdateDimensions=y||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=b=f([m(2,w.IBufferService),m(3,w.IDecorationService),m(4,_.IRenderService),m(5,w.IOptionsService),m(6,_.ICoreBrowserService)],b)},2950:function(u,c,d){var f=this&&this.__decorate||function(C,v,S,b){var y,E=arguments.length,N=E<3?v:b===null?b=Object.getOwnPropertyDescriptor(v,S):b;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")N=Reflect.decorate(C,v,S,b);else for(var T=C.length-1;T>=0;T--)(y=C[T])&&(N=(E<3?y(N):E>3?y(v,S,N):y(v,S))||N);return E>3&&N&&Object.defineProperty(v,S,N),N},m=this&&this.__param||function(C,v){return function(S,b){v(S,b,C)}};Object.defineProperty(c,"__esModule",{value:!0}),c.CompositionHelper=void 0;const p=d(4725),_=d(2585),x=d(2584);let w=c.CompositionHelper=class{get isComposing(){return this._isComposing}constructor(C,v,S,b,y,E){this._textarea=C,this._compositionView=v,this._bufferService=S,this._optionsService=b,this._coreService=y,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(C){this._compositionView.textContent=C.data,this.updateCompositionElements(),setTimeout((()=>{this._compositionPosition.end=this._textarea.value.length}),0)}compositionend(){this._finalizeComposition(!0)}keydown(C){if(this._isComposing||this._isSendingComposition){if(C.keyCode===229||C.keyCode===16||C.keyCode===17||C.keyCode===18)return!1;this._finalizeComposition(!1)}return C.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(C){if(this._compositionView.classList.remove("active"),this._isComposing=!1,C){const v={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout((()=>{if(this._isSendingComposition){let S;this._isSendingComposition=!1,v.start+=this._dataAlreadySent.length,S=this._isComposing?this._textarea.value.substring(v.start,v.end):this._textarea.value.substring(v.start),S.length>0&&this._coreService.triggerDataEvent(S,!0)}}),0)}else{this._isSendingComposition=!1;const v=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(v,!0)}}_handleAnyTextareaChanges(){const C=this._textarea.value;setTimeout((()=>{if(!this._isComposing){const v=this._textarea.value,S=v.replace(C,"");this._dataAlreadySent=S,v.length>C.length?this._coreService.triggerDataEvent(S,!0):v.length<C.length?this._coreService.triggerDataEvent(`${x.C0.DEL}`,!0):v.length===C.length&&v!==C&&this._coreService.triggerDataEvent(v,!0)}}),0)}updateCompositionElements(C){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){const v=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),S=this._renderService.dimensions.css.cell.height,b=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,y=v*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=y+"px",this._compositionView.style.top=b+"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=y+"px",this._textarea.style.top=b+"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"}C||setTimeout((()=>this.updateCompositionElements(!0)),0)}}};c.CompositionHelper=w=f([m(2,_.IBufferService),m(3,_.IOptionsService),m(4,_.ICoreService),m(5,p.IRenderService)],w)},9806:(u,c)=>{function d(f,m,p){const _=p.getBoundingClientRect(),x=f.getComputedStyle(p),w=parseInt(x.getPropertyValue("padding-left")),C=parseInt(x.getPropertyValue("padding-top"));return[m.clientX-_.left-w,m.clientY-_.top-C]}Object.defineProperty(c,"__esModule",{value:!0}),c.getCoords=c.getCoordsRelativeToElement=void 0,c.getCoordsRelativeToElement=d,c.getCoords=function(f,m,p,_,x,w,C,v,S){if(!w)return;const b=d(f,m,p);return b?(b[0]=Math.ceil((b[0]+(S?C/2:0))/C),b[1]=Math.ceil(b[1]/v),b[0]=Math.min(Math.max(b[0],1),_+(S?1:0)),b[1]=Math.min(Math.max(b[1],1),x),b):void 0}},9504:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.moveToCellSequence=void 0;const f=d(2584);function m(v,S,b,y){const E=v-p(v,b),N=S-p(S,b),T=Math.abs(E-N)-(function(L,A,R){let M=0;const G=L-p(L,R),W=A-p(A,R);for(let O=0;O<Math.abs(G-W);O++){const U=_(L,A)==="A"?-1:1,V=R.buffer.lines.get(G+U*O);V!=null&&V.isWrapped&&M++}return M})(v,S,b);return C(T,w(_(v,S),y))}function p(v,S){let b=0,y=S.buffer.lines.get(v),E=y==null?void 0:y.isWrapped;for(;E&&v>=0&&v<S.rows;)b++,y=S.buffer.lines.get(--v),E=y==null?void 0:y.isWrapped;return b}function _(v,S){return v>S?"A":"B"}function x(v,S,b,y,E,N){let T=v,L=S,A="";for(;T!==b||L!==y;)T+=E?1:-1,E&&T>N.cols-1?(A+=N.buffer.translateBufferLineToString(L,!1,v,T),T=0,v=0,L++):!E&&T<0&&(A+=N.buffer.translateBufferLineToString(L,!1,0,v+1),T=N.cols-1,v=T,L--);return A+N.buffer.translateBufferLineToString(L,!1,v,T)}function w(v,S){const b=S?"O":"[";return f.C0.ESC+b+v}function C(v,S){v=Math.floor(v);let b="";for(let y=0;y<v;y++)b+=S;return b}c.moveToCellSequence=function(v,S,b,y){const E=b.buffer.x,N=b.buffer.y;if(!b.buffer.hasScrollback)return(function(A,R,M,G,W,O){return m(R,G,W,O).length===0?"":C(x(A,R,A,R-p(R,W),!1,W).length,w("D",O))})(E,N,0,S,b,y)+m(N,S,b,y)+(function(A,R,M,G,W,O){let U;U=m(R,G,W,O).length>0?G-p(G,W):R;const V=G,z=(function(X,te,H,I,$,F){let P;return P=m(H,I,$,F).length>0?I-p(I,$):te,X<H&&P<=I||X>=H&&P<I?"C":"D"})(A,R,M,G,W,O);return C(x(A,U,M,V,z==="C",W).length,w(z,O))})(E,N,v,S,b,y);let T;if(N===S)return T=E>v?"D":"C",C(Math.abs(E-v),w(T,y));T=N>S?"D":"C";const L=Math.abs(N-S);return C((function(A,R){return R.cols-A})(N>S?v:E,b)+(L-1)*b.cols+1+((N>S?E:v)-1),w(T,y))}},1296:function(u,c,d){var f=this&&this.__decorate||function(O,U,V,z){var X,te=arguments.length,H=te<3?U:z===null?z=Object.getOwnPropertyDescriptor(U,V):z;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")H=Reflect.decorate(O,U,V,z);else for(var I=O.length-1;I>=0;I--)(X=O[I])&&(H=(te<3?X(H):te>3?X(U,V,H):X(U,V))||H);return te>3&&H&&Object.defineProperty(U,V,H),H},m=this&&this.__param||function(O,U){return function(V,z){U(V,z,O)}};Object.defineProperty(c,"__esModule",{value:!0}),c.DomRenderer=void 0;const p=d(3787),_=d(2550),x=d(2223),w=d(6171),C=d(6052),v=d(4725),S=d(8055),b=d(8460),y=d(844),E=d(2585),N="xterm-dom-renderer-owner-",T="xterm-rows",L="xterm-fg-",A="xterm-bg-",R="xterm-focus",M="xterm-selection";let G=1,W=c.DomRenderer=class extends y.Disposable{constructor(O,U,V,z,X,te,H,I,$,F,P,ee,J){super(),this._terminal=O,this._document=U,this._element=V,this._screenElement=z,this._viewportElement=X,this._helperContainer=te,this._linkifier2=H,this._charSizeService=$,this._optionsService=F,this._bufferService=P,this._coreBrowserService=ee,this._themeService=J,this._terminalClass=G++,this._rowElements=[],this._selectionRenderModel=(0,C.createSelectionRenderModel)(),this.onRequestRedraw=this.register(new b.EventEmitter).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(T),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(M),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=(0,w.createRenderDimensions)(),this._updateDimensions(),this.register(this._optionsService.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._themeService.onChangeColors((re=>this._injectCss(re)))),this._injectCss(this._themeService.colors),this._rowFactory=I.createInstance(p.DomRendererRowFactory,document),this._element.classList.add(N+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this.register(this._linkifier2.onShowLinkUnderline((re=>this._handleLinkHover(re)))),this.register(this._linkifier2.onHideLinkUnderline((re=>this._handleLinkLeave(re)))),this.register((0,y.toDisposable)((()=>{this._element.classList.remove(N+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 V of this._rowElements)V.style.width=`${this.dimensions.css.canvas.width}px`,V.style.height=`${this.dimensions.css.cell.height}px`,V.style.lineHeight=`${this.dimensions.css.cell.height}px`,V.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));const U=`${this._terminalSelector} .${T} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=U,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 U=`${this._terminalSelector} .${T} { color: ${O.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;U+=`${this._terminalSelector} .${T} .xterm-dim { color: ${S.color.multiplyOpacity(O.foreground,.5).css};}`,U+=`${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 V=`blink_underline_${this._terminalClass}`,z=`blink_bar_${this._terminalClass}`,X=`blink_block_${this._terminalClass}`;U+=`@keyframes ${V} { 50% { border-bottom-style: hidden; }}`,U+=`@keyframes ${z} { 50% { box-shadow: none; }}`,U+=`@keyframes ${X} { 0% { background-color: ${O.cursor.css}; color: ${O.cursorAccent.css}; } 50% { background-color: inherit; color: ${O.cursor.css}; }}`,U+=`${this._terminalSelector} .${T}.${R} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${V} 1s step-end infinite;}${this._terminalSelector} .${T}.${R} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${z} 1s step-end infinite;}${this._terminalSelector} .${T}.${R} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${X} 1s step-end infinite;}${this._terminalSelector} .${T} .xterm-cursor.xterm-cursor-block { background-color: ${O.cursor.css}; color: ${O.cursorAccent.css};}${this._terminalSelector} .${T} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${O.cursor.css} !important; color: ${O.cursorAccent.css} !important;}${this._terminalSelector} .${T} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${O.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${T} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${O.cursor.css} inset;}${this._terminalSelector} .${T} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${O.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,U+=`${this._terminalSelector} .${M} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${M} div { position: absolute; background-color: ${O.selectionBackgroundOpaque.css};}${this._terminalSelector} .${M} div { position: absolute; background-color: ${O.selectionInactiveBackgroundOpaque.css};}`;for(const[te,H]of O.ansi.entries())U+=`${this._terminalSelector} .${L}${te} { color: ${H.css}; }${this._terminalSelector} .${L}${te}.xterm-dim { color: ${S.color.multiplyOpacity(H,.5).css}; }${this._terminalSelector} .${A}${te} { background-color: ${H.css}; }`;U+=`${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=U}_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,U){for(let V=this._rowElements.length;V<=U;V++){const z=this._document.createElement("div");this._rowContainer.appendChild(z),this._rowElements.push(z)}for(;this._rowElements.length>U;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(O,U){this._refreshRowElements(O,U),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(R),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(R),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(O,U,V){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(O,U,V),this.renderRows(0,this._bufferService.rows-1),!O||!U)return;this._selectionRenderModel.update(this._terminal,O,U,V);const z=this._selectionRenderModel.viewportStartRow,X=this._selectionRenderModel.viewportEndRow,te=this._selectionRenderModel.viewportCappedStartRow,H=this._selectionRenderModel.viewportCappedEndRow;if(te>=this._bufferService.rows||H<0)return;const I=this._document.createDocumentFragment();if(V){const $=O[0]>U[0];I.appendChild(this._createSelectionElement(te,$?U[0]:O[0],$?O[0]:U[0],H-te+1))}else{const $=z===te?O[0]:0,F=te===X?U[0]:this._bufferService.cols;I.appendChild(this._createSelectionElement(te,$,F));const P=H-te-1;if(I.appendChild(this._createSelectionElement(te+1,0,this._bufferService.cols,P)),te!==H){const ee=X===H?U[0]:this._bufferService.cols;I.appendChild(this._createSelectionElement(H,0,ee))}}this._selectionContainer.appendChild(I)}_createSelectionElement(O,U,V,z=1){const X=this._document.createElement("div"),te=U*this.dimensions.css.cell.width;let H=this.dimensions.css.cell.width*(V-U);return te+H>this.dimensions.css.canvas.width&&(H=this.dimensions.css.canvas.width-te),X.style.height=z*this.dimensions.css.cell.height+"px",X.style.top=O*this.dimensions.css.cell.height+"px",X.style.left=`${te}px`,X.style.width=`${H}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,U){const V=this._bufferService.buffer,z=V.ybase+V.y,X=Math.min(V.x,this._bufferService.cols-1),te=this._optionsService.rawOptions.cursorBlink,H=this._optionsService.rawOptions.cursorStyle,I=this._optionsService.rawOptions.cursorInactiveStyle;for(let $=O;$<=U;$++){const F=$+V.ydisp,P=this._rowElements[$],ee=V.lines.get(F);if(!P||!ee)break;P.replaceChildren(...this._rowFactory.createRow(ee,F,F===z,H,I,X,te,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${N}${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,U,V,z,X,te){V<0&&(O=0),z<0&&(U=0);const H=this._bufferService.rows-1;V=Math.max(Math.min(V,H),0),z=Math.max(Math.min(z,H),0),X=Math.min(X,this._bufferService.cols);const I=this._bufferService.buffer,$=I.ybase+I.y,F=Math.min(I.x,X-1),P=this._optionsService.rawOptions.cursorBlink,ee=this._optionsService.rawOptions.cursorStyle,J=this._optionsService.rawOptions.cursorInactiveStyle;for(let re=V;re<=z;++re){const Y=re+I.ydisp,q=this._rowElements[re],Z=I.lines.get(Y);if(!q||!Z)break;q.replaceChildren(...this._rowFactory.createRow(Z,Y,Y===$,ee,J,F,P,this.dimensions.css.cell.width,this._widthCache,te?re===V?O:0:-1,te?(re===z?U:X)-1:-1))}}};c.DomRenderer=W=f([m(7,E.IInstantiationService),m(8,v.ICharSizeService),m(9,E.IOptionsService),m(10,E.IBufferService),m(11,v.ICoreBrowserService),m(12,v.IThemeService)],W)},3787:function(u,c,d){var f=this&&this.__decorate||function(T,L,A,R){var M,G=arguments.length,W=G<3?L:R===null?R=Object.getOwnPropertyDescriptor(L,A):R;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")W=Reflect.decorate(T,L,A,R);else for(var O=T.length-1;O>=0;O--)(M=T[O])&&(W=(G<3?M(W):G>3?M(L,A,W):M(L,A))||W);return G>3&&W&&Object.defineProperty(L,A,W),W},m=this&&this.__param||function(T,L){return function(A,R){L(A,R,T)}};Object.defineProperty(c,"__esModule",{value:!0}),c.DomRendererRowFactory=void 0;const p=d(2223),_=d(643),x=d(511),w=d(2585),C=d(8055),v=d(4725),S=d(4269),b=d(6171),y=d(3734);let E=c.DomRendererRowFactory=class{constructor(T,L,A,R,M,G,W){this._document=T,this._characterJoinerService=L,this._optionsService=A,this._coreBrowserService=R,this._coreService=M,this._decorationService=G,this._themeService=W,this._workCell=new x.CellData,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(T,L,A){this._selectionStart=T,this._selectionEnd=L,this._columnSelectMode=A}createRow(T,L,A,R,M,G,W,O,U,V,z){const X=[],te=this._characterJoinerService.getJoinedCharacters(L),H=this._themeService.colors;let I,$=T.getNoBgTrimmedLength();A&&$<G+1&&($=G+1);let F=0,P="",ee=0,J=0,re=0,Y=!1,q=0,Z=!1,ae=0;const se=[],oe=V!==-1&&z!==-1;for(let je=0;je<$;je++){T.loadCell(je,this._workCell);let Le=this._workCell.getWidth();if(Le===0)continue;let De=!1,Re=je,Te=this._workCell;if(te.length>0&&je===te[0][0]){De=!0;const Ye=te.shift();Te=new S.JoinedCellData(this._workCell,T.translateToString(!0,Ye[0],Ye[1]),Ye[1]-Ye[0]),Re=Ye[1]-1,Le=Te.getWidth()}const Ae=this._isCellInSelection(je,L),pe=A&&je===G,ce=oe&&je>=V&&je<=z;let Se=!1;this._decorationService.forEachDecorationAtCell(je,L,void 0,(Ye=>{Se=!0}));let Ze=Te.getChars()||_.WHITESPACE_CELL_CHAR;if(Ze===" "&&(Te.isUnderline()||Te.isOverline())&&(Ze=" "),ae=Le*O-U.get(Ze,Te.isBold(),Te.isItalic()),I){if(F&&(Ae&&Z||!Ae&&!Z&&Te.bg===ee)&&(Ae&&Z&&H.selectionForeground||Te.fg===J)&&Te.extended.ext===re&&ce===Y&&ae===q&&!pe&&!De&&!Se){Te.isInvisible()?P+=_.WHITESPACE_CELL_CHAR:P+=Ze,F++;continue}F&&(I.textContent=P),I=this._document.createElement("span"),F=0,P=""}else I=this._document.createElement("span");if(ee=Te.bg,J=Te.fg,re=Te.extended.ext,Y=ce,q=ae,Z=Ae,De&&G>=je&&G<=Re&&(G=je),!this._coreService.isCursorHidden&&pe&&this._coreService.isCursorInitialized){if(se.push("xterm-cursor"),this._coreBrowserService.isFocused)W&&se.push("xterm-cursor-blink"),se.push(R==="bar"?"xterm-cursor-bar":R==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(M)switch(M){case"outline":se.push("xterm-cursor-outline");break;case"block":se.push("xterm-cursor-block");break;case"bar":se.push("xterm-cursor-bar");break;case"underline":se.push("xterm-cursor-underline")}}if(Te.isBold()&&se.push("xterm-bold"),Te.isItalic()&&se.push("xterm-italic"),Te.isDim()&&se.push("xterm-dim"),P=Te.isInvisible()?_.WHITESPACE_CELL_CHAR:Te.getChars()||_.WHITESPACE_CELL_CHAR,Te.isUnderline()&&(se.push(`xterm-underline-${Te.extended.underlineStyle}`),P===" "&&(P=" "),!Te.isUnderlineColorDefault()))if(Te.isUnderlineColorRGB())I.style.textDecorationColor=`rgb(${y.AttributeData.toColorRGB(Te.getUnderlineColor()).join(",")})`;else{let Ye=Te.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&Te.isBold()&&Ye<8&&(Ye+=8),I.style.textDecorationColor=H.ansi[Ye].css}Te.isOverline()&&(se.push("xterm-overline"),P===" "&&(P=" ")),Te.isStrikethrough()&&se.push("xterm-strikethrough"),ce&&(I.style.textDecoration="underline");let _t=Te.getFgColor(),dt=Te.getFgColorMode(),tn=Te.getBgColor(),ge=Te.getBgColorMode();const Ce=!!Te.isInverse();if(Ce){const Ye=_t;_t=tn,tn=Ye;const wt=dt;dt=ge,ge=wt}let Ie,Fe,Ve,St=!1;switch(this._decorationService.forEachDecorationAtCell(je,L,void 0,(Ye=>{Ye.options.layer!=="top"&&St||(Ye.backgroundColorRGB&&(ge=50331648,tn=Ye.backgroundColorRGB.rgba>>8&16777215,Ie=Ye.backgroundColorRGB),Ye.foregroundColorRGB&&(dt=50331648,_t=Ye.foregroundColorRGB.rgba>>8&16777215,Fe=Ye.foregroundColorRGB),St=Ye.options.layer==="top")})),!St&&Ae&&(Ie=this._coreBrowserService.isFocused?H.selectionBackgroundOpaque:H.selectionInactiveBackgroundOpaque,tn=Ie.rgba>>8&16777215,ge=50331648,St=!0,H.selectionForeground&&(dt=50331648,_t=H.selectionForeground.rgba>>8&16777215,Fe=H.selectionForeground)),St&&se.push("xterm-decoration-top"),ge){case 16777216:case 33554432:Ve=H.ansi[tn],se.push(`xterm-bg-${tn}`);break;case 50331648:Ve=C.channels.toColor(tn>>16,tn>>8&255,255&tn),this._addStyle(I,`background-color:#${N((tn>>>0).toString(16),"0",6)}`);break;default:Ce?(Ve=H.foreground,se.push(`xterm-bg-${p.INVERTED_DEFAULT_COLOR}`)):Ve=H.background}switch(Ie||Te.isDim()&&(Ie=C.color.multiplyOpacity(Ve,.5)),dt){case 16777216:case 33554432:Te.isBold()&&_t<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(_t+=8),this._applyMinimumContrast(I,Ve,H.ansi[_t],Te,Ie,void 0)||se.push(`xterm-fg-${_t}`);break;case 50331648:const Ye=C.channels.toColor(_t>>16&255,_t>>8&255,255&_t);this._applyMinimumContrast(I,Ve,Ye,Te,Ie,Fe)||this._addStyle(I,`color:#${N(_t.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(I,Ve,H.foreground,Te,Ie,Fe)||Ce&&se.push(`xterm-fg-${p.INVERTED_DEFAULT_COLOR}`)}se.length&&(I.className=se.join(" "),se.length=0),pe||De||Se?I.textContent=P:F++,ae!==this.defaultSpacing&&(I.style.letterSpacing=`${ae}px`),X.push(I),je=Re}return I&&F&&(I.textContent=P),X}_applyMinimumContrast(T,L,A,R,M,G){if(this._optionsService.rawOptions.minimumContrastRatio===1||(0,b.treatGlyphAsBackgroundColor)(R.getCode()))return!1;const W=this._getContrastCache(R);let O;if(M||G||(O=W.getColor(L.rgba,A.rgba)),O===void 0){const U=this._optionsService.rawOptions.minimumContrastRatio/(R.isDim()?2:1);O=C.color.ensureContrastRatio(M||L,G||A,U),W.setColor((M||L).rgba,(G||A).rgba,O??null)}return!!O&&(this._addStyle(T,`color:${O.css}`),!0)}_getContrastCache(T){return T.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(T,L){T.setAttribute("style",`${T.getAttribute("style")||""}${L};`)}_isCellInSelection(T,L){const A=this._selectionStart,R=this._selectionEnd;return!(!A||!R)&&(this._columnSelectMode?A[0]<=R[0]?T>=A[0]&&L>=A[1]&&T<R[0]&&L<=R[1]:T<A[0]&&L>=A[1]&&T>=R[0]&&L<=R[1]:L>A[1]&&L<R[1]||A[1]===R[1]&&L===A[1]&&T>=A[0]&&T<R[0]||A[1]<R[1]&&L===R[1]&&T<R[0]||A[1]<R[1]&&L===A[1]&&T>=A[0])}};function N(T,L,A){for(;T.length<A;)T=L+T;return T}c.DomRendererRowFactory=E=f([m(1,v.ICharacterJoinerService),m(2,w.IOptionsService),m(3,v.ICoreBrowserService),m(4,w.ICoreService),m(5,w.IDecorationService),m(6,v.IThemeService)],E)},2550:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.WidthCache=void 0,c.WidthCache=class{constructor(d,f){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=d.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";const m=d.createElement("span");m.classList.add("xterm-char-measure-element");const p=d.createElement("span");p.classList.add("xterm-char-measure-element"),p.style.fontWeight="bold";const _=d.createElement("span");_.classList.add("xterm-char-measure-element"),_.style.fontStyle="italic";const x=d.createElement("span");x.classList.add("xterm-char-measure-element"),x.style.fontWeight="bold",x.style.fontStyle="italic",this._measureElements=[m,p,_,x],this._container.appendChild(m),this._container.appendChild(p),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(d,f,m,p){d===this._font&&f===this._fontSize&&m===this._weight&&p===this._weightBold||(this._font=d,this._fontSize=f,this._weight=m,this._weightBold=p,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${m}`,this._measureElements[1].style.fontWeight=`${p}`,this._measureElements[2].style.fontWeight=`${m}`,this._measureElements[3].style.fontWeight=`${p}`,this.clear())}get(d,f,m){let p=0;if(!f&&!m&&d.length===1&&(p=d.charCodeAt(0))<256){if(this._flat[p]!==-9999)return this._flat[p];const w=this._measure(d,0);return w>0&&(this._flat[p]=w),w}let _=d;f&&(_+="B"),m&&(_+="I");let x=this._holey.get(_);if(x===void 0){let w=0;f&&(w|=1),m&&(w|=2),x=this._measure(d,w),x>0&&this._holey.set(_,x)}return x}_measure(d,f){const m=this._measureElements[f];return m.textContent=d.repeat(32),m.offsetWidth/32}}},2223:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.TEXT_BASELINE=c.DIM_OPACITY=c.INVERTED_DEFAULT_COLOR=void 0;const f=d(6114);c.INVERTED_DEFAULT_COLOR=257,c.DIM_OPACITY=.5,c.TEXT_BASELINE=f.isFirefox||f.isLegacyEdge?"bottom":"ideographic"},6171:(u,c)=>{function d(m){return 57508<=m&&m<=57558}function f(m){return m>=128512&&m<=128591||m>=127744&&m<=128511||m>=128640&&m<=128767||m>=9728&&m<=9983||m>=9984&&m<=10175||m>=65024&&m<=65039||m>=129280&&m<=129535||m>=127462&&m<=127487}Object.defineProperty(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(m){if(!m)throw new Error("value must not be falsy");return m},c.isPowerlineGlyph=d,c.isRestrictedPowerlineGlyph=function(m){return 57520<=m&&m<=57527},c.isEmoji=f,c.allowRescaling=function(m,p,_,x){return p===1&&_>Math.ceil(1.5*x)&&m!==void 0&&m>255&&!f(m)&&!d(m)&&!(function(w){return 57344<=w&&w<=63743})(m)},c.treatGlyphAsBackgroundColor=function(m){return d(m)||(function(p){return 9472<=p&&p<=9631})(m)},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(m,p,_=0){return(m-(2*Math.round(p)-_))%(2*Math.round(p))}},6052:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.createSelectionRenderModel=void 0;class d{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(m,p,_,x=!1){if(this.selectionStart=p,this.selectionEnd=_,!p||!_||p[0]===_[0]&&p[1]===_[1])return void this.clear();const w=m.buffers.active.ydisp,C=p[1]-w,v=_[1]-w,S=Math.max(C,0),b=Math.min(v,m.rows-1);S>=m.rows||b<0?this.clear():(this.hasSelection=!0,this.columnSelectMode=x,this.viewportStartRow=C,this.viewportEndRow=v,this.viewportCappedStartRow=S,this.viewportCappedEndRow=b,this.startCol=p[0],this.endCol=_[0])}isCellSelected(m,p,_){return!!this.hasSelection&&(_-=m.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?p>=this.startCol&&_>=this.viewportCappedStartRow&&p<this.endCol&&_<=this.viewportCappedEndRow:p<this.startCol&&_>=this.viewportCappedStartRow&&p>=this.endCol&&_<=this.viewportCappedEndRow:_>this.viewportStartRow&&_<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&_===this.viewportStartRow&&p>=this.startCol&&p<this.endCol||this.viewportStartRow<this.viewportEndRow&&_===this.viewportEndRow&&p<this.endCol||this.viewportStartRow<this.viewportEndRow&&_===this.viewportStartRow&&p>=this.startCol)}}c.createSelectionRenderModel=function(){return new d}},456:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.SelectionModel=void 0,c.SelectionModel=class{constructor(d){this._bufferService=d,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:this.selectionEnd&&this.selectionStart&&this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){const d=this.selectionStart[0]+this.selectionStartLength;return d>this._bufferService.cols?d%this._bufferService.cols==0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(d/this._bufferService.cols)-1]:[d%this._bufferService.cols,this.selectionStart[1]+Math.floor(d/this._bufferService.cols)]:[d,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){const d=this.selectionStart[0]+this.selectionStartLength;return d>this._bufferService.cols?[d%this._bufferService.cols,this.selectionStart[1]+Math.floor(d/this._bufferService.cols)]:[Math.max(d,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){const d=this.selectionStart,f=this.selectionEnd;return!(!d||!f)&&(d[1]>f[1]||d[1]===f[1]&&d[0]>f[0])}handleTrim(d){return this.selectionStart&&(this.selectionStart[1]-=d),this.selectionEnd&&(this.selectionEnd[1]-=d),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}}},428:function(u,c,d){var f=this&&this.__decorate||function(b,y,E,N){var T,L=arguments.length,A=L<3?y:N===null?N=Object.getOwnPropertyDescriptor(y,E):N;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(b,y,E,N);else for(var R=b.length-1;R>=0;R--)(T=b[R])&&(A=(L<3?T(A):L>3?T(y,E,A):T(y,E))||A);return L>3&&A&&Object.defineProperty(y,E,A),A},m=this&&this.__param||function(b,y){return function(E,N){y(E,N,b)}};Object.defineProperty(c,"__esModule",{value:!0}),c.CharSizeService=void 0;const p=d(2585),_=d(8460),x=d(844);let w=c.CharSizeService=class extends x.Disposable{get hasValidSize(){return this.width>0&&this.height>0}constructor(b,y,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 v(b,y,this._optionsService))}this.register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],(()=>this.measure())))}measure(){const b=this._measureStrategy.measure();b.width===this.width&&b.height===this.height||(this.width=b.width,this.height=b.height,this._onCharSizeChange.fire())}};c.CharSizeService=w=f([m(2,p.IOptionsService)],w);class C extends x.Disposable{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(y,E){y!==void 0&&y>0&&E!==void 0&&E>0&&(this._result.width=y,this._result.height=E)}}class v extends C{constructor(y,E,N){super(),this._document=y,this._parentElement=E,this._optionsService=N,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}}class S extends C{constructor(y){super(),this._optionsService=y,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 y=this._ctx.measureText("W");return this._validateAndSet(y.width,y.fontBoundingBoxAscent+y.fontBoundingBoxDescent),this._result}}},4269:function(u,c,d){var f=this&&this.__decorate||function(S,b,y,E){var N,T=arguments.length,L=T<3?b:E===null?E=Object.getOwnPropertyDescriptor(b,y):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")L=Reflect.decorate(S,b,y,E);else for(var A=S.length-1;A>=0;A--)(N=S[A])&&(L=(T<3?N(L):T>3?N(b,y,L):N(b,y))||L);return T>3&&L&&Object.defineProperty(b,y,L),L},m=this&&this.__param||function(S,b){return function(y,E){b(y,E,S)}};Object.defineProperty(c,"__esModule",{value:!0}),c.CharacterJoinerService=c.JoinedCellData=void 0;const p=d(3734),_=d(643),x=d(511),w=d(2585);class C extends p.AttributeData{constructor(b,y,E){super(),this.content=0,this.combinedData="",this.fg=b.fg,this.bg=b.bg,this.combinedData=y,this._width=E}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(b){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}c.JoinedCellData=C;let v=c.CharacterJoinerService=class BS{constructor(b){this._bufferService=b,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new x.CellData}register(b){const y={id:this._nextCharacterJoinerId++,handler:b};return this._characterJoiners.push(y),y.id}deregister(b){for(let y=0;y<this._characterJoiners.length;y++)if(this._characterJoiners[y].id===b)return this._characterJoiners.splice(y,1),!0;return!1}getJoinedCharacters(b){if(this._characterJoiners.length===0)return[];const y=this._bufferService.buffer.lines.get(b);if(!y||y.length===0)return[];const E=[],N=y.translateToString(!0);let T=0,L=0,A=0,R=y.getFg(0),M=y.getBg(0);for(let G=0;G<y.getTrimmedLength();G++)if(y.loadCell(G,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==R||this._workCell.bg!==M){if(G-T>1){const W=this._getJoinedRanges(N,A,L,y,T);for(let O=0;O<W.length;O++)E.push(W[O])}T=G,A=L,R=this._workCell.fg,M=this._workCell.bg}L+=this._workCell.getChars().length||_.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-T>1){const G=this._getJoinedRanges(N,A,L,y,T);for(let W=0;W<G.length;W++)E.push(G[W])}return E}_getJoinedRanges(b,y,E,N,T){const L=b.substring(y,E);let A=[];try{A=this._characterJoiners[0].handler(L)}catch(R){console.error(R)}for(let R=1;R<this._characterJoiners.length;R++)try{const M=this._characterJoiners[R].handler(L);for(let G=0;G<M.length;G++)BS._mergeRanges(A,M[G])}catch(M){console.error(M)}return this._stringRangesToCellRanges(A,N,T),A}_stringRangesToCellRanges(b,y,E){let N=0,T=!1,L=0,A=b[N];if(A){for(let R=E;R<this._bufferService.cols;R++){const M=y.getWidth(R),G=y.getString(R).length||_.WHITESPACE_CELL_CHAR.length;if(M!==0){if(!T&&A[0]<=L&&(A[0]=R,T=!0),A[1]<=L){if(A[1]=R,A=b[++N],!A)break;A[0]<=L?(A[0]=R,T=!0):T=!1}L+=G}}A&&(A[1]=this._bufferService.cols)}}static _mergeRanges(b,y){let E=!1;for(let N=0;N<b.length;N++){const T=b[N];if(E){if(y[1]<=T[0])return b[N-1][1]=y[1],b;if(y[1]<=T[1])return b[N-1][1]=Math.max(y[1],T[1]),b.splice(N,1),b;b.splice(N,1),N--}else{if(y[1]<=T[0])return b.splice(N,0,y),b;if(y[1]<=T[1])return T[0]=Math.min(y[0],T[0]),b;y[0]<T[1]&&(T[0]=Math.min(y[0],T[0]),E=!0)}}return E?b[b.length-1][1]=y[1]:b.push(y),b}};c.CharacterJoinerService=v=f([m(0,w.IBufferService)],v)},5114:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.CoreBrowserService=void 0;const f=d(844),m=d(8460),p=d(3656);class _ extends f.Disposable{constructor(C,v,S){super(),this._textarea=C,this._window=v,this.mainDocument=S,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=new x(this._window),this._onDprChange=this.register(new m.EventEmitter),this.onDprChange=this._onDprChange.event,this._onWindowChange=this.register(new m.EventEmitter),this.onWindowChange=this._onWindowChange.event,this.register(this.onWindowChange((b=>this._screenDprMonitor.setWindow(b)))),this.register((0,m.forwardEvent)(this._screenDprMonitor.onDprChange,this._onDprChange)),this._textarea.addEventListener("focus",(()=>this._isFocused=!0)),this._textarea.addEventListener("blur",(()=>this._isFocused=!1))}get window(){return this._window}set window(C){this._window!==C&&(this._window=C,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask((()=>this._cachedIsFocused=void 0))),this._cachedIsFocused}}c.CoreBrowserService=_;class x extends f.Disposable{constructor(C){super(),this._parentWindow=C,this._windowResizeListener=this.register(new f.MutableDisposable),this._onDprChange=this.register(new m.EventEmitter),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this.register((0,f.toDisposable)((()=>this.clearListener())))}setWindow(C){this._parentWindow=C,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=(0,p.addDisposableDomListener)(this._parentWindow,"resize",(()=>this._setDprAndFireIfDiffers()))}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var C;this._outerListener&&((C=this._resolutionMediaMatchList)==null||C.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){this._resolutionMediaMatchList&&this._outerListener&&(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}}},779:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.LinkProviderService=void 0;const f=d(844);class m 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=m},8934:function(u,c,d){var f=this&&this.__decorate||function(w,C,v,S){var b,y=arguments.length,E=y<3?C:S===null?S=Object.getOwnPropertyDescriptor(C,v):S;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(w,C,v,S);else for(var N=w.length-1;N>=0;N--)(b=w[N])&&(E=(y<3?b(E):y>3?b(C,v,E):b(C,v))||E);return y>3&&E&&Object.defineProperty(C,v,E),E},m=this&&this.__param||function(w,C){return function(v,S){C(v,S,w)}};Object.defineProperty(c,"__esModule",{value:!0}),c.MouseService=void 0;const p=d(4725),_=d(9806);let x=c.MouseService=class{constructor(w,C){this._renderService=w,this._charSizeService=C}getCoords(w,C,v,S,b){return(0,_.getCoords)(window,w,C,v,S,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,b)}getMouseReportCoords(w,C){const v=(0,_.getCoordsRelativeToElement)(window,w,C);if(this._charSizeService.hasValidSize)return v[0]=Math.min(Math.max(v[0],0),this._renderService.dimensions.css.canvas.width-1),v[1]=Math.min(Math.max(v[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(v[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(v[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(v[0]),y:Math.floor(v[1])}}};c.MouseService=x=f([m(0,p.IRenderService),m(1,p.ICharSizeService)],x)},3230:function(u,c,d){var f=this&&this.__decorate||function(b,y,E,N){var T,L=arguments.length,A=L<3?y:N===null?N=Object.getOwnPropertyDescriptor(y,E):N;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(b,y,E,N);else for(var R=b.length-1;R>=0;R--)(T=b[R])&&(A=(L<3?T(A):L>3?T(y,E,A):T(y,E))||A);return L>3&&A&&Object.defineProperty(y,E,A),A},m=this&&this.__param||function(b,y){return function(E,N){y(E,N,b)}};Object.defineProperty(c,"__esModule",{value:!0}),c.RenderService=void 0;const p=d(6193),_=d(4725),x=d(8460),w=d(844),C=d(7226),v=d(2585);let S=c.RenderService=class extends w.Disposable{get dimensions(){return this._renderer.value.dimensions}constructor(b,y,E,N,T,L,A,R){super(),this._rowCount=b,this._charSizeService=N,this._renderer=this.register(new w.MutableDisposable),this._pausedResizeTask=new C.DebouncedIdleTask,this._observerDisposable=this.register(new w.MutableDisposable),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this.register(new x.EventEmitter),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this.register(new x.EventEmitter),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this.register(new x.EventEmitter),this.onRender=this._onRender.event,this._onRefreshRequest=this.register(new x.EventEmitter),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new p.RenderDebouncer(((M,G)=>this._renderRows(M,G)),A),this.register(this._renderDebouncer),this.register(A.onDprChange((()=>this.handleDevicePixelRatioChange()))),this.register(L.onResize((()=>this._fullRefresh()))),this.register(L.buffers.onBufferActivate((()=>{var M;return(M=this._renderer.value)==null?void 0:M.clear()}))),this.register(E.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._charSizeService.onCharSizeChange((()=>this.handleCharSizeChanged()))),this.register(T.onDecorationRegistered((()=>this._fullRefresh()))),this.register(T.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(R.onChangeColors((()=>this._fullRefresh()))),this._registerIntersectionObserver(A.window,y),this.register(A.onWindowChange((M=>this._registerIntersectionObserver(M,y))))}_registerIntersectionObserver(b,y){if("IntersectionObserver"in b){const E=new b.IntersectionObserver((N=>this._handleIntersectionChange(N[N.length-1])),{threshold:0});E.observe(y),this._observerDisposable.value=(0,w.toDisposable)((()=>E.disconnect()))}}_handleIntersectionChange(b){this._isPaused=b.isIntersecting===void 0?b.intersectionRatio===0:!b.isIntersecting,this._isPaused||this._charSizeService.hasValidSize||this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(b,y,E=!1){this._isPaused?this._needsFullRefresh=!0:(E||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(b,y,this._rowCount))}_renderRows(b,y){this._renderer.value&&(b=Math.min(b,this._rowCount-1),y=Math.min(y,this._rowCount-1),this._renderer.value.renderRows(b,y),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:b,end:y}),this._onRender.fire({start:b,end:y}),this._isNextRenderRedrawOnly=!0)}resize(b,y){this._rowCount=y,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(b){this._renderer.value=b,this._renderer.value&&(this._renderer.value.onRequestRedraw((y=>this.refreshRows(y.start,y.end,!0))),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(b){return this._renderDebouncer.addRefreshCallback(b)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var b,y;this._renderer.value&&((y=(b=this._renderer.value).clearTextureAtlas)==null||y.call(b),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(b,y){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set((()=>{var E;return(E=this._renderer.value)==null?void 0:E.handleResize(b,y)})):this._renderer.value.handleResize(b,y),this._fullRefresh())}handleCharSizeChanged(){var b;(b=this._renderer.value)==null||b.handleCharSizeChanged()}handleBlur(){var b;(b=this._renderer.value)==null||b.handleBlur()}handleFocus(){var b;(b=this._renderer.value)==null||b.handleFocus()}handleSelectionChanged(b,y,E){var N;this._selectionState.start=b,this._selectionState.end=y,this._selectionState.columnSelectMode=E,(N=this._renderer.value)==null||N.handleSelectionChanged(b,y,E)}handleCursorMove(){var b;(b=this._renderer.value)==null||b.handleCursorMove()}clear(){var b;(b=this._renderer.value)==null||b.clear()}};c.RenderService=S=f([m(2,v.IOptionsService),m(3,_.ICharSizeService),m(4,v.IDecorationService),m(5,v.IBufferService),m(6,_.ICoreBrowserService),m(7,_.IThemeService)],S)},9312:function(u,c,d){var f=this&&this.__decorate||function(A,R,M,G){var W,O=arguments.length,U=O<3?R:G===null?G=Object.getOwnPropertyDescriptor(R,M):G;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")U=Reflect.decorate(A,R,M,G);else for(var V=A.length-1;V>=0;V--)(W=A[V])&&(U=(O<3?W(U):O>3?W(R,M,U):W(R,M))||U);return O>3&&U&&Object.defineProperty(R,M,U),U},m=this&&this.__param||function(A,R){return function(M,G){R(M,G,A)}};Object.defineProperty(c,"__esModule",{value:!0}),c.SelectionService=void 0;const p=d(9806),_=d(9504),x=d(456),w=d(4725),C=d(8460),v=d(844),S=d(6114),b=d(4841),y=d(511),E=d(2585),N=" ",T=new RegExp(N,"g");let L=c.SelectionService=class extends v.Disposable{constructor(A,R,M,G,W,O,U,V,z){super(),this._element=A,this._screenElement=R,this._linkifier=M,this._bufferService=G,this._coreService=W,this._mouseService=O,this._optionsService=U,this._renderService=V,this._coreBrowserService=z,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new y.CellData,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this.register(new C.EventEmitter),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this.register(new C.EventEmitter),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this.register(new C.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this.register(new C.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=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,v.toDisposable)((()=>{this._removeMouseDownListeners()})))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){const A=this._model.finalSelectionStart,R=this._model.finalSelectionEnd;return!(!A||!R||A[0]===R[0]&&A[1]===R[1])}get selectionText(){const A=this._model.finalSelectionStart,R=this._model.finalSelectionEnd;if(!A||!R)return"";const M=this._bufferService.buffer,G=[];if(this._activeSelectionMode===3){if(A[0]===R[0])return"";const W=A[0]<R[0]?A[0]:R[0],O=A[0]<R[0]?R[0]:A[0];for(let U=A[1];U<=R[1];U++){const V=M.translateBufferLineToString(U,!0,W,O);G.push(V)}}else{const W=A[1]===R[1]?R[0]:void 0;G.push(M.translateBufferLineToString(A[1],!0,A[0],W));for(let O=A[1]+1;O<=R[1]-1;O++){const U=M.lines.get(O),V=M.translateBufferLineToString(O,!0);U!=null&&U.isWrapped?G[G.length-1]+=V:G.push(V)}if(A[1]!==R[1]){const O=M.lines.get(R[1]),U=M.translateBufferLineToString(R[1],!0,0,R[0]);O&&O.isWrapped?G[G.length-1]+=U:G.push(U)}}return G.map((W=>W.replace(T," "))).join(S.isWindows?`\r
65
+ `:`
66
+ `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(A){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._refresh()))),S.isLinux&&A&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(A){const R=this._getMouseBufferCoords(A),M=this._model.finalSelectionStart,G=this._model.finalSelectionEnd;return!!(M&&G&&R)&&this._areCoordsInSelection(R,M,G)}isCellInSelection(A,R){const M=this._model.finalSelectionStart,G=this._model.finalSelectionEnd;return!(!M||!G)&&this._areCoordsInSelection([A,R],M,G)}_areCoordsInSelection(A,R,M){return A[1]>R[1]&&A[1]<M[1]||R[1]===M[1]&&A[1]===R[1]&&A[0]>=R[0]&&A[0]<M[0]||R[1]<M[1]&&A[1]===M[1]&&A[0]<M[0]||R[1]<M[1]&&A[1]===R[1]&&A[0]>=R[0]}_selectWordAtCursor(A,R){var W,O;const M=(O=(W=this._linkifier.currentLink)==null?void 0:W.link)==null?void 0:O.range;if(M)return this._model.selectionStart=[M.start.x-1,M.start.y-1],this._model.selectionStartLength=(0,b.getRangeLength)(M,this._bufferService.cols),this._model.selectionEnd=void 0,!0;const G=this._getMouseBufferCoords(A);return!!G&&(this._selectWordAt(G,R),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(A,R){this._model.clearSelection(),A=Math.max(A,0),R=Math.min(R,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,A],this._model.selectionEnd=[this._bufferService.cols,R],this.refresh(),this._onSelectionChange.fire()}_handleTrim(A){this._model.handleTrim(A)&&this.refresh()}_getMouseBufferCoords(A){const R=this._mouseService.getCoords(A,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(R)return R[0]--,R[1]--,R[1]+=this._bufferService.buffer.ydisp,R}_getMouseEventScrollAmount(A){let R=(0,p.getCoordsRelativeToElement)(this._coreBrowserService.window,A,this._screenElement)[1];const M=this._renderService.dimensions.css.canvas.height;return R>=0&&R<=M?0:(R>M&&(R-=M),R=Math.min(Math.max(R,-50),50),R/=50,R/Math.abs(R)+Math.round(14*R))}shouldForceSelection(A){return S.isMac?A.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:A.shiftKey}handleMouseDown(A){if(this._mouseDownTimeStamp=A.timeStamp,(A.button!==2||!this.hasSelection)&&A.button===0){if(!this._enabled){if(!this.shouldForceSelection(A))return;A.stopPropagation()}A.preventDefault(),this._dragScrollAmount=0,this._enabled&&A.shiftKey?this._handleIncrementalClick(A):A.detail===1?this._handleSingleClick(A):A.detail===2?this._handleDoubleClick(A):A.detail===3&&this._handleTripleClick(A),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval((()=>this._dragScroll()),50)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(A){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(A))}_handleSingleClick(A){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(A)?3:0,this._model.selectionStart=this._getMouseBufferCoords(A),!this._model.selectionStart)return;this._model.selectionEnd=void 0;const R=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);R&&R.length!==this._model.selectionStart[0]&&R.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(A){this._selectWordAtCursor(A,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(A){const R=this._getMouseBufferCoords(A);R&&(this._activeSelectionMode=2,this._selectLineAt(R[1]))}shouldColumnSelect(A){return A.altKey&&!(S.isMac&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(A){if(A.stopImmediatePropagation(),!this._model.selectionStart)return;const R=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(A),!this._model.selectionEnd)return void this.refresh(!0);this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(A),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));const M=this._bufferService.buffer;if(this._model.selectionEnd[1]<M.lines.length){const G=M.lines.get(this._model.selectionEnd[1]);G&&G.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}R&&R[0]===this._model.selectionEnd[0]&&R[1]===this._model.selectionEnd[1]||this.refresh(!0)}_dragScroll(){if(this._model.selectionEnd&&this._model.selectionStart&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});const A=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(A.ydisp+this._bufferService.rows,A.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=A.ydisp),this.refresh()}}_handleMouseUp(A){const R=A.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&R<500&&A.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){const M=this._mouseService.getCoords(A,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(M&&M[0]!==void 0&&M[1]!==void 0){const G=(0,_.moveToCellSequence)(M[0]-1,M[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(G,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){const A=this._model.finalSelectionStart,R=this._model.finalSelectionEnd,M=!(!A||!R||A[0]===R[0]&&A[1]===R[1]);M?A&&R&&(this._oldSelectionStart&&this._oldSelectionEnd&&A[0]===this._oldSelectionStart[0]&&A[1]===this._oldSelectionStart[1]&&R[0]===this._oldSelectionEnd[0]&&R[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(A,R,M)):this._oldHasSelection&&this._fireOnSelectionChange(A,R,M)}_fireOnSelectionChange(A,R,M){this._oldSelectionStart=A,this._oldSelectionEnd=R,this._oldHasSelection=M,this._onSelectionChange.fire()}_handleBufferActivate(A){this.clearSelection(),this._trimListener.dispose(),this._trimListener=A.activeBuffer.lines.onTrim((R=>this._handleTrim(R)))}_convertViewportColToCharacterIndex(A,R){let M=R;for(let G=0;R>=G;G++){const W=A.loadCell(G,this._workCell).getChars().length;this._workCell.getWidth()===0?M--:W>1&&R!==G&&(M+=W-1)}return M}setSelection(A,R,M){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[A,R],this._model.selectionStartLength=M,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(A){this._isClickInSelection(A)||(this._selectWordAtCursor(A,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(A,R,M=!0,G=!0){if(A[0]>=this._bufferService.cols)return;const W=this._bufferService.buffer,O=W.lines.get(A[1]);if(!O)return;const U=W.translateBufferLineToString(A[1],!1);let V=this._convertViewportColToCharacterIndex(O,A[0]),z=V;const X=A[0]-V;let te=0,H=0,I=0,$=0;if(U.charAt(V)===" "){for(;V>0&&U.charAt(V-1)===" ";)V--;for(;z<U.length&&U.charAt(z+1)===" ";)z++}else{let ee=A[0],J=A[0];O.getWidth(ee)===0&&(te++,ee--),O.getWidth(J)===2&&(H++,J++);const re=O.getString(J).length;for(re>1&&($+=re-1,z+=re-1);ee>0&&V>0&&!this._isCharWordSeparator(O.loadCell(ee-1,this._workCell));){O.loadCell(ee-1,this._workCell);const Y=this._workCell.getChars().length;this._workCell.getWidth()===0?(te++,ee--):Y>1&&(I+=Y-1,V-=Y-1),V--,ee--}for(;J<O.length&&z+1<U.length&&!this._isCharWordSeparator(O.loadCell(J+1,this._workCell));){O.loadCell(J+1,this._workCell);const Y=this._workCell.getChars().length;this._workCell.getWidth()===2?(H++,J++):Y>1&&($+=Y-1,z+=Y-1),z++,J++}}z++;let F=V+X-te+I,P=Math.min(this._bufferService.cols,z-V+te+H-I-$);if(R||U.slice(V,z).trim()!==""){if(M&&F===0&&O.getCodePoint(0)!==32){const ee=W.lines.get(A[1]-1);if(ee&&O.isWrapped&&ee.getCodePoint(this._bufferService.cols-1)!==32){const J=this._getWordAt([this._bufferService.cols-1,A[1]-1],!1,!0,!1);if(J){const re=this._bufferService.cols-J.start;F-=re,P+=re}}}if(G&&F+P===this._bufferService.cols&&O.getCodePoint(this._bufferService.cols-1)!==32){const ee=W.lines.get(A[1]+1);if(ee!=null&&ee.isWrapped&&ee.getCodePoint(0)!==32){const J=this._getWordAt([0,A[1]+1],!1,!1,!0);J&&(P+=J.length)}}return{start:F,length:P}}}_selectWordAt(A,R){const M=this._getWordAt(A,R);if(M){for(;M.start<0;)M.start+=this._bufferService.cols,A[1]--;this._model.selectionStart=[M.start,A[1]],this._model.selectionStartLength=M.length}}_selectToWordAt(A){const R=this._getWordAt(A,!0);if(R){let M=A[1];for(;R.start<0;)R.start+=this._bufferService.cols,M--;if(!this._model.areSelectionValuesReversed())for(;R.start+R.length>this._bufferService.cols;)R.length-=this._bufferService.cols,M++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?R.start:R.start+R.length,M]}}_isCharWordSeparator(A){return A.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(A.getChars())>=0}_selectLineAt(A){const R=this._bufferService.buffer.getWrappedRangeForLine(A),M={start:{x:0,y:R.first},end:{x:this._bufferService.cols-1,y:R.last}};this._model.selectionStart=[0,R.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=(0,b.getRangeLength)(M,this._bufferService.cols)}};c.SelectionService=L=f([m(3,E.IBufferService),m(4,E.ICoreService),m(5,w.IMouseService),m(6,E.IOptionsService),m(7,w.IRenderService),m(8,w.ICoreBrowserService)],L)},4725:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.ILinkProviderService=c.IThemeService=c.ICharacterJoinerService=c.ISelectionService=c.IRenderService=c.IMouseService=c.ICoreBrowserService=c.ICharSizeService=void 0;const f=d(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,d){var f=this&&this.__decorate||function(L,A,R,M){var G,W=arguments.length,O=W<3?A:M===null?M=Object.getOwnPropertyDescriptor(A,R):M;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")O=Reflect.decorate(L,A,R,M);else for(var U=L.length-1;U>=0;U--)(G=L[U])&&(O=(W<3?G(O):W>3?G(A,R,O):G(A,R))||O);return W>3&&O&&Object.defineProperty(A,R,O),O},m=this&&this.__param||function(L,A){return function(R,M){A(R,M,L)}};Object.defineProperty(c,"__esModule",{value:!0}),c.ThemeService=c.DEFAULT_ANSI_COLORS=void 0;const p=d(7239),_=d(8055),x=d(8460),w=d(844),C=d(2585),v=_.css.toColor("#ffffff"),S=_.css.toColor("#000000"),b=_.css.toColor("#ffffff"),y=_.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 R=0;R<216;R++){const M=A[R/36%6|0],G=A[R/6%6|0],W=A[R%6];L.push({css:_.channels.toCss(M,G,W),rgba:_.channels.toRgba(M,G,W)})}for(let R=0;R<24;R++){const M=8+10*R;L.push({css:_.channels.toCss(M,M,M),rgba:_.channels.toRgba(M,M,M)})}return L})());let N=c.ThemeService=class extends w.Disposable{get colors(){return this._colors}constructor(L){super(),this._optionsService=L,this._contrastCache=new p.ColorContrastCache,this._halfContrastCache=new p.ColorContrastCache,this._onChangeColors=this.register(new x.EventEmitter),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:v,background:S,cursor:b,cursorAccent:y,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=T(L.foreground,v),A.background=T(L.background,S),A.cursor=T(L.cursor,b),A.cursorAccent=T(L.cursorAccent,y),A.selectionBackgroundTransparent=T(L.selectionBackground,E),A.selectionBackgroundOpaque=_.color.blend(A.background,A.selectionBackgroundTransparent),A.selectionInactiveBackgroundTransparent=T(L.selectionInactiveBackground,A.selectionBackgroundTransparent),A.selectionInactiveBackgroundOpaque=_.color.blend(A.background,A.selectionInactiveBackgroundTransparent),A.selectionForeground=L.selectionForeground?T(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]=T(L.black,c.DEFAULT_ANSI_COLORS[0]),A.ansi[1]=T(L.red,c.DEFAULT_ANSI_COLORS[1]),A.ansi[2]=T(L.green,c.DEFAULT_ANSI_COLORS[2]),A.ansi[3]=T(L.yellow,c.DEFAULT_ANSI_COLORS[3]),A.ansi[4]=T(L.blue,c.DEFAULT_ANSI_COLORS[4]),A.ansi[5]=T(L.magenta,c.DEFAULT_ANSI_COLORS[5]),A.ansi[6]=T(L.cyan,c.DEFAULT_ANSI_COLORS[6]),A.ansi[7]=T(L.white,c.DEFAULT_ANSI_COLORS[7]),A.ansi[8]=T(L.brightBlack,c.DEFAULT_ANSI_COLORS[8]),A.ansi[9]=T(L.brightRed,c.DEFAULT_ANSI_COLORS[9]),A.ansi[10]=T(L.brightGreen,c.DEFAULT_ANSI_COLORS[10]),A.ansi[11]=T(L.brightYellow,c.DEFAULT_ANSI_COLORS[11]),A.ansi[12]=T(L.brightBlue,c.DEFAULT_ANSI_COLORS[12]),A.ansi[13]=T(L.brightMagenta,c.DEFAULT_ANSI_COLORS[13]),A.ansi[14]=T(L.brightCyan,c.DEFAULT_ANSI_COLORS[14]),A.ansi[15]=T(L.brightWhite,c.DEFAULT_ANSI_COLORS[15]),L.extendedAnsi){const R=Math.min(A.ansi.length-16,L.extendedAnsi.length);for(let M=0;M<R;M++)A.ansi[M+16]=T(L.extendedAnsi[M],c.DEFAULT_ANSI_COLORS[M+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(L){this._restoreColor(L),this._onChangeColors.fire(this.colors)}_restoreColor(L){if(L!==void 0)switch(L){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[L]=this._restoreColors.ansi[L]}else for(let A=0;A<this._restoreColors.ansi.length;++A)this._colors.ansi[A]=this._restoreColors.ansi[A]}modifyColors(L){L(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};function T(L,A){if(L!==void 0)try{return _.css.toColor(L)}catch{}return A}c.ThemeService=N=f([m(0,C.IOptionsService)],N)},6349:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.CircularList=void 0;const f=d(8460),m=d(844);class p extends m.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 C=0;C<Math.min(x,this.length);C++)w[C]=this._array[this._getCyclicIndex(C)];this._array=w,this._maxLength=x,this._startIndex=0}get length(){return this._length}set length(x){if(x>this._length)for(let w=this._length;w<x;w++)this._array[w]=void 0;this._length=x}get(x){return this._array[this._getCyclicIndex(x)]}set(x,w){this._array[this._getCyclicIndex(x)]=w}push(x){this._array[this._getCyclicIndex(this._length)]=x,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(x,w,...C){if(w){for(let v=x;v<this._length-w;v++)this._array[this._getCyclicIndex(v)]=this._array[this._getCyclicIndex(v+w)];this._length-=w,this.onDeleteEmitter.fire({index:x,amount:w})}for(let v=this._length-1;v>=x;v--)this._array[this._getCyclicIndex(v+C.length)]=this._array[this._getCyclicIndex(v)];for(let v=0;v<C.length;v++)this._array[this._getCyclicIndex(x+v)]=C[v];if(C.length&&this.onInsertEmitter.fire({index:x,amount:C.length}),this._length+C.length>this._maxLength){const v=this._length+C.length-this._maxLength;this._startIndex+=v,this._length=this._maxLength,this.onTrimEmitter.fire(v)}else this._length+=C.length}trimStart(x){x>this._length&&(x=this._length),this._startIndex+=x,this._length-=x,this.onTrimEmitter.fire(x)}shiftElements(x,w,C){if(!(w<=0)){if(x<0||x>=this._length)throw new Error("start argument out of range");if(x+C<0)throw new Error("Cannot shift elements in list beyond index 0");if(C>0){for(let S=w-1;S>=0;S--)this.set(x+S+C,this.get(x+S));const v=x+w+C-this._length;if(v>0)for(this._length+=v;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let v=0;v<w;v++)this.set(x+v+C,this.get(x+v))}}_getCyclicIndex(x){return(this._startIndex+x)%this._maxLength}}c.CircularList=p},1439:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.clone=void 0,c.clone=function d(f,m=5){if(typeof f!="object")return f;const p=Array.isArray(f)?[]:{};for(const _ in f)p[_]=m<=1?f[_]:f[_]&&d(f[_],m-1);return p}},8055:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.contrastRatio=c.toPaddedHex=c.rgba=c.rgb=c.css=c.color=c.channels=c.NULL_COLOR=void 0;let d=0,f=0,m=0,p=0;var _,x,w,C,v;function S(y){const E=y.toString(16);return E.length<2?"0"+E:E}function b(y,E){return y<E?(E+.05)/(y+.05):(y+.05)/(E+.05)}c.NULL_COLOR={css:"#00000000",rgba:0},(function(y){y.toCss=function(E,N,T,L){return L!==void 0?`#${S(E)}${S(N)}${S(T)}${S(L)}`:`#${S(E)}${S(N)}${S(T)}`},y.toRgba=function(E,N,T,L=255){return(E<<24|N<<16|T<<8|L)>>>0},y.toColor=function(E,N,T,L){return{css:y.toCss(E,N,T,L),rgba:y.toRgba(E,N,T,L)}}})(_||(c.channels=_={})),(function(y){function E(N,T){return p=Math.round(255*T),[d,f,m]=v.toChannels(N.rgba),{css:_.toCss(d,f,m,p),rgba:_.toRgba(d,f,m,p)}}y.blend=function(N,T){if(p=(255&T.rgba)/255,p===1)return{css:T.css,rgba:T.rgba};const L=T.rgba>>24&255,A=T.rgba>>16&255,R=T.rgba>>8&255,M=N.rgba>>24&255,G=N.rgba>>16&255,W=N.rgba>>8&255;return d=M+Math.round((L-M)*p),f=G+Math.round((A-G)*p),m=W+Math.round((R-W)*p),{css:_.toCss(d,f,m),rgba:_.toRgba(d,f,m)}},y.isOpaque=function(N){return(255&N.rgba)==255},y.ensureContrastRatio=function(N,T,L){const A=v.ensureContrastRatio(N.rgba,T.rgba,L);if(A)return _.toColor(A>>24&255,A>>16&255,A>>8&255)},y.opaque=function(N){const T=(255|N.rgba)>>>0;return[d,f,m]=v.toChannels(T),{css:_.toCss(d,f,m),rgba:T}},y.opacity=E,y.multiplyOpacity=function(N,T){return p=255&N.rgba,E(N,p*T/255)},y.toColorRGB=function(N){return[N.rgba>>24&255,N.rgba>>16&255,N.rgba>>8&255]}})(x||(c.color=x={})),(function(y){let E,N;try{const T=document.createElement("canvas");T.width=1,T.height=1;const L=T.getContext("2d",{willReadFrequently:!0});L&&(E=L,E.globalCompositeOperation="copy",N=E.createLinearGradient(0,0,1,1))}catch{}y.toColor=function(T){if(T.match(/#[\da-f]{3,8}/i))switch(T.length){case 4:return d=parseInt(T.slice(1,2).repeat(2),16),f=parseInt(T.slice(2,3).repeat(2),16),m=parseInt(T.slice(3,4).repeat(2),16),_.toColor(d,f,m);case 5:return d=parseInt(T.slice(1,2).repeat(2),16),f=parseInt(T.slice(2,3).repeat(2),16),m=parseInt(T.slice(3,4).repeat(2),16),p=parseInt(T.slice(4,5).repeat(2),16),_.toColor(d,f,m,p);case 7:return{css:T,rgba:(parseInt(T.slice(1),16)<<8|255)>>>0};case 9:return{css:T,rgba:parseInt(T.slice(1),16)>>>0}}const L=T.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(L)return d=parseInt(L[1]),f=parseInt(L[2]),m=parseInt(L[3]),p=Math.round(255*(L[5]===void 0?1:parseFloat(L[5]))),_.toColor(d,f,m,p);if(!E||!N)throw new Error("css.toColor: Unsupported css format");if(E.fillStyle=N,E.fillStyle=T,typeof E.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(E.fillRect(0,0,1,1),[d,f,m,p]=E.getImageData(0,0,1,1).data,p!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:_.toRgba(d,f,m,p),css:T}}})(w||(c.css=w={})),(function(y){function E(N,T,L){const A=N/255,R=T/255,M=L/255;return .2126*(A<=.03928?A/12.92:Math.pow((A+.055)/1.055,2.4))+.7152*(R<=.03928?R/12.92:Math.pow((R+.055)/1.055,2.4))+.0722*(M<=.03928?M/12.92:Math.pow((M+.055)/1.055,2.4))}y.relativeLuminance=function(N){return E(N>>16&255,N>>8&255,255&N)},y.relativeLuminance2=E})(C||(c.rgb=C={})),(function(y){function E(T,L,A){const R=T>>24&255,M=T>>16&255,G=T>>8&255;let W=L>>24&255,O=L>>16&255,U=L>>8&255,V=b(C.relativeLuminance2(W,O,U),C.relativeLuminance2(R,M,G));for(;V<A&&(W>0||O>0||U>0);)W-=Math.max(0,Math.ceil(.1*W)),O-=Math.max(0,Math.ceil(.1*O)),U-=Math.max(0,Math.ceil(.1*U)),V=b(C.relativeLuminance2(W,O,U),C.relativeLuminance2(R,M,G));return(W<<24|O<<16|U<<8|255)>>>0}function N(T,L,A){const R=T>>24&255,M=T>>16&255,G=T>>8&255;let W=L>>24&255,O=L>>16&255,U=L>>8&255,V=b(C.relativeLuminance2(W,O,U),C.relativeLuminance2(R,M,G));for(;V<A&&(W<255||O<255||U<255);)W=Math.min(255,W+Math.ceil(.1*(255-W))),O=Math.min(255,O+Math.ceil(.1*(255-O))),U=Math.min(255,U+Math.ceil(.1*(255-U))),V=b(C.relativeLuminance2(W,O,U),C.relativeLuminance2(R,M,G));return(W<<24|O<<16|U<<8|255)>>>0}y.blend=function(T,L){if(p=(255&L)/255,p===1)return L;const A=L>>24&255,R=L>>16&255,M=L>>8&255,G=T>>24&255,W=T>>16&255,O=T>>8&255;return d=G+Math.round((A-G)*p),f=W+Math.round((R-W)*p),m=O+Math.round((M-O)*p),_.toRgba(d,f,m)},y.ensureContrastRatio=function(T,L,A){const R=C.relativeLuminance(T>>8),M=C.relativeLuminance(L>>8);if(b(R,M)<A){if(M<R){const O=E(T,L,A),U=b(R,C.relativeLuminance(O>>8));if(U<A){const V=N(T,L,A);return U>b(R,C.relativeLuminance(V>>8))?O:V}return O}const G=N(T,L,A),W=b(R,C.relativeLuminance(G>>8));if(W<A){const O=E(T,L,A);return W>b(R,C.relativeLuminance(O>>8))?G:O}return G}},y.reduceLuminance=E,y.increaseLuminance=N,y.toChannels=function(T){return[T>>24&255,T>>16&255,T>>8&255,255&T]}})(v||(c.rgba=v={})),c.toPaddedHex=S,c.contrastRatio=b},8969:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.CoreTerminal=void 0;const f=d(844),m=d(2585),p=d(4348),_=d(7866),x=d(744),w=d(7302),C=d(6975),v=d(8460),S=d(1753),b=d(1480),y=d(7994),E=d(9282),N=d(5435),T=d(5981),L=d(2660);let A=!1;class R extends f.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new v.EventEmitter),this._onScroll.event((G=>{var W;(W=this._onScrollApi)==null||W.fire(G.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(G){for(const W in G)this.optionsService.options[W]=G[W]}constructor(G){super(),this._windowsWrappingHeuristics=this.register(new f.MutableDisposable),this._onBinary=this.register(new v.EventEmitter),this.onBinary=this._onBinary.event,this._onData=this.register(new v.EventEmitter),this.onData=this._onData.event,this._onLineFeed=this.register(new v.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onResize=this.register(new v.EventEmitter),this.onResize=this._onResize.event,this._onWriteParsed=this.register(new v.EventEmitter),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this.register(new v.EventEmitter),this._instantiationService=new p.InstantiationService,this.optionsService=this.register(new w.OptionsService(G)),this._instantiationService.setService(m.IOptionsService,this.optionsService),this._bufferService=this.register(this._instantiationService.createInstance(x.BufferService)),this._instantiationService.setService(m.IBufferService,this._bufferService),this._logService=this.register(this._instantiationService.createInstance(_.LogService)),this._instantiationService.setService(m.ILogService,this._logService),this.coreService=this.register(this._instantiationService.createInstance(C.CoreService)),this._instantiationService.setService(m.ICoreService,this.coreService),this.coreMouseService=this.register(this._instantiationService.createInstance(S.CoreMouseService)),this._instantiationService.setService(m.ICoreMouseService,this.coreMouseService),this.unicodeService=this.register(this._instantiationService.createInstance(b.UnicodeService)),this._instantiationService.setService(m.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(y.CharsetService),this._instantiationService.setService(m.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(L.OscLinkService),this._instantiationService.setService(m.IOscLinkService,this._oscLinkService),this._inputHandler=this.register(new N.InputHandler(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this.register((0,v.forwardEvent)(this._inputHandler.onLineFeed,this._onLineFeed)),this.register(this._inputHandler),this.register((0,v.forwardEvent)(this._bufferService.onResize,this._onResize)),this.register((0,v.forwardEvent)(this.coreService.onData,this._onData)),this.register((0,v.forwardEvent)(this.coreService.onBinary,this._onBinary)),this.register(this.coreService.onRequestScrollToBottom((()=>this.scrollToBottom()))),this.register(this.coreService.onUserInput((()=>this._writeBuffer.handleUserInput()))),this.register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],(()=>this._handleWindowsPtyOptionChange()))),this.register(this._bufferService.onScroll((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 T.WriteBuffer(((W,O)=>this._inputHandler.parse(W,O)))),this.register((0,v.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(G,W){this._writeBuffer.write(G,W)}writeSync(G,W){this._logService.logLevel<=m.LogLevelEnum.WARN&&!A&&(this._logService.warn("writeSync is unreliable and will be removed soon."),A=!0),this._writeBuffer.writeSync(G,W)}input(G,W=!0){this.coreService.triggerDataEvent(G,W)}resize(G,W){isNaN(G)||isNaN(W)||(G=Math.max(G,x.MINIMUM_COLS),W=Math.max(W,x.MINIMUM_ROWS),this._bufferService.resize(G,W))}scroll(G,W=!1){this._bufferService.scroll(G,W)}scrollLines(G,W,O){this._bufferService.scrollLines(G,W,O)}scrollPages(G){this.scrollLines(G*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(G){const W=G-this._bufferService.buffer.ydisp;W!==0&&this.scrollLines(W)}registerEscHandler(G,W){return this._inputHandler.registerEscHandler(G,W)}registerDcsHandler(G,W){return this._inputHandler.registerDcsHandler(G,W)}registerCsiHandler(G,W){return this._inputHandler.registerCsiHandler(G,W)}registerOscHandler(G,W){return this._inputHandler.registerOscHandler(G,W)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let G=!1;const W=this.optionsService.rawOptions.windowsPty;W&&W.buildNumber!==void 0&&W.buildNumber!==void 0?G=W.backend==="conpty"&&W.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(G=!0),G?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){const G=[];G.push(this.onLineFeed(E.updateWindowsModeWrappedState.bind(null,this._bufferService))),G.push(this.registerCsiHandler({final:"H"},(()=>((0,E.updateWindowsModeWrappedState)(this._bufferService),!1)))),this._windowsWrappingHeuristics.value=(0,f.toDisposable)((()=>{for(const W of G)W.dispose()}))}}}c.CoreTerminal=R},8460:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.runAndSubscribe=c.forwardEvent=c.EventEmitter=void 0,c.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=d=>(this._listeners.push(d),{dispose:()=>{if(!this._disposed){for(let f=0;f<this._listeners.length;f++)if(this._listeners[f]===d)return void this._listeners.splice(f,1)}}})),this._event}fire(d,f){const m=[];for(let p=0;p<this._listeners.length;p++)m.push(this._listeners[p]);for(let p=0;p<m.length;p++)m[p].call(void 0,d,f)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},c.forwardEvent=function(d,f){return d((m=>f.fire(m)))},c.runAndSubscribe=function(d,f){return f(void 0),d((m=>f(m)))}},5435:function(u,c,d){var f=this&&this.__decorate||function(te,H,I,$){var F,P=arguments.length,ee=P<3?H:$===null?$=Object.getOwnPropertyDescriptor(H,I):$;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")ee=Reflect.decorate(te,H,I,$);else for(var J=te.length-1;J>=0;J--)(F=te[J])&&(ee=(P<3?F(ee):P>3?F(H,I,ee):F(H,I))||ee);return P>3&&ee&&Object.defineProperty(H,I,ee),ee},m=this&&this.__param||function(te,H){return function(I,$){H(I,$,te)}};Object.defineProperty(c,"__esModule",{value:!0}),c.InputHandler=c.WindowsOptionsReportType=void 0;const p=d(2584),_=d(7116),x=d(2015),w=d(844),C=d(482),v=d(8437),S=d(8460),b=d(643),y=d(511),E=d(3734),N=d(2585),T=d(1480),L=d(6242),A=d(6351),R=d(5941),M={"(":0,")":1,"*":2,"+":3,"-":1,".":2},G=131072;function W(te,H){if(te>24)return H.setWinLines||!1;switch(te){case 1:return!!H.restoreWin;case 2:return!!H.minimizeWin;case 3:return!!H.setWinPosition;case 4:return!!H.setWinSizePixels;case 5:return!!H.raiseWin;case 6:return!!H.lowerWin;case 7:return!!H.refreshWin;case 8:return!!H.setWinSizeChars;case 9:return!!H.maximizeWin;case 10:return!!H.fullscreenWin;case 11:return!!H.getWinState;case 13:return!!H.getWinPosition;case 14:return!!H.getWinSizePixels;case 15:return!!H.getScreenSizePixels;case 16:return!!H.getCellSizePixels;case 18:return!!H.getWinSizeChars;case 19:return!!H.getScreenSizeChars;case 20:return!!H.getIconTitle;case 21:return!!H.getWinTitle;case 22:return!!H.pushTitle;case 23:return!!H.popTitle;case 24:return!!H.setWinLines}return!1}var O;(function(te){te[te.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",te[te.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(O||(c.WindowsOptionsReportType=O={}));let U=0;class V extends w.Disposable{getAttrData(){return this._curAttrData}constructor(H,I,$,F,P,ee,J,re,Y=new x.EscapeSequenceParser){super(),this._bufferService=H,this._charsetService=I,this._coreService=$,this._logService=F,this._optionsService=P,this._oscLinkService=ee,this._coreMouseService=J,this._unicodeService=re,this._parser=Y,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new C.StringToUtf32,this._utf8Decoder=new C.Utf8ToUtf32,this._workCell=new y.CellData,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=v.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=v.DEFAULT_ATTR_DATA.clone(),this._onRequestBell=this.register(new S.EventEmitter),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this.register(new S.EventEmitter),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this.register(new S.EventEmitter),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this.register(new S.EventEmitter),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this.register(new S.EventEmitter),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this.register(new S.EventEmitter),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this.register(new S.EventEmitter),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this.register(new S.EventEmitter),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this.register(new S.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this.register(new S.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onScroll=this.register(new S.EventEmitter),this.onScroll=this._onScroll.event,this._onTitleChange=this.register(new S.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onColor=this.register(new S.EventEmitter),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this.register(this._parser),this._dirtyRowTracker=new z(this._bufferService),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((q=>this._activeBuffer=q.activeBuffer))),this._parser.setCsiHandlerFallback(((q,Z)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(q),params:Z.toArray()})})),this._parser.setEscHandlerFallback((q=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(q)})})),this._parser.setExecuteHandlerFallback((q=>{this._logService.debug("Unknown EXECUTE code: ",{code:q})})),this._parser.setOscHandlerFallback(((q,Z,ae)=>{this._logService.debug("Unknown OSC code: ",{identifier:q,action:Z,data:ae})})),this._parser.setDcsHandlerFallback(((q,Z,ae)=>{Z==="HOOK"&&(ae=ae.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(q),action:Z,payload:ae})})),this._parser.setPrintHandler(((q,Z,ae)=>this.print(q,Z,ae))),this._parser.registerCsiHandler({final:"@"},(q=>this.insertChars(q))),this._parser.registerCsiHandler({intermediates:" ",final:"@"},(q=>this.scrollLeft(q))),this._parser.registerCsiHandler({final:"A"},(q=>this.cursorUp(q))),this._parser.registerCsiHandler({intermediates:" ",final:"A"},(q=>this.scrollRight(q))),this._parser.registerCsiHandler({final:"B"},(q=>this.cursorDown(q))),this._parser.registerCsiHandler({final:"C"},(q=>this.cursorForward(q))),this._parser.registerCsiHandler({final:"D"},(q=>this.cursorBackward(q))),this._parser.registerCsiHandler({final:"E"},(q=>this.cursorNextLine(q))),this._parser.registerCsiHandler({final:"F"},(q=>this.cursorPrecedingLine(q))),this._parser.registerCsiHandler({final:"G"},(q=>this.cursorCharAbsolute(q))),this._parser.registerCsiHandler({final:"H"},(q=>this.cursorPosition(q))),this._parser.registerCsiHandler({final:"I"},(q=>this.cursorForwardTab(q))),this._parser.registerCsiHandler({final:"J"},(q=>this.eraseInDisplay(q,!1))),this._parser.registerCsiHandler({prefix:"?",final:"J"},(q=>this.eraseInDisplay(q,!0))),this._parser.registerCsiHandler({final:"K"},(q=>this.eraseInLine(q,!1))),this._parser.registerCsiHandler({prefix:"?",final:"K"},(q=>this.eraseInLine(q,!0))),this._parser.registerCsiHandler({final:"L"},(q=>this.insertLines(q))),this._parser.registerCsiHandler({final:"M"},(q=>this.deleteLines(q))),this._parser.registerCsiHandler({final:"P"},(q=>this.deleteChars(q))),this._parser.registerCsiHandler({final:"S"},(q=>this.scrollUp(q))),this._parser.registerCsiHandler({final:"T"},(q=>this.scrollDown(q))),this._parser.registerCsiHandler({final:"X"},(q=>this.eraseChars(q))),this._parser.registerCsiHandler({final:"Z"},(q=>this.cursorBackwardTab(q))),this._parser.registerCsiHandler({final:"`"},(q=>this.charPosAbsolute(q))),this._parser.registerCsiHandler({final:"a"},(q=>this.hPositionRelative(q))),this._parser.registerCsiHandler({final:"b"},(q=>this.repeatPrecedingCharacter(q))),this._parser.registerCsiHandler({final:"c"},(q=>this.sendDeviceAttributesPrimary(q))),this._parser.registerCsiHandler({prefix:">",final:"c"},(q=>this.sendDeviceAttributesSecondary(q))),this._parser.registerCsiHandler({final:"d"},(q=>this.linePosAbsolute(q))),this._parser.registerCsiHandler({final:"e"},(q=>this.vPositionRelative(q))),this._parser.registerCsiHandler({final:"f"},(q=>this.hVPosition(q))),this._parser.registerCsiHandler({final:"g"},(q=>this.tabClear(q))),this._parser.registerCsiHandler({final:"h"},(q=>this.setMode(q))),this._parser.registerCsiHandler({prefix:"?",final:"h"},(q=>this.setModePrivate(q))),this._parser.registerCsiHandler({final:"l"},(q=>this.resetMode(q))),this._parser.registerCsiHandler({prefix:"?",final:"l"},(q=>this.resetModePrivate(q))),this._parser.registerCsiHandler({final:"m"},(q=>this.charAttributes(q))),this._parser.registerCsiHandler({final:"n"},(q=>this.deviceStatus(q))),this._parser.registerCsiHandler({prefix:"?",final:"n"},(q=>this.deviceStatusPrivate(q))),this._parser.registerCsiHandler({intermediates:"!",final:"p"},(q=>this.softReset(q))),this._parser.registerCsiHandler({intermediates:" ",final:"q"},(q=>this.setCursorStyle(q))),this._parser.registerCsiHandler({final:"r"},(q=>this.setScrollRegion(q))),this._parser.registerCsiHandler({final:"s"},(q=>this.saveCursor(q))),this._parser.registerCsiHandler({final:"t"},(q=>this.windowOptions(q))),this._parser.registerCsiHandler({final:"u"},(q=>this.restoreCursor(q))),this._parser.registerCsiHandler({intermediates:"'",final:"}"},(q=>this.insertColumns(q))),this._parser.registerCsiHandler({intermediates:"'",final:"~"},(q=>this.deleteColumns(q))),this._parser.registerCsiHandler({intermediates:'"',final:"q"},(q=>this.selectProtected(q))),this._parser.registerCsiHandler({intermediates:"$",final:"p"},(q=>this.requestMode(q,!0))),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},(q=>this.requestMode(q,!1))),this._parser.setExecuteHandler(p.C0.BEL,(()=>this.bell())),this._parser.setExecuteHandler(p.C0.LF,(()=>this.lineFeed())),this._parser.setExecuteHandler(p.C0.VT,(()=>this.lineFeed())),this._parser.setExecuteHandler(p.C0.FF,(()=>this.lineFeed())),this._parser.setExecuteHandler(p.C0.CR,(()=>this.carriageReturn())),this._parser.setExecuteHandler(p.C0.BS,(()=>this.backspace())),this._parser.setExecuteHandler(p.C0.HT,(()=>this.tab())),this._parser.setExecuteHandler(p.C0.SO,(()=>this.shiftOut())),this._parser.setExecuteHandler(p.C0.SI,(()=>this.shiftIn())),this._parser.setExecuteHandler(p.C1.IND,(()=>this.index())),this._parser.setExecuteHandler(p.C1.NEL,(()=>this.nextLine())),this._parser.setExecuteHandler(p.C1.HTS,(()=>this.tabSet())),this._parser.registerOscHandler(0,new L.OscHandler((q=>(this.setTitle(q),this.setIconName(q),!0)))),this._parser.registerOscHandler(1,new L.OscHandler((q=>this.setIconName(q)))),this._parser.registerOscHandler(2,new L.OscHandler((q=>this.setTitle(q)))),this._parser.registerOscHandler(4,new L.OscHandler((q=>this.setOrReportIndexedColor(q)))),this._parser.registerOscHandler(8,new L.OscHandler((q=>this.setHyperlink(q)))),this._parser.registerOscHandler(10,new L.OscHandler((q=>this.setOrReportFgColor(q)))),this._parser.registerOscHandler(11,new L.OscHandler((q=>this.setOrReportBgColor(q)))),this._parser.registerOscHandler(12,new L.OscHandler((q=>this.setOrReportCursorColor(q)))),this._parser.registerOscHandler(104,new L.OscHandler((q=>this.restoreIndexedColor(q)))),this._parser.registerOscHandler(110,new L.OscHandler((q=>this.restoreFgColor(q)))),this._parser.registerOscHandler(111,new L.OscHandler((q=>this.restoreBgColor(q)))),this._parser.registerOscHandler(112,new L.OscHandler((q=>this.restoreCursorColor(q)))),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 q in _.CHARSETS)this._parser.registerEscHandler({intermediates:"(",final:q},(()=>this.selectCharset("("+q))),this._parser.registerEscHandler({intermediates:")",final:q},(()=>this.selectCharset(")"+q))),this._parser.registerEscHandler({intermediates:"*",final:q},(()=>this.selectCharset("*"+q))),this._parser.registerEscHandler({intermediates:"+",final:q},(()=>this.selectCharset("+"+q))),this._parser.registerEscHandler({intermediates:"-",final:q},(()=>this.selectCharset("-"+q))),this._parser.registerEscHandler({intermediates:".",final:q},(()=>this.selectCharset("."+q))),this._parser.registerEscHandler({intermediates:"/",final:q},(()=>this.selectCharset("/"+q)));this._parser.registerEscHandler({intermediates:"#",final:"8"},(()=>this.screenAlignmentPattern())),this._parser.setErrorHandler((q=>(this._logService.error("Parsing error: ",q),q))),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new A.DcsHandler(((q,Z)=>this.requestStatusString(q,Z))))}_preserveStack(H,I,$,F){this._parseStack.paused=!0,this._parseStack.cursorStartX=H,this._parseStack.cursorStartY=I,this._parseStack.decodedLength=$,this._parseStack.position=F}_logSlowResolvingAsync(H){this._logService.logLevel<=N.LogLevelEnum.WARN&&Promise.race([H,new Promise(((I,$)=>setTimeout((()=>$("#SLOW_TIMEOUT")),5e3)))]).catch((I=>{if(I!=="#SLOW_TIMEOUT")throw I;console.warn("async parser handler taking longer than 5000 ms")}))}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(H,I){let $,F=this._activeBuffer.x,P=this._activeBuffer.y,ee=0;const J=this._parseStack.paused;if(J){if($=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,I))return this._logSlowResolvingAsync($),$;F=this._parseStack.cursorStartX,P=this._parseStack.cursorStartY,this._parseStack.paused=!1,H.length>G&&(ee=this._parseStack.position+G)}if(this._logService.logLevel<=N.LogLevelEnum.DEBUG&&this._logService.debug("parsing data"+(typeof H=="string"?` "${H}"`:` "${Array.prototype.map.call(H,(q=>String.fromCharCode(q))).join("")}"`),typeof H=="string"?H.split("").map((q=>q.charCodeAt(0))):H),this._parseBuffer.length<H.length&&this._parseBuffer.length<G&&(this._parseBuffer=new Uint32Array(Math.min(H.length,G))),J||this._dirtyRowTracker.clearRange(),H.length>G)for(let q=ee;q<H.length;q+=G){const Z=q+G<H.length?q+G:H.length,ae=typeof H=="string"?this._stringDecoder.decode(H.substring(q,Z),this._parseBuffer):this._utf8Decoder.decode(H.subarray(q,Z),this._parseBuffer);if($=this._parser.parse(this._parseBuffer,ae))return this._preserveStack(F,P,ae,q),this._logSlowResolvingAsync($),$}else if(!J){const q=typeof H=="string"?this._stringDecoder.decode(H,this._parseBuffer):this._utf8Decoder.decode(H,this._parseBuffer);if($=this._parser.parse(this._parseBuffer,q))return this._preserveStack(F,P,q,0),this._logSlowResolvingAsync($),$}this._activeBuffer.x===F&&this._activeBuffer.y===P||this._onCursorMove.fire();const re=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(re,this._bufferService.rows-1))}print(H,I,$){let F,P;const ee=this._charsetService.charset,J=this._optionsService.rawOptions.screenReaderMode,re=this._bufferService.cols,Y=this._coreService.decPrivateModes.wraparound,q=this._coreService.modes.insertMode,Z=this._curAttrData;let ae=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&$-I>0&&ae.getWidth(this._activeBuffer.x-1)===2&&ae.setCellFromCodepoint(this._activeBuffer.x-1,0,1,Z);let se=this._parser.precedingJoinState;for(let oe=I;oe<$;++oe){if(F=H[oe],F<127&&ee){const Re=ee[String.fromCharCode(F)];Re&&(F=Re.charCodeAt(0))}const je=this._unicodeService.charProperties(F,se);P=T.UnicodeService.extractWidth(je);const Le=T.UnicodeService.extractShouldJoin(je),De=Le?T.UnicodeService.extractWidth(se):0;if(se=je,J&&this._onA11yChar.fire((0,C.stringFromCodePoint)(F)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+P-De>re){if(Y){const Re=ae;let Te=this._activeBuffer.x-De;for(this._activeBuffer.x=De,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),ae=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),De>0&&ae instanceof v.BufferLine&&ae.copyCellsFrom(Re,Te,0,De,!1);Te<re;)Re.setCellFromCodepoint(Te++,0,1,Z)}else if(this._activeBuffer.x=re-1,P===2)continue}if(Le&&this._activeBuffer.x){const Re=ae.getWidth(this._activeBuffer.x-1)?1:2;ae.addCodepointToCell(this._activeBuffer.x-Re,F,P);for(let Te=P-De;--Te>=0;)ae.setCellFromCodepoint(this._activeBuffer.x++,0,0,Z)}else if(q&&(ae.insertCells(this._activeBuffer.x,P-De,this._activeBuffer.getNullCell(Z)),ae.getWidth(re-1)===2&&ae.setCellFromCodepoint(re-1,b.NULL_CELL_CODE,b.NULL_CELL_WIDTH,Z)),ae.setCellFromCodepoint(this._activeBuffer.x++,F,P,Z),P>0)for(;--P;)ae.setCellFromCodepoint(this._activeBuffer.x++,0,0,Z)}this._parser.precedingJoinState=se,this._activeBuffer.x<re&&$-I>0&&ae.getWidth(this._activeBuffer.x)===0&&!ae.hasContent(this._activeBuffer.x)&&ae.setCellFromCodepoint(this._activeBuffer.x,0,1,Z),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(H,I){return H.final!=="t"||H.prefix||H.intermediates?this._parser.registerCsiHandler(H,I):this._parser.registerCsiHandler(H,($=>!W($.params[0],this._optionsService.rawOptions.windowOptions)||I($)))}registerDcsHandler(H,I){return this._parser.registerDcsHandler(H,new A.DcsHandler(I))}registerEscHandler(H,I){return this._parser.registerEscHandler(H,I)}registerOscHandler(H,I){return this._parser.registerOscHandler(H,new L.OscHandler(I))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var H;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&&((H=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&H.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;const I=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);I.hasWidth(this._activeBuffer.x)&&!I.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;const H=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-H),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(H=this._bufferService.cols-1){this._activeBuffer.x=Math.min(H,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(H,I){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=H,this._activeBuffer.y=this._activeBuffer.scrollTop+I):(this._activeBuffer.x=H,this._activeBuffer.y=I),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(H,I){this._restrictCursor(),this._setCursor(this._activeBuffer.x+H,this._activeBuffer.y+I)}cursorUp(H){const I=this._activeBuffer.y-this._activeBuffer.scrollTop;return I>=0?this._moveCursor(0,-Math.min(I,H.params[0]||1)):this._moveCursor(0,-(H.params[0]||1)),!0}cursorDown(H){const I=this._activeBuffer.scrollBottom-this._activeBuffer.y;return I>=0?this._moveCursor(0,Math.min(I,H.params[0]||1)):this._moveCursor(0,H.params[0]||1),!0}cursorForward(H){return this._moveCursor(H.params[0]||1,0),!0}cursorBackward(H){return this._moveCursor(-(H.params[0]||1),0),!0}cursorNextLine(H){return this.cursorDown(H),this._activeBuffer.x=0,!0}cursorPrecedingLine(H){return this.cursorUp(H),this._activeBuffer.x=0,!0}cursorCharAbsolute(H){return this._setCursor((H.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(H){return this._setCursor(H.length>=2?(H.params[1]||1)-1:0,(H.params[0]||1)-1),!0}charPosAbsolute(H){return this._setCursor((H.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(H){return this._moveCursor(H.params[0]||1,0),!0}linePosAbsolute(H){return this._setCursor(this._activeBuffer.x,(H.params[0]||1)-1),!0}vPositionRelative(H){return this._moveCursor(0,H.params[0]||1),!0}hVPosition(H){return this.cursorPosition(H),!0}tabClear(H){const I=H.params[0];return I===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:I===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(H){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let I=H.params[0]||1;for(;I--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(H){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let I=H.params[0]||1;for(;I--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(H){const I=H.params[0];return I===1&&(this._curAttrData.bg|=536870912),I!==2&&I!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(H,I,$,F=!1,P=!1){const ee=this._activeBuffer.lines.get(this._activeBuffer.ybase+H);ee.replaceCells(I,$,this._activeBuffer.getNullCell(this._eraseAttrData()),P),F&&(ee.isWrapped=!1)}_resetBufferLine(H,I=!1){const $=this._activeBuffer.lines.get(this._activeBuffer.ybase+H);$&&($.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),I),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+H),$.isWrapped=!1)}eraseInDisplay(H,I=!1){let $;switch(this._restrictCursor(this._bufferService.cols),H.params[0]){case 0:for($=this._activeBuffer.y,this._dirtyRowTracker.markDirty($),this._eraseInBufferLine($++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,I);$<this._bufferService.rows;$++)this._resetBufferLine($,I);this._dirtyRowTracker.markDirty($);break;case 1:for($=this._activeBuffer.y,this._dirtyRowTracker.markDirty($),this._eraseInBufferLine($,0,this._activeBuffer.x+1,!0,I),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get($+1).isWrapped=!1);$--;)this._resetBufferLine($,I);this._dirtyRowTracker.markDirty(0);break;case 2:for($=this._bufferService.rows,this._dirtyRowTracker.markDirty($-1);$--;)this._resetBufferLine($,I);this._dirtyRowTracker.markDirty(0);break;case 3:const F=this._activeBuffer.lines.length-this._bufferService.rows;F>0&&(this._activeBuffer.lines.trimStart(F),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-F,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-F,0),this._onScroll.fire(0))}return!0}eraseInLine(H,I=!1){switch(this._restrictCursor(this._bufferService.cols),H.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,I);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,I);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,I)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(H){this._restrictCursor();let I=H.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,F=this._bufferService.rows-1-this._activeBuffer.scrollBottom,P=this._bufferService.rows-1+this._activeBuffer.ybase-F+1;for(;I--;)this._activeBuffer.lines.splice(P-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(H){this._restrictCursor();let I=H.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 F;for(F=this._bufferService.rows-1-this._activeBuffer.scrollBottom,F=this._bufferService.rows-1+this._activeBuffer.ybase-F;I--;)this._activeBuffer.lines.splice($,1),this._activeBuffer.lines.splice(F,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(H){this._restrictCursor();const I=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return I&&(I.insertCells(this._activeBuffer.x,H.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(H){this._restrictCursor();const I=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return I&&(I.deleteCells(this._activeBuffer.x,H.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(H){let I=H.params[0]||1;for(;I--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(H){let I=H.params[0]||1;for(;I--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(v.DEFAULT_ATTR_DATA));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(H){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const I=H.params[0]||1;for(let $=this._activeBuffer.scrollTop;$<=this._activeBuffer.scrollBottom;++$){const F=this._activeBuffer.lines.get(this._activeBuffer.ybase+$);F.deleteCells(0,I,this._activeBuffer.getNullCell(this._eraseAttrData())),F.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(H){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const I=H.params[0]||1;for(let $=this._activeBuffer.scrollTop;$<=this._activeBuffer.scrollBottom;++$){const F=this._activeBuffer.lines.get(this._activeBuffer.ybase+$);F.insertCells(0,I,this._activeBuffer.getNullCell(this._eraseAttrData())),F.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(H){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const I=H.params[0]||1;for(let $=this._activeBuffer.scrollTop;$<=this._activeBuffer.scrollBottom;++$){const F=this._activeBuffer.lines.get(this._activeBuffer.ybase+$);F.insertCells(this._activeBuffer.x,I,this._activeBuffer.getNullCell(this._eraseAttrData())),F.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(H){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const I=H.params[0]||1;for(let $=this._activeBuffer.scrollTop;$<=this._activeBuffer.scrollBottom;++$){const F=this._activeBuffer.lines.get(this._activeBuffer.ybase+$);F.deleteCells(this._activeBuffer.x,I,this._activeBuffer.getNullCell(this._eraseAttrData())),F.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(H){this._restrictCursor();const I=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return I&&(I.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(H.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(H){const I=this._parser.precedingJoinState;if(!I)return!0;const $=H.params[0]||1,F=T.UnicodeService.extractWidth(I),P=this._activeBuffer.x-F,ee=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(P),J=new Uint32Array(ee.length*$);let re=0;for(let q=0;q<ee.length;){const Z=ee.codePointAt(q)||0;J[re++]=Z,q+=Z>65535?2:1}let Y=re;for(let q=1;q<$;++q)J.copyWithin(Y,0,re),Y+=re;return this.print(J,0,Y),!0}sendDeviceAttributesPrimary(H){return H.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(p.C0.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(p.C0.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(H){return H.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(p.C0.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(p.C0.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(H.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(p.C0.ESC+"[>83;40003;0c")),!0}_is(H){return(this._optionsService.rawOptions.termName+"").indexOf(H)===0}setMode(H){for(let I=0;I<H.length;I++)switch(H.params[I]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(H){for(let I=0;I<H.length;I++)switch(H.params[I]){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(H){for(let I=0;I<H.length;I++)switch(H.params[I]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(H){for(let I=0;I<H.length;I++)switch(H.params[I]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),H.params[I]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1}return!0}requestMode(H,I){const $=this._coreService.decPrivateModes,{activeProtocol:F,activeEncoding:P}=this._coreMouseService,ee=this._coreService,{buffers:J,cols:re}=this._bufferService,{active:Y,alt:q}=J,Z=this._optionsService.rawOptions,ae=Le=>Le?1:2,se=H.params[0];return oe=se,je=I?se===2?4:se===4?ae(ee.modes.insertMode):se===12?3:se===20?ae(Z.convertEol):0:se===1?ae($.applicationCursorKeys):se===3?Z.windowOptions.setWinLines?re===80?2:re===132?1:0:0:se===6?ae($.origin):se===7?ae($.wraparound):se===8?3:se===9?ae(F==="X10"):se===12?ae(Z.cursorBlink):se===25?ae(!ee.isCursorHidden):se===45?ae($.reverseWraparound):se===66?ae($.applicationKeypad):se===67?4:se===1e3?ae(F==="VT200"):se===1002?ae(F==="DRAG"):se===1003?ae(F==="ANY"):se===1004?ae($.sendFocus):se===1005?4:se===1006?ae(P==="SGR"):se===1015?4:se===1016?ae(P==="SGR_PIXELS"):se===1048?1:se===47||se===1047||se===1049?ae(Y===q):se===2004?ae($.bracketedPasteMode):0,ee.triggerDataEvent(`${p.C0.ESC}[${I?"":"?"}${oe};${je}$y`),!0;var oe,je}_updateAttrColor(H,I,$,F,P){return I===2?(H|=50331648,H&=-16777216,H|=E.AttributeData.fromColorRGB([$,F,P])):I===5&&(H&=-50331904,H|=33554432|255&$),H}_extractColor(H,I,$){const F=[0,0,-1,0,0,0];let P=0,ee=0;do{if(F[ee+P]=H.params[I+ee],H.hasSubParams(I+ee)){const J=H.getSubParams(I+ee);let re=0;do F[1]===5&&(P=1),F[ee+re+1+P]=J[re];while(++re<J.length&&re+ee+1+P<F.length);break}if(F[1]===5&&ee+P>=2||F[1]===2&&ee+P>=5)break;F[1]&&(P=1)}while(++ee+I<H.length&&ee+P<F.length);for(let J=2;J<F.length;++J)F[J]===-1&&(F[J]=0);switch(F[0]){case 38:$.fg=this._updateAttrColor($.fg,F[1],F[3],F[4],F[5]);break;case 48:$.bg=this._updateAttrColor($.bg,F[1],F[3],F[4],F[5]);break;case 58:$.extended=$.extended.clone(),$.extended.underlineColor=this._updateAttrColor($.extended.underlineColor,F[1],F[3],F[4],F[5])}return ee}_processUnderline(H,I){I.extended=I.extended.clone(),(!~H||H>5)&&(H=1),I.extended.underlineStyle=H,I.fg|=268435456,H===0&&(I.fg&=-268435457),I.updateExtended()}_processSGR0(H){H.fg=v.DEFAULT_ATTR_DATA.fg,H.bg=v.DEFAULT_ATTR_DATA.bg,H.extended=H.extended.clone(),H.extended.underlineStyle=0,H.extended.underlineColor&=-67108864,H.updateExtended()}charAttributes(H){if(H.length===1&&H.params[0]===0)return this._processSGR0(this._curAttrData),!0;const I=H.length;let $;const F=this._curAttrData;for(let P=0;P<I;P++)$=H.params[P],$>=30&&$<=37?(F.fg&=-50331904,F.fg|=16777216|$-30):$>=40&&$<=47?(F.bg&=-50331904,F.bg|=16777216|$-40):$>=90&&$<=97?(F.fg&=-50331904,F.fg|=16777224|$-90):$>=100&&$<=107?(F.bg&=-50331904,F.bg|=16777224|$-100):$===0?this._processSGR0(F):$===1?F.fg|=134217728:$===3?F.bg|=67108864:$===4?(F.fg|=268435456,this._processUnderline(H.hasSubParams(P)?H.getSubParams(P)[0]:1,F)):$===5?F.fg|=536870912:$===7?F.fg|=67108864:$===8?F.fg|=1073741824:$===9?F.fg|=2147483648:$===2?F.bg|=134217728:$===21?this._processUnderline(2,F):$===22?(F.fg&=-134217729,F.bg&=-134217729):$===23?F.bg&=-67108865:$===24?(F.fg&=-268435457,this._processUnderline(0,F)):$===25?F.fg&=-536870913:$===27?F.fg&=-67108865:$===28?F.fg&=-1073741825:$===29?F.fg&=2147483647:$===39?(F.fg&=-67108864,F.fg|=16777215&v.DEFAULT_ATTR_DATA.fg):$===49?(F.bg&=-67108864,F.bg|=16777215&v.DEFAULT_ATTR_DATA.bg):$===38||$===48||$===58?P+=this._extractColor(H,P,F):$===53?F.bg|=1073741824:$===55?F.bg&=-1073741825:$===59?(F.extended=F.extended.clone(),F.extended.underlineColor=-1,F.updateExtended()):$===100?(F.fg&=-67108864,F.fg|=16777215&v.DEFAULT_ATTR_DATA.fg,F.bg&=-67108864,F.bg|=16777215&v.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",$);return!0}deviceStatus(H){switch(H.params[0]){case 5:this._coreService.triggerDataEvent(`${p.C0.ESC}[0n`);break;case 6:const I=this._activeBuffer.y+1,$=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${p.C0.ESC}[${I};${$}R`)}return!0}deviceStatusPrivate(H){if(H.params[0]===6){const I=this._activeBuffer.y+1,$=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${p.C0.ESC}[?${I};${$}R`)}return!0}softReset(H){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=v.DEFAULT_ATTR_DATA.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(H){const I=H.params[0]||1;switch(I){case 1:case 2:this._optionsService.options.cursorStyle="block";break;case 3:case 4:this._optionsService.options.cursorStyle="underline";break;case 5:case 6:this._optionsService.options.cursorStyle="bar"}const $=I%2==1;return this._optionsService.options.cursorBlink=$,!0}setScrollRegion(H){const I=H.params[0]||1;let $;return(H.length<2||($=H.params[1])>this._bufferService.rows||$===0)&&($=this._bufferService.rows),$>I&&(this._activeBuffer.scrollTop=I-1,this._activeBuffer.scrollBottom=$-1,this._setCursor(0,0)),!0}windowOptions(H){if(!W(H.params[0],this._optionsService.rawOptions.windowOptions))return!0;const I=H.length>1?H.params[1]:0;switch(H.params[0]){case 14:I!==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(`${p.C0.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:I!==0&&I!==2||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),I!==0&&I!==1||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:I!==0&&I!==2||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),I!==0&&I!==1||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(H){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(H){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(H){return this._windowTitle=H,this._onTitleChange.fire(H),!0}setIconName(H){return this._iconName=H,!0}setOrReportIndexedColor(H){const I=[],$=H.split(";");for(;$.length>1;){const F=$.shift(),P=$.shift();if(/^\d+$/.exec(F)){const ee=parseInt(F);if(X(ee))if(P==="?")I.push({type:0,index:ee});else{const J=(0,R.parseColor)(P);J&&I.push({type:1,index:ee,color:J})}}}return I.length&&this._onColor.fire(I),!0}setHyperlink(H){const I=H.split(";");return!(I.length<2)&&(I[1]?this._createHyperlink(I[0],I[1]):!I[0]&&this._finishHyperlink())}_createHyperlink(H,I){this._getCurrentLinkId()&&this._finishHyperlink();const $=H.split(":");let F;const P=$.findIndex((ee=>ee.startsWith("id=")));return P!==-1&&(F=$[P].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:F,uri:I}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(H,I){const $=H.split(";");for(let F=0;F<$.length&&!(I>=this._specialColors.length);++F,++I)if($[F]==="?")this._onColor.fire([{type:0,index:this._specialColors[I]}]);else{const P=(0,R.parseColor)($[F]);P&&this._onColor.fire([{type:1,index:this._specialColors[I],color:P}])}return!0}setOrReportFgColor(H){return this._setOrReportSpecialColor(H,0)}setOrReportBgColor(H){return this._setOrReportSpecialColor(H,1)}setOrReportCursorColor(H){return this._setOrReportSpecialColor(H,2)}restoreIndexedColor(H){if(!H)return this._onColor.fire([{type:2}]),!0;const I=[],$=H.split(";");for(let F=0;F<$.length;++F)if(/^\d+$/.exec($[F])){const P=parseInt($[F]);X(P)&&I.push({type:2,index:P})}return I.length&&this._onColor.fire(I),!0}restoreFgColor(H){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(H){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(H){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(H){return H.length!==2?(this.selectDefaultCharset(),!0):(H[0]==="/"||this._charsetService.setgCharset(M[H[0]],_.CHARSETS[H[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 H=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,H,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=v.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=v.DEFAULT_ATTR_DATA.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(H){return this._charsetService.setgLevel(H),!0}screenAlignmentPattern(){const H=new y.CellData;H.content=4194373,H.fg=this._curAttrData.fg,H.bg=this._curAttrData.bg,this._setCursor(0,0);for(let I=0;I<this._bufferService.rows;++I){const $=this._activeBuffer.ybase+this._activeBuffer.y+I,F=this._activeBuffer.lines.get($);F&&(F.fill(H),F.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(H,I){const $=this._bufferService.buffer,F=this._optionsService.rawOptions;return(P=>(this._coreService.triggerDataEvent(`${p.C0.ESC}${P}${p.C0.ESC}\\`),!0))(H==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:H==='"p'?'P1$r61;1"p':H==="r"?`P1$r${$.scrollTop+1};${$.scrollBottom+1}r`:H==="m"?"P1$r0m":H===" q"?`P1$r${{block:2,underline:4,bar:6}[F.cursorStyle]-(F.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(H,I){this._dirtyRowTracker.markRangeDirty(H,I)}}c.InputHandler=V;let z=class{constructor(te){this._bufferService=te,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(te){te<this.start?this.start=te:te>this.end&&(this.end=te)}markRangeDirty(te,H){te>H&&(U=te,te=H,H=U),te<this.start&&(this.start=te),H>this.end&&(this.end=H)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function X(te){return 0<=te&&te<256}z=f([m(0,N.IBufferService)],z)},844:(u,c)=>{function d(f){for(const m of f)m.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 m=this._disposables.indexOf(f);m!==-1&&this._disposables.splice(m,1)}},c.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(f){var m;this._isDisposed||f===this._value||((m=this._value)==null||m.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=d,c.getDisposeArrayDisposable=function(f){return{dispose:()=>d(f)}}},1505:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.FourKeyMap=c.TwoKeyMap=void 0;class d{constructor(){this._data={}}set(m,p,_){this._data[m]||(this._data[m]={}),this._data[m][p]=_}get(m,p){return this._data[m]?this._data[m][p]:void 0}clear(){this._data={}}}c.TwoKeyMap=d,c.FourKeyMap=class{constructor(){this._data=new d}set(f,m,p,_,x){this._data.get(f,m)||this._data.set(f,m,new d),this._data.get(f,m).set(p,_,x)}get(f,m,p,_){var x;return(x=this._data.get(f,m))==null?void 0:x.get(p,_)}clear(){this._data.clear()}}},6114:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.isChromeOS=c.isLinux=c.isWindows=c.isIphone=c.isIpad=c.isMac=c.getSafariVersion=c.isSafari=c.isLegacyEdge=c.isFirefox=c.isNode=void 0,c.isNode=typeof process<"u"&&"title"in process;const d=c.isNode?"node":navigator.userAgent,f=c.isNode?"node":navigator.platform;c.isFirefox=d.includes("Firefox"),c.isLegacyEdge=d.includes("Edge"),c.isSafari=/^((?!chrome|android).)*safari/i.test(d),c.getSafariVersion=function(){if(!c.isSafari)return 0;const m=d.match(/Version\/(\d+)/);return m===null||m.length<2?0:parseInt(m[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(d)},6106:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.SortedList=void 0;let d=0;c.SortedList=class{constructor(f){this._getKey=f,this._array=[]}clear(){this._array.length=0}insert(f){this._array.length!==0?(d=this._search(this._getKey(f)),this._array.splice(d,0,f)):this._array.push(f)}delete(f){if(this._array.length===0)return!1;const m=this._getKey(f);if(m===void 0||(d=this._search(m),d===-1)||this._getKey(this._array[d])!==m)return!1;do if(this._array[d]===f)return this._array.splice(d,1),!0;while(++d<this._array.length&&this._getKey(this._array[d])===m);return!1}*getKeyIterator(f){if(this._array.length!==0&&(d=this._search(f),!(d<0||d>=this._array.length)&&this._getKey(this._array[d])===f))do yield this._array[d];while(++d<this._array.length&&this._getKey(this._array[d])===f)}forEachByKey(f,m){if(this._array.length!==0&&(d=this._search(f),!(d<0||d>=this._array.length)&&this._getKey(this._array[d])===f))do m(this._array[d]);while(++d<this._array.length&&this._getKey(this._array[d])===f)}values(){return[...this._array].values()}_search(f){let m=0,p=this._array.length-1;for(;p>=m;){let _=m+p>>1;const x=this._getKey(this._array[_]);if(x>f)p=_-1;else{if(!(x<f)){for(;_>0&&this._getKey(this._array[_-1])===f;)_--;return _}m=_+1}}return m}}},7226:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.DebouncedIdleTask=c.IdleTaskQueue=c.PriorityTaskQueue=void 0;const f=d(6114);class m{constructor(){this._tasks=[],this._i=0}enqueue(x){this._tasks.push(x),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(x){this._idleCallback=void 0;let w=0,C=0,v=x.timeRemaining(),S=0;for(;this._i<this._tasks.length;){if(w=Date.now(),this._tasks[this._i]()||this._i++,w=Math.max(1,Date.now()-w),C=Math.max(w,C),S=x.timeRemaining(),1.5*C>S)return v-w<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(v-w))}ms`),void this._start();v=S}this.clear()}}class p extends m{_requestCallback(x){return setTimeout((()=>x(this._createDeadline(16))))}_cancelCallback(x){clearTimeout(x)}_createDeadline(x){const w=Date.now()+x;return{timeRemaining:()=>Math.max(0,w-Date.now())}}}c.PriorityTaskQueue=p,c.IdleTaskQueue=!f.isNode&&"requestIdleCallback"in window?class extends m{_requestCallback(_){return requestIdleCallback(_)}_cancelCallback(_){cancelIdleCallback(_)}}:p,c.DebouncedIdleTask=class{constructor(){this._queue=new c.IdleTaskQueue}set(_){this._queue.clear(),this._queue.enqueue(_)}flush(){this._queue.flush()}}},9282:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.updateWindowsModeWrappedState=void 0;const f=d(643);c.updateWindowsModeWrappedState=function(m){const p=m.buffer.lines.get(m.buffer.ybase+m.buffer.y-1),_=p==null?void 0:p.get(m.cols-1),x=m.buffer.lines.get(m.buffer.ybase+m.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 d{constructor(){this.fg=0,this.bg=0,this.extended=new f}static toColorRGB(p){return[p>>>16&255,p>>>8&255,255&p]}static fromColorRGB(p){return(255&p[0])<<16|(255&p[1])<<8|255&p[2]}clone(){const p=new d;return p.fg=this.fg,p.bg=this.bg,p.extended=this.extended.clone(),p}isInverse(){return 67108864&this.fg}isBold(){return 134217728&this.fg}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:268435456&this.fg}isBlink(){return 536870912&this.fg}isInvisible(){return 1073741824&this.fg}isItalic(){return 67108864&this.bg}isDim(){return 134217728&this.bg}isStrikethrough(){return 2147483648&this.fg}isProtected(){return 536870912&this.bg}isOverline(){return 1073741824&this.bg}getFgColorMode(){return 50331648&this.fg}getBgColorMode(){return 50331648&this.bg}isFgRGB(){return(50331648&this.fg)==50331648}isBgRGB(){return(50331648&this.bg)==50331648}isFgPalette(){return(50331648&this.fg)==16777216||(50331648&this.fg)==33554432}isBgPalette(){return(50331648&this.bg)==16777216||(50331648&this.bg)==33554432}isFgDefault(){return(50331648&this.fg)==0}isBgDefault(){return(50331648&this.bg)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}}getBgColor(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}}hasExtendedAttrs(){return 268435456&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(268435456&this.bg&&~this.extended.underlineColor)switch(50331648&this.extended.underlineColor){case 16777216:case 33554432:return 255&this.extended.underlineColor;case 50331648:return 16777215&this.extended.underlineColor;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return 268435456&this.bg&&~this.extended.underlineColor?50331648&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==16777216||(50331648&this.extended.underlineColor)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==0:this.isFgDefault()}getUnderlineStyle(){return 268435456&this.fg?268435456&this.bg?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}}c.AttributeData=d;class f{get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(p){this._ext=p}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(p){this._ext&=-469762049,this._ext|=p<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(p){this._ext&=-67108864,this._ext|=67108863&p}get urlId(){return this._urlId}set urlId(p){this._urlId=p}get underlineVariantOffset(){const p=(3758096384&this._ext)>>29;return p<0?4294967288^p:p}set underlineVariantOffset(p){this._ext&=536870911,this._ext|=p<<29&3758096384}constructor(p=0,_=0){this._ext=0,this._urlId=0,this._ext=p,this._urlId=_}clone(){return new f(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}c.ExtendedAttrs=f},9092:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.Buffer=c.MAX_BUFFER_SIZE=void 0;const f=d(6349),m=d(7226),p=d(3734),_=d(8437),x=d(4634),w=d(511),C=d(643),v=d(4863),S=d(7116);c.MAX_BUFFER_SIZE=4294967295,c.Buffer=class{constructor(b,y,E){this._hasScrollback=b,this._optionsService=y,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,C.NULL_CELL_CHAR,C.NULL_CELL_WIDTH,C.NULL_CELL_CODE]),this._whitespaceCell=w.CellData.fromCharData([0,C.WHITESPACE_CELL_CHAR,C.WHITESPACE_CELL_WIDTH,C.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new m.IdleTaskQueue,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new f.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(b){return b?(this._nullCell.fg=b.fg,this._nullCell.bg=b.bg,this._nullCell.extended=b.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new p.ExtendedAttrs),this._nullCell}getWhitespaceCell(b){return b?(this._whitespaceCell.fg=b.fg,this._whitespaceCell.bg=b.bg,this._whitespaceCell.extended=b.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new p.ExtendedAttrs),this._whitespaceCell}getBlankLine(b,y){return new _.BufferLine(this._bufferService.cols,this.getNullCell(b),y)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){const b=this.ybase+this.y-this.ydisp;return b>=0&&b<this._rows}_getCorrectBufferLength(b){if(!this._hasScrollback)return b;const y=b+this._optionsService.rawOptions.scrollback;return y>c.MAX_BUFFER_SIZE?c.MAX_BUFFER_SIZE:y}fillViewportRows(b){if(this.lines.length===0){b===void 0&&(b=_.DEFAULT_ATTR_DATA);let y=this._rows;for(;y--;)this.lines.push(this.getBlankLine(b))}}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(b,y){const E=this.getNullCell(_.DEFAULT_ATTR_DATA);let N=0;const T=this._getCorrectBufferLength(y);if(T>this.lines.maxLength&&(this.lines.maxLength=T),this.lines.length>0){if(this._cols<b)for(let A=0;A<this.lines.length;A++)N+=+this.lines.get(A).resize(b,E);let L=0;if(this._rows<y)for(let A=this._rows;A<y;A++)this.lines.length<y+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(b,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(b,E)));else for(let A=this._rows;A>y;A--)this.lines.length>y+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(T<this.lines.maxLength){const A=this.lines.length-T;A>0&&(this.lines.trimStart(A),this.ybase=Math.max(this.ybase-A,0),this.ydisp=Math.max(this.ydisp-A,0),this.savedY=Math.max(this.savedY-A,0)),this.lines.maxLength=T}this.x=Math.min(this.x,b-1),this.y=Math.min(this.y,y-1),L&&(this.y+=L),this.savedX=Math.min(this.savedX,b-1),this.scrollTop=0}if(this.scrollBottom=y-1,this._isReflowEnabled&&(this._reflow(b,y),this._cols>b))for(let L=0;L<this.lines.length;L++)N+=+this.lines.get(L).resize(b,E);this._cols=b,this._rows=y,this._memoryCleanupQueue.clear(),N>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue((()=>this._batchedMemoryCleanup())))}_batchedMemoryCleanup(){let b=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,b=!1);let y=0;for(;this._memoryCleanupPosition<this.lines.length;)if(y+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),y>100)return!0;return b}get _isReflowEnabled(){const b=this._optionsService.rawOptions.windowsPty;return b&&b.buildNumber?this._hasScrollback&&b.backend==="conpty"&&b.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(b,y){this._cols!==b&&(b>this._cols?this._reflowLarger(b,y):this._reflowSmaller(b,y))}_reflowLarger(b,y){const E=(0,x.reflowLargerGetLinesToRemove)(this.lines,this._cols,b,this.ybase+this.y,this.getNullCell(_.DEFAULT_ATTR_DATA));if(E.length>0){const N=(0,x.reflowLargerCreateNewLayout)(this.lines,E);(0,x.reflowLargerApplyNewLayout)(this.lines,N.layout),this._reflowLargerAdjustViewport(b,y,N.countRemoved)}}_reflowLargerAdjustViewport(b,y,E){const N=this.getNullCell(_.DEFAULT_ATTR_DATA);let T=E;for(;T-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<y&&this.lines.push(new _.BufferLine(b,N))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-E,0)}_reflowSmaller(b,y){const E=this.getNullCell(_.DEFAULT_ATTR_DATA),N=[];let T=0;for(let L=this.lines.length-1;L>=0;L--){let A=this.lines.get(L);if(!A||!A.isWrapped&&A.getTrimmedLength()<=b)continue;const R=[A];for(;A.isWrapped&&L>0;)A=this.lines.get(--L),R.unshift(A);const M=this.ybase+this.y;if(M>=L&&M<L+R.length)continue;const G=R[R.length-1].getTrimmedLength(),W=(0,x.reflowSmallerGetNewLineLengths)(R,this._cols,b),O=W.length-R.length;let U;U=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 V=[];for(let $=0;$<O;$++){const F=this.getBlankLine(_.DEFAULT_ATTR_DATA,!0);V.push(F)}V.length>0&&(N.push({start:L+R.length+T,newLines:V}),T+=V.length),R.push(...V);let z=W.length-1,X=W[z];X===0&&(z--,X=W[z]);let te=R.length-O-1,H=G;for(;te>=0;){const $=Math.min(H,X);if(R[z]===void 0)break;if(R[z].copyCellsFrom(R[te],H-$,X-$,$,!0),X-=$,X===0&&(z--,X=W[z]),H-=$,H===0){te--;const F=Math.max(te,0);H=(0,x.getWrappedLineTrimmedLength)(R,F,this._cols)}}for(let $=0;$<R.length;$++)W[$]<b&&R[$].setCell(W[$],E);let I=O-U;for(;I-- >0;)this.ybase===0?this.y<y-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+T)-y&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+O,this.ybase+y-1)}if(N.length>0){const L=[],A=[];for(let z=0;z<this.lines.length;z++)A.push(this.lines.get(z));const R=this.lines.length;let M=R-1,G=0,W=N[G];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+T);let O=0;for(let z=Math.min(this.lines.maxLength-1,R+T-1);z>=0;z--)if(W&&W.start>M+O){for(let X=W.newLines.length-1;X>=0;X--)this.lines.set(z--,W.newLines[X]);z++,L.push({index:M+1,amount:W.newLines.length}),O+=W.newLines.length,W=N[++G]}else this.lines.set(z,A[M--]);let U=0;for(let z=L.length-1;z>=0;z--)L[z].index+=U,this.lines.onInsertEmitter.fire(L[z]),U+=L[z].amount;const V=Math.max(0,R+T-this.lines.maxLength);V>0&&this.lines.onTrimEmitter.fire(V)}}translateBufferLineToString(b,y,E=0,N){const T=this.lines.get(b);return T?T.translateToString(y,E,N):""}getWrappedRangeForLine(b){let y=b,E=b;for(;y>0&&this.lines.get(y).isWrapped;)y--;for(;E+1<this.lines.length&&this.lines.get(E+1).isWrapped;)E++;return{first:y,last:E}}setupTabStops(b){for(b!=null?this.tabs[b]||(b=this.prevStop(b)):(this.tabs={},b=0);b<this._cols;b+=this._optionsService.rawOptions.tabStopWidth)this.tabs[b]=!0}prevStop(b){for(b==null&&(b=this.x);!this.tabs[--b]&&b>0;);return b>=this._cols?this._cols-1:b<0?0:b}nextStop(b){for(b==null&&(b=this.x);!this.tabs[++b]&&b<this._cols;);return b>=this._cols?this._cols-1:b<0?0:b}clearMarkers(b){this._isClearing=!0;for(let y=0;y<this.markers.length;y++)this.markers[y].line===b&&(this.markers[y].dispose(),this.markers.splice(y--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let b=0;b<this.markers.length;b++)this.markers[b].dispose(),this.markers.splice(b--,1);this._isClearing=!1}addMarker(b){const y=new v.Marker(b);return this.markers.push(y),y.register(this.lines.onTrim((E=>{y.line-=E,y.line<0&&y.dispose()}))),y.register(this.lines.onInsert((E=>{y.line>=E.index&&(y.line+=E.amount)}))),y.register(this.lines.onDelete((E=>{y.line>=E.index&&y.line<E.index+E.amount&&y.dispose(),y.line>E.index&&(y.line-=E.amount)}))),y.register(y.onDispose((()=>this._removeMarker(y)))),y}_removeMarker(b){this._isClearing||this.markers.splice(this.markers.indexOf(b),1)}}},8437:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.BufferLine=c.DEFAULT_ATTR_DATA=void 0;const f=d(3734),m=d(511),p=d(643),_=d(482);c.DEFAULT_ATTR_DATA=Object.freeze(new f.AttributeData);let x=0;class w{constructor(v,S,b=!1){this.isWrapped=b,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*v);const y=S||m.CellData.fromCharData([0,p.NULL_CELL_CHAR,p.NULL_CELL_WIDTH,p.NULL_CELL_CODE]);for(let E=0;E<v;++E)this.setCell(E,y);this.length=v}get(v){const S=this._data[3*v+0],b=2097151&S;return[this._data[3*v+1],2097152&S?this._combined[v]:b?(0,_.stringFromCodePoint)(b):"",S>>22,2097152&S?this._combined[v].charCodeAt(this._combined[v].length-1):b]}set(v,S){this._data[3*v+1]=S[p.CHAR_DATA_ATTR_INDEX],S[p.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[v]=S[1],this._data[3*v+0]=2097152|v|S[p.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*v+0]=S[p.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|S[p.CHAR_DATA_WIDTH_INDEX]<<22}getWidth(v){return this._data[3*v+0]>>22}hasWidth(v){return 12582912&this._data[3*v+0]}getFg(v){return this._data[3*v+1]}getBg(v){return this._data[3*v+2]}hasContent(v){return 4194303&this._data[3*v+0]}getCodePoint(v){const S=this._data[3*v+0];return 2097152&S?this._combined[v].charCodeAt(this._combined[v].length-1):2097151&S}isCombined(v){return 2097152&this._data[3*v+0]}getString(v){const S=this._data[3*v+0];return 2097152&S?this._combined[v]:2097151&S?(0,_.stringFromCodePoint)(2097151&S):""}isProtected(v){return 536870912&this._data[3*v+2]}loadCell(v,S){return x=3*v,S.content=this._data[x+0],S.fg=this._data[x+1],S.bg=this._data[x+2],2097152&S.content&&(S.combinedData=this._combined[v]),268435456&S.bg&&(S.extended=this._extendedAttrs[v]),S}setCell(v,S){2097152&S.content&&(this._combined[v]=S.combinedData),268435456&S.bg&&(this._extendedAttrs[v]=S.extended),this._data[3*v+0]=S.content,this._data[3*v+1]=S.fg,this._data[3*v+2]=S.bg}setCellFromCodepoint(v,S,b,y){268435456&y.bg&&(this._extendedAttrs[v]=y.extended),this._data[3*v+0]=S|b<<22,this._data[3*v+1]=y.fg,this._data[3*v+2]=y.bg}addCodepointToCell(v,S,b){let y=this._data[3*v+0];2097152&y?this._combined[v]+=(0,_.stringFromCodePoint)(S):2097151&y?(this._combined[v]=(0,_.stringFromCodePoint)(2097151&y)+(0,_.stringFromCodePoint)(S),y&=-2097152,y|=2097152):y=S|4194304,b&&(y&=-12582913,y|=b<<22),this._data[3*v+0]=y}insertCells(v,S,b){if((v%=this.length)&&this.getWidth(v-1)===2&&this.setCellFromCodepoint(v-1,0,1,b),S<this.length-v){const y=new m.CellData;for(let E=this.length-v-S-1;E>=0;--E)this.setCell(v+S+E,this.loadCell(v+E,y));for(let E=0;E<S;++E)this.setCell(v+E,b)}else for(let y=v;y<this.length;++y)this.setCell(y,b);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,b)}deleteCells(v,S,b){if(v%=this.length,S<this.length-v){const y=new m.CellData;for(let E=0;E<this.length-v-S;++E)this.setCell(v+E,this.loadCell(v+S+E,y));for(let E=this.length-S;E<this.length;++E)this.setCell(E,b)}else for(let y=v;y<this.length;++y)this.setCell(y,b);v&&this.getWidth(v-1)===2&&this.setCellFromCodepoint(v-1,0,1,b),this.getWidth(v)!==0||this.hasContent(v)||this.setCellFromCodepoint(v,0,1,b)}replaceCells(v,S,b,y=!1){if(y)for(v&&this.getWidth(v-1)===2&&!this.isProtected(v-1)&&this.setCellFromCodepoint(v-1,0,1,b),S<this.length&&this.getWidth(S-1)===2&&!this.isProtected(S)&&this.setCellFromCodepoint(S,0,1,b);v<S&&v<this.length;)this.isProtected(v)||this.setCell(v,b),v++;else for(v&&this.getWidth(v-1)===2&&this.setCellFromCodepoint(v-1,0,1,b),S<this.length&&this.getWidth(S-1)===2&&this.setCellFromCodepoint(S,0,1,b);v<S&&v<this.length;)this.setCell(v++,b)}resize(v,S){if(v===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;const b=3*v;if(v>this.length){if(this._data.buffer.byteLength>=4*b)this._data=new Uint32Array(this._data.buffer,0,b);else{const y=new Uint32Array(b);y.set(this._data),this._data=y}for(let y=this.length;y<v;++y)this.setCell(y,S)}else{this._data=this._data.subarray(0,b);const y=Object.keys(this._combined);for(let N=0;N<y.length;N++){const T=parseInt(y[N],10);T>=v&&delete this._combined[T]}const E=Object.keys(this._extendedAttrs);for(let N=0;N<E.length;N++){const T=parseInt(E[N],10);T>=v&&delete this._extendedAttrs[T]}}return this.length=v,4*b*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){const v=new Uint32Array(this._data.length);return v.set(this._data),this._data=v,1}return 0}fill(v,S=!1){if(S)for(let b=0;b<this.length;++b)this.isProtected(b)||this.setCell(b,v);else{this._combined={},this._extendedAttrs={};for(let b=0;b<this.length;++b)this.setCell(b,v)}}copyFrom(v){this.length!==v.length?this._data=new Uint32Array(v._data):this._data.set(v._data),this.length=v.length,this._combined={};for(const S in v._combined)this._combined[S]=v._combined[S];this._extendedAttrs={};for(const S in v._extendedAttrs)this._extendedAttrs[S]=v._extendedAttrs[S];this.isWrapped=v.isWrapped}clone(){const v=new w(0);v._data=new Uint32Array(this._data),v.length=this.length;for(const S in this._combined)v._combined[S]=this._combined[S];for(const S in this._extendedAttrs)v._extendedAttrs[S]=this._extendedAttrs[S];return v.isWrapped=this.isWrapped,v}getTrimmedLength(){for(let v=this.length-1;v>=0;--v)if(4194303&this._data[3*v+0])return v+(this._data[3*v+0]>>22);return 0}getNoBgTrimmedLength(){for(let v=this.length-1;v>=0;--v)if(4194303&this._data[3*v+0]||50331648&this._data[3*v+2])return v+(this._data[3*v+0]>>22);return 0}copyCellsFrom(v,S,b,y,E){const N=v._data;if(E)for(let L=y-1;L>=0;L--){for(let A=0;A<3;A++)this._data[3*(b+L)+A]=N[3*(S+L)+A];268435456&N[3*(S+L)+2]&&(this._extendedAttrs[b+L]=v._extendedAttrs[S+L])}else for(let L=0;L<y;L++){for(let A=0;A<3;A++)this._data[3*(b+L)+A]=N[3*(S+L)+A];268435456&N[3*(S+L)+2]&&(this._extendedAttrs[b+L]=v._extendedAttrs[S+L])}const T=Object.keys(v._combined);for(let L=0;L<T.length;L++){const A=parseInt(T[L],10);A>=S&&(this._combined[A-S+b]=v._combined[A])}}translateToString(v,S,b,y){S=S??0,b=b??this.length,v&&(b=Math.min(b,this.getTrimmedLength())),y&&(y.length=0);let E="";for(;S<b;){const N=this._data[3*S+0],T=2097151&N,L=2097152&N?this._combined[S]:T?(0,_.stringFromCodePoint)(T):p.WHITESPACE_CELL_CHAR;if(E+=L,y)for(let A=0;A<L.length;++A)y.push(S);S+=N>>22||1}return y&&y.push(S),E}}c.BufferLine=w},4841:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.getRangeLength=void 0,c.getRangeLength=function(d,f){if(d.start.y>d.end.y)throw new Error(`Buffer range end (${d.end.x}, ${d.end.y}) cannot be before start (${d.start.x}, ${d.start.y})`);return f*(d.end.y-d.start.y)+(d.end.x-d.start.x+1)}},4634:(u,c)=>{function d(f,m,p){if(m===f.length-1)return f[m].getTrimmedLength();const _=!f[m].hasContent(p-1)&&f[m].getWidth(p-1)===1,x=f[m+1].getWidth(0)===2;return _&&x?p-1:p}Object.defineProperty(c,"__esModule",{value:!0}),c.getWrappedLineTrimmedLength=c.reflowSmallerGetNewLineLengths=c.reflowLargerApplyNewLayout=c.reflowLargerCreateNewLayout=c.reflowLargerGetLinesToRemove=void 0,c.reflowLargerGetLinesToRemove=function(f,m,p,_,x){const w=[];for(let C=0;C<f.length-1;C++){let v=C,S=f.get(++v);if(!S.isWrapped)continue;const b=[f.get(C)];for(;v<f.length&&S.isWrapped;)b.push(S),S=f.get(++v);if(_>=C&&_<v){C+=b.length-1;continue}let y=0,E=d(b,y,m),N=1,T=0;for(;N<b.length;){const A=d(b,N,m),R=A-T,M=p-E,G=Math.min(R,M);b[y].copyCellsFrom(b[N],T,E,G,!1),E+=G,E===p&&(y++,E=0),T+=G,T===A&&(N++,T=0),E===0&&y!==0&&b[y-1].getWidth(p-1)===2&&(b[y].copyCellsFrom(b[y-1],p-1,E++,1,!1),b[y-1].setCell(p-1,x))}b[y].replaceCells(E,p,x);let L=0;for(let A=b.length-1;A>0&&(A>y||b[A].getTrimmedLength()===0);A--)L++;L>0&&(w.push(C+b.length-L),w.push(L)),C+=b.length-1}return w},c.reflowLargerCreateNewLayout=function(f,m){const p=[];let _=0,x=m[_],w=0;for(let C=0;C<f.length;C++)if(x===C){const v=m[++_];f.onDeleteEmitter.fire({index:C-w,amount:v}),C+=v-1,w+=v,x=m[++_]}else p.push(C);return{layout:p,countRemoved:w}},c.reflowLargerApplyNewLayout=function(f,m){const p=[];for(let _=0;_<m.length;_++)p.push(f.get(m[_]));for(let _=0;_<p.length;_++)f.set(_,p[_]);f.length=m.length},c.reflowSmallerGetNewLineLengths=function(f,m,p){const _=[],x=f.map(((S,b)=>d(f,b,m))).reduce(((S,b)=>S+b));let w=0,C=0,v=0;for(;v<x;){if(x-v<p){_.push(x-v);break}w+=p;const S=d(f,C,m);w>S&&(w-=S,C++);const b=f[C].getWidth(w-1)===2;b&&w--;const y=b?p-1:p;_.push(y),v+=y}return _},c.getWrappedLineTrimmedLength=d},5295:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.BufferSet=void 0;const f=d(8460),m=d(844),p=d(9092);class _ extends m.Disposable{constructor(w,C){super(),this._optionsService=w,this._bufferService=C,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 p.Buffer(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new p.Buffer(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(w){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(w),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(w,C){this._normal.resize(w,C),this._alt.resize(w,C),this.setupTabStops(w)}setupTabStops(w){this._normal.setupTabStops(w),this._alt.setupTabStops(w)}}c.BufferSet=_},511:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.CellData=void 0;const f=d(482),m=d(643),p=d(3734);class _ extends p.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new p.ExtendedAttrs,this.combinedData=""}static fromCharData(w){const C=new _;return C.setFromCharData(w),C}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?(0,f.stringFromCodePoint)(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(w){this.fg=w[m.CHAR_DATA_ATTR_INDEX],this.bg=0;let C=!1;if(w[m.CHAR_DATA_CHAR_INDEX].length>2)C=!0;else if(w[m.CHAR_DATA_CHAR_INDEX].length===2){const v=w[m.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=v&&v<=56319){const S=w[m.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=S&&S<=57343?this.content=1024*(v-55296)+S-56320+65536|w[m.CHAR_DATA_WIDTH_INDEX]<<22:C=!0}else C=!0}else this.content=w[m.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|w[m.CHAR_DATA_WIDTH_INDEX]<<22;C&&(this.combinedData=w[m.CHAR_DATA_CHAR_INDEX],this.content=2097152|w[m.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}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,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.Marker=void 0;const f=d(8460),m=d(844);class p{get id(){return this._id}constructor(x){this.line=x,this.isDisposed=!1,this._disposables=[],this._id=p._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,m.disposeArray)(this._disposables),this._disposables.length=0)}register(x){return this._disposables.push(x),x}}c.Marker=p,p._nextId=1},7116:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.DEFAULT_CHARSET=c.CHARSETS=void 0,c.CHARSETS={},c.DEFAULT_CHARSET=c.CHARSETS.B,c.CHARSETS[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"␤",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"},c.CHARSETS.A={"#":"£"},c.CHARSETS.B=void 0,c.CHARSETS[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},c.CHARSETS.C=c.CHARSETS[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},c.CHARSETS.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},c.CHARSETS.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},c.CHARSETS.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},c.CHARSETS.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},c.CHARSETS.E=c.CHARSETS[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},c.CHARSETS.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},c.CHARSETS.H=c.CHARSETS[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},c.CHARSETS["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"}},2584:(u,c)=>{var d,f,m;Object.defineProperty(c,"__esModule",{value:!0}),c.C1_ESCAPED=c.C1=c.C0=void 0,(function(p){p.NUL="\0",p.SOH="",p.STX="",p.ETX="",p.EOT="",p.ENQ="",p.ACK="",p.BEL="\x07",p.BS="\b",p.HT=" ",p.LF=`
67
+ `,p.VT="\v",p.FF="\f",p.CR="\r",p.SO="",p.SI="",p.DLE="",p.DC1="",p.DC2="",p.DC3="",p.DC4="",p.NAK="",p.SYN="",p.ETB="",p.CAN="",p.EM="",p.SUB="",p.ESC="\x1B",p.FS="",p.GS="",p.RS="",p.US="",p.SP=" ",p.DEL=""})(d||(c.C0=d={})),(function(p){p.PAD="€",p.HOP="",p.BPH="‚",p.NBH="ƒ",p.IND="„",p.NEL="…",p.SSA="†",p.ESA="‡",p.HTS="ˆ",p.HTJ="‰",p.VTS="Š",p.PLD="‹",p.PLU="Œ",p.RI="",p.SS2="Ž",p.SS3="",p.DCS="",p.PU1="‘",p.PU2="’",p.STS="“",p.CCH="”",p.MW="•",p.SPA="–",p.EPA="—",p.SOS="˜",p.SGCI="™",p.SCI="š",p.CSI="›",p.ST="œ",p.OSC="",p.PM="ž",p.APC="Ÿ"})(f||(c.C1=f={})),(function(p){p.ST=`${d.ESC}\\`})(m||(c.C1_ESCAPED=m={}))},7399:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.evaluateKeyboardEvent=void 0;const f=d(2584),m={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};c.evaluateKeyboardEvent=function(p,_,x,w){const C={type:0,cancel:!1,key:void 0},v=(p.shiftKey?1:0)|(p.altKey?2:0)|(p.ctrlKey?4:0)|(p.metaKey?8:0);switch(p.keyCode){case 0:p.key==="UIKeyInputUpArrow"?C.key=_?f.C0.ESC+"OA":f.C0.ESC+"[A":p.key==="UIKeyInputLeftArrow"?C.key=_?f.C0.ESC+"OD":f.C0.ESC+"[D":p.key==="UIKeyInputRightArrow"?C.key=_?f.C0.ESC+"OC":f.C0.ESC+"[C":p.key==="UIKeyInputDownArrow"&&(C.key=_?f.C0.ESC+"OB":f.C0.ESC+"[B");break;case 8:C.key=p.ctrlKey?"\b":f.C0.DEL,p.altKey&&(C.key=f.C0.ESC+C.key);break;case 9:if(p.shiftKey){C.key=f.C0.ESC+"[Z";break}C.key=f.C0.HT,C.cancel=!0;break;case 13:C.key=p.altKey?f.C0.ESC+f.C0.CR:f.C0.CR,C.cancel=!0;break;case 27:C.key=f.C0.ESC,p.altKey&&(C.key=f.C0.ESC+f.C0.ESC),C.cancel=!0;break;case 37:if(p.metaKey)break;v?(C.key=f.C0.ESC+"[1;"+(v+1)+"D",C.key===f.C0.ESC+"[1;3D"&&(C.key=f.C0.ESC+(x?"b":"[1;5D"))):C.key=_?f.C0.ESC+"OD":f.C0.ESC+"[D";break;case 39:if(p.metaKey)break;v?(C.key=f.C0.ESC+"[1;"+(v+1)+"C",C.key===f.C0.ESC+"[1;3C"&&(C.key=f.C0.ESC+(x?"f":"[1;5C"))):C.key=_?f.C0.ESC+"OC":f.C0.ESC+"[C";break;case 38:if(p.metaKey)break;v?(C.key=f.C0.ESC+"[1;"+(v+1)+"A",x||C.key!==f.C0.ESC+"[1;3A"||(C.key=f.C0.ESC+"[1;5A")):C.key=_?f.C0.ESC+"OA":f.C0.ESC+"[A";break;case 40:if(p.metaKey)break;v?(C.key=f.C0.ESC+"[1;"+(v+1)+"B",x||C.key!==f.C0.ESC+"[1;3B"||(C.key=f.C0.ESC+"[1;5B")):C.key=_?f.C0.ESC+"OB":f.C0.ESC+"[B";break;case 45:p.shiftKey||p.ctrlKey||(C.key=f.C0.ESC+"[2~");break;case 46:C.key=v?f.C0.ESC+"[3;"+(v+1)+"~":f.C0.ESC+"[3~";break;case 36:C.key=v?f.C0.ESC+"[1;"+(v+1)+"H":_?f.C0.ESC+"OH":f.C0.ESC+"[H";break;case 35:C.key=v?f.C0.ESC+"[1;"+(v+1)+"F":_?f.C0.ESC+"OF":f.C0.ESC+"[F";break;case 33:p.shiftKey?C.type=2:p.ctrlKey?C.key=f.C0.ESC+"[5;"+(v+1)+"~":C.key=f.C0.ESC+"[5~";break;case 34:p.shiftKey?C.type=3:p.ctrlKey?C.key=f.C0.ESC+"[6;"+(v+1)+"~":C.key=f.C0.ESC+"[6~";break;case 112:C.key=v?f.C0.ESC+"[1;"+(v+1)+"P":f.C0.ESC+"OP";break;case 113:C.key=v?f.C0.ESC+"[1;"+(v+1)+"Q":f.C0.ESC+"OQ";break;case 114:C.key=v?f.C0.ESC+"[1;"+(v+1)+"R":f.C0.ESC+"OR";break;case 115:C.key=v?f.C0.ESC+"[1;"+(v+1)+"S":f.C0.ESC+"OS";break;case 116:C.key=v?f.C0.ESC+"[15;"+(v+1)+"~":f.C0.ESC+"[15~";break;case 117:C.key=v?f.C0.ESC+"[17;"+(v+1)+"~":f.C0.ESC+"[17~";break;case 118:C.key=v?f.C0.ESC+"[18;"+(v+1)+"~":f.C0.ESC+"[18~";break;case 119:C.key=v?f.C0.ESC+"[19;"+(v+1)+"~":f.C0.ESC+"[19~";break;case 120:C.key=v?f.C0.ESC+"[20;"+(v+1)+"~":f.C0.ESC+"[20~";break;case 121:C.key=v?f.C0.ESC+"[21;"+(v+1)+"~":f.C0.ESC+"[21~";break;case 122:C.key=v?f.C0.ESC+"[23;"+(v+1)+"~":f.C0.ESC+"[23~";break;case 123:C.key=v?f.C0.ESC+"[24;"+(v+1)+"~":f.C0.ESC+"[24~";break;default:if(!p.ctrlKey||p.shiftKey||p.altKey||p.metaKey)if(x&&!w||!p.altKey||p.metaKey)!x||p.altKey||p.ctrlKey||p.shiftKey||!p.metaKey?p.key&&!p.ctrlKey&&!p.altKey&&!p.metaKey&&p.keyCode>=48&&p.key.length===1?C.key=p.key:p.key&&p.ctrlKey&&(p.key==="_"&&(C.key=f.C0.US),p.key==="@"&&(C.key=f.C0.NUL)):p.keyCode===65&&(C.type=1);else{const S=m[p.keyCode],b=S==null?void 0:S[p.shiftKey?1:0];if(b)C.key=f.C0.ESC+b;else if(p.keyCode>=65&&p.keyCode<=90){const y=p.ctrlKey?p.keyCode-64:p.keyCode+32;let E=String.fromCharCode(y);p.shiftKey&&(E=E.toUpperCase()),C.key=f.C0.ESC+E}else if(p.keyCode===32)C.key=f.C0.ESC+(p.ctrlKey?f.C0.NUL:" ");else if(p.key==="Dead"&&p.code.startsWith("Key")){let y=p.code.slice(3,4);p.shiftKey||(y=y.toLowerCase()),C.key=f.C0.ESC+y,C.cancel=!0}}else p.keyCode>=65&&p.keyCode<=90?C.key=String.fromCharCode(p.keyCode-64):p.keyCode===32?C.key=f.C0.NUL:p.keyCode>=51&&p.keyCode<=55?C.key=String.fromCharCode(p.keyCode-51+27):p.keyCode===56?C.key=f.C0.DEL:p.keyCode===219?C.key=f.C0.ESC:p.keyCode===220?C.key=f.C0.FS:p.keyCode===221&&(C.key=f.C0.GS)}return C}},482:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.Utf8ToUtf32=c.StringToUtf32=c.utf32ToString=c.stringFromCodePoint=void 0,c.stringFromCodePoint=function(d){return d>65535?(d-=65536,String.fromCharCode(55296+(d>>10))+String.fromCharCode(d%1024+56320)):String.fromCharCode(d)},c.utf32ToString=function(d,f=0,m=d.length){let p="";for(let _=f;_<m;++_){let x=d[_];x>65535?(x-=65536,p+=String.fromCharCode(55296+(x>>10))+String.fromCharCode(x%1024+56320)):p+=String.fromCharCode(x)}return p},c.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(d,f){const m=d.length;if(!m)return 0;let p=0,_=0;if(this._interim){const x=d.charCodeAt(_++);56320<=x&&x<=57343?f[p++]=1024*(this._interim-55296)+x-56320+65536:(f[p++]=this._interim,f[p++]=x),this._interim=0}for(let x=_;x<m;++x){const w=d.charCodeAt(x);if(55296<=w&&w<=56319){if(++x>=m)return this._interim=w,p;const C=d.charCodeAt(x);56320<=C&&C<=57343?f[p++]=1024*(w-55296)+C-56320+65536:(f[p++]=w,f[p++]=C)}else w!==65279&&(f[p++]=w)}return p}},c.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(d,f){const m=d.length;if(!m)return 0;let p,_,x,w,C=0,v=0,S=0;if(this.interim[0]){let E=!1,N=this.interim[0];N&=(224&N)==192?31:(240&N)==224?15:7;let T,L=0;for(;(T=63&this.interim[++L])&&L<4;)N<<=6,N|=T;const A=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,R=A-L;for(;S<R;){if(S>=m)return 0;if(T=d[S++],(192&T)!=128){S--,E=!0;break}this.interim[L++]=T,N<<=6,N|=63&T}E||(A===2?N<128?S--:f[C++]=N:A===3?N<2048||N>=55296&&N<=57343||N===65279||(f[C++]=N):N<65536||N>1114111||(f[C++]=N)),this.interim.fill(0)}const b=m-4;let y=S;for(;y<m;){for(;!(!(y<b)||128&(p=d[y])||128&(_=d[y+1])||128&(x=d[y+2])||128&(w=d[y+3]));)f[C++]=p,f[C++]=_,f[C++]=x,f[C++]=w,y+=4;if(p=d[y++],p<128)f[C++]=p;else if((224&p)==192){if(y>=m)return this.interim[0]=p,C;if(_=d[y++],(192&_)!=128){y--;continue}if(v=(31&p)<<6|63&_,v<128){y--;continue}f[C++]=v}else if((240&p)==224){if(y>=m)return this.interim[0]=p,C;if(_=d[y++],(192&_)!=128){y--;continue}if(y>=m)return this.interim[0]=p,this.interim[1]=_,C;if(x=d[y++],(192&x)!=128){y--;continue}if(v=(15&p)<<12|(63&_)<<6|63&x,v<2048||v>=55296&&v<=57343||v===65279)continue;f[C++]=v}else if((248&p)==240){if(y>=m)return this.interim[0]=p,C;if(_=d[y++],(192&_)!=128){y--;continue}if(y>=m)return this.interim[0]=p,this.interim[1]=_,C;if(x=d[y++],(192&x)!=128){y--;continue}if(y>=m)return this.interim[0]=p,this.interim[1]=_,this.interim[2]=x,C;if(w=d[y++],(192&w)!=128){y--;continue}if(v=(7&p)<<18|(63&_)<<12|(63&x)<<6|63&w,v<65536||v>1114111)continue;f[C++]=v}}return C}}},225:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.UnicodeV6=void 0;const f=d(1480),m=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],p=[[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<m.length;++x)_.fill(0,m[x][0],m[x][1]+1)}}wcwidth(x){return x<32?0:x<127?1:x<65536?_[x]:(function(w,C){let v,S=0,b=C.length-1;if(w<C[0][0]||w>C[b][1])return!1;for(;b>=S;)if(v=S+b>>1,w>C[v][1])S=v+1;else{if(!(w<C[v][0]))return!0;b=v-1}return!1})(x,p)?0:x>=131072&&x<=196605||x>=196608&&x<=262141?2:1}charProperties(x,w){let C=this.wcwidth(x),v=C===0&&w!==0;if(v){const S=f.UnicodeService.extractWidth(w);S===0?v=!1:S>C&&(C=S)}return f.UnicodeService.createPropertyValue(0,C,v)}}},5981:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.WriteBuffer=void 0;const f=d(8460),m=d(844);class p extends m.Disposable{constructor(x){super(),this._action=x,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this.register(new 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 C;for(this._isSyncWriting=!0;C=this._writeBuffer.shift();){this._action(C);const v=this._callbacks.shift();v&&v()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(x,w){if(this._pendingData>5e7)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput)return this._didUserInput=!1,this._pendingData+=x.length,this._writeBuffer.push(x),this._callbacks.push(w),void this._innerWrite();setTimeout((()=>this._innerWrite()))}this._pendingData+=x.length,this._writeBuffer.push(x),this._callbacks.push(w)}_innerWrite(x=0,w=!0){const C=x||Date.now();for(;this._writeBuffer.length>this._bufferOffset;){const v=this._writeBuffer[this._bufferOffset],S=this._action(v,w);if(S){const y=E=>Date.now()-C>=12?setTimeout((()=>this._innerWrite(0,E))):this._innerWrite(C,E);return void S.catch((E=>(queueMicrotask((()=>{throw E})),Promise.resolve(!1)))).then(y)}const b=this._callbacks[this._bufferOffset];if(b&&b(),this._bufferOffset++,this._pendingData-=v.length,Date.now()-C>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout((()=>this._innerWrite()))):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}}c.WriteBuffer=p},5941:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.toRgbString=c.parseColor=void 0;const d=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,f=/^[\da-f]+$/;function m(p,_){const x=p.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(p){if(!p)return;let _=p.toLowerCase();if(_.indexOf("rgb:")===0){_=_.slice(4);const x=d.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 C=0;C<3;++C){const v=parseInt(_.slice(x*C,x*C+x),16);w[C]=x===1?v<<4:x===2?v:x===3?v>>4:v>>8}return w}},c.toRgbString=function(p,_=16){const[x,w,C]=p;return`rgb:${m(x,_)}/${m(w,_)}/${m(C,_)}`}},5770:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.PAYLOAD_LIMIT=void 0,c.PAYLOAD_LIMIT=1e7},6351:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.DcsHandler=c.DcsParser=void 0;const f=d(482),m=d(8742),p=d(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,C){this._handlers[w]===void 0&&(this._handlers[w]=[]);const v=this._handlers[w];return v.push(C),{dispose:()=>{const S=v.indexOf(C);S!==-1&&v.splice(S,1)}}}clearHandler(w){this._handlers[w]&&delete this._handlers[w]}setHandlerFallback(w){this._handlerFb=w}reset(){if(this._active.length)for(let w=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;w>=0;--w)this._active[w].unhook(!1);this._stack.paused=!1,this._active=_,this._ident=0}hook(w,C){if(this.reset(),this._ident=w,this._active=this._handlers[w]||_,this._active.length)for(let v=this._active.length-1;v>=0;v--)this._active[v].hook(C);else this._handlerFb(this._ident,"HOOK",C)}put(w,C,v){if(this._active.length)for(let S=this._active.length-1;S>=0;S--)this._active[S].put(w,C,v);else this._handlerFb(this._ident,"PUT",(0,f.utf32ToString)(w,C,v))}unhook(w,C=!0){if(this._active.length){let v=!1,S=this._active.length-1,b=!1;if(this._stack.paused&&(S=this._stack.loopPosition-1,v=C,b=this._stack.fallThrough,this._stack.paused=!1),!b&&v===!1){for(;S>=0&&(v=this._active[S].unhook(w),v!==!0);S--)if(v instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=S,this._stack.fallThrough=!1,v;S--}for(;S>=0;S--)if(v=this._active[S].unhook(!1),v instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=S,this._stack.fallThrough=!0,v}else this._handlerFb(this._ident,"UNHOOK",w);this._active=_,this._ident=0}};const x=new m.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,C,v){this._hitLimit||(this._data+=(0,f.utf32ToString)(w,C,v),this._data.length>p.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(w){let C=!1;if(this._hitLimit)C=!1;else if(w&&(C=this._handler(this._data,this._params),C instanceof Promise))return C.then((v=>(this._params=x,this._data="",this._hitLimit=!1,v)));return this._params=x,this._data="",this._hitLimit=!1,C}}},2015:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.EscapeSequenceParser=c.VT500_TRANSITION_TABLE=c.TransitionTable=void 0;const f=d(844),m=d(8742),p=d(6242),_=d(6351);class x{constructor(S){this.table=new Uint8Array(S)}setDefault(S,b){this.table.fill(S<<4|b)}add(S,b,y,E){this.table[b<<8|S]=y<<4|E}addMany(S,b,y,E){for(let N=0;N<S.length;N++)this.table[b<<8|S[N]]=y<<4|E}}c.TransitionTable=x;const w=160;c.VT500_TRANSITION_TABLE=(function(){const v=new x(4095),S=Array.apply(null,Array(256)).map(((L,A)=>A)),b=(L,A)=>S.slice(L,A),y=b(32,127),E=b(0,24);E.push(25),E.push.apply(E,b(28,32));const N=b(0,14);let T;for(T in v.setDefault(1,0),v.addMany(y,0,2,0),N)v.addMany([24,26,153,154],T,3,0),v.addMany(b(128,144),T,3,0),v.addMany(b(144,152),T,3,0),v.add(156,T,0,0),v.add(27,T,11,1),v.add(157,T,4,8),v.addMany([152,158,159],T,0,7),v.add(155,T,11,3),v.add(144,T,11,9);return v.addMany(E,0,3,0),v.addMany(E,1,3,1),v.add(127,1,0,1),v.addMany(E,8,0,8),v.addMany(E,3,3,3),v.add(127,3,0,3),v.addMany(E,4,3,4),v.add(127,4,0,4),v.addMany(E,6,3,6),v.addMany(E,5,3,5),v.add(127,5,0,5),v.addMany(E,2,3,2),v.add(127,2,0,2),v.add(93,1,4,8),v.addMany(y,8,5,8),v.add(127,8,5,8),v.addMany([156,27,24,26,7],8,6,0),v.addMany(b(28,32),8,0,8),v.addMany([88,94,95],1,0,7),v.addMany(y,7,0,7),v.addMany(E,7,0,7),v.add(156,7,0,0),v.add(127,7,0,7),v.add(91,1,11,3),v.addMany(b(64,127),3,7,0),v.addMany(b(48,60),3,8,4),v.addMany([60,61,62,63],3,9,4),v.addMany(b(48,60),4,8,4),v.addMany(b(64,127),4,7,0),v.addMany([60,61,62,63],4,0,6),v.addMany(b(32,64),6,0,6),v.add(127,6,0,6),v.addMany(b(64,127),6,0,0),v.addMany(b(32,48),3,9,5),v.addMany(b(32,48),5,9,5),v.addMany(b(48,64),5,0,6),v.addMany(b(64,127),5,7,0),v.addMany(b(32,48),4,9,5),v.addMany(b(32,48),1,9,2),v.addMany(b(32,48),2,9,2),v.addMany(b(48,127),2,10,0),v.addMany(b(48,80),1,10,0),v.addMany(b(81,88),1,10,0),v.addMany([89,90,92],1,10,0),v.addMany(b(96,127),1,10,0),v.add(80,1,11,9),v.addMany(E,9,0,9),v.add(127,9,0,9),v.addMany(b(28,32),9,0,9),v.addMany(b(32,48),9,9,12),v.addMany(b(48,60),9,8,10),v.addMany([60,61,62,63],9,9,10),v.addMany(E,11,0,11),v.addMany(b(32,128),11,0,11),v.addMany(b(28,32),11,0,11),v.addMany(E,10,0,10),v.add(127,10,0,10),v.addMany(b(28,32),10,0,10),v.addMany(b(48,60),10,8,10),v.addMany([60,61,62,63],10,0,11),v.addMany(b(32,48),10,9,12),v.addMany(E,12,0,12),v.add(127,12,0,12),v.addMany(b(28,32),12,0,12),v.addMany(b(32,48),12,9,12),v.addMany(b(48,64),12,0,11),v.addMany(b(64,127),12,12,13),v.addMany(b(64,127),10,12,13),v.addMany(b(64,127),9,12,13),v.addMany(E,13,13,13),v.addMany(y,13,13,13),v.add(127,13,0,13),v.addMany([27,156,24,26],13,14,0),v.add(w,0,2,0),v.add(w,8,5,8),v.add(w,6,0,6),v.add(w,11,0,11),v.add(w,13,13,13),v})();class C extends 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 m.Params,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(b,y,E)=>{},this._executeHandlerFb=b=>{},this._csiHandlerFb=(b,y)=>{},this._escHandlerFb=b=>{},this._errorHandlerFb=b=>b,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 p.OscParser),this._dcsParser=this.register(new _.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},(()=>!0))}_identifier(S,b=[64,126]){let y=0;if(S.prefix){if(S.prefix.length>1)throw new Error("only one byte as prefix supported");if(y=S.prefix.charCodeAt(0),y&&60>y||y>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 N=0;N<S.intermediates.length;++N){const T=S.intermediates.charCodeAt(N);if(32>T||T>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");y<<=8,y|=T}}if(S.final.length!==1)throw new Error("final must be a single byte");const E=S.final.charCodeAt(0);if(b[0]>E||E>b[1])throw new Error(`final must be in range ${b[0]} .. ${b[1]}`);return y<<=8,y|=E,y}identToString(S){const b=[];for(;S;)b.push(String.fromCharCode(255&S)),S>>=8;return b.reverse().join("")}setPrintHandler(S){this._printHandler=S}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(S,b){const y=this._identifier(S,[48,126]);this._escHandlers[y]===void 0&&(this._escHandlers[y]=[]);const E=this._escHandlers[y];return E.push(b),{dispose:()=>{const N=E.indexOf(b);N!==-1&&E.splice(N,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,b){this._executeHandlers[S.charCodeAt(0)]=b}clearExecuteHandler(S){this._executeHandlers[S.charCodeAt(0)]&&delete this._executeHandlers[S.charCodeAt(0)]}setExecuteHandlerFallback(S){this._executeHandlerFb=S}registerCsiHandler(S,b){const y=this._identifier(S);this._csiHandlers[y]===void 0&&(this._csiHandlers[y]=[]);const E=this._csiHandlers[y];return E.push(b),{dispose:()=>{const N=E.indexOf(b);N!==-1&&E.splice(N,1)}}}clearCsiHandler(S){this._csiHandlers[this._identifier(S)]&&delete this._csiHandlers[this._identifier(S)]}setCsiHandlerFallback(S){this._csiHandlerFb=S}registerDcsHandler(S,b){return this._dcsParser.registerHandler(this._identifier(S),b)}clearDcsHandler(S){this._dcsParser.clearHandler(this._identifier(S))}setDcsHandlerFallback(S){this._dcsParser.setHandlerFallback(S)}registerOscHandler(S,b){return this._oscParser.registerHandler(S,b)}clearOscHandler(S){this._oscParser.clearHandler(S)}setOscHandlerFallback(S){this._oscParser.setHandlerFallback(S)}setErrorHandler(S){this._errorHandler=S}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(S,b,y,E,N){this._parseStack.state=S,this._parseStack.handlers=b,this._parseStack.handlerPos=y,this._parseStack.transition=E,this._parseStack.chunkPos=N}parse(S,b,y){let E,N=0,T=0,L=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,L=this._parseStack.chunkPos+1;else{if(y===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");const A=this._parseStack.handlers;let R=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(y===!1&&R>-1){for(;R>=0&&(E=A[R](this._params),E!==!0);R--)if(E instanceof Promise)return this._parseStack.handlerPos=R,E}this._parseStack.handlers=[];break;case 4:if(y===!1&&R>-1){for(;R>=0&&(E=A[R](),E!==!0);R--)if(E instanceof Promise)return this._parseStack.handlerPos=R,E}this._parseStack.handlers=[];break;case 6:if(N=S[this._parseStack.chunkPos],E=this._dcsParser.unhook(N!==24&&N!==26,y),E)return E;N===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(N=S[this._parseStack.chunkPos],E=this._oscParser.end(N!==24&&N!==26,y),E)return E;N===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<b;++A){switch(N=S[A],T=this._transitions.table[this.currentState<<8|(N<160?N:w)],T>>4){case 2:for(let O=A+1;;++O){if(O>=b||(N=S[O])<32||N>126&&N<w){this._printHandler(S,A,O),A=O-1;break}if(++O>=b||(N=S[O])<32||N>126&&N<w){this._printHandler(S,A,O),A=O-1;break}if(++O>=b||(N=S[O])<32||N>126&&N<w){this._printHandler(S,A,O),A=O-1;break}if(++O>=b||(N=S[O])<32||N>126&&N<w){this._printHandler(S,A,O),A=O-1;break}}break;case 3:this._executeHandlers[N]?this._executeHandlers[N]():this._executeHandlerFb(N),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:A,code:N,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:const R=this._csiHandlers[this._collect<<8|N];let M=R?R.length-1:-1;for(;M>=0&&(E=R[M](this._params),E!==!0);M--)if(E instanceof Promise)return this._preserveStack(3,R,M,T,A),E;M<0&&this._csiHandlerFb(this._collect<<8|N,this._params),this.precedingJoinState=0;break;case 8:do switch(N){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(N-48)}while(++A<b&&(N=S[A])>47&&N<60);A--;break;case 9:this._collect<<=8,this._collect|=N;break;case 10:const G=this._escHandlers[this._collect<<8|N];let W=G?G.length-1:-1;for(;W>=0&&(E=G[W](),E!==!0);W--)if(E instanceof Promise)return this._preserveStack(4,G,W,T,A),E;W<0&&this._escHandlerFb(this._collect<<8|N),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|N,this._params);break;case 13:for(let O=A+1;;++O)if(O>=b||(N=S[O])===24||N===26||N===27||N>127&&N<w){this._dcsParser.put(S,A,O),A=O-1;break}break;case 14:if(E=this._dcsParser.unhook(N!==24&&N!==26),E)return this._preserveStack(6,[],0,T,A),E;N===27&&(T|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let O=A+1;;O++)if(O>=b||(N=S[O])<32||N>127&&N<w){this._oscParser.put(S,A,O),A=O-1;break}break;case 6:if(E=this._oscParser.end(N!==24&&N!==26),E)return this._preserveStack(5,[],0,T,A),E;N===27&&(T|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=15&T}}}c.EscapeSequenceParser=C},6242:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.OscHandler=c.OscParser=void 0;const f=d(5770),m=d(482),p=[];c.OscParser=class{constructor(){this._state=0,this._active=p,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 C=w.indexOf(x);C!==-1&&w.splice(C,1)}}}clearHandler(_){this._handlers[_]&&delete this._handlers[_]}setHandlerFallback(_){this._handlerFb=_}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=p}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=p,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||p,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 C=this._active.length-1;C>=0;C--)this._active[C].put(_,x,w);else this._handlerFb(this._id,"PUT",(0,m.utf32ToString)(_,x,w))}start(){this.reset(),this._state=1}put(_,x,w){if(this._state!==3){if(this._state===1)for(;x<w;){const C=_[x++];if(C===59){this._state=2,this._start();break}if(C<48||57<C)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+C-48}this._state===2&&w-x>0&&this._put(_,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,C=this._active.length-1,v=!1;if(this._stack.paused&&(C=this._stack.loopPosition-1,w=x,v=this._stack.fallThrough,this._stack.paused=!1),!v&&w===!1){for(;C>=0&&(w=this._active[C].end(_),w!==!0);C--)if(w instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=C,this._stack.fallThrough=!1,w;C--}for(;C>=0;C--)if(w=this._active[C].end(!1),w instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=C,this._stack.fallThrough=!0,w}else this._handlerFb(this._id,"END",_);this._active=p,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,m.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 d=2147483647;class f{static fromArray(p){const _=new f;if(!p.length)return _;for(let x=Array.isArray(p[0])?1:0;x<p.length;++x){const w=p[x];if(Array.isArray(w))for(let C=0;C<w.length;++C)_.addSubParam(w[C]);else _.addParam(w)}return _}constructor(p=32,_=32){if(this.maxLength=p,this.maxSubParamsLength=_,_>256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(p),this.length=0,this._subParams=new Int32Array(_),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(p),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}clone(){const p=new f(this.maxLength,this.maxSubParamsLength);return p.params.set(this.params),p.length=this.length,p._subParams.set(this._subParams),p._subParamsLength=this._subParamsLength,p._subParamsIdx.set(this._subParamsIdx),p._rejectDigits=this._rejectDigits,p._rejectSubDigits=this._rejectSubDigits,p._digitIsSub=this._digitIsSub,p}toArray(){const p=[];for(let _=0;_<this.length;++_){p.push(this.params[_]);const x=this._subParamsIdx[_]>>8,w=255&this._subParamsIdx[_];w-x>0&&p.push(Array.prototype.slice.call(this._subParams,x,w))}return p}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(p){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(p<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=p>d?d:p}}addSubParam(p){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(p<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=p>d?d:p,this._subParamsIdx[this.length-1]++}}hasSubParams(p){return(255&this._subParamsIdx[p])-(this._subParamsIdx[p]>>8)>0}getSubParams(p){const _=this._subParamsIdx[p]>>8,x=255&this._subParamsIdx[p];return x-_>0?this._subParams.subarray(_,x):null}getSubParamsAll(){const p={};for(let _=0;_<this.length;++_){const x=this._subParamsIdx[_]>>8,w=255&this._subParamsIdx[_];w-x>0&&(p[_]=this._subParams.slice(x,w))}return p}addDigit(p){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+p,d):p}}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 d=this._addons.length-1;d>=0;d--)this._addons[d].instance.dispose()}loadAddon(d,f){const m={instance:f,dispose:f.dispose,isDisposed:!1};this._addons.push(m),f.dispose=()=>this._wrappedAddonDispose(m),f.activate(d)}_wrappedAddonDispose(d){if(d.isDisposed)return;let f=-1;for(let m=0;m<this._addons.length;m++)if(this._addons[m]===d){f=m;break}if(f===-1)throw new Error("Could not dispose an addon that has not been loaded");d.isDisposed=!0,d.dispose.apply(d.instance),this._addons.splice(f,1)}}},8771:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.BufferApiView=void 0;const f=d(3785),m=d(511);c.BufferApiView=class{constructor(p,_){this._buffer=p,this.type=_}init(p){return this._buffer=p,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(p){const _=this._buffer.lines.get(p);if(_)return new f.BufferLineApiView(_)}getNullCell(){return new m.CellData}}},3785:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.BufferLineApiView=void 0;const f=d(511);c.BufferLineApiView=class{constructor(m){this._line=m}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(m,p){if(!(m<0||m>=this._line.length))return p?(this._line.loadCell(m,p),p):this._line.loadCell(m,new f.CellData)}translateToString(m,p,_){return this._line.translateToString(m,p,_)}}},8285:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.BufferNamespaceApi=void 0;const f=d(8771),m=d(8460),p=d(844);class _ extends p.Disposable{constructor(w){super(),this._core=w,this._onBufferChange=this.register(new m.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(d){this._core=d}registerCsiHandler(d,f){return this._core.registerCsiHandler(d,(m=>f(m.toArray())))}addCsiHandler(d,f){return this.registerCsiHandler(d,f)}registerDcsHandler(d,f){return this._core.registerDcsHandler(d,((m,p)=>f(m,p.toArray())))}addDcsHandler(d,f){return this.registerDcsHandler(d,f)}registerEscHandler(d,f){return this._core.registerEscHandler(d,f)}addEscHandler(d,f){return this.registerEscHandler(d,f)}registerOscHandler(d,f){return this._core.registerOscHandler(d,f)}addOscHandler(d,f){return this.registerOscHandler(d,f)}}},7090:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.UnicodeApi=void 0,c.UnicodeApi=class{constructor(d){this._core=d}register(d){this._core.unicodeService.register(d)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(d){this._core.unicodeService.activeVersion=d}}},744:function(u,c,d){var f=this&&this.__decorate||function(v,S,b,y){var E,N=arguments.length,T=N<3?S:y===null?y=Object.getOwnPropertyDescriptor(S,b):y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")T=Reflect.decorate(v,S,b,y);else for(var L=v.length-1;L>=0;L--)(E=v[L])&&(T=(N<3?E(T):N>3?E(S,b,T):E(S,b))||T);return N>3&&T&&Object.defineProperty(S,b,T),T},m=this&&this.__param||function(v,S){return function(b,y){S(b,y,v)}};Object.defineProperty(c,"__esModule",{value:!0}),c.BufferService=c.MINIMUM_ROWS=c.MINIMUM_COLS=void 0;const p=d(8460),_=d(844),x=d(5295),w=d(2585);c.MINIMUM_COLS=2,c.MINIMUM_ROWS=1;let C=c.BufferService=class extends _.Disposable{get buffer(){return this.buffers.active}constructor(v){super(),this.isUserScrolling=!1,this._onResize=this.register(new p.EventEmitter),this.onResize=this._onResize.event,this._onScroll=this.register(new p.EventEmitter),this.onScroll=this._onScroll.event,this.cols=Math.max(v.rawOptions.cols||0,c.MINIMUM_COLS),this.rows=Math.max(v.rawOptions.rows||0,c.MINIMUM_ROWS),this.buffers=this.register(new x.BufferSet(v,this))}resize(v,S){this.cols=v,this.rows=S,this.buffers.resize(v,S),this._onResize.fire({cols:v,rows:S})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(v,S=!1){const b=this.buffer;let y;y=this._cachedBlankLine,y&&y.length===this.cols&&y.getFg(0)===v.fg&&y.getBg(0)===v.bg||(y=b.getBlankLine(v,S),this._cachedBlankLine=y),y.isWrapped=S;const E=b.ybase+b.scrollTop,N=b.ybase+b.scrollBottom;if(b.scrollTop===0){const T=b.lines.isFull;N===b.lines.length-1?T?b.lines.recycle().copyFrom(y):b.lines.push(y.clone()):b.lines.splice(N+1,0,y.clone()),T?this.isUserScrolling&&(b.ydisp=Math.max(b.ydisp-1,0)):(b.ybase++,this.isUserScrolling||b.ydisp++)}else{const T=N-E+1;b.lines.shiftElements(E+1,T-1,-1),b.lines.set(N,y.clone())}this.isUserScrolling||(b.ydisp=b.ybase),this._onScroll.fire(b.ydisp)}scrollLines(v,S,b){const y=this.buffer;if(v<0){if(y.ydisp===0)return;this.isUserScrolling=!0}else v+y.ydisp>=y.ybase&&(this.isUserScrolling=!1);const E=y.ydisp;y.ydisp=Math.max(Math.min(y.ydisp+v,y.ybase),0),E!==y.ydisp&&(S||this._onScroll.fire(y.ydisp))}};c.BufferService=C=f([m(0,w.IOptionsService)],C)},7994:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.CharsetService=void 0,c.CharsetService=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(d){this.glevel=d,this.charset=this._charsets[d]}setgCharset(d,f){this._charsets[d]=f,this.glevel===d&&(this.charset=f)}}},1753:function(u,c,d){var f=this&&this.__decorate||function(y,E,N,T){var L,A=arguments.length,R=A<3?E:T===null?T=Object.getOwnPropertyDescriptor(E,N):T;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(y,E,N,T);else for(var M=y.length-1;M>=0;M--)(L=y[M])&&(R=(A<3?L(R):A>3?L(E,N,R):L(E,N))||R);return A>3&&R&&Object.defineProperty(E,N,R),R},m=this&&this.__param||function(y,E){return function(N,T){E(N,T,y)}};Object.defineProperty(c,"__esModule",{value:!0}),c.CoreMouseService=void 0;const p=d(2585),_=d(8460),x=d(844),w={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:y=>y.button!==4&&y.action===1&&(y.ctrl=!1,y.alt=!1,y.shift=!1,!0)},VT200:{events:19,restrict:y=>y.action!==32},DRAG:{events:23,restrict:y=>y.action!==32||y.button!==3},ANY:{events:31,restrict:y=>!0}};function C(y,E){let N=(y.ctrl?16:0)|(y.shift?4:0)|(y.alt?8:0);return y.button===4?(N|=64,N|=y.action):(N|=3&y.button,4&y.button&&(N|=64),8&y.button&&(N|=128),y.action===32?N|=32:y.action!==0||E||(N|=3)),N}const v=String.fromCharCode,S={DEFAULT:y=>{const E=[C(y,!1)+32,y.col+32,y.row+32];return E[0]>255||E[1]>255||E[2]>255?"":`\x1B[M${v(E[0])}${v(E[1])}${v(E[2])}`},SGR:y=>{const E=y.action===0&&y.button!==4?"m":"M";return`\x1B[<${C(y,!0)};${y.col};${y.row}${E}`},SGR_PIXELS:y=>{const E=y.action===0&&y.button!==4?"m":"M";return`\x1B[<${C(y,!0)};${y.x};${y.y}${E}`}};let b=c.CoreMouseService=class extends x.Disposable{constructor(y,E){super(),this._bufferService=y,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 N of Object.keys(w))this.addProtocol(N,w[N]);for(const N of Object.keys(S))this.addEncoding(N,S[N]);this.reset()}addProtocol(y,E){this._protocols[y]=E}addEncoding(y,E){this._encodings[y]=E}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(y){if(!this._protocols[y])throw new Error(`unknown protocol "${y}"`);this._activeProtocol=y,this._onProtocolChange.fire(this._protocols[y].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(y){if(!this._encodings[y])throw new Error(`unknown encoding "${y}"`);this._activeEncoding=y}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null}triggerMouseEvent(y){if(y.col<0||y.col>=this._bufferService.cols||y.row<0||y.row>=this._bufferService.rows||y.button===4&&y.action===32||y.button===3&&y.action!==32||y.button!==4&&(y.action===2||y.action===3)||(y.col++,y.row++,y.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,y,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(y))return!1;const E=this._encodings[this._activeEncoding](y);return E&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(E):this._coreService.triggerDataEvent(E,!0)),this._lastEvent=y,!0}explainEvents(y){return{down:!!(1&y),up:!!(2&y),drag:!!(4&y),move:!!(8&y),wheel:!!(16&y)}}_equalEvents(y,E,N){if(N){if(y.x!==E.x||y.y!==E.y)return!1}else if(y.col!==E.col||y.row!==E.row)return!1;return y.button===E.button&&y.action===E.action&&y.ctrl===E.ctrl&&y.alt===E.alt&&y.shift===E.shift}};c.CoreMouseService=b=f([m(0,p.IBufferService),m(1,p.ICoreService)],b)},6975:function(u,c,d){var f=this&&this.__decorate||function(b,y,E,N){var T,L=arguments.length,A=L<3?y:N===null?N=Object.getOwnPropertyDescriptor(y,E):N;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(b,y,E,N);else for(var R=b.length-1;R>=0;R--)(T=b[R])&&(A=(L<3?T(A):L>3?T(y,E,A):T(y,E))||A);return L>3&&A&&Object.defineProperty(y,E,A),A},m=this&&this.__param||function(b,y){return function(E,N){y(E,N,b)}};Object.defineProperty(c,"__esModule",{value:!0}),c.CoreService=void 0;const p=d(1439),_=d(8460),x=d(844),w=d(2585),C=Object.freeze({insertMode:!1}),v=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0});let S=c.CoreService=class extends x.Disposable{constructor(b,y,E){super(),this._bufferService=b,this._logService=y,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,p.clone)(C),this.decPrivateModes=(0,p.clone)(v)}reset(){this.modes=(0,p.clone)(C),this.decPrivateModes=(0,p.clone)(v)}triggerDataEvent(b,y=!1){if(this._optionsService.rawOptions.disableStdin)return;const E=this._bufferService.buffer;y&&this._optionsService.rawOptions.scrollOnUserInput&&E.ybase!==E.ydisp&&this._onRequestScrollToBottom.fire(),y&&this._onUserInput.fire(),this._logService.debug(`sending data "${b}"`,(()=>b.split("").map((N=>N.charCodeAt(0))))),this._onData.fire(b)}triggerBinaryEvent(b){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${b}"`,(()=>b.split("").map((y=>y.charCodeAt(0))))),this._onBinary.fire(b))}};c.CoreService=S=f([m(0,w.IBufferService),m(1,w.ILogService),m(2,w.IOptionsService)],S)},9074:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.DecorationService=void 0;const f=d(8055),m=d(8460),p=d(844),_=d(6106);let x=0,w=0;class C extends p.Disposable{get decorations(){return this._decorations.values()}constructor(){super(),this._decorations=new _.SortedList((b=>b==null?void 0:b.marker.line)),this._onDecorationRegistered=this.register(new m.EventEmitter),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this.register(new m.EventEmitter),this.onDecorationRemoved=this._onDecorationRemoved.event,this.register((0,p.toDisposable)((()=>this.reset())))}registerDecoration(b){if(b.marker.isDisposed)return;const y=new v(b);if(y){const E=y.marker.onDispose((()=>y.dispose()));y.onDispose((()=>{y&&(this._decorations.delete(y)&&this._onDecorationRemoved.fire(y),E.dispose())})),this._decorations.insert(y),this._onDecorationRegistered.fire(y)}return y}reset(){for(const b of this._decorations.values())b.dispose();this._decorations.clear()}*getDecorationsAtCell(b,y,E){let N=0,T=0;for(const L of this._decorations.getKeyIterator(y))N=L.options.x??0,T=N+(L.options.width??1),b>=N&&b<T&&(!E||(L.options.layer??"bottom")===E)&&(yield L)}forEachDecorationAtCell(b,y,E,N){this._decorations.forEachByKey(y,(T=>{x=T.options.x??0,w=x+(T.options.width??1),b>=x&&b<w&&(!E||(T.options.layer??"bottom")===E)&&N(T)}))}}c.DecorationService=C;class v extends p.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(b){super(),this.options=b,this.onRenderEmitter=this.register(new m.EventEmitter),this.onRender=this.onRenderEmitter.event,this._onDispose=this.register(new m.EventEmitter),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=b.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}dispose(){this._onDispose.fire(),super.dispose()}}},4348:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.InstantiationService=c.ServiceCollection=void 0;const f=d(2585),m=d(8343);class p{constructor(...x){this._entries=new Map;for(const[w,C]of x)this.set(w,C)}set(x,w){const C=this._entries.get(x);return this._entries.set(x,w),C}forEach(x){for(const[w,C]of this._entries.entries())x(w,C)}has(x){return this._entries.has(x)}get(x){return this._entries.get(x)}}c.ServiceCollection=p,c.InstantiationService=class{constructor(){this._services=new p,this._services.set(f.IInstantiationService,this)}setService(_,x){this._services.set(_,x)}getService(_){return this._services.get(_)}createInstance(_,...x){const w=(0,m.getServiceDependencies)(_).sort(((S,b)=>S.index-b.index)),C=[];for(const S of w){const b=this._services.get(S.id);if(!b)throw new Error(`[createInstance] ${_.name} depends on UNKNOWN service ${S.id}.`);C.push(b)}const v=w.length>0?w[0].index:x.length;if(x.length!==v)throw new Error(`[createInstance] First service dependency of ${_.name} at position ${v+1} conflicts with ${x.length} static arguments`);return new _(...x,...C)}}},7866:function(u,c,d){var f=this&&this.__decorate||function(v,S,b,y){var E,N=arguments.length,T=N<3?S:y===null?y=Object.getOwnPropertyDescriptor(S,b):y;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")T=Reflect.decorate(v,S,b,y);else for(var L=v.length-1;L>=0;L--)(E=v[L])&&(T=(N<3?E(T):N>3?E(S,b,T):E(S,b))||T);return N>3&&T&&Object.defineProperty(S,b,T),T},m=this&&this.__param||function(v,S){return function(b,y){S(b,y,v)}};Object.defineProperty(c,"__esModule",{value:!0}),c.traceCall=c.setTraceLogger=c.LogService=void 0;const p=d(844),_=d(2585),x={trace:_.LogLevelEnum.TRACE,debug:_.LogLevelEnum.DEBUG,info:_.LogLevelEnum.INFO,warn:_.LogLevelEnum.WARN,error:_.LogLevelEnum.ERROR,off:_.LogLevelEnum.OFF};let w,C=c.LogService=class extends p.Disposable{get logLevel(){return this._logLevel}constructor(v){super(),this._optionsService=v,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(v){for(let S=0;S<v.length;S++)typeof v[S]=="function"&&(v[S]=v[S]())}_log(v,S,b){this._evalLazyOptionalParams(b),v.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+S,...b)}trace(v,...S){var b;this._logLevel<=_.LogLevelEnum.TRACE&&this._log(((b=this._optionsService.options.logger)==null?void 0:b.trace.bind(this._optionsService.options.logger))??console.log,v,S)}debug(v,...S){var b;this._logLevel<=_.LogLevelEnum.DEBUG&&this._log(((b=this._optionsService.options.logger)==null?void 0:b.debug.bind(this._optionsService.options.logger))??console.log,v,S)}info(v,...S){var b;this._logLevel<=_.LogLevelEnum.INFO&&this._log(((b=this._optionsService.options.logger)==null?void 0:b.info.bind(this._optionsService.options.logger))??console.info,v,S)}warn(v,...S){var b;this._logLevel<=_.LogLevelEnum.WARN&&this._log(((b=this._optionsService.options.logger)==null?void 0:b.warn.bind(this._optionsService.options.logger))??console.warn,v,S)}error(v,...S){var b;this._logLevel<=_.LogLevelEnum.ERROR&&this._log(((b=this._optionsService.options.logger)==null?void 0:b.error.bind(this._optionsService.options.logger))??console.error,v,S)}};c.LogService=C=f([m(0,_.IOptionsService)],C),c.setTraceLogger=function(v){w=v},c.traceCall=function(v,S,b){if(typeof b.value!="function")throw new Error("not supported");const y=b.value;b.value=function(...E){if(w.logLevel!==_.LogLevelEnum.TRACE)return y.apply(this,E);w.trace(`GlyphRenderer#${y.name}(${E.map((T=>JSON.stringify(T))).join(", ")})`);const N=y.apply(this,E);return w.trace(`GlyphRenderer#${y.name} return`,N),N}}},7302:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.OptionsService=c.DEFAULT_OPTIONS=void 0;const f=d(8460),m=d(844),p=d(6114);c.DEFAULT_OPTIONS={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"courier-new, courier, monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},rescaleOverlappingGlyphs:!1,rightClickSelectsWord:p.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 m.Disposable{constructor(C){super(),this._onOptionChange=this.register(new f.EventEmitter),this.onOptionChange=this._onOptionChange.event;const v={...c.DEFAULT_OPTIONS};for(const S in C)if(S in v)try{const b=C[S];v[S]=this._sanitizeAndValidateOption(S,b)}catch(b){console.error(b)}this.rawOptions=v,this.options={...v},this._setupOptions(),this.register((0,m.toDisposable)((()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null})))}onSpecificOptionChange(C,v){return this.onOptionChange((S=>{S===C&&v(this.rawOptions[C])}))}onMultipleOptionChange(C,v){return this.onOptionChange((S=>{C.indexOf(S)!==-1&&v()}))}_setupOptions(){const C=S=>{if(!(S in c.DEFAULT_OPTIONS))throw new Error(`No option with key "${S}"`);return this.rawOptions[S]},v=(S,b)=>{if(!(S in c.DEFAULT_OPTIONS))throw new Error(`No option with key "${S}"`);b=this._sanitizeAndValidateOption(S,b),this.rawOptions[S]!==b&&(this.rawOptions[S]=b,this._onOptionChange.fire(S))};for(const S in this.rawOptions){const b={get:C.bind(this,S),set:v.bind(this,S)};Object.defineProperty(this.options,S,b)}}_sanitizeAndValidateOption(C,v){switch(C){case"cursorStyle":if(v||(v=c.DEFAULT_OPTIONS[C]),!(function(S){return S==="block"||S==="underline"||S==="bar"})(v))throw new Error(`"${v}" is not a valid value for ${C}`);break;case"wordSeparator":v||(v=c.DEFAULT_OPTIONS[C]);break;case"fontWeight":case"fontWeightBold":if(typeof v=="number"&&1<=v&&v<=1e3)break;v=_.includes(v)?v:c.DEFAULT_OPTIONS[C];break;case"cursorWidth":v=Math.floor(v);case"lineHeight":case"tabStopWidth":if(v<1)throw new Error(`${C} cannot be less than 1, value: ${v}`);break;case"minimumContrastRatio":v=Math.max(1,Math.min(21,Math.round(10*v)/10));break;case"scrollback":if((v=Math.min(v,4294967295))<0)throw new Error(`${C} cannot be less than 0, value: ${v}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(v<=0)throw new Error(`${C} cannot be less than or equal to 0, value: ${v}`);break;case"rows":case"cols":if(!v&&v!==0)throw new Error(`${C} must be numeric, value: ${v}`);break;case"windowsPty":v=v??{}}return v}}c.OptionsService=x},2660:function(u,c,d){var f=this&&this.__decorate||function(x,w,C,v){var S,b=arguments.length,y=b<3?w:v===null?v=Object.getOwnPropertyDescriptor(w,C):v;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")y=Reflect.decorate(x,w,C,v);else for(var E=x.length-1;E>=0;E--)(S=x[E])&&(y=(b<3?S(y):b>3?S(w,C,y):S(w,C))||y);return b>3&&y&&Object.defineProperty(w,C,y),y},m=this&&this.__param||function(x,w){return function(C,v){w(C,v,x)}};Object.defineProperty(c,"__esModule",{value:!0}),c.OscLinkService=void 0;const p=d(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),N={data:x,id:this._nextId++,lines:[E]};return E.onDispose((()=>this._removeMarkerFromLink(N,E))),this._dataByLinkId.set(N.id,N),N.id}const C=x,v=this._getEntryIdKey(C),S=this._entriesWithId.get(v);if(S)return this.addLineToLink(S.id,w.ybase+w.y),S.id;const b=w.addMarker(w.ybase+w.y),y={id:this._nextId++,key:this._getEntryIdKey(C),data:C,lines:[b]};return b.onDispose((()=>this._removeMarkerFromLink(y,b))),this._entriesWithId.set(y.key,y),this._dataByLinkId.set(y.id,y),y.id}addLineToLink(x,w){const C=this._dataByLinkId.get(x);if(C&&C.lines.every((v=>v.line!==w))){const v=this._bufferService.buffer.addMarker(w);C.lines.push(v),v.onDispose((()=>this._removeMarkerFromLink(C,v)))}}getLinkData(x){var w;return(w=this._dataByLinkId.get(x))==null?void 0:w.data}_getEntryIdKey(x){return`${x.id};;${x.uri}`}_removeMarkerFromLink(x,w){const C=x.lines.indexOf(w);C!==-1&&(x.lines.splice(C,1),x.lines.length===0&&(x.data.id!==void 0&&this._entriesWithId.delete(x.key),this._dataByLinkId.delete(x.id)))}};c.OscLinkService=_=f([m(0,p.IBufferService)],_)},8343:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.createDecorator=c.getServiceDependencies=c.serviceRegistry=void 0;const d="di$target",f="di$dependencies";c.serviceRegistry=new Map,c.getServiceDependencies=function(m){return m[f]||[]},c.createDecorator=function(m){if(c.serviceRegistry.has(m))return c.serviceRegistry.get(m);const p=function(_,x,w){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(C,v,S){v[d]===v?v[f].push({id:C,index:S}):(v[f]=[{id:C,index:S}],v[d]=v)})(p,_,w)};return p.toString=()=>m,c.serviceRegistry.set(m,p),p}},2585:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.IDecorationService=c.IUnicodeService=c.IOscLinkService=c.IOptionsService=c.ILogService=c.LogLevelEnum=c.IInstantiationService=c.ICharsetService=c.ICoreService=c.ICoreMouseService=c.IBufferService=void 0;const f=d(8343);var m;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(p){p[p.TRACE=0]="TRACE",p[p.DEBUG=1]="DEBUG",p[p.INFO=2]="INFO",p[p.WARN=3]="WARN",p[p.ERROR=4]="ERROR",p[p.OFF=5]="OFF"})(m||(c.LogLevelEnum=m={})),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,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.UnicodeService=void 0;const f=d(8460),m=d(225);class p{static extractShouldJoin(x){return(1&x)!=0}static extractWidth(x){return x>>1&3}static extractCharKind(x){return x>>3}static createPropertyValue(x,w,C=!1){return(16777215&x)<<3|(3&w)<<1|(C?1:0)}constructor(){this._providers=Object.create(null),this._active="",this._onChange=new f.EventEmitter,this.onChange=this._onChange.event;const x=new m.UnicodeV6;this.register(x),this._active=x.version,this._activeProvider=x}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(x){if(!this._providers[x])throw new Error(`unknown Unicode version "${x}"`);this._active=x,this._activeProvider=this._providers[x],this._onChange.fire(x)}register(x){this._providers[x.version]=x}wcwidth(x){return this._activeProvider.wcwidth(x)}getStringCellWidth(x){let w=0,C=0;const v=x.length;for(let S=0;S<v;++S){let b=x.charCodeAt(S);if(55296<=b&&b<=56319){if(++S>=v)return w+this.wcwidth(b);const N=x.charCodeAt(S);56320<=N&&N<=57343?b=1024*(b-55296)+N-56320+65536:w+=this.wcwidth(N)}const y=this.charProperties(b,C);let E=p.extractWidth(y);p.extractShouldJoin(y)&&(E-=p.extractWidth(C)),w+=E,C=y}return w}charProperties(x,w){return this._activeProvider.charProperties(x,w)}}c.UnicodeService=p}},s={};function a(u){var c=s[u];if(c!==void 0)return c.exports;var d=s[u]={exports:{}};return n[u].call(d.exports,d,d.exports,a),d.exports}var l={};return(()=>{var u=l;Object.defineProperty(u,"__esModule",{value:!0}),u.Terminal=void 0;const c=a(9042),d=a(3236),f=a(844),m=a(5741),p=a(8285),_=a(7975),x=a(7090),w=["cols","rows"];class C extends f.Disposable{constructor(S){super(),this._core=this.register(new d.Terminal(S)),this._addonManager=this.register(new m.AddonManager),this._publicOptions={...this._core.options};const b=E=>this._core.options[E],y=(E,N)=>{this._checkReadonlyOptions(E),this._core.options[E]=N};for(const E in this._core.options){const N={get:b.bind(this,E),set:y.bind(this,E)};Object.defineProperty(this._publicOptions,E,N)}}_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 p.BufferNamespaceApi(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){const S=this._core.coreService.decPrivateModes;let b="none";switch(this._core.coreMouseService.activeProtocol){case"X10":b="x10";break;case"VT200":b="vt200";break;case"DRAG":b="drag";break;case"ANY":b="any"}return{applicationCursorKeysMode:S.applicationCursorKeys,applicationKeypadMode:S.applicationKeypad,bracketedPasteMode:S.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:b,originMode:S.origin,reverseWraparoundMode:S.reverseWraparound,sendFocusMode:S.sendFocus,wraparoundMode:S.wraparound}}get options(){return this._publicOptions}set options(S){for(const b in S)this._publicOptions[b]=S[b]}blur(){this._core.blur()}focus(){this._core.focus()}input(S,b=!0){this._core.input(S,b)}resize(S,b){this._verifyIntegers(S,b),this._core.resize(S,b)}open(S){this._core.open(S)}attachCustomKeyEventHandler(S){this._core.attachCustomKeyEventHandler(S)}attachCustomWheelEventHandler(S){this._core.attachCustomWheelEventHandler(S)}registerLinkProvider(S){return this._core.registerLinkProvider(S)}registerCharacterJoiner(S){return this._checkProposedApi(),this._core.registerCharacterJoiner(S)}deregisterCharacterJoiner(S){this._checkProposedApi(),this._core.deregisterCharacterJoiner(S)}registerMarker(S=0){return this._verifyIntegers(S),this._core.registerMarker(S)}registerDecoration(S){return this._checkProposedApi(),this._verifyPositiveIntegers(S.x??0,S.width??0,S.height??0),this._core.registerDecoration(S)}hasSelection(){return this._core.hasSelection()}select(S,b,y){this._verifyIntegers(S,b,y),this._core.select(S,b,y)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(S,b){this._verifyIntegers(S,b),this._core.selectLines(S,b)}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,b){this._core.write(S,b)}writeln(S,b){this._core.write(S),this._core.write(`\r
68
+ `,b)}paste(S){this._core.paste(S)}refresh(S,b){this._verifyIntegers(S,b),this._core.refresh(S,b)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(S){this._addonManager.loadAddon(this,S)}static get strings(){return c}_verifyIntegers(...S){for(const b of S)if(b===1/0||isNaN(b)||b%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...S){for(const b of S)if(b&&(b===1/0||isNaN(b)||b%1!=0||b<0))throw new Error("This API only accepts positive integers")}}u.Terminal=C})(),l})()))})($f)),$f.exports}var _N=xN();/**
69
+ * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
70
+ * @license MIT
71
+ *
72
+ * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
73
+ * @license MIT
74
+ *
75
+ * Originally forked from (with the author's permission):
76
+ * Fabrice Bellard's javascript vt100 for jslinux:
77
+ * http://bellard.org/jslinux/
78
+ * Copyright (c) 2011 Fabrice Bellard
79
+ */var yN=2,vN=1,bN=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"))},d=c.top+c.bottom,f=c.right+c.left,m=a-d,p=l-f-n;return{cols:Math.max(yN,Math.floor(p/t.css.cell.width)),rows:Math.max(vN,Math.floor(m/t.css.cell.height))}}};function SN({sessionId:e,onClose:t,onEscape:n,autoFocus:s}){const a=D.useRef(null),l=D.useRef(e),u=D.useRef(null),c=D.useRef(null),d=yr(m=>m.writeSession),f=yr(m=>m.resizeSession);return D.useEffect(()=>{l.current=e},[e]),D.useEffect(()=>{if(!n)return;const m=p=>{p.key==="Escape"&&(p.preventDefault(),p.stopPropagation(),n())};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[n]),D.useEffect(()=>{if(!a.current)return;const m=new _N.Terminal({fontFamily:'"JetBrains Mono", monospace',fontSize:13,theme:{background:"#1a1a1a",foreground:"#e0e0e0",cursor:"#ffffff",cursorAccent:"#1a1a1a"},cursorBlink:!0,cursorStyle:"bar",convertEol:!0}),p=new bN;m.loadAddon(p),u.current={term:m,fitAddon:p},a.current.addEventListener("keydown",C=>{C.key==="Escape"&&n&&(C.preventDefault(),C.stopPropagation(),n())}),m.open(a.current);const _=a.current.querySelector(".xterm");_&&(_.style.padding="8px"),p.fit(),s&&setTimeout(()=>{m.focus()},150);const x=new ResizeObserver(()=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{requestAnimationFrame(()=>{var v;p.fit&&p.fit();const C=(v=u.current)==null?void 0:v.term;C&&C.cols>0&&C.rows>0&&f(l.current,C.cols,C.rows)})},100)});x.observe(a.current),m.onData(C=>{if(C==="\x1B"&&n){n();return}d(l.current,C)}),m.onKey(C=>{C.key==="\x1B"&&n&&(C.domEvent.stopPropagation(),n())});const w=$t.subscribe(C=>{const v=C.payload;if(C.type==="terminal.output"&&(v==null?void 0:v.sessionId)===l.current){const S=v==null?void 0:v.data;S&&m.write(S)}});return()=>{w(),x.disconnect(),c.current&&clearTimeout(c.current),m.dispose(),u.current=null}},[e,d,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(jS,{})})]}),o.jsx("div",{ref:a,className:"flex-1 relative overflow-hidden",tabIndex:0,onKeyDown:m=>{m.key==="Escape"&&n&&(m.preventDefault(),m.stopPropagation(),n())}})]})}const zS="openfox-chat-textarea";function $S(){const e=document.getElementById(zS);e&&e.focus()}function wN(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 CN({isOpen:e,onClose:t}){const n=yr(w=>w.createSession),s=yr(w=>w.killSession),a=yr(w=>w.sessions),l=yr(w=>w.setWorkdir),u=yr(w=>w.fetchSessions),c=Rt(w=>w.currentProject),[d,f]=D.useState(!0),m=D.useRef(null),p=D.useRef(!1),_=D.useRef(!1),x=D.useCallback(()=>{t()},[t]);return D.useEffect(()=>{c!=null&&c.workdir&&l(c.workdir)},[c==null?void 0:c.workdir,l]),D.useEffect(()=>{e?(f(!0),u(c==null?void 0:c.id).finally(()=>f(!1))):$S()},[e,u,c==null?void 0:c.id]),D.useEffect(()=>{e&&a.length===0&&!d&&!_.current&&(_.current=!0,n(void 0,c==null?void 0:c.id))},[e,a.length,d,n,c==null?void 0:c.id]),D.useEffect(()=>{e?(p.current=!0,setTimeout(()=>{var w;(w=m.current)==null||w.focus(),setTimeout(()=>{p.current=!1},200)},100)):_.current=!1},[e]),D.useEffect(()=>{if(!e)return;const w=C=>{p.current||C.key==="Escape"&&(C.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:m,tabIndex:-1,className:"fixed inset-x-0 top-0 z-[100] h-[50vh] bg-bg-primary border-b border-border flex flex-col animate-slide-down outline-none",onClick: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(Mj,{})}),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(_l,{})})]})]}),o.jsx("div",{className:"flex-1 min-h-0 p-2 overflow-auto",children:d?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 ${wN(a.length)} gap-2 h-full auto-rows-fr`,children:a.map(w=>o.jsx(SN,{sessionId:w.id,onClose:()=>s(w.id),onEscape:x,autoFocus:a.length===1},w.id))})})]})]}):null}function yl({items:e,footerItems:t=[],trigger:n,minWidth:s="120px",isOpen:a,onOpenChange:l}){const[u,c]=D.useState(!1),d=a!==void 0,f=d?a:u,m=O=>{if(d){const U=typeof O=="function"?O(u):O;l==null||l(U)}else c(O)},[p,_]=D.useState(null),x=D.useRef(null),w=D.useRef(null),[C,v]=D.useState(0),S=D.useRef(0),b=D.useMemo(()=>[...e,...t],[e,t]),y=D.useRef(b),E=D.useCallback(()=>{if(!x.current)return;const O=x.current.getBoundingClientRect(),U=200,z=window.innerHeight-O.bottom<U;_({top:z?O.top-U-4:O.bottom+4,left:O.left,alignToTop:z})},[]);D.useEffect(()=>{y.current=b},[b]),D.useEffect(()=>{function O(U){if(w.current){const V=U.target;w.current.contains(V)||m(!1)}}return f&&document.addEventListener("mousedown",O),()=>{document.removeEventListener("mousedown",O)}},[f]),D.useEffect(()=>{f&&E()},[f,E]),D.useEffect(()=>{if(!f)return;setTimeout(()=>{var U;(U=w.current)==null||U.focus()},0);function O(U){const V=y.current,z=V.filter(te=>!N(te)),X=T(S.current,V);switch(U.key){case"ArrowDown":if(U.preventDefault(),U.stopPropagation(),X<z.length-1){const te=L(S.current+1,V);S.current=te,v(te)}break;case"ArrowUp":if(U.preventDefault(),U.stopPropagation(),X>0){const te=A(S.current-1,V);S.current=te,v(te)}break;case"Enter":U.preventDefault(),U.stopPropagation(),R(S.current,V);break;case"Escape":U.preventDefault(),U.stopPropagation(),m(!1);break}}return window.addEventListener("keydown",O,!0),()=>window.removeEventListener("keydown",O,!0)},[f,b]);function N(O){var z;const U=O.label;return U?String(((z=U.props)==null?void 0:z.className)??"").includes("cursor-default"):!1}function T(O,U){let V=0;for(let z=0;z<O;z++){const X=U[z];X&&!N(X)&&V++}return V}function L(O,U){for(let V=O;V<U.length;V++){const z=U[V];if(z&&!N(z))return V}return O}function A(O,U){for(let V=O;V>=0;V--){const z=U[V];if(z&&!N(z))return V}return O}function R(O,U){var z;const V=U[O];!V||N(V)||((z=V.onClick)==null||z.call(V),V.href&&(window.history.pushState(null,"",V.href),window.dispatchEvent(new PopStateEvent("popstate"))),m(!1))}D.useEffect(()=>{f&&(v(b.findIndex(O=>!N(O))),S.current=b.findIndex(O=>!N(O)))},[f,b]);const M=O=>{O.stopPropagation(),f||E(),m(!f)};function G(O,U,V,z){const te=!N(O)&&z===C,H=o.jsxs(o.Fragment,{children:[O.icon&&o.jsx("span",{className:"w-4 h-4 flex-shrink-0",children:O.icon}),O.label]}),I=U!==V-1;return O.href?o.jsx(qn,{href:O.href,onClick:$=>{var F;(F=O.onClick)==null||F.call(O,$),m(!1)},onAuxClick:()=>m(!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":te?"bg-accent-primary/20 text-text-primary":"hover:bg-bg-tertiary text-text-primary"} ${I?"border-b border-border":""}`,children:H},z):o.jsx("button",{onClick:$=>{var F;(F=O.onClick)==null||F.call(O,$),O.closeOnClick!==!1&&m(!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":te?"bg-accent-primary/20 text-text-primary":"hover:bg-bg-tertiary text-text-primary"} ${I?"border-b border-border":""}`,children:H},z)}const W=p&&o.jsxs("div",{ref:w,"data-testid":"session-dropdown-menu",className:`fixed bg-bg-secondary border border-border rounded shadow-lg z-50 ${p.alignToTop?"mb-1":"mt-1"}`,style:{top:p.top,left:p.left,minWidth:s},tabIndex:-1,children:[o.jsx("div",{className:"max-h-[60vh] overflow-y-auto",children:e.map((O,U)=>G(O,U,e.length,U))}),t.length>0&&o.jsx("div",{className:"border-t border-border",children:t.map((O,U)=>G(O,U,t.length,e.length+U))})]});return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"relative",children:o.jsx("div",{ref:x,onClick:M,children:n})}),f&&Ha.createPortal(W,document.body)]})}const Wu=D.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}));Wu.displayName="Input";function kN(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 HS({isOpen:e,onClose:t,path:n,onRetry:s}){const[a,l]=D.useState(!1),[u,c]=D.useState(null),[d,f]=D.useState(null);D.useEffect(()=>{e&&m()},[e]);const m=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})}},p=D.useCallback(async y=>{l(!0),c(null);try{const N=await(await Ne("/api/projects/fix-permissions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n,action:y})})).json();N.success?(s(),t()):N.sudoAvailable?c("Failed to fix permissions: "+(N.error||"Unknown error")):c(`Passwordless sudo is not available. Please fix permissions manually:
80
+
81
+ `+(y==="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]),_=(d==null?void 0:d.userInGroup)??!1,x=(d==null?void 0:d.groupHasWrite)??!1,w=(d==null?void 0:d.sudoAvailable)??!1,C=(d==null?void 0:d.groupName)??"",v=_&&!x,S=!_&&x,b=!_&&!x;return o.jsx(Ot,{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:v?o.jsxs(o.Fragment,{children:["The group ",o.jsx("strong",{children:C})," doesn't have write access:"]}):S?o.jsxs(o.Fragment,{children:["You're not a member of group ",o.jsx("strong",{children:C}),":"]}):o.jsxs(o.Fragment,{children:["You're not a member of group ",o.jsx("strong",{children:C})," 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}):d?o.jsxs("div",{className:"flex flex-col gap-2",children:[v&&o.jsxs(o.Fragment,{children:[o.jsx(tt,{type:"button",variant:"primary",onClick:()=>p("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:()=>p("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 ",C," $USER"]})]}),b&&o.jsxs(o.Fragment,{children:[o.jsx(tt,{type:"button",variant:"primary",onClick:()=>p("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 ",C," $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 US({isOpen:e,onClose:t}){const[,n]=hr(),s=Rt(N=>N.listProjects),[a,l]=D.useState(""),[u,c]=D.useState(null),[d,f]=D.useState(!1),[m,p]=D.useState(""),[_,x]=D.useState(null),w=D.useRef(null);D.useEffect(()=>{e&&(Ne("/api/config").then(N=>N.json()).then(N=>{N.workdir&&p(N.workdir)}),l(""),c(null),f(!1),x(null),setTimeout(()=>{var N;(N=w.current)==null||N.focus()},100))},[e]);const C=D.useCallback(async N=>{N.preventDefault();const T=kN(a);if(!T.valid){c(T.error);return}const L=`${m}/${a}`;await b(L)},[a,n,t,m]),v=D.useCallback(()=>{x(null)},[]),S=D.useCallback(async()=>{const N=`${m}/${a}`;await b(N)},[m,a,n,t,x,c,f]);async function b(N){f(!0),c(null),x(null);try{const T=await Ne("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:a,workdir:N})});if(!T.ok){const R=await T.json().catch(()=>({}));if(R.code==="EACCES"){x(N),f(!1);return}throw new Error(R.error||"Failed to create project")}const A=(await T.json()).project;t(),await s(),n(`/p/${A.id}`)}catch(T){c(T instanceof Error?T.message:"Failed to create project"),f(!1)}}const y=D.useCallback(()=>{l(""),c(null),t()},[t]),E=a?`${m}/${a}`:"";return o.jsxs(o.Fragment,{children:[o.jsx(Ot,{isOpen:e,onClose:y,title:"Create New Project",size:"sm",children:o.jsxs("form",{onSubmit:C,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(Wu,{ref:w,id:"project-name",value:a,onChange:N=>{l(N.target.value),c(null)},placeholder:"my-project",disabled:d,"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:y,disabled:d,children:"Cancel"}),o.jsx(tt,{type:"submit",variant:"primary",disabled:d||!a.trim(),"data-testid":"create-project-submit-button",className:"min-w-[100px]",children:d?o.jsxs("span",{className:"flex items-center gap-2",children:[o.jsx(Ks,{className:"h-4 w-4"}),"Creating..."]}):"Create"})]})]})}),_&&o.jsx(HS,{isOpen:!!_,onClose:v,path:_,onRetry:S})]})}const EN={sm:"w-4 h-4",md:"w-8 h-8",lg:"w-12 h-12"};function vl({size:e="md",className:t=""}){return o.jsx("div",{className:`animate-spin border-2 border-accent-primary border-t-transparent rounded-full ${EN[e]} ${t}`})}function jN({text:e,...t}){return o.jsxs("div",{className:"text-center",children:[o.jsx(vl,{...t,className:"mx-auto mb-4"}),e&&o.jsx("div",{className:"text-text-secondary",children:e})]})}function Cp({onSelect:e,onClose:t,initialPath:n}){const[s,a]=D.useState(null),[l,u]=D.useState(!0),[c,d]=D.useState(""),[f,m]=D.useState(-1),p=D.useRef(null),_=D.useRef([]),x=D.useCallback(async y=>{u(!0),d(""),m(-1);try{const E=y?`/api/directories?path=${encodeURIComponent(y)}`:"/api/directories",T=await(await Ne(E)).json();a(T)}catch(E){console.error("Failed to load directories:",E)}finally{u(!1)}},[]);D.useEffect(()=>{x(n)},[n,x]);const w=((s==null?void 0:s.current)??"").split("/").filter(Boolean).map((y,E,N)=>({name:y,path:"/"+N.slice(0,E+1).join("/")})),C=(s==null?void 0:s.directories.filter(y=>c===""||y.name.toLowerCase().includes(c.toLowerCase())))??[],v=[...s!=null&&s.parent?[{type:"parent",path:s.parent,name:".."}]:[],...C.map(y=>({type:"dir",path:y.path,name:y.name}))];D.useEffect(()=>{m(c?0:-1)},[c,C.length]),D.useEffect(()=>{var y;f>=0&&_.current[f]&&((y=_.current[f])==null||y.scrollIntoView({block:"nearest"}))},[f]);const S=y=>{var E;if(y.key==="ArrowDown")y.preventDefault(),m(N=>Math.min(N+1,v.length-1));else if(y.key==="ArrowUp")y.preventDefault(),m(N=>Math.max(N-1,0));else if(y.key==="Enter"){if(y.preventDefault(),f>=0&&v[f]){const N=v[f];N.type==="parent"?x(N.path):e(N.path)}}else y.key==="Escape"&&(d(""),(E=p.current)==null||E.focus())},b=o.jsxs("div",{className:"flex flex-col gap-2",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"})]});return o.jsx(Ot,{isOpen:!0,onClose:t,title:"Select Folder",size:"lg",footer:b,children:o.jsxs("div",{className:"flex flex-col h-full -m-4",children:[o.jsxs("div",{className:"sticky top-0 bg-bg-secondary z-10 border-b border-border",children:[s&&o.jsx("div",{className:"px-3 py-2 bg-bg-tertiary/30",children:o.jsxs("div",{className:"flex items-center text-xs overflow-x-auto",children:[w.map((y,E)=>o.jsxs("span",{className:"flex items-center shrink-0",children:[o.jsx("span",{className:"text-text-muted",children:"/"}),o.jsx("button",{onClick:()=>x(y.path),className:`px-1 ${E===w.length-1?"text-accent-primary font-medium":"text-text-secondary hover:text-accent-primary"}`,children:y.name})]},y.path)),w.length===0&&o.jsx("button",{onClick:()=>x("/"),className:"text-text-muted hover:text-accent-primary",children:"/"})]})}),o.jsx("div",{className:"px-4 py-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(gp,{})}),o.jsx(Wu,{autoFocus:!0,ref:p,value:c,onChange:y=>d(y.target.value),onKeyDown:S,placeholder:"Filter directories...",className:"w-full pl-9"})]})})]}),o.jsx("div",{className:"flex-1 overflow-y-auto",children:l?o.jsx("div",{className:"p-8 text-center",children:o.jsx(vl,{size:"sm"})}):v.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:v.map((y,E)=>o.jsxs("div",{className:`group flex items-center transition-colors ${E===f?"bg-accent-primary/20":"hover:bg-bg-tertiary/50"}`,children:[o.jsxs("button",{ref:N=>{_.current[E]=N},onClick:()=>{y.type==="parent"?x(y.path):e(y.path)},className:"flex-1 flex items-center gap-3 p-3 text-left min-w-0",children:[y.type==="parent"?o.jsx(Cj,{className:"w-5 h-5 text-text-muted shrink-0"}):o.jsx(Hu,{className:"w-5 h-5 shrink-0"}),o.jsx("span",{className:"truncate",children:y.name})]}),y.type==="dir"&&o.jsx("button",{onClick:N=>{N.stopPropagation(),x(y.path)},className:"mr-2 p-2 text-text-muted hover:text-text-primary opacity-0 group-hover:opacity-100 transition-opacity rounded hover:bg-bg-tertiary",title:"Navigate into folder",children:o.jsx(hp,{className:"w-4 h-4"})})]},y.path))})})]})})}function FS(){const[e,t]=D.useState(null);return D.useEffect(()=>{Ne("/api/config").then(n=>n.json()).then(n=>{n.workdir&&t(n.workdir)})},[]),e}function qv({projects:e,currentProject:t}){const[,n]=hr(),s=Rt(v=>v.loadProject),a=Rt(v=>v.toggleStar),l=Rt(v=>v.createProject),u=Rt(v=>v.listProjects),[c,d]=D.useState(!1),[f,m]=D.useState(!1),p=FS(),_=D.useCallback(async v=>{const S=v.split("/").filter(Boolean).pop()??"",b=await l(S,v);return b&&"id"in b?(await u(),m(!1),n(`/p/${b.id}`),!0):!1},[l,u,n]),w=D.useMemo(()=>{const v=e.filter(b=>b.isStarred).sort((b,y)=>b.name.localeCompare(y.name)),S=e.filter(b=>!b.isStarred).sort((b,y)=>b.name.localeCompare(y.name));return[...v,...S]},[e]).map(v=>({label:o.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[o.jsx("span",{className:"truncate flex-1",children:v.name}),o.jsx("button",{onClick:S=>{S.stopPropagation(),S.preventDefault(),S.nativeEvent.stopImmediatePropagation(),a(v.id,!v.isStarred)},className:"flex-shrink-0 p-1 hover:bg-bg-tertiary rounded transition-colors",title:v.isStarred?"Unstar project":"Star project",children:v.isStarred?o.jsx(Bj,{className:"w-3.5 h-3.5 text-yellow-500"}):o.jsx(zj,{className:"w-3.5 h-3.5 text-text-muted hover:text-yellow-500"})})]}),icon:v.id===(t==null?void 0:t.id)?o.jsx(Pr,{}):void 0,href:`/p/${v.id}`,closeOnClick:!0,onClick:()=>{s(v.id)}})),C=[{label:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Hu,{className:"w-4 h-4"}),o.jsx("span",{children:"Open Project"})]}),onClick:()=>m(!0)},{label:o.jsxs("div",{className:"flex items-center gap-2 text-accent-primary",children:[o.jsx(Ks,{className:"w-4 h-4"}),o.jsx("span",{children:"New Project"})]}),onClick:()=>d(!0)}];return o.jsxs(o.Fragment,{children:[o.jsx(yl,{items:w,footerItems:C,trigger:o.jsxs("button",{className:`text-text-secondary hover:text-text-primary text-sm truncate flex items-center gap-1 ${t?"hover:underline":""}`,title:(t==null?void 0:t.name)??"Select project",children:[(t==null?void 0:t.name)??o.jsx("span",{className:"text-text-muted",children:"Select project..."}),o.jsx(dr,{})]}),minWidth:"250px"}),c&&o.jsx(US,{isOpen:c,onClose:()=>d(!1)}),f&&o.jsx(Cp,{initialPath:p??void 0,onSelect:_,onClose:()=>m(!1)})]})}function VS(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 qu(e){const t=new Date(e),n=String(t.getHours()).padStart(2,"0"),s=String(t.getMinutes()).padStart(2,"0");return`${n}:${s}`}function NN(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=qu(e);if(l===0)return`today ${u}`;if(l===1)return`yesterday ${u}`;if(l<7)return`${l} days ago ${u}`;{const c=t.getFullYear(),d=String(t.getMonth()+1).padStart(2,"0"),f=String(t.getDate()).padStart(2,"0");return`${c}/${d}/${f} ${u}`}}function GS(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 TN(e){const{year:t,month:n,day:s}=GS(e);return`${t}-${n}-${s}`}function WS(e){const t=new Map;for(const a of e){const l=TN(a.updatedAt);t.has(l)||t.set(l,[]),t.get(l).push(a)}for(const[a,l]of t)l.sort((u,c)=>{const d=new Date(u.updatedAt).getTime();return new Date(c.updatedAt).getTime()-d});const n=Array.from(t.keys()).sort((a,l)=>l.localeCompare(a)),s=new Map;for(const a of n)s.set(a,t.get(a));return s}function AN({sessions:e,currentProject:t,currentSession:n,isOpen:s,onOpenChange:a}){var m;const l=we(p=>p.loadSession),u=e.filter(p=>p.projectId===t.id).slice(0,15),c=WS(u),d=D.useMemo(()=>{const p=[];p.push({label:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Ks,{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){p.push({label:o.jsx("div",{className:"px-3 py-2 text-text-muted text-xs font-medium cursor-default",children:VS(w.updatedAt)}),onClick:()=>{}});for(const C of x)p.push({label:o.jsxs("div",{className:"min-w-[160px]",children:[o.jsx("div",{className:"truncate text-sm",children:C.title??C.id.slice(0,8)}),o.jsx("div",{className:"text-text-muted text-xs",children:qu(C.updatedAt)})]}),icon:C.id===(n==null?void 0:n.id)?o.jsx(Pr,{}):void 0,href:`/p/${t.id}/s/${C.id}`,onClick:()=>{l(C.id)}})}}return p},[t.id,c,n==null?void 0:n.id]),f=n?((m=n.metadata)==null?void 0:m.title)??n.id.slice(0,8):"No session selected";return o.jsx(yl,{items:d,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(dr,{})]}),minWidth:"280px"})}function LN({items:e,trigger:t,isActive:n=!1}){const[s,a]=D.useState(!1),l=D.useRef(null);return D.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(dr,{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 d=u.label&&typeof u.label=="object"&&u.label.type===qn?u.label:null;if(d){const f=d.props.href||"";return o.jsxs(qn,{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,d.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 DN({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(qn,{href:`/p/${e.id}/new`,className:"flex items-center gap-2",children:[o.jsx(Ks,{className:"w-3 h-3 text-accent-primary"}),o.jsx("span",{className:"text-sm",children:"New Session"})]})},...a.map(u=>({label:o.jsx(qn,{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(Pr,{className:"w-3 h-3"}):void 0})),{label:o.jsxs(qn,{href:"/",className:"flex items-center gap-2 text-text-muted hover:text-text-primary",children:[o.jsx(Ej,{className:"w-3 h-3"}),o.jsx("span",{className:"text-sm",children:"Projects"})]})}];return o.jsx(LN,{items:l,trigger:o.jsx("span",{className:"text-sm text-text-secondary font-medium",children:e.name})})}function RN({onMenuClick:e,onCriteriaToggle:t}){const[n,s]=D.useState(!1),[a,l]=D.useState(!1),[u,c]=D.useState(!!document.fullscreenElement);D.useEffect(()=>{const E=()=>c(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",E),()=>document.removeEventListener("fullscreenchange",E)},[]);const[d]=hr(),f=d.startsWith("/p/"),m=/^\/p\/[^/]+\/s\/[^/]+$/.test(d),p=we(E=>E.currentSession),_=we(E=>E.sessions),x=Rt(E=>E.currentProject),w=Rt(E=>E.projects),C=zt(E=>E.startAutoRefresh),v=zt(E=>E.stopAutoRefresh),S=yr(E=>E.setOpen),b=yr(E=>E.isOpen);D.useEffect(()=>{const E=()=>l(!0);return window.addEventListener("open-session-dropdown",E),()=>window.removeEventListener("open-session-dropdown",E)},[]);const y=xp();return LS(y.terminalToggle,()=>{yr.getState().toggleOpen()},{capture:!0}),D.useEffect(()=>(C(),()=>v()),[C,v]),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(Pv,{})}),o.jsx(qn,{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(qv,{projects:w,currentProject:x})}),o.jsx("span",{className:"md:hidden",children:o.jsx(DN,{currentProject:x,sessions:_,currentSession:p,projectIdFromUrl:f&&d.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(AN,{sessions:_,currentProject:x,currentSession:p,isOpen:a,onOpenChange:l})})]}),!x&&o.jsx("span",{className:"hidden md:inline",children:o.jsx(qv,{projects:w})})]}),o.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[m&&o.jsx("button",{onClick:()=>{var E,N,T;document.fullscreenElement?(E=document.exitFullscreen)==null||E.call(document):(T=(N=document.documentElement).requestFullscreen)==null||T.call(N)},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(Aj,{}):o.jsx(Lj,{})}),f&&o.jsx("button",{onClick:()=>S(!b),className:`p-2.5 rounded hover:bg-bg-tertiary transition-colors ${b?"text-accent-primary":"text-text-muted hover:text-text-primary"}`,title:"Toggle terminal (double Ctrl)",children:o.jsx(Hj,{})}),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(Ij,{})}),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(Dj,{})}),t&&m&&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(Pv,{})})]}),o.jsx(gN,{isOpen:n,onClose:()=>s(!1)}),o.jsx(CN,{isOpen:b,onClose:()=>S(!1)})]})}function ON({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 MN({isOpen:e,onClose:t,project:n}){const s=Rt(E=>E.updateProject),a=()=>{try{$t.send("context.checkDynamic",{})}catch{}t()},[l,u]=D.useState(n.customInstructions??""),[c,d]=D.useState(n.dangerLevel??""),[f,m]=D.useState(!1),[p,_]=D.useState(!1),[x,w]=D.useState(!1),C=f||p;D.useEffect(()=>{u(n.customInstructions??""),d(n.dangerLevel??""),m(!1),_(!1)},[n]);const v=E=>{u(E.target.value),m(!0)},S=E=>{d(E),_(!0)},b=async()=>{w(!0);const E=c===""?null:c;await s(n.id,{customInstructions:l||null,dangerLevel:E}),w(!1),m(!1),_(!1),a()},y=()=>{u(n.customInstructions??""),d(n.dangerLevel??""),m(!1),_(!1),a()};return o.jsx(Ot,{isOpen:e,onClose:y,title:`${n.name} Settings`,size:"lg",footer:o.jsx(ON,{onCancel:y,onSave:b,saving:x,saveDisabled:!C||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:v,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 IN={sm:"w-3 h-3",md:"w-4 h-4",lg:"w-5 h-5",xl:"w-6 h-6"},PN="M6 18L18 6M6 6l12 12";function bl({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(Uu,{onClick:e,icon:PN,iconSize:IN[n],className:`${a} ${t}`,title:"Close"})}function qS({projectId:e,isOpen:t=!0,onClose:n}){const[,s]=hr(),[a,l]=D.useState(!1),u=we(N=>N.sessions),c=we(N=>N.currentSession),d=we(N=>N.unreadSessionIds),f=we(N=>N.deleteSession),m=we(N=>N.deleteAllSessions),p=we(N=>N.loadMoreSessions),_=we(N=>N.sessionsHasMore),x=we(N=>N.sessionsPaginationLoading),w=Rt(N=>N.currentProject),C=D.useRef(null),v=D.useCallback(()=>{_&&!x&&w&&p(w.id)},[_,x,w,p]);D.useEffect(()=>{if(!C.current||!_)return;const N=new IntersectionObserver(T=>{const L=T[0];L&&L.isIntersecting&&v()},{threshold:.1});return N.observe(C.current),()=>N.disconnect()},[_,v]);const S=u.filter(N=>N.projectId===(w==null?void 0:w.id)),b=(N,T)=>{T==null||T.stopPropagation(),confirm("Delete this session?")&&(f(N),(c==null?void 0:c.id)===N&&s(`/p/${e}`))},y=(N,T)=>{T==null||T.stopPropagation();const L=u.find(M=>M.id===N),A=(L==null?void 0:L.title)??N.slice(0,6),R=prompt("Rename session:",A);if(R!==null&&R.trim()!==""){const M=we.getState().renameSession;M(N,R.trim())}},E=()=>{confirm("Delete all sessions in this project? This cannot be undone.")&&(m(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:`
82
+ ${t?"md:w-[300px] md:shrink-0":"md:w-0 md:shrink-0 md:overflow-hidden"}
83
+ md:relative md:h-auto md:translate-x-0
84
+
85
+ fixed z-50 h-[calc(100vh-32px)]
86
+ w-[300px] bg-secondary border-r border-border flex flex-col
87
+ transition-all duration-300 ease-in-out
88
+ ${t?"translate-x-0":"-translate-x-full"}
89
+ `,children:[o.jsxs("div",{className:"p-4 border-b border-border flex gap-2",children:[o.jsx(qn,{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(yl,{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(mp,{})})}),n&&o.jsx(bl,{onClick:n,className:"md:hidden",variant:"sidebar",size:"md"})]}),w&&o.jsx(MN,{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:BN(S,c,d,b,y,e)}),x&&o.jsx("div",{className:"p-4 text-center text-text-muted text-xs",children:"Loading more..."}),o.jsx("div",{ref:C,className:"h-px"})]})})]})]})}function BN(e,t,n,s,a,l){const u=WS(e);return Array.from(u).map(([c,d])=>{const f=d[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:VS(f.updatedAt)}),d.map(m=>{const p=(t==null?void 0:t.id)===m.id,_=n.includes(m.id),x=m.isRunning;return o.jsx("div",{className:`w-full px-4 py-3 text-left hover:bg-bg-tertiary/50 transition-colors group ${p?"bg-bg-tertiary":""}`,children:o.jsxs(qn,{href:`/p/${l}/s/${m.id}`,className:`block ${p?"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 ${p?"text-accent-primary":"text-text-primary"}`,children:m.title??m.id.slice(0,6)}),o.jsx(yl,{items:[{label:"Rename session",onClick:w=>a(m.id,w)},{label:"Delete session",onClick:w=>s(m.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(mp,{})})})]}),o.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[x?o.jsx(Pj,{}):_&&!p?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:qu(m.updatedAt)}),o.jsxs("span",{className:"text-text-muted text-xs flex-shrink-0",children:[m.messageCount," messages"]})]})]})},m.id)})]},c):null})}const Kv=["⠋","⠙","⠹","⠸","⠼","⠴"];function zN(){var c;const e=Rt(d=>d.currentProject),t=we(d=>d.currentSession),n=$u(),s=!1,a=D.useRef(0),l=D.useRef(null);D.useEffect(()=>(n?(l.current=window.setInterval(()=>{a.current=(a.current+1)%Kv.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 p;const f=(p=t==null?void 0:t.metadata)==null?void 0:p.title,m=n?`${Kv[a.current]} `:"";e&&f?document.title=`${m}${e.name} - ${f} | OpenFox`:e?document.title=`${m}${e.name} | OpenFox`:document.title=`${m}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 KS(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)),d=l.slice(-Math.ceil(u/2));return`/${s}/${c}...${d}/${a}`}function YS({isOpen:e,onClose:t,projectName:n,onConfirm:s}){const a=()=>{s(),t()};return o.jsx(Ot,{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 $N({isOpen:e,onClose:t}){const[,n]=hr(),[s,a]=D.useState(!1),l=FS(),[u,c]=D.useState(!1),d=Rt(A=>A.projects),f=Rt(A=>A.createProject),m=Rt(A=>A.listProjects),p=Rt(A=>A.deleteProject),[_,x]=D.useState(null),[w,C]=D.useState(null);D.useEffect(()=>{e&&m()},[e,m]);const v=A=>{n(`/p/${A}`),t()},S=(A,R)=>{R.stopPropagation(),x(A)},b=()=>{_&&(p(_.id),x(null))},y=async A=>N(A);function E(A){return A!=null&&typeof A=="object"&&"error"in A&&A.error!=null&&typeof A.error=="object"&&"code"in A.error&&A.error.code==="EACCES"}async function N(A){const R=A.split("/").filter(Boolean).pop()??"",M=await f(R,A);return m(),E(M)?(C(M.error.path||A),!1):M&&"id"in M?(n(`/p/${M.id}`),t(),!0):!1}const T=D.useCallback(()=>{C(null)},[]),L=D.useCallback(async()=>{const A=w;C(null),A&&await N(A)},[w]);return e?o.jsxs(Ot,{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:d.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:d.map(A=>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(A.id),className:"flex-1 flex items-center gap-3 text-left",children:[o.jsx(Hu,{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:A.name}),o.jsx("div",{className:"text-xs text-text-muted truncate",children:KS(A.workdir,32)})]})]}),o.jsx("button",{onClick:R=>S(A,R),className:"text-accent-error/70 hover:text-accent-error p-1",title:"Delete project",children:o.jsx(xl,{className:"w-4 h-4"})})]},A.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(US,{isOpen:s,onClose:()=>a(!1)}),_&&o.jsx(YS,{isOpen:!0,onClose:()=>x(null),projectName:_.name,onConfirm:b}),u&&o.jsx(Cp,{initialPath:l??void 0,onSelect:A=>{y(A)},onClose:()=>c(!1)}),w&&o.jsx(HS,{isOpen:!0,onClose:T,path:w,onRetry:L})]}):null}function HN(){const[e,t]=D.useState(!1),[n,s]=D.useState(null),a=we(w=>w.sessions),l=Rt(w=>w.projects),u=Rt(w=>w.loading),c=Rt(w=>w.listProjects),d=we(w=>w.listSessions),f=Rt(w=>w.deleteProject),m=we(w=>w.connectionStatus);D.useEffect(()=>{m==="connected"&&(c(),d())},[m,c,d]);const p=[...l].sort((w,C)=>{const v=a.filter(E=>E.workdir.startsWith(w.workdir)),S=a.filter(E=>E.workdir.startsWith(C.workdir)),b=v.length>0?new Date(v.reduce((E,N)=>new Date(N.updatedAt)>new Date(E.updatedAt)?N:E).updatedAt).getTime():new Date(w.updatedAt).getTime();return(S.length>0?new Date(S.reduce((E,N)=>new Date(N.updatedAt)>new Date(E.updatedAt)?N:E).updatedAt).getTime():new Date(C.updatedAt).getTime())-b}),_=w=>{const C=l.find(v=>v.id===w);return C?a.filter(v=>v.workdir.startsWith(C.workdir)).sort((v,S)=>new Date(S.updatedAt).getTime()-new Date(v.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"})]}),p.map(w=>{const C=_(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(qn,{href:`/p/${w.id}`,className:"flex items-center gap-2 cursor-pointer hover:opacity-80 transition-opacity flex-1",children:[o.jsx(Hu,{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(qn,{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(xl,{className:"w-4 h-4"})})]}),o.jsx("div",{className:"divide-y divide-border",children:C.length>0?C.map(v=>{const S=l.find(y=>v.workdir.startsWith(y.workdir)),b=S?`/p/${S.id}/s/${v.id}`:"#";return o.jsx(qn,{href:b,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:v.title??v.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:NN(v.updatedAt)}),o.jsxs("span",{className:"text-text-muted text-xs",children:[v.messageCount," msgs"]})]})]})},v.id)}):o.jsx("div",{className:"p-3 md:p-4 text-text-muted text-sm",children:"No sessions yet"})})]})},w.id)}),p.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(vl,{})})]}),e&&o.jsx($N,{isOpen:e,onClose:()=>t(!1)}),n&&o.jsx(YS,{isOpen:!0,onClose:()=>s(null),projectName:n.name,onConfirm:()=>f(n.id)})]})}function UN(){const[,e]=up("/p/:projectId/new"),[,t]=hr(),n=e==null?void 0:e.projectId,s=we(u=>u.createSession),a=we(u=>u.resetPendingSessionCreate),l=D.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 D.useEffect(()=>{l()},[l]),o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(vl,{})})}function FN(){const e=Rt(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(qn,{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 VN(e){return typeof e.totalTime=="number"&&!Number.isNaN(e.totalTime)}function Am(e){return{providerId:e.providerId,providerName:e.providerName,backend:e.backend,model:e.model}}function GN(e){return`${e.providerId}::${e.model}`}function WN(e){return`${e.providerName} > ${e.model}`}function Yv(e){let t=0,n=0,s=0,a=0,l=0,u=0;const c=[],d=[];let f=0;for(const[_,x]of e.entries()){const w=x.stats,C=Am(w);t+=w.totalTime,n+=w.toolTime,s+=w.prefillTokens,a+=w.generationTokens;const v=w.prefillSpeed>0?w.prefillTokens/w.prefillSpeed:0,S=w.generationSpeed>0?w.generationTokens/w.generationSpeed:0;l+=v,u+=S,c.push({messageId:x.id,timestamp:x.timestamp,...C,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 b=w.llmCalls??[];for(const y of b)f+=1,d.push({messageId:x.id,timestamp:y.timestamp??x.timestamp,providerId:y.providerId,providerName:y.providerName,backend:y.backend,model:y.model,mode:w.mode,responseIndex:_+1,sessionCallIndex:f,callIndex:y.callIndex,promptTokens:y.promptTokens,completionTokens:y.completionTokens,ttft:y.ttft,completionTime:y.completionTime,prefillSpeed:y.prefillSpeed,generationSpeed:y.generationSpeed,totalTime:y.totalTime,...y.temperature!==void 0&&{temperature:y.temperature},...y.topP!==void 0&&{topP:y.topP},...y.topK!==void 0&&{topK:y.topK},...y.maxTokens!==void 0&&{maxTokens:y.maxTokens}})}const m=l>0?Uo(s/l):0,p=u>0?Uo(a/u):0;return{totalTime:Uo(t),aiTime:Uo(t-n),toolTime:Uo(n),prefillTokens:s,generationTokens:a,avgPrefillSpeed:m,avgGenerationSpeed:p,responseCount:e.length,llmCallCount:d.length,dataPoints:c,callDataPoints:d}}function qN(e){const t=e.filter(a=>a.stats!==void 0&&a.stats!==null&&VN(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=GN(Am(a.stats)),u=n.get(l)??[];n.set(l,[...u,a])}const s=Array.from(n.entries()).map(([a,l])=>{const u=Am(l[0].stats),c=Yv(l);return{...u,key:a,label:WN(u),...c}});return{...Yv(t),modelGroups:s}}function KN(e){return D.useMemo(()=>qN(e),[e])}function XS(){var a;const e=we(l=>l.gitStatus),t=we(l=>l.currentSession),[n,s]=D.useState(!0);return D.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 pu(e){return e.toLocaleString("en-US").replace(/,/g," ")}function Xv(e){return Number.isFinite(e)?e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toFixed(1):"0"}function YN(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 Qv=["▁","▂","▃","▄","▅","▆","▇","█"];function XN(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 QN(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 JN(e,t){if(e.length===0||t<=0)return{blocks:"",minX:0,maxX:0,minY:0,maxY:0};const n=[...e].sort((p,_)=>p.x-_.x),s=n[0].x,a=n[n.length-1].x,l=Math.min(...n.map(p=>p.y)),u=Math.max(...n.map(p=>p.y)),{minY:c,maxY:d}=QN(l,u),f=Array.from({length:t},()=>" "),m=new Map;for(const p of n){const _=a===s?0:Math.round((p.x-s)/(a-s)*(t-1)),x=m.get(_)??[];m.set(_,[...x,p.y])}for(const[p,_]of m){const x=Math.max(..._);f[p]=Qv[XN(x,c,d)]??Qv[0]}return{blocks:f.join(""),minX:s,maxX:a,minY:c,maxY:d}}function Jv(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toFixed(1)}function Zv({data:e,width:t=60,height:n=78,label:s,xLabel:a,yLabel:l,showAxes:u=!0,formatY:c=Jv,formatX:d=Jv}){const f=D.useMemo(()=>{const m=JN(e,t),p=Math.max(t*6,240),_=10,x=8,C=[...e].sort((y,E)=>y.x-E.x).map(y=>{const E=m.maxX===m.minX?p/2:_+(y.x-m.minX)/(m.maxX-m.minX)*(p-_*2),N=m.maxY===m.minY?n/2:x+(m.maxY-y.y)/(m.maxY-m.minY)*(n-x*2);return{...y,cx:E,cy:N,leftPercent:E/p*100,topPercent:N/n*100}}),v=C.map((y,E)=>`${E===0?"M":"L"} ${y.cx.toFixed(1)} ${y.cy.toFixed(1)}`).join(" "),b=[m.maxY,(m.maxY+m.minY)/2,m.minY].map(y=>({value:y,y:m.maxY===m.minY?n/2:x+(m.maxY-y)/(m.maxY-m.minY)*(n-x*2)}));return{...m,chartWidth:p,points:C,path:v,gridLines:b}},[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(m=>o.jsx("span",{children:c(m.value)},`${m.value}-${m.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(m=>o.jsx("line",{x1:"0",x2:f.chartWidth,y1:m.y,y2:m.y,stroke:"currentColor",strokeDasharray:"3 4",className:"text-border/60"},`grid-${m.y}`)),f.points.map(m=>o.jsx("line",{x1:m.cx,x2:m.cx,y1:n-4,y2:m.cy,stroke:"currentColor",className:"text-border/40"},`guide-${m.cx}-${m.cy}`)),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(m=>o.jsx("div",{className:"absolute -translate-x-1/2 -translate-y-1/2",style:{left:`${m.leftPercent}%`,top:`${m.topPercent}%`},title:`${d(m.x)} -> ${c(m.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-${m.x}-${m.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:d(f.minX)}),o.jsx("span",{children:a}),o.jsx("span",{children:d(f.maxX)})]})]}),l&&u&&o.jsx("div",{className:"text-text-muted mt-1 text-center",children:l})]})}function ZN({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(Zv,{data:l,width:a,label:t,xLabel:s}),o.jsx(Zv,{data:u,width:a,label:n,xLabel:s})]})}function eT(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 tT(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 nT(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 rT(e){return e.callDataPoints.length>0?nT(e):tT(e)}function Hf(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 Ti(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toString()}function Zo(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toFixed(1)}function sT(e){if(e.length===0)return"0 ctx";const t=Math.min(...e),n=Math.max(...e);return t===n?`${Ti(t)} ctx`:`${Ti(t)}-${Ti(n)} ctx`}function gu(e){return`${Zo(e)} t/s`}function QS(e){try{return new Date(e).toLocaleTimeString("en-US",{hour12:!1})}catch{return e}}function iT(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 aT({isOpen:e,onClose:t,stats:n}){const s=D.useRef(null),[a,l]=D.useState({}),[u,c]=D.useState(()=>{var w;return((w=n.modelGroups[0])==null?void 0:w.key)??""});D.useEffect(()=>{var w;n.modelGroups.some(C=>C.key===u)||c(((w=n.modelGroups[0])==null?void 0:w.key)??"")},[u,n.modelGroups]);const d=D.useMemo(()=>n.modelGroups.find(w=>w.key===u)??n.modelGroups[0],[u,n.modelGroups]),f=D.useMemo(()=>d?eT(d):[],[d]),m=D.useMemo(()=>d?rT(d):{mode:"responses",xLabel:"response",prefillLabel:"",generationLabel:"",points:[]},[d]),p=D.useCallback(w=>{l(C=>({...C,[w]:!C[w]}))},[]),_=D.useCallback(()=>{if(!d)return;const w=iT(d);navigator.clipboard.writeText(JSON.stringify(w,null,2)).catch(C=>console.error("Failed to copy:",C))},[d]),x=D.useCallback(async()=>{if(s.current)try{const w=(await Q(async()=>{const{default:S}=await import("./html2canvas.esm-QH1iLAAe.js");return{default:S}},[])).default,C=await w(s.current,{backgroundColor:"#1a1a1a",scale:2}),v=document.createElement("a");v.download=`openfox-stats-${new Date().toISOString().slice(0,10)}.png`,v.href=C.toDataURL("image/png"),v.click()}catch(w){console.error("Failed to export PNG:",w),_()}},[_]);return o.jsx(Ot,{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===(d==null?void 0:d.key)?"border-accent-primary bg-accent-primary/10 text-accent-primary":"border-border text-text-muted hover:text-text-primary hover:bg-bg-tertiary/40"}`,title:w.label,children:w.label},w.key))})}),d&&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(rs,{label:"AI Time",value:Hf(d.aiTime)}),o.jsx(rs,{label:"Total Time",value:Hf(d.totalTime)}),o.jsx(rs,{label:"Tool Time",value:Hf(d.toolTime)}),o.jsx(rs,{label:"Responses",value:d.responseCount.toString()}),o.jsx(rs,{label:"LLM Calls",value:d.llmCallCount.toString()})]}),o.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mt-3",children:[o.jsx(rs,{label:"Prefill Tokens",value:Ti(d.prefillTokens),subValue:`@ ${Zo(d.avgPrefillSpeed)} tok/s`}),o.jsx(rs,{label:"Gen Tokens",value:Ti(d.generationTokens),subValue:`@ ${Zo(d.avgGenerationSpeed)} tok/s`}),o.jsx(rs,{label:"Avg PP Speed",value:`${Zo(d.avgPrefillSpeed)}`,subValue:"tok/s"}),o.jsx(rs,{label:"Avg TG Speed",value:`${Zo(d.avgGenerationSpeed)}`,subValue:"tok/s"})]})]}),d&&m.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(ZN,{data:m.points,width:50,prefillLabel:m.prefillLabel,generationLabel:m.generationLabel,xLabel:m.xLabel})})]}),d&&o.jsxs("section",{children:[o.jsxs("h3",{className:"text-sm font-semibold text-text-secondary mb-3 uppercase tracking-wide",children:["Response Log (",d.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,C)=>o.jsxs(D.Fragment,{children:[o.jsx(oT,{row:w,index:C,isExpanded:a[w.messageId]??!1,onToggle:w.isExpandable?()=>p(w.messageId):void 0}),(a[w.messageId]??!1)&&w.calls.map((v,S)=>o.jsx(lT,{dataPoint:v,index:S},`${v.messageId}-${v.callIndex}`))]},w.messageId))})]})})]})]})})}function rs({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 oT({row:e,index:t,isExpanded:n,onToggle:s}){const a=e.calls.length>0?sT(e.calls.map(l=>l.promptTokens)):`${Ti(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:QS(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:gu(e.prefillSpeed)}),o.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:gu(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 lT({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:QS(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:Ti(e.promptTokens)}),o.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:gu(e.prefillSpeed)}),o.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:gu(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 cT={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"}},uT=["open","in_progress","pending","completed","resolved","dismissed","passed","failed"];function dT(e){return cT[e]??{icon:"○",color:"text-text-muted"}}function JS(e){const t=document.createElement("textarea");return t.innerHTML=e,t.value}const Ku=D.memo(function({status:t,className:n="text-xs leading-tight flex-shrink-0"}){const{icon:s,color:a}=dT(t);return o.jsx("span",{className:`${a} ${n}`,children:s})});function eb({entries:e,title:t}){const n=D.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:uT.map(s=>{const a=n[s];return a?o.jsxs("span",{className:"flex items-center gap-0.5",children:[o.jsx(Ku,{status:s}),o.jsx("span",{children:a})]},s):null})})]})}const hT=D.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(Ku,{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,"]"]})," ",JS(s.description)]})]},s.id??a))})]})}),fT="#6b7280";function ol(e,t){var n;return((n=e.find(s=>s.id===t))==null?void 0:n.color)??fT}const gt=Yn(e=>{const t=async()=>{await yp("/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 qs("POST","/api/agents",{...n,destination:s});return a.success&&await t(),a},updateAgent:async(n,s)=>{const a=await qs("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)=>zu(`/api/agents/${n}/duplicate`,t,s)}}),jt=Yn((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 qs("POST","/api/workflows",{...n,destination:s});return a.success&&await t().fetchWorkflows(),a},updateWorkflow:async(n,s)=>{const a=await qs("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)=>zu(`/api/workflows/${n}/duplicate`,()=>t().fetchWorkflows(),s)})),mT={pending:"completed",completed:"passed",passed:"failed",failed:"pending"};async function pT(e,t){await Ne(`/api/sessions/${e}/criteria`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({criteria:t})})}function Gc({id:e,agents:t}){const n=ol(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 gT({id:e}){const t=jt(u=>u.defaults),n=jt(u=>u.userItems),a=D.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 xT({entries:e,sessionId:t}){const[n,s]=D.useState(e),[a,l]=D.useState(!1),[u,c]=D.useState(null),[d,f]=D.useState(""),[m,p]=D.useState(""),[_,x]=D.useState(!1),[w,C]=D.useState(!1),v=gt(z=>z.defaults),S=gt(z=>z.userItems),b=gt(z=>z.projectItems),y=D.useMemo(()=>[...v,...S,...b],[v,S,b]),E=D.useRef(null),N=D.useRef(null);D.useEffect(()=>{s(e)},[e]),D.useEffect(()=>{var z;a&&((z=E.current)==null||z.focus())},[a]),D.useEffect(()=>{var z;u&&((z=N.current)==null||z.focus())},[u]);const T=D.useCallback(z=>{s(z),pT(t,z)},[t]),L=D.useCallback(()=>{var H;const z=d.trim();if(!z)return;const X=String(n.length),te=[...n,{id:X,description:z,status:"pending"}];T(te),f(""),(H=E.current)==null||H.focus()},[n,d,T]),A=D.useCallback(()=>{l(!1),f("")},[]),R=D.useCallback((z,X)=>{c(z),p(X)},[]),M=D.useCallback(()=>{if(!u)return;const z=m.trim(),X=n.map(te=>te.id===u?{...te,description:z||te.description}:te);T(X),c(null)},[u,m,n,T]),G=D.useCallback(z=>{const X=n.map(te=>te.id===z?{...te,status:mT[te.status]??"pending"}:te);T(X)},[n,T]),W=D.useCallback(z=>{T(n.filter(X=>X.id!==z))},[n,T]),O=D.useCallback(()=>{T([]),x(!1)},[T]),U=D.useCallback(z=>{z.key==="Enter"&&(z.preventDefault(),L()),z.key==="Escape"&&A()},[L,A]),V=D.useCallback(z=>{z.key==="Enter"&&M(),z.key==="Escape"&&c(null)},[M]);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:()=>C(!0),className:"text-accent-primary hover:underline not-italic cursor-pointer",children:"Learn more"})]}),n.map((z,X)=>{const te=z.status,H=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:()=>G(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(Ku,{status:te})}),o.jsx("div",{className:"flex-1 min-w-0",children:H?o.jsx("input",{ref:N,value:m,onChange:I=>p(I.target.value),onBlur:M,onKeyDown:V,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:()=>R(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,"] ",JS(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(_l,{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:d,onChange:z=>f(z.target.value),onKeyDown:U,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(Ks,{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(Ks,{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(xl,{className:"w-3 h-3"}),"Clear all"]}),o.jsx("button",{onClick:()=>C(!0),className:"flex items-center gap-1 text-xs text-text-muted hover:text-accent-primary transition-colors cursor-pointer",title:"About criteria",children:o.jsx(CS,{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(Ot,{isOpen:w,onClose:()=>C(!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(Gc,{id:"planner",agents:y})," 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(gT,{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(Gc,{id:"builder",agents:y}),' agent, that will be forced to continue until it marks all criteria as "completed"']}),o.jsxs("li",{children:["Then launch the ",o.jsx(Gc,{id:"verifier",agents:y})," 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(Gc,{id:"code_reviewer",agents:y})," 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 _T({isOpen:e,onClose:t}){const n=Or(C=>C.config),s=Or(C=>C.saveConfig),[a,l]=D.useState(""),[u,c]=D.useState(""),[d,f]=D.useState(!1),[m,p]=D.useState(!1),[_,x]=D.useState(!1);D.useEffect(()=>{e&&(l((n==null?void 0:n.command)??""),c((n==null?void 0:n.url)??""),f((n==null?void 0:n.hotReload)??!1),p((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:d,disableInspect:m}),x(!1),t())};return o.jsx(Ot,{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:C=>l(C.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:C=>c(C.target.value),placeholder:"http://localhost:3000"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("input",{type:"checkbox",id:"hotReload",checked:d,onChange:C=>f(C.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:m,onChange:C=>p(C.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 tb={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"},yT={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"},nb={1:"font-bold",2:"opacity-75",4:"underline",7:"bg-bg-secondary"},vT="text-text-primary";function bT(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 d=[];for(const f of c)if(f>=30&&f<=37){const m=tb[f];m&&d.push(m)}else if(f>=40&&f<=47){const m=yT[f];m&&d.push(m)}else if(f>=90&&f<=97){const m=tb[f];m&&d.push(m)}else if(f in nb){const m=nb[f];m&&d.push(m)}else f===39?d.push(vT):f===49&&(a=a.split(" ").filter(m=>!m.startsWith("bg-")).join(" "));d.length>0&&(a=d.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:ST(e),className:"text-text-primary"}]}}function ST(e){return e.replace(new RegExp("\x1B\\[([0-9;]+)m","g"),"")}function xu(e){const t=bT(e),n=[];return t.forEach((s,a)=>{const l=s.text.split(`
90
+ `);l.forEach((u,c)=>{n.push(Us.createElement("span",{key:`${a}-${c}`,className:s.className,style:{display:"inline-block",whiteSpace:"pre-wrap"}},u)),c<l.length-1&&n.push(Us.createElement("br",{key:`${a}-${c}-br`}))})}),n.length===1?n[0]:n}function ZS({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:xu(s.content)},a))})}function kp({isActive:e,onToggle:t,className:n,style:s}){return o.jsxs("button",{type:"button",onClick:()=>t(!e),className:n,style:s,children:[e?o.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent-success"}):o.jsx(dr,{className:"w-3 h-3"}),e?"live":"scroll to bottom"]})}const Yu=(e,t)=>{const n=D.useRef(!0),s=D.useRef(null),[a,l]=D.useState(!0),u=()=>{const c=e.current;c&&(c.scrollTop=c.scrollHeight)};return D.useEffect(()=>{const c=e.current;if(!c)return;const d=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)},m=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))}))},p=new MutationObserver(()=>{n.current&&requestAnimationFrame(u)}),_=setInterval(()=>{n.current&&u()},1e3);return c.addEventListener("wheel",d,{passive:!0}),c.addEventListener("touchstart",f,{passive:!0}),c.addEventListener("touchmove",m,{passive:!0}),p.observe(c,{childList:!0,subtree:!0,characterData:!0}),()=>{c.removeEventListener("wheel",d),c.removeEventListener("touchstart",f),c.removeEventListener("touchmove",m),p.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()}}},e1=D.memo(function({title:t,logs:n,onClose:s,preClassName:a}){const l=D.useRef(null),{isAutoScrollActive:u,setAutoScroll:c}=Yu(l,null);return o.jsx(Ot,{isOpen:!0,onClose:s,title:t,size:"full",headerRight:o.jsx(kp,{isActive:u,onToggle:c,className:"text-xs text-text-muted hover:text-text-primary flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors"}),children:o.jsx("div",{ref:l,className:"h-full overflow-y-auto",children:o.jsx(ZS,{logs:n,preClassName:a})})})}),wT=D.memo(function({logs:t,anchorRef:n,isHiding:s,isAutoScrollActive:a,onSetAutoScroll:l}){const[u,c]=D.useState(null),d=D.useRef(null),f=D.useRef(l);return f.current=l,D.useEffect(()=>{var p;const m=(p=n.current)==null?void 0:p.getBoundingClientRect();m&&c({bottom:window.innerHeight-m.bottom,right:window.innerWidth-m.right,width:m.width,height:m.height})},[n]),D.useEffect(()=>{const m=d.current;if(!m)return;const p=_=>{if(_.deltaY<0){f.current(!1);return}_.deltaY>0&&requestAnimationFrame(()=>requestAnimationFrame(()=>{m.scrollHeight-m.scrollTop-m.offsetHeight<100&&f.current(!0)}))};return m.addEventListener("wheel",p,{passive:!0}),()=>m.removeEventListener("wheel",p)},[]),D.useEffect(()=>{d.current&&a&&(d.current.scrollTop=d.current.scrollHeight)},[t,a,u]),o.jsx("div",{className:`relative ${u?"":"hidden"}`,children:o.jsx("pre",{ref:d,className:"fixed z-40 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:u?{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}:void 0,children:t.map((m,p)=>o.jsx("span",{className:m.stream==="stderr"?"text-accent-warning":"",children:xu(m.content)},p))})})}),CT=D.memo(function({workdir:t}){const n=Or(U=>U.setWorkdir),s=Or(U=>U.status),a=Or(U=>U.config),l=Or(U=>U.logs),u=Or(U=>U.start),c=Or(U=>U.stop),d=Or(U=>U.fetchLogs),f=we(U=>U.currentSession),[m,p]=D.useState(!1),[_,x]=D.useState(!1),[w,C]=D.useState(!1),[v,S]=D.useState(!1),b=D.useRef(null),{isAutoScrollActive:y,setAutoScroll:E}=Yu(b,null),N=D.useRef(null),T=D.useRef(null),L=D.useRef(null),A=D.useRef(null),R=()=>{const U=s==null?void 0:s.inspectProxyPort;if(!U){s!=null&&s.url&&window.open(s.url,"_blank");return}const V=`${window.location.protocol}//${window.location.hostname}:${U}`,z=window.open(V,"_blank");if(z){A.current=z;const X=()=>{var H;!A.current||A.current.closed||(A.current.postMessage({type:"setFoxSessionId",sessionId:(f==null?void 0:f.id)??null},"*"),A.current.postMessage({type:"setFoxSessionTitle",sessionTitle:((H=f==null?void 0:f.metadata)==null?void 0:H.title)??null},"*"),A.current.postMessage({type:"setFoxInspectEnabled",enabled:!(a!=null&&a.disableInspect)},"*"))},te=setInterval(()=>{X(),(!A.current||A.current.closed)&&clearInterval(te)},500);setTimeout(()=>clearInterval(te),5e3)}},M=(s==null?void 0:s.state)??"off",G=a!==null,W=M==="running"||M==="warning";D.useEffect(()=>{n(t??null)},[t,n]),D.useEffect(()=>{W&&d()},[W,d]);const O=()=>{W?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 ${M==="running"?"bg-accent-success":M==="warning"?"bg-accent-warning":M==="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:()=>p(!0),className:"p-1.5 rounded hover:bg-bg-tertiary transition-colors text-text-muted",title:"Configure dev server",children:o.jsx(wS,{})})]}),G?o.jsx(o.Fragment,{children:M==="running"||M==="warning"?o.jsxs("div",{className:"flex gap-2",children:[o.jsxs("button",{onClick:O,className:"flex-1 flex items-center justify-center gap-1.5 rounded font-medium text-sm px-3 py-1.5 bg-bg-tertiary text-text-primary hover:bg-border transition-colors",children:[o.jsx(ES,{}),"Stop"]}),(s==null?void 0:s.url)&&o.jsxs("button",{onClick:()=>R(),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(Rj,{}),"Open"]})]}):o.jsx("button",{onClick:O,className:"w-full rounded font-medium text-sm px-3 py-1.5 bg-accent-primary/25 text-text-primary hover:bg-accent-primary/40 transition-colors",children:"Start"})}):o.jsx("button",{onClick:()=>p(!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.jsxs("div",{ref:L,className:`relative ${G&&W?"":"hidden"}`,onMouseEnter:()=>{!G||!W||(T.current&&clearTimeout(T.current),N.current=setTimeout(()=>{C(!0),S(!1)},500))},onMouseLeave:()=>{N.current&&clearTimeout(N.current),S(!0),T.current=setTimeout(()=>C(!1),150)},children:[o.jsx(ZS,{logs:l,preRef:b,preClassName:"text-sm bg-bg-primary p-2 rounded overflow-auto max-h-[200px] border border-border"}),G&&W&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"absolute bottom-1 right-1 z-50 flex items-center gap-1",children:[(w||v)&&o.jsx(kp,{isActive:y,onToggle:E,className:"text-xs text-text-muted hover:text-text-primary flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors"}),o.jsx("button",{onClick:()=>x(!0),className:"px-2 py-0.5 rounded text-xs font-medium bg-accent-primary/30 text-text-primary hover:bg-accent-primary/50 transition-colors",children:"Expand"})]}),(w||v)&&L.current&&Ha.createPortal(o.jsx(wT,{logs:l,anchorRef:L,isHiding:v,isAutoScrollActive:y,onSetAutoScroll:E}),document.body)]})]}),o.jsx(_T,{isOpen:m,onClose:()=>p(!1)}),_&&o.jsx(e1,{title:"Dev Server Logs",logs:l,onClose:()=>x(!1)})]})}),kT=D.memo(function({sessionId:t}){var x;const n=tl(w=>w.processes),s=tl(w=>w.stopProcess),[a,l]=D.useState(null),[u,c]=D.useState([]),d=n.filter(w=>w.status!=="exited"),f=d.filter(w=>w.status==="running").length;if(n.length===0)return null;const m=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"}},p=w=>{const C=tl.getState().logs[w]??[];c(C.map(v=>({content:v.content,stream:v.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:d.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 ${m(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:()=>p(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(e1,{title:((x=d.find(w=>w.id===a))==null?void 0:x.name)??"",logs:u,onClose:()=>{l(null),c([])}})]})});function ET({isOpen:e,onClose:t,versionInfo:n}){const[s,a]=D.useState("ready"),[l,u]=D.useState(""),[c,d]=D.useState(n),[f,m]=D.useState(!1),[p,_]=D.useState(null),[x,w]=D.useState(null),[C,v]=D.useState(!1);D.useEffect(()=>{if(e){if(n){d(n);return}fetch("/api/auto-update/check").then(E=>E.json()).then(E=>{d({current:E.current,latest:E.latest}),m(E.isService??!1)}).catch(()=>{})}},[e]),D.useEffect(()=>{if(!e||s!=="updating")return;const E=setInterval(()=>{u(N=>N.length>=3?"":N+".")},400);return()=>clearInterval(E)},[e,s]);const S=D.useCallback(async()=>{a("updating"),w(null);try{const N=await(await Ne("/api/auto-update",{method:"POST"})).json();if(m(N.isService??!1),N.success){const T=N.version??"unknown";_(T),localStorage.setItem("openfox_updated_to",T),localStorage.setItem("update_pending","true"),a("complete")}else w(N.error??"Update failed"),a("failed")}catch(E){w(E instanceof Error?E.message:"Update request failed"),a("failed")}},[]),b=D.useCallback(async()=>{v(!0);try{await Ne("/api/auto-update/restart",{method:"POST"})}catch{}setTimeout(()=>window.location.reload(),1e4)},[]);D.useEffect(()=>{e&&(a("ready"),u(""),_(null),w(null),v(!1))},[e]);const y=s!=="updating";return o.jsxs(Ot,{isOpen:e,onClose:y?t:void 0,title:s==="failed"?"Update Failed":s==="complete"?"Update Complete":"New OpenFox Version Available",size:"sm",closeOnBackdropClick:y,showCloseButton:y,children:[o.jsxs("div",{className:"flex flex-col gap-4",children:[c&&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:c.current})]}),c&&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:c.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.jsxs("p",{className:"text-xs text-text-muted text-center",children:["Updating",l]})]}),s==="complete"&&o.jsxs("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",p??(c==null?void 0:c.latest),".",!f&&" Please restart OpenFox to use the new version."]}),f&&o.jsx("button",{onClick:b,disabled:C,className:"w-full px-3 py-2 text-sm rounded bg-accent-primary hover:brightness-110 transition-all text-white font-medium disabled:opacity-50",children:C?"Reloading in 10s…":"Restart Service"})]}),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:x})]}),o.jsx("div",{className:"bg-bg-tertiary rounded px-3 py-2 text-xs font-mono text-text-secondary",children:"openfox update"}),o.jsx("p",{className:"text-xs text-text-muted",children:"Run this command in your terminal to complete the update."})]})]}),s==="ready"&&o.jsx("button",{onClick:S,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"})]})}function jT({file:e}){const t=KS(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 NT(){const{diff:e}=XS();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(jT,{file:t},n))})})}function rb({messages:e,workdir:t}){var C,v,S,b;const[n,s]=D.useState(!1),[a,l]=D.useState(!1),[u,c]=D.useState(!1),[d,f]=D.useState(!1),m=KN(e),{branch:p}=XS(),_=zt(y=>y.version),x=we(y=>y.currentSession),w=D.useCallback(async()=>{l(!0);try{const y=await fetch("/api/auto-update/check");if(y.ok){const E=await y.json();c(E.isUpdateAvailable)}}catch{}finally{l(!1)}},[]);return D.useEffect(()=>{w()},[w]),o.jsxs("div",{className:"flex flex-col h-full",children:[m&&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:YN(m.aiTime)}),o.jsx("span",{className:"w-px h-3 bg-border"}),o.jsx("span",{className:"text-text-secondary",children:Xv(m.avgPrefillSpeed)}),o.jsx("span",{children:"pp"}),o.jsx("span",{className:"w-px h-3 bg-border"}),o.jsx("span",{className:"text-text-secondary",children:Xv(m.avgGenerationSpeed)}),o.jsx("span",{children:"tg"})]})}),o.jsx(aT,{isOpen:n,onClose:()=>s(!1),stats:m})]}),o.jsx("div",{className:"flex flex-col flex-1 overflow-y-auto",children:o.jsxs("div",{className:"mt-4",children:[o.jsx(eb,{entries:((C=x==null?void 0:x.metadataEntries)==null?void 0:C.criteria)??[],title:"Acceptance Criteria"}),x&&o.jsx(xT,{entries:((v=x==null?void 0:x.metadataEntries)==null?void 0:v.criteria)??[],sessionId:x.id}),x&&(((b=(S=x.metadataEntries)==null?void 0:S.review_findings)==null?void 0:b.length)??0)>0&&o.jsxs("div",{className:"mt-6",children:[o.jsx(eb,{entries:x.metadataEntries.review_findings,title:"Review Findings"}),o.jsx(hT,{entries:x.metadataEntries.review_findings})]})]})}),p&&o.jsxs("div",{className:"mt-4 flex items-center gap-2 text-sm",children:[o.jsx(jj,{}),o.jsx("span",{className:"truncate text-text-secondary",title:p,children:p})]}),o.jsx(NT,{}),o.jsx(CT,{workdir:t}),o.jsx(kT,{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(pp,{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(ET,{isOpen:d,onClose:()=>f(!1),versionInfo:null})]})}function TT({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(rb,{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:`
91
+ md:hidden
92
+ p-4 overflow-y-auto bg-secondary
93
+ transition-all duration-300 ease-in-out
94
+ fixed right-0 top-[32px] h-[calc(100vh-32px)] z-50
95
+ ${t?"w-[320px] translate-x-0 border-l border-border":"w-[320px] translate-x-full"}
96
+ `,children:o.jsx(rb,{messages:s,workdir:a==null?void 0:a.workdir})})]})]})}function AT(e,t){return t||e>85?"bg-accent-error":e>60?"bg-accent-warning":"bg-accent-success"}function t1({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 ${AT(e,t)}`,style:{width:`${Math.min(e,100)}%`}})})}function LT({dangerZone:e,size:t="md"}){return e?o.jsx("span",{className:"text-accent-error animate-pulse text-[10px] font-medium",children:"Low!"}):null}function sb(e,t){return t||e>85?"text-accent-error":e>60?"text-accent-warning":"text-text-muted"}function DT(){const e=we(b=>b.contextState),t=we(b=>b.currentSession),n=we(b=>b.compactContext),[s,a]=D.useState(!1),[l,u]=D.useState(!1),[c,d]=D.useState(!1),f=D.useRef(!1);if(D.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:m,maxTokens:p,compactionCount:_,dangerZone:x,dynamicContextChanged:w}=e,C=Math.round(m/p*100),v=t.isRunning,S=()=>{$t.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:sb(C,x),children:[pu(m)," / ",pu(p)]}),o.jsxs("span",{className:sb(C,x),children:["(",C,"%)"]}),o.jsx(t1,{percent:C,dangerZone:x}),o.jsx(LT,{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(kS,{})}),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:()=>{v||n(),a(!1)},disabled:v,className:"w-full px-3 py-1.5 text-left text-sm hover:bg-bg-tertiary transition-colors disabled:opacity-40 disabled:cursor-not-allowed",title:v?"Cannot compact while running":"Compact context",children:o.jsx("span",{className:x?"text-accent-error":"",children:"Compact"})}),w&&o.jsx("button",{onClick:()=>{a(!1),d(!0)},disabled:v,className:"w-full px-3 py-1.5 text-left text-sm hover:bg-bg-tertiary transition-colors disabled:opacity-40 disabled:cursor-not-allowed",title:v?"Cannot 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:()=>d(!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(_l,{})})]})}),o.jsxs(Ot,{isOpen:c,onClose:()=>d(!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:()=>d(!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(),d(!1)},disabled:v,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 RT({stats:e,onClose:t}){var n;return o.jsx(Ot,{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(Wc,{label:"Total Time",value:`${e.totalTime.toFixed(1)}s`}),o.jsx(Wc,{label:"Prefill",value:e.prefillTokens>=1e3?`${(e.prefillTokens/1e3).toFixed(1)}k`:String(e.prefillTokens)}),o.jsx(Wc,{label:"Generated",value:e.generationTokens>=1e3?`${(e.generationTokens/1e3).toFixed(1)}k`:String(e.generationTokens)}),o.jsx(Wc,{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(qc,{label:"temp",value:s.temperature.toFixed(2)}),s.topP!==void 0&&o.jsx(qc,{label:"topP",value:s.topP.toFixed(2)}),s.topK!==void 0&&o.jsx(qc,{label:"topK",value:String(s.topK)}),s.maxTokens!==void 0&&o.jsx(qc,{label:"maxTok",value:String(s.maxTokens)})]})]})]},a))]})]})})}function Wc({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 qc({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 OT(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const MT=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,IT=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,PT={};function ib(e,t){return(PT.jsx?IT:MT).test(e)}const BT=/[ \t\n\f\r]/g;function zT(e){return typeof e=="object"?e.type==="text"?ab(e.value):!1:ab(e)}function ab(e){return e.replace(BT,"")===""}let Sl=class{constructor(t,n,s){this.normal=n,this.property=t,s&&(this.space=s)}};Sl.prototype.normal={};Sl.prototype.property={};Sl.prototype.space=void 0;function n1(e,t){const n={},s={};for(const a of e)Object.assign(n,a.property),Object.assign(s,a.normal);return new Sl(n,s,t)}function Lm(e){return e.toLowerCase()}let In=class{constructor(t,n){this.attribute=n,this.property=t}};In.prototype.attribute="";In.prototype.booleanish=!1;In.prototype.boolean=!1;In.prototype.commaOrSpaceSeparated=!1;In.prototype.commaSeparated=!1;In.prototype.defined=!1;In.prototype.mustUseProperty=!1;In.prototype.number=!1;In.prototype.overloadedBoolean=!1;In.prototype.property="";In.prototype.spaceSeparated=!1;In.prototype.space=void 0;let $T=0;const Qe=Di(),Jt=Di(),Dm=Di(),ke=Di(),At=Di(),Oa=Di(),Gn=Di();function Di(){return 2**++$T}const Rm=Object.freeze(Object.defineProperty({__proto__:null,boolean:Qe,booleanish:Jt,commaOrSpaceSeparated:Gn,commaSeparated:Oa,number:ke,overloadedBoolean:Dm,spaceSeparated:At},Symbol.toStringTag,{value:"Module"})),Uf=Object.keys(Rm);let Ep=class extends In{constructor(t,n,s,a){let l=-1;if(super(t,n),ob(this,"space",a),typeof s=="number")for(;++l<Uf.length;){const u=Uf[l];ob(this,Uf[l],(s&Rm[u])===Rm[u])}}};Ep.prototype.defined=!0;function ob(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 Ep(s,e.transform(e.attributes||{},s),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(s)&&(l.mustUseProperty=!0),t[s]=l,n[Lm(s)]=s,n[Lm(l.attribute)]=s}return new Sl(t,n,e.space)}const r1=Ua({properties:{ariaActiveDescendant:null,ariaAtomic:Jt,ariaAutoComplete:null,ariaBusy:Jt,ariaChecked:Jt,ariaColCount:ke,ariaColIndex:ke,ariaColSpan:ke,ariaControls:At,ariaCurrent:null,ariaDescribedBy:At,ariaDetails:null,ariaDisabled:Jt,ariaDropEffect:At,ariaErrorMessage:null,ariaExpanded:Jt,ariaFlowTo:At,ariaGrabbed:Jt,ariaHasPopup:null,ariaHidden:Jt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:At,ariaLevel:ke,ariaLive:null,ariaModal:Jt,ariaMultiLine:Jt,ariaMultiSelectable:Jt,ariaOrientation:null,ariaOwns:At,ariaPlaceholder:null,ariaPosInSet:ke,ariaPressed:Jt,ariaReadOnly:Jt,ariaRelevant:null,ariaRequired:Jt,ariaRoleDescription:At,ariaRowCount:ke,ariaRowIndex:ke,ariaRowSpan:ke,ariaSelected:Jt,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 s1(e,t){return t in e?e[t]:t}function i1(e,t){return s1(e,t.toLowerCase())}const HT=Ua({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Oa,acceptCharset:At,accessKey:At,action:null,allow:null,allowFullScreen:Qe,allowPaymentRequest:Qe,allowUserMedia:Qe,alt:null,as:null,async:Qe,autoCapitalize:null,autoComplete:At,autoFocus:Qe,autoPlay:Qe,blocking:At,capture:null,charSet:null,checked:Qe,cite:null,className:At,cols:ke,colSpan:null,content:null,contentEditable:Jt,controls:Qe,controlsList:At,coords:ke|Oa,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Qe,defer:Qe,dir:null,dirName:null,disabled:Qe,download:Dm,draggable:Jt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Qe,formTarget:null,headers:At,height:ke,hidden:Dm,high:ke,href:null,hrefLang:null,htmlFor:At,httpEquiv:At,id:null,imageSizes:null,imageSrcSet:null,inert:Qe,inputMode:null,integrity:null,is:null,isMap:Qe,itemId:null,itemProp:At,itemRef:At,itemScope:Qe,itemType:At,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Qe,low:ke,manifest:null,max:null,maxLength:ke,media:null,method:null,min:null,minLength:ke,multiple:Qe,muted:Qe,name:null,nonce:null,noModule:Qe,noValidate:Qe,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:Qe,optimum:ke,pattern:null,ping:At,placeholder:null,playsInline:Qe,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Qe,referrerPolicy:null,rel:At,required:Qe,reversed:Qe,rows:ke,rowSpan:ke,sandbox:At,scope:null,scoped:Qe,seamless:Qe,selected:Qe,shadowRootClonable:Qe,shadowRootDelegatesFocus:Qe,shadowRootMode:null,shape:null,size:ke,sizes:null,slot:null,span:ke,spellCheck:Jt,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:Qe,useMap:null,value:Jt,width:ke,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:At,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:Qe,declare:Qe,event:null,face:null,frame:null,frameBorder:null,hSpace:ke,leftMargin:ke,link:null,longDesc:null,lowSrc:null,marginHeight:ke,marginWidth:ke,noResize:Qe,noHref:Qe,noShade:Qe,noWrap:Qe,object:null,profile:null,prompt:null,rev:null,rightMargin:ke,rules:null,scheme:null,scrolling:Jt,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:Qe,disableRemotePlayback:Qe,prefix:null,property:null,results:ke,security:null,unselectable:null},space:"html",transform:i1}),UT=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:Gn,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:At,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:Qe,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:Gn,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:At,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:ke,pointsAtY:ke,pointsAtZ:ke,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Gn,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Gn,rev:Gn,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Gn,requiredFeatures:Gn,requiredFonts:Gn,requiredFormats:Gn,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:Gn,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:Gn,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:Gn,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:s1}),a1=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()}}),o1=Ua({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:i1}),l1=Ua({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),FT={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"},VT=/[A-Z]/g,lb=/-[a-z]/g,GT=/^data[-\w.:]+$/i;function WT(e,t){const n=Lm(t);let s=t,a=In;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&GT.test(t)){if(t.charAt(4)==="-"){const l=t.slice(5).replace(lb,KT);s="data"+l.charAt(0).toUpperCase()+l.slice(1)}else{const l=t.slice(4);if(!lb.test(l)){let u=l.replace(VT,qT);u.charAt(0)!=="-"&&(u="-"+u),t="data"+u}}a=Ep}return new a(s,t)}function qT(e){return"-"+e.toLowerCase()}function KT(e){return e.charAt(1).toUpperCase()}const YT=n1([r1,HT,a1,o1,l1],"html"),jp=n1([r1,UT,a1,o1,l1],"svg");function XT(e){return e.join(" ").trim()}var Sa={},Ff,cb;function QT(){if(cb)return Ff;cb=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,s=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,a=/^:\s*/,l=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,u=/^[;\s]*/,c=/^\s+|\s+$/g,d=`
97
+ `,f="/",m="*",p="",_="comment",x="declaration";function w(v,S){if(typeof v!="string")throw new TypeError("First argument must be a string");if(!v)return[];S=S||{};var b=1,y=1;function E(U){var V=U.match(t);V&&(b+=V.length);var z=U.lastIndexOf(d);y=~z?U.length-z:y+U.length}function N(){var U={line:b,column:y};return function(V){return V.position=new T(U),R(),V}}function T(U){this.start=U,this.end={line:b,column:y},this.source=S.source}T.prototype.content=v;function L(U){var V=new Error(S.source+":"+b+":"+y+": "+U);if(V.reason=U,V.filename=S.source,V.line=b,V.column=y,V.source=v,!S.silent)throw V}function A(U){var V=U.exec(v);if(V){var z=V[0];return E(z),v=v.slice(z.length),V}}function R(){A(n)}function M(U){var V;for(U=U||[];V=G();)V!==!1&&U.push(V);return U}function G(){var U=N();if(!(f!=v.charAt(0)||m!=v.charAt(1))){for(var V=2;p!=v.charAt(V)&&(m!=v.charAt(V)||f!=v.charAt(V+1));)++V;if(V+=2,p===v.charAt(V-1))return L("End of comment missing");var z=v.slice(2,V-2);return y+=2,E(z),v=v.slice(V),y+=2,U({type:_,comment:z})}}function W(){var U=N(),V=A(s);if(V){if(G(),!A(a))return L("property missing ':'");var z=A(l),X=U({type:x,property:C(V[0].replace(e,p)),value:z?C(z[0].replace(e,p)):p});return A(u),X}}function O(){var U=[];M(U);for(var V;V=W();)V!==!1&&(U.push(V),M(U));return U}return R(),O()}function C(v){return v?v.replace(c,p):p}return Ff=w,Ff}var ub;function JT(){if(ub)return Sa;ub=1;var e=Sa&&Sa.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(Sa,"__esModule",{value:!0}),Sa.default=n;const t=e(QT());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(d=>{if(d.type!=="declaration")return;const{property:f,value:m}=d;c?a(f,m,d):m&&(l=l||{},l[f]=m)}),l}return Sa}var Fo={},db;function ZT(){if(db)return Fo;db=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,m){return m.toUpperCase()},c=function(f,m){return"".concat(m,"-")},d=function(f,m){return m===void 0&&(m={}),l(f)?f:(f=f.toLowerCase(),m.reactCompat?f=f.replace(a,c):f=f.replace(s,c),f.replace(t,u))};return Fo.camelCase=d,Fo}var Vo,hb;function eA(){if(hb)return Vo;hb=1;var e=Vo&&Vo.__importDefault||function(a){return a&&a.__esModule?a:{default:a}},t=e(JT()),n=ZT();function s(a,l){var u={};return!a||typeof a!="string"||(0,t.default)(a,function(c,d){c&&d&&(u[(0,n.camelCase)(c,l)]=d)}),u}return s.default=s,Vo=s,Vo}var tA=eA();const nA=Mu(tA),c1=u1("end"),Np=u1("start");function u1(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 rA(e){const t=Np(e),n=c1(e);if(t&&n)return{start:t,end:n}}function nl(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?fb(e.position):"start"in e||"end"in e?fb(e):"line"in e||"column"in e?Om(e):""}function Om(e){return mb(e&&e.line)+":"+mb(e&&e.column)}function fb(e){return Om(e&&e.start)+"-"+Om(e&&e.end)}function mb(e){return e&&typeof e=="number"?e:1}class wn 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 d=s.indexOf(":");d===-1?l.ruleId=s:(l.source=s.slice(0,d),l.ruleId=s.slice(d+1))}if(!l.place&&l.ancestors&&l.ancestors){const d=l.ancestors[l.ancestors.length-1];d&&(l.place=d.position)}const c=l.place&&"start"in l.place?l.place.start:l.place;this.ancestors=l.ancestors||void 0,this.cause=l.cause||void 0,this.column=c?c.column:void 0,this.fatal=void 0,this.file="",this.message=a,this.line=c?c.line:void 0,this.name=nl(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}}wn.prototype.file="";wn.prototype.name="";wn.prototype.reason="";wn.prototype.message="";wn.prototype.stack="";wn.prototype.column=void 0;wn.prototype.line=void 0;wn.prototype.ancestors=void 0;wn.prototype.cause=void 0;wn.prototype.fatal=void 0;wn.prototype.place=void 0;wn.prototype.ruleId=void 0;wn.prototype.source=void 0;const Tp={}.hasOwnProperty,sA=new Map,iA=/[A-Z]/g,aA=new Set(["table","tbody","thead","tfoot","tr"]),oA=new Set(["td","th"]),d1="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function lA(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=gA(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=pA(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"?jp:YT,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},l=h1(a,e,void 0);return l&&typeof l!="string"?l:a.create(e,a.Fragment,{children:l||void 0},void 0)}function h1(e,t,n){if(t.type==="element")return cA(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return uA(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return hA(e,t,n);if(t.type==="mdxjsEsm")return dA(e,t);if(t.type==="root")return fA(e,t,n);if(t.type==="text")return mA(e,t)}function cA(e,t,n){const s=e.schema;let a=s;t.tagName.toLowerCase()==="svg"&&s.space==="html"&&(a=jp,e.schema=a),e.ancestors.push(t);const l=m1(e,t.tagName,!1),u=xA(e,t);let c=Lp(e,t);return aA.has(t.tagName)&&(c=c.filter(function(d){return typeof d=="string"?!zT(d):!0})),f1(e,u,l,t),Ap(u,c),e.ancestors.pop(),e.schema=s,e.create(t,l,u,n)}function uA(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)}ll(e,t.position)}function dA(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);ll(e,t.position)}function hA(e,t,n){const s=e.schema;let a=s;t.name==="svg"&&s.space==="html"&&(a=jp,e.schema=a),e.ancestors.push(t);const l=t.name===null?e.Fragment:m1(e,t.name,!0),u=_A(e,t),c=Lp(e,t);return f1(e,u,l,t),Ap(u,c),e.ancestors.pop(),e.schema=s,e.create(t,l,u,n)}function fA(e,t,n){const s={};return Ap(s,Lp(e,t)),e.create(t,e.Fragment,s,n)}function mA(e,t){return t.value}function f1(e,t,n,s){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=s)}function Ap(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function pA(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 gA(e,t){return n;function n(s,a,l,u){const c=Array.isArray(l.children),d=Np(s);return t(a,l,u,c,{columnNumber:d?d.column-1:void 0,fileName:e,lineNumber:d?d.line:void 0},void 0)}}function xA(e,t){const n={};let s,a;for(a in t.properties)if(a!=="children"&&Tp.call(t.properties,a)){const l=yA(e,a,t.properties[a]);if(l){const[u,c]=l;e.tableCellAlignToStyle&&u==="align"&&typeof c=="string"&&oA.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 _A(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 ll(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 ll(e,t.position);else l=s.value===null?!0:s.value;n[a]=l}return n}function Lp(e,t){const n=[];let s=-1;const a=e.passKeys?new Map:sA;for(;++s<t.children.length;){const l=t.children[s];let u;if(e.passKeys){const d=l.type==="element"?l.tagName:l.type==="mdxJsxFlowElement"||l.type==="mdxJsxTextElement"?l.name:void 0;if(d){const f=a.get(d)||0;u=d+"-"+f,a.set(d,f+1)}}const c=h1(e,l,u);c!==void 0&&n.push(c)}return n}function yA(e,t,n){const s=WT(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=s.commaSeparated?OT(n):XT(n)),s.property==="style"){let a=typeof n=="object"?n:vA(e,String(n));return e.stylePropertyNameCase==="css"&&(a=bA(a)),["style",a]}return[e.elementAttributeNameCase==="react"&&s.space?FT[s.property]||s.property:s.attribute,n]}}function vA(e,t){try{return nA(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const s=n,a=new wn("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=d1+"#cannot-parse-style-attribute",a}}function m1(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=ib(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=ib(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(s.type==="Literal"){const a=s.value;return Tp.call(e.components,a)?e.components[a]:a}if(e.evaluater)return e.evaluater.evaluateExpression(s);ll(e)}function ll(e,t){const n=new wn("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=d1+"#cannot-handle-mdx-estrees-without-createevaluater",n}function bA(e){const t={};let n;for(n in e)Tp.call(e,n)&&(t[SA(n)]=e[n]);return t}function SA(e){let t=e.replace(iA,wA);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function wA(e){return"-"+e.toLowerCase()}const Vf={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"]},CA={};function Dp(e,t){const n=CA,s=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,a=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return p1(e,s,a)}function p1(e,t,n){if(kA(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 pb(e.children,t,n)}return Array.isArray(e)?pb(e,t,n):""}function pb(e,t,n){const s=[];let a=-1;for(;++a<e.length;)s[a]=p1(e[a],t,n);return s.join("")}function kA(e){return!!(e&&typeof e=="object")}const gb=document.createElement("i");function Rp(e){const t="&"+e+";";gb.innerHTML=t;const n=gb.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function Kn(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 or(e,t){return e.length>0?(Kn(e,e.length,0,t),e):t}const xb={}.hasOwnProperty;function g1(e){const t={};let n=-1;for(;++n<e.length;)EA(t,e[n]);return t}function EA(e,t){let n;for(n in t){const a=(xb.call(e,n)?e[n]:void 0)||(e[n]={}),l=t[n];let u;if(l)for(u in l){xb.call(a,u)||(a[u]=[]);const c=l[u];jA(a[u],Array.isArray(c)?c:c?[c]:[])}}}function jA(e,t){let n=-1;const s=[];for(;++n<t.length;)(t[n].add==="after"?e:s).push(t[n]);Kn(e,0,0,s)}function x1(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 Sr(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const En=Ys(/[A-Za-z]/),Sn=Ys(/[\dA-Za-z]/),NA=Ys(/[#-'*+\--9=?A-Z^-~]/);function _u(e){return e!==null&&(e<32||e===127)}const Mm=Ys(/\d/),TA=Ys(/[\dA-Fa-f]/),AA=Ys(/[!-/:-@[-`{-~]/);function He(e){return e!==null&&e<-2}function Tt(e){return e!==null&&(e<0||e===32)}function st(e){return e===-2||e===-1||e===32}const Xu=Ys(new RegExp("\\p{P}|\\p{S}","u")),Ai=Ys(/\s/);function Ys(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&&Sn(e.charCodeAt(n+1))&&Sn(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(d){return st(d)?(e.enter(n),c(d)):t(d)}function c(d){return st(d)&&l++<a?(e.consume(d),c):(e.exit(n),t(d))}}const LA={tokenize:DA};function DA(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 d=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=d),n=d,u(c)}function u(c){if(c===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(c);return}return He(c)?(e.consume(c),e.exit("chunkText"),l):(e.consume(c),u)}}const RA={tokenize:OA},_b={tokenize:MA};function OA(e){const t=this,n=[];let s=0,a,l,u;return c;function c(y){if(s<n.length){const E=n[s];return t.containerState=E[1],e.attempt(E[0].continuation,d,f)(y)}return f(y)}function d(y){if(s++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,a&&b();const E=t.events.length;let N=E,T;for(;N--;)if(t.events[N][0]==="exit"&&t.events[N][1].type==="chunkFlow"){T=t.events[N][1].end;break}S(s);let L=E;for(;L<t.events.length;)t.events[L][1].end={...T},L++;return Kn(t.events,N+1,0,t.events.slice(E)),t.events.length=L,f(y)}return c(y)}function f(y){if(s===n.length){if(!a)return _(y);if(a.currentConstruct&&a.currentConstruct.concrete)return w(y);t.interrupt=!!(a.currentConstruct&&!a._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(_b,m,p)(y)}function m(y){return a&&b(),S(s),_(y)}function p(y){return t.parser.lazy[t.now().line]=s!==n.length,u=t.now().offset,w(y)}function _(y){return t.containerState={},e.attempt(_b,x,w)(y)}function x(y){return s++,n.push([t.currentConstruct,t.containerState]),_(y)}function w(y){if(y===null){a&&b(),S(0),e.consume(y);return}return a=a||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:a,contentType:"flow",previous:l}),C(y)}function C(y){if(y===null){v(e.exit("chunkFlow"),!0),S(0),e.consume(y);return}return He(y)?(e.consume(y),v(e.exit("chunkFlow")),s=0,t.interrupt=void 0,c):(e.consume(y),C)}function v(y,E){const N=t.sliceStream(y);if(E&&N.push(null),y.previous=l,l&&(l.next=y),l=y,a.defineSkip(y.start),a.write(N),t.parser.lazy[y.start.line]){let T=a.events.length;for(;T--;)if(a.events[T][1].start.offset<u&&(!a.events[T][1].end||a.events[T][1].end.offset>u))return;const L=t.events.length;let A=L,R,M;for(;A--;)if(t.events[A][0]==="exit"&&t.events[A][1].type==="chunkFlow"){if(R){M=t.events[A][1].end;break}R=!0}for(S(s),T=L;T<t.events.length;)t.events[T][1].end={...M},T++;Kn(t.events,A+1,0,t.events.slice(L)),t.events.length=T}}function S(y){let E=n.length;for(;E-- >y;){const N=n[E];t.containerState=N[1],N[0].exit.call(t,e)}n.length=y}function b(){a.write([null]),l=void 0,a=void 0,t.containerState._closeFlow=void 0}}function MA(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||Tt(e)||Ai(e))return 1;if(Xu(e))return 2}function Qu(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 Im={name:"attention",resolveAll:IA,tokenize:PA};function IA(e,t){let n=-1,s,a,l,u,c,d,f,m;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;d=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 p={...e[s][1].end},_={...e[n][1].start};yb(p,-d),yb(_,d),u={type:d>1?"strongSequence":"emphasisSequence",start:p,end:{...e[s][1].end}},c={type:d>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:_},l={type:d>1?"strongText":"emphasisText",start:{...e[s][1].end},end:{...e[n][1].start}},a={type:d>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=or(f,[["enter",e[s][1],t],["exit",e[s][1],t]])),f=or(f,[["enter",a,t],["enter",u,t],["exit",u,t],["enter",l,t]]),f=or(f,Qu(t.parser.constructs.insideSpan.null,e.slice(s+1,n),t)),f=or(f,[["exit",l,t],["enter",c,t],["exit",c,t],["exit",a,t]]),e[n][1].end.offset-e[n][1].start.offset?(m=2,f=or(f,[["enter",e[n][1],t],["exit",e[n][1],t]])):m=0,Kn(e,s-1,n-s+3,f),n=s+f.length-m-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function PA(e,t){const n=this.parser.constructs.attentionMarkers.null,s=this.previous,a=Pa(s);let l;return u;function u(d){return l=d,e.enter("attentionSequence"),c(d)}function c(d){if(d===l)return e.consume(d),c;const f=e.exit("attentionSequence"),m=Pa(d),p=!m||m===2&&a||n.includes(d),_=!a||a===2&&m||n.includes(s);return f._open=!!(l===42?p:p&&(a||!_)),f._close=!!(l===42?_:_&&(m||!p)),t(d)}}function yb(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const BA={name:"autolink",tokenize:zA};function zA(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 En(x)?(e.consume(x),u):x===64?n(x):f(x)}function u(x){return x===43||x===45||x===46||Sn(x)?(s=1,c(x)):f(x)}function c(x){return x===58?(e.consume(x),s=0,d):(x===43||x===45||x===46||Sn(x))&&s++<32?(e.consume(x),c):(s=0,f(x))}function d(x){return x===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(x),e.exit("autolinkMarker"),e.exit("autolink"),t):x===null||x===32||x===60||_u(x)?n(x):(e.consume(x),d)}function f(x){return x===64?(e.consume(x),m):NA(x)?(e.consume(x),f):n(x)}function m(x){return Sn(x)?p(x):n(x)}function p(x){return x===46?(e.consume(x),s=0,m):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||Sn(x))&&s++<63){const w=x===45?_:p;return e.consume(x),w}return n(x)}}const wl={partial:!0,tokenize:$A};function $A(e,t,n){return s;function s(l){return st(l)?ut(e,a,"linePrefix")(l):a(l)}function a(l){return l===null||He(l)?t(l):n(l)}}const _1={continuation:{tokenize:UA},exit:FA,name:"blockQuote",tokenize:HA};function HA(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 st(u)?(e.enter("blockQuotePrefixWhitespace"),e.consume(u),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(u))}}function UA(e,t,n){const s=this;return a;function a(u){return st(u)?ut(e,l,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(u):l(u)}function l(u){return e.attempt(_1,t,n)(u)}}function FA(e){e.exit("blockQuote")}const y1={name:"characterEscape",tokenize:VA};function VA(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 AA(l)?(e.enter("characterEscapeValue"),e.consume(l),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(l)}}const v1={name:"characterReference",tokenize:GA};function GA(e,t,n){const s=this;let a=0,l,u;return c;function c(p){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(p),e.exit("characterReferenceMarker"),d}function d(p){return p===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(p),e.exit("characterReferenceMarkerNumeric"),f):(e.enter("characterReferenceValue"),l=31,u=Sn,m(p))}function f(p){return p===88||p===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(p),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),l=6,u=TA,m):(e.enter("characterReferenceValue"),l=7,u=Mm,m(p))}function m(p){if(p===59&&a){const _=e.exit("characterReferenceValue");return u===Sn&&!Rp(s.sliceSerialize(_))?n(p):(e.enter("characterReferenceMarker"),e.consume(p),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return u(p)&&a++<l?(e.consume(p),m):n(p)}}const vb={partial:!0,tokenize:qA},bb={concrete:!0,name:"codeFenced",tokenize:WA};function WA(e,t,n){const s=this,a={partial:!0,tokenize:N};let l=0,u=0,c;return d;function d(T){return f(T)}function f(T){const L=s.events[s.events.length-1];return l=L&&L[1].type==="linePrefix"?L[2].sliceSerialize(L[1],!0).length:0,c=T,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),m(T)}function m(T){return T===c?(u++,e.consume(T),m):u<3?n(T):(e.exit("codeFencedFenceSequence"),st(T)?ut(e,p,"whitespace")(T):p(T))}function p(T){return T===null||He(T)?(e.exit("codeFencedFence"),s.interrupt?t(T):e.check(vb,C,E)(T)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),_(T))}function _(T){return T===null||He(T)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),p(T)):st(T)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),ut(e,x,"whitespace")(T)):T===96&&T===c?n(T):(e.consume(T),_)}function x(T){return T===null||He(T)?p(T):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),w(T))}function w(T){return T===null||He(T)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),p(T)):T===96&&T===c?n(T):(e.consume(T),w)}function C(T){return e.attempt(a,E,v)(T)}function v(T){return e.enter("lineEnding"),e.consume(T),e.exit("lineEnding"),S}function S(T){return l>0&&st(T)?ut(e,b,"linePrefix",l+1)(T):b(T)}function b(T){return T===null||He(T)?e.check(vb,C,E)(T):(e.enter("codeFlowValue"),y(T))}function y(T){return T===null||He(T)?(e.exit("codeFlowValue"),b(T)):(e.consume(T),y)}function E(T){return e.exit("codeFenced"),t(T)}function N(T,L,A){let R=0;return M;function M(V){return T.enter("lineEnding"),T.consume(V),T.exit("lineEnding"),G}function G(V){return T.enter("codeFencedFence"),st(V)?ut(T,W,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(V):W(V)}function W(V){return V===c?(T.enter("codeFencedFenceSequence"),O(V)):A(V)}function O(V){return V===c?(R++,T.consume(V),O):R>=u?(T.exit("codeFencedFenceSequence"),st(V)?ut(T,U,"whitespace")(V):U(V)):A(V)}function U(V){return V===null||He(V)?(T.exit("codeFencedFence"),L(V)):A(V)}}}function qA(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 Gf={name:"codeIndented",tokenize:YA},KA={partial:!0,tokenize:XA};function YA(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 m=s.events[s.events.length-1];return m&&m[1].type==="linePrefix"&&m[2].sliceSerialize(m[1],!0).length>=4?u(f):n(f)}function u(f){return f===null?d(f):He(f)?e.attempt(KA,u,d)(f):(e.enter("codeFlowValue"),c(f))}function c(f){return f===null||He(f)?(e.exit("codeFlowValue"),u(f)):(e.consume(f),c)}function d(f){return e.exit("codeIndented"),t(f)}}function XA(e,t,n){const s=this;return a;function a(u){return s.parser.lazy[s.now().line]?n(u):He(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):He(u)?a(u):n(u)}}const QA={name:"codeText",previous:ZA,resolve:JA,tokenize:eL};function JA(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 ZA(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function eL(e,t,n){let s=0,a,l;return u;function u(p){return e.enter("codeText"),e.enter("codeTextSequence"),c(p)}function c(p){return p===96?(e.consume(p),s++,c):(e.exit("codeTextSequence"),d(p))}function d(p){return p===null?n(p):p===32?(e.enter("space"),e.consume(p),e.exit("space"),d):p===96?(l=e.enter("codeTextSequence"),a=0,m(p)):He(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),d):(e.enter("codeTextData"),f(p))}function f(p){return p===null||p===32||p===96||He(p)?(e.exit("codeTextData"),d(p)):(e.consume(p),f)}function m(p){return p===96?(e.consume(p),a++,m):a===s?(e.exit("codeTextSequence"),e.exit("codeText"),t(p)):(l.type="codeTextData",f(p))}}class tL{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 b1(e){const t={};let n=-1,s,a,l,u,c,d,f;const m=new tL(e);for(;++n<m.length;){for(;n in t;)n=t[n];if(s=m.get(n),n&&s[1].type==="chunkFlow"&&m.get(n-1)[1].type==="listItemPrefix"&&(d=s[1]._tokenizer.events,l=0,l<d.length&&d[l][1].type==="lineEndingBlank"&&(l+=2),l<d.length&&d[l][1].type==="content"))for(;++l<d.length&&d[l][1].type!=="content";)d[l][1].type==="chunkText"&&(d[l][1]._isInFirstContentOfListItem=!0,l++);if(s[0]==="enter")s[1].contentType&&(Object.assign(t,nL(m,n)),n=t[n],f=!0);else if(s[1]._container){for(l=n,a=void 0;l--;)if(u=m.get(l),u[1].type==="lineEnding"||u[1].type==="lineEndingBlank")u[0]==="enter"&&(a&&(m.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={...m.get(a)[1].start},c=m.slice(a,n),c.unshift(s),m.splice(a,n-a+1,c))}}return Kn(e,0,Number.POSITIVE_INFINITY,m.slice(0)),!f}function nL(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,d=[],f={};let m,p,_=-1,x=n,w=0,C=0;const v=[C];for(;x;){for(;e.get(++a)[1]!==x;);l.push(a),x._tokenizer||(m=s.sliceStream(x),x.next||m.push(null),p&&u.defineSkip(x.start),x._isInFirstContentOfListItem&&(u._gfmTasklistFirstContentOfListItem=!0),u.write(m),x._isInFirstContentOfListItem&&(u._gfmTasklistFirstContentOfListItem=void 0)),p=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&&(C=_+1,v.push(C),x._tokenizer=void 0,x.previous=void 0,x=x.next);for(u.events=[],x?(x._tokenizer=void 0,x.previous=void 0):v.pop(),_=v.length;_--;){const S=c.slice(v[_],v[_+1]),b=l.pop();d.push([b,b+S.length-1]),e.splice(b,2,S)}for(d.reverse(),_=-1;++_<d.length;)f[w+d[_][0]]=w+d[_][1],w+=d[_][1]-d[_][0]-1;return f}const rL={resolve:iL,tokenize:aL},sL={partial:!0,tokenize:oL};function iL(e){return b1(e),e}function aL(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):He(c)?e.check(sL,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 oL(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||He(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 S1(e,t,n,s,a,l,u,c,d){const f=d||Number.POSITIVE_INFINITY;let m=0;return p;function p(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||_u(S)?n(S):(e.enter(s),e.enter(u),e.enter(c),e.enter("chunkString",{contentType:"string"}),C(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||He(S)?n(S):(e.consume(S),S===92?w:x)}function w(S){return S===60||S===62||S===92?(e.consume(S),x):x(S)}function C(S){return!m&&(S===null||S===41||Tt(S))?(e.exit("chunkString"),e.exit(c),e.exit(u),e.exit(s),t(S)):m<f&&S===40?(e.consume(S),m++,C):S===41?(e.consume(S),m--,C):S===null||S===32||S===40||_u(S)?n(S):(e.consume(S),S===92?v:C)}function v(S){return S===40||S===41||S===92?(e.consume(S),C):C(S)}}function w1(e,t,n,s,a,l){const u=this;let c=0,d;return f;function f(x){return e.enter(s),e.enter(a),e.consume(x),e.exit(a),e.enter(l),m}function m(x){return c>999||x===null||x===91||x===93&&!d||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):He(x)?(e.enter("lineEnding"),e.consume(x),e.exit("lineEnding"),m):(e.enter("chunkString",{contentType:"string"}),p(x))}function p(x){return x===null||x===91||x===93||He(x)||c++>999?(e.exit("chunkString"),m(x)):(e.consume(x),d||(d=!st(x)),x===92?_:p)}function _(x){return x===91||x===92||x===93?(e.consume(x),c++,p):p(x)}}function C1(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:_,d):n(_)}function d(_){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),d(u)):_===null?n(_):He(_)?(e.enter("lineEnding"),e.consume(_),e.exit("lineEnding"),ut(e,f,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),m(_))}function m(_){return _===u||_===null||He(_)?(e.exit("chunkString"),f(_)):(e.consume(_),_===92?p:m)}function p(_){return _===u||_===92?(e.consume(_),m):m(_)}}function rl(e,t){let n;return s;function s(a){return He(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),n=!0,s):st(a)?ut(e,s,n?"linePrefix":"lineSuffix")(a):t(a)}}const lL={name:"definition",tokenize:uL},cL={partial:!0,tokenize:dL};function uL(e,t,n){const s=this;let a;return l;function l(x){return e.enter("definition"),u(x)}function u(x){return w1.call(s,e,c,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(x)}function c(x){return a=Sr(s.sliceSerialize(s.events[s.events.length-1][1]).slice(1,-1)),x===58?(e.enter("definitionMarker"),e.consume(x),e.exit("definitionMarker"),d):n(x)}function d(x){return Tt(x)?rl(e,f)(x):f(x)}function f(x){return S1(e,m,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(x)}function m(x){return e.attempt(cL,p,p)(x)}function p(x){return st(x)?ut(e,_,"whitespace")(x):_(x)}function _(x){return x===null||He(x)?(e.exit("definition"),s.parser.defined.push(a),t(x)):n(x)}}function dL(e,t,n){return s;function s(c){return Tt(c)?rl(e,a)(c):n(c)}function a(c){return C1(e,l,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(c)}function l(c){return st(c)?ut(e,u,"whitespace")(c):u(c)}function u(c){return c===null||He(c)?t(c):n(c)}}const hL={name:"hardBreakEscape",tokenize:fL};function fL(e,t,n){return s;function s(l){return e.enter("hardBreakEscape"),e.consume(l),a}function a(l){return He(l)?(e.exit("hardBreakEscape"),t(l)):n(l)}}const mL={name:"headingAtx",resolve:pL,tokenize:gL};function pL(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"},Kn(e,s,n-s+1,[["enter",a,t],["enter",l,t],["exit",l,t],["exit",a,t]])),e}function gL(e,t,n){let s=0;return a;function a(m){return e.enter("atxHeading"),l(m)}function l(m){return e.enter("atxHeadingSequence"),u(m)}function u(m){return m===35&&s++<6?(e.consume(m),u):m===null||Tt(m)?(e.exit("atxHeadingSequence"),c(m)):n(m)}function c(m){return m===35?(e.enter("atxHeadingSequence"),d(m)):m===null||He(m)?(e.exit("atxHeading"),t(m)):st(m)?ut(e,c,"whitespace")(m):(e.enter("atxHeadingText"),f(m))}function d(m){return m===35?(e.consume(m),d):(e.exit("atxHeadingSequence"),c(m))}function f(m){return m===null||m===35||Tt(m)?(e.exit("atxHeadingText"),c(m)):(e.consume(m),f)}}const xL=["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"],Sb=["pre","script","style","textarea"],_L={concrete:!0,name:"htmlFlow",resolveTo:bL,tokenize:SL},yL={partial:!0,tokenize:CL},vL={partial:!0,tokenize:wL};function bL(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 SL(e,t,n){const s=this;let a,l,u,c,d;return f;function f(P){return m(P)}function m(P){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(P),p}function p(P){return P===33?(e.consume(P),_):P===47?(e.consume(P),l=!0,C):P===63?(e.consume(P),a=3,s.interrupt?t:I):En(P)?(e.consume(P),u=String.fromCharCode(P),v):n(P)}function _(P){return P===45?(e.consume(P),a=2,x):P===91?(e.consume(P),a=5,c=0,w):En(P)?(e.consume(P),a=4,s.interrupt?t:I):n(P)}function x(P){return P===45?(e.consume(P),s.interrupt?t:I):n(P)}function w(P){const ee="CDATA[";return P===ee.charCodeAt(c++)?(e.consume(P),c===ee.length?s.interrupt?t:W:w):n(P)}function C(P){return En(P)?(e.consume(P),u=String.fromCharCode(P),v):n(P)}function v(P){if(P===null||P===47||P===62||Tt(P)){const ee=P===47,J=u.toLowerCase();return!ee&&!l&&Sb.includes(J)?(a=1,s.interrupt?t(P):W(P)):xL.includes(u.toLowerCase())?(a=6,ee?(e.consume(P),S):s.interrupt?t(P):W(P)):(a=7,s.interrupt&&!s.parser.lazy[s.now().line]?n(P):l?b(P):y(P))}return P===45||Sn(P)?(e.consume(P),u+=String.fromCharCode(P),v):n(P)}function S(P){return P===62?(e.consume(P),s.interrupt?t:W):n(P)}function b(P){return st(P)?(e.consume(P),b):M(P)}function y(P){return P===47?(e.consume(P),M):P===58||P===95||En(P)?(e.consume(P),E):st(P)?(e.consume(P),y):M(P)}function E(P){return P===45||P===46||P===58||P===95||Sn(P)?(e.consume(P),E):N(P)}function N(P){return P===61?(e.consume(P),T):st(P)?(e.consume(P),N):y(P)}function T(P){return P===null||P===60||P===61||P===62||P===96?n(P):P===34||P===39?(e.consume(P),d=P,L):st(P)?(e.consume(P),T):A(P)}function L(P){return P===d?(e.consume(P),d=null,R):P===null||He(P)?n(P):(e.consume(P),L)}function A(P){return P===null||P===34||P===39||P===47||P===60||P===61||P===62||P===96||Tt(P)?N(P):(e.consume(P),A)}function R(P){return P===47||P===62||st(P)?y(P):n(P)}function M(P){return P===62?(e.consume(P),G):n(P)}function G(P){return P===null||He(P)?W(P):st(P)?(e.consume(P),G):n(P)}function W(P){return P===45&&a===2?(e.consume(P),z):P===60&&a===1?(e.consume(P),X):P===62&&a===4?(e.consume(P),$):P===63&&a===3?(e.consume(P),I):P===93&&a===5?(e.consume(P),H):He(P)&&(a===6||a===7)?(e.exit("htmlFlowData"),e.check(yL,F,O)(P)):P===null||He(P)?(e.exit("htmlFlowData"),O(P)):(e.consume(P),W)}function O(P){return e.check(vL,U,F)(P)}function U(P){return e.enter("lineEnding"),e.consume(P),e.exit("lineEnding"),V}function V(P){return P===null||He(P)?O(P):(e.enter("htmlFlowData"),W(P))}function z(P){return P===45?(e.consume(P),I):W(P)}function X(P){return P===47?(e.consume(P),u="",te):W(P)}function te(P){if(P===62){const ee=u.toLowerCase();return Sb.includes(ee)?(e.consume(P),$):W(P)}return En(P)&&u.length<8?(e.consume(P),u+=String.fromCharCode(P),te):W(P)}function H(P){return P===93?(e.consume(P),I):W(P)}function I(P){return P===62?(e.consume(P),$):P===45&&a===2?(e.consume(P),I):W(P)}function $(P){return P===null||He(P)?(e.exit("htmlFlowData"),F(P)):(e.consume(P),$)}function F(P){return e.exit("htmlFlow"),t(P)}}function wL(e,t,n){const s=this;return a;function a(u){return He(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 CL(e,t,n){return s;function s(a){return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),e.attempt(wl,t,n)}}const kL={name:"htmlText",tokenize:EL};function EL(e,t,n){const s=this;let a,l,u;return c;function c(I){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(I),d}function d(I){return I===33?(e.consume(I),f):I===47?(e.consume(I),N):I===63?(e.consume(I),y):En(I)?(e.consume(I),A):n(I)}function f(I){return I===45?(e.consume(I),m):I===91?(e.consume(I),l=0,w):En(I)?(e.consume(I),b):n(I)}function m(I){return I===45?(e.consume(I),x):n(I)}function p(I){return I===null?n(I):I===45?(e.consume(I),_):He(I)?(u=p,X(I)):(e.consume(I),p)}function _(I){return I===45?(e.consume(I),x):p(I)}function x(I){return I===62?z(I):I===45?_(I):p(I)}function w(I){const $="CDATA[";return I===$.charCodeAt(l++)?(e.consume(I),l===$.length?C:w):n(I)}function C(I){return I===null?n(I):I===93?(e.consume(I),v):He(I)?(u=C,X(I)):(e.consume(I),C)}function v(I){return I===93?(e.consume(I),S):C(I)}function S(I){return I===62?z(I):I===93?(e.consume(I),S):C(I)}function b(I){return I===null||I===62?z(I):He(I)?(u=b,X(I)):(e.consume(I),b)}function y(I){return I===null?n(I):I===63?(e.consume(I),E):He(I)?(u=y,X(I)):(e.consume(I),y)}function E(I){return I===62?z(I):y(I)}function N(I){return En(I)?(e.consume(I),T):n(I)}function T(I){return I===45||Sn(I)?(e.consume(I),T):L(I)}function L(I){return He(I)?(u=L,X(I)):st(I)?(e.consume(I),L):z(I)}function A(I){return I===45||Sn(I)?(e.consume(I),A):I===47||I===62||Tt(I)?R(I):n(I)}function R(I){return I===47?(e.consume(I),z):I===58||I===95||En(I)?(e.consume(I),M):He(I)?(u=R,X(I)):st(I)?(e.consume(I),R):z(I)}function M(I){return I===45||I===46||I===58||I===95||Sn(I)?(e.consume(I),M):G(I)}function G(I){return I===61?(e.consume(I),W):He(I)?(u=G,X(I)):st(I)?(e.consume(I),G):R(I)}function W(I){return I===null||I===60||I===61||I===62||I===96?n(I):I===34||I===39?(e.consume(I),a=I,O):He(I)?(u=W,X(I)):st(I)?(e.consume(I),W):(e.consume(I),U)}function O(I){return I===a?(e.consume(I),a=void 0,V):I===null?n(I):He(I)?(u=O,X(I)):(e.consume(I),O)}function U(I){return I===null||I===34||I===39||I===60||I===61||I===96?n(I):I===47||I===62||Tt(I)?R(I):(e.consume(I),U)}function V(I){return I===47||I===62||Tt(I)?R(I):n(I)}function z(I){return I===62?(e.consume(I),e.exit("htmlTextData"),e.exit("htmlText"),t):n(I)}function X(I){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(I),e.exit("lineEnding"),te}function te(I){return st(I)?ut(e,H,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(I):H(I)}function H(I){return e.enter("htmlTextData"),u(I)}}const Op={name:"labelEnd",resolveAll:AL,resolveTo:LL,tokenize:DL},jL={tokenize:RL},NL={tokenize:OL},TL={tokenize:ML};function AL(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&&Kn(e,0,e.length,n),e}function LL(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 d={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}},m={type:"labelText",start:{...e[l+s+2][1].end},end:{...e[u-2][1].start}};return c=[["enter",d,t],["enter",f,t]],c=or(c,e.slice(l+1,l+s+3)),c=or(c,[["enter",m,t]]),c=or(c,Qu(t.parser.constructs.insideSpan.null,e.slice(l+s+4,u-3),t)),c=or(c,[["exit",m,t],e[u-2],e[u-1],["exit",f,t]]),c=or(c,e.slice(u+1)),c=or(c,[["exit",d,t]]),Kn(e,l,e.length,c),e}function DL(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?p(_):(u=s.parser.defined.includes(Sr(s.sliceSerialize({start:l.end,end:s.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(_),e.exit("labelMarker"),e.exit("labelEnd"),d):n(_)}function d(_){return _===40?e.attempt(jL,m,u?m:p)(_):_===91?e.attempt(NL,m,u?f:p)(_):u?m(_):p(_)}function f(_){return e.attempt(TL,m,p)(_)}function m(_){return t(_)}function p(_){return l._balanced=!0,n(_)}}function RL(e,t,n){return s;function s(p){return e.enter("resource"),e.enter("resourceMarker"),e.consume(p),e.exit("resourceMarker"),a}function a(p){return Tt(p)?rl(e,l)(p):l(p)}function l(p){return p===41?m(p):S1(e,u,c,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(p)}function u(p){return Tt(p)?rl(e,d)(p):m(p)}function c(p){return n(p)}function d(p){return p===34||p===39||p===40?C1(e,f,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(p):m(p)}function f(p){return Tt(p)?rl(e,m)(p):m(p)}function m(p){return p===41?(e.enter("resourceMarker"),e.consume(p),e.exit("resourceMarker"),e.exit("resource"),t):n(p)}}function OL(e,t,n){const s=this;return a;function a(c){return w1.call(s,e,l,u,"reference","referenceMarker","referenceString")(c)}function l(c){return s.parser.defined.includes(Sr(s.sliceSerialize(s.events[s.events.length-1][1]).slice(1,-1)))?t(c):n(c)}function u(c){return n(c)}}function ML(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 IL={name:"labelStartImage",resolveAll:Op.resolveAll,tokenize:PL};function PL(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 BL={name:"labelStartLink",resolveAll:Op.resolveAll,tokenize:zL};function zL(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 Wf={name:"lineEnding",tokenize:$L};function $L(e,t){return n;function n(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),ut(e,t,"linePrefix")}}const cu={name:"thematicBreak",tokenize:HL};function HL(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"),d(f)):s>=3&&(f===null||He(f))?(e.exit("thematicBreak"),t(f)):n(f)}function d(f){return f===a?(e.consume(f),s++,d):(e.exit("thematicBreakSequence"),st(f)?ut(e,c,"whitespace")(f):c(f))}}const Mn={continuation:{tokenize:GL},exit:qL,name:"list",tokenize:VL},UL={partial:!0,tokenize:KL},FL={partial:!0,tokenize:WL};function VL(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:Mm(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(cu,n,f)(x):f(x);if(!s.interrupt||x===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),d(x)}return n(x)}function d(x){return Mm(x)&&++u<10?(e.consume(x),d):(!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(wl,s.interrupt?n:m,e.attempt(UL,_,p))}function m(x){return s.containerState.initialBlankLine=!0,l++,_(x)}function p(x){return st(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 GL(e,t,n){const s=this;return s.containerState._closeFlow=void 0,e.check(wl,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||!st(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(FL,t,u)(c))}function u(c){return s.containerState._closeFlow=!0,s.interrupt=void 0,ut(e,e.attempt(Mn,t,n),"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c)}}function WL(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 qL(e){e.exit(this.containerState.type)}function KL(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!st(l)&&u&&u[1].type==="listItemPrefixWhitespace"?t(l):n(l)}}const wb={name:"setextUnderline",resolveTo:YL,tokenize:XL};function YL(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 XL(e,t,n){const s=this;let a;return l;function l(f){let m=s.events.length,p;for(;m--;)if(s.events[m][1].type!=="lineEnding"&&s.events[m][1].type!=="linePrefix"&&s.events[m][1].type!=="content"){p=s.events[m][1].type==="paragraph";break}return!s.parser.lazy[s.now().line]&&(s.interrupt||p)?(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"),st(f)?ut(e,d,"lineSuffix")(f):d(f))}function d(f){return f===null||He(f)?(e.exit("setextHeadingLine"),t(f)):n(f)}}const QL={tokenize:JL};function JL(e){const t=this,n=e.attempt(wl,s,e.attempt(this.parser.constructs.flowInitial,a,ut(e,e.attempt(this.parser.constructs.flow,a,e.attempt(rL,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 ZL={resolveAll:E1()},eD=k1("string"),tD=k1("text");function k1(e){return{resolveAll:E1(e==="text"?nD: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(m){return f(m)?l(m):c(m)}function c(m){if(m===null){n.consume(m);return}return n.enter("data"),n.consume(m),d}function d(m){return f(m)?(n.exit("data"),l(m)):(n.consume(m),d)}function f(m){if(m===null)return!0;const p=a[m];let _=-1;if(p)for(;++_<p.length;){const x=p[_];if(!x.previous||x.previous.call(s,s.previous))return!0}return!1}}}function E1(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 nD(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,d;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)d=!0,c++;else if(f!==-1){l++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(c=0),c){const f={type:n===e.length||d||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 rD={42:Mn,43:Mn,45:Mn,48:Mn,49:Mn,50:Mn,51:Mn,52:Mn,53:Mn,54:Mn,55:Mn,56:Mn,57:Mn,62:_1},sD={91:lL},iD={[-2]:Gf,[-1]:Gf,32:Gf},aD={35:mL,42:cu,45:[wb,cu],60:_L,61:wb,95:cu,96:bb,126:bb},oD={38:v1,92:y1},lD={[-5]:Wf,[-4]:Wf,[-3]:Wf,33:IL,38:v1,42:Im,60:[BA,kL],91:BL,92:[hL,y1],93:Op,95:Im,96:QA},cD={null:[Im,ZL]},uD={null:[42,95]},dD={null:[]},hD=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:uD,contentInitial:sD,disable:dD,document:rD,flow:aD,flowInitial:iD,insideSpan:cD,string:oD,text:lD},Symbol.toStringTag,{value:"Module"}));function fD(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 d={attempt:L(N),check:L(T),consume:b,enter:y,exit:E,interrupt:L(T,{interrupt:!0})},f={code:null,containerState:{},defineSkip:C,events:[],now:w,parser:e,previous:null,sliceSerialize:_,sliceStream:x,write:p};let m=t.tokenize.call(f,d);return t.resolveAll&&l.push(t),f;function p(G){return u=or(u,G),v(),u[u.length-1]!==null?[]:(A(t,0),f.events=Qu(l,f.events,f),f.events)}function _(G,W){return pD(x(G),W)}function x(G){return mD(u,G)}function w(){const{_bufferIndex:G,_index:W,line:O,column:U,offset:V}=s;return{_bufferIndex:G,_index:W,line:O,column:U,offset:V}}function C(G){a[G.line]=G.column,M()}function v(){let G;for(;s._index<u.length;){const W=u[s._index];if(typeof W=="string")for(G=s._index,s._bufferIndex<0&&(s._bufferIndex=0);s._index===G&&s._bufferIndex<W.length;)S(W.charCodeAt(s._bufferIndex));else S(W)}}function S(G){m=m(G)}function b(G){He(G)?(s.line++,s.column=1,s.offset+=G===-3?2:1,M()):G!==-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=G}function y(G,W){const O=W||{};return O.type=G,O.start=w(),f.events.push(["enter",O,f]),c.push(O),O}function E(G){const W=c.pop();return W.end=w(),f.events.push(["exit",W,f]),W}function N(G,W){A(G,W.from)}function T(G,W){W.restore()}function L(G,W){return O;function O(U,V,z){let X,te,H,I;return Array.isArray(U)?F(U):"tokenize"in U?F([U]):$(U);function $(re){return Y;function Y(q){const Z=q!==null&&re[q],ae=q!==null&&re.null,se=[...Array.isArray(Z)?Z:Z?[Z]:[],...Array.isArray(ae)?ae:ae?[ae]:[]];return F(se)(q)}}function F(re){return X=re,te=0,re.length===0?z:P(re[te])}function P(re){return Y;function Y(q){return I=R(),H=re,re.partial||(f.currentConstruct=re),re.name&&f.parser.constructs.disable.null.includes(re.name)?J():re.tokenize.call(W?Object.assign(Object.create(f),W):f,d,ee,J)(q)}}function ee(re){return G(H,I),V}function J(re){return I.restore(),++te<X.length?P(X[te]):z}}}function A(G,W){G.resolveAll&&!l.includes(G)&&l.push(G),G.resolve&&Kn(f.events,W,f.events.length-W,G.resolve(f.events.slice(W),f)),G.resolveTo&&(f.events=G.resolveTo(f.events,f))}function R(){const G=w(),W=f.previous,O=f.currentConstruct,U=f.events.length,V=Array.from(c);return{from:U,restore:z};function z(){s=G,f.previous=W,f.currentConstruct=O,f.events.length=U,c=V,M()}}function M(){s.line in a&&s.column<2&&(s.column=a[s.line],s.offset+=a[s.line]-1)}}function mD(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 pD(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=`
98
+ `;break}case-3:{u=`\r
99
+ `;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 gD(e){const s={constructs:g1([hD,...(e||{}).extensions||[]]),content:a(LA),defined:[],document:a(RA),flow:a(QL),lazy:{},string:a(eD),text:a(tD)};return s;function a(l){return u;function u(c){return fD(s,l,c)}}}function xD(e){for(;!b1(e););return e}const Cb=/[\0\t\n\r]/g;function _D(){let e=1,t="",n=!0,s;return a;function a(l,u,c){const d=[];let f,m,p,_,x;for(l=t+(typeof l=="string"?l.toString():new TextDecoder(u||void 0).decode(l)),p=0,t="",n&&(l.charCodeAt(0)===65279&&p++,n=void 0);p<l.length;){if(Cb.lastIndex=p,f=Cb.exec(l),_=f&&f.index!==void 0?f.index:l.length,x=l.charCodeAt(_),!f){t=l.slice(p);break}if(x===10&&p===_&&s)d.push(-3),s=void 0;else switch(s&&(d.push(-5),s=void 0),p<_&&(d.push(l.slice(p,_)),e+=_-p),x){case 0:{d.push(65533),e++;break}case 9:{for(m=Math.ceil(e/4)*4,d.push(-2);e++<m;)d.push(-1);break}case 10:{d.push(-4),e=1;break}default:s=!0,e=1}p=_+1}return c&&(s&&d.push(-5),t&&d.push(t),d.push(null)),d}}const yD=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function vD(e){return e.replace(yD,bD)}function bD(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const a=n.charCodeAt(1),l=a===120||a===88;return x1(n.slice(l?2:1),l?16:10)}return Rp(n)||e}const j1={}.hasOwnProperty;function SD(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),wD(n)(xD(gD(n).document().write(_D()(e,t,!0))))}function wD(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:l(pe),autolinkProtocol:R,autolinkEmail:R,atxHeading:l(De),blockQuote:l(ae),characterEscape:R,characterReference:R,codeFenced:l(se),codeFencedFenceInfo:u,codeFencedFenceMeta:u,codeIndented:l(se,u),codeText:l(oe,u),codeTextData:R,data:R,codeFlowValue:R,definition:l(je),definitionDestinationString:u,definitionLabelString:u,definitionTitleString:u,emphasis:l(Le),hardBreakEscape:l(Re),hardBreakTrailing:l(Re),htmlFlow:l(Te,u),htmlFlowData:R,htmlText:l(Te,u),htmlTextData:R,image:l(Ae),label:u,link:l(pe),listItem:l(Se),listItemValue:_,listOrdered:l(ce,p),listUnordered:l(ce),paragraph:l(Ze),reference:P,referenceString:u,resourceDestinationString:u,resourceTitleString:u,setextHeading:l(De),strong:l(_t),thematicBreak:l(tn)},exit:{atxHeading:d(),atxHeadingSequence:N,autolink:d(),autolinkEmail:Z,autolinkProtocol:q,blockQuote:d(),characterEscapeValue:M,characterReferenceMarkerHexadecimal:J,characterReferenceMarkerNumeric:J,characterReferenceValue:re,characterReference:Y,codeFenced:d(v),codeFencedFence:C,codeFencedFenceInfo:x,codeFencedFenceMeta:w,codeFlowValue:M,codeIndented:d(S),codeText:d(V),codeTextData:M,data:M,definition:d(),definitionDestinationString:E,definitionLabelString:b,definitionTitleString:y,emphasis:d(),hardBreakEscape:d(W),hardBreakTrailing:d(W),htmlFlow:d(O),htmlFlowData:M,htmlText:d(U),htmlTextData:M,image:d(X),label:H,labelText:te,lineEnding:G,link:d(z),listItem:d(),listOrdered:d(),listUnordered:d(),paragraph:d(),referenceString:ee,resourceDestinationString:I,resourceTitleString:$,resource:F,setextHeading:d(A),setextHeadingLineSequence:L,setextHeadingText:T,strong:d(),thematicBreak:d()}};N1(t,(e||{}).mdastExtensions||[]);const n={};return s;function s(ge){let Ce={type:"root",children:[]};const Ie={stack:[Ce],tokenStack:[],config:t,enter:c,exit:f,buffer:u,resume:m,data:n},Fe=[];let Ve=-1;for(;++Ve<ge.length;)if(ge[Ve][1].type==="listOrdered"||ge[Ve][1].type==="listUnordered")if(ge[Ve][0]==="enter")Fe.push(Ve);else{const St=Fe.pop();Ve=a(ge,St,Ve)}for(Ve=-1;++Ve<ge.length;){const St=t[ge[Ve][0]];j1.call(St,ge[Ve][1].type)&&St[ge[Ve][1].type].call(Object.assign({sliceSerialize:ge[Ve][2].sliceSerialize},Ie),ge[Ve][1])}if(Ie.tokenStack.length>0){const St=Ie.tokenStack[Ie.tokenStack.length-1];(St[1]||kb).call(Ie,void 0,St[0])}for(Ce.position={start:Ps(ge.length>0?ge[0][1].start:{line:1,column:1,offset:0}),end:Ps(ge.length>0?ge[ge.length-2][1].end:{line:1,column:1,offset:0})},Ve=-1;++Ve<t.transforms.length;)Ce=t.transforms[Ve](Ce)||Ce;return Ce}function a(ge,Ce,Ie){let Fe=Ce-1,Ve=-1,St=!1,Ye,wt,ct,nn;for(;++Fe<=Ie;){const ht=ge[Fe];switch(ht[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{ht[0]==="enter"?Ve++:Ve--,nn=void 0;break}case"lineEndingBlank":{ht[0]==="enter"&&(Ye&&!nn&&!Ve&&!ct&&(ct=Fe),nn=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:nn=void 0}if(!Ve&&ht[0]==="enter"&&ht[1].type==="listItemPrefix"||Ve===-1&&ht[0]==="exit"&&(ht[1].type==="listUnordered"||ht[1].type==="listOrdered")){if(Ye){let jn=Fe;for(wt=void 0;jn--;){const _n=ge[jn];if(_n[1].type==="lineEnding"||_n[1].type==="lineEndingBlank"){if(_n[0]==="exit")continue;wt&&(ge[wt][1].type="lineEndingBlank",St=!0),_n[1].type="lineEnding",wt=jn}else if(!(_n[1].type==="linePrefix"||_n[1].type==="blockQuotePrefix"||_n[1].type==="blockQuotePrefixWhitespace"||_n[1].type==="blockQuoteMarker"||_n[1].type==="listItemIndent"))break}ct&&(!wt||ct<wt)&&(Ye._spread=!0),Ye.end=Object.assign({},wt?ge[wt][1].start:ht[1].end),ge.splice(wt||Fe,0,["exit",Ye,ht[2]]),Fe++,Ie++}if(ht[1].type==="listItemPrefix"){const jn={type:"listItem",_spread:!1,start:Object.assign({},ht[1].start),end:void 0};Ye=jn,ge.splice(Fe,0,["enter",jn,ht[2]]),Fe++,Ie++,ct=void 0,nn=!0}}}return ge[Ce][1]._spread=St,Ie}function l(ge,Ce){return Ie;function Ie(Fe){c.call(this,ge(Fe),Fe),Ce&&Ce.call(this,Fe)}}function u(){this.stack.push({type:"fragment",children:[]})}function c(ge,Ce,Ie){this.stack[this.stack.length-1].children.push(ge),this.stack.push(ge),this.tokenStack.push([Ce,Ie||void 0]),ge.position={start:Ps(Ce.start),end:void 0}}function d(ge){return Ce;function Ce(Ie){ge&&ge.call(this,Ie),f.call(this,Ie)}}function f(ge,Ce){const Ie=this.stack.pop(),Fe=this.tokenStack.pop();if(Fe)Fe[0].type!==ge.type&&(Ce?Ce.call(this,ge,Fe[0]):(Fe[1]||kb).call(this,ge,Fe[0]));else throw new Error("Cannot close `"+ge.type+"` ("+nl({start:ge.start,end:ge.end})+"): it’s not open");Ie.position.end=Ps(ge.end)}function m(){return Dp(this.stack.pop())}function p(){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 C(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function v(){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 b(ge){const Ce=this.resume(),Ie=this.stack[this.stack.length-1];Ie.label=Ce,Ie.identifier=Sr(this.sliceSerialize(ge)).toLowerCase()}function y(){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 N(ge){const Ce=this.stack[this.stack.length-1];if(!Ce.depth){const Ie=this.sliceSerialize(ge).length;Ce.depth=Ie}}function T(){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 R(ge){const Ie=this.stack[this.stack.length-1].children;let Fe=Ie[Ie.length-1];(!Fe||Fe.type!=="text")&&(Fe=dt(),Fe.position={start:Ps(ge.start),end:void 0},Ie.push(Fe)),this.stack.push(Fe)}function M(ge){const Ce=this.stack.pop();Ce.value+=this.sliceSerialize(ge),Ce.position.end=Ps(ge.end)}function G(ge){const Ce=this.stack[this.stack.length-1];if(this.data.atHardBreak){const Ie=Ce.children[Ce.children.length-1];Ie.position.end=Ps(ge.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(Ce.type)&&(R.call(this,ge),M.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 U(){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 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 te(ge){const Ce=this.sliceSerialize(ge),Ie=this.stack[this.stack.length-2];Ie.label=vD(Ce),Ie.identifier=Sr(Ce).toLowerCase()}function H(){const ge=this.stack[this.stack.length-1],Ce=this.resume(),Ie=this.stack[this.stack.length-1];if(this.data.inReference=!0,Ie.type==="link"){const Fe=ge.children;Ie.children=Fe}else Ie.alt=Ce}function I(){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 F(){this.data.inReference=void 0}function P(){this.data.referenceType="collapsed"}function ee(ge){const Ce=this.resume(),Ie=this.stack[this.stack.length-1];Ie.label=Ce,Ie.identifier=Sr(this.sliceSerialize(ge)).toLowerCase(),this.data.referenceType="full"}function J(ge){this.data.characterReferenceType=ge.type}function re(ge){const Ce=this.sliceSerialize(ge),Ie=this.data.characterReferenceType;let Fe;Ie?(Fe=x1(Ce,Ie==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Fe=Rp(Ce);const Ve=this.stack[this.stack.length-1];Ve.value+=Fe}function Y(ge){const Ce=this.stack.pop();Ce.position.end=Ps(ge.end)}function q(ge){M.call(this,ge);const Ce=this.stack[this.stack.length-1];Ce.url=this.sliceSerialize(ge)}function Z(ge){M.call(this,ge);const Ce=this.stack[this.stack.length-1];Ce.url="mailto:"+this.sliceSerialize(ge)}function ae(){return{type:"blockquote",children:[]}}function se(){return{type:"code",lang:null,meta:null,value:""}}function oe(){return{type:"inlineCode",value:""}}function je(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Le(){return{type:"emphasis",children:[]}}function De(){return{type:"heading",depth:0,children:[]}}function Re(){return{type:"break"}}function Te(){return{type:"html",value:""}}function Ae(){return{type:"image",title:null,url:"",alt:null}}function pe(){return{type:"link",title:null,url:"",children:[]}}function ce(ge){return{type:"list",ordered:ge.type==="listOrdered",start:null,spread:ge._spread,children:[]}}function Se(ge){return{type:"listItem",spread:ge._spread,checked:null,children:[]}}function Ze(){return{type:"paragraph",children:[]}}function _t(){return{type:"strong",children:[]}}function dt(){return{type:"text",value:""}}function tn(){return{type:"thematicBreak"}}}function Ps(e){return{line:e.line,column:e.column,offset:e.offset}}function N1(e,t){let n=-1;for(;++n<t.length;){const s=t[n];Array.isArray(s)?N1(e,s):CD(e,s)}}function CD(e,t){let n;for(n in t)if(j1.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 kb(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+nl({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+nl({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+nl({start:t.start,end:t.end})+") is still open")}function kD(e){const t=this;t.parser=n;function n(s){return SD(s,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function ED(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 jD(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
100
+ `}]}function ND(e,t){const n=t.value?t.value+`
101
+ `:"",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 TD(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function AD(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function LD(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 d={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+a,id:n+"fnref-"+a+(c>1?"-"+c:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(u)}]};e.patch(t,d);const f={type:"element",tagName:"sup",properties:{},children:[d]};return e.patch(t,f),e.applyData(t,f)}function DD(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 RD(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function T1(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 OD(e,t){const n=String(t.identifier).toUpperCase(),s=e.definitionById.get(n);if(!s)return T1(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 MD(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 ID(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 PD(e,t){const n=String(t.identifier).toUpperCase(),s=e.definitionById.get(n);if(!s)return T1(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 BD(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 zD(e,t,n){const s=e.all(t),a=n?$D(n):A1(t),l={},u=[];if(typeof t.checked=="boolean"){const m=s[0];let p;m&&m.type==="element"&&m.tagName==="p"?p=m:(p={type:"element",tagName:"p",properties:{},children:[]},s.unshift(p)),p.children.length>0&&p.children.unshift({type:"text",value:" "}),p.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 m=s[c];(a||c!==0||m.type!=="element"||m.tagName!=="p")&&u.push({type:"text",value:`
102
+ `}),m.type==="element"&&m.tagName==="p"&&!a?u.push(...m.children):u.push(m)}const d=s[s.length-1];d&&(a||d.type!=="element"||d.tagName!=="p")&&u.push({type:"text",value:`
103
+ `});const f={type:"element",tagName:"li",properties:l,children:u};return e.patch(t,f),e.applyData(t,f)}function $D(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=A1(n[s])}return t}function A1(e){const t=e.spread;return t??e.children.length>1}function HD(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 UD(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function FD(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function VD(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function GD(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=Np(t.children[1]),d=c1(t.children[t.children.length-1]);c&&d&&(u.position={start:c,end:d}),a.push(u)}const l={type:"element",tagName:"table",properties:{},children:e.wrap(a,!0)};return e.patch(t,l),e.applyData(t,l)}function WD(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 d=-1;const f=[];for(;++d<c;){const p=t.children[d],_={},x=u?u[d]:void 0;x&&(_.align=x);let w={type:"element",tagName:l,properties:_,children:[]};p&&(w.children=e.all(p),e.patch(p,w),w=e.applyData(p,w)),f.push(w)}const m={type:"element",tagName:"tr",properties:{},children:e.wrap(f,!0)};return e.patch(t,m),e.applyData(t,m)}function qD(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const Eb=9,jb=32;function KD(e){const t=String(e),n=/\r?\n|\r/g;let s=n.exec(t),a=0;const l=[];for(;s;)l.push(Nb(t.slice(a,s.index),a>0,!0),s[0]),a=s.index+s[0].length,s=n.exec(t);return l.push(Nb(t.slice(a),a>0,!1)),l.join("")}function Nb(e,t,n){let s=0,a=e.length;if(t){let l=e.codePointAt(s);for(;l===Eb||l===jb;)s++,l=e.codePointAt(s)}if(n){let l=e.codePointAt(a-1);for(;l===Eb||l===jb;)a--,l=e.codePointAt(a-1)}return a>s?e.slice(s,a):""}function YD(e,t){const n={type:"text",value:KD(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function XD(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const QD={blockquote:ED,break:jD,code:ND,delete:TD,emphasis:AD,footnoteReference:LD,heading:DD,html:RD,imageReference:OD,image:MD,inlineCode:ID,linkReference:PD,link:BD,listItem:zD,list:HD,paragraph:UD,root:FD,strong:VD,table:GD,tableCell:qD,tableRow:WD,text:YD,thematicBreak:XD,toml:Kc,yaml:Kc,definition:Kc,footnoteDefinition:Kc};function Kc(){}const L1=-1,Ju=0,sl=1,yu=2,Mp=3,Ip=4,Pp=5,Bp=6,D1=7,R1=8,Tb=typeof self=="object"?self:globalThis,JD=(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 Ju:case L1:return n(u,a);case sl:{const c=n([],a);for(const d of u)c.push(s(d));return c}case yu:{const c=n({},a);for(const[d,f]of u)c[s(d)]=s(f);return c}case Mp:return n(new Date(u),a);case Ip:{const{source:c,flags:d}=u;return n(new RegExp(c,d),a)}case Pp:{const c=n(new Map,a);for(const[d,f]of u)c.set(s(d),s(f));return c}case Bp:{const c=n(new Set,a);for(const d of u)c.add(s(d));return c}case D1:{const{name:c,message:d}=u;return n(new Tb[c](d),a)}case R1: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 Tb[l](u),a)};return s},Ab=e=>JD(new Map,e)(0),wa="",{toString:ZD}={},{keys:eR}=Object,Wo=e=>{const t=typeof e;if(t!=="object"||!e)return[Ju,t];const n=ZD.call(e).slice(8,-1);switch(n){case"Array":return[sl,wa];case"Object":return[yu,wa];case"Date":return[Mp,wa];case"RegExp":return[Ip,wa];case"Map":return[Pp,wa];case"Set":return[Bp,wa];case"DataView":return[sl,n]}return n.includes("Array")?[sl,n]:n.includes("Error")?[D1,n]:[yu,n]},Yc=([e,t])=>e===Ju&&(t==="function"||t==="symbol"),tR=(e,t,n,s)=>{const a=(u,c)=>{const d=s.push(u)-1;return n.set(c,d),d},l=u=>{if(n.has(u))return n.get(u);let[c,d]=Wo(u);switch(c){case Ju:{let m=u;switch(d){case"bigint":c=R1,m=u.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+d);m=null;break;case"undefined":return a([L1],u)}return a([c,m],u)}case sl:{if(d){let _=u;return d==="DataView"?_=new Uint8Array(u.buffer):d==="ArrayBuffer"&&(_=new Uint8Array(u)),a([d,[..._]],u)}const m=[],p=a([c,m],u);for(const _ of u)m.push(l(_));return p}case yu:{if(d)switch(d){case"BigInt":return a([d,u.toString()],u);case"Boolean":case"Number":case"String":return a([d,u.valueOf()],u)}if(t&&"toJSON"in u)return l(u.toJSON());const m=[],p=a([c,m],u);for(const _ of eR(u))(e||!Yc(Wo(u[_])))&&m.push([l(_),l(u[_])]);return p}case Mp:return a([c,u.toISOString()],u);case Ip:{const{source:m,flags:p}=u;return a([c,{source:m,flags:p}],u)}case Pp:{const m=[],p=a([c,m],u);for(const[_,x]of u)(e||!(Yc(Wo(_))||Yc(Wo(x))))&&m.push([l(_),l(x)]);return p}case Bp:{const m=[],p=a([c,m],u);for(const _ of u)(e||!Yc(Wo(_)))&&m.push(l(_));return p}}const{message:f}=u;return a([c,{name:d,message:f}],u)};return l},Lb=(e,{json:t,lossy:n}={})=>{const s=[];return tR(!(t||n),!!t,new Map,s)(e),s},vu=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?Ab(Lb(e,t)):structuredClone(e):(e,t)=>Ab(Lb(e,t));function nR(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 rR(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function sR(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||nR,s=e.options.footnoteBackLabel||rR,a=e.options.footnoteLabel||"Footnotes",l=e.options.footnoteLabelTagName||"h2",u=e.options.footnoteLabelProperties||{className:["sr-only"]},c=[];let d=-1;for(;++d<e.footnoteOrder.length;){const f=e.footnoteById.get(e.footnoteOrder[d]);if(!f)continue;const m=e.all(f),p=String(f.identifier).toUpperCase(),_=Fa(p.toLowerCase());let x=0;const w=[],C=e.footnoteCounts.get(p);for(;C!==void 0&&++x<=C;){w.length>0&&w.push({type:"text",value:" "});let b=typeof n=="string"?n:n(d,x);typeof b=="string"&&(b={type:"text",value:b}),w.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+_+(x>1?"-"+x:""),dataFootnoteBackref:"",ariaLabel:typeof s=="string"?s:s(d,x),className:["data-footnote-backref"]},children:Array.isArray(b)?b:[b]})}const v=m[m.length-1];if(v&&v.type==="element"&&v.tagName==="p"){const b=v.children[v.children.length-1];b&&b.type==="text"?b.value+=" ":v.children.push({type:"text",value:" "}),v.children.push(...w)}else m.push(...w);const S={type:"element",tagName:"li",properties:{id:t+"fn-"+_},children:e.wrap(m,!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:{...vu(u),id:"footnote-label"},children:[{type:"text",value:a}]},{type:"text",value:`
104
+ `},{type:"element",tagName:"ol",properties:{},children:e.wrap(c,!0)},{type:"text",value:`
105
+ `}]}}const Zu=(function(e){if(e==null)return lR;if(typeof e=="function")return ed(e);if(typeof e=="object")return Array.isArray(e)?iR(e):aR(e);if(typeof e=="string")return oR(e);throw new Error("Expected function, string, or object as test")});function iR(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=Zu(e[n]);return ed(s);function s(...a){let l=-1;for(;++l<t.length;)if(t[l].apply(this,a))return!0;return!1}}function aR(e){const t=e;return ed(n);function n(s){const a=s;let l;for(l in e)if(a[l]!==t[l])return!1;return!0}}function oR(e){return ed(t);function t(n){return n&&n.type===e}}function ed(e){return t;function t(n,s,a){return!!(cR(n)&&e.call(this,n,typeof s=="number"?s:void 0,a||void 0))}}function lR(){return!0}function cR(e){return e!==null&&typeof e=="object"&&"type"in e}const O1=[],uR=!0,Pm=!1,dR="skip";function M1(e,t,n,s){let a;typeof t=="function"&&typeof n!="function"?(s=n,n=t):a=t;const l=Zu(a),u=s?-1:1;c(e,void 0,[])();function c(d,f,m){const p=d&&typeof d=="object"?d:{};if(typeof p.type=="string"){const x=typeof p.tagName=="string"?p.tagName:typeof p.name=="string"?p.name:void 0;Object.defineProperty(_,"name",{value:"node ("+(d.type+(x?"<"+x+">":""))+")"})}return _;function _(){let x=O1,w,C,v;if((!t||l(d,f,m[m.length-1]||void 0))&&(x=hR(n(d,m)),x[0]===Pm))return x;if("children"in d&&d.children){const S=d;if(S.children&&x[0]!==dR)for(C=(s?S.children.length:-1)+u,v=m.concat(S);C>-1&&C<S.children.length;){const b=S.children[C];if(w=c(b,C,v)(),w[0]===Pm)return w;C=typeof w[1]=="number"?w[1]:C+u}}return x}}}function hR(e){return Array.isArray(e)?e:typeof e=="number"?[uR,e]:e==null?O1:[e]}function zp(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),M1(e,l,c,a);function c(d,f){const m=f[f.length-1],p=m?m.children.indexOf(d):void 0;return u(d,p,m)}}const Bm={}.hasOwnProperty,fR={};function mR(e,t){const n=t||fR,s=new Map,a=new Map,l=new Map,u={...QD,...n.handlers},c={all:f,applyData:gR,definitionById:s,footnoteById:a,footnoteCounts:l,footnoteOrder:[],handlers:u,one:d,options:n,patch:pR,wrap:_R};return zp(e,function(m){if(m.type==="definition"||m.type==="footnoteDefinition"){const p=m.type==="definition"?s:a,_=String(m.identifier).toUpperCase();p.has(_)||p.set(_,m)}}),c;function d(m,p){const _=m.type,x=c.handlers[_];if(Bm.call(c.handlers,_)&&x)return x(c,m,p);if(c.options.passThrough&&c.options.passThrough.includes(_)){if("children"in m){const{children:C,...v}=m,S=vu(v);return S.children=c.all(m),S}return vu(m)}return(c.options.unknownHandler||xR)(c,m,p)}function f(m){const p=[];if("children"in m){const _=m.children;let x=-1;for(;++x<_.length;){const w=c.one(_[x],m);if(w){if(x&&_[x-1].type==="break"&&(!Array.isArray(w)&&w.type==="text"&&(w.value=Db(w.value)),!Array.isArray(w)&&w.type==="element")){const C=w.children[0];C&&C.type==="text"&&(C.value=Db(C.value))}Array.isArray(w)?p.push(...w):p.push(w)}}}return p}}function pR(e,t){e.position&&(t.position=rA(e))}function gR(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,vu(l)),"children"in n&&n.children&&a!==null&&a!==void 0&&(n.children=a)}return n}function xR(e,t){const n=t.data||{},s="value"in t&&!(Bm.call(n,"hProperties")||Bm.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 _R(e,t){const n=[];let s=-1;for(t&&n.push({type:"text",value:`
106
+ `});++s<e.length;)s&&n.push({type:"text",value:`
107
+ `}),n.push(e[s]);return t&&e.length>0&&n.push({type:"text",value:`
108
+ `}),n}function Db(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function Rb(e,t){const n=mR(e,t),s=n.one(e,void 0),a=sR(n),l=Array.isArray(s)?{type:"root",children:s}:s||{type:"root",children:[]};return a&&l.children.push({type:"text",value:`
109
+ `},a),l}function yR(e,t){return e&&"run"in e?async function(n,s){const a=Rb(n,{file:s,...t});await e.run(a,s)}:function(n,s){return Rb(n,{file:s,...e||t})}}function Ob(e){if(e)throw e}var qf,Mb;function vR(){if(Mb)return qf;Mb=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 m=e.call(f,"constructor"),p=f.constructor&&f.constructor.prototype&&e.call(f.constructor.prototype,"isPrototypeOf");if(f.constructor&&!m&&!p)return!1;var _;for(_ in f);return typeof _>"u"||e.call(f,_)},u=function(f,m){n&&m.name==="__proto__"?n(f,m.name,{enumerable:!0,configurable:!0,value:m.newValue,writable:!0}):f[m.name]=m.newValue},c=function(f,m){if(m==="__proto__")if(e.call(f,m)){if(s)return s(f,m).value}else return;return f[m]};return qf=function d(){var f,m,p,_,x,w,C=arguments[0],v=1,S=arguments.length,b=!1;for(typeof C=="boolean"&&(b=C,C=arguments[1]||{},v=2),(C==null||typeof C!="object"&&typeof C!="function")&&(C={});v<S;++v)if(f=arguments[v],f!=null)for(m in f)p=c(C,m),_=c(f,m),C!==_&&(b&&_&&(l(_)||(x=a(_)))?(x?(x=!1,w=p&&a(p)?p:[]):w=p&&l(p)?p:{},u(C,{name:m,newValue:d(b,w,_)})):typeof _<"u"&&u(C,{name:m,newValue:_}));return C},qf}var bR=vR();const Kf=Mu(bR);function zm(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 SR(){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(d,...f){const m=e[++l];let p=-1;if(d){u(d);return}for(;++p<a.length;)(f[p]===null||f[p]===void 0)&&(f[p]=a[p]);a=f,m?wR(m,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 wR(e,t){let n;return s;function s(...u){const c=e.length>u.length;let d;c&&u.push(a);try{d=e.apply(this,u)}catch(f){const m=f;if(c&&n)throw m;return a(m)}c||(d&&d.then&&typeof d.then=="function"?d.then(l,a):d instanceof Error?a(d):l(d))}function a(u,...c){n||(n=!0,t(u,...c))}function l(u){a(null,u)}}const Rr={basename:CR,dirname:kR,extname:ER,join:jR,sep:"/"};function CR(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Cl(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 kR(e){if(Cl(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 ER(e){Cl(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 jR(...e){let t=-1,n;for(;++t<e.length;)Cl(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":NR(n)}function NR(e){Cl(e);const t=e.codePointAt(0)===47;let n=TR(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function TR(e,t){let n="",s=0,a=-1,l=0,u=-1,c,d;for(;++u<=e.length;){if(u<e.length)c=e.codePointAt(u);else{if(c===47)break;c=47}if(c===47){if(!(a===u-1||l===1))if(a!==u-1&&l===2){if(n.length<2||s!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(d=n.lastIndexOf("/"),d!==n.length-1){d<0?(n="",s=0):(n=n.slice(0,d),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 Cl(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const AR={cwd:LR};function LR(){return"/"}function $m(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function DR(e){if(typeof e=="string")e=new URL(e);else if(!$m(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 RR(e)}function RR(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 Yf=["history","path","basename","stem","extname","dirname"];class I1{constructor(t){let n;t?$m(t)?n={path:t}:typeof t=="string"||OR(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":AR.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let s=-1;for(;++s<Yf.length;){const l=Yf[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)Yf.includes(a)||(this[a]=n[a])}get basename(){return typeof this.path=="string"?Rr.basename(this.path):void 0}set basename(t){Qf(t,"basename"),Xf(t,"basename"),this.path=Rr.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Rr.dirname(this.path):void 0}set dirname(t){Ib(this.basename,"dirname"),this.path=Rr.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Rr.extname(this.path):void 0}set extname(t){if(Xf(t,"extname"),Ib(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=Rr.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){$m(t)&&(t=DR(t)),Qf(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Rr.basename(this.path,this.extname):void 0}set stem(t){Qf(t,"stem"),Xf(t,"stem"),this.path=Rr.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 wn(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 Xf(e,t){if(e&&e.includes(Rr.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Rr.sep+"`")}function Qf(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function Ib(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function OR(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const MR=(function(e){const s=this.constructor.prototype,a=s[e],l=function(){return a.apply(l,arguments)};return Object.setPrototypeOf(l,s),l}),IR={}.hasOwnProperty;class $p extends MR{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=SR()}copy(){const t=new $p;let n=-1;for(;++n<this.attachers.length;){const s=this.attachers[n];t.use(...s)}return t.data(Kf(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(em("data",this.frozen),this.namespace[t]=n,this):IR.call(this.namespace,t)&&this.namespace[t]||void 0:t?(em("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=Xc(t),s=this.parser||this.Parser;return Jf("parse",s),s(String(n),n)}process(t,n){const s=this;return this.freeze(),Jf("process",this.parser||this.Parser),Zf("process",this.compiler||this.Compiler),n?a(void 0,n):new Promise(a);function a(l,u){const c=Xc(t),d=s.parse(c);s.run(d,c,function(m,p,_){if(m||!p||!_)return f(m);const x=p,w=s.stringify(x,_);zR(w)?_.value=w:_.result=w,f(m,_)});function f(m,p){m||!p?u(m):l?l(p):n(void 0,p)}}}processSync(t){let n=!1,s;return this.freeze(),Jf("processSync",this.parser||this.Parser),Zf("processSync",this.compiler||this.Compiler),this.process(t,a),Bb("processSync","process",n),s;function a(l,u){n=!0,Ob(l),s=u}}run(t,n,s){Pb(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 d=Xc(n);a.run(t,d,f);function f(m,p,_){const x=p||t;m?c(m):u?u(x):s(void 0,x,_)}}}runSync(t,n){let s=!1,a;return this.run(t,n,l),Bb("runSync","run",s),a;function l(u,c){Ob(u),a=c,s=!0}}stringify(t,n){this.freeze();const s=Xc(n),a=this.compiler||this.Compiler;return Zf("stringify",a),Pb(t),a(t,s)}use(t,...n){const s=this.attachers,a=this.namespace;if(em("use",this.frozen),t!=null)if(typeof t=="function")d(t,n);else if(typeof t=="object")Array.isArray(t)?c(t):u(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function l(f){if(typeof f=="function")d(f,[]);else if(typeof f=="object")if(Array.isArray(f)){const[m,...p]=f;d(m,p)}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=Kf(!0,a.settings,f.settings))}function c(f){let m=-1;if(f!=null)if(Array.isArray(f))for(;++m<f.length;){const p=f[m];l(p)}else throw new TypeError("Expected a list of plugins, not `"+f+"`")}function d(f,m){let p=-1,_=-1;for(;++p<s.length;)if(s[p][0]===f){_=p;break}if(_===-1)s.push([f,...m]);else if(m.length>0){let[x,...w]=m;const C=s[_][1];zm(C)&&zm(x)&&(x=Kf(!0,C,x)),s[_]=[f,x,...w]}}}}const PR=new $p().freeze();function Jf(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Zf(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function em(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 Pb(e){if(!zm(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function Bb(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Xc(e){return BR(e)?e:new I1(e)}function BR(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function zR(e){return typeof e=="string"||$R(e)}function $R(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const HR="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",zb=[],$b={allowDangerousHtml:!0},UR=/^(https?|ircs?|mailto|xmpp)$/i,FR=[{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 VR(e){const t=GR(e),n=WR(e);return qR(t.runSync(t.parse(n),n),e)}function GR(e){const t=e.rehypePlugins||zb,n=e.remarkPlugins||zb,s=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...$b}:$b;return PR().use(kD).use(n).use(yR,s).use(t)}function WR(e){const t=e.children||"",n=new I1;return typeof t=="string"&&(n.value=t),n}function qR(e,t){const n=t.allowedElements,s=t.allowElement,a=t.components,l=t.disallowedElements,u=t.skipHtml,c=t.unwrapDisallowed,d=t.urlTransform||KR;for(const m of FR)Object.hasOwn(t,m.from)&&(""+m.from+(m.to?"use `"+m.to+"` instead":"remove it")+HR+m.id,void 0);return zp(e,f),lA(e,{Fragment:o.Fragment,components:a,ignoreInvalidStyle:!0,jsx:o.jsx,jsxs:o.jsxs,passKeys:!0,passNode:!0});function f(m,p,_){if(m.type==="raw"&&_&&typeof p=="number")return u?_.children.splice(p,1):_.children[p]={type:"text",value:m.value},p;if(m.type==="element"){let x;for(x in Vf)if(Object.hasOwn(Vf,x)&&Object.hasOwn(m.properties,x)){const w=m.properties[x],C=Vf[x];(C===null||C.includes(m.tagName))&&(m.properties[x]=d(String(w||""),x,m))}}if(m.type==="element"){let x=n?!n.includes(m.tagName):l?l.includes(m.tagName):!1;if(!x&&s&&typeof p=="number"&&(x=!s(m,p,_)),x&&_&&typeof p=="number")return c&&m.children?_.children.splice(p,1,...m.children):_.children.splice(p,1),p}}}function KR(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||UR.test(e.slice(0,t))?e:""}function Hb(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 YR(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function XR(e,t,n){const a=Zu((n||{}).ignore||[]),l=QR(t);let u=-1;for(;++u<l.length;)M1(e,"text",c);function c(f,m){let p=-1,_;for(;++p<m.length;){const x=m[p],w=_?_.children:void 0;if(a(x,w?w.indexOf(x):void 0,_))return;_=x}if(_)return d(f,m)}function d(f,m){const p=m[m.length-1],_=l[u][0],x=l[u][1];let w=0;const v=p.children.indexOf(f);let S=!1,b=[];_.lastIndex=0;let y=_.exec(f.value);for(;y;){const E=y.index,N={index:y.index,input:y.input,stack:[...m,f]};let T=x(...y,N);if(typeof T=="string"&&(T=T.length>0?{type:"text",value:T}:void 0),T===!1?_.lastIndex=E+1:(w!==E&&b.push({type:"text",value:f.value.slice(w,E)}),Array.isArray(T)?b.push(...T):T&&b.push(T),w=E+y[0].length,S=!0),!_.global)break;y=_.exec(f.value)}return S?(w<f.value.length&&b.push({type:"text",value:f.value.slice(w)}),p.children.splice(v,1,...b)):b=[f],v+b.length}}function QR(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([JR(a[0]),ZR(a[1])])}return t}function JR(e){return typeof e=="string"?new RegExp(YR(e),"g"):e}function ZR(e){return typeof e=="function"?e:function(){return e}}const tm="phrasing",nm=["autolink","link","image","label"];function e3(){return{transforms:[o3],enter:{literalAutolink:n3,literalAutolinkEmail:rm,literalAutolinkHttp:rm,literalAutolinkWww:rm},exit:{literalAutolink:a3,literalAutolinkEmail:i3,literalAutolinkHttp:r3,literalAutolinkWww:s3}}}function t3(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:tm,notInConstruct:nm},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:tm,notInConstruct:nm},{character:":",before:"[ps]",after:"\\/",inConstruct:tm,notInConstruct:nm}]}}function n3(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function rm(e){this.config.enter.autolinkProtocol.call(this,e)}function r3(e){this.config.exit.autolinkProtocol.call(this,e)}function s3(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 i3(e){this.config.exit.autolinkEmail.call(this,e)}function a3(e){this.exit(e)}function o3(e){XR(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,l3],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),c3]],{ignore:["link","linkReference"]})}function l3(e,t,n,s,a){let l="";if(!P1(a)||(/^w/i.test(t)&&(n=t+n,t="",l="http://"),!u3(n)))return!1;const u=d3(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 c3(e,t,n,s){return!P1(s,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function u3(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 d3(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=Hb(e,"(");let l=Hb(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 P1(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||Ai(n)||Xu(n))&&(!t||n!==47)}B1.peek=v3;function h3(){this.buffer()}function f3(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function m3(){this.buffer()}function p3(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function g3(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Sr(this.sliceSerialize(e)).toLowerCase(),n.label=t}function x3(e){this.exit(e)}function _3(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Sr(this.sliceSerialize(e)).toLowerCase(),n.label=t}function y3(e){this.exit(e)}function v3(){return"["}function B1(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 b3(){return{enter:{gfmFootnoteCallString:h3,gfmFootnoteCall:f3,gfmFootnoteDefinitionLabelString:m3,gfmFootnoteDefinition:p3},exit:{gfmFootnoteCallString:g3,gfmFootnoteCall:x3,gfmFootnoteDefinitionLabelString:_3,gfmFootnoteDefinition:y3}}}function S3(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:B1},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(s,a,l,u){const c=l.createTracker(u);let d=c.move("[^");const f=l.enter("footnoteDefinition"),m=l.enter("label");return d+=c.move(l.safe(l.associationId(s),{before:d,after:"]"})),m(),d+=c.move("]:"),s.children&&s.children.length>0&&(c.shift(4),d+=c.move((t?`
110
+ `:" ")+l.indentLines(l.containerFlow(s,c.current()),t?z1:w3))),f(),d}}function w3(e,t,n){return t===0?e:z1(e,t,n)}function z1(e,t,n){return(n?"":" ")+e}const C3=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];$1.peek=T3;function k3(){return{canContainEols:["delete"],enter:{strikethrough:j3},exit:{strikethrough:N3}}}function E3(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:C3}],handlers:{delete:$1}}}function j3(e){this.enter({type:"delete",children:[]},e)}function N3(e){this.exit(e)}function $1(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 T3(){return"~"}function A3(e){return e.length}function L3(e,t){const n=t||{},s=(n.align||[]).concat(),a=n.stringLength||A3,l=[],u=[],c=[],d=[];let f=0,m=-1;for(;++m<e.length;){const C=[],v=[];let S=-1;for(e[m].length>f&&(f=e[m].length);++S<e[m].length;){const b=D3(e[m][S]);if(n.alignDelimiters!==!1){const y=a(b);v[S]=y,(d[S]===void 0||y>d[S])&&(d[S]=y)}C.push(b)}u[m]=C,c[m]=v}let p=-1;if(typeof s=="object"&&"length"in s)for(;++p<f;)l[p]=Ub(s[p]);else{const C=Ub(s);for(;++p<f;)l[p]=C}p=-1;const _=[],x=[];for(;++p<f;){const C=l[p];let v="",S="";C===99?(v=":",S=":"):C===108?v=":":C===114&&(S=":");let b=n.alignDelimiters===!1?1:Math.max(1,d[p]-v.length-S.length);const y=v+"-".repeat(b)+S;n.alignDelimiters!==!1&&(b=v.length+b+S.length,b>d[p]&&(d[p]=b),x[p]=b),_[p]=y}u.splice(1,0,_),c.splice(1,0,x),m=-1;const w=[];for(;++m<u.length;){const C=u[m],v=c[m];p=-1;const S=[];for(;++p<f;){const b=C[p]||"";let y="",E="";if(n.alignDelimiters!==!1){const N=d[p]-(v[p]||0),T=l[p];T===114?y=" ".repeat(N):T===99?N%2?(y=" ".repeat(N/2+.5),E=" ".repeat(N/2-.5)):(y=" ".repeat(N/2),E=y):E=" ".repeat(N)}n.delimiterStart!==!1&&!p&&S.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&b==="")&&(n.delimiterStart!==!1||p)&&S.push(" "),n.alignDelimiters!==!1&&S.push(y),S.push(b),n.alignDelimiters!==!1&&S.push(E),n.padding!==!1&&S.push(" "),(n.delimiterEnd!==!1||p!==f-1)&&S.push("|")}w.push(n.delimiterEnd===!1?S.join("").replace(/ +$/,""):S.join(""))}return w.join(`
111
+ `)}function D3(e){return e==null?"":String(e)}function Ub(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 R3(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()),O3);return a(),u}function O3(e,t,n){return">"+(n?"":" ")+e}function M3(e,t){return Fb(e,t.inConstruct,!0)&&!Fb(e,t.notInConstruct,!1)}function Fb(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 Vb(e,t,n,s){let a=-1;for(;++a<n.unsafe.length;)if(n.unsafe[a].character===`
112
+ `&&M3(n.stack,n.unsafe[a]))return/[ \t]/.test(s.before)?"":" ";return`\\
113
+ `}function I3(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 P3(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 B3(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 z3(e,t,n,s){const a=B3(n),l=e.value||"",u=a==="`"?"GraveAccent":"Tilde";if(P3(e,n)){const p=n.enter("codeIndented"),_=n.indentLines(l,$3);return p(),_}const c=n.createTracker(s),d=a.repeat(Math.max(I3(l,a)+1,3)),f=n.enter("codeFenced");let m=c.move(d);if(e.lang){const p=n.enter(`codeFencedLang${u}`);m+=c.move(n.safe(e.lang,{before:m,after:" ",encode:["`"],...c.current()})),p()}if(e.lang&&e.meta){const p=n.enter(`codeFencedMeta${u}`);m+=c.move(" "),m+=c.move(n.safe(e.meta,{before:m,after:`
114
+ `,encode:["`"],...c.current()})),p()}return m+=c.move(`
115
+ `),l&&(m+=c.move(l+`
116
+ `)),m+=c.move(d),f(),m}function $3(e,t,n){return(n?"":" ")+e}function Hp(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 H3(e,t,n,s){const a=Hp(n),l=a==='"'?"Quote":"Apostrophe",u=n.enter("definition");let c=n.enter("label");const d=n.createTracker(s);let f=d.move("[");return f+=d.move(n.safe(n.associationId(e),{before:f,after:"]",...d.current()})),f+=d.move("]: "),c(),!e.url||/[\0- \u007F]/.test(e.url)?(c=n.enter("destinationLiteral"),f+=d.move("<"),f+=d.move(n.safe(e.url,{before:f,after:">",...d.current()})),f+=d.move(">")):(c=n.enter("destinationRaw"),f+=d.move(n.safe(e.url,{before:f,after:e.title?" ":`
117
+ `,...d.current()}))),c(),e.title&&(c=n.enter(`title${l}`),f+=d.move(" "+a),f+=d.move(n.safe(e.title,{before:f,after:a,...d.current()})),f+=d.move(a),c()),u(),f}function U3(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 cl(e){return"&#x"+e.toString(16).toUpperCase()+";"}function bu(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}}H1.peek=F3;function H1(e,t,n,s){const a=U3(n),l=n.enter("emphasis"),u=n.createTracker(s),c=u.move(a);let d=u.move(n.containerPhrasing(e,{after:a,before:c,...u.current()}));const f=d.charCodeAt(0),m=bu(s.before.charCodeAt(s.before.length-1),f,a);m.inside&&(d=cl(f)+d.slice(1));const p=d.charCodeAt(d.length-1),_=bu(s.after.charCodeAt(0),p,a);_.inside&&(d=d.slice(0,-1)+cl(p));const x=u.move(a);return l(),n.attentionEncodeSurroundingInfo={after:_.outside,before:m.outside},c+d+x}function F3(e,t,n){return n.options.emphasis||"*"}function V3(e,t){let n=!1;return zp(e,function(s){if("value"in s&&/\r?\n|\r/.test(s.value)||s.type==="break")return n=!0,Pm}),!!((!e.depth||e.depth<3)&&Dp(e)&&(t.options.setext||n))}function G3(e,t,n,s){const a=Math.max(Math.min(6,e.depth||1),1),l=n.createTracker(s);if(V3(e,n)){const m=n.enter("headingSetext"),p=n.enter("phrasing"),_=n.containerPhrasing(e,{...l.current(),before:`
118
+ `,after:`
119
+ `});return p(),m(),_+`
120
+ `+(a===1?"=":"-").repeat(_.length-(Math.max(_.lastIndexOf("\r"),_.lastIndexOf(`
121
+ `))+1))}const u="#".repeat(a),c=n.enter("headingAtx"),d=n.enter("phrasing");l.move(u+" ");let f=n.containerPhrasing(e,{before:"# ",after:`
122
+ `,...l.current()});return/^[\t ]/.test(f)&&(f=cl(f.charCodeAt(0))+f.slice(1)),f=f?u+" "+f:u,n.options.closeAtx&&(f+=" "+u),d(),c(),f}U1.peek=W3;function U1(e){return e.value||""}function W3(){return"<"}F1.peek=q3;function F1(e,t,n,s){const a=Hp(n),l=a==='"'?"Quote":"Apostrophe",u=n.enter("image");let c=n.enter("label");const d=n.createTracker(s);let f=d.move("![");return f+=d.move(n.safe(e.alt,{before:f,after:"]",...d.current()})),f+=d.move("]("),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter("destinationLiteral"),f+=d.move("<"),f+=d.move(n.safe(e.url,{before:f,after:">",...d.current()})),f+=d.move(">")):(c=n.enter("destinationRaw"),f+=d.move(n.safe(e.url,{before:f,after:e.title?" ":")",...d.current()}))),c(),e.title&&(c=n.enter(`title${l}`),f+=d.move(" "+a),f+=d.move(n.safe(e.title,{before:f,after:a,...d.current()})),f+=d.move(a),c()),f+=d.move(")"),u(),f}function q3(){return"!"}V1.peek=K3;function V1(e,t,n,s){const a=e.referenceType,l=n.enter("imageReference");let u=n.enter("label");const c=n.createTracker(s);let d=c.move("![");const f=n.safe(e.alt,{before:d,after:"]",...c.current()});d+=c.move(f+"]["),u();const m=n.stack;n.stack=[],u=n.enter("reference");const p=n.safe(n.associationId(e),{before:d,after:"]",...c.current()});return u(),n.stack=m,l(),a==="full"||!f||f!==p?d+=c.move(p+"]"):a==="shortcut"?d=d.slice(0,-1):d+=c.move("]"),d}function K3(){return"!"}G1.peek=Y3;function G1(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 d;if(u.atBreak)for(;d=c.exec(s);){let f=d.index;s.charCodeAt(f)===10&&s.charCodeAt(f-1)===13&&f--,s=s.slice(0,f)+" "+s.slice(d.index+1)}}return a+s+a}function Y3(){return"`"}function W1(e,t){const n=Dp(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))}q1.peek=X3;function q1(e,t,n,s){const a=Hp(n),l=a==='"'?"Quote":"Apostrophe",u=n.createTracker(s);let c,d;if(W1(e,n)){const m=n.stack;n.stack=[],c=n.enter("autolink");let p=u.move("<");return p+=u.move(n.containerPhrasing(e,{before:p,after:">",...u.current()})),p+=u.move(">"),c(),n.stack=m,p}c=n.enter("link"),d=n.enter("label");let f=u.move("[");return f+=u.move(n.containerPhrasing(e,{before:f,after:"](",...u.current()})),f+=u.move("]("),d(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(d=n.enter("destinationLiteral"),f+=u.move("<"),f+=u.move(n.safe(e.url,{before:f,after:">",...u.current()})),f+=u.move(">")):(d=n.enter("destinationRaw"),f+=u.move(n.safe(e.url,{before:f,after:e.title?" ":")",...u.current()}))),d(),e.title&&(d=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),d()),f+=u.move(")"),c(),f}function X3(e,t,n){return W1(e,n)?"<":"["}K1.peek=Q3;function K1(e,t,n,s){const a=e.referenceType,l=n.enter("linkReference");let u=n.enter("label");const c=n.createTracker(s);let d=c.move("[");const f=n.containerPhrasing(e,{before:d,after:"]",...c.current()});d+=c.move(f+"]["),u();const m=n.stack;n.stack=[],u=n.enter("reference");const p=n.safe(n.associationId(e),{before:d,after:"]",...c.current()});return u(),n.stack=m,l(),a==="full"||!f||f!==p?d+=c.move(p+"]"):a==="shortcut"?d=d.slice(0,-1):d+=c.move("]"),d}function Q3(){return"["}function Up(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 J3(e){const t=Up(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 Z3(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 Y1(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 e5(e,t,n,s){const a=n.enter("list"),l=n.bulletCurrent;let u=e.ordered?Z3(n):Up(n);const c=e.ordered?u==="."?")":".":J3(n);let d=t&&n.bulletLastUsed?u===n.bulletLastUsed:!1;if(!e.ordered){const m=e.children?e.children[0]:void 0;if((u==="*"||u==="-")&&m&&(!m.children||!m.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(d=!0),Y1(n)===u&&m){let p=-1;for(;++p<e.children.length;){const _=e.children[p];if(_&&_.type==="listItem"&&_.children&&_.children[0]&&_.children[0].type==="thematicBreak"){d=!0;break}}}}d&&(u=c),n.bulletCurrent=u;const f=n.containerFlow(e,s);return n.bulletLastUsed=u,n.bulletCurrent=l,a(),f}function t5(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 n5(e,t,n,s){const a=t5(n);let l=n.bulletCurrent||Up(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 d=n.enter("listItem"),f=n.indentLines(n.containerFlow(e,c.current()),m);return d(),f;function m(p,_,x){return _?(x?"":" ".repeat(u))+p:(x?l:l+" ".repeat(u-l.length))+p}}function r5(e,t,n,s){const a=n.enter("paragraph"),l=n.enter("phrasing"),u=n.containerPhrasing(e,s);return l(),a(),u}const s5=Zu(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function i5(e,t,n,s){return(e.children.some(function(u){return s5(u)})?n.containerPhrasing:n.containerFlow).call(n,e,s)}function a5(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}X1.peek=o5;function X1(e,t,n,s){const a=a5(n),l=n.enter("strong"),u=n.createTracker(s),c=u.move(a+a);let d=u.move(n.containerPhrasing(e,{after:a,before:c,...u.current()}));const f=d.charCodeAt(0),m=bu(s.before.charCodeAt(s.before.length-1),f,a);m.inside&&(d=cl(f)+d.slice(1));const p=d.charCodeAt(d.length-1),_=bu(s.after.charCodeAt(0),p,a);_.inside&&(d=d.slice(0,-1)+cl(p));const x=u.move(a+a);return l(),n.attentionEncodeSurroundingInfo={after:_.outside,before:m.outside},c+d+x}function o5(e,t,n){return n.options.strong||"*"}function l5(e,t,n,s){return n.safe(e.value,s)}function c5(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 u5(e,t,n){const s=(Y1(n)+(n.options.ruleSpaces?" ":"")).repeat(c5(n));return n.options.ruleSpaces?s.slice(0,-1):s}const Q1={blockquote:R3,break:Vb,code:z3,definition:H3,emphasis:H1,hardBreak:Vb,heading:G3,html:U1,image:F1,imageReference:V1,inlineCode:G1,link:q1,linkReference:K1,list:e5,listItem:n5,paragraph:r5,root:i5,strong:X1,text:l5,thematicBreak:u5};function d5(){return{enter:{table:h5,tableData:Gb,tableHeader:Gb,tableRow:m5},exit:{codeText:p5,table:f5,tableData:sm,tableHeader:sm,tableRow:sm}}}function h5(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 f5(e){this.exit(e),this.data.inTable=void 0}function m5(e){this.enter({type:"tableRow",children:[]},e)}function sm(e){this.exit(e)}function Gb(e){this.enter({type:"tableCell",children:[]},e)}function p5(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,g5));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function g5(e,t){return t==="|"?t:e}function x5(e){const t=e||{},n=t.tableCellPadding,s=t.tablePipeAlign,a=t.stringLength,l=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
123
+ `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:_,table:u,tableCell:d,tableRow:c}};function u(x,w,C,v){return f(m(x,C,v),x.align)}function c(x,w,C,v){const S=p(x,C,v),b=f([S]);return b.slice(0,b.indexOf(`
124
+ `))}function d(x,w,C,v){const S=C.enter("tableCell"),b=C.enter("phrasing"),y=C.containerPhrasing(x,{...v,before:l,after:l});return b(),S(),y}function f(x,w){return L3(x,{align:w,alignDelimiters:s,padding:n,stringLength:a})}function m(x,w,C){const v=x.children;let S=-1;const b=[],y=w.enter("table");for(;++S<v.length;)b[S]=p(v[S],w,C);return y(),b}function p(x,w,C){const v=x.children;let S=-1;const b=[],y=w.enter("tableRow");for(;++S<v.length;)b[S]=d(v[S],x,w,C);return y(),b}function _(x,w,C){let v=Q1.inlineCode(x,w,C);return C.stack.includes("tableCell")&&(v=v.replace(/\|/g,"\\$&")),v}}function _5(){return{exit:{taskListCheckValueChecked:Wb,taskListCheckValueUnchecked:Wb,paragraph:v5}}}function y5(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:b5}}}function Wb(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function v5(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 b5(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 d=Q1.listItem(e,t,n,{...s,...c.current()});return l&&(d=d.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,f)),d;function f(m){return m+u}}function S5(){return[e3(),b3(),k3(),d5(),_5()]}function w5(e){return{extensions:[t3(),S3(e),E3(),x5(e),y5()]}}const C5={tokenize:A5,partial:!0},J1={tokenize:L5,partial:!0},Z1={tokenize:D5,partial:!0},ew={tokenize:R5,partial:!0},k5={tokenize:O5,partial:!0},tw={name:"wwwAutolink",tokenize:N5,previous:rw},nw={name:"protocolAutolink",tokenize:T5,previous:sw},hs={name:"emailAutolink",tokenize:j5,previous:iw},Br={};function E5(){return{text:Br}}let gi=48;for(;gi<123;)Br[gi]=hs,gi++,gi===58?gi=65:gi===91&&(gi=97);Br[43]=hs;Br[45]=hs;Br[46]=hs;Br[95]=hs;Br[72]=[hs,nw];Br[104]=[hs,nw];Br[87]=[hs,tw];Br[119]=[hs,tw];function j5(e,t,n){const s=this;let a,l;return u;function u(p){return!Hm(p)||!iw.call(s,s.previous)||Fp(s.events)?n(p):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),c(p))}function c(p){return Hm(p)?(e.consume(p),c):p===64?(e.consume(p),d):n(p)}function d(p){return p===46?e.check(k5,m,f)(p):p===45||p===95||Sn(p)?(l=!0,e.consume(p),d):m(p)}function f(p){return e.consume(p),a=!0,d}function m(p){return l&&a&&En(s.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(p)):n(p)}}function N5(e,t,n){const s=this;return a;function a(u){return u!==87&&u!==119||!rw.call(s,s.previous)||Fp(s.events)?n(u):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(C5,e.attempt(J1,e.attempt(Z1,l),n),n)(u))}function l(u){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(u)}}function T5(e,t,n){const s=this;let a="",l=!1;return u;function u(p){return(p===72||p===104)&&sw.call(s,s.previous)&&!Fp(s.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),a+=String.fromCodePoint(p),e.consume(p),c):n(p)}function c(p){if(En(p)&&a.length<5)return a+=String.fromCodePoint(p),e.consume(p),c;if(p===58){const _=a.toLowerCase();if(_==="http"||_==="https")return e.consume(p),d}return n(p)}function d(p){return p===47?(e.consume(p),l?f:(l=!0,d)):n(p)}function f(p){return p===null||_u(p)||Tt(p)||Ai(p)||Xu(p)?n(p):e.attempt(J1,e.attempt(Z1,m),n)(p)}function m(p){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(p)}}function A5(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 L5(e,t,n){let s,a,l;return u;function u(f){return f===46||f===95?e.check(ew,d,c)(f):f===null||Tt(f)||Ai(f)||f!==45&&Xu(f)?d(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 d(f){return a||s||!l?n(f):t(f)}}function D5(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(ew,t,l)(u):u===null||Tt(u)||Ai(u)?t(u):(e.consume(u),a)}function l(u){return u===41&&s++,e.consume(u),a}}function R5(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||Tt(c)||Ai(c)?t(c):n(c)}function a(c){return c===null||c===40||c===91||Tt(c)||Ai(c)?t(c):s(c)}function l(c){return En(c)?u(c):n(c)}function u(c){return c===59?(e.consume(c),s):En(c)?(e.consume(c),u):n(c)}}function O5(e,t,n){return s;function s(l){return e.consume(l),a}function a(l){return Sn(l)?n(l):t(l)}}function rw(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Tt(e)}function sw(e){return!En(e)}function iw(e){return!(e===47||Hm(e))}function Hm(e){return e===43||e===45||e===46||e===95||Sn(e)}function Fp(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 M5={tokenize:F5,partial:!0};function I5(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:$5,continuation:{tokenize:H5},exit:U5}},text:{91:{name:"gfmFootnoteCall",tokenize:z5},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:P5,resolveTo:B5}}}}function P5(e,t,n){const s=this;let a=s.events.length;const l=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let u;for(;a--;){const d=s.events[a][1];if(d.type==="labelImage"){u=d;break}if(d.type==="gfmFootnoteCall"||d.type==="labelLink"||d.type==="label"||d.type==="image"||d.type==="link")break}return c;function c(d){if(!u||!u._balanced)return n(d);const f=Sr(s.sliceSerialize({start:u.end,end:s.now()}));return f.codePointAt(0)!==94||!l.includes(f.slice(1))?n(d):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),t(d))}}function B5(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 z5(e,t,n){const s=this,a=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let l=0,u;return c;function c(p){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),d}function d(p){return p!==94?n(p):(e.enter("gfmFootnoteCallMarker"),e.consume(p),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",f)}function f(p){if(l>999||p===93&&!u||p===null||p===91||Tt(p))return n(p);if(p===93){e.exit("chunkString");const _=e.exit("gfmFootnoteCallString");return a.includes(Sr(s.sliceSerialize(_)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(p),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(p)}return Tt(p)||(u=!0),l++,e.consume(p),p===92?m:f}function m(p){return p===91||p===92||p===93?(e.consume(p),l++,f):f(p)}}function $5(e,t,n){const s=this,a=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let l,u=0,c;return d;function d(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",m):n(w)}function m(w){if(u>999||w===93&&!c||w===null||w===91||Tt(w))return n(w);if(w===93){e.exit("chunkString");const C=e.exit("gfmFootnoteDefinitionLabelString");return l=Sr(s.sliceSerialize(C)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),_}return Tt(w)||(c=!0),u++,e.consume(w),w===92?p:m}function p(w){return w===91||w===92||w===93?(e.consume(w),u++,m):m(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 H5(e,t,n){return e.check(wl,t,e.attempt(M5,t,n))}function U5(e){e.exit("gfmFootnoteDefinition")}function F5(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 V5(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 d=-1;for(;++d<u.length;)if(u[d][0]==="enter"&&u[d][1].type==="strikethroughSequenceTemporary"&&u[d][1]._close){let f=d;for(;f--;)if(u[f][0]==="exit"&&u[f][1].type==="strikethroughSequenceTemporary"&&u[f][1]._open&&u[d][1].end.offset-u[d][1].start.offset===u[f][1].end.offset-u[f][1].start.offset){u[d][1].type="strikethroughSequence",u[f][1].type="strikethroughSequence";const m={type:"strikethrough",start:Object.assign({},u[f][1].start),end:Object.assign({},u[d][1].end)},p={type:"strikethroughText",start:Object.assign({},u[f][1].end),end:Object.assign({},u[d][1].start)},_=[["enter",m,c],["enter",u[f][1],c],["exit",u[f][1],c],["enter",p,c]],x=c.parser.constructs.insideSpan.null;x&&Kn(_,_.length,0,Qu(x,u.slice(f+1,d),c)),Kn(_,_.length,0,[["exit",p,c],["enter",u[d][1],c],["exit",u[d][1],c],["exit",m,c]]),Kn(u,f-1,d-f+3,_),d=f+_.length-2;break}}for(d=-1;++d<u.length;)u[d][1].type==="strikethroughSequenceTemporary"&&(u[d][1].type="data");return u}function l(u,c,d){const f=this.previous,m=this.events;let p=0;return _;function _(w){return f===126&&m[m.length-1][1].type!=="characterEscape"?d(w):(u.enter("strikethroughSequenceTemporary"),x(w))}function x(w){const C=Pa(f);if(w===126)return p>1?d(w):(u.consume(w),p++,x);if(p<2&&!n)return d(w);const v=u.exit("strikethroughSequenceTemporary"),S=Pa(w);return v._open=!S||S===2&&!!C,v._close=!C||C===2&&!!S,c(w)}}}class G5{constructor(){this.map=[]}add(t,n,s){W5(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 W5(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 q5(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 K5(){return{flow:{null:{name:"table",tokenize:Y5,resolveAll:X5}}}}function Y5(e,t,n){const s=this;let a=0,l=0,u;return c;function c(M){let G=s.events.length-1;for(;G>-1;){const U=s.events[G][1].type;if(U==="lineEnding"||U==="linePrefix")G--;else break}const W=G>-1?s.events[G][1].type:null,O=W==="tableHead"||W==="tableRow"?T:d;return O===T&&s.parser.lazy[s.now().line]?n(M):O(M)}function d(M){return e.enter("tableHead"),e.enter("tableRow"),f(M)}function f(M){return M===124||(u=!0,l+=1),m(M)}function m(M){return M===null?n(M):He(M)?l>1?(l=0,s.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(M),e.exit("lineEnding"),x):n(M):st(M)?ut(e,m,"whitespace")(M):(l+=1,u&&(u=!1,a+=1),M===124?(e.enter("tableCellDivider"),e.consume(M),e.exit("tableCellDivider"),u=!0,m):(e.enter("data"),p(M)))}function p(M){return M===null||M===124||Tt(M)?(e.exit("data"),m(M)):(e.consume(M),M===92?_:p)}function _(M){return M===92||M===124?(e.consume(M),p):p(M)}function x(M){return s.interrupt=!1,s.parser.lazy[s.now().line]?n(M):(e.enter("tableDelimiterRow"),u=!1,st(M)?ut(e,w,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(M):w(M))}function w(M){return M===45||M===58?v(M):M===124?(u=!0,e.enter("tableCellDivider"),e.consume(M),e.exit("tableCellDivider"),C):N(M)}function C(M){return st(M)?ut(e,v,"whitespace")(M):v(M)}function v(M){return M===58?(l+=1,u=!0,e.enter("tableDelimiterMarker"),e.consume(M),e.exit("tableDelimiterMarker"),S):M===45?(l+=1,S(M)):M===null||He(M)?E(M):N(M)}function S(M){return M===45?(e.enter("tableDelimiterFiller"),b(M)):N(M)}function b(M){return M===45?(e.consume(M),b):M===58?(u=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(M),e.exit("tableDelimiterMarker"),y):(e.exit("tableDelimiterFiller"),y(M))}function y(M){return st(M)?ut(e,E,"whitespace")(M):E(M)}function E(M){return M===124?w(M):M===null||He(M)?!u||a!==l?N(M):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(M)):N(M)}function N(M){return n(M)}function T(M){return e.enter("tableRow"),L(M)}function L(M){return M===124?(e.enter("tableCellDivider"),e.consume(M),e.exit("tableCellDivider"),L):M===null||He(M)?(e.exit("tableRow"),t(M)):st(M)?ut(e,L,"whitespace")(M):(e.enter("data"),A(M))}function A(M){return M===null||M===124||Tt(M)?(e.exit("data"),L(M)):(e.consume(M),M===92?R:A)}function R(M){return M===92||M===124?(e.consume(M),A):A(M)}}function X5(e,t){let n=-1,s=!0,a=0,l=[0,0,0,0],u=[0,0,0,0],c=!1,d=0,f,m,p;const _=new G5;for(;++n<e.length;){const x=e[n],w=x[1];x[0]==="enter"?w.type==="tableHead"?(c=!1,d!==0&&(qb(_,t,d,f,m),m=void 0,d=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,p=void 0,l=[0,0,0,0],u=[0,n+1,0,0],c&&(c=!1,m={type:"tableBody",start:Object.assign({},w.start),end:Object.assign({},w.end)},_.add(n,0,[["enter",m,t]])),a=w.type==="tableDelimiterRow"?2:m?3:1):a&&(w.type==="data"||w.type==="tableDelimiterMarker"||w.type==="tableDelimiterFiller")?(s=!1,u[2]===0&&(l[1]!==0&&(u[0]=u[1],p=Qc(_,t,l,a,void 0,p),l=[0,0,0,0]),u[2]=n)):w.type==="tableCellDivider"&&(s?s=!1:(l[1]!==0&&(u[0]=u[1],p=Qc(_,t,l,a,void 0,p)),l=u,u=[l[1],n,0,0])):w.type==="tableHead"?(c=!0,d=n):w.type==="tableRow"||w.type==="tableDelimiterRow"?(d=n,l[1]!==0?(u[0]=u[1],p=Qc(_,t,l,a,n,p)):u[1]!==0&&(p=Qc(_,t,u,a,n,p)),a=0):a&&(w.type==="data"||w.type==="tableDelimiterMarker"||w.type==="tableDelimiterFiller")&&(u[3]=n)}for(d!==0&&qb(_,t,d,f,m),_.consume(t.events),n=-1;++n<t.events.length;){const x=t.events[n];x[0]==="enter"&&x[1].type==="table"&&(x[1]._align=q5(t.events,n))}return e}function Qc(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 d=La(t.events,n[1]);if(l={type:u,start:Object.assign({},d),end:Object.assign({},d)},e.add(n[1],0,[["enter",l,t]]),n[2]!==0){const f=La(t.events,n[2]),m=La(t.events,n[3]),p={type:c,start:Object.assign({},f),end:Object.assign({},m)};if(e.add(n[2],0,[["enter",p,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,C=n[3]-n[2]-1;e.add(w,C,[])}}e.add(n[3]+1,0,[["exit",p,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 qb(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 Q5={name:"tasklistCheck",tokenize:Z5};function J5(){return{text:{91:Q5}}}function Z5(e,t,n){const s=this;return a;function a(d){return s.previous!==null||!s._gfmTasklistFirstContentOfListItem?n(d):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(d),e.exit("taskListCheckMarker"),l)}function l(d){return Tt(d)?(e.enter("taskListCheckValueUnchecked"),e.consume(d),e.exit("taskListCheckValueUnchecked"),u):d===88||d===120?(e.enter("taskListCheckValueChecked"),e.consume(d),e.exit("taskListCheckValueChecked"),u):n(d)}function u(d){return d===93?(e.enter("taskListCheckMarker"),e.consume(d),e.exit("taskListCheckMarker"),e.exit("taskListCheck"),c):n(d)}function c(d){return He(d)?t(d):st(d)?e.check({tokenize:eO},t,n)(d):n(d)}}function eO(e,t,n){return ut(e,s,"whitespace");function s(a){return a===null?n(a):t(a)}}function tO(e){return g1([E5(),I5(),V5(e),K5(),J5()])}const nO={};function rO(e){const t=this,n=e||nO,s=t.data(),a=s.micromarkExtensions||(s.micromarkExtensions=[]),l=s.fromMarkdownExtensions||(s.fromMarkdownExtensions=[]),u=s.toMarkdownExtensions||(s.toMarkdownExtensions=[]);a.push(tO(n)),l.push(S5()),u.push(w5(n))}var Um=Object.defineProperty,sO=Object.getOwnPropertyDescriptor,iO=Object.getOwnPropertyNames,aO=Object.prototype.hasOwnProperty,Vp=(e,t)=>{let n={};for(var s in e)Um(n,s,{get:e[s],enumerable:!0});return Um(n,Symbol.toStringTag,{value:"Module"}),n},oO=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(var a=iO(t),l=0,u=a.length,c;l<u;l++)c=a[l],!aO.call(e,c)&&c!==n&&Um(e,c,{get:(d=>t[d]).bind(null,c),enumerable:!(s=sO(t,c))||s.enumerable});return e},aw=(e,t,n)=>(oO(e,t,"default"),n);const td=[{id:"abap",name:"ABAP",import:(()=>Q(()=>import("./abap-BdImnpbu.js"),[]))},{id:"actionscript-3",name:"ActionScript",import:(()=>Q(()=>import("./actionscript-3-CoDkCxhg.js"),[]))},{id:"ada",name:"Ada",import:(()=>Q(()=>import("./ada-bCR0ucgS.js"),[]))},{id:"angular-html",name:"Angular HTML",import:(()=>Q(()=>import("./angular-html-DA-rfuFy.js").then(e=>e.f),__vite__mapDeps([0,1,2,3])))},{id:"angular-ts",name:"Angular TypeScript",import:(()=>Q(()=>import("./angular-ts-BrjP3tb8.js"),__vite__mapDeps([4,0,1,2,3,5])))},{id:"apache",name:"Apache Conf",import:(()=>Q(()=>import("./apache-Pmp26Uib.js"),[]))},{id:"apex",name:"Apex",import:(()=>Q(()=>import("./apex-Dqspr-GT.js"),[]))},{id:"apl",name:"APL",import:(()=>Q(()=>import("./apl-CORt7UWP.js"),__vite__mapDeps([6,1,2,3,7,8,9])))},{id:"applescript",name:"AppleScript",import:(()=>Q(()=>import("./applescript-Co6uUVPk.js"),[]))},{id:"ara",name:"Ara",import:(()=>Q(()=>import("./ara-BRHolxvo.js"),[]))},{id:"asciidoc",name:"AsciiDoc",aliases:["adoc"],import:(()=>Q(()=>import("./asciidoc-Ve4PFQV2.js"),[]))},{id:"asm",name:"Assembly",import:(()=>Q(()=>import("./asm-D_Q5rh1f.js"),[]))},{id:"astro",name:"Astro",import:(()=>Q(()=>import("./astro-HNnZUWAn.js"),__vite__mapDeps([10,9,2,11,3,12,13])))},{id:"awk",name:"AWK",import:(()=>Q(()=>import("./awk-DMzUqQB5.js"),[]))},{id:"ballerina",name:"Ballerina",import:(()=>Q(()=>import("./ballerina-BFfxhgS-.js"),[]))},{id:"bat",name:"Batch File",aliases:["batch"],import:(()=>Q(()=>import("./bat-BkioyH1T.js"),[]))},{id:"beancount",name:"Beancount",import:(()=>Q(()=>import("./beancount-k_qm7-4y.js"),[]))},{id:"berry",name:"Berry",aliases:["be"],import:(()=>Q(()=>import("./berry-uYugtg8r.js"),[]))},{id:"bibtex",name:"BibTeX",import:(()=>Q(()=>import("./bibtex-CHM0blh-.js"),[]))},{id:"bicep",name:"Bicep",import:(()=>Q(()=>import("./bicep-Bmn6On1c.js"),[]))},{id:"bird2",name:"BIRD2 Configuration",aliases:["bird"],import:(()=>Q(()=>import("./bird2-BIv1doCn.js"),[]))},{id:"blade",name:"Blade",import:(()=>Q(()=>import("./blade-2xfisSek.js"),__vite__mapDeps([14,15,1,2,3,7,8,16,9])))},{id:"bsl",name:"1C (Enterprise)",aliases:["1c"],import:(()=>Q(()=>import("./bsl-BO_Y6i37.js"),__vite__mapDeps([17,18])))},{id:"c",name:"C",import:(()=>Q(()=>import("./c-BIGW1oBm.js"),[]))},{id:"c3",name:"C3",import:(()=>Q(()=>import("./c3-MRO5bC_T.js"),[]))},{id:"cadence",name:"Cadence",aliases:["cdc"],import:(()=>Q(()=>import("./cadence-Bv_4Rxtq.js"),[]))},{id:"cairo",name:"Cairo",import:(()=>Q(()=>import("./cairo-KRGpt6FW.js"),__vite__mapDeps([19,20])))},{id:"clarity",name:"Clarity",import:(()=>Q(()=>import("./clarity-D53aC0YG.js"),[]))},{id:"clojure",name:"Clojure",aliases:["clj"],import:(()=>Q(()=>import("./clojure-P80f7IUj.js"),[]))},{id:"cmake",name:"CMake",import:(()=>Q(()=>import("./cmake-D1j8_8rp.js"),[]))},{id:"cobol",name:"COBOL",import:(()=>Q(()=>import("./cobol-nBiQ_Alo.js"),__vite__mapDeps([21,1,2,3,8])))},{id:"codeowners",name:"CODEOWNERS",import:(()=>Q(()=>import("./codeowners-Bp6g37R7.js"),[]))},{id:"codeql",name:"CodeQL",aliases:["ql"],import:(()=>Q(()=>import("./codeql-DsOJ9woJ.js"),[]))},{id:"coffee",name:"CoffeeScript",aliases:["coffeescript"],import:(()=>Q(()=>import("./coffee-Ch7k5sss.js"),__vite__mapDeps([22,2])))},{id:"common-lisp",name:"Common Lisp",aliases:["lisp"],import:(()=>Q(()=>import("./common-lisp-Cg-RD9OK.js"),[]))},{id:"coq",name:"Coq",import:(()=>Q(()=>import("./coq-DkFqJrB1.js"),[]))},{id:"cpp",name:"C++",aliases:["c++"],import:(()=>Q(()=>import("./cpp-UfJy6YNI.js"),__vite__mapDeps([23,24,25,26,16])))},{id:"crystal",name:"Crystal",import:(()=>Q(()=>import("./crystal-DGywbUpC.js"),__vite__mapDeps([27,1,2,3,16,26,28])))},{id:"csharp",name:"C#",aliases:["c#","cs"],import:(()=>Q(()=>import("./csharp-DSvCPggb.js"),[]))},{id:"css",name:"CSS",import:(()=>Q(()=>import("./css-CLj8gQPS.js"),[]))},{id:"csv",name:"CSV",import:(()=>Q(()=>import("./csv-fuZLfV_i.js"),[]))},{id:"cue",name:"CUE",import:(()=>Q(()=>import("./cue-D82EKSYY.js"),[]))},{id:"cypher",name:"Cypher",aliases:["cql"],import:(()=>Q(()=>import("./cypher-COkxafJQ.js"),[]))},{id:"d",name:"D",import:(()=>Q(()=>import("./d-85-TOEBH.js"),[]))},{id:"dart",name:"Dart",import:(()=>Q(()=>import("./dart-bE4Kk8sk.js"),[]))},{id:"dax",name:"DAX",import:(()=>Q(()=>import("./dax-CEL-wOlO.js"),[]))},{id:"desktop",name:"Desktop",import:(()=>Q(()=>import("./desktop-BmXAJ9_W.js"),[]))},{id:"diff",name:"Diff",import:(()=>Q(()=>import("./diff-D97Zzqfu.js"),[]))},{id:"docker",name:"Dockerfile",aliases:["dockerfile"],import:(()=>Q(()=>import("./docker-BcOcwvcX.js"),[]))},{id:"dotenv",name:"dotEnv",import:(()=>Q(()=>import("./dotenv-Da5cRb03.js"),[]))},{id:"dream-maker",name:"Dream Maker",import:(()=>Q(()=>import("./dream-maker-BtqSS_iP.js"),[]))},{id:"edge",name:"Edge",import:(()=>Q(()=>import("./edge-FbVlp4U3.js"),__vite__mapDeps([29,11,1,2,3,15])))},{id:"elixir",name:"Elixir",import:(()=>Q(()=>import("./elixir-CkH2-t6x.js"),__vite__mapDeps([30,1,2,3])))},{id:"elm",name:"Elm",import:(()=>Q(()=>import("./elm-DbKCFpqz.js"),__vite__mapDeps([31,25,26])))},{id:"emacs-lisp",name:"Emacs Lisp",aliases:["elisp"],import:(()=>Q(()=>import("./emacs-lisp-CXvaQtF9.js"),[]))},{id:"erb",name:"ERB",import:(()=>Q(()=>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:(()=>Q(()=>import("./erlang-DsQrWhSR.js"),__vite__mapDeps([39,40])))},{id:"fennel",name:"Fennel",import:(()=>Q(()=>import("./fennel-BYunw83y.js"),[]))},{id:"fish",name:"Fish",import:(()=>Q(()=>import("./fish-BvzEVeQv.js"),[]))},{id:"fluent",name:"Fluent",aliases:["ftl"],import:(()=>Q(()=>import("./fluent-C4IJs8-o.js"),[]))},{id:"fortran-fixed-form",name:"Fortran (Fixed Form)",aliases:["f","for","f77"],import:(()=>Q(()=>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:(()=>Q(()=>import("./fortran-free-form-BxgE0vQu.js"),[]))},{id:"fsharp",name:"F#",aliases:["f#","fs"],import:(()=>Q(()=>import("./fsharp-CXgrBDvD.js"),__vite__mapDeps([43,40])))},{id:"gdresource",name:"GDResource",aliases:["tscn","tres"],import:(()=>Q(()=>import("./gdresource-BOOCDP_w.js"),__vite__mapDeps([44,45,46])))},{id:"gdscript",name:"GDScript",aliases:["gd"],import:(()=>Q(()=>import("./gdscript-C5YyOfLZ.js"),[]))},{id:"gdshader",name:"GDShader",import:(()=>Q(()=>import("./gdshader-DkwncUOv.js"),[]))},{id:"genie",name:"Genie",import:(()=>Q(()=>import("./genie-D0YGMca9.js"),[]))},{id:"gherkin",name:"Gherkin",import:(()=>Q(()=>import("./gherkin-DyxjwDmM.js"),[]))},{id:"git-commit",name:"Git Commit Message",import:(()=>Q(()=>import("./git-commit-F4YmCXRG.js"),__vite__mapDeps([47,48])))},{id:"git-rebase",name:"Git Rebase Message",import:(()=>Q(()=>import("./git-rebase-r7XF79zn.js"),__vite__mapDeps([49,28])))},{id:"gleam",name:"Gleam",import:(()=>Q(()=>import("./gleam-BspZqrRM.js"),[]))},{id:"glimmer-js",name:"Glimmer JS",aliases:["gjs"],import:(()=>Q(()=>import("./glimmer-js-ByusRIyA.js"),__vite__mapDeps([50,2,11,3,1])))},{id:"glimmer-ts",name:"Glimmer TS",aliases:["gts"],import:(()=>Q(()=>import("./glimmer-ts-BfAWNZQY.js"),__vite__mapDeps([51,11,3,2,1])))},{id:"glsl",name:"GLSL",import:(()=>Q(()=>import("./glsl-DplSGwfg.js"),__vite__mapDeps([25,26])))},{id:"gn",name:"GN",import:(()=>Q(()=>import("./gn-n2N0HUVH.js"),[]))},{id:"gnuplot",name:"Gnuplot",import:(()=>Q(()=>import("./gnuplot-DdkO51Og.js"),[]))},{id:"go",name:"Go",import:(()=>Q(()=>import("./go-C27-OAKa.js"),[]))},{id:"graphql",name:"GraphQL",aliases:["gql"],import:(()=>Q(()=>import("./graphql-ChdNCCLP.js"),__vite__mapDeps([35,2,11,36,13])))},{id:"groovy",name:"Groovy",import:(()=>Q(()=>import("./groovy-gcz8RCvz.js"),[]))},{id:"hack",name:"Hack",import:(()=>Q(()=>import("./hack-DbPARsA_.js"),__vite__mapDeps([52,1,2,3,16])))},{id:"haml",name:"Ruby Haml",import:(()=>Q(()=>import("./haml-D5jkg6IW.js"),__vite__mapDeps([34,2,3])))},{id:"handlebars",name:"Handlebars",aliases:["hbs"],import:(()=>Q(()=>import("./handlebars-BpdQsYii.js"),__vite__mapDeps([53,1,2,3,38])))},{id:"haskell",name:"Haskell",aliases:["hs"],import:(()=>Q(()=>import("./haskell-Df6bDoY_.js"),[]))},{id:"haxe",name:"Haxe",import:(()=>Q(()=>import("./haxe-CzTSHFRz.js"),[]))},{id:"hcl",name:"HashiCorp HCL",import:(()=>Q(()=>import("./hcl-BWvSN4gD.js"),[]))},{id:"hjson",name:"Hjson",import:(()=>Q(()=>import("./hjson-D5-asLiD.js"),[]))},{id:"hlsl",name:"HLSL",import:(()=>Q(()=>import("./hlsl-D3lLCCz7.js"),[]))},{id:"html",name:"HTML",import:(()=>Q(()=>import("./html-pp8916En.js"),__vite__mapDeps([1,2,3])))},{id:"html-derivative",name:"HTML (Derivative)",import:(()=>Q(()=>import("./html-derivative-DlHx6ybY.js"),__vite__mapDeps([15,1,2,3])))},{id:"http",name:"HTTP",import:(()=>Q(()=>import("./http-jrhK8wxY.js"),__vite__mapDeps([54,28,9,7,8,35,2,11,36,13])))},{id:"hurl",name:"Hurl",import:(()=>Q(()=>import("./hurl-irOxFIW8.js"),__vite__mapDeps([55,35,2,11,36,13,7,8,56])))},{id:"hxml",name:"HXML",import:(()=>Q(()=>import("./hxml-Bvhsp5Yf.js"),__vite__mapDeps([57,58])))},{id:"hy",name:"Hy",import:(()=>Q(()=>import("./hy-DFXneXwc.js"),[]))},{id:"imba",name:"Imba",import:(()=>Q(()=>import("./imba-DGztddWO.js"),[]))},{id:"ini",name:"INI",aliases:["properties"],import:(()=>Q(()=>import("./ini-BEwlwnbL.js"),[]))},{id:"java",name:"Java",import:(()=>Q(()=>import("./java-CylS5w8V.js"),[]))},{id:"javascript",name:"JavaScript",aliases:["js","cjs","mjs"],import:(()=>Q(()=>import("./javascript-wDzz0qaB.js"),[]))},{id:"jinja",name:"Jinja",import:(()=>Q(()=>import("./jinja-f2NsQr07.js"),__vite__mapDeps([59,1,2,3])))},{id:"jison",name:"Jison",import:(()=>Q(()=>import("./jison-wvAkD_A8.js"),__vite__mapDeps([60,2])))},{id:"json",name:"JSON",import:(()=>Q(()=>import("./json-Cp-IABpG.js"),[]))},{id:"json5",name:"JSON5",import:(()=>Q(()=>import("./json5-C9tS-k6U.js"),[]))},{id:"jsonc",name:"JSON with Comments",import:(()=>Q(()=>import("./jsonc-Des-eS-w.js"),[]))},{id:"jsonl",name:"JSON Lines",import:(()=>Q(()=>import("./jsonl-DcaNXYhu.js"),[]))},{id:"jsonnet",name:"Jsonnet",import:(()=>Q(()=>import("./jsonnet-DFQXde-d.js"),[]))},{id:"jssm",name:"JSSM",aliases:["fsl"],import:(()=>Q(()=>import("./jssm-C2t-YnRu.js"),[]))},{id:"jsx",name:"JSX",import:(()=>Q(()=>import("./jsx-g9-lgVsj.js"),[]))},{id:"julia",name:"Julia",aliases:["jl"],import:(()=>Q(()=>import("./julia-D7OTSIA_.js"),__vite__mapDeps([61,23,24,25,26,16,20,2,62])))},{id:"just",name:"Just",import:(()=>Q(()=>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:(()=>Q(()=>import("./kdl-DV7GczEv.js"),[]))},{id:"kotlin",name:"Kotlin",aliases:["kt","kts"],import:(()=>Q(()=>import("./kotlin-BdnUsdx6.js"),[]))},{id:"kusto",name:"Kusto",aliases:["kql"],import:(()=>Q(()=>import("./kusto-wEQ09or8.js"),[]))},{id:"latex",name:"LaTeX",import:(()=>Q(()=>import("./latex-CaSxy8MP.js"),__vite__mapDeps([65,66,62])))},{id:"lean",name:"Lean 4",aliases:["lean4"],import:(()=>Q(()=>import("./lean-BZvkOJ9d.js"),[]))},{id:"less",name:"Less",import:(()=>Q(()=>import("./less-B1dDrJ26.js"),[]))},{id:"liquid",name:"Liquid",import:(()=>Q(()=>import("./liquid-C0sCDyMI.js"),__vite__mapDeps([67,1,2,3,9])))},{id:"llvm",name:"LLVM IR",import:(()=>Q(()=>import("./llvm-DjAJT7YJ.js"),[]))},{id:"log",name:"Log file",import:(()=>Q(()=>import("./log-2UxHyX5q.js"),[]))},{id:"logo",name:"Logo",import:(()=>Q(()=>import("./logo-BtOb2qkB.js"),[]))},{id:"lua",name:"Lua",import:(()=>Q(()=>import("./lua-BaeVxFsk.js"),__vite__mapDeps([37,26])))},{id:"luau",name:"Luau",import:(()=>Q(()=>import("./luau-KW6xsasC.js"),[]))},{id:"make",name:"Makefile",aliases:["makefile"],import:(()=>Q(()=>import("./make-CHLpvVh8.js"),[]))},{id:"markdown",name:"Markdown",aliases:["md"],import:(()=>Q(()=>import("./markdown-Cvjx9yec.js"),[]))},{id:"marko",name:"Marko",import:(()=>Q(()=>import("./marko-DjSrsDqO.js"),__vite__mapDeps([68,3,69,5,11])))},{id:"matlab",name:"MATLAB",import:(()=>Q(()=>import("./matlab-D7o27uSR.js"),[]))},{id:"mdc",name:"MDC",import:(()=>Q(()=>import("./mdc-DTYItulj.js"),__vite__mapDeps([70,40,38,15,1,2,3])))},{id:"mdx",name:"MDX",import:(()=>Q(()=>import("./mdx-Cmh6b_Ma.js"),[]))},{id:"mermaid",name:"Mermaid",aliases:["mmd"],import:(()=>Q(()=>import("./mermaid-mWjccvbQ.js"),[]))},{id:"mipsasm",name:"MIPS Assembly",aliases:["mips"],import:(()=>Q(()=>import("./mipsasm-CKIfxQSi.js"),[]))},{id:"mojo",name:"Mojo",import:(()=>Q(()=>import("./mojo-rZm6bMo-.js"),[]))},{id:"moonbit",name:"MoonBit",aliases:["mbt","mbti"],import:(()=>Q(()=>import("./moonbit-_H4v1dQx.js"),[]))},{id:"move",name:"Move",import:(()=>Q(()=>import("./move-IF9eRakj.js"),[]))},{id:"narrat",name:"Narrat Language",aliases:["nar"],import:(()=>Q(()=>import("./narrat-DRg8JJMk.js"),[]))},{id:"nextflow",name:"Nextflow",aliases:["nf"],import:(()=>Q(()=>import("./nextflow-C-mBbutL.js"),__vite__mapDeps([71,72])))},{id:"nextflow-groovy",name:"Nextflow Groovy",import:(()=>Q(()=>import("./nextflow-groovy-vE_lwT2v.js"),[]))},{id:"nginx",name:"Nginx",import:(()=>Q(()=>import("./nginx-BpAMiNFr.js"),__vite__mapDeps([73,37,26])))},{id:"nim",name:"Nim",import:(()=>Q(()=>import("./nim-BIad80T-.js"),__vite__mapDeps([74,26,1,2,3,7,8,25,40])))},{id:"nix",name:"Nix",import:(()=>Q(()=>import("./nix-CwoSXNpI.js"),[]))},{id:"nushell",name:"nushell",aliases:["nu"],import:(()=>Q(()=>import("./nushell-Cz2AlsmD.js"),[]))},{id:"objective-c",name:"Objective-C",aliases:["objc"],import:(()=>Q(()=>import("./objective-c-DXmwc3jG.js"),[]))},{id:"objective-cpp",name:"Objective-C++",import:(()=>Q(()=>import("./objective-cpp-CLxacb5B.js"),[]))},{id:"ocaml",name:"OCaml",import:(()=>Q(()=>import("./ocaml-C0hk2d4L.js"),[]))},{id:"odin",name:"Odin",import:(()=>Q(()=>import("./odin-BBf5iR-q.js"),[]))},{id:"openscad",name:"OpenSCAD",aliases:["scad"],import:(()=>Q(()=>import("./openscad-C4EeE6gA.js"),[]))},{id:"pascal",name:"Pascal",import:(()=>Q(()=>import("./pascal-D93ZcfNL.js"),[]))},{id:"perl",name:"Perl",import:(()=>Q(()=>import("./perl-B9cMNwum.js"),__vite__mapDeps([64,1,2,3,7,8,16])))},{id:"php",name:"PHP",import:(()=>Q(()=>import("./php-Csjmro_R.js"),__vite__mapDeps([75,1,2,3,7,8,16,9])))},{id:"pkl",name:"Pkl",import:(()=>Q(()=>import("./pkl-u5AG7uiY.js"),[]))},{id:"plsql",name:"PL/SQL",import:(()=>Q(()=>import("./plsql-ChMvpjG-.js"),[]))},{id:"po",name:"Gettext PO",aliases:["pot","potx"],import:(()=>Q(()=>import("./po-BTJTHyun.js"),[]))},{id:"polar",name:"Polar",import:(()=>Q(()=>import("./polar-C0HS_06l.js"),[]))},{id:"postcss",name:"PostCSS",import:(()=>Q(()=>import("./postcss-CXtECtnM.js"),[]))},{id:"powerquery",name:"PowerQuery",import:(()=>Q(()=>import("./powerquery-CEu0bR-o.js"),[]))},{id:"powershell",name:"PowerShell",aliases:["ps","ps1"],import:(()=>Q(()=>import("./powershell-Dpen1YoG.js"),[]))},{id:"prisma",name:"Prisma",import:(()=>Q(()=>import("./prisma-Dd19v3D-.js"),[]))},{id:"prolog",name:"Prolog",import:(()=>Q(()=>import("./prolog-CbFg5uaA.js"),[]))},{id:"proto",name:"Protocol Buffer 3",aliases:["protobuf"],import:(()=>Q(()=>import("./proto-C7zT0LnQ.js"),[]))},{id:"pug",name:"Pug",aliases:["jade"],import:(()=>Q(()=>import("./pug-DKIMFp6K.js"),__vite__mapDeps([76,2,3,1])))},{id:"puppet",name:"Puppet",import:(()=>Q(()=>import("./puppet-BMWR74SV.js"),[]))},{id:"purescript",name:"PureScript",import:(()=>Q(()=>import("./purescript-CklMAg4u.js"),[]))},{id:"python",name:"Python",aliases:["py"],import:(()=>Q(()=>import("./python-B6aJPvgy.js"),[]))},{id:"qml",name:"QML",import:(()=>Q(()=>import("./qml-3beO22l8.js"),__vite__mapDeps([77,2])))},{id:"qmldir",name:"QML Directory",import:(()=>Q(()=>import("./qmldir-C8lEn-DE.js"),[]))},{id:"qss",name:"Qt Style Sheets",import:(()=>Q(()=>import("./qss-IeuSbFQv.js"),[]))},{id:"r",name:"R",import:(()=>Q(()=>import("./r-Dspwwk_N.js"),[]))},{id:"racket",name:"Racket",import:(()=>Q(()=>import("./racket-BqYA7rlc.js"),[]))},{id:"raku",name:"Raku",aliases:["perl6"],import:(()=>Q(()=>import("./raku-DXvB9xmW.js"),[]))},{id:"razor",name:"ASP.NET Razor",import:(()=>Q(()=>import("./razor-BjBPvh-w.js"),__vite__mapDeps([78,1,2,3,79])))},{id:"reg",name:"Windows Registry Script",import:(()=>Q(()=>import("./reg-C-SQnVFl.js"),[]))},{id:"regexp",name:"RegExp",aliases:["regex"],import:(()=>Q(()=>import("./regexp-CDVJQ6XC.js"),[]))},{id:"rel",name:"Rel",import:(()=>Q(()=>import("./rel-C3B-1QV4.js"),[]))},{id:"riscv",name:"RISC-V",import:(()=>Q(()=>import("./riscv-BM1_JUlF.js"),[]))},{id:"ron",name:"RON",import:(()=>Q(()=>import("./ron-D8l8udqQ.js"),[]))},{id:"rosmsg",name:"ROS Interface",import:(()=>Q(()=>import("./rosmsg-BJDFO7_C.js"),[]))},{id:"rst",name:"reStructuredText",import:(()=>Q(()=>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:(()=>Q(()=>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:(()=>Q(()=>import("./rust-B1yitclQ.js"),[]))},{id:"sas",name:"SAS",import:(()=>Q(()=>import("./sas-DEy46yEz.js"),__vite__mapDeps([82,16])))},{id:"sass",name:"Sass",import:(()=>Q(()=>import("./sass-Cj5Yp3dK.js"),[]))},{id:"scala",name:"Scala",import:(()=>Q(()=>import("./scala-C151Ov-r.js"),[]))},{id:"scheme",name:"Scheme",import:(()=>Q(()=>import("./scheme-C98Dy4si.js"),[]))},{id:"scss",name:"SCSS",import:(()=>Q(()=>import("./scss-D5BDwBP9.js"),__vite__mapDeps([5,3])))},{id:"sdbl",name:"1C (Query)",aliases:["1c-query"],import:(()=>Q(()=>import("./sdbl-DVxCFoDh.js"),[]))},{id:"shaderlab",name:"ShaderLab",aliases:["shader"],import:(()=>Q(()=>import("./shaderlab-Dg9Lc6iA.js"),__vite__mapDeps([83,84])))},{id:"shellscript",name:"Shell",aliases:["bash","sh","shell","zsh"],import:(()=>Q(()=>import("./shellscript-Yzrsuije.js"),[]))},{id:"shellsession",name:"Shell Session",aliases:["console"],import:(()=>Q(()=>import("./shellsession-BADoaaVG.js"),__vite__mapDeps([85,28])))},{id:"smalltalk",name:"Smalltalk",import:(()=>Q(()=>import("./smalltalk-BERRCDM3.js"),[]))},{id:"solidity",name:"Solidity",import:(()=>Q(()=>import("./solidity-rGO070M0.js"),[]))},{id:"soy",name:"Closure Templates",aliases:["closure-templates"],import:(()=>Q(()=>import("./soy-8wufbnw4.js"),__vite__mapDeps([86,1,2,3])))},{id:"sparql",name:"SPARQL",import:(()=>Q(()=>import("./sparql-rVzFXLq3.js"),__vite__mapDeps([87,88])))},{id:"splunk",name:"Splunk Query Language",aliases:["spl"],import:(()=>Q(()=>import("./splunk-BtCnVYZw.js"),[]))},{id:"sql",name:"SQL",import:(()=>Q(()=>import("./sql-CRqJ_cUM.js"),[]))},{id:"ssh-config",name:"SSH Config",import:(()=>Q(()=>import("./ssh-config-_ykCGR6B.js"),[]))},{id:"stata",name:"Stata",import:(()=>Q(()=>import("./stata-DI20mbqo.js"),__vite__mapDeps([89,16])))},{id:"stylus",name:"Stylus",aliases:["styl"],import:(()=>Q(()=>import("./stylus-BEDo0Tqx.js"),[]))},{id:"surrealql",name:"SurrealQL",aliases:["surql"],import:(()=>Q(()=>import("./surrealql-Bq5Q-fJD.js"),__vite__mapDeps([90,2])))},{id:"svelte",name:"Svelte",import:(()=>Q(()=>import("./svelte-Cy7k_4gC.js"),__vite__mapDeps([91,2,11,3,12])))},{id:"swift",name:"Swift",import:(()=>Q(()=>import("./swift-D82vCrfD.js"),[]))},{id:"system-verilog",name:"SystemVerilog",import:(()=>Q(()=>import("./system-verilog-CnnmHF94.js"),[]))},{id:"systemd",name:"Systemd Units",import:(()=>Q(()=>import("./systemd-4A_iFExJ.js"),[]))},{id:"talonscript",name:"TalonScript",aliases:["talon"],import:(()=>Q(()=>import("./talonscript-CkByrt1z.js"),[]))},{id:"tasl",name:"Tasl",import:(()=>Q(()=>import("./tasl-QIJgUcNo.js"),[]))},{id:"tcl",name:"Tcl",import:(()=>Q(()=>import("./tcl-dwOrl1Do.js"),[]))},{id:"templ",name:"Templ",import:(()=>Q(()=>import("./templ-DhtptRzy.js"),__vite__mapDeps([92,93,2,3])))},{id:"terraform",name:"Terraform",aliases:["tf","tfvars"],import:(()=>Q(()=>import("./terraform-BETggiCN.js"),[]))},{id:"tex",name:"TeX",import:(()=>Q(()=>import("./tex-idrVyKtj.js"),__vite__mapDeps([66,62])))},{id:"toml",name:"TOML",import:(()=>Q(()=>import("./toml-vGWfd6FD.js"),[]))},{id:"ts-tags",name:"TypeScript with Tags",aliases:["lit"],import:(()=>Q(()=>import("./ts-tags-D351s5mN.js"),__vite__mapDeps([94,11,3,2,25,26,1,16,7,8])))},{id:"tsv",name:"TSV",import:(()=>Q(()=>import("./tsv-B_m7g4N7.js"),[]))},{id:"tsx",name:"TSX",import:(()=>Q(()=>import("./tsx-COt5Ahok.js"),[]))},{id:"turtle",name:"Turtle",import:(()=>Q(()=>import("./turtle-BsS91CYL.js"),[]))},{id:"twig",name:"Twig",import:(()=>Q(()=>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:(()=>Q(()=>import("./typescript-BPQ3VLAy.js"),[]))},{id:"typespec",name:"TypeSpec",aliases:["tsp"],import:(()=>Q(()=>import("./typespec-CAFt9gP4.js"),[]))},{id:"typst",name:"Typst",aliases:["typ"],import:(()=>Q(()=>import("./typst-DHCkPAjA.js"),[]))},{id:"v",name:"V",import:(()=>Q(()=>import("./v-BcVCzyr7.js"),[]))},{id:"vala",name:"Vala",import:(()=>Q(()=>import("./vala-CsfeWuGM.js"),[]))},{id:"vb",name:"Visual Basic",aliases:["cmd"],import:(()=>Q(()=>import("./vb-D17OF-Vu.js"),[]))},{id:"verilog",name:"Verilog",import:(()=>Q(()=>import("./verilog-BQ8w6xss.js"),[]))},{id:"vhdl",name:"VHDL",import:(()=>Q(()=>import("./vhdl-CeAyd5Ju.js"),[]))},{id:"viml",name:"Vim Script",aliases:["vim","vimscript"],import:(()=>Q(()=>import("./viml-CJc9bBzg.js"),[]))},{id:"vue",name:"Vue",import:(()=>Q(()=>import("./vue-D2xRrEX4.js"),__vite__mapDeps([96,3,2,11,9,1,15])))},{id:"vue-html",name:"Vue HTML",import:(()=>Q(()=>import("./vue-html-AaS7Mt5G.js"),__vite__mapDeps([97,2])))},{id:"vue-vine",name:"Vue Vine",import:(()=>Q(()=>import("./vue-vine-BoDAl6tE.js"),__vite__mapDeps([98,3,5,69,99,12,2])))},{id:"vyper",name:"Vyper",aliases:["vy"],import:(()=>Q(()=>import("./vyper-CDx5xZoG.js"),[]))},{id:"wasm",name:"WebAssembly",import:(()=>Q(()=>import("./wasm-MzD3tlZU.js"),[]))},{id:"wenyan",name:"Wenyan",aliases:["文言"],import:(()=>Q(()=>import("./wenyan-BV7otONQ.js"),[]))},{id:"wgsl",name:"WGSL",import:(()=>Q(()=>import("./wgsl-Dx-B1_4e.js"),[]))},{id:"wikitext",name:"Wikitext",aliases:["mediawiki","wiki"],import:(()=>Q(()=>import("./wikitext-BhOHFoWU.js"),[]))},{id:"wit",name:"WebAssembly Interface Types",import:(()=>Q(()=>import("./wit-5i3qLPDT.js"),[]))},{id:"wolfram",name:"Wolfram",aliases:["wl"],import:(()=>Q(()=>import("./wolfram-lXgVvXCa.js"),[]))},{id:"xml",name:"XML",import:(()=>Q(()=>import("./xml-sdJ4AIDG.js"),__vite__mapDeps([7,8])))},{id:"xsl",name:"XSL",import:(()=>Q(()=>import("./xsl-CtQFsRM5.js"),__vite__mapDeps([100,7,8])))},{id:"yaml",name:"YAML",aliases:["yml"],import:(()=>Q(()=>import("./yaml-Buea-lGh.js"),[]))},{id:"zenscript",name:"ZenScript",import:(()=>Q(()=>import("./zenscript-DVFEvuxE.js"),[]))},{id:"zig",name:"Zig",import:(()=>Q(()=>import("./zig-VOosw3JB.js"),[]))}],Gp=Object.fromEntries(td.map(e=>[e.id,e.import])),Wp=Object.fromEntries(td.flatMap(e=>{var t;return((t=e.aliases)==null?void 0:t.map(n=>[n,e.import]))||[]})),qp={...Gp,...Wp},Kp=[{id:"andromeeda",displayName:"Andromeeda",type:"dark",import:(()=>Q(()=>import("./andromeeda-C4gqWexZ.js"),[]))},{id:"aurora-x",displayName:"Aurora X",type:"dark",import:(()=>Q(()=>import("./aurora-x-D-2ljcwZ.js"),[]))},{id:"ayu-dark",displayName:"Ayu Dark",type:"dark",import:(()=>Q(()=>import("./ayu-dark-DYE7WIF3.js"),[]))},{id:"ayu-light",displayName:"Ayu Light",type:"light",import:(()=>Q(()=>import("./ayu-light-BA47KaF1.js"),[]))},{id:"ayu-mirage",displayName:"Ayu Mirage",type:"dark",import:(()=>Q(()=>import("./ayu-mirage-32ctXXKs.js"),[]))},{id:"catppuccin-frappe",displayName:"Catppuccin Frappé",type:"dark",import:(()=>Q(()=>import("./catppuccin-frappe-DFWUc33u.js"),[]))},{id:"catppuccin-latte",displayName:"Catppuccin Latte",type:"light",import:(()=>Q(()=>import("./catppuccin-latte-C9dUb6Cb.js"),[]))},{id:"catppuccin-macchiato",displayName:"Catppuccin Macchiato",type:"dark",import:(()=>Q(()=>import("./catppuccin-macchiato-DQyhUUbL.js"),[]))},{id:"catppuccin-mocha",displayName:"Catppuccin Mocha",type:"dark",import:(()=>Q(()=>import("./catppuccin-mocha-D87Tk5Gz.js"),[]))},{id:"dark-plus",displayName:"Dark Plus",type:"dark",import:(()=>Q(()=>import("./dark-plus-C3mMm8J8.js"),[]))},{id:"dracula",displayName:"Dracula Theme",type:"dark",import:(()=>Q(()=>import("./dracula-BzJJZx-M.js"),[]))},{id:"dracula-soft",displayName:"Dracula Theme Soft",type:"dark",import:(()=>Q(()=>import("./dracula-soft-BXkSAIEj.js"),[]))},{id:"everforest-dark",displayName:"Everforest Dark",type:"dark",import:(()=>Q(()=>import("./everforest-dark-BgDCqdQA.js"),[]))},{id:"everforest-light",displayName:"Everforest Light",type:"light",import:(()=>Q(()=>import("./everforest-light-C8M2exoo.js"),[]))},{id:"github-dark",displayName:"GitHub Dark",type:"dark",import:(()=>Q(()=>import("./github-dark-DHJKELXO.js"),[]))},{id:"github-dark-default",displayName:"GitHub Dark Default",type:"dark",import:(()=>Q(()=>import("./github-dark-default-Cuk6v7N8.js"),[]))},{id:"github-dark-dimmed",displayName:"GitHub Dark Dimmed",type:"dark",import:(()=>Q(()=>import("./github-dark-dimmed-DH5Ifo-i.js"),[]))},{id:"github-dark-high-contrast",displayName:"GitHub Dark High Contrast",type:"dark",import:(()=>Q(()=>import("./github-dark-high-contrast-E3gJ1_iC.js"),[]))},{id:"github-light",displayName:"GitHub Light",type:"light",import:(()=>Q(()=>import("./github-light-DAi9KRSo.js"),[]))},{id:"github-light-default",displayName:"GitHub Light Default",type:"light",import:(()=>Q(()=>import("./github-light-default-D7oLnXFd.js"),[]))},{id:"github-light-high-contrast",displayName:"GitHub Light High Contrast",type:"light",import:(()=>Q(()=>import("./github-light-high-contrast-BfjtVDDH.js"),[]))},{id:"gruvbox-dark-hard",displayName:"Gruvbox Dark Hard",type:"dark",import:(()=>Q(()=>import("./gruvbox-dark-hard-CFHQjOhq.js"),[]))},{id:"gruvbox-dark-medium",displayName:"Gruvbox Dark Medium",type:"dark",import:(()=>Q(()=>import("./gruvbox-dark-medium-GsRaNv29.js"),[]))},{id:"gruvbox-dark-soft",displayName:"Gruvbox Dark Soft",type:"dark",import:(()=>Q(()=>import("./gruvbox-dark-soft-CVdnzihN.js"),[]))},{id:"gruvbox-light-hard",displayName:"Gruvbox Light Hard",type:"light",import:(()=>Q(()=>import("./gruvbox-light-hard-CH1njM8p.js"),[]))},{id:"gruvbox-light-medium",displayName:"Gruvbox Light Medium",type:"light",import:(()=>Q(()=>import("./gruvbox-light-medium-DRw_LuNl.js"),[]))},{id:"gruvbox-light-soft",displayName:"Gruvbox Light Soft",type:"light",import:(()=>Q(()=>import("./gruvbox-light-soft-hJgmCMqR.js"),[]))},{id:"horizon",displayName:"Horizon",type:"dark",import:(()=>Q(()=>import("./horizon-BUw7H-hv.js"),[]))},{id:"horizon-bright",displayName:"Horizon Bright",type:"light",import:(()=>Q(()=>import("./horizon-bright-CUuTKBJd.js"),[]))},{id:"houston",displayName:"Houston",type:"dark",import:(()=>Q(()=>import("./houston-DnULxvSX.js"),[]))},{id:"kanagawa-dragon",displayName:"Kanagawa Dragon",type:"dark",import:(()=>Q(()=>import("./kanagawa-dragon-CkXjmgJE.js"),[]))},{id:"kanagawa-lotus",displayName:"Kanagawa Lotus",type:"light",import:(()=>Q(()=>import("./kanagawa-lotus-CfQXZHmo.js"),[]))},{id:"kanagawa-wave",displayName:"Kanagawa Wave",type:"dark",import:(()=>Q(()=>import("./kanagawa-wave-DWedfzmr.js"),[]))},{id:"laserwave",displayName:"LaserWave",type:"dark",import:(()=>Q(()=>import("./laserwave-DUszq2jm.js"),[]))},{id:"light-plus",displayName:"Light Plus",type:"light",import:(()=>Q(()=>import("./light-plus-B7mTdjB0.js"),[]))},{id:"material-theme",displayName:"Material Theme",type:"dark",import:(()=>Q(()=>import("./material-theme-D5KoaKCx.js"),[]))},{id:"material-theme-darker",displayName:"Material Theme Darker",type:"dark",import:(()=>Q(()=>import("./material-theme-darker-BfHTSMKl.js"),[]))},{id:"material-theme-lighter",displayName:"Material Theme Lighter",type:"light",import:(()=>Q(()=>import("./material-theme-lighter-B0m2ddpp.js"),[]))},{id:"material-theme-ocean",displayName:"Material Theme Ocean",type:"dark",import:(()=>Q(()=>import("./material-theme-ocean-CyktbL80.js"),[]))},{id:"material-theme-palenight",displayName:"Material Theme Palenight",type:"dark",import:(()=>Q(()=>import("./material-theme-palenight-Csfq5Kiy.js"),[]))},{id:"min-dark",displayName:"Min Dark",type:"dark",import:(()=>Q(()=>import("./min-dark-CafNBF8u.js"),[]))},{id:"min-light",displayName:"Min Light",type:"light",import:(()=>Q(()=>import("./min-light-CTRr51gU.js"),[]))},{id:"monokai",displayName:"Monokai",type:"dark",import:(()=>Q(()=>import("./monokai-D4h5O-jR.js"),[]))},{id:"night-owl",displayName:"Night Owl",type:"dark",import:(()=>Q(()=>import("./night-owl-C39BiMTA.js"),[]))},{id:"night-owl-light",displayName:"Night Owl Light",type:"light",import:(()=>Q(()=>import("./night-owl-light-CMTm3GFP.js"),[]))},{id:"nord",displayName:"Nord",type:"dark",import:(()=>Q(()=>import("./nord-Ddv68eIx.js"),[]))},{id:"one-dark-pro",displayName:"One Dark Pro",type:"dark",import:(()=>Q(()=>import("./one-dark-pro-DVMEJ2y_.js"),[]))},{id:"one-light",displayName:"One Light",type:"light",import:(()=>Q(()=>import("./one-light-C3Wv6jpd.js"),[]))},{id:"plastic",displayName:"Plastic",type:"dark",import:(()=>Q(()=>import("./plastic-3e1v2bzS.js"),[]))},{id:"poimandres",displayName:"Poimandres",type:"dark",import:(()=>Q(()=>import("./poimandres-CS3Unz2-.js"),[]))},{id:"red",displayName:"Red",type:"dark",import:(()=>Q(()=>import("./red-bN70gL4F.js"),[]))},{id:"rose-pine",displayName:"Rosé Pine",type:"dark",import:(()=>Q(()=>import("./rose-pine-qdsjHGoJ.js"),[]))},{id:"rose-pine-dawn",displayName:"Rosé Pine Dawn",type:"light",import:(()=>Q(()=>import("./rose-pine-dawn-DHQR4-dF.js"),[]))},{id:"rose-pine-moon",displayName:"Rosé Pine Moon",type:"dark",import:(()=>Q(()=>import("./rose-pine-moon-D4_iv3hh.js"),[]))},{id:"slack-dark",displayName:"Slack Dark",type:"dark",import:(()=>Q(()=>import("./slack-dark-BthQWCQV.js"),[]))},{id:"slack-ochin",displayName:"Slack Ochin",type:"light",import:(()=>Q(()=>import("./slack-ochin-DqwNpetd.js"),[]))},{id:"snazzy-light",displayName:"Snazzy Light",type:"light",import:(()=>Q(()=>import("./snazzy-light-Bw305WKR.js"),[]))},{id:"solarized-dark",displayName:"Solarized Dark",type:"dark",import:(()=>Q(()=>import("./solarized-dark-DXbdFlpD.js"),[]))},{id:"solarized-light",displayName:"Solarized Light",type:"light",import:(()=>Q(()=>import("./solarized-light-L9t79GZl.js"),[]))},{id:"synthwave-84",displayName:"Synthwave '84",type:"dark",import:(()=>Q(()=>import("./synthwave-84-CbfX1IO0.js"),[]))},{id:"tokyo-night",displayName:"Tokyo Night",type:"dark",import:(()=>Q(()=>import("./tokyo-night-hegEt444.js"),[]))},{id:"vesper",displayName:"Vesper",type:"dark",import:(()=>Q(()=>import("./vesper-DRje8inN.js"),[]))},{id:"vitesse-black",displayName:"Vitesse Black",type:"dark",import:(()=>Q(()=>import("./vitesse-black-Bkuqu6BP.js"),[]))},{id:"vitesse-dark",displayName:"Vitesse Dark",type:"dark",import:(()=>Q(()=>import("./vitesse-dark-D0r3Knsf.js"),[]))},{id:"vitesse-light",displayName:"Vitesse Light",type:"light",import:(()=>Q(()=>import("./vitesse-light-CVO1_9PV.js"),[]))}],Yp=Object.fromEntries(Kp.map(e=>[e.id,e.import]));var Xp=class extends Error{constructor(t){super(t),this.name="ShikiError"}};function lO(){return 2147483648}function cO(){return typeof performance<"u"?performance.now():Date.now()}const uO=(e,t)=>e+(t-e%t)%t;async function dO(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,C){s.HEAPU8.copyWithin(x,w,w+C)}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 C=lO();if(x>C)return!1;for(let v=1;v<=4;v*=2){let S=w*(1+.2/v);S=Math.min(S,x+100663296);const b=Math.min(C,uO(Math.max(x,S),65536));if(u(b))return!0}return!1}const d=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function f(x,w,C=1024){const v=w+C;let S=w;for(;x[S]&&!(S>=v);)++S;if(S-w>16&&x.buffer&&d)return d.decode(x.subarray(w,S));let b="";for(;w<S;){let y=x[w++];if(!(y&128)){b+=String.fromCharCode(y);continue}const E=x[w++]&63;if((y&224)===192){b+=String.fromCharCode((y&31)<<6|E);continue}const N=x[w++]&63;if((y&240)===224?y=(y&15)<<12|E<<6|N:y=(y&7)<<18|E<<12|N<<6|x[w++]&63,y<65536)b+=String.fromCharCode(y);else{const T=y-65536;b+=String.fromCharCode(55296|T>>10,56320|T&1023)}}return b}function m(x,w){return x?f(s.HEAPU8,x,w):""}const p={emscripten_get_now:cO,emscripten_memcpy_big:l,emscripten_resize_heap:c,fd_write:()=>0};async function _(){const w=await e({env:p,wasi_snapshot_preview1:p});t=w.memory,a(t.buffer),Object.assign(s,w),s.UTF8ToString=m}return await _(),s}var hO=Object.defineProperty,fO=(e,t,n)=>t in e?hO(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,sn=(e,t,n)=>fO(e,typeof t!="symbol"?t+"":t,n);let dn=null;function mO(e){throw new Xp(e.UTF8ToString(e.getLastOnigError()))}class nd{constructor(t){sn(this,"utf16Length"),sn(this,"utf8Length"),sn(this,"utf16Value"),sn(this,"utf8Value"),sn(this,"utf16OffsetToUtf8"),sn(this,"utf8OffsetToUtf16");const n=t.length,s=nd._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 d=0;for(let f=0;f<n;f++){const m=t.charCodeAt(f);let p=m,_=!1;if(m>=55296&&m<=56319&&f+1<n){const x=t.charCodeAt(f+1);x>=56320&&x<=57343&&(p=(m-55296<<10)+65536|x-56320,_=!0)}a&&(l[f]=d,_&&(l[f+1]=d),p<=127?u[d+0]=f:p<=2047?(u[d+0]=f,u[d+1]=f):p<=65535?(u[d+0]=f,u[d+1]=f,u[d+2]=f):(u[d+0]=f,u[d+1]=f,u[d+2]=f,u[d+3]=f)),p<=127?c[d++]=p:p<=2047?(c[d++]=192|(p&1984)>>>6,c[d++]=128|(p&63)>>>0):p<=65535?(c[d++]=224|(p&61440)>>>12,c[d++]=128|(p&4032)>>>6,c[d++]=128|(p&63)>>>0):(c[d++]=240|(p&1835008)>>>18,c[d++]=128|(p&258048)>>>12,c[d++]=128|(p&4032)>>>6,c[d++]=128|(p&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 d=t.charCodeAt(s+1);d>=56320&&d<=57343&&(u=(l-55296<<10)+65536|d-56320,c=!0)}u<=127?n+=1:u<=2047?n+=2:u<=65535?n+=3:n+=4,c&&s++}return n}createString(t){const n=t.omalloc(this.utf8Length);return t.HEAPU8.set(this.utf8Value,n),n}}const rd=class Lr{constructor(t){if(sn(this,"id",++Lr.LAST_ID),sn(this,"_onigBinding"),sn(this,"content"),sn(this,"utf16Length"),sn(this,"utf8Length"),sn(this,"utf16OffsetToUtf8"),sn(this,"utf8OffsetToUtf16"),sn(this,"ptr"),!dn)throw new Xp("Must invoke loadWasm first.");this._onigBinding=dn,this.content=t;const n=new nd(t);this.utf16Length=n.utf16Length,this.utf8Length=n.utf8Length,this.utf16OffsetToUtf8=n.utf16OffsetToUtf8,this.utf8OffsetToUtf16=n.utf8OffsetToUtf16,this.utf8Length<1e4&&!Lr._sharedPtrInUse?(Lr._sharedPtr||(Lr._sharedPtr=dn.omalloc(1e4)),Lr._sharedPtrInUse=!0,dn.HEAPU8.set(n.utf8Value,Lr._sharedPtr),this.ptr=Lr._sharedPtr):this.ptr=n.createString(dn)}convertUtf8OffsetToUtf16(t){return this.utf8OffsetToUtf16?t<0?0:t>this.utf8Length?this.utf16Length:this.utf8OffsetToUtf16[t]:t}convertUtf16OffsetToUtf8(t){return this.utf16OffsetToUtf8?t<0?0:t>this.utf16Length?this.utf8Length:this.utf16OffsetToUtf8[t]:t}dispose(){this.ptr===Lr._sharedPtr?Lr._sharedPtrInUse=!1:this._onigBinding.ofree(this.ptr)}};sn(rd,"LAST_ID",0);sn(rd,"_sharedPtr",0);sn(rd,"_sharedPtrInUse",!1);let ow=rd;class pO{constructor(t){if(sn(this,"_onigBinding"),sn(this,"_ptr"),!dn)throw new Xp("Must invoke loadWasm first.");const n=[],s=[];for(let c=0,d=t.length;c<d;c++){const f=new nd(t[c]);n[c]=f.createString(dn),s[c]=f.utf8Length}const a=dn.omalloc(4*t.length);dn.HEAPU32.set(n,a/4);const l=dn.omalloc(4*t.length);dn.HEAPU32.set(s,l/4);const u=dn.createOnigScanner(a,l,t.length);for(let c=0,d=t.length;c<d;c++)dn.ofree(n[c]);dn.ofree(l),dn.ofree(a),u===0&&mO(dn),this._onigBinding=dn,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 ow(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 d=u/4;const f=c[d++],m=c[d++],p=[];for(let _=0;_<m;_++){const x=t.convertUtf8OffsetToUtf16(c[d++]),w=t.convertUtf8OffsetToUtf16(c[d++]);p[_]={start:x,end:w,length:w-x}}return{index:f,captureIndices:p}}}function gO(e){return typeof e.instantiator=="function"}function xO(e){return typeof e.default=="function"}function _O(e){return typeof e.data<"u"}function yO(e){return typeof Response<"u"&&e instanceof Response}function vO(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 Jc;function Qp(e){if(Jc)return Jc;async function t(){dn=await dO(async n=>{let s=e;return s=await s,typeof s=="function"&&(s=await s(n)),typeof s=="function"&&(s=await s(n)),gO(s)?s=await s.instantiator(n):xO(s)?s=await s.default(n):(_O(s)&&(s=s.data),yO(s)?typeof WebAssembly.instantiateStreaming=="function"?s=await bO(s)(n):s=await SO(s)(n):vO(s)?s=await im(s)(n):s instanceof WebAssembly.Module?s=await im(s)(n):"default"in s&&s.default instanceof WebAssembly.Module&&(s=await im(s.default)(n))),"instance"in s&&(s=s.instance),"exports"in s&&(s=s.exports),s})}return Jc=t(),Jc}function im(e){return t=>WebAssembly.instantiate(e,t)}function bO(e){return t=>WebAssembly.instantiateStreaming(e,t)}function SO(e){return async t=>{const n=await e.arrayBuffer();return WebAssembly.instantiate(n,t)}}let lw;function wO(e){lw=e}function CO(){return lw}async function cw(e){return e&&await Qp(e),{createScanner(t){return new pO(t.map(n=>typeof n=="string"?n:n.source))},createString(t){return new ow(t)}}}const kO=Object.freeze(Object.defineProperty({__proto__:null,createOnigurumaEngine:cw,getDefaultWasmLoader:CO,loadWasm:Qp,setDefaultWasmLoader:wO},Symbol.toStringTag,{value:"Module"}));var uw=Vp({});aw(uw,kO);var Dt=class extends Error{constructor(e){super(e),this.name="ShikiError"}};function EO(e){return Jp(e)}function Jp(e){return Array.isArray(e)?jO(e):e instanceof RegExp?e:typeof e=="object"?NO(e):e}function jO(e){let t=[];for(let n=0,s=e.length;n<s;n++)t[n]=Jp(e[n]);return t}function NO(e){let t={};for(let n in e)t[n]=Jp(e[n]);return t}function dw(e,...t){return t.forEach(n=>{for(let s in n)e[s]=n[s]}),e}function hw(e){const t=~e.lastIndexOf("/")||~e.lastIndexOf("\\");return t===0?e:~t===e.length-1?hw(e.substring(0,e.length-1)):e.substr(~t+1)}var am=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,Zc=class{static hasCaptures(e){return e===null?!1:(am.lastIndex=0,am.test(e))}static replaceCaptures(e,t,n){return e.replace(am,(s,a,l,u)=>{let c=n[parseInt(a||l,10)];if(c){let d=t.substring(c.start,c.end);for(;d[0]===".";)d=d.substring(1);switch(u){case"downcase":return d.toLowerCase();case"upcase":return d.toUpperCase();default:return d}}else return s})}};function fw(e,t){return e<t?-1:e>t?1:0}function mw(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=fw(e[a],t[a]);if(l!==0)return l}return 0}return n-s}function Kb(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 pw(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var gw=class{constructor(e){me(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}},Su=class{constructor(e,t,n){me(this,"_cachedMatchRoot",new gw(e=>this._root.match(e)));this._colorMap=e,this._defaults=t,this._root=n}static createFromRawTheme(e,t){return this.createFromParsedTheme(LO(e),t)}static createFromParsedTheme(e,t){return RO(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=>TO(e.parent,a.parentScopes));return s?new xw(s.fontStyle,s.foreground,s.background):null}},om=class uu{constructor(t,n){this.parent=t,this.scopeName=n}static push(t,n){for(const s of n)t=new uu(t,s);return t}static from(...t){let n=null;for(let s=0;s<t.length;s++)n=new uu(n,t[s]);return n}push(t){return new uu(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 TO(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&&!AO(e.scopeName,s);){if(a)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function AO(e,t){return t===e||e.startsWith(t)&&e[t.length]==="."}var xw=class{constructor(e,t,n){this.fontStyle=e,this.foregroundId=t,this.backgroundId=n}};function LO(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 p=u.scope;p=p.replace(/^[,]+/,""),p=p.replace(/[,]+$/,""),c=p.split(",")}else Array.isArray(u.scope)?c=u.scope:c=[""];let d=-1;if(typeof u.settings.fontStyle=="string"){d=0;let p=u.settings.fontStyle.split(" ");for(let _=0,x=p.length;_<x;_++)switch(p[_]){case"italic":d=d|1;break;case"bold":d=d|2;break;case"underline":d=d|4;break;case"strikethrough":d=d|8;break}}let f=null;typeof u.settings.foreground=="string"&&Kb(u.settings.foreground)&&(f=u.settings.foreground);let m=null;typeof u.settings.background=="string"&&Kb(u.settings.background)&&(m=u.settings.background);for(let p=0,_=c.length;p<_;p++){let w=c[p].trim().split(" "),C=w[w.length-1],v=null;w.length>1&&(v=w.slice(0,w.length-1),v.reverse()),n[s++]=new DO(C,v,a,d,f,m)}}return n}var DO=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}},bn=(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))(bn||{});function RO(e,t){e.sort((d,f)=>{let m=fw(d.scope,f.scope);return m!==0||(m=mw(d.parentScopes,f.parentScopes),m!==0)?m:d.index-f.index});let n=0,s="#000000",a="#ffffff";for(;e.length>=1&&e[0].scope==="";){let d=e.shift();d.fontStyle!==-1&&(n=d.fontStyle),d.foreground!==null&&(s=d.foreground),d.background!==null&&(a=d.background)}let l=new OO(t),u=new xw(n,l.getId(s),l.getId(a)),c=new IO(new Fm(0,null,-1,0,0),[]);for(let d=0,f=e.length;d<f;d++){let m=e[d];c.insert(0,m.scope,m.parentScopes,m.fontStyle,l.getId(m.foreground),l.getId(m.background))}return new Su(l,u,c)}var OO=class{constructor(e){me(this,"_isFrozen");me(this,"_lastColorId");me(this,"_id2color");me(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)}},MO=Object.freeze([]),Fm=class _w{constructor(t,n,s,a,l){me(this,"scopeDepth");me(this,"parentScopes");me(this,"fontStyle");me(this,"foreground");me(this,"background");this.scopeDepth=t,this.parentScopes=n||MO,this.fontStyle=s,this.foreground=a,this.background=l}clone(){return new _w(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)}},IO=class Vm{constructor(t,n=[],s={}){me(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(Vm._cmpBySpecificity),n}insert(t,n,s,a,l,u){if(n===""){this._doInsertHere(t,s,a,l,u);return}let c=n.indexOf("."),d,f;c===-1?(d=n,f=""):(d=n.substring(0,c),f=n.substring(c+1));let m;this._children.hasOwnProperty(d)?m=this._children[d]:(m=new Vm(this._mainRule.clone(),Fm.cloneArr(this._rulesWithParentScopes)),this._children[d]=m),m.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 d=this._rulesWithParentScopes[u];if(mw(d.parentScopes,n)===0){d.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 Fm(t,n,s,a,l))}},Ba=class ar{static toBinaryStr(t){return t.toString(2).padStart(32,"0")}static print(t){const n=ar.getLanguageId(t),s=ar.getTokenType(t),a=ar.getFontStyle(t),l=ar.getForeground(t),u=ar.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 d=ar.getLanguageId(t),f=ar.getTokenType(t),m=ar.containsBalancedBrackets(t)?1:0,p=ar.getFontStyle(t),_=ar.getForeground(t),x=ar.getBackground(t);return n!==0&&(d=n),s!==8&&(f=s),a!==null&&(m=a?1:0),l!==-1&&(p=l),u!==0&&(_=u),c!==0&&(x=c),(d<<0|f<<8|m<<10|p<<11|_<<15|x<<24)>>>0}};function wu(e,t){const n=[],s=PO(e);let a=s.next();for(;a!==null;){let d=0;if(a.length===2&&a.charAt(1)===":"){switch(a.charAt(0)){case"R":d=1;break;case"L":d=-1;break;default:console.log(`Unknown priority ${a} in scope selector`)}a=s.next()}let f=u();if(n.push({matcher:f,priority:d}),a!==",")break;a=s.next()}return n;function l(){if(a==="-"){a=s.next();const d=l();return f=>!!d&&!d(f)}if(a==="("){a=s.next();const d=c();return a===")"&&(a=s.next()),d}if(Yb(a)){const d=[];do d.push(a),a=s.next();while(Yb(a));return f=>t(d,f)}return null}function u(){const d=[];let f=l();for(;f;)d.push(f),f=l();return m=>d.every(p=>p(m))}function c(){const d=[];let f=u();for(;f&&(d.push(f),a==="|"||a===",");){do a=s.next();while(a==="|"||a===",");f=u()}return m=>d.some(p=>p(m))}}function Yb(e){return!!e&&!!e.match(/[\w\.:]+/)}function PO(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 yw(e){typeof e.dispose=="function"&&e.dispose()}var ul=class{constructor(e){this.scopeName=e}toKey(){return this.scopeName}},BO=class{constructor(e,t){this.scopeName=e,this.ruleName=t}toKey(){return`${this.scopeName}#${this.ruleName}`}},zO=class{constructor(){me(this,"_references",[]);me(this,"_seenReferenceKeys",new Set);me(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))}},$O=class{constructor(e,t){me(this,"seenFullScopeRequests",new Set);me(this,"seenPartialScopeRequests",new Set);me(this,"Q");this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new ul(this.initialScopeName)]}processQueue(){const e=this.Q;this.Q=[];const t=new zO;for(const n of e)HO(n,this.initialScopeName,this.repo,t);for(const n of t.references)if(n instanceof ul){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 HO(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 ul?du({baseGrammar:l,selfGrammar:a},s):Gm(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 ul(c))}function Gm(e,t,n){if(t.repository&&t.repository[e]){const s=t.repository[e];Cu([s],t,n)}}function du(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&Cu(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&Cu(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function Cu(e,t,n){for(const s of e){if(n.visitedRule.has(s))continue;n.visitedRule.add(s);const a=s.repository?dw({},t.repository,s.repository):t.repository;Array.isArray(s.patterns)&&Cu(s.patterns,{...t,repository:a},n);const l=s.include;if(!l)continue;const u=vw(l);switch(u.kind){case 0:du({...t,selfGrammar:t.baseGrammar},n);break;case 1:du(t,n);break;case 2:Gm(u.ruleName,{...t,repository:a},n);break;case 3:case 4:const c=u.scopeName===t.selfGrammar.scopeName?t.selfGrammar:u.scopeName===t.baseGrammar.scopeName?t.baseGrammar:void 0;if(c){const d={baseGrammar:t.baseGrammar,selfGrammar:c,repository:a};u.kind===4?Gm(u.ruleName,d,n):du(d,n)}else u.kind===4?n.add(new BO(u.scopeName,u.ruleName)):n.add(new ul(u.scopeName));break}}}var UO=class{constructor(){me(this,"kind",0)}},FO=class{constructor(){me(this,"kind",1)}},VO=class{constructor(e){me(this,"kind",2);this.ruleName=e}},GO=class{constructor(e){me(this,"kind",3);this.scopeName=e}},WO=class{constructor(e,t){me(this,"kind",4);this.scopeName=e,this.ruleName=t}};function vw(e){if(e==="$base")return new UO;if(e==="$self")return new FO;const t=e.indexOf("#");if(t===-1)return new GO(e);if(t===0)return new VO(e.substring(1));{const n=e.substring(0,t),s=e.substring(t+1);return new WO(n,s)}}var qO=/\\(\d+)/,Xb=/\\(\d+)/g,KO=-1,bw=-2;var kl=class{constructor(e,t,n,s){me(this,"$location");me(this,"id");me(this,"_nameIsCapturing");me(this,"_name");me(this,"_contentNameIsCapturing");me(this,"_contentName");this.$location=e,this.id=t,this._name=n||null,this._nameIsCapturing=Zc.hasCaptures(this._name),this._contentName=s||null,this._contentNameIsCapturing=Zc.hasCaptures(this._contentName)}get debugName(){const e=this.$location?`${hw(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:Zc.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:Zc.replaceCaptures(this._contentName,e,t)}},YO=class extends kl{constructor(t,n,s,a,l){super(t,n,s,a);me(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!")}},XO=class extends kl{constructor(t,n,s,a,l){super(t,n,s,null);me(this,"_match");me(this,"captures");me(this,"_cachedCompiledPatterns");this._match=new dl(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 hl,this.collectPatterns(t,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Qb=class extends kl{constructor(t,n,s,a,l){super(t,n,s,a);me(this,"hasMissingPatterns");me(this,"patterns");me(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 hl,this.collectPatterns(t,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Wm=class extends kl{constructor(t,n,s,a,l,u,c,d,f,m){super(t,n,s,a);me(this,"_begin");me(this,"beginCaptures");me(this,"_end");me(this,"endHasBackReferences");me(this,"endCaptures");me(this,"applyEndPatternLast");me(this,"hasMissingPatterns");me(this,"patterns");me(this,"_cachedCompiledPatterns");this._begin=new dl(l,this.id),this.beginCaptures=u,this._end=new dl(c||"￿",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=d,this.applyEndPatternLast=f||!1,this.patterns=m.patterns,this.hasMissingPatterns=m.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(t,n){return this._end.resolveBackReferences(t,n)}collectPatterns(t,n){n.push(this._begin)}compile(t,n){return this._getCachedCompiledPatterns(t,n).compile(t)}compileAG(t,n,s,a){return this._getCachedCompiledPatterns(t,n).compileAG(t,s,a)}_getCachedCompiledPatterns(t,n){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new hl;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}},ku=class extends kl{constructor(t,n,s,a,l,u,c,d,f){super(t,n,s,a);me(this,"_begin");me(this,"beginCaptures");me(this,"whileCaptures");me(this,"_while");me(this,"whileHasBackReferences");me(this,"hasMissingPatterns");me(this,"patterns");me(this,"_cachedCompiledPatterns");me(this,"_cachedCompiledWhilePatterns");this._begin=new dl(l,this.id),this.beginCaptures=u,this.whileCaptures=d,this._while=new dl(c,bw),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 hl;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 hl,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,n||"￿"),this._cachedCompiledWhilePatterns}},Sw=class vn{static createCaptureRule(t,n,s,a,l){return t.registerRule(u=>new YO(n,u,s,a,l))}static getCompiledRuleId(t,n,s){return t.id||n.registerRule(a=>{if(t.id=a,t.match)return new XO(t.$vscodeTextmateLocation,t.id,t.name,t.match,vn._compileCaptures(t.captures,n,s));if(typeof t.begin>"u"){t.repository&&(s=dw({},s,t.repository));let l=t.patterns;return typeof l>"u"&&t.include&&(l=[{include:t.include}]),new Qb(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,vn._compilePatterns(l,n,s))}return t.while?new ku(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,vn._compileCaptures(t.beginCaptures||t.captures,n,s),t.while,vn._compileCaptures(t.whileCaptures||t.captures,n,s),vn._compilePatterns(t.patterns,n,s)):new Wm(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,vn._compileCaptures(t.beginCaptures||t.captures,n,s),t.end,vn._compileCaptures(t.endCaptures||t.captures,n,s),t.applyEndPatternLast,vn._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 d=0;t[u].patterns&&(d=vn.getCompiledRuleId(t[u],n,s)),a[c]=vn.createCaptureRule(n,t[u].$vscodeTextmateLocation,t[u].name,t[u].contentName,d)}}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 d=-1;if(c.include){const f=vw(c.include);switch(f.kind){case 0:case 1:d=vn.getCompiledRuleId(s[c.include],n,s);break;case 2:let m=s[f.ruleName];m&&(d=vn.getCompiledRuleId(m,n,s));break;case 3:case 4:const p=f.scopeName,_=f.kind===4?f.ruleName:null,x=n.getExternalGrammar(p,s);if(x)if(_){let w=x.repository[_];w&&(d=vn.getCompiledRuleId(w,n,x.repository))}else d=vn.getCompiledRuleId(x.repository.$self,n,x.repository);break}}else d=vn.getCompiledRuleId(c,n,s);if(d!==-1){const f=n.getRule(d);let m=!1;if((f instanceof Qb||f instanceof Wm||f instanceof ku)&&f.hasMissingPatterns&&f.patterns.length===0&&(m=!0),m)continue;a.push(d)}}return{patterns:a,hasMissingPatterns:(t?t.length:0)!==a.length}}},dl=class ww{constructor(t,n){me(this,"source");me(this,"ruleId");me(this,"hasAnchor");me(this,"hasBackReferences");me(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=qO.test(this.source):this.hasBackReferences=!1}clone(){return new ww(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 Xb.lastIndex=0,this.source.replace(Xb,(a,l)=>pw(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,d;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&&(d=this.source.charAt(l+1),d==="A"?(t[l+1]="￿",n[l+1]="￿",s[l+1]="A",a[l+1]="A"):d==="G"?(t[l+1]="￿",n[l+1]="G",s[l+1]="￿",a[l+1]="G"):(t[l+1]=d,n[l+1]=d,s[l+1]=d,a[l+1]=d),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}},hl=class{constructor(){me(this,"_items");me(this,"_hasAnchors");me(this,"_cached");me(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 Jb(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 Jb(e,s,this._items.map(a=>a.ruleId))}},Jb=class{constructor(e,t,n){me(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(`
125
+ `)}findNextMatchSync(e,t,n){const s=this.scanner.findNextMatchSync(e,t,n);return s?{ruleId:this.rules[s.index],captureIndices:s.captureIndices}:null}},lm=class{constructor(e,t){this.languageId=e,this.tokenType=t}},cs,QO=(cs=class{constructor(t,n){me(this,"_defaultAttributes");me(this,"_embeddedLanguagesMatcher");me(this,"_getBasicScopeAttributes",new gw(t=>{const n=this._scopeToLanguage(t),s=this._toStandardTokenType(t);return new lm(n,s)}));this._defaultAttributes=new lm(t,8),this._embeddedLanguagesMatcher=new JO(Object.entries(n||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(t){return t===null?cs._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(t)}_scopeToLanguage(t){return this._embeddedLanguagesMatcher.match(t)||0}_toStandardTokenType(t){const n=t.match(cs.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!")}},me(cs,"_NULL_SCOPE_METADATA",new lm(0,0)),me(cs,"STANDARD_TOKEN_TYPE_REGEXP",/\b(comment|string|regex|meta\.embedded)\b/),cs),JO=class{constructor(e){me(this,"values");me(this,"scopesRegExp");if(e.length===0)this.values=null,this.scopesRegExp=null;else{this.values=new Map(e);const t=e.map(([n,s])=>pw(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])}},Zb=class{constructor(e,t){this.stack=e,this.stoppedEarly=t}};function Cw(e,t,n,s,a,l,u,c){const d=t.content.length;let f=!1,m=-1;if(u){const x=ZO(e,t,n,s,a,l);a=x.stack,s=x.linePos,n=x.isFirstLine,m=x.anchorPosition}const p=Date.now();for(;!f;){if(c!==0&&Date.now()-p>c)return new Zb(a,!0);_()}return new Zb(a,!1);function _(){const x=e4(e,t,n,s,a,m);if(!x){l.produce(a,d),f=!0;return}const w=x.captureIndices,C=x.matchedRuleId,v=w&&w.length>0?w[0].end>s:!1;if(C===KO){const S=a.getRule(e);l.produce(a,w[0].start),a=a.withContentNameScopesList(a.nameScopesList),el(e,t,n,a,l,S.endCaptures,w),l.produce(a,w[0].end);const b=a;if(a=a.parent,m=b.getAnchorPos(),!v&&b.getEnterPos()===s){a=b,l.produce(a,d),f=!0;return}}else{const S=e.getRule(C);l.produce(a,w[0].start);const b=a,y=S.getName(t.content,w),E=a.contentNameScopesList.pushAttributed(y,e);if(a=a.push(C,s,m,w[0].end===d,null,E,E),S instanceof Wm){const N=S;el(e,t,n,a,l,N.beginCaptures,w),l.produce(a,w[0].end),m=w[0].end;const T=N.getContentName(t.content,w),L=E.pushAttributed(T,e);if(a=a.withContentNameScopesList(L),N.endHasBackReferences&&(a=a.withEndRule(N.getEndWithResolvedBackReferences(t.content,w))),!v&&b.hasSameRuleAs(a)){a=a.pop(),l.produce(a,d),f=!0;return}}else if(S instanceof ku){const N=S;el(e,t,n,a,l,N.beginCaptures,w),l.produce(a,w[0].end),m=w[0].end;const T=N.getContentName(t.content,w),L=E.pushAttributed(T,e);if(a=a.withContentNameScopesList(L),N.whileHasBackReferences&&(a=a.withEndRule(N.getWhileWithResolvedBackReferences(t.content,w))),!v&&b.hasSameRuleAs(a)){a=a.pop(),l.produce(a,d),f=!0;return}}else if(el(e,t,n,a,l,S.captures,w),l.produce(a,w[0].end),a=a.pop(),!v){a=a.safePop(),l.produce(a,d),f=!0;return}}w[0].end>s&&(s=w[0].end,n=!1)}}function ZO(e,t,n,s,a,l){let u=a.beginRuleCapturedEOL?0:-1;const c=[];for(let d=a;d;d=d.pop()){const f=d.getRule(e);f instanceof ku&&c.push({rule:f,stack:d})}for(let d=c.pop();d;d=c.pop()){const{ruleScanner:f,findOptions:m}=r4(d.rule,e,d.stack.endRule,n,s===u),p=f.findNextMatchSync(t,s,m);if(p){if(p.ruleId!==bw){a=d.stack.pop();break}p.captureIndices&&p.captureIndices.length&&(l.produce(d.stack,p.captureIndices[0].start),el(e,t,n,d.stack,l,d.rule.whileCaptures,p.captureIndices),l.produce(d.stack,p.captureIndices[0].end),u=p.captureIndices[0].end,p.captureIndices[0].end>s&&(s=p.captureIndices[0].end,n=!1))}else{a=d.stack.pop();break}}return{stack:a,linePos:s,anchorPosition:u,isFirstLine:n}}function e4(e,t,n,s,a,l){const u=t4(e,t,n,s,a,l),c=e.getInjections();if(c.length===0)return u;const d=n4(c,e,t,n,s,a,l);if(!d)return u;if(!u)return d;const f=u.captureIndices[0].start,m=d.captureIndices[0].start;return m<f||d.priorityMatch&&m===f?d:u}function t4(e,t,n,s,a,l){const u=a.getRule(e),{ruleScanner:c,findOptions:d}=kw(u,e,a.endRule,n,s===l),f=c.findNextMatchSync(t,s,d);return f?{captureIndices:f.captureIndices,matchedRuleId:f.ruleId}:null}function n4(e,t,n,s,a,l,u){let c=Number.MAX_VALUE,d=null,f,m=0;const p=l.contentNameScopesList.getScopeNames();for(let _=0,x=e.length;_<x;_++){const w=e[_];if(!w.matcher(p))continue;const C=t.getRule(w.ruleId),{ruleScanner:v,findOptions:S}=kw(C,t,null,s,a===u),b=v.findNextMatchSync(n,a,S);if(!b)continue;const y=b.captureIndices[0].start;if(!(y>=c)&&(c=y,d=b.captureIndices,f=b.ruleId,m=w.priority,c===a))break}return d?{priorityMatch:m===-1,captureIndices:d,matchedRuleId:f}:null}function kw(e,t,n,s,a){return{ruleScanner:e.compileAG(t,n,s,a),findOptions:0}}function r4(e,t,n,s,a){return{ruleScanner:e.compileWhileAG(t,n,s,a),findOptions:0}}function el(e,t,n,s,a,l,u){if(l.length===0)return;const c=t.content,d=Math.min(l.length,u.length),f=[],m=u[0].end;for(let p=0;p<d;p++){const _=l[p];if(_===null)continue;const x=u[p];if(x.length===0)continue;if(x.start>m)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 C=_.getName(c,u),v=s.contentNameScopesList.pushAttributed(C,e),S=_.getContentName(c,u),b=v.pushAttributed(S,e),y=s.push(_.retokenizeCapturedWithRuleId,x.start,-1,!1,null,v,b),E=e.createOnigString(c.substring(0,x.end));Cw(e,E,n&&x.start===0,x.start,y,a,!1,0),yw(E);continue}const w=_.getName(c,u);if(w!==null){const v=(f.length>0?f[f.length-1].scopes:s.contentNameScopesList).pushAttributed(w,e);f.push(new s4(v,x.end))}}for(;f.length>0;)a.produceFromScopes(f[f.length-1].scopes,f[f.length-1].endPos),f.pop()}var s4=class{constructor(e,t){me(this,"scopes");me(this,"endPos");this.scopes=e,this.endPos=t}};function i4(e,t,n,s,a,l,u,c){return new o4(e,t,n,s,a,l,u,c)}function e0(e,t,n,s,a){const l=wu(t,Eu),u=Sw.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 Eu(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(a4(t[a],s))return n=a+1,!0;return!1})}function a4(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 o4=class{constructor(e,t,n,s,a,l,u,c){me(this,"_rootId");me(this,"_lastRuleId");me(this,"_ruleId2desc");me(this,"_includedGrammars");me(this,"_grammarRepository");me(this,"_grammar");me(this,"_injections");me(this,"_basicScopeAttributesProvider");me(this,"_tokenTypeMatchers");if(this._rootScopeName=e,this.balancedBracketSelectors=l,this._onigLib=c,this._basicScopeAttributesProvider=new QO(n,s),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=u,this._grammar=t0(t,null),this._injections=null,this._tokenTypeMatchers=[],a)for(const d of Object.keys(a)){const f=wu(d,Eu);for(const m of f)this._tokenTypeMatchers.push({matcher:m.matcher,type:a[d]})}}get themeProvider(){return this._grammarRepository}dispose(){for(const e of this._ruleId2desc)e&&e.dispose()}createOnigScanner(e){return this._onigLib.createOnigScanner(e)}createOnigString(e){return this._onigLib.createOnigString(e)}getMetadataForScope(e){return this._basicScopeAttributesProvider.getBasicScopeAttributes(e)}_collectInjections(){const e={lookup:a=>a===this._rootScopeName?this._grammar:this.getExternalGrammar(a),injections:a=>this._grammarRepository.injections(a)},t=[],n=this._rootScopeName,s=e.lookup(n);if(s){const a=s.injections;if(a)for(let u in a)e0(t,u,a[u],this,s);const l=this._grammarRepository.injections(n);l&&l.forEach(u=>{const c=this.getExternalGrammar(u);if(c){const d=c.injectionSelector;d&&e0(t,d,c,this,c)}})}return t.sort((a,l)=>a.priority-l.priority),t}getInjections(){return this._injections===null&&(this._injections=this._collectInjections()),this._injections}registerRule(e){const t=++this._lastRuleId,n=e(t);return this._ruleId2desc[t]=n,n}getRule(e){return this._ruleId2desc[e]}getExternalGrammar(e,t){if(this._includedGrammars[e])return this._includedGrammars[e];if(this._grammarRepository){const n=this._grammarRepository.lookup(e);if(n)return this._includedGrammars[e]=t0(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=Sw.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let a;if(!t||t===qm.NULL){a=!0;const f=this._basicScopeAttributesProvider.getDefaultAttributes(),m=this.themeProvider.getDefaults(),p=Ba.set(0,f.languageId,f.tokenType,null,m.fontStyle,m.foregroundId,m.backgroundId),_=this.getRule(this._rootId).getName(null,null);let x;_?x=il.createRootAndLookUpScopeName(_,p,this):x=il.createRoot("unknown",p),t=new qm(null,this._rootId,-1,-1,!1,null,x,x)}else a=!1,t.reset();e=e+`
126
+ `;const l=this.createOnigString(e),u=l.content.length,c=new c4(n,e,this._tokenTypeMatchers,this.balancedBracketSelectors),d=Cw(this,l,a,0,t,c,!0,s);return yw(l),{lineLength:u,lineTokens:c,ruleStack:d.stack,stoppedEarly:d.stoppedEarly}}};function t0(e,t){return e=EO(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 il=class Dr{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=om.push(a,l.scopeNames),s=new Dr(s,a,l.encodedTokenAttributes);return s}static createRoot(t,n){return new Dr(null,new om(null,t),n)}static createRootAndLookUpScopeName(t,n,s){const a=s.getMetadataForScope(t),l=new om(null,t),u=s.themeProvider.themeMatch(l),c=Dr.mergeAttributes(n,a,u);return new Dr(null,l,c)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(t){return Dr.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 Dr._pushAttributed(this,t,n);const s=t.split(/ /g);let a=this;for(const l of s)a=Dr._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=Dr.mergeAttributes(t.tokenAttributes,a,u);return new Dr(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}},lr,qm=(lr=class{constructor(t,n,s,a,l,u,c,d){me(this,"_stackElementBrand");me(this,"_enterPos");me(this,"_anchorPos");me(this,"depth");this.parent=t,this.ruleId=n,this.beginRuleCapturedEOL=l,this.endRule=u,this.nameScopesList=c,this.contentNameScopesList=d,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=s,this._anchorPos=a}equals(t){return t===null?!1:lr._equals(this,t)}static _equals(t,n){return t===n?!0:this._structuralEquals(t,n)?il.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(){lr._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(t,n,s,a,l,u,c){return new lr(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 lr(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=il.fromExtension((t==null?void 0:t.nameScopesList)??null,n.nameScopesList);return new lr(t,n.ruleId,n.enterPos??-1,n.anchorPos??-1,n.beginRuleCapturedEOL,n.endRule,s,il.fromExtension(s,n.contentNameScopesList))}},me(lr,"NULL",new lr(null,0,0,0,!1,null,null,null)),lr),l4=class{constructor(e,t){me(this,"balancedBracketScopes");me(this,"unbalancedBracketScopes");me(this,"allowAny",!1);this.balancedBracketScopes=e.flatMap(n=>n==="*"?(this.allowAny=!0,[]):wu(n,Eu).map(s=>s.matcher)),this.unbalancedBracketScopes=t.flatMap(n=>wu(n,Eu).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}},c4=class{constructor(e,t,n,s){me(this,"_emitBinaryTokens");me(this,"_lineText");me(this,"_tokens");me(this,"_binaryTokens");me(this,"_lastTokenEndIndex");me(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}},u4=class{constructor(e,t){me(this,"_grammars",new Map);me(this,"_rawGrammars",new Map);me(this,"_injectionGrammars",new Map);me(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,i4(e,l,t,n,s,a,this,this._onigLib))}return this._grammars.get(e)}},d4=class{constructor(t){me(this,"_options");me(this,"_syncRegistry");me(this,"_ensureGrammarCache");this._options=t,this._syncRegistry=new u4(Su.createFromRawTheme(t.theme,t.colorMap),t.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(t,n){this._syncRegistry.setTheme(Su.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 l4(s.balancedBracketSelectors||[],s.unbalancedBracketSelectors||[]))}loadGrammar(t){return this._loadGrammar(t,0,null,null,null)}_loadGrammar(t,n,s,a,l){const u=new $O(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)}},Km=qm.NULL;function ju(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 Gs(e,t){return e&&((t==null?void 0:t[e==null?void 0:e.toLowerCase()])||e)}function h4(e){return Array.isArray(e)?e:[e]}async function Ew(e){return Promise.resolve(typeof e=="function"?e():e).then(t=>t.default||t)}function sd(e){return!e||["plaintext","txt","text","plain"].includes(e)}function jw(e){return e==="ansi"||sd(e)}function id(e){return e==="none"}function Nw(e){return id(e)}const f4=/(\r?\n)/g;function ad(e,t=!1){var l;if(e.length===0)return[["",0]];const n=e.split(f4);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 n0={light:"#333333",dark:"#bbbbbb"},r0={light:"#fffffe",dark:"#1e1e1e"},s0="__shiki_resolved";function Zp(e){var c,d,f,m,p;if(e!=null&&e[s0])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),(d=_==null?void 0:_.settings)!=null&&d.background&&(n=_.settings.background),!s&&((f=t==null?void 0:t.colors)!=null&&f["editor.foreground"])&&(s=t.colors["editor.foreground"]),!n&&((m=t==null?void 0:t.colors)!=null&&m["editor.background"])&&(n=t.colors["editor.background"]),s||(s=t.type==="light"?n0.light:n0.dark),n||(n=t.type==="light"?r0.light:r0.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 v,S;const x=((v=_.settings)==null?void 0:v.foreground)&&!_.settings.foreground.startsWith("#"),w=((S=_.settings)==null?void 0:S.background)&&!_.settings.background.startsWith("#");if(!x&&!w)return _;const C={..._,settings:{..._.settings}};if(x){const b=u(_.settings.foreground);t.colorReplacements[b]=_.settings.foreground,C.settings.foreground=b}if(w){const b=u(_.settings.background);t.colorReplacements[b]=_.settings.background,C.settings.background=b}return C});for(const _ of Object.keys(t.colors||{}))if((_==="editor.foreground"||_==="editor.background"||_.startsWith("terminal.ansi"))&&!((p=t.colors[_])!=null&&p.startsWith("#"))){const x=u(t.colors[_]);t.colorReplacements[x]=t.colors[_],t.colors[_]=x}return Object.defineProperty(t,s0,{enumerable:!1,writable:!1,value:!0}),t}async function Tw(e){return[...new Set((await Promise.all(e.filter(t=>!jw(t)).map(async t=>await Ew(t).then(n=>Array.isArray(n)?n:[n])))).flat())]}async function Aw(e){return(await Promise.all(e.map(async t=>Nw(t)?null:Zp(await Ew(t))))).filter(t=>!!t)}function Lw(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 Dt(`Circular alias \`${[...n].join(" -> ")} -> ${e}\``);n.add(e)}}return e}var m4=class extends d4{constructor(t,n,s,a={}){super(t);me(this,"_resolver");me(this,"_themes");me(this,"_langs");me(this,"_alias");me(this,"_resolvedThemes",new Map);me(this,"_resolvedGrammars",new Map);me(this,"_langMap",new Map);me(this,"_langGraph",new Map);me(this,"_textmateThemeCache",new WeakMap);me(this,"_loadedThemesCache",null);me(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=Zp(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=Su.createFromRawTheme(t),this._textmateThemeCache.set(t,n)),this._syncRegistry.setTheme(n)}getGrammar(t){return t=Lw(t,this._alias),this._resolvedGrammars.get(t)}loadLanguage(t){var l,u,c,d;if(this.getGrammar(t.name))return;const n=new Set([...this._langMap.values()].filter(f=>{var m;return(m=f.embeddedLangsLazy)==null?void 0:m.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),(d=(c=this._syncRegistry)==null?void 0:c._grammars)==null||d.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(d=>s.map(([f])=>f).includes(d)):!1}).filter(l=>!s.includes(l));throw new Dt(`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))}},p4=class{constructor(e,t){me(this,"_langs",new Map);me(this,"_scopeToLang",new Map);me(this,"_injections",new Map);me(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 g4(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 Dt("`engine` option is required for synchronous mode");const n=(e.langs||[]).flat(1),s=(e.themes||[]).flat(1).map(Zp),a=new m4(new p4(e.engine,n),s,n,e.langAlias);let l;function u(b){return Lw(b,e.langAlias)}function c(b){v();const y=a.getGrammar(typeof b=="string"?b:b.name);if(!y)throw new Dt(`Language \`${b}\` not found, you may need to load it first`);return y}function d(b){if(b==="none")return{bg:"",fg:"",name:"none",settings:[],type:"dark"};v();const y=a.getTheme(b);if(!y)throw new Dt(`Theme \`${b}\` not found, you may need to load it first`);return y}function f(b){v();const y=d(b);return l!==b&&(a.setTheme(y),l=b),{theme:y,colorMap:a.getColorMap()}}function m(){return v(),a.getLoadedThemes()}function p(){return v(),a.getLoadedLanguages()}function _(...b){v(),a.loadLanguages(b.flat(1))}async function x(...b){return _(await Tw(b))}function w(...b){v();for(const y of b.flat(1))a.loadTheme(y)}async function C(...b){return v(),w(await Aw(b))}function v(){if(t)throw new Dt("Shiki instance has been disposed")}function S(){t||(t=!0,a.dispose(),qo-=1)}return{setTheme:f,getTheme:d,getLanguage:c,getLoadedThemes:m,getLoadedLanguages:p,resolveLangAlias:u,loadLanguage:x,loadLanguageSync:_,loadTheme:C,loadThemeSync:w,dispose:S,[Symbol.dispose]:S}}async function x4(e){e.engine||console.warn("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");const[t,n,s]=await Promise.all([Aw(e.themes||[]),Tw(e.langs||[]),e.engine]);return g4({...e,themes:t,langs:n,engine:s})}const Dw=new WeakMap;function od(e,t){Dw.set(e,t)}function fl(e){return Dw.get(e)}var ld=class Rw{constructor(...t){me(this,"_stacks",{});me(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 Rw(Object.fromEntries(h4(n).map(s=>[s,Km])),t)}getInternalStack(t=this.theme){return this._stacks[t]}getScopes(t=this.theme){return _4(this._stacks[t])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function _4(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 y4(e,t){if(!(e instanceof ld))throw new Dt("Invalid grammar state");return e.getInternalStack(t)}const v4=/,/,b4=/ /;function Ow(e,t,n={}){const{theme:s=e.getLoadedThemes()[0]}=n;if(sd(e.resolveLangAlias(n.lang||"text"))||id(s))return ad(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 Dt(`Grammar state language "${n.grammarState.lang}" does not match highlight language "${u.name}"`);if(!n.grammarState.themes.includes(a.name))throw new Dt(`Grammar state themes "${n.grammarState.themes}" do not contain highlight theme "${a.name}"`)}return w4(t,u,a,l,n)}function S4(...e){if(e.length===2)return fl(e[1]);const[t,n,s={}]=e,{lang:a="text",theme:l=t.getLoadedThemes()[0]}=s;if(sd(a)||id(l))throw new Dt("Plain language does not have grammar state");if(a==="ansi")throw new Dt("ANSI language does not have grammar state");const{theme:u,colorMap:c}=t.setTheme(l),d=t.getLanguage(a);return new ld(eg(n,d,u,c,s).stateStack,d.name,u.name)}function w4(e,t,n,s,a){const l=eg(e,t,n,s,a),u=new ld(l.stateStack,t.name,n.name);return od(l.tokens,u),l.tokens}function eg(e,t,n,s,a){const l=ju(n,a),{tokenizeMaxLineLength:u=0,tokenizeTimeLimit:c=500}=a,d=ad(e);let f=a.grammarState?y4(a.grammarState,n.name)??Km:a.grammarContextCode!=null?eg(a.grammarContextCode,t,n,s,{...a,grammarState:void 0,grammarContextCode:void 0}).stateStack:Km,m=[];const p=[];for(let _=0,x=d.length;_<x;_++){const[w,C]=d[_];if(w===""){m=[],p.push([]);continue}if(u>0&&w.length>=u){m=[],p.push([{content:w,offset:C,color:"",fontStyle:0}]);continue}let v,S,b;a.includeExplanation&&(v=t.tokenizeLine(w,f,c),S=v.tokens,b=0);const y=t.tokenizeLine2(w,f,c),E=y.tokens.length/2;for(let N=0;N<E;N++){const T=y.tokens[2*N],L=N+1<E?y.tokens[2*N+2]:w.length;if(T===L)continue;const A=y.tokens[2*N+1],R=Gs(s[Ba.getForeground(A)],l),M=Ba.getFontStyle(A),G={content:w.substring(T,L),offset:C+T,color:R,fontStyle:M};if(a.includeExplanation){const W=[];if(a.includeExplanation!=="scopeName")for(const U of n.settings){let V;switch(typeof U.scope){case"string":V=U.scope.split(v4).map(z=>z.trim());break;case"object":V=U.scope;break;default:continue}W.push({settings:U,selectors:V.map(z=>z.split(b4))})}G.explanation=[];let O=0;for(;T+O<L;){const U=S[b],V=w.substring(U.startIndex,U.endIndex);O+=V.length,G.explanation.push({content:V,scopes:a.includeExplanation==="scopeName"?C4(U.scopes):k4(W,U.scopes)}),b+=1}}m.push(G)}p.push(m),m=[],f=y.ruleStack}return{tokens:p,stateStack:f}}function C4(e){return e.map(t=>({scopeName:t}))}function k4(e,t){const n=[];for(let s=0,a=t.length;s<a;s++){const l=t[s];n[s]={scopeName:l,themeMatches:j4(e,l,t.slice(0,s))}}return n}function i0(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]==="."}function E4(e,t,n){if(!i0(e.at(-1),t))return!1;let s=e.length-2,a=n.length-1;for(;s>=0&&a>=0;)i0(e[s],n[a])&&(s-=1),a-=1;return s===-1}function j4(e,t,n){const s=[];for(const{selectors:a,settings:l}of e)for(const u of a)if(E4(u,t,n)){s.push(l);break}return s}function Mw(e,t,n,s=Ow){const a=Object.entries(n.themes).filter(f=>f[1]).map(f=>({color:f[0],theme:f[1]})),l=a.map(f=>{const m=s(e,t,{...n,theme:f.theme});return{tokens:m,state:fl(m),theme:typeof f.theme=="string"?f.theme:f.theme.name}}),u=N4(...l.map(f=>f.tokens)),c=u[0].map((f,m)=>f.map((p,_)=>{const x={content:p.content,variants:{},offset:p.offset};return"includeExplanation"in n&&n.includeExplanation&&(x.explanation=p.explanation),u.forEach((w,C)=>{const{content:v,explanation:S,offset:b,...y}=w[m][_];x.variants[a[C].color]=y}),x})),d=l[0].state?new ld(Object.fromEntries(l.map(f=>{var m;return[f.theme,(m=f.state)==null?void 0:m.getInternalStack(f.theme)]})),l[0].state.lang):void 0;return d&&od(c,d),c}function N4(...e){const t=e.map(()=>[]),n=e.length;for(let s=0;s<e[0].length;s++){const a=e.map(d=>d[s]),l=t.map(()=>[]);t.forEach((d,f)=>d.push(l[f]));const u=a.map(()=>0),c=a.map(d=>d[0]);for(;c.every(d=>d);){const d=Math.min(...c.map(f=>f.content.length));for(let f=0;f<n;f++){const m=c[f];m.content.length===d?(l[f].push(m),u[f]+=1,c[f]=a[f][u[f]]):(l[f].push({...m,content:m.content.slice(0,d)}),c[f]={...m,content:m.content.slice(d),offset:m.offset+d})}}}return t}const T4=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"];class El{constructor(t,n,s){this.normal=n,this.property=t,s&&(this.space=s)}}El.prototype.normal={};El.prototype.property={};El.prototype.space=void 0;function Iw(e,t){const n={},s={};for(const a of e)Object.assign(n,a.property),Object.assign(s,a.normal);return new El(n,s,t)}function Ym(e){return e.toLowerCase()}class Pn{constructor(t,n){this.attribute=n,this.property=t}}Pn.prototype.attribute="";Pn.prototype.booleanish=!1;Pn.prototype.boolean=!1;Pn.prototype.commaOrSpaceSeparated=!1;Pn.prototype.commaSeparated=!1;Pn.prototype.defined=!1;Pn.prototype.mustUseProperty=!1;Pn.prototype.number=!1;Pn.prototype.overloadedBoolean=!1;Pn.prototype.property="";Pn.prototype.spaceSeparated=!1;Pn.prototype.space=void 0;let A4=0;const Je=Ri(),Zt=Ri(),Xm=Ri(),Ee=Ri(),Lt=Ri(),Ma=Ri(),Wn=Ri();function Ri(){return 2**++A4}const Qm=Object.freeze(Object.defineProperty({__proto__:null,boolean:Je,booleanish:Zt,commaOrSpaceSeparated:Wn,commaSeparated:Ma,number:Ee,overloadedBoolean:Xm,spaceSeparated:Lt},Symbol.toStringTag,{value:"Module"})),cm=Object.keys(Qm);class tg extends Pn{constructor(t,n,s,a){let l=-1;if(super(t,n),a0(this,"space",a),typeof s=="number")for(;++l<cm.length;){const u=cm[l];a0(this,cm[l],(s&Qm[u])===Qm[u])}}}tg.prototype.defined=!0;function a0(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 tg(s,e.transform(e.attributes||{},s),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(s)&&(l.mustUseProperty=!0),t[s]=l,n[Ym(s)]=s,n[Ym(l.attribute)]=s}return new El(t,n,e.space)}const Pw=Va({properties:{ariaActiveDescendant:null,ariaAtomic:Zt,ariaAutoComplete:null,ariaBusy:Zt,ariaChecked:Zt,ariaColCount:Ee,ariaColIndex:Ee,ariaColSpan:Ee,ariaControls:Lt,ariaCurrent:null,ariaDescribedBy:Lt,ariaDetails:null,ariaDisabled:Zt,ariaDropEffect:Lt,ariaErrorMessage:null,ariaExpanded:Zt,ariaFlowTo:Lt,ariaGrabbed:Zt,ariaHasPopup:null,ariaHidden:Zt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Lt,ariaLevel:Ee,ariaLive:null,ariaModal:Zt,ariaMultiLine:Zt,ariaMultiSelectable:Zt,ariaOrientation:null,ariaOwns:Lt,ariaPlaceholder:null,ariaPosInSet:Ee,ariaPressed:Zt,ariaReadOnly:Zt,ariaRelevant:null,ariaRequired:Zt,ariaRoleDescription:Lt,ariaRowCount:Ee,ariaRowIndex:Ee,ariaRowSpan:Ee,ariaSelected:Zt,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 Bw(e,t){return t in e?e[t]:t}function zw(e,t){return Bw(e,t.toLowerCase())}const L4=Va({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Ma,acceptCharset:Lt,accessKey:Lt,action:null,allow:null,allowFullScreen:Je,allowPaymentRequest:Je,allowUserMedia:Je,alt:null,as:null,async:Je,autoCapitalize:null,autoComplete:Lt,autoFocus:Je,autoPlay:Je,blocking:Lt,capture:null,charSet:null,checked:Je,cite:null,className:Lt,cols:Ee,colSpan:null,content:null,contentEditable:Zt,controls:Je,controlsList:Lt,coords:Ee|Ma,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Je,defer:Je,dir:null,dirName:null,disabled:Je,download:Xm,draggable:Zt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Je,formTarget:null,headers:Lt,height:Ee,hidden:Xm,high:Ee,href:null,hrefLang:null,htmlFor:Lt,httpEquiv:Lt,id:null,imageSizes:null,imageSrcSet:null,inert:Je,inputMode:null,integrity:null,is:null,isMap:Je,itemId:null,itemProp:Lt,itemRef:Lt,itemScope:Je,itemType:Lt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Je,low:Ee,manifest:null,max:null,maxLength:Ee,media:null,method:null,min:null,minLength:Ee,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:Ee,pattern:null,ping:Lt,placeholder:null,playsInline:Je,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Je,referrerPolicy:null,rel:Lt,required:Je,reversed:Je,rows:Ee,rowSpan:Ee,sandbox:Lt,scope:null,scoped:Je,seamless:Je,selected:Je,shadowRootClonable:Je,shadowRootDelegatesFocus:Je,shadowRootMode:null,shape:null,size:Ee,sizes:null,slot:null,span:Ee,spellCheck:Zt,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:Je,useMap:null,value:Zt,width:Ee,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Lt,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:Je,declare:Je,event:null,face:null,frame:null,frameBorder:null,hSpace:Ee,leftMargin:Ee,link:null,longDesc:null,lowSrc:null,marginHeight:Ee,marginWidth:Ee,noResize:Je,noHref:Je,noShade:Je,noWrap:Je,object:null,profile:null,prompt:null,rev:null,rightMargin:Ee,rules:null,scheme:null,scrolling:Zt,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:Je,disableRemotePlayback:Je,prefix:null,property:null,results:Ee,security:null,unselectable:null},space:"html",transform:zw}),D4=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:Wn,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:Lt,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:Je,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:Wn,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:Lt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Ee,pointsAtY:Ee,pointsAtZ:Ee,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Wn,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Wn,rev:Wn,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Wn,requiredFeatures:Wn,requiredFonts:Wn,requiredFormats:Wn,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:Wn,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:Wn,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:Wn,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:Bw}),$w=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()}}),Hw=Va({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:zw}),Uw=Va({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),R4=/[A-Z]/g,o0=/-[a-z]/g,O4=/^data[-\w.:]+$/i;function M4(e,t){const n=Ym(t);let s=t,a=Pn;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&O4.test(t)){if(t.charAt(4)==="-"){const l=t.slice(5).replace(o0,P4);s="data"+l.charAt(0).toUpperCase()+l.slice(1)}else{const l=t.slice(4);if(!o0.test(l)){let u=l.replace(R4,I4);u.charAt(0)!=="-"&&(u="-"+u),t="data"+u}}a=tg}return new a(s,t)}function I4(e){return"-"+e.toLowerCase()}function P4(e){return e.charAt(1).toUpperCase()}const B4=Iw([Pw,L4,$w,Hw,Uw],"html"),Fw=Iw([Pw,D4,$w,Hw,Uw],"svg"),l0={}.hasOwnProperty;function z4(e,t){const n=t||{};function s(a,...l){let u=s.invalid;const c=s.handlers;if(a&&l0.call(a,e)){const d=String(a[e]);u=l0.call(c,d)?c[d]: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 $4=/["&'<>`]/g,H4=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,U4=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,F4=/[|\\{}()[\]^$+*?.]/g,c0=new WeakMap;function V4(e,t){if(e=e.replace(t.subset?G4(t.subset):$4,s),t.subset||t.escapeOnly)return e;return e.replace(H4,n).replace(U4,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 G4(e){let t=c0.get(e);return t||(t=W4(e),c0.set(e,t)),t}function W4(e){const t=[];let n=-1;for(;++n<e.length;)t.push(e[n].replace(F4,"\\$&"));return new RegExp("(?:"+t.join("|")+")","g")}const q4=/[\dA-Fa-f]/;function K4(e,t,n){const s="&#x"+e.toString(16).toUpperCase();return n&&t&&!q4.test(String.fromCharCode(t))?s:s+";"}const Y4=/\d/;function X4(e,t,n){const s="&#"+String(e);return n&&t&&!Y4.test(String.fromCharCode(t))?s:s+";"}const Q4=["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"],um={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:"€"},J4=["cent","copy","divide","gt","lt","not","para","times"],Vw={}.hasOwnProperty,Jm={};let eu;for(eu in um)Vw.call(um,eu)&&(Jm[um[eu]]=eu);const Z4=/[^\dA-Za-z]/;function eM(e,t,n,s){const a=String.fromCharCode(e);if(Vw.call(Jm,a)){const l=Jm[a],u="&"+l;return n&&Q4.includes(l)&&!J4.includes(l)&&(!s||t&&t!==61&&Z4.test(String.fromCharCode(t)))?u:u+";"}return""}function tM(e,t,n){let s=K4(e,t,n.omitOptionalSemicolons),a;if((n.useNamedReferences||n.useShortestReferences)&&(a=eM(e,t,n.omitOptionalSemicolons,n.attribute)),(n.useShortestReferences||!a)&&n.useShortestReferences){const l=X4(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 V4(e,Object.assign({format:tM},t))}const nM=/^>|^->|<!--|-->|--!>|<!-$/g,rM=[">"],sM=["<",">"];function iM(e,t,n,s){return s.settings.bogusComments?"<?"+Ia(e.value,Object.assign({},s.settings.characterReferences,{subset:rM}))+">":"<!--"+e.value.replace(nM,a)+"-->";function a(l){return Ia(l,Object.assign({},s.settings.characterReferences,{subset:sM}))}}function aM(e,t,n,s){return"<!"+(s.settings.upperDoctype?"DOCTYPE":"doctype")+(s.settings.tightDoctype?"":" ")+"html>"}function u0(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 oM(e,t){const n=t||{};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}function lM(e){return e.join(" ").trim()}const cM=/[ \t\n\f\r]/g;function ng(e){return typeof e=="object"?e.type==="text"?d0(e.value):!1:d0(e)}function d0(e){return e.replace(cM,"")===""}const ln=Ww(1),Gw=Ww(-1),uM=[];function Ww(e){return t;function t(n,s,a){const l=n?n.children:uM;let u=(s||0)+e,c=l[u];if(!a)for(;c&&ng(c);)u+=e,c=l[u];return c}}const dM={}.hasOwnProperty;function qw(e){return t;function t(n,s,a){return dM.call(e,n.tagName)&&e[n.tagName](n,s,a)}}const rg=qw({body:fM,caption:dm,colgroup:dm,dd:xM,dt:gM,head:dm,html:hM,li:pM,optgroup:_M,option:yM,p:mM,rp:h0,rt:h0,tbody:bM,td:f0,tfoot:SM,th:f0,thead:vM,tr:wM});function dm(e,t,n){const s=ln(n,t,!0);return!s||s.type!=="comment"&&!(s.type==="text"&&ng(s.value.charAt(0)))}function hM(e,t,n){const s=ln(n,t);return!s||s.type!=="comment"}function fM(e,t,n){const s=ln(n,t);return!s||s.type!=="comment"}function mM(e,t,n){const s=ln(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 pM(e,t,n){const s=ln(n,t);return!s||s.type==="element"&&s.tagName==="li"}function gM(e,t,n){const s=ln(n,t);return!!(s&&s.type==="element"&&(s.tagName==="dt"||s.tagName==="dd"))}function xM(e,t,n){const s=ln(n,t);return!s||s.type==="element"&&(s.tagName==="dt"||s.tagName==="dd")}function h0(e,t,n){const s=ln(n,t);return!s||s.type==="element"&&(s.tagName==="rp"||s.tagName==="rt")}function _M(e,t,n){const s=ln(n,t);return!s||s.type==="element"&&s.tagName==="optgroup"}function yM(e,t,n){const s=ln(n,t);return!s||s.type==="element"&&(s.tagName==="option"||s.tagName==="optgroup")}function vM(e,t,n){const s=ln(n,t);return!!(s&&s.type==="element"&&(s.tagName==="tbody"||s.tagName==="tfoot"))}function bM(e,t,n){const s=ln(n,t);return!s||s.type==="element"&&(s.tagName==="tbody"||s.tagName==="tfoot")}function SM(e,t,n){return!ln(n,t)}function wM(e,t,n){const s=ln(n,t);return!s||s.type==="element"&&s.tagName==="tr"}function f0(e,t,n){const s=ln(n,t);return!s||s.type==="element"&&(s.tagName==="td"||s.tagName==="th")}const CM=qw({body:jM,colgroup:NM,head:EM,html:kM,tbody:TM});function kM(e){const t=ln(e,-1);return!t||t.type!=="comment"}function EM(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 jM(e){const t=ln(e,-1,!0);return!t||t.type!=="comment"&&!(t.type==="text"&&ng(t.value.charAt(0)))&&!(t.type==="element"&&(t.tagName==="meta"||t.tagName==="link"||t.tagName==="script"||t.tagName==="style"||t.tagName==="template"))}function NM(e,t,n){const s=Gw(n,t),a=ln(e,-1,!0);return n&&s&&s.type==="element"&&s.tagName==="colgroup"&&rg(s,n.children.indexOf(s),n)?!1:!!(a&&a.type==="element"&&a.tagName==="col")}function TM(e,t,n){const s=Gw(n,t),a=ln(e,-1);return n&&s&&s.type==="element"&&(s.tagName==="thead"||s.tagName==="tbody")&&rg(s,n.children.indexOf(s),n)?!1:!!(a&&a.type==="element"&&a.tagName==="tr")}const tu={name:[[`
127
+ \f\r &/=>`.split(""),`
128
+ \f\r "&'/=>\``.split("")],[`\0
129
+ \f\r "&'/<=>`.split(""),`\0
130
+ \f\r "&'/<=>\``.split("")]],unquoted:[[`
131
+ \f\r &>`.split(""),`\0
132
+ \f\r "&'<=>\``.split("")],[`\0
133
+ \f\r "&'<=>\``.split(""),`\0
134
+ \f\r "&'<=>\``.split("")]],single:[["&'".split(""),"\"&'`".split("")],["\0&'".split(""),"\0\"&'`".split("")]],double:[['"&'.split(""),"\"&'`".split("")],['\0"&'.split(""),"\0\"&'`".split("")]]};function AM(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 d;a.space==="html"&&e.tagName==="svg"&&(s.schema=Fw);const f=LM(s,e.properties),m=s.all(a.space==="html"&&e.tagName==="template"?e.content:e);return s.schema=a,m&&(u=!1),(f||!l||!CM(e,t,n))&&(c.push("<",e.tagName,f?" "+f:""),u&&(a.space==="svg"||s.settings.closeSelfClosing)&&(d=f.charAt(f.length-1),(!s.settings.tightSelfClosing||d==="/"||d&&d!=='"'&&d!=="'")&&c.push(" "),c.push("/")),c.push(">")),c.push(m),!u&&(!l||!rg(e,t,n))&&c.push("</"+e.tagName+">"),c.join("")}function LM(e,t){const n=[];let s=-1,a;if(t){for(a in t)if(t[a]!==null&&t[a]!==void 0){const l=DM(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 DM(e,t,n){const s=M4(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 d=Ia(s.attribute,Object.assign({},e.settings.characterReferences,{subset:tu.name[a][l]}));return n===!0||(n=Array.isArray(n)?(s.commaSeparated?oM:lM)(n,{padLeft:!e.settings.tightCommaSeparatedLists}):String(n),e.settings.collapseEmptyAttributes&&!n)?d:(e.settings.preferUnquoted&&(c=Ia(n,Object.assign({},e.settings.characterReferences,{attribute:!0,subset:tu.unquoted[a][l]}))),c!==n&&(e.settings.quoteSmart&&u0(n,u)>u0(n,e.alternative)&&(u=e.alternative),c=u+Ia(n,Object.assign({},e.settings.characterReferences,{subset:(u==="'"?tu.single:tu.double)[a][l],attribute:!0}))+u),d+(c&&"="+c))}const RM=["<","&"];function Kw(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:RM}))}function OM(e,t,n,s){return s.settings.allowDangerousHtml?e.value:Kw(e,t,n,s)}function MM(e,t,n,s){return s.all(e)}const IM=z4("type",{invalid:PM,unknown:BM,handlers:{comment:iM,doctype:aM,element:AM,raw:OM,root:MM,text:Kw}});function PM(e){throw new Error("Expected node, not `"+e+"`")}function BM(e){const t=e;throw new Error("Cannot compile unknown node `"+t.type+"`")}const zM={},$M={},HM=[];function UM(e,t){const n=t||zM,s=n.quote||'"',a=s==='"'?"'":'"';if(s!=='"'&&s!=="'")throw new Error("Invalid quote `"+s+"`, expected `'` or `\"`");return{one:FM,all:VM,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||T4,characterReferences:n.characterReferences||$M,closeSelfClosing:n.closeSelfClosing||!1,closeEmptyElements:n.closeEmptyElements||!1},schema:n.space==="svg"?Fw:B4,quote:s,alternative:a}.one(Array.isArray(e)?{type:"root",children:e}:e,void 0,void 0)}function FM(e,t,n){return IM(e,t,n,this)}function VM(e){const t=[],n=e&&e.children||HM;let s=-1;for(;++s<n.length;)t[s]=this.one(n[s],s,e);return t.join("")}const m0=/\s+/g;function Yw(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(m0)),Array.isArray(e.properties.class)||(e.properties.class=[]);const n=Array.isArray(t)?t:t.split(m0);for(const a of n)a&&!e.properties.class.includes(a)&&e.properties.class.push(a);return e}const GM=/:?lang=["']([^"']+)["']/g,WM=/(?:```|~~~)([\w-]+)/g,qM=/\\begin\{([\w-]+)\}/g,KM=/<script\s+(?:type|lang)=["']([^"']+)["']/gi;function YM(e){const t=ad(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 XM(e,t,n){const s=new Set;for(const l of e.matchAll(GM)){const u=l[1].toLowerCase().trim();u&&s.add(u)}for(const l of e.matchAll(WM)){const u=l[1].toLowerCase().trim();u&&s.add(u)}for(const l of e.matchAll(qM)){const u=l[1].toLowerCase().trim();u&&s.add(u)}for(const l of e.matchAll(KM)){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 QM=["color","background-color"];function JM(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 ZM(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?JM(a,l):a})):e}function eI(e,t,n,s,a="css-vars"){const l={content:e.content,explanation:e.explanation,offset:e.offset},u=t.map(m=>Nu(e.variants[m])),c=new Set(u.flatMap(m=>Object.keys(m))),d={},f=(m,p)=>{const _=p==="color"?"":p==="background-color"?"-bg":`-${p}`;return n+t[m]+(p==="color"?"":_)};return u.forEach((m,p)=>{for(const _ of c){const x=m[_]||"inherit";if(p===0&&s&&QM.includes(_))if(s==="light-dark()"&&u.length>1){const w=t.findIndex(v=>v==="light"),C=t.findIndex(v=>v==="dark");if(w===-1||C===-1)throw new Dt('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');d[_]=`light-dark(${u[w][_]||"inherit"}, ${u[C][_]||"inherit"})`,a==="css-vars"&&(d[f(p,_)]=x)}else d[_]=x;else a==="css-vars"&&(d[f(p,_)]=x)}}),l.htmlStyle=d,l}function Nu(e){const t={};if(e.color&&(t.color=e.color),e.bgColor&&(t["background-color"]=e.bgColor),e.fontStyle){e.fontStyle&bn.Italic&&(t["font-style"]="italic"),e.fontStyle&bn.Bold&&(t["font-weight"]="bold");const n=[];e.fontStyle&bn.Underline&&n.push("underline"),e.fontStyle&bn.Strikethrough&&n.push("line-through"),n.length&&(t["text-decoration"]=n.join(" "))}return t}function Zm(e){return typeof e=="string"?e:Object.entries(e).map(([t,n])=>`${t}:${n}`).join(";")}function tI(){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 Dt(`Invalid decoration offset: ${c}. Code length: ${n.source.length}`);return{...a.indexToPos(c),offset:c}}else{const d=a.lines[c.line];if(d===void 0)throw new Dt(`Invalid decoration position ${JSON.stringify(c)}. Lines length: ${a.lines.length}`);let f=c.character;if(f<0&&(f=d.length+f),f<0||f>d.length)throw new Dt(`Invalid decoration position ${JSON.stringify(c)}. Line ${c.line} length: ${d.length}`);return{...c,character:f,offset:a.posToIndex(c.line,f)}}};var s=l;const a=YM(n.source),u=(n.options.decorations||[]).map(c=>({...c,start:l(c.start),end:l(c.end)}));nI(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 ZM(n,t(this).decorations.flatMap(a=>[a.start.offset,a.end.offset]))},code(n){var m;if(!((m=this.options.decorations)!=null&&m.length))return;const s=t(this),a=[...n.children].filter(p=>p.type==="element"&&p.tagName==="span");if(a.length!==s.converter.lines.length)throw new Dt(`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(p,_,x,w){const C=a[p];let v="",S=-1,b=-1;if(_===0&&(S=0),x===0&&(b=0),x===Number.POSITIVE_INFINITY&&(b=C.children.length),S===-1||b===-1)for(let E=0;E<C.children.length;E++)v+=Xw(C.children[E]),S===-1&&v.length===_&&(S=E+1),b===-1&&v.length===x&&(b=E+1);if(S===-1)throw new Dt(`Failed to find start index for decoration ${JSON.stringify(w.start)}`);if(b===-1)throw new Dt(`Failed to find end index for decoration ${JSON.stringify(w.end)}`);const y=C.children.slice(S,b);if(!w.alwaysWrap&&y.length===C.children.length)c(C,w,"line");else if(!w.alwaysWrap&&y.length===1&&y[0].type==="element")c(y[0],w,"token");else{const E={type:"element",tagName:"span",properties:{},children:y};c(E,w,"wrapper"),C.children.splice(S,y.length,E)}}function u(p,_){a[p]=c(a[p],_,"line")}function c(p,_,x){var v;const w=_.properties||{},C=_.transform||(S=>S);return p.tagName=_.tagName||"span",p.properties={...p.properties,...w,class:p.properties.class},(v=_.properties)!=null&&v.class&&Yw(p,_.properties.class),p=C(p,x)||p,p}const d=[],f=s.decorations.sort((p,_)=>_.start.offset-p.start.offset||p.end.offset-_.end.offset);for(const p of f){const{start:_,end:x}=p;if(_.line===x.line)l(_.line,_.character,x.character,p);else if(_.line<x.line){l(_.line,_.character,Number.POSITIVE_INFINITY,p);for(let w=_.line+1;w<x.line;w++)d.unshift(()=>u(w,p));l(x.line,0,x.character,p)}}d.forEach(p=>p())}}}function nI(e){for(let t=0;t<e.length;t++){const n=e[t];if(n.start.offset>n.end.offset)throw new Dt(`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,d=a.start.offset<n.end.offset&&n.end.offset<=a.end.offset;if(l||u||c||d){if(l&&u||c&&d||c&&n.start.offset===n.end.offset||u&&a.start.offset===a.end.offset)continue;throw new Dt(`Decorations ${JSON.stringify(n.start)} and ${JSON.stringify(a.start)} intersect.`)}}}}function Xw(e){return e.type==="text"?e.value:e.type==="element"?e.children.map(Xw).join(""):""}const rI=[tI()];function Tu(e){const t=sI(e.transformers||[]);return[...t.pre,...t.normal,...t.post,...rI]}function sI(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 ki=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],hm={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function iI(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 p0(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 aI(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)hm[s]&&t.push({type:"setDecoration",value:hm[s]});else if(s<=29){const a=hm[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:ki[s-30]}});else if(s===38){const a=p0(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:ki[s-40]}});else if(s===48){const a=p0(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:ki[s-90+8]}}):s>=100&&s<=107&&t.push({type:"setBackgroundColor",value:{type:"named",name:ki[s-100+8]}})}return t}function oI(){let e=null,t=null,n=new Set;return{parse(s){const a=[];let l=0;do{const u=iI(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 d=aI(u.sequence);for(const f of d)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 d)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 lI={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 cI(e=lI){function t(c){return e[c]}function n(c){return`#${c.map(d=>Math.max(0,Math.min(d,255)).toString(16).padStart(2,"0")).join("")}`}let s;function a(){if(s)return s;s=[];for(let f=0;f<ki.length;f++)s.push(t(ki[f]));let c=[0,95,135,175,215,255];for(let f=0;f<6;f++)for(let m=0;m<6;m++)for(let p=0;p<6;p++)s.push(n([c[f],c[m],c[p]]));let d=8;for(let f=0;f<24;f++,d+=10)s.push(n([d,d,d]));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 uI=/#([0-9a-f]{3,8})/i,dI=/var\((--[\w-]+-ansi-[\w-]+)\)/,hI={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 fI(e,t,n){const s=ju(e,n),a=ad(t),l=cI(Object.fromEntries(ki.map(c=>{var f;const d=`terminal.ansi${c[0].toUpperCase()}${c.substring(1)}`;return[c,((f=e.colors)==null?void 0:f[d])||hI[c]]}))),u=oI();return a.map(c=>u.parse(c[0]).map(d=>{let f,m;d.decorations.has("reverse")?(f=d.background?l.value(d.background):e.bg,m=d.foreground?l.value(d.foreground):e.fg):(f=d.foreground?l.value(d.foreground):e.fg,m=d.background?l.value(d.background):void 0),f=Gs(f,s),m=Gs(m,s),d.decorations.has("dim")&&(f=mI(f));let p=bn.None;return d.decorations.has("bold")&&(p|=bn.Bold),d.decorations.has("italic")&&(p|=bn.Italic),d.decorations.has("underline")&&(p|=bn.Underline),d.decorations.has("strikethrough")&&(p|=bn.Strikethrough),{content:d.value,offset:c[1],color:f,bgColor:m,fontStyle:p}}))}function mI(e){const t=e.match(uI);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(dI);return n?`var(${n[1]}-dim)`:e}function ep(e,t,n={}){const s=e.resolveLangAlias(n.lang||"text"),{theme:a=e.getLoadedThemes()[0]}=n;if(!sd(s)&&!id(a)&&s==="ansi"){const{theme:l}=e.setTheme(a);return fI(l,t,n)}return Ow(e,t,n)}function Au(e,t,n){let s,a,l,u,c,d;if("themes"in n){const{defaultColor:f="light",cssVariablePrefix:m="--shiki-",colorsRendering:p="css-vars"}=n,_=Object.entries(n.themes).filter(S=>S[1]).map(S=>({color:S[0],theme:S[1]})).sort((S,b)=>S.color===f?-1:b.color===f?1:0);if(_.length===0)throw new Dt("`themes` option must not be empty");const x=Mw(e,t,n,ep);if(d=fl(x),f&&f!=="light-dark()"&&!_.some(S=>S.color===f))throw new Dt(`\`themes\` option must contain the defaultColor key \`${f}\``);const w=_.map(S=>e.getTheme(S.theme)),C=_.map(S=>S.color);l=x.map(S=>S.map(b=>eI(b,C,m,f,p))),d&&od(l,d);const v=_.map(S=>ju(S.theme,n));a=g0(_,w,v,m,f,"fg",p),s=g0(_,w,v,m,f,"bg",p),u=`shiki-themes ${w.map(S=>S.name).join(" ")}`,c=f?void 0:[a,s].join(";")}else if("theme"in n){const f=ju(n.theme,n);l=ep(e,t,n);const m=e.getTheme(n.theme);s=Gs(m.bg,f),a=Gs(m.fg,f),u=m.name,d=fl(l)}else throw new Dt("Invalid options, either `theme` or `themes` must be provided");return{tokens:l,fg:a,bg:s,themeName:u,rootStyle:c,grammarState:d}}function g0(e,t,n,s,a,l,u){return e.map((c,d)=>{const f=Gs(t[d][l],n[d])||"inherit",m=`${s+c.color}${l==="bg"?"-bg":""}:${f}`;if(d===0&&a){if(a==="light-dark()"&&e.length>1){const p=e.findIndex(x=>x.color==="light"),_=e.findIndex(x=>x.color==="dark");if(p===-1||_===-1)throw new Dt('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');return`light-dark(${Gs(t[p][l],n[p])||"inherit"}, ${Gs(t[_][l],n[_])||"inherit"});${m}`}return f}return u==="css-vars"?m:null}).filter(c=>!!c).join(";")}const Qw=/^\s+$/,pI=/^(\s*)(.*?)(\s*)$/;function Lu(e,t,n,s={meta:{},options:n,codeToHast:(a,l)=>Lu(e,a,l),codeToTokens:(a,l)=>Au(e,a,l)}){var w,C;let a=t;for(const v of Tu(n))a=((w=v.preprocess)==null?void 0:w.call(s,a,n))||a;let{tokens:l,fg:u,bg:c,themeName:d,rootStyle:f,grammarState:m}=Au(e,a,n);const{mergeWhitespaces:p=!0,mergeSameStyleTokens:_=!1}=n;p===!0?l=xI(l):p==="never"&&(l=_I(l)),_&&(l=yI(l));const x={...s,get source(){return a}};for(const v of Tu(n))l=((C=v.tokens)==null?void 0:C.call(x,l))||l;return gI(l,{...n,fg:u,bg:c,themeName:d,rootStyle:n.rootStyle===!1?!1:n.rootStyle??f},x,m)}function gI(e,t,n,s=fl(e)){var C,v,S,b;const a=Tu(t),l=[],u={type:"root",children:[]},{structure:c="classic",tabindex:d="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}`),d!==!1&&d!=null&&(f.tabindex=d.toString());for(const[y,E]of Object.entries(t.meta||{}))y.startsWith("_")||(f[y]=E);let m={type:"element",tagName:"pre",properties:f,children:[],data:t.data},p={type:"element",tagName:"code",properties:{},children:l};const _=[],x={...n,structure:c,addClassToHast:Yw,get source(){return n.source},get tokens(){return e},get options(){return t},get root(){return u},get pre(){return m},get code(){return p},get lines(){return _}};if(e.forEach((y,E)=>{var L,A;E&&(c==="inline"?u.children.push({type:"element",tagName:"br",properties:{},children:[]}):c==="classic"&&l.push({type:"text",value:`
135
+ `}));let N={type:"element",tagName:"span",properties:{class:"line"},children:[]},T=0;for(const R of y){let M={type:"element",tagName:"span",properties:{...R.htmlAttrs},children:[{type:"text",value:R.content}]};const G=Zm(R.htmlStyle||Nu(R));G&&(M.properties.style=G);for(const W of a)M=((L=W==null?void 0:W.span)==null?void 0:L.call(x,M,E+1,T,N,R))||M;c==="inline"?u.children.push(M):c==="classic"&&N.children.push(M),T+=R.content.length}if(c==="classic"){for(const R of a)N=((A=R==null?void 0:R.line)==null?void 0:A.call(x,N,E+1))||N;_.push(N),l.push(N)}else c==="inline"&&_.push(N)}),c==="classic"){for(const y of a)p=((C=y==null?void 0:y.code)==null?void 0:C.call(x,p))||p;m.children.push(p);for(const y of a)m=((v=y==null?void 0:y.pre)==null?void 0:v.call(x,m))||m;u.children.push(m)}else if(c==="inline"){const y=[];let E={type:"element",tagName:"span",properties:{class:"line"},children:[]};for(const T of u.children)T.type==="element"&&T.tagName==="br"?(y.push(E),E={type:"element",tagName:"span",properties:{class:"line"},children:[]}):(T.type==="element"||T.type==="text")&&E.children.push(T);y.push(E);let N={type:"element",tagName:"code",properties:{},children:y};for(const T of a)N=((S=T==null?void 0:T.code)==null?void 0:S.call(x,N))||N;u.children=[];for(let T=0;T<N.children.length;T++){T>0&&u.children.push({type:"element",tagName:"br",properties:{},children:[]});const L=N.children[T];L.type==="element"&&u.children.push(...L.children)}}let w=u;for(const y of a)w=((b=y==null?void 0:y.root)==null?void 0:b.call(x,w))||w;return s&&od(w,s),w}function xI(e){return e.map(t=>{const n=[];let s="",a;return t.forEach((l,u)=>{const c=!(l.fontStyle&&(l.fontStyle&bn.Underline||l.fontStyle&bn.Strikethrough));c&&Qw.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 _I(e){return e.map(t=>t.flatMap(n=>{if(Qw.test(n.content))return n;const s=n.content.match(pI);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 yI(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=Zm(a.htmlStyle||Nu(a)),u=Zm(s.htmlStyle||Nu(s)),c=a.fontStyle&&(a.fontStyle&bn.Underline||a.fontStyle&bn.Strikethrough),d=s.fontStyle&&(s.fontStyle&bn.Underline||s.fontStyle&bn.Strikethrough);!c&&!d&&l===u?a.content+=s.content:n.push({...s})}return n})}const vI=UM;function bI(e,t,n){var l;const s={meta:{},options:n,codeToHast:(u,c)=>Lu(e,u,c),codeToTokens:(u,c)=>Au(e,u,c)};let a=vI(Lu(e,t,n,s));for(const u of Tu(n))a=((l=u.postprocess)==null?void 0:l.call(s,a,n))||a;return a}async function SI(e){const t=await x4(e);return{getLastGrammarState:(...n)=>S4(t,...n),codeToTokensBase:(n,s)=>ep(t,n,s),codeToTokensWithThemes:(n,s)=>Mw(t,n,s),codeToTokens:(n,s)=>Au(t,n,s),codeToHast:(n,s)=>Lu(t,n,s),codeToHtml:(n,s)=>bI(t,n,s),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...t,getInternalContext:()=>t}}function wI(e){const t=e.langs,n=e.themes,s=e.engine;async function a(l){function u(p){var _;if(typeof p=="string"){if(p=((_=l.langAlias)==null?void 0:_[p])||p,jw(p))return[];const x=t[p];if(!x)throw new Dt(`Language \`${p}\` is not included in this bundle. You may want to load it from external source.`);return x}return p}function c(p){if(Nw(p))return"none";if(typeof p=="string"){const _=n[p];if(!_)throw new Dt(`Theme \`${p}\` is not included in this bundle. You may want to load it from external source.`);return _}return p}const d=(l.themes??[]).map(p=>c(p)),f=(l.langs??[]).map(p=>u(p)),m=await SI({engine:l.engine??s(),...l,themes:d,langs:f});return{...m,loadLanguage(...p){return m.loadLanguage(...p.map(u))},loadTheme(...p){return m.loadTheme(...p.map(c))},getBundledLanguages(){return t},getBundledThemes(){return n}}}return a}function CI(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 kI(e,t){const n=CI(e);async function s(a,l){var d;const u=await n({langs:[l.lang],themes:"theme"in l?[l.theme]:Object.values(l.themes)}),c=await((d=t==null?void 0:t.guessEmbeddedLanguages)==null?void 0:d.call(t,a,l.lang,u));return c&&await u.loadLanguage(...c),u}return{getSingletonHighlighter(a){return n(a)},async codeToHtml(a,l){return(await 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 EI=Vp({bundledLanguages:()=>qp,bundledLanguagesAlias:()=>Wp,bundledLanguagesBase:()=>Gp,bundledLanguagesInfo:()=>td,bundledThemes:()=>Yp,bundledThemesInfo:()=>Kp,codeToHast:()=>Zw,codeToHtml:()=>Jw,codeToTokens:()=>eC,codeToTokensBase:()=>tC,codeToTokensWithThemes:()=>nC,createHighlighter:()=>cd,getLastGrammarState:()=>sC,getSingletonHighlighter:()=>rC});const cd=wI({langs:qp,themes:Yp,engine:()=>(0,uw.createOnigurumaEngine)(Q(()=>import("./wasm-CG6Dc4jp.js"),[]))}),{codeToHtml:Jw,codeToHast:Zw,codeToTokens:eC,codeToTokensBase:tC,codeToTokensWithThemes:nC,getSingletonHighlighter:rC,getLastGrammarState:sC}=kI(cd,{guessEmbeddedLanguages:XM}),x0=4294967295;var jI=class{constructor(e,t={}){me(this,"patterns");me(this,"options");me(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,d=0){return{index:u,captureIndices:c.indices.map(f=>f==null?{start:x0,end:x0,length:0}:{start:f[0]+d,end:f[1]+d,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 d=c.exec(s);if(!d)continue;if(d.index===t)return l(u,d,0);a.push([u,d,0])}catch(d){if(this.options.forgiving)continue;throw d}}if(a.length){const u=Math.min(...a.map(c=>c[1].index));for(const[c,d,f]of a)if(d.index===u)return l(c,d,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 NI(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}const sg=new Set(["alnum","alpha","ascii","blank","cntrl","digit","graph","lower","print","punct","space","upper","word","xdigit"]),hn=String.raw;function Wa(e,t){if(e==null)throw new Error(t??"Value expected");return e}const iC=hn`\[\^?`,aC=`c.? | C(?:-.?)?|${hn`[pP]\{(?:\^?[-\x20_]*[A-Za-z][-\x20\w]*\})?`}|${hn`x[89A-Fa-f]\p{AHex}(?:\\x[89A-Fa-f]\p{AHex})*`}|${hn`u(?:\p{AHex}{4})? | x\{[^\}]*\}? | x\p{AHex}{0,2}`}|${hn`o\{[^\}]*\}?`}|${hn`\d{1,3}`}`,ig=/[?*+][?+]?|\{(?:\d+(?:,\d*)?|,\d+)\}\??/,nu=new RegExp(hn`
136
+ \\ (?:
137
+ ${aC}
138
+ | [gk]<[^>]*>?
139
+ | [gk]'[^']*'?
140
+ | .
141
+ )
142
+ | \( (?:
143
+ \? (?:
144
+ [:=!>({]
145
+ | <[=!]
146
+ | <[^>]*>
147
+ | '[^']*'
148
+ | ~\|?
149
+ | #(?:[^)\\]|\\.?)*
150
+ | [^:)]*[:)]
151
+ )?
152
+ | \*[^\)]*\)?
153
+ )?
154
+ | (?:${ig.source})+
155
+ | ${iC}
156
+ | .
157
+ `.replace(/\s+/g,""),"gsu"),fm=new RegExp(hn`
158
+ \\ (?:
159
+ ${aC}
160
+ | .
161
+ )
162
+ | \[:(?:\^?\p{Alpha}+|\^):\]
163
+ | ${iC}
164
+ | &&
165
+ | .
166
+ `.replace(/\s+/g,""),"gsu");function TI(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=KI(n.flags),a=[s.extended],l={captureGroup:n.rules.captureGroup,getCurrentModX(){return a.at(-1)},numOpenGroups:0,popModX(){a.pop()},pushModX(p){a.push(p)},replaceCurrentModX(p){a[a.length-1]=p},singleline:n.rules.singleline};let u=[],c;for(nu.lastIndex=0;c=nu.exec(e);){const p=AI(l,e,c[0],nu.lastIndex);p.tokens?u.push(...p.tokens):p.token&&u.push(p.token),p.lastIndex!==void 0&&(nu.lastIndex=p.lastIndex)}const d=[];let f=0;u.filter(p=>p.type==="GroupOpen").forEach(p=>{p.kind==="capturing"?p.number=++f:p.raw==="("&&d.push(p)}),f||d.forEach((p,_)=>{p.kind="capturing",p.number=_+1});const m=f||d.length;return{tokens:u.map(p=>p.type==="EscapedNumber"?XI(p,m):p).flat(),flags:s}}function AI(e,t,n,s){const[a,l]=n;if(n==="["||n==="[^"){const u=LI(t,n,s);return{tokens:u.tokens,lastIndex:u.lastIndex}}if(a==="\\"){if("AbBGyYzZ".includes(l))return{token:_0(n,n)};if(/^\\g[<']/.test(n)){if(!/^\\g(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:HI(n)}}if(/^\\k[<']/.test(n)){if(!/^\\k(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:lC(n)}}if(l==="K")return{token:cC("keep",n)};if(l==="N"||l==="R")return{token:Ei("newline",n,{negate:l==="N"})};if(l==="O")return{token:Ei("any",n)};if(l==="X")return{token:Ei("text_segment",n)};const u=oC(n,{inCharClass:!1});return Array.isArray(u)?{tokens:u}:{token:u}}if(a==="("){if(l==="*")return{token:GI(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:VI(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:BI(n)}}if(e.getCurrentModX()){if(n==="#"){const u=t.indexOf(`
167
+ `,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:Ei("dot",n)};if(n==="^"||n==="$"){const u=e.singleline?{"^":hn`\A`,$:hn`\Z`}[n]:n;return{token:_0(u,n)}}return n==="|"?{token:RI(n)}:ig.test(n)?{tokens:QI(n)}:{token:us(Ga(n),n)}}function LI(e,t,n){const s=[y0(t[1]==="^",t)];let a=1,l;for(fm.lastIndex=n;l=fm.exec(e);){const u=l[0];if(u[0]==="["&&u[1]!==":")a++,s.push(y0(u[1]==="^",u));else if(u==="]"){if(s.at(-1).type==="CharacterClassOpen")s.push(us(93,u));else if(a--,s.push(OI(u)),!a)break}else{const c=DI(u);Array.isArray(c)?s.push(...c):s.push(c)}}return{tokens:s,lastIndex:fm.lastIndex||e.length}}function DI(e){if(e[0]==="\\")return oC(e,{inCharClass:!0});if(e[0]==="["){const t=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);if(!t||!sg.has(t.groups.name))throw new Error(`Invalid POSIX class "${e}"`);return Ei("posix",e,{value:t.groups.name,negate:!!t.groups.negate})}return e==="-"?MI(e):e==="&&"?II(e):us(Ga(e),e)}function oC(e,{inCharClass:t}){const n=e[1];if(n==="c"||n==="C")return FI(e);if("dDhHsSwW".includes(n))return WI(e);if(e.startsWith(hn`\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 qI(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(d=>`\\x${d.toString(16)}`).join("");return us(Ga(u),c)})}catch{throw new Error(`Multibyte code "${e}" incomplete or invalid in Oniguruma`)}if(n==="u"||n==="x")return us(YI(e),e);if(v0.has(n))return us(v0.get(n),e);if(/\d/.test(n))return PI(t,e);if(e==="\\")throw new Error(hn`Incomplete escape "\"`);if(n==="M")throw new Error(`Unsupported meta "${e}"`);if([...e].length===2)return us(e.codePointAt(1),e);throw new Error(`Unexpected escape "${e}"`)}function RI(e){return{type:"Alternator",raw:e}}function _0(e,t){return{type:"Assertion",kind:e,raw:t}}function lC(e){return{type:"Backreference",raw:e}}function us(e,t){return{type:"Character",value:e,raw:t}}function OI(e){return{type:"CharacterClassClose",raw:e}}function MI(e){return{type:"CharacterClassHyphen",raw:e}}function II(e){return{type:"CharacterClassIntersector",raw:e}}function y0(e,t){return{type:"CharacterClassOpen",negate:e,raw:t}}function Ei(e,t,n={}){return{type:"CharacterSet",kind:e,...n,raw:t}}function cC(e,t,n={}){return e==="keep"?{type:"Directive",kind:e,raw:t}:{type:"Directive",kind:e,flags:Wa(n.flags),raw:t}}function PI(e,t){return{type:"EscapedNumber",inCharClass:e,raw:t}}function BI(e){return{type:"GroupClose",raw:e}}function Da(e,t,n={}){return{type:"GroupOpen",kind:e,...n,raw:t}}function zI(e,t,n,s){return{type:"NamedCallout",kind:e,tag:t,arguments:n,raw:s}}function $I(e,t,n,s){return{type:"Quantifier",kind:e,min:t,max:n,raw:s}}function HI(e){return{type:"Subroutine",raw:e}}const UI=new Set(["COUNT","CMP","ERROR","FAIL","MAX","MISMATCH","SKIP","TOTAL_COUNT"]),v0=new Map([["a",7],["b",8],["e",27],["f",12],["n",10],["r",13],["t",9],["v",11]]);function FI(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 us(Ga(t.toUpperCase())-64,e)}function VI(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=S0(n),u=S0(s),c={};if(l&&(c.enable=l),u&&(c.disable=u),e.endsWith(")"))return t.replaceCurrentModX(a),cC("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 GI(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(m=>m!=="").map(m=>/^[+-]?\d+$/.test(m)?+m:m):[],[u,c,d]=l,f=UI.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 d=="string"&&!/^[A-Za-z_]\w*$/.test(d))throw new Error(`Named callout argument three must be a tag or number "${d}"`);break;case"custom":throw new Error(`Undefined callout name "${n}"`);default:throw new Error(`Unexpected named callout kind "${f}"`)}return zI(f,s??null,(a==null?void 0:a.split(","))??null,e)}function b0(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 $I(t,n,s,e)}function WI(e){const t=e[1].toLowerCase();return Ei({d:"digit",h:"hex",s:"space",w:"word"}[t],e,{negate:e[1]!==t})}function qI(e){const{p:t,neg:n,value:s}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(e).groups;return Ei("property",e,{value:s,negate:t==="P"&&!n||t==="p"&&!!n})}function S0(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 KI(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 YI(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 XI(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[lC(n)];const l=[],u=a.match(/^[0-7]+|\d/g);for(let c=0;c<u.length;c++){const d=u[c];let f;if(c===0&&d!=="8"&&d!=="9"){if(f=parseInt(d,8),f>127)throw new Error(hn`Octal encoded byte above 177 unsupported "${n}"`)}else f=Ga(d);l.push(us(f,(c===0?"\\":"")+d))}return l}function QI(e){const t=[],n=new RegExp(ig,"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(b0(a.slice(0,-1)));continue}}}t.push(b0(a))}return t}function uC(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 JI(e){return ZI.has(e.type)}const ZI=new Set(["AbsenceFunction","Backreference","CapturingGroup","Character","CharacterClass","CharacterSet","Group","Quantifier","Subroutine"]);function dC(e,t={}){const n={flags:"",normalizeUnknownPropertyNames:!1,skipBackrefValidation:!1,skipLookbehindValidation:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t,rules:{captureGroup:!1,singleline:!1,...t.rules}},s=TI(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 Li();case"Assertion":return eP(w);case"Backreference":return tP(w,l);case"Character":return ud(w.value,{useLastValid:!!x.isCheckingRangeEnd});case"CharacterClassHyphen":return nP(w,l,x);case"CharacterClassOpen":return rP(w,l,x);case"CharacterSet":return sP(w,l);case"Directive":return uP(w.kind,{flags:w.flags});case"GroupOpen":return iP(w,l,x);case"NamedCallout":return hP(w.kind,w.tag,w.arguments);case"Quantifier":return aP(w,l);case"Subroutine":return oP(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=mP(dP(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:d,hasNumberedRef:f,namedGroupsByName:m,subroutines:p}=l;if(f&&m.size&&!n.rules.captureGroup)throw new Error("Numbered backref/subroutine not allowed when using named capture");for(const{ref:_}of p)if(typeof _=="number"){if(_>d.length)throw new Error("Subroutine uses a group number that's not defined");_&&(d[_-1].isSubroutined=!0)}else if(m.has(_)){if(m.get(_).length>1)throw new Error(hn`Subroutine uses a duplicate group name "\g<${_}>"`);m.get(_)[0].isSubroutined=!0}else throw new Error(hn`Subroutine uses a group name that's not defined "\g<${_}>"`);return u}function eP({kind:e}){return tp(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===hn`\B`||e===hn`\Y`})}function tP({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 d=!1;if(l>c)if(t.skipBackrefValidation)d=!0;else throw new Error(`Not enough capturing groups defined to the left "${e}"`);return t.hasNumberedRef=!0,np(u?c+1-l:l,{orphan:d})};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 np(s)}return a(+s)}function nP(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 d=a(l,{...n,isCheckingRangeEnd:!0});if(u.type==="Character"&&d.type==="Character")return l.body.pop(),cP(u,d);throw new Error("Invalid character class range")}return ud(Ga("-"))}function rP({negate:e},t,n){const{tokens:s,walk:a}=t,l=[hu()],u=s[t.nextIndex];let c=k0(u);for(;c.type!=="CharacterClassClose";){if(c.type==="CharacterClassIntersector")l.push(hu()),t.nextIndex++;else{const f=l.at(-1);f.body.push(a(f,n))}c=k0(s[t.nextIndex],u)}const d=hu({negate:e});return l.length===1?d.body=l[0].body:(d.kind="intersection",d.body=l.map(f=>f.body.length===1?f.body[0]:f)),t.nextIndex++,d}function sP({kind:e,negate:t,value:n},s){const{normalizeUnknownPropertyNames:a,skipPropertyNameValidation:l,unicodePropertyMap:u}=s;if(e==="property"){const c=dd(n);if(sg.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"?fP(n,{negate:t}):rp(e,{negate:t})}function iP(e,t,n){const{tokens:s,capturingGroups:a,namedGroupsByName:l,skipLookbehindValidation:u,walk:c}=t,d=pP(e),f=d.type==="AbsenceFunction",m=C0(d),p=m&&d.negate;if(d.type==="CapturingGroup"&&(a.push(d),d.name&&NI(l,d.name,[]).push(d)),f&&n.isInAbsenceFunction)throw new Error("Nested absence function not supported by Oniguruma");let _=E0(s[t.nextIndex]);for(;_.type!=="GroupClose";){if(_.type==="Alternator")d.body.push(Li()),t.nextIndex++;else{const x=d.body.at(-1),w=c(x,{...n,isInAbsenceFunction:n.isInAbsenceFunction||f,isInLookbehind:n.isInLookbehind||m,isInNegLookbehind:n.isInNegLookbehind||p});if(x.body.push(w),(m||n.isInLookbehind)&&!u){const C="Lookbehind includes a pattern not allowed by Oniguruma";if(p||n.isInNegLookbehind){if(w0(w)||w.type==="CapturingGroup")throw new Error(C)}else if(w0(w)||C0(w)&&w.negate)throw new Error(C)}}_=E0(s[t.nextIndex])}return t.nextIndex++,d}function aP({kind:e,min:t,max:n},s){const a=s.parent,l=a.body.at(-1);if(!l||!JI(l))throw new Error("Quantifier requires a repeatable token");const u=fC(e,t,n,l);return a.body.pop(),u}function oP({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,d=n.length;if(t.hasNumberedRef=!0,a={"":c,"+":d+c,"-":d+1-c}[l.groups.sign],a<1)throw new Error("Invalid subroutine number")}else a==="0"&&(a=0);const u=mC(a);return s.push(u),u}function lP(e,t){return{type:"AbsenceFunction",kind:e,body:jl(t==null?void 0:t.body)}}function Li(e){return{type:"Alternative",body:pC(e==null?void 0:e.body)}}function tp(e,t){const n={type:"Assertion",kind:e};return(e==="word_boundary"||e==="text_segment_boundary")&&(n.negate=!!(t!=null&&t.negate)),n}function np(e,t){const n=!!(t!=null&&t.orphan);return{type:"Backreference",ref:e,...n&&{orphan:n}}}function hC(e,t){const n={name:void 0,isSubroutined:!1,...t};if(n.name!==void 0&&!gP(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:jl(t==null?void 0:t.body)}}function ud(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 hu(e){const t={kind:"union",negate:!1,...e};return{type:"CharacterClass",kind:t.kind,negate:t.negate,body:pC(e==null?void 0:e.body)}}function cP(e,t){if(t.value<e.value)throw new Error("Character class range out of order");return{type:"CharacterClassRange",min:e,max:t}}function rp(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 uP(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 dP(e){return{type:"Flags",...e}}function vr(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:jl(e==null?void 0:e.body)}}function Ci(e){const t={behind:!1,negate:!1,...e};return{type:"LookaroundAssertion",kind:t.behind?"lookbehind":"lookahead",negate:t.negate,body:jl(e==null?void 0:e.body)}}function hP(e,t,n){return{type:"NamedCallout",kind:e,tag:t,arguments:n}}function fP(e,t){const n=!!(t!=null&&t.negate);if(!sg.has(e))throw new Error(`Invalid POSIX class "${e}"`);return{type:"CharacterSet",kind:"posix",value:e,negate:n}}function fC(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 mP(e,t){return{type:"Regex",body:jl(t==null?void 0:t.body),flags:e}}function mC(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(dd(e));if(!s){if(n.normalizeUnknownPropertyNames)s=xP(e);else if(n.unicodePropertyMap&&!n.skipPropertyNameValidation)throw new Error(hn`Invalid Unicode property "\p{${e}}"`)}return{type:"CharacterSet",kind:"property",value:s??e,negate:n.negate}}function pP({flags:e,kind:t,name:n,negate:s,number:a}){switch(t){case"absence_repeater":return lP("repeater");case"atomic":return vr({atomic:!0});case"capturing":return hC(a,{name:n});case"group":return vr({flags:e});case"lookahead":case"lookbehind":return Ci({behind:t==="lookbehind",negate:s});default:throw new Error(`Unexpected group kind "${t}"`)}}function jl(e){if(e===void 0)e=[Li()];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 pC(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 w0(e){return e.type==="LookaroundAssertion"&&e.kind==="lookahead"}function C0(e){return e.type==="LookaroundAssertion"&&e.kind==="lookbehind"}function gP(e){return/^[\p{Alpha}\p{Pc}][^)]*$/u.test(e)}function xP(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 dd(e){return e.replace(/[- _]+/g,"").toLowerCase()}function k0(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 E0(e){return Wa(e,"Unclosed group")}function al(e,t,n=null){function s(l,u){for(let c=0;c<l.length;c++){const d=a(l[c],u,c,l);c=Math.max(-1,c+d)}}function a(l,u=null,c=null,d=null){var S,b;let f=0,m=!1;const p={node:l,parent:u,key:c,container:d,root:e,remove(){ru(d).splice(Math.max(0,Ca(c)+f),1),f--,m=!0},removeAllNextSiblings(){return ru(d).splice(Ca(c)+1)},removeAllPrevSiblings(){const y=Ca(c)+f;return f-=y,ru(d).splice(0,Math.max(0,y))},replaceWith(y,E={}){const N=!!E.traverse;d?d[Math.max(0,Ca(c)+f)]=y:Wa(u,"Can't replace root node")[c]=y,N&&a(y,u,c,d),m=!0},replaceWithMultiple(y,E={}){const N=!!E.traverse;if(ru(d).splice(Math.max(0,Ca(c)+f),1,...y),f+=y.length-1,N){let T=0;for(let L=0;L<y.length;L++)T+=a(y[L],u,Ca(c)+L+T,d)}m=!0},skip(){m=!0}},{type:_}=l,x=t["*"],w=t[_],C=typeof x=="function"?x:x==null?void 0:x.enter,v=typeof w=="function"?w:w==null?void 0:w.enter;if(C==null||C(p,n),v==null||v(p,n),!m)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,p,n),(b=x==null?void 0:x.exit)==null||b.call(x,p,n),f}return a(e),e}function ru(e){if(!Array.isArray(e))throw new Error("Container expected");return e}function Ca(e){if(typeof e!="number")throw new Error("Numeric key expected");return e}const _P=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function yP(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function vP(e,t,n,s){return e.slice(0,t)+s+e.slice(t+n.length)}const ur=Object.freeze({DEFAULT:"DEFAULT",CHAR_CLASS:"CHAR_CLASS"});function ag(e,t,n,s){const a=new RegExp(String.raw`${t}|(?<$skip>\[\^?|\\?.)`,"gsu"),l=[!1];let u=0,c="";for(const d of e.matchAll(a)){const{0:f,groups:{$skip:m}}=d;if(!m&&(!s||s===ur.DEFAULT==!u)){n instanceof Function?c+=n(d,{context:u?ur.CHAR_CLASS:ur.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 gC(e,t,n,s){ag(e,t,n,s)}function bP(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:d}}=u;if(!d&&(!s||s===ur.DEFAULT==!l))return u;c==="["?l++:c==="]"&&l&&l--,a.lastIndex==u.index&&a.lastIndex++}return null}function su(e,t,n){return!!bP(e,t,0,n)}function SP(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 j0=new RegExp(String.raw`(?<noncapturingStart>${_P})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,"gsu");function wP(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 d=0,f=0,m=NaN,p;do{p=!1;let _=0,x=0,w=!1,C;for(j0.lastIndex=Number.isNaN(m)?0:m+l.length;C=j0.exec(e);){const{0:v,index:S,groups:{capturingStart:b,noncapturingStart:y}}=C;if(v==="[")_++;else if(_)v==="]"&&_--;else if(v===a&&!w)m=S,w=!0;else if(w&&y)x++;else if(b)w?x++:(d++,u.push(d+f));else if(v===")"&&w){if(!x){f++;const E=d+f;if(e=`${e.slice(0,m)}${l}${e.slice(m+a.length,S)}))<$$${E}>)${e.slice(S+1)}`,p=!0,c.push(E),yP(n,E),s.size){const N=new Map;s.forEach((T,L)=>{N.set(L>=E?L+1:L,T.map(A=>A>=E?A+1:A))}),s=N}break}x--}}}while(p);return n.push(...c),e=ag(e,String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,({0:_,groups:{backrefNum:x,wrappedBackrefNum:w}})=>{if(x){const C=+x;if(C>u.length-1)throw new Error(`Backref "${_}" greater than number of captures`);return`\\${u[C]}`}return`\\${w}`},ur.DEFAULT),{pattern:e,captureTransfers:s,hiddenCaptures:n}}const xC=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,mm=new RegExp(String.raw`
168
+ \\(?: \d+
169
+ | c[A-Za-z]
170
+ | [gk]<[^>]+>
171
+ | [pPu]\{[^\}]+\}
172
+ | u[A-Fa-f\d]{4}
173
+ | x[A-Fa-f\d]{2}
174
+ )
175
+ | \((?: \? (?: [:=!>]
176
+ | <(?:[=!]|[^>]+>)
177
+ | [A-Za-z\-]+:
178
+ | \(DEFINE\)
179
+ ))?
180
+ | (?<qBase>${xC})(?<qMod>[?+]?)(?<invalidQ>[?*+\{]?)
181
+ | \\?.
182
+ `.replace(/\s+/g,""),"gsu");function CP(e){if(!new RegExp(`${xC}\\+`).test(e))return{pattern:e};const t=[];let n=null,s=null,a="",l=0,u;for(mm.lastIndex=0;u=mm.exec(e);){const{0:c,index:d,groups:{qBase:f,qMod:m,invalidQ:p}}=u;if(c==="[")l||(s=d),l++;else if(c==="]")l?l--:s=null;else if(!l)if(m==="+"&&a&&!a.startsWith("(")){if(p)throw new Error(`Invalid quantifier "${c}"`);let _=-1;if(/^\{\d+\}$/.test(f))e=vP(e,d+f.length,m,"");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,d)}${f})${e.slice(d+c.length)}`}else e=`${e.slice(0,d-a.length)}(?>${a}${f})${e.slice(d+c.length)}`;_+=4}mm.lastIndex+=_}else c[0]==="("?t.push(d):c===")"&&(n=t.length?t.pop():null);a=c}return{pattern:e}}const cr=String.raw,kP=cr`\\g<(?<gRNameOrNum>[^>&]+)&R=(?<gRDepth>[^>]+)>`,sp=cr`\(\?R=(?<rDepth>[^\)]+)\)|${kP}`,hd=cr`\(\?<(?![=!])(?<captureName>[^>]+)>`,_C=cr`${hd}|(?<unnamed>\()(?!\?)`,xi=new RegExp(cr`${hd}|${sp}|\(\?|\\?.`,"gsu"),pm="Cannot use multiple overlapping recursions";function EP(e,t){const{hiddenCaptures:n,mode:s}={hiddenCaptures:[],mode:"plugin",...t};let a=(t==null?void 0:t.captureTransfers)??new Map;if(!new RegExp(sp,"su").test(e))return{pattern:e,captureTransfers:a,hiddenCaptures:n};if(s==="plugin"&&su(e,cr`\(\?\(DEFINE\)`,ur.DEFAULT))throw new Error("DEFINE groups cannot be used with recursion");const l=[],u=su(e,cr`\\[1-9]`,ur.DEFAULT),c=new Map,d=[];let f=!1,m=0,p=0,_;for(xi.lastIndex=0;_=xi.exec(e);){const{0:x,groups:{captureName:w,rDepth:C,gRNameOrNum:v,gRDepth:S}}=_;if(x==="[")m++;else if(m)x==="]"&&m--;else if(C){if(N0(C),f)throw new Error(pm);if(u)throw new Error(`${s==="external"?"Backrefs":"Numbered backrefs"} cannot be used with global recursion`);const b=e.slice(0,_.index),y=e.slice(xi.lastIndex);if(su(y,sp,ur.DEFAULT))throw new Error(pm);const E=+C-1;e=T0(b,y,E,!1,n,l,p),a=L0(a,b,E,l.length,0,p);break}else if(v){N0(S);let b=!1;for(const W of d)if(W.name===v||W.num===+v){if(b=!0,W.hasRecursedWithin)throw new Error(pm);break}if(!b)throw new Error(cr`Recursive \g cannot be used outside the referenced group "${s==="external"?v:cr`\g<${v}&R=${S}>`}"`);const y=c.get(v),E=SP(e,y);if(u&&su(E,cr`${hd}|\((?!\?)`,ur.DEFAULT))throw new Error(`${s==="external"?"Backrefs":"Numbered backrefs"} cannot be used with recursion of capturing groups`);const N=e.slice(y,_.index),T=E.slice(N.length+x.length),L=l.length,A=+S-1,R=T0(N,T,A,!0,n,l,p);a=L0(a,N,A,l.length-L,L,p);const M=e.slice(0,y),G=e.slice(y+E.length);e=`${M}${R}${G}`,xi.lastIndex+=R.length-x.length-N.length-T.length,d.forEach(W=>W.hasRecursedWithin=!0),f=!0}else if(w)p++,c.set(String(p),xi.lastIndex),c.set(w,xi.lastIndex),d.push({num:p,name:w});else if(x[0]==="("){const b=x==="(";b&&(p++,c.set(String(p),xi.lastIndex)),d.push(b?{num:p}:{})}else x===")"&&d.pop()}return n.push(...l),{pattern:e,captureTransfers:a,hiddenCaptures:n}}function N0(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 T0(e,t,n,s,a,l,u){const c=new Set;s&&gC(e+t,hd,({groups:{captureName:f}})=>{c.add(f)},ur.DEFAULT);const d=[n,s?c:null,a,l,u];return`${e}${A0(`(?:${e}`,"forward",...d)}(?:)${A0(`${t})`,"backward",...d)}${t}`}function A0(e,t,n,s,a,l,u){const d=m=>t==="forward"?m+2:n-m+2-1;let f="";for(let m=0;m<n;m++){const p=d(m);f+=ag(e,cr`${_C}|\\k<(?<backref>[^>]+)>`,({0:_,groups:{captureName:x,unnamed:w,backref:C}})=>{if(C&&s&&!s.has(C))return _;const v=`_$${p}`;if(w||x){const S=u+l.length+1;return l.push(S),jP(a,S),w?_:`(?<${x}${v}>`}return cr`\k<${C}${v}>`},ur.DEFAULT)}return f}function jP(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function L0(e,t,n,s,a,l){if(e.size&&s){let u=0;gC(t,_C,()=>u++,ur.DEFAULT);const c=l-u+a,d=new Map;return e.forEach((f,m)=>{const p=(s-u*n)/n,_=u*n,x=m>c+u?m+s:m,w=[];for(const C of f)if(C<=c)w.push(C);else if(C>c+u+p)w.push(C+s);else if(C<=c+u)for(let v=0;v<=n;v++)w.push(C+u*v);else for(let v=0;v<=n;v++)w.push(C+_+p*v);d.set(x,w)}),d}return e}var an=String.fromCodePoint,qe=String.raw,wr={},fd=globalThis.RegExp;wr.flagGroups=(()=>{try{new fd("(?i:)")}catch{return!1}return!0})();wr.unicodeSets=(()=>{try{new fd("[[]]","v")}catch{return!1}return!0})();wr.bugFlagVLiteralHyphenIsRange=wr.unicodeSets?(()=>{try{new fd(qe`[\d\-a]`,"v")}catch{return!0}return!1})():!1;wr.bugNestedClassIgnoresNegation=wr.unicodeSets&&new fd("[[^a]]","v").test("a");function Du(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 ml(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}function ip(e,t){return D0[e]>=D0[t]}function NP(e,t){if(e==null)throw new Error(t??"Value expected");return e}var D0={ES2025:2025,ES2024:2024,ES2018:2018},TP={auto:"auto",ES2025:"ES2025",ES2024:"ES2024",ES2018:"ES2018"};function yC(e={}){if({}.toString.call(e)!=="[object Object]")throw new Error("Unexpected options");if(e.target!==void 0&&!TP[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=wr.flagGroups?"ES2025":wr.unicodeSets?"ES2024":"ES2018"),t}var AP="[ -\r ]",LP=new Set([an(304),an(305)]),ss=qe`[\p{L}\p{M}\p{N}\p{Pc}]`;function vC(e){if(LP.has(e))return[e];const t=new Set,n=e.toLowerCase(),s=n.toUpperCase(),a=OP.get(n),l=DP.get(n),u=RP.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 og=new Map(`C Other
183
+ Cc Control cntrl
184
+ Cf Format
185
+ Cn Unassigned
186
+ Co Private_Use
187
+ Cs Surrogate
188
+ L Letter
189
+ LC Cased_Letter
190
+ Ll Lowercase_Letter
191
+ Lm Modifier_Letter
192
+ Lo Other_Letter
193
+ Lt Titlecase_Letter
194
+ Lu Uppercase_Letter
195
+ M Mark Combining_Mark
196
+ Mc Spacing_Mark
197
+ Me Enclosing_Mark
198
+ Mn Nonspacing_Mark
199
+ N Number
200
+ Nd Decimal_Number digit
201
+ Nl Letter_Number
202
+ No Other_Number
203
+ P Punctuation punct
204
+ Pc Connector_Punctuation
205
+ Pd Dash_Punctuation
206
+ Pe Close_Punctuation
207
+ Pf Final_Punctuation
208
+ Pi Initial_Punctuation
209
+ Po Other_Punctuation
210
+ Ps Open_Punctuation
211
+ S Symbol
212
+ Sc Currency_Symbol
213
+ Sk Modifier_Symbol
214
+ Sm Math_Symbol
215
+ So Other_Symbol
216
+ Z Separator
217
+ Zl Line_Separator
218
+ Zp Paragraph_Separator
219
+ Zs Space_Separator
220
+ ASCII
221
+ ASCII_Hex_Digit AHex
222
+ Alphabetic Alpha
223
+ Any
224
+ Assigned
225
+ Bidi_Control Bidi_C
226
+ Bidi_Mirrored Bidi_M
227
+ Case_Ignorable CI
228
+ Cased
229
+ Changes_When_Casefolded CWCF
230
+ Changes_When_Casemapped CWCM
231
+ Changes_When_Lowercased CWL
232
+ Changes_When_NFKC_Casefolded CWKCF
233
+ Changes_When_Titlecased CWT
234
+ Changes_When_Uppercased CWU
235
+ Dash
236
+ Default_Ignorable_Code_Point DI
237
+ Deprecated Dep
238
+ Diacritic Dia
239
+ Emoji
240
+ Emoji_Component EComp
241
+ Emoji_Modifier EMod
242
+ Emoji_Modifier_Base EBase
243
+ Emoji_Presentation EPres
244
+ Extended_Pictographic ExtPict
245
+ Extender Ext
246
+ Grapheme_Base Gr_Base
247
+ Grapheme_Extend Gr_Ext
248
+ Hex_Digit Hex
249
+ IDS_Binary_Operator IDSB
250
+ IDS_Trinary_Operator IDST
251
+ ID_Continue IDC
252
+ ID_Start IDS
253
+ Ideographic Ideo
254
+ Join_Control Join_C
255
+ Logical_Order_Exception LOE
256
+ Lowercase Lower
257
+ Math
258
+ Noncharacter_Code_Point NChar
259
+ Pattern_Syntax Pat_Syn
260
+ Pattern_White_Space Pat_WS
261
+ Quotation_Mark QMark
262
+ Radical
263
+ Regional_Indicator RI
264
+ Sentence_Terminal STerm
265
+ Soft_Dotted SD
266
+ Terminal_Punctuation Term
267
+ Unified_Ideograph UIdeo
268
+ Uppercase Upper
269
+ Variation_Selector VS
270
+ White_Space space
271
+ XID_Continue XIDC
272
+ XID_Start XIDS`.split(/\s/).map(e=>[dd(e),e])),DP=new Map([["s",an(383)],[an(383),"s"]]),RP=new Map([[an(223),an(7838)],[an(107),an(8490)],[an(229),an(8491)],[an(969),an(8486)]]),OP=new Map([Bs(453),Bs(456),Bs(459),Bs(498),...gm(8072,8079),...gm(8088,8095),...gm(8104,8111),Bs(8124),Bs(8140),Bs(8188)]),MP=new Map([["alnum",qe`[\p{Alpha}\p{Nd}]`],["alpha",qe`\p{Alpha}`],["ascii",qe`\p{ASCII}`],["blank",qe`[\p{Zs}\t]`],["cntrl",qe`\p{Cc}`],["digit",qe`\p{Nd}`],["graph",qe`[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]`],["lower",qe`\p{Lower}`],["print",qe`[[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],["punct",qe`[\p{P}\p{S}]`],["space",qe`\p{space}`],["upper",qe`\p{Upper}`],["word",qe`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],["xdigit",qe`\p{AHex}`]]);function IP(e,t){const n=[];for(let s=e;s<=t;s++)n.push(s);return n}function Bs(e){const t=an(e);return[t.toLowerCase(),t]}function gm(e,t){return IP(e,t).map(n=>Bs(n))}var bC=new Set(["Lower","Lowercase","Upper","Uppercase","Ll","Lowercase_Letter","Lt","Titlecase_Letter","Lu","Uppercase_Letter"]);function PP(e,t){const n={accuracy:"default",asciiWordBoundaries:!1,avoidSubclass:!1,bestEffortTarget:"ES2025",...t};SC(e);const s={accuracy:n.accuracy,asciiWordBoundaries:n.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,flagDirectivesByAlt:new Map,jsGroupNameMap:new Map,minTargetEs2024:ip(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};al(e,BP,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};al(e,zP,l);const u={groupsByName:l.groupsByName,highestOrphanBackref:0,numCapturesToLeft:0,reffedNodesByReferencer:l.reffedNodesByReferencer};return al(e,$P,u),e._originMap=l.groupOriginByCopy,e._strategy=s.strategy,e}var BP={AbsenceFunction({node:e,parent:t,replaceWith:n}){const{body:s,kind:a}=e;if(a==="repeater"){const l=vr();l.body[0].body.push(Ci({negate:!0,body:s}),Ra("Any"));const u=vr();u.body[0].body.push(fC("greedy",0,1/0,l)),n(qt(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];ml(s,u,[]).push(...a)}},exit({node:e},{flagDirectivesByAlt:t}){var n;if((n=t.get(e))!=null&&n.length){const s=CC(t.get(e));if(s){const a=vr({flags:s});a.body[0].body=e.body,e.body=[qt(a,e)]}}}},Assertion({node:e,parent:t,key:n,container:s,root:a,remove:l,replaceWith:u},c){const{kind:d,negate:f}=e,{asciiWordBoundaries:m,avoidSubclass:p,supportedGNodes:_,wordIsAscii:x}=c;if(d==="text_segment_boundary")throw new Error(`Unsupported text segment boundary "\\${f?"Y":"y"}"`);if(d==="line_end")u(qt(Ci({body:[Li({body:[tp("string_end")]}),Li({body:[ud(10)]})]}),t));else if(d==="line_start")u(qt(is(qe`(?<=\A|\n(?!\z))`,{skipLookbehindValidation:!0}),t));else if(d==="search_start")if(_.has(e))a.flags.sticky=!0,l();else{const w=s[n-1];if(w&&WP(w))u(qt(Ci({negate:!0}),t));else{if(p)throw new Error(qe`Uses "\G" in a way that requires a subclass`);u(zs(tp("string_start"),t)),c.strategy="clip_search"}}else if(!(d==="string_end"||d==="string_start"))if(d==="string_end_newline")u(qt(is(qe`(?=\n?\z)`),t));else if(d==="word_boundary"){if(!x&&!m){const w=`(?:(?<=${ss})(?!${ss})|(?<!${ss})(?=${ss}))`,C=`(?:(?<=${ss})(?=${ss})|(?<!${ss})(?!${ss}))`;u(qt(is(f?C:w),t))}}else throw new Error(`Unexpected assertion kind "${d}"`)},Backreference({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n=="string"&&!_m(n)&&(n=xm(n,t),e.ref=n)},CapturingGroup({node:e},{jsGroupNameMap:t,subroutineRefMap:n}){let{name:s}=e;s&&!_m(s)&&(s=xm(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=hu({body:[e]});n(qt(s,t),{traverse:!0})}},CharacterSet({node:e,parent:t,replaceWith:n},{accuracy:s,minTargetEs2024:a,digitIsAscii:l,spaceIsAscii:u,wordIsAscii:c}){const{kind:d,negate:f,value:m}=e;if(l&&(d==="digit"||m==="digit")){n(zs(rp("digit",{negate:f}),t));return}if(u&&(d==="space"||m==="space")){n(qt(ym(is(AP),f),t));return}if(c&&(d==="word"||m==="word")){n(zs(rp("word",{negate:f}),t));return}if(d==="any")n(zs(Ra("Any"),t));else if(d==="digit")n(zs(Ra("Nd",{negate:f}),t));else if(d!=="dot")if(d==="text_segment"){if(s==="strict")throw new Error(qe`Use of "\X" requires non-strict accuracy`);const p="\\p{Emoji}(?:\\p{EMod}|\\uFE0F\\u20E3?|[\\x{E0020}-\\x{E007E}]+\\x{E007F})?",_=qe`\p{RI}{2}|${p}(?:\u200D${p})*`;n(qt(is(qe`(?>\r\n|${a?qe`\p{RGI_Emoji}`:_}|\P{M}\p{M}*)`,{skipPropertyNameValidation:!0}),t))}else if(d==="hex")n(zs(Ra("AHex",{negate:f}),t));else if(d==="newline")n(qt(is(f?`[^
273
+ ]`:`(?>\r
274
+ ?|[
275
+ \v\f…\u2028\u2029])`),t));else if(d==="posix")if(!a&&(m==="graph"||m==="print")){if(s==="strict")throw new Error(`POSIX class "${m}" requires min target ES2024 or non-strict accuracy`);let p={graph:"!-~",print:" -~"}[m];f&&(p=`\0-${an(p.codePointAt(0)-1)}${an(p.codePointAt(2)+1)}-􏿿`),n(qt(is(`[${p}]`),t))}else n(qt(ym(is(MP.get(m)),f),t));else if(d==="property")og.has(dd(m))||(e.key="sc");else if(d==="space")n(zs(Ra("space",{negate:f}),t));else if(d==="word")n(qt(ym(is(ss),f),t));else throw new Error(`Unexpected character set kind "${d}"`)},Directive({node:e,parent:t,root:n,remove:s,replaceWith:a,removeAllPrevSiblings:l,removeAllNextSiblings:u}){const{kind:c,flags:d}=e;if(c==="flags")if(!d.enable&&!d.disable)s();else{const f=vr({flags:d});f.body[0].body=u(),a(qt(f,t),{traverse:!0})}else if(c==="keep"){const f=n.body[0],p=n.body.length===1&&uC(f,{type:"Group"})&&f.body[0].body.length===1?f.body[0]:n;if(t.parent!==p||p.body.length>1)throw new Error(qe`Uses "\K" in a way that's unsupported`);const _=Ci({behind:!0});_.body[0].body=l(),a(qt(_,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(qt(Ci({negate:!0}),t));else throw new Error(`Unsupported named callout "(*${s.toUpperCase()}"`)},Quantifier({node:e}){if(e.body.type==="Quantifier"){const t=vr();t.body[0].body.push(e.body),e.body=qt(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=EC(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(qe`Uses "\G" in a way that requires non-strict accuracy`)}},Subroutine({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n=="string"&&!_m(n)&&(n=xm(n,t),e.ref=n)}},zP={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:d}){const f=a.get(e);if(f&&c.has(e.number)){const p=zs(R0(e.number),t);d.set(p,c.get(e.number)),n(p);return}c.set(e.number,e),u.set(e.number,[]),e.name&&ml(u,e.name,[]);const m=u.get(e.name??e.number);for(let p=0;p<m.length;p++){const _=m[p];if(f===_.node||f&&f===_.origin||e===_.origin){m.splice(p,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 p=ml(l,e.name,new Map);let _=!1;if(f)_=!0;else for(const x of p.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=Du(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 m=t;for(;(m=m.parent)&&!(m.type==="CapturingGroup"&&(m.name===l||m.number===l)););s.reffedNodesByReferencer.set(e,m);return}const u=s.subroutineRefMap.get(l),c=l===0,d=c?R0(0):wC(u,s.groupOriginByCopy,null);let f=d;if(!c){const m=CC(FP(u,_=>_.type==="Group"&&!!_.flags)),p=m?Du(s.globalFlags,m):s.globalFlags;HP(p,s.currentFlags)||(f=vr({flags:VP(p)}),f.body[0].body.push(d))}n(qt(f,t),{traverse:!c})}},$P={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=>UP(u,e));if(!l.length)n(qt(Ci({negate:!0}),t));else if(l.length>1){const u=vr({atomic:!0,body:l.reverse().map(c=>Li({body:[np(c.number)]}))});n(qt(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=hC();e.body.at(-1).body.push(a)}}},Subroutine({node:e},t){!e.isRecursive||e.ref===0||(e.ref=t.reffedNodesByReferencer.get(e).number)}};function SC(e){al(e,{"*"({node:t,parent:n}){t.parent=n}})}function HP(e,t){return e.dotAll===t.dotAll&&e.ignoreCase===t.ignoreCase}function UP(e,t){let n=t;do{if(n.type==="Regex")return!1;if(n.type==="Alternative")continue;if(n===e)return!1;const s=kC(n.parent);for(const a of s){if(a===n)break;if(a===e||jC(a,e))return!0}}while(n=n.parent);throw new Error("Unexpected path")}function wC(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]=wC(u,t,a,n):(l==="type"&&u==="CapturingGroup"&&t.set(a,t.get(e)??e),a[l]=u);return a}function R0(e){const t=mC(e);return t.isRecursive=!0,t}function FP(e,t){const n=[];for(;e=e.parent;)(!t||t(e))&&n.push(e);return n}function xm(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 CC(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 VP({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 kC(e){if(!e)throw new Error("Node expected");const{body:t}=e;return Array.isArray(t)?t:t?[t]:null}function EC(e){const t=e.find(n=>n.kind==="search_start"||qP(n,{negate:!1})||!GP(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=EC(s.body);if(!a)return null;Array.isArray(a)?n.push(...a):n.push(a)}return n}return null}function jC(e,t){const n=kC(e)??[];for(const s of n)if(s===t||jC(s,t))return!0;return!1}function GP({type:e}){return e==="Assertion"||e==="Directive"||e==="LookaroundAssertion"}function WP(e){const t=["Character","CharacterClass","CharacterSet"];return t.includes(e.type)||e.type==="Quantifier"&&e.min&&t.includes(e.body.type)}function qP(e,t){const n={negate:null,...t};return e.type==="LookaroundAssertion"&&(n.negate===null||e.negate===n.negate)&&e.body.length===1&&uC(e.body[0],{type:"Assertion",kind:"search_start"})}function _m(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function is(e,t){const s=dC(e,{...t,unicodePropertyMap:og}).body;return s.length>1||s[0].body.length>1?vr({body:s}):s[0].body[0]}function ym(e,t){return e.negate=t,e}function zs(e,t){return e.parent=t,e}function qt(e,t){return SC(e),e.parent=t,e}function KP(e,t){const n=yC(t),s=ip(n.target,"ES2024"),a=ip(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];al(e,YP,{getCurrentModI:()=>x.at(-1),popModI(){x.pop()},pushModI(w){x.push(w)},setHasCasedChar(){x.at(-1)?u=!0:c=!0}})}const d={dotAll:e.flags.dotAll,ignoreCase:!!((e.flags.ignoreCase||u)&&!c)};let f=e;const m={accuracy:n.accuracy,appliedGlobalFlags:d,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 p(x){return m.lastNode=f,f=x,NP(XP[x.type],`Unexpected node type "${x.type}"`)(x,m,p)}const _={pattern:e.body.map(p).join("|"),flags:p(e.flags),options:{...e.options}};return s||(delete _.options.force.v,_.options.disable.v=!0,_.options.unicodeSetsPlugin=null),_._captureTransfers=new Map,_._hiddenCaptures=[],m.captureMap.forEach((x,w)=>{x.hidden&&_._hiddenCaptures.push(w),x.transferTo&&ml(_._captureTransfers,x.transferTo,[]).push(w)}),_}var YP={"*":{enter({node:e},t){if(M0(e)){const n=t.getCurrentModI();t.pushModI(e.flags?Du({ignoreCase:n},e.flags).ignoreCase:n)}},exit({node:e},t){M0(e)&&t.popModI()}},Backreference(e,t){t.setHasCasedChar()},Character({node:e},t){lg(an(e.value))&&t.setHasCasedChar()},CharacterClassRange({node:e,skip:t},n){t(),NC(e,{firstOnly:!0}).length&&n.setHasCasedChar()},CharacterSet({node:e},t){e.kind==="property"&&bC.has(e.value)&&t.setHasCasedChar()}},XP={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?qe`\B`:qe`\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=an(e),s=ka(e,{escDigit:t.lastNode.type==="Backreference",inCharClass:t.inCharClass,useFlagV:t.useFlagV});if(s!==n)return s;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&lg(n)){const a=vC(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");wr.bugFlagVLiteralHyphenIsRange&&t.useFlagV&&u.some(I0)&&(u=[ud(45),...u.filter(f=>!I0(f))]);const c=()=>`[${a?"^":""}${u.map(n).join(s==="intersection"?"&&":"")}]`;if(!t.inCharClass){if((!t.useFlagV||wr.bugNestedClassIgnoresNegation)&&!a){const m=u.filter(p=>p.type==="CharacterClass"&&p.kind==="union"&&p.negate);if(m.length){const p=vr(),_=p.body[0];return p.parent=l,_.parent=p,u=u.filter(x=>!m.includes(x)),e.body=u,u.length?(e.parent=_,_.body.push(e)):p.body.pop(),m.forEach(x=>{const w=Li({body:[x]});x.parent=w,w.parent=p,p.body.push(w)}),n(p)}}t.inCharClass=!0;const f=c();return t.inCharClass=!1,f}const d=u[0];if(s==="union"&&!a&&d&&((!t.useFlagV||!t.verbose)&&l.kind==="union"&&!(wr.bugFlagVLiteralHyphenIsRange&&t.useFlagV)||!t.verbose&&l.kind==="intersection"&&u.length===1&&d.type!=="CharacterClassRange"))return u.map(n).join("");if(!t.useFlagV&&l.type==="CharacterClass")throw new Error("Uses nested character class in a way that requires min target ES2024");return c()},CharacterClassRange(e,t){const n=e.min.value,s=e.max.value,a={escDigit:!1,inCharClass:!0,useFlagV:t.useFlagV},l=ka(n,a),u=ka(s,a),c=new Set;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase){const d=NC(e);t6(d).forEach(m=>{c.add(Array.isArray(m)?`${ka(m[0],a)}-${ka(m[1],a)}`:ka(m,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?".":"[^]":qe`[^\n]`;if(e==="digit")return t?qe`\D`:qe`\d`;if(e==="property"){if(a.useAppliedIgnoreCase&&a.currentFlags.ignoreCase&&bC.has(n))throw new Error(`Unicode property "${n}" can't be case-insensitive when other chars have specific case`);return`${t?qe`\P`:qe`\p`}{${s?`${s}=`:""}${n}}`}if(e==="word")return t?qe`\W`:qe`\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=Du(u,n));const c=t.map(l).join("|"),d=!a.verbose&&t.length===1&&s.type!=="Quantifier"&&!e&&(!a.useFlagMods||!n)?c:`(?${n6(e,n,a.useFlagMods)}${c})`;return a.currentFlags=u,d},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)+r6(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})`:qe`\g<${t}&R=${s}>`}},QP=new Set(["$","(",")","*","+",".","?","[","\\","]","^","{","|","}"]),JP=new Set(["-","\\","]","^","["]),ZP=new Set(["(",")","-","/","[","\\","]","^","{","|","}","!","#","$","%","&","*","+",",",".",":",";","<","=",">","?","@","`","~"]),O0=new Map([[9,qe`\t`],[10,qe`\n`],[11,qe`\v`],[12,qe`\f`],[13,qe`\r`],[8232,qe`\u2028`],[8233,qe`\u2029`],[65279,qe`\uFEFF`]]),e6=new RegExp("^\\p{Cased}$","u");function lg(e){return e6.test(e)}function NC(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=an(u);if(!lg(c))continue;const d=vC(c).filter(f=>{const m=f.codePointAt(0);return m<s||m>a});if(d.length&&(l.push(...d),n))break}return l}function ka(e,{escDigit:t,inCharClass:n,useFlagV:s}){if(O0.has(e))return O0.get(e);if(e<32||e>126&&e<160||e>262143||t&&s6(e))return e>255?`\\u{${e.toString(16).toUpperCase()}}`:`\\x${e.toString(16).toUpperCase().padStart(2,"0")}`;const a=n?s?ZP:JP:QP,l=an(e);return(a.has(l)?"\\":"")+l}function t6(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 n6(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 r6({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 M0({type:e}){return e==="CapturingGroup"||e==="Group"||e==="LookaroundAssertion"}function s6(e){return e>47&&e<58}function I0({type:e,value:t}){return e==="Character"&&t===45}var $s,ls,ji,Hs,Ni,pl,ap,Ws,i6=(Ws=class extends RegExp{constructor(n,s,a){var t=(...m7)=>(super(...m7),mi(this,pl),mi(this,$s,new Map),mi(this,ls,null),mi(this,ji),mi(this,Hs,null),mi(this,Ni,null),me(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),xr(this,ji,u.source),u instanceof Ws&&(xr(this,$s,kn(u,$s)),xr(this,Hs,kn(u,Hs)),xr(this,Ni,kn(u,Ni)),this.rawOptions=u.rawOptions)}else{const u={hiddenCaptures:[],strategy:null,transfers:[],...a};t(l?"":n,s),xr(this,ji,n),xr(this,$s,o6(u.hiddenCaptures,u.transfers)),xr(this,Ni,u.strategy),this.rawOptions=a??{}}l||xr(this,ls,this)}get source(){return kn(this,ji)||"(?:)"}exec(n){if(!kn(this,ls)){const{lazyCompile:l,...u}=this.rawOptions;xr(this,ls,new Ws(kn(this,ji),this.flags,u))}const s=this.global||this.sticky,a=this.lastIndex;if(kn(this,Ni)==="clip_search"&&s&&a){this.lastIndex=0;const l=Ef(this,pl,ap).call(this,n.slice(a));return l&&(a6(l,a,n,this.hasIndices),this.lastIndex+=a),l}return Ef(this,pl,ap).call(this,n)}},$s=new WeakMap,ls=new WeakMap,ji=new WeakMap,Hs=new WeakMap,Ni=new WeakMap,pl=new WeakSet,ap=function(n){kn(this,ls).lastIndex=this.lastIndex;const s=sv(Ws.prototype,this,"exec").call(kn(this,ls),n);if(this.lastIndex=kn(this,ls).lastIndex,!s||!kn(this,$s).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:d,transferTo:f}=kn(this,$s).get(c)??{};if(d?u.push(null):(u.push(s.length),s.push(a[c]),this.hasIndices&&s.indices.push(l[c])),f&&a[c]!==void 0){const m=u[f];if(!m)throw new Error(`Invalid capture transfer to "${m}"`);if(s[m]=a[c],this.hasIndices&&(s.indices[m]=l[c]),s.groups){kn(this,Hs)||xr(this,Hs,l6(this.source));const p=kn(this,Hs).get(f);p&&(s.groups[p]=a[c],this.hasIndices&&(s.indices.groups[p]=l[c]))}}}return s},Ws);function a6(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 o6(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)ml(n,l,{}).transferTo=s;return n}function l6(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:d}}=l;u==="["?s++:s?u==="]"&&s--:c&&(a++,d&&n.set(a,d))}return n}function c6(e,t){const n=u6(e,t);return n.options?new i6(n.pattern,n.flags,n.options):new RegExp(n.pattern,n.flags)}function u6(e,t){const n=yC(t),s=dC(e,{flags:n.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline},skipBackrefValidation:n.rules.allowOrphanBackrefs,unicodePropertyMap:og}),a=PP(s,{accuracy:n.accuracy,asciiWordBoundaries:n.rules.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,bestEffortTarget:n.target}),l=KP(a,n),u=EP(l.pattern,{captureTransfers:l._captureTransfers,hiddenCaptures:l._hiddenCaptures,mode:"external"}),c=CP(u.pattern),d=wP(c.pattern,{captureTransfers:u.captureTransfers,hiddenCaptures:u.hiddenCaptures}),f={pattern:d.pattern,flags:`${n.hasIndices?"d":""}${n.global?"g":""}${l.flags}${l.options.disable.v?"u":"v"}`};if(n.avoidSubclass){if(n.lazyCompileLength!==1/0)throw new Error("Lazy compilation requires subclass")}else{const m=d.hiddenCaptures.sort((w,C)=>w-C),p=Array.from(d.captureTransfers),_=a._strategy,x=f.pattern.length>=n.lazyCompileLength;(m.length||p.length||_||x)&&(f.options={...m.length&&{hiddenCaptures:m},...p.length&&{transfers:p},..._&&{strategy:_},...x&&{lazyCompile:x}})}return f}function TC(e,t){return c6(e,{global:!0,hasIndices:!0,lazyCompileLength:3e3,rules:{allowOrphanBackrefs:!0,asciiWordBoundaries:!0,captureGroup:!0,recursionLimit:5,singleline:!0},...t})}function d6(e={}){const t={target:"auto",cache:new Map,...e};return t.regexConstructor||(t.regexConstructor=n=>TC(n,{target:t.target})),{createScanner(n){return new jI(n,t)},createString(n){return{content:n}}}}aw(Vp({bundledLanguages:()=>qp,bundledLanguagesAlias:()=>Wp,bundledLanguagesBase:()=>Gp,bundledLanguagesInfo:()=>td,bundledThemes:()=>Yp,bundledThemesInfo:()=>Kp,codeToHast:()=>Zw,codeToHtml:()=>Jw,codeToTokens:()=>eC,codeToTokensBase:()=>tC,codeToTokensWithThemes:()=>nC,createHighlighter:()=>cd,createJavaScriptRegexEngine:()=>d6,createOnigurumaEngine:()=>cw,defaultJavaScriptRegexConstructor:()=>TC,getLastGrammarState:()=>sC,getSingletonHighlighter:()=>rC,loadWasm:()=>Qp}),EI);let vm=null;const h6=["typescript","javascript","tsx","jsx","python","bash","json","css","html","sql","yaml","markdown","diff","rust","go","java","c","cpp","ruby","toml","scss","graphql","docker","powershell"],f6=["github-dark-default","vitesse-light","monokai","dracula","nord"],m6={dark:"github-dark-default",light:"vitesse-light",monokai:"monokai",dracula:"dracula",nord:"nord"};function p6(){return{name:"line-numbers",line(e,t){e.properties["data-line"]=String(t+1)}}}async function g6(){return vm||(vm=cd({themes:f6,langs:h6})),vm}const Ko=new Map,x6=50;function _6(e,t,n){return`${e}|${t}|${n}`}async function AC(e,t,n="github-dark-default"){const s=_6(e,t,n),a=Ko.get(s);if(a)return a;const u=(await g6()).codeToHtml(e,{lang:t,theme:n,transformers:[p6()]});if(Ko.size>=x6){const c=Ko.keys().next().value;c&&Ko.delete(c)}return Ko.set(s,u),u}const y6={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 md(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?y6[s]??"text":"text"}function LC(){const e=Ft(n=>n.currentPreset);return Ft(n=>n.isCustom)?"github-dark-default":m6[e]??"github-dark-default"}function DC(e=2e3){const[t,n]=D.useState(!1),s=D.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 v6=D.memo(function({language:t,codeString:n,showSyntaxHighlighting:s}){const{copied:a,copy:l}=DC(),[u,c]=D.useState(null),d=LC(),f=D.useRef(n);return D.useEffect(()=>{s&&(f.current=n,AC(n,t,d).then(m=>{f.current===n&&c(m)}))},[n,t,d,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:m=>{m.preventDefault(),m.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(Pr,{}):o.jsx(fp,{})})]}),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 b6(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(`
276
+ `)){const p=e?"text-text-muted":"text-accent-secondary";return o.jsx("code",{className:`bg-bg-tertiary px-1 py-0.5 rounded ${p} font-mono text-xs`,...u,children:l})}const f=(c==null?void 0:c[1])||"text",m=String(l).replace(/\n$/,"");return o.jsx(v6,{language:f,codeString:m,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 ds=D.memo(function({content:t,className:n="",muted:s=!1}){const{showSyntaxHighlighting:a}=Pu(),l=D.useMemo(()=>{let c=S6(t);return c=w6(c),c},[t]),u=D.useMemo(()=>b6(s,a),[s,a]);return o.jsx("div",{className:`markdown-content [&_li>p]:inline ${n}`,children:o.jsx(VR,{remarkPlugins:[rO],components:u,children:l})})});function S6(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 w6(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(`
277
+ `),e+"\n```"}return e}const C6=D.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(ds,{content:t})})]}):o.jsx("div",{className:"text-text-muted text-sm italic bg-secondary rounded p-1.5 feed-item",children:o.jsx(ds,{content:t,muted:!0})})});function RC({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=D.memo(function({code:t,language:n,variant:s,showLineNumbers:a=!1,startLine:l=1}){const[u,c]=D.useState(null),d=LC(),f=D.useRef(t);if(D.useEffect(()=>{f.current=t,AC(t,n,d).then(p=>{f.current===t&&c(p)})},[t,n,d]),!u){const p=s==="inline"?"span":s==="block-nowrap"?"div":"pre";return o.jsx(p,{className:"language-",children:o.jsx("code",{className:"language-",children:t})})}if(s==="inline")return o.jsx("span",{dangerouslySetInnerHTML:{__html:u}});const m=a?"":"shiki-plain";return o.jsx("div",{className:m,style:{"--shiki-start":l},dangerouslySetInnerHTML:{__html:u}})});function OC({src:e,alt:t,isOpen:n,onClose:s}){return n?o.jsx(Ot,{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 Ru=D.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})})})}),k6=D.memo(function({oldString:t,newString:n,filePath:s}){const a=D.useMemo(()=>md(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(Ru,{type:"removed",children:o.jsx(za,{code:t,language:a,variant:"block",showLineNumbers:!0})}),u&&o.jsx(Ru,{type:"added",children:o.jsx(za,{code:n,language:a,variant:"block",showLineNumbers:!0})})]})}),E6=D.memo(function({content:t,filePath:n}){const s=D.useMemo(()=>md(n),[n]);return o.jsx("div",{className:"rounded overflow-hidden border border-border max-h-[45vh] overflow-y-auto",children:o.jsx(Ru,{type:"added",children:o.jsx(za,{code:t,language:s,variant:"block",showLineNumbers:!0})})})}),j6=D.memo(function({regions:t,filePath:n}){const s=D.useMemo(()=>md(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(T6,{region:a,language:s},l))})});function N6(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(`
278
+ `);for(let u=0;u<a.length;u++)n("removed",s.startLine+u,a[u]);const l=s.newContent.split(`
279
+ `);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 T6=D.memo(function({region:t,language:n}){const s=N6(t);return o.jsx("div",{className:"rounded overflow-hidden border border-border font-mono text-sm",children:s.map((a,l)=>o.jsx(A6,{section:a,language:n},l))})}),A6=D.memo(function({section:t,language:n}){const s=t.lines.join(`
280
+ `);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(Ru,{type:t.type,children:o.jsx(za,{code:s,language:n,variant:"block",showLineNumbers:!0,startLine:t.startLine})})});function P0(e){return e.split(`
281
+ `).filter(t=>!t.startsWith(`
282
+ [`)&&!t.startsWith("[")).map(t=>t.replace(/^\d+: /,"")).join(`
283
+ `)}const L6=D.memo(function({result:t,metadata:n,filePath:s,heightExpanded:a=!1}){const[l,u]=D.useState(!1),c=D.useMemo(()=>md(s),[s]),d=n==null?void 0:n.mimeType,f=n==null?void 0:n.base64Data;if(d!=null&&d.startsWith("image/")&&f){const C=`data:${d};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:C,alt:s,className:"max-w-full max-h-[45vh] object-contain"})}),o.jsx(OC,{src:C,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 m=t;if(c==="markdown"){const C=P0(m);return o.jsx("div",{className:`rounded overflow-hidden border border-border ${a?"":"max-h-[45vh]"} overflow-y-auto p-2`,children:o.jsx(ds,{content:C})})}const p=P0(m),_=m.split(`
284
+ `)[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:p,language:c,variant:"block",showLineNumbers:!0,startLine:w})})}),D6={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"}},B0=D.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=D6[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)})})]})}),R6=D.memo(function({command:t,timeout:n,startedAt:s,streamingOutput:a,status:l,result:u,error:c,durationMs:d}){const f=D.useRef(null),[m,p]=D.useState(0);D.useEffect(()=>{f.current&&l==="pending"&&(f.current.scrollTop=f.current.scrollHeight)},[a,l]),D.useEffect(()=>{if(l!=="pending"||!s)return;const C=setInterval(()=>{p(Date.now()-s)},100);return()=>clearInterval(C)},[l,s]);const _=n/1e3,x=l==="pending"?m/1e3:(d??0)/1e3,w=l==="pending"?(a==null?void 0:a.map(C=>C.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,m/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((C,v)=>o.jsx("span",{className:C.stream==="stderr"?"text-accent-warning":"",children:xu(C.content)},v)):xu(w)}),l==="error"&&c&&o.jsx("div",{className:"text-xs text-accent-error bg-accent-error/10 p-2 rounded",children:c}),l!=="pending"&&d!==void 0&&o.jsxs("div",{className:"text-[10px] text-text-muted",children:["Completed in ",(d/1e3).toFixed(2),"s"]})]})});function O6(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 M6({confirmation:e}){const t=we(p=>p.confirmPath),n=we(p=>p.currentSession),s=we(p=>p.switchDangerLevel),{title:a,description:l}=O6(e.reason),u=e.reason==="sensitive_file"||e.reason==="both",c=u?"border-red-500/50":"border-amber-500/50",d=u?"bg-red-500/10":"bg-amber-500/10",f=e.reason==="git_no_verify",m=()=>{n!=null&&n.id&&s("dangerous"),t(e.callId,!0,!1)};return o.jsxs("div",{className:`border ${c} ${d} rounded p-3 my-2`,children:[o.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[o.jsx(jm,{}),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((p,_)=>o.jsx("li",{className:`text-xs font-mono ${u?"text-red-300":"text-amber-300"} break-all`,children:p},_))})}),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:m,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 I6(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 z0(e,t,n){return I6(e,t)}function P6(e){return JSON.stringify(e,null,2)}const B6={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}},z6=D.memo(function({tool:t,args:n,status:s,variant:a="compact",forceCompact:l,result:u,error:c,durationMs:d,diagnostics:f,editContext:m,startedAt:p,streamingOutput:_,metadata:x,callId:w}){var G;const C=t==="edit_file"||t==="write_file",v=t==="run_command"&&s==="pending",S=t==="read_file",y=l?!1:C||v||t==="return_value",[E,N]=D.useState(y),T=B6[s],L=on(W=>W.settings[ze.DISPLAY_SHOW_OPEN_IN_EDITOR])==="true",A=t==="edit_file"?(G=m==null?void 0:m.regions[0])==null?void 0:G.startLine:t==="read_file"?(()=>{const W=u==null?void 0:u.split(`
285
+ `)[0],O=W==null?void 0:W.match(/^(\d+): /);return O?parseInt(O[1],10):void 0})():void 0,R=we(W=>W.pendingPathConfirmations),M=s==="pending"&&w?R.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(RC,{tool:t}),o.jsx("span",{className:"text-accent-primary font-medium",children:t}),o.jsx("span",{className:"text-text-muted truncate flex-1",children:z0(t,n)}),o.jsx("span",{className:`${T.color} ${T.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:()=>N(!E),children:[o.jsx("span",{className:`${T.color} ${T.animate?"animate-pulse":""}`,children:T.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:z0(t,n)}),o.jsx("span",{className:"text-text-muted text-xs",children:E?"▼":"▶"})]}),M&&o.jsx(M6,{confirmation:M}),(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(R6,{command:String(n.command??""),timeout:n.timeout??12e4,startedAt:p,streamingOutput:_,status:s,result:u,error:c,durationMs:d}),t==="edit_file"&&s==="success"&&o.jsxs(o.Fragment,{children:[m&&m.regions.length>0?o.jsx(j6,{regions:m.regions,filePath:String(n.path??"")}):o.jsx(k6,{oldString:String(n.old_string??""),newString:String(n.new_string??""),filePath:String(n.path??"")}),f&&f.length>0&&o.jsx(B0,{diagnostics:f})]}),t==="write_file"&&s==="success"&&o.jsxs(o.Fragment,{children:[o.jsx(E6,{content:String(n.content??""),filePath:String(n.path??"")}),f&&f.length>0&&o.jsx(B0,{diagnostics:f})]}),t==="read_file"&&s==="success"&&o.jsx(L6,{result:u,metadata:x,filePath:String(n.path??""),heightExpanded:E}),t==="return_value"&&(()=>{const W=(_==null?void 0:_.map(U=>U.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(ds,{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:P6(n)})]}),s==="success"&&u!==void 0&&o.jsxs("div",{children:[o.jsxs("div",{className:"text-[10px] text-text-muted mb-0.5",children:["Result",d!==void 0&&` (${d}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")&&d!==void 0&&o.jsxs("div",{className:"text-[10px] text-text-muted flex items-center gap-2",children:[o.jsxs("span",{children:["Completed in ",d,"ms"]}),L&&(t==="read_file"||t==="write_file"||t==="edit_file")&&String((x==null?void 0:x.path)??n.path??"")&&o.jsx("a",{href:`vscode://file/${String((x==null?void 0:x.path)??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})]})]})]})}),$6={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"},H6={criteria:"criteria",review_findings:"review findings",todos:"tasks"};function U6(e,t){const n=$6[e];if(!n)return`Preparing ${e}`;if(e==="session_metadata"&&t)try{const a=JSON.parse(t).key;if(a){const l=H6[a]??a;return`${n} ${l}`}}catch{}return n}function F6(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 V6=D.memo(function({name:t,arguments:n}){let a=U6(t,n)+"...";if(t==="run_command"&&n){const l=F6(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(RC,{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})]})})}),G6={pending:{icon:"○",color:"text-text-muted"},in_progress:{icon:"●",color:"text-accent-warning",animate:!0},completed:{icon:"✓",color:"text-accent-success"}},W6=D.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=G6[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"})});function q6({toolCall:e}){var E;const t=we(N=>N.pendingQuestions),n=we(N=>N.answerQuestion),[s,a]=D.useState(""),l=D.useRef(null),u=D.useRef(null),c=t.find(N=>N.callId===e.id),d=e.arguments.question??(c==null?void 0:c.question)??"",f=e.arguments.type??(c==null?void 0:c.type)??"text",m=e.arguments.options??(c==null?void 0:c.options)??void 0,p=e.result!==void 0,_=c!==void 0&&!p,x=((E=e.result)==null?void 0:E.output)??"",w=x==="[user skipped]";D.useEffect(()=>{_&&l.current&&l.current.focus()},[_]),D.useEffect(()=>{_&&u.current&&u.current.scrollIntoView({behavior:"smooth",block:"nearest"})},[_]);const C=D.useCallback(()=>{c&&n(c.callId,s)},[c,s,n]),v=D.useCallback(()=>{c&&n(c.callId,"",!0)},[c,n]),S=D.useCallback(N=>{N.key==="Enter"&&!N.shiftKey&&(N.preventDefault(),C()),N.key==="Escape"&&!N.shiftKey&&(N.preventDefault(),v())},[C,v]),b=D.useCallback(N=>{c&&n(c.callId,N)},[c,n]),y="px-3 py-1.5 text-xs font-medium rounded transition-colors";return o.jsxs("div",{ref:u,className:"my-1",children:[o.jsx("div",{className:"text-sm text-text-primary",children:d}),_&&o.jsx("div",{className:"mt-2 border border-border rounded overflow-hidden",children:o.jsx("div",{className:"p-3 bg-primary space-y-2",children:f==="confirm"?o.jsxs("div",{className:"flex gap-2",children:[o.jsx("button",{onClick:()=>b("yes"),className:`${y} flex-1 bg-accent-success/20 hover:bg-accent-success/30 text-accent-success border border-accent-success/30`,children:"Yes"}),o.jsx("button",{onClick:()=>b("no"),className:`${y} flex-1 bg-accent-error/20 hover:bg-accent-error/30 text-accent-error border border-accent-error/30`,children:"No"}),o.jsx("button",{onClick:v,className:`${y} bg-bg-tertiary hover:bg-bg-tertiary/80 text-text-secondary border border-border`,children:"Skip"})]}):f==="choice"&&m&&m.length>0?o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"flex flex-col gap-1.5",children:m.map(N=>o.jsx("button",{onClick:()=>b(N),className:`${y} text-left w-full bg-bg-tertiary hover:bg-accent-primary/20 text-text-primary border border-border hover:border-accent-primary/50`,children:N},N))}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx("textarea",{ref:l,value:s,onChange:N=>a(N.target.value),onKeyDown:S,placeholder:"Or type your own answer... (Enter to submit)",className:"flex-1 min-h-[36px] max-h-[80px] px-2 py-1.5 bg-bg-tertiary border border-border rounded text-xs text-text-primary placeholder:text-text-muted focus:outline-none focus:ring-2 focus:ring-accent-primary/50 resize-y",rows:1}),o.jsx("button",{onClick:C,disabled:!s.trim(),className:`${y} bg-accent-primary/25 hover:bg-accent-primary/40 text-text-primary disabled:opacity-50 disabled:cursor-not-allowed`,children:"Send"}),o.jsx("button",{onClick:v,className:`${y} bg-bg-tertiary hover:bg-bg-tertiary/80 text-text-secondary border border-border`,children:"Skip"})]})]}):o.jsxs(o.Fragment,{children:[o.jsx("textarea",{ref:l,value:s,onChange:N=>a(N.target.value),onKeyDown:S,placeholder:"Type your answer here... (Enter to submit, Shift+Enter for new line)",className:"w-full min-h-[80px] px-3 py-2 bg-bg-tertiary border border-border rounded text-sm text-text-primary placeholder:text-text-muted focus:outline-none focus:ring-2 focus:ring-accent-primary/50 resize-y",autoFocus:!0}),o.jsxs("div",{className:"flex justify-end gap-2",children:[o.jsx("button",{onClick:v,className:`${y} bg-bg-tertiary hover:bg-bg-tertiary/80 text-text-secondary border border-border`,children:"Skip"}),o.jsx("button",{onClick:C,disabled:!s.trim(),className:`${y} bg-accent-primary/25 hover:bg-accent-primary/40 text-text-primary disabled:opacity-50 disabled:cursor-not-allowed`,children:"Send Answer"})]})]})})}),p&&o.jsx("div",{className:"mt-1 flex items-center gap-2",children:o.jsx("span",{className:`text-xs ${w?"text-amber-400":"text-accent-success"}`,children:w?"Skipped":`Answered: ${x}`})})]})}const $0={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"}},MC=D.memo(function({toolCalls:t,criteria:n}){if(t.length===0)return null;const s=new Map((n==null?void 0:n.map(d=>[d.id,d]))??[]),a=t.find(d=>{var f,m;return d.arguments.action==="get"&&((f=d.result)==null?void 0:f.success)&&((m=d.result)==null?void 0:m.output)}),l=t.some(d=>d.name==="session_metadata"),u={criteria:"Acceptance Criteria",review_findings:"Review Findings",todos:"Tasks"},c=(()=>{if(!l)return"Acceptance Criteria";const d=new Set(t.map(f=>f.arguments.key).filter(Boolean));if(d.size===1){const f=d.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 d=a.result.output;if(d==="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(d).map((m,p)=>o.jsxs("div",{className:`flex items-start gap-2 px-2 py-1.5 ${p>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(ds,{content:`[${m.id}] ${m.description}`})})]},m.id??p))}catch{return t.map((f,m)=>o.jsx(H0,{tc:f,index:m,criteriaMap:s},f.id??m))}})():t.map((d,f)=>o.jsx(H0,{tc:d,index:f,criteriaMap:s},d.id??f))})]})});function H0({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,d=a.description,f=c?n.get(c):void 0,m=d??(f==null?void 0:f.description)??(u&&c?`[${c}]`:"Criterion updated"),p=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(Ku,{status:a.status,className:"text-sm leading-tight flex-shrink-0"}):(()=>{const x=s&&$0[s]?$0[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(ds,{content:m})}),p&&o.jsxs("div",{className:`mt-1 text-sm ${_?"text-accent-error":"text-text-muted"}`,children:[o.jsx("span",{className:"text-text-muted",children:"└ "}),'"',p,'"']})]})]})}function K6(e){return e==="criterion"||e==="session_metadata"}function Y6(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"&&K6(a.toolCall.name)?n.push(a.toolCall):(s(),t.push(a));return s(),t}function X6(e,t){if(e.segments&&e.segments.length>0)return Q6(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 Q6(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 d=u.get(c.toolCallId);d&&l.push({type:"tool_call",toolCall:d});break}}for(const c of n)l.push({type:"preparing_tool_call",preparing:c});return a&&s&&l.push({type:"stats",stats:s}),l}const cg=D.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=gt(_=>_.defaults),c=gt(_=>_.userItems),d=[...u,...c],f=X6(t,n),m=s?f:f.filter(_=>_.type!=="thinking"),p=Y6(m);return p.length===0?null:o.jsx("div",{className:"feed-item",children:o.jsxs("div",{className:"min-w-0",children:[p.map((_,x)=>{var w,C;switch(_.type){case"thinking":return o.jsx(C6,{content:_.content},x);case"text":return o.jsx("div",{className:"prose prose-sm prose-invert max-w-none",children:o.jsx(ds,{content:_.content})},x);case"preparing_tool_call":return o.jsx(V6,{name:_.preparing.name,arguments:_.preparing.arguments},`preparing-${_.preparing.index}`);case"tool_call":{const v=_.toolCall,S=v.result;if(v.name==="ask_user")return o.jsx(q6,{toolCall:v},x);if(v.name==="todo_write"){const E=v.arguments.todos,N=Array.isArray(E)?E:[];return o.jsx(W6,{todos:N},x)}const b=(w=S==null?void 0:S.output)==null?void 0:w.includes("[interrupted by user]"),y=S?b?"interrupted":S.success?"success":"error":"pending";return o.jsx(z6,{tool:v.name,args:v.arguments,status:y,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:v.startedAt,streamingOutput:v.streamingOutput,metadata:S==null?void 0:S.metadata,callId:v.id},x)}case"criteria_group":return o.jsx(MC,{toolCalls:_.toolCalls,criteria:l},x);case"stats":{const v=_.stats;if(!v||"error"in v)return null;const S=((C=v.model.split("/").pop())==null?void 0:C.split("-").slice(0,2).join("-"))??v.model,b=ol(d,v.mode),y=N=>N>=1e3?`${(N/1e3).toFixed(1)}k`:N.toString(),E=N=>N>=1e3?`${(N/1e3).toFixed(1)}k`:N.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:b},children:v.mode}),o.jsx("span",{className:"text-text-muted",children:"·"}),o.jsxs("span",{children:[v.totalTime.toFixed(1),"s"]}),v.toolTime>0&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"text-text-muted",children:"·"}),o.jsxs("span",{children:[v.toolTime.toFixed(1),"s tools"]})]}),o.jsx("span",{className:"text-text-muted",children:"·"}),o.jsxs("span",{children:[y(v.prefillTokens)," @ ",E(v.prefillSpeed)," pp"]}),o.jsx("span",{className:"text-text-muted",children:"·"}),o.jsxs("span",{children:[y(v.generationTokens)," @ ",E(v.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 N=new CustomEvent("open-turn-stats",{detail:{stats:v}});window.dispatchEvent(N)},children:o.jsx(CS,{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(jm,{}),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(jm,{}),o.jsx("span",{children:"Response was truncated — the model ran out of output tokens."})]})]})})});function Ou(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 J6(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 Z6(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}const eB=D.memo(function({data:t}){var u;const n=jt(c=>c.defaults),s=jt(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:Ou(l,.3),backgroundColor:Ou(l,.08)},children:[o.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[o.jsx($j,{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:J6(t.totalTimeSeconds)}),o.jsx(Yo,{label:"Tool calls",value:String(t.totalToolCalls)}),o.jsx(Yo,{label:"Tokens",value:Z6(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 tB=D.memo(function({data:t}){var u;const n=jt(c=>c.defaults),s=jt(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:Ou(l,.3),backgroundColor:Ou(l,.08)},children:[o.jsx(Oj,{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 nB({attachments:e,messageId:t}){const[n,s]=D.useState(null),a=we(m=>m.visionFallbackByMessage),l=we(m=>m.messages),u=D.useMemo(()=>{const m=l.findIndex(p=>p.id===t);if(m===-1)return null;for(let p=m+1;p<l.length;p++){const _=l[p];if(_&&_.role==="assistant")return _.id}return null},[l,t]),c=m=>{s(m)},d=()=>{s(null)},f=m=>{const p=`${t}-${m}`;if(a[p])return a[p];if(u){const _=`${u}-${m}`;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(m=>{const p=f(m.id);return o.jsxs("div",{className:"relative inline-block",children:[o.jsxs("button",{onClick:()=>c(m.data),className:"group relative inline-block",title:m.filename,disabled:(p==null?void 0:p.type)==="start",children:[o.jsx("img",{src:m.data,alt:m.filename,className:"max-w-[256px] max-h-[256px] object-contain rounded-lg border border-border hover:border-accent-primary transition-colors cursor-pointer"}),(p==null?void 0:p.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..."})})]}),(p==null?void 0:p.type)==="done"&&p.description&&o.jsxs("div",{className:"mt-2 p-2 bg-bg-tertiary rounded text-xs text-text-secondary max-w-[256px]",children:[p.description.slice(0,200),p.description.length>200?"...":""]})]},m.id)})}),n&&o.jsx(OC,{src:n,alt:"Attached image",isOpen:!0,onClose:d})]})}function rB({content:e,align:t="right",messageIndex:n,sessionId:s}){const[a,l]=D.useState(!1),[u,c]=D.useState(!1),[d,f]=D.useState("left"),m=D.useRef(null),p=D.useRef(null),_=we(S=>S.loadSession),x=t==="right",w=()=>{if(!p.current)return"left";const S=p.current.getBoundingClientRect(),b=window.innerWidth-S.right,y=S.left,E=160,N=b>=E,T=y>=E;return T&&N||T?"left":N?"right":y>=b?"left":"right"};D.useEffect(()=>{const S=b=>{m.current&&!m.current.contains(b.target)&&l(!1)};return a&&document.addEventListener("mousedown",S),()=>document.removeEventListener("mousedown",S)},[a]);const C=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)}},v=async()=>{!s||n===void 0||(l(!1),await w2(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(Pr,{className:"w-4 h-4 text-accent-success"}),o.jsxs("div",{ref:m,className:"relative",children:[o.jsx("button",{ref:p,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(mp,{})}),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 ${d==="right"?"left-0":"right-0"}`,children:[o.jsxs("button",{onClick:C,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(fp,{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:v,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(pp,{className:"w-4 h-4"}),"Replay"]})]})]})]})]})})}function sB({message:e}){const[t,n]=D.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",d={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:d}),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(Ot,{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 iB({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(rB,{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(nB,{attachments:e.attachments,messageId:e.id})]})]})}const IC=D.memo(function({message:t,isLastAssistantMessage:n=!1,messageIndex:s,sessionId:a}){const l=t.role==="user",u=t.role==="assistant",c=t.role==="system",d=t.role==="tool";if(u)return o.jsx(cg,{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]
286
+ `,"")})]});if(d)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(tB,{data:f})}catch{}if(t.messageKind==="task-completed")try{const f=JSON.parse(t.content);return o.jsx(eB,{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(sB,{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(iB,{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(ds,{content:t.content})})})}),aB={verifier:"Verification",code_reviewer:"Code Review",test_generator:"Test Generation",debugger:"Debug"};function oB(e){return{backgroundColor:`${e}20`,color:e,borderColor:`${e}4d`}}function U0(e,t){return t||e>85?"text-accent-error":e>60?"text-accent-warning":"text-text-muted"}function lB({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:U0(l,a),children:[pu(t),"/",pu(n)]}),o.jsxs("span",{className:U0(l,a),children:["(",l,"%)"]}),o.jsx(t1,{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 cB=D.memo(function({messages:t,subAgentType:n,subAgentId:s,isStreaming:a}){const l=D.useRef(null),u=D.useRef(null),[c,d]=D.useState(!1),f=gt(L=>L.defaults),m=gt(L=>L.userItems),p=[...f,...m],_=we(L=>L.subAgentContextStates[s]),{showThinking:x,showVerboseToolOutput:w}=Pu(),{isAutoScrollActive:C,setAutoScroll:v}=Yu(u,null);D.useEffect(()=>{a||v(!0)},[a]);const S=D.useCallback(()=>{const L=!c;d(L),L&&setTimeout(()=>{var A;(A=l.current)==null||A.scrollIntoView({block:"start",behavior:"smooth"})},220)},[c]),b=p.find(L=>L.id===n),y=(b==null?void 0:b.name)??aB[n]??n,E=ol(p,n),N=oB(E),T=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:N,children:[o.jsx("span",{className:"text-xs font-medium",children:y}),o.jsx("div",{className:"absolute left-1/2 -translate-x-1/2",children:_&&o.jsx(lB,{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:()=>v(!C),children:[o.jsx("span",{className:`w-1 h-1 rounded-full ${C?"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:T.map(L=>L.role==="assistant"?o.jsx(cg,{message:L,showStats:!0,showThinking:x,showVerboseToolOutput:w},L.id):o.jsx(IC,{message:L,isLastAssistantMessage:!1},L.id))})]})});function PC(e,t,n=!0){D.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 uB=[],dB=D.memo(function({displayItems:t,scrollContainerRef:n,highlightedMessageId:s}){const a=we(R=>{var M,G;return((G=(M=R.currentSession)==null?void 0:M.metadataEntries)==null?void 0:G.criteria)??uB}),l=we(R=>{var M;return(M=R.currentSession)==null?void 0:M.id}),u=we(R=>{var M;return(M=R.currentSession)==null?void 0:M.mode}),c=we(R=>{var M;return(M=R.currentSession)==null?void 0:M.phase}),d=we(R=>R.error),f=we(R=>R.clearError),m=we(R=>R.acceptAndBuild),p=$u(),{showThinking:_,showVerboseToolOutput:x,showStats:w,showAgentDefinitions:C,showWorkflowBars:v}=Pu(),S=jt(R=>R.defaults),b=jt(R=>R.userItems),y=[...S,...b],E=u==="planner",N=a.length>0,T=c==="done",L=t.some(R=>R.type==="message"&&R.message.role==="assistant"),A=E&&N&&!p&&L&&!T;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((R,M)=>{if(R.type==="context-divider")return o.jsxs("div",{"data-item-index":M,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"})]},M);if(R.type==="subagent"){const U=R.messages.some(V=>V.isStreaming);return o.jsx("div",{"data-item-index":M,className:"px-2 md:px-4",children:o.jsx(cB,{messages:R.messages,subAgentType:R.subAgentType,subAgentId:R.subAgentId,isStreaming:U})},M)}if(R.type==="criteria-batch")return o.jsx("div",{"data-item-index":M,className:"feed-item px-2 md:px-4",children:o.jsx(MC,{toolCalls:R.toolCalls,criteria:a})},M);const G=R.message;if(G.role==="assistant")return o.jsx("div",{"data-item-index":M,className:"px-2 md:px-4",children:o.jsx(cg,{message:G,showStats:w,showThinking:_,showVerboseToolOutput:x})},M);const W=!C&&G.messageKind==="auto-prompt",O=!v&&(G.messageKind==="workflow-started"||G.messageKind==="task-completed");return W||O?null:o.jsx("div",{"data-item-index":M,className:"px-2 md:px-4",children:o.jsx("div",{"data-message-id":G.id,className:s===G.id?"rounded animate-highlight-fade":void 0,children:o.jsx(IC,{message:G,messageIndex:M,sessionId:l,isLastAssistantMessage:!1})})},M)})}),o.jsxs("div",{className:"px-2 md:px-4 pb-4",children:[d&&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:d.code}),o.jsx("div",{className:"text-red-300 text-xs mt-0.5",children:d.message})]}),o.jsx(bl,{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:y.map(R=>{const M=R.color??"#3b82f6",G=parseInt(M.slice(1,3),16),W=parseInt(M.slice(3,5),16),O=parseInt(M.slice(5,7),16),U=`rgba(${G},${W},${O},0.12)`,V=`rgba(${G},${W},${O},0.22)`,z=`rgba(${G},${W},${O},0.25)`;return o.jsx(hB,{workflowName:R.name,color:M,bg:U,bgHover:V,border:z,subGroups:R.subGroups,onLaunch:X=>m(R.id,void 0,void 0,X)},R.id)})})]})]})});function hB({workflowName:e,color:t,bg:n,bgHover:s,border:a,subGroups:l,onLaunch:u}){const[c,d]=D.useState(!1),f=D.useRef(null);return PC(f,()=>d(!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:m=>{m.currentTarget.style.backgroundColor=s},onMouseLeave:m=>{m.currentTarget.style.backgroundColor=n},children:["▶ ",e]}),l&&l.length>0&&o.jsxs("div",{ref:f,className:"relative",children:[o.jsx("button",{onClick:()=>d(!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:m=>{m.currentTarget.style.backgroundColor=s},onMouseLeave:m=>{m.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(),d(!1)},className:"w-full text-left px-3 py-2 text-sm text-text-primary hover:bg-bg-tertiary transition-colors",children:"Full workflow"}),o.jsx("div",{className:"border-t border-border/50"}),l.map(m=>o.jsx("button",{onClick:()=>{u(m),d(!1)},className:"w-full text-left px-3 py-2 text-sm text-text-primary hover:bg-bg-tertiary transition-colors",children:m},m))]})]})]})}function fB(){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:`
287
+ flex items-center justify-between px-4 py-2
288
+ text-sm font-medium
289
+ ${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"}
290
+ `,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(Uj,{}),o.jsx("span",{children:"Connection lost"})]})}),o.jsx("button",{onClick:()=>t(),disabled:n,className:`
291
+ px-3 py-1 rounded text-xs font-medium
292
+ transition-colors
293
+ ${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"}
294
+ `,children:n?"Reconnecting...":"Reconnect"})]})}const en=Yn((e,t)=>({defaults:[],userItems:[],projectItems:[],loading:!1,fetchCommands:async()=>{await yp("/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 qs("POST","/api/commands",{...n,destination:s});return a.success&&await t().fetchCommands(),a},updateCommand:async(n,s)=>{const a=await qs("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)=>zu(`/api/commands/${n}/duplicate`,()=>t().fetchCommands(),s)}));function mB(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function pB({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(fu,{})})}function BC({isOpen:e,onClose:t,initialEditId:n}){const s=en(ce=>ce.defaults),a=en(ce=>ce.userItems),l=en(ce=>ce.projectItems),u=en(ce=>ce.loading),c=en(ce=>ce.fetchCommands),d=en(ce=>ce.fetchCommand),f=en(ce=>ce.fetchDefaultContent),m=en(ce=>ce.createCommand),p=en(ce=>ce.updateCommand),_=en(ce=>ce.deleteCommand),[x,w]=D.useState(null),[C,v]=D.useState(null),{view:S,editingId:b,formError:y,saving:E,formData:N,setView:T,setEditingId:L,setFormError:A,setFormData:R,setSaving:M}=IS(),{requestDelete:G,clearConfirm:W,isConfirming:O}=Fu(),U=D.useRef(!1),V=gt(ce=>ce.defaults),z=gt(ce=>ce.userItems),X=gt(ce=>ce.fetchAgents),H=[...V,...z].filter(ce=>!ce.subagent),I=D.useRef(c),$=D.useRef(X),F=D.useRef(d),P=D.useRef(f),ee=D.useRef(n),J=D.useRef(T),re=D.useRef(L),Y=D.useRef(A),q=D.useRef(W);D.useEffect(()=>{I.current=c,$.current=X,F.current=d,P.current=f,ee.current=n,J.current=T,re.current=L,Y.current=A,q.current=W}),D.useEffect(()=>{if(e)if(I.current(),$.current(),U.current||(q.current(),U.current=!0),ee.current){const ce=s.some(Se=>Se.id===ee.current);J.current("edit"),re.current(ee.current),Y.current(""),ce?P.current(ee.current).then(Se=>{Se&&R({name:Se.metadata.name+" (copy)",id:`${ee.current}-copy-${Date.now()}`,prompt:Se.prompt,agentMode:Se.metadata.agentMode??"",isDefault:!0,destination:"user"})}):F.current(ee.current).then(Se=>{Se&&R({name:Se.metadata.name,id:Se.metadata.id,prompt:Se.prompt,agentMode:Se.metadata.agentMode??"",isDefault:!1,destination:"user"})})}else J.current("list"),re.current(null);else U.current=!1},[e]);const Z=async ce=>{w(ce);const Se=await f(ce);v((Se==null?void 0:Se.prompt)??null)},ae=async ce=>{if(s.some(Ze=>Ze.id===ce)){const Ze=await f(ce);Ze&&(L(null),R({name:`${Ze.metadata.name} (copy)`,id:`${ce}-copy-${Date.now()}`,prompt:Ze.prompt,agentMode:Ze.metadata.agentMode??"",isDefault:!0,destination:"user"}),A(""),T("edit"))}else{const Ze=await d(ce);Ze&&(L(null),R({name:`${Ze.metadata.name} (copy)`,id:`${ce}-copy-${Date.now()}`,prompt:Ze.prompt,agentMode:Ze.metadata.agentMode??"",isDefault:!1,destination:"user"}),A(""),T("edit"))}},se=()=>{R({name:"",id:"",prompt:"",agentMode:"",isDefault:!1,destination:"user"}),L(null),T("edit")},oe=async ce=>{const Se=await d(ce);Se&&(L(ce),R({name:Se.metadata.name,id:Se.metadata.id,prompt:Se.prompt,agentMode:Se.metadata.agentMode??"",isDefault:!1,destination:"user"}),A(""),T("edit"))},je=async ce=>{await _(ce),W()},Le=async()=>{const ce=b??N.id;if(!ce||!N.name||!N.prompt){A("Name and message are required.");return}M(!0),A("");const Se={metadata:{id:ce,name:N.name,...N.agentMode?{agentMode:N.agentMode}:{}},prompt:N.prompt},Ze=b?await p(b,Se):await m(Se,N.destination);if(M(!1),!Ze.success){A(Ze.error??"Failed to save command.");return}n?t():T("list")},De=()=>{n?t():(T("list"),w(null),v(null))},Re=ce=>{R(Se=>({...Se,name:ce})),(!b||N.isDefault)&&R(Se=>({...Se,id:mB(ce)}))},Te=()=>{w(null),v(null),T("list")},Ae=()=>{x&&(w(null),T("edit"),L(x),f(x).then(ce=>{ce&&R({name:`${ce.metadata.name} (copy)`,id:`${x}-copy-${Date.now()}`,prompt:ce.prompt,agentMode:ce.metadata.agentMode??"",isDefault:!0,destination:"user"})}))};if(x){const ce=s.find(Se=>Se.id===x);return o.jsx(Ot,{isOpen:e,onClose:Te,title:`Default: ${(ce==null?void 0:ce.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:ce==null?void 0:ce.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:(ce==null?void 0:ce.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:C??"",readOnly:!0,placeholder:"...",className:"flex-1 w-full px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono resize-none opacity-60"})]}),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:Te,children:"Close"}),o.jsx(tt,{variant:"primary",onClick:Ae,children:"Duplicate & Customize"})]})]})})}if(S==="edit")return o.jsx(Ot,{isOpen:e,onClose:De,title:b?"Edit Command":"New Command",size:"xl",children:o.jsxs("div",{className:"flex flex-col h-full",children:[y&&o.jsx(Vu,{message:y}),o.jsxs("div",{className:"space-y-3 mb-3",children:[o.jsx(MS,{name:N.name,id:N.id,nameLabel:"Name",idLabel:"ID",namePlaceholder:"My Command",idPlaceholder:"my-command",readOnlyId:!!b&&!N.isDefault,onNameChange:Re,onIdChange:ce=>R(Se=>({...Se,id:ce}))}),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:N.agentMode,onChange:ce=>R(Se=>({...Se,agentMode:ce.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)"}),H.map(ce=>o.jsx("option",{value:ce.id,children:ce.name},ce.id))]})]}),!b&&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:N.destination,onChange:ce=>R(Se=>({...Se,destination:ce.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:N.prompt,onChange:ce=>R(Se=>({...Se,prompt:ce.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:De,children:"Cancel"}),o.jsx(tt,{variant:"primary",onClick:Le,disabled:E||!N.name||!N.prompt,children:E?"Saving...":"Save"})]})]})});const pe=ce=>ce.map(Se=>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:Se.name})})}),o.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[o.jsx(Vs,{onClick:()=>oe(Se.id)}),o.jsx(mu,{onClick:()=>ae(Se.id)}),O(Se.id,"delete")?o.jsx(vp,{onConfirm:()=>je(Se.id),onCancel:W}):o.jsx(bp,{onClick:()=>G(Se.id)})]})]},Se.id));return o.jsxs(Ot,{isOpen:e,onClose:t,title:"Commands",size:"lg",children:[o.jsx(Sp,{description:"Commands are pre-defined messages you can send with a single click.",onNew:se}),o.jsxs(wp,{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(ce=>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:ce.name})}),o.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[o.jsx(pB,{onClick:()=>Z(ce.id)}),o.jsx(mu,{onClick:()=>ae(ce.id)})]})]},ce.id))})]}),a.length>0&&o.jsx(RS,{children:pe(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:pe(l)})]})]})]})}const _i=150,as=54,iu=80,_r=30,Ea=70,F0=100,yi=50,au=50,V0=4,zC={step_result:"Result",metadata_all_match:"Metadata match",metadata_all_in:"Metadata in",always:"otherwise"},$C=[{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)"}],gB=[{value:"agent",label:"Agent"},{value:"sub_agent",label:"Sub-Agent"},{value:"shell",label:"Shell"}];function ug(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 xB(e,t,n,s){const a=au+yi+_i+F0+_i+yi+au,l=a/2,u=au+yi+_i/2,c=au+yi+_i+F0+_i/2,d=[],f=[],m=new Map,p=e.filter(V=>V.type==="agent"||V.type==="shell"),_=e.filter(V=>V.type==="sub_agent"),x=_.length>0,w=x?u:l,C=p.length>0?c:l,v=yi+_r/2;d.push({id:"$start",type:"terminal",label:"Start",cx:w,cy:v,w:iu,h:_r}),m.set("$start",{cx:w,cy:v,w:iu,h:_r});const S=V=>{d.push({id:"$done",type:"terminal",label:"Done",cx:w,cy:V,w:iu,h:_r}),m.set("$done",{cx:w,cy:V,w:iu,h:_r})};if(e.length===0){const V=v+_r/2+Ea*2+_r/2;return S(V),{nodes:d,edges:f,width:a,height:V+_r/2+yi,posMap:m}}const b=v+_r/2+Ea,y=(V,z)=>{V.forEach((X,te)=>{const H=b+te*(as+Ea)+as/2,{name:I,color:$}=ug(X,s);d.push({id:X.id,type:"step",label:I,color:$,cx:z,cy:H,w:_i,h:as}),m.set(X.id,{cx:z,cy:H,w:_i,h:as})})};y(p,w),y(_,C);const E=p.length>0?b+(p.length-1)*(as+Ea)+as/2:v,N=x?b+(_.length-1)*(as+Ea)+as/2:v,T=Math.max(E,N)+as/2+Ea+_r/2;S(T);const L=[];t&&m.has(t)&&L.push({from:"$start",to:t,label:n,edgeKey:"start",direction:"down",backEdgeIndex:0});let A=0;for(const V of e)V.transitions.forEach((z,X)=>{var P;if(!z.goto||!m.has(z.goto))return;const te=m.get(V.id),H=m.get(z.goto),I=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 [${((P=z.when.values)==null?void 0:P.join(","))??"?"}]`:zC[z.when.type]??z.when.type,$=V.id===z.goto;let F;$?F="back":H.cy>te.cy+1?F="down":H.cy<te.cy-1?F="back":F="same",L.push({from:V.id,to:z.goto,label:I,edgeKey:`${V.id}:${X}`,direction:F,backEdgeIndex:F==="back"?A++:0})});const R=new Map,M=new Map,G=new Map,W=new Map;for(const V of L)V.direction==="down"&&(R.set(V.from,(R.get(V.from)??0)+1),M.set(V.to,(M.get(V.to)??0)+1));const O=new Map,U=new Map;for(const V of L){if(V.direction!=="same")continue;const z=[V.from,V.to].sort().join("|");O.set(z,(O.get(z)??0)+1)}for(const V of L){if(V.direction==="back"||V.direction==="same"){let F=0;if(V.direction==="same"){const P=[V.from,V.to].sort().join("|");F=U.get(P)??0,U.set(P,F+1)}f.push({...V,fromPort:0,toPort:0,sameEdgeIndex:F});continue}const z=R.get(V.from)??1,X=M.get(V.to)??1,te=G.get(V.from)??0,H=W.get(V.to)??0;G.set(V.from,te+1),W.set(V.to,H+1);const I=z===1?0:-.6+1.2*te/(z-1),$=X===1?0:-.6+1.2*H/(X-1);f.push({...V,fromPort:I,toPort:$,sameEdgeIndex:0})}return{nodes:d,edges:f,width:a,height:T+_r/2+yi,posMap:m}}function _B({steps:e,entryStep:t,selectedNodeId:n,selectedEdgeKey:s,startConditionLabel:a,agentTypes:l,isReadOnly:u,onSelectNode:c,onSelectEdge:d,onRemoveStep:f,onCreateTransition:m,onReconnectTo:p,onReconnectFrom:_,onDeleteTransition:x}){const w=D.useRef(null),C=D.useRef(!1),[v,S]=D.useState(null),[b,y]=D.useState(null),[E,N]=D.useState(null),{nodes:T,edges:L,width:A,height:R,posMap:M}=D.useMemo(()=>xB(e,t,a,l),[e,t,a,l]),G=D.useCallback(J=>{var ae;const re=w.current;if(!re)return{x:0,y:0};const Y=re.createSVGPoint();Y.x=J.clientX,Y.y=J.clientY;const q=(ae=re.getScreenCTM())==null?void 0:ae.inverse();if(!q)return{x:0,y:0};const Z=Y.matrixTransform(q);return{x:Z.x,y:Z.y}},[]),W=D.useCallback(J=>!J||!b||J==="$start"?!1:b.type==="reconnect-from"?J!=="$done":!0,[b]),O=D.useCallback((J,re)=>{if(u)return;J.stopPropagation(),J.preventDefault();const Y=G(J);y({type:"new",fromNodeId:re,mouseX:Y.x,mouseY:Y.y})},[G,u]),U=D.useCallback((J,re)=>{if(u)return;J.stopPropagation(),J.preventDefault();const Y=G(J);y({type:"reconnect-to",fromNodeId:re.from,edgeKey:re.edgeKey,mouseX:Y.x,mouseY:Y.y})},[G,u]),V=D.useCallback((J,re)=>{if(u)return;J.stopPropagation(),J.preventDefault();const Y=G(J);y({type:"reconnect-from",fromNodeId:re.from,fixedTargetId:re.to,edgeKey:re.edgeKey,mouseX:Y.x,mouseY:Y.y})},[G,u]),z=D.useCallback(J=>{if(!b)return;const re=G(J);y(Y=>Y?{...Y,mouseX:re.x,mouseY:re.y}:null)},[b,G]),X=D.useCallback(()=>{b&&(C.current=!0,E&&W(E)&&(b.type==="new"?m(b.fromNodeId,E):b.type==="reconnect-to"?p(b.edgeKey,E):b.type==="reconnect-from"&&_(b.edgeKey,E)),y(null),N(null))},[b,E,W,m,p,_]),te=D.useCallback(()=>{if(C.current){C.current=!1;return}c(null),d(null)},[c,d]);D.useEffect(()=>{if(u)return;const J=re=>{re.target instanceof HTMLInputElement||re.target instanceof HTMLTextAreaElement||re.target instanceof HTMLSelectElement||(re.key==="Delete"||re.key==="Backspace")&&s&&s!=="start"&&(re.preventDefault(),x(s),d(null))};return document.addEventListener("keydown",J),()=>document.removeEventListener("keydown",J)},[u,s,x,d]);const H=J=>{const re=M.get(J.from),Y=M.get(J.to);if(!re||!Y)return null;let q,Z,ae,se="middle",oe,je;if(J.direction==="down"){const Le=re.cx+J.fromPort*(re.w/2-10),De=re.cy+re.h/2,Re=Y.cx+J.toPort*(Y.w/2-10),Te=Y.cy-Y.h/2,Ae=Te-De,pe=Re-Le;q=`M ${Le} ${De} C ${Le} ${De+Ae*.4}, ${Re-pe*.2} ${Te-Ae*.1}, ${Re} ${Te}`,Z=Le+(Re-Le)*.5,ae=De+Ae*.6,oe={x:Le,y:De},je={x:Re,y:Te}}else if(J.direction==="back"){const Le=J.from===J.to,De=re.cx>=A/2,Re=J.backEdgeIndex*16,Te=De?A-20-Re:20+Re;if(Le){const Ae=re.cx>=A/2,pe=30+J.backEdgeIndex*14,ce=re.cy-re.h/2,Se=Ae?re.cx+re.w/2:re.cx-re.w/2,Ze=Ae?Se+pe:Se-pe,_t=re.cx+(Ae?re.w/4:-re.w/4),dt=ce-20-J.backEdgeIndex*10;q=`M ${Se} ${re.cy} C ${Ze} ${re.cy}, ${Ze} ${dt}, ${_t} ${ce}`,Z=Ze+10,ae=dt+4,se="middle",oe={x:Se,y:re.cy},je={x:_t,y:ce}}else{const Ae=De?re.cx+re.w/2:re.cx-re.w/2,pe=Y.cx+(De?Y.w/4:-Y.w/4),ce=Math.min(re.cy,Y.cy)-Y.h/2-18-J.backEdgeIndex*14;q=`M ${Ae} ${re.cy} L ${Te} ${re.cy} L ${Te} ${ce} L ${pe} ${ce} L ${pe} ${Y.cy-Y.h/2}`,Z=Te,ae=(re.cy+ce)/2,se=De?"start":"end",oe={x:Ae,y:re.cy},je={x:pe,y:Y.cy-Y.h/2}}}else{const Le=Y.cx>re.cx,De=J.sameEdgeIndex===0?-12:12,Re=Le?re.cx+re.w/2:re.cx-re.w/2,Te=Le?Y.cx-Y.w/2:Y.cx+Y.w/2,Ae=re.cy+De,pe=Y.cy+De,ce=(Re+Te)/2;q=`M ${Re} ${Ae} C ${ce} ${Ae}, ${ce} ${pe}, ${Te} ${pe}`,Z=ce,ae=(Ae+pe)/2-6,oe={x:Re,y:Ae},je={x:Te,y:pe}}return{path:q,labelX:Z,labelY:ae,labelAnchor:se,fromPt:oe,toPt:je}},I=(J,re)=>{const Y=H(J);if(!Y)return null;const{path:q,labelX:Z,labelY:ae,labelAnchor:se}=Y,oe=s===J.edgeKey,je=J.label&&J.label!=="otherwise";return o.jsxs("g",{children:[o.jsx("path",{d:q,fill:"none",stroke:"transparent",strokeWidth:14,className:"cursor-pointer",onClick:Le=>{Le.stopPropagation(),u||d(oe?null:J.edgeKey)}}),o.jsx("path",{d:q,fill:"none",stroke:oe?"#58a6ff":"#484f58",strokeWidth:oe?2.2:1.2,markerEnd:oe?"url(#arrow-selected)":"url(#arrow)",pointerEvents:"none"}),je&&o.jsx("text",{x:Z+(se==="start"?5:se==="end"?-5:0),y:ae+3,textAnchor:se,className:"text-[8px]",fill:oe?"#79c0ff":"#8b949e",style:{paintOrder:"stroke",stroke:"#0d1117",strokeWidth:3,strokeLinejoin:"round"},pointerEvents:"none",children:J.label})]},re)},$=()=>{if(!s||b)return null;const J=L.find(ae=>ae.edgeKey===s);if(!J)return null;const re=H(J);if(!re)return null;const{fromPt:Y,toPt:q}=re,Z=6;return o.jsxs(o.Fragment,{children:[J.edgeKey!=="start"&&o.jsx("circle",{cx:Y.x,cy:Y.y,r:Z,fill:"#58a6ff",fillOpacity:.25,stroke:"#58a6ff",strokeWidth:2,strokeOpacity:.8,className:"cursor-grab",onMouseDown:ae=>V(ae,J)}),o.jsx("circle",{cx:q.x,cy:q.y,r:Z,fill:"#58a6ff",fillOpacity:.25,stroke:"#58a6ff",strokeWidth:2,strokeOpacity:.8,className:"cursor-grab",onMouseDown:ae=>U(ae,J)})]})},F=()=>{if(!b)return null;let J,re,Y,q;if(b.type==="reconnect-from"){const se=M.get(b.fixedTargetId);if(!se)return null;J=b.mouseX,re=b.mouseY,Y=se.cx,q=se.cy-se.h/2}else{const se=M.get(b.fromNodeId);if(!se)return null;J=se.cx,re=se.cy+se.h/2,Y=b.mouseX,q=b.mouseY}const Z=q-re,ae=Math.abs(Z)>10?`M ${J} ${re} C ${J} ${re+Z*.4}, ${Y} ${q-Z*.4}, ${Y} ${q}`:`M ${J} ${re} L ${Y} ${q}`;return o.jsx("path",{d:ae,fill:"none",stroke:"#58a6ff",strokeWidth:2,strokeDasharray:"6 3",strokeOpacity:.7,pointerEvents:"none"})},P=J=>{const re=J.cy+J.h/2,Y=(b==null?void 0:b.fromNodeId)===J.id;return o.jsx("circle",{cx:J.cx,cy:re,r:V0,fill:Y?"#58a6ff":"#1c2128",stroke:Y?"#58a6ff":"#484f58",strokeWidth:1.5,strokeOpacity:Y?1:.5,className:"cursor-crosshair",onMouseDown:q=>O(q,J.id)})},ee=J=>{const re=J.cy-J.h/2,Y=b&&E===J.id&&W(J.id);return o.jsx("circle",{cx:J.cx,cy:re,r:V0,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} ${R}`,className:"block w-full",preserveAspectRatio:"xMidYMin meet",onMouseMove:z,onMouseUp:X,onClick:te,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((J,re)=>I(J,re)),T.map(J=>{const re=n===J.id,Y=J.cx-J.w/2,q=J.cy-J.h/2,Z=v===J.id,ae=b&&E===J.id&&W(J.id);if(J.type==="terminal"){const oe=J.id==="$start",je=oe?"#58a6ff":"#3fb950",Le=oe,De=!oe;return o.jsxs("g",{onClick:Re=>{Re.stopPropagation(),oe&&!u&&d("start")},className:oe&&!u?"cursor-pointer":void 0,children:[ae&&o.jsx("rect",{x:Y-3,y:q-3,width:J.w+6,height:J.h+6,rx:J.h/2+3,fill:"none",stroke:"#3fb950",strokeOpacity:.6,strokeWidth:2}),oe&&s==="start"&&o.jsx("rect",{x:Y-3,y:q-3,width:J.w+6,height:J.h+6,rx:J.h/2+3,fill:"none",stroke:"#58a6ff",strokeOpacity:.5,strokeWidth:2}),o.jsx("rect",{x:Y,y:q,width:J.w,height:J.h,rx:J.h/2,fill:je,fillOpacity:.08,stroke:je,strokeOpacity:.4,strokeWidth:1.5}),o.jsx("text",{x:J.cx,y:J.cy+4,textAnchor:"middle",fill:je,className:"text-[10px] font-medium",pointerEvents:"none",children:J.label}),Le&&P(J),De&&ee(J)]},J.id)}const se=J.color??"#6b7280";return o.jsxs("g",{onClick:oe=>{oe.stopPropagation(),u||c(re?null:J.id)},onMouseEnter:()=>S(J.id),onMouseLeave:()=>S(null),className:u?void 0:"cursor-pointer",children:[ae&&o.jsx("rect",{x:Y-3,y:q-3,width:J.w+6,height:J.h+6,rx:12,fill:"none",stroke:"#3fb950",strokeOpacity:.6,strokeWidth:2}),re&&o.jsx("rect",{x:Y-3,y:q-3,width:J.w+6,height:J.h+6,rx:12,fill:"none",stroke:"#58a6ff",strokeOpacity:.5,strokeWidth:2}),o.jsx("rect",{x:Y,y:q,width:J.w,height:J.h,rx:10,fill:se,fillOpacity:.08,stroke:se,strokeOpacity:.6,strokeWidth:re?2:1.5}),o.jsx("text",{x:J.cx,y:J.cy+4,textAnchor:"middle",fill:"#c9d1d9",className:"text-[11px] font-medium",pointerEvents:"none",children:J.label}),!u&&P(J),!u&&ee(J),Z&&!b&&!u&&o.jsxs("g",{onClick:oe=>{oe.stopPropagation(),f(J.id)},className:"cursor-pointer",children:[o.jsx("circle",{cx:Y+J.w-2,cy:q+2,r:8,fill:"#0d1117",fillOpacity:.9,stroke:"#f85149",strokeOpacity:.5,strokeWidth:1}),o.jsx("line",{x1:Y+J.w-5,y1:q-1,x2:Y+J.w+1,y2:q+5,stroke:"#f85149",strokeWidth:1.5,strokeLinecap:"round"}),o.jsx("line",{x1:Y+J.w+1,y1:q-1,x2:Y+J.w-5,y2:q+5,stroke:"#f85149",strokeWidth:1.5,strokeLinecap:"round"})]})]},J.id)}),b&&T.map(J=>W(J.id)?o.jsx("rect",{x:J.cx-J.w/2-8,y:J.cy-J.h/2-8,width:J.w+16,height:J.h+16,fill:"transparent",rx:12,onMouseEnter:()=>N(J.id),onMouseLeave:()=>N(null),onMouseUp:re=>{re.stopPropagation(),X()}},`drop-${J.id}`):null),F(),$()]})}const ou="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",Xo="block text-[11px] text-text-secondary mb-0.5";function yB({formName:e,formId:t,formDescription:n,formMaxIterations:s,formColor:a,isReadOnly:l,onNameChange:u,onDescriptionChange:c,onMaxIterationsChange:d,onColorChange:f}){return 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:Xo,children:"Name"}),o.jsx("input",{value:e,onChange:m=>u(m.target.value),placeholder:"Workflow name",className:`${ou} ${l?"opacity-50":""}`,readOnly:l})]}),o.jsxs("div",{className:"min-w-[100px]",children:[o.jsx("label",{className:Xo,children:"ID"}),o.jsx("input",{value:t,readOnly:!0,className:`${ou} font-mono opacity-50`})]}),o.jsxs("div",{className:"flex-1 min-w-[140px]",children:[o.jsx("label",{className:Xo,children:"Description"}),o.jsx("input",{value:n,onChange:m=>!l&&c(m.target.value),readOnly:l,placeholder:"What does this workflow do?",className:`${ou} ${l?"opacity-50":""}`})]}),o.jsxs("div",{className:"w-20",children:[o.jsx("label",{className:Xo,children:"Max Iter."}),o.jsx("input",{type:"number",value:s,onChange:m=>!l&&d(Number(m.target.value)),readOnly:l,className:`${ou} font-mono ${l?"opacity-50":""}`})]}),o.jsxs("div",{children:[o.jsx("label",{className:Xo,children:"Color"}),o.jsx("input",{type:"color",value:a,onChange:m=>!l&&f(m.target.value),disabled:l,className:`w-8 h-8 rounded border border-border bg-transparent ${l?"opacity-50":"cursor-pointer"}`})]})]})}function vB({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 G0({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(vB,{name:s.name,id:s.id,color:s.color??"#3b82f6",description:s.description,actions:n(s)},s.id))})]})}const ja="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",bm="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",os="block text-[11px] text-text-secondary mb-0.5";function Sm({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 bB({step:e,isEntry:t,agentTypes:n,transitionCount:s,templateVariables:a,onUpdate:l,onRemove:u,onSetEntry:c}){const{color:d,name:f}=ug(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:d+"20",color:d},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:os,children:"Type"}),o.jsx("select",{value:e.type,onChange:m=>{const p=m.target.value,_=p==="sub_agent"?"verification":"build";if(p==="agent"){const x=n.find(w=>!w.subagent);l({...e,type:p,phase:_,agentId:(x==null?void 0:x.id)??"builder",name:(x==null?void 0:x.name)??"Agent"})}else if(p==="sub_agent"){const x=n.find(w=>w.subagent);l({...e,type:p,phase:_,subAgentType:(x==null?void 0:x.id)??"",name:(x==null?void 0:x.name)??"Sub-Agent"})}else l({...e,type:p,phase:_,name:"Shell"})},className:bm,children:gB.map(m=>o.jsx("option",{value:m.value,children:m.label},m.value))})]}),e.type==="agent"&&o.jsxs("div",{children:[o.jsx("label",{className:os,children:"Agent Type"}),o.jsx("select",{value:e.agentId??"builder",onChange:m=>{const p=n.find(_=>_.id===m.target.value);l({...e,agentId:m.target.value,name:(p==null?void 0:p.name)??m.target.value})},className:bm,children:n.filter(m=>!m.subagent).map(m=>o.jsx("option",{value:m.id,children:m.name},m.id))})]}),e.type==="sub_agent"&&o.jsxs("div",{children:[o.jsx("label",{className:os,children:"Sub-Agent Type"}),o.jsxs("select",{value:e.subAgentType??"",onChange:m=>{const p=n.find(_=>_.id===m.target.value);l({...e,subAgentType:m.target.value,name:(p==null?void 0:p.name)??m.target.value})},className:bm,children:[o.jsx("option",{value:"",children:"— select —"}),n.filter(m=>m.subagent).map(m=>o.jsx("option",{value:m.id,children:m.name},m.id))]})]}),(e.type==="agent"||e.type==="sub_agent")&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx("label",{className:os,children:"Prompt"}),o.jsx("textarea",{value:e.prompt??"",onChange:m=>l({...e,prompt:m.target.value||void 0}),rows:6,className:`${ja} resize-y text-xs`,placeholder:"Injected on first entry..."}),o.jsx(Sm,{variables:a,onInsert:m=>l({...e,prompt:(e.prompt??"")+`{{${m}}}`})})]}),o.jsxs("div",{children:[o.jsx("label",{className:os,children:"Nudge Prompt"}),o.jsx("textarea",{value:e.nudgePrompt??"",onChange:m=>l({...e,nudgePrompt:m.target.value||void 0}),rows:6,className:`${ja} resize-y text-xs`,placeholder:"Injected on re-entry..."}),o.jsx(Sm,{variables:a,onInsert:m=>l({...e,nudgePrompt:(e.nudgePrompt??"")+`{{${m}}}`})})]})]}),e.type==="shell"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx("label",{className:os,children:"Command"}),o.jsx("textarea",{value:e.command??"",onChange:m=>l({...e,command:m.target.value}),rows:3,className:`${ja} font-mono text-xs resize-y`,placeholder:"cd {{workdir}} && npm run lint"}),o.jsx(Sm,{variables:a,onInsert:m=>l({...e,command:(e.command??"")+`{{${m}}}`})})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[o.jsxs("div",{children:[o.jsx("label",{className:os,children:"Timeout (ms)"}),o.jsx("input",{type:"number",value:e.timeout??6e4,onChange:m=>l({...e,timeout:Number(m.target.value)}),className:`${ja} font-mono text-xs`})]}),o.jsxs("div",{children:[o.jsx("label",{className:os,children:"Success Codes"}),o.jsx("input",{value:(e.successExitCodes??[0]).join(", "),onChange:m=>l({...e,successExitCodes:m.target.value.split(",").map(p=>Number(p.trim())).filter(p=>!isNaN(p))}),className:`${ja} font-mono text-xs`})]})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:os,children:"Sub-group"}),o.jsx("input",{value:e.subGroup??"",onChange:m=>l({...e,subGroup:m.target.value||void 0}),placeholder:"e.g. build, verify, review",className:ja})]}),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 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",W0="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",vi="block text-[11px] text-text-secondary mb-0.5";function SB({fromLabel:e,toLabel:t,condition:n,subGroup:s,fromStep:a,agentTypes:l,transitionIndex:u,totalTransitions:c,onUpdateCondition:d,onUpdateSubGroup:f,onDelete:m,onMoveUp:p,onMoveDown:_}){var C;const x=a&&(a.type==="sub_agent"||a.type==="agent")?l.find(v=>v.id===(a.type==="sub_agent"?a.subAgentType:a.agentId)):void 0,w=(x==null?void 0:x.results)&&x.results.length>0;return 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:p,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(dr,{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(dr,{className:"w-3 h-3"})})]})]}),o.jsx("button",{onClick:m,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(hp,{}),o.jsx("span",{className:"font-medium text-text-primary",children:t})]}),o.jsxs("div",{children:[o.jsx("label",{className:vi,children:"Condition"}),o.jsx("select",{value:n.type,onChange:v=>{d(v.target.value==="step_result"?{type:"step_result",result:"success"}:{type:v.target.value})},className:W0,children:$C.map(v=>o.jsx("option",{value:v.value,children:v.label},v.value))})]}),n.type==="step_result"&&o.jsxs("div",{children:[o.jsx("label",{className:vi,children:"Result"}),w?o.jsx("select",{value:n.result??x.results[0],onChange:v=>{d({type:"step_result",result:v.target.value})},className:W0,children:x.results.map(v=>o.jsx("option",{value:v,children:v},v))}):o.jsx("input",{type:"text",value:n.result??"success",onChange:v=>d({type:"step_result",result:v.target.value}),placeholder:"e.g. success, passed, failed",className:Na})]}),(n.type==="metadata_all_match"||n.type==="metadata_all_in")&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx("label",{className:vi,children:"Metadata Key"}),o.jsx("input",{type:"text",value:n.key??"",onChange:v=>d({...n,key:v.target.value}),placeholder:"e.g. criteria, todos, review_findings",className:Na})]}),o.jsxs("div",{children:[o.jsx("label",{className:vi,children:"Field"}),o.jsx("input",{type:"text",value:n.field??"",onChange:v=>d({...n,field:v.target.value}),placeholder:"e.g. status",className:Na})]}),n.type==="metadata_all_match"?o.jsxs("div",{children:[o.jsx("label",{className:vi,children:"Value"}),o.jsx("input",{type:"text",value:n.value??"",onChange:v=>d({...n,value:v.target.value}),placeholder:"e.g. passed, resolved",className:Na})]}):o.jsxs("div",{children:[o.jsx("label",{className:vi,children:"Values (comma-separated)"}),o.jsx("input",{type:"text",value:((C=n.values)==null?void 0:C.join(", "))??"",onChange:v=>d({...n,values:v.target.value.split(",").map(S=>S.trim()).filter(Boolean)}),placeholder:"e.g. resolved, dismissed",className:Na})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:vi,children:"Sub-group"}),o.jsx("input",{type:"text",value:s??"",onChange:v=>f(v.target.value||void 0),placeholder:"e.g. build, verify",className:Na})]}),o.jsx("p",{className:"text-text-muted text-[10px]",children:"Drag handles to reconnect. Order determines evaluation priority. Press Delete to remove."})]})}function wB(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function CB(e){let t=1;for(;e.some(n=>n.id===`s${t}`);)t++;return`s${t}`}const Qo="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",q0="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",Ta="block text-[11px] text-text-secondary mb-0.5",K0=[];function HC({isOpen:e,onClose:t,initialEditId:n}){var Pi,fs;const s=jt(_e=>_e.defaults),a=jt(_e=>_e.userItems),l=jt(_e=>_e.loading),u=jt(_e=>_e.templateVariables),c=jt(_e=>_e.fetchWorkflows),d=jt(_e=>_e.fetchWorkflow),f=jt(_e=>_e.fetchDefaultContent),m=jt(_e=>_e.fetchTemplateVariables),p=jt(_e=>_e.createWorkflow),_=jt(_e=>_e.updateWorkflow),x=jt(_e=>_e.deleteWorkflow),{requestDelete:w,clearConfirm:C,isConfirming:v}=Fu(),[S,b]=D.useState("list"),[y,E]=D.useState(null),[N,T]=D.useState(!1),[L,A]=D.useState(null),[R,M]=D.useState(null),[G,W]=D.useState(""),[O,U]=D.useState(""),[V,z]=D.useState(""),[X,te]=D.useState("1.0.0"),[H,I]=D.useState("#3b82f6"),[$,F]=D.useState(""),[P,ee]=D.useState(50),[J,re]=D.useState(K0),[Y,q]=D.useState({type:"always"}),[Z,ae]=D.useState(""),[se,oe]=D.useState(!1),je=gt(_e=>_e.defaults),Le=gt(_e=>_e.userItems),De=gt(_e=>_e.projectItems),Re=D.useMemo(()=>[...je,...Le,...De],[je,Le,De]),Te=gt(_e=>_e.fetchAgents),[Ae]=D.useState(null);D.useEffect(()=>{e&&(c(),m(),Te(),A(null),M(null),n?s.some(ve=>ve.id===n)?f(n).then(ve=>{ve&&pe({...ve,metadata:{...ve.metadata,name:ve.metadata.name+" (copy)",id:`${n}-copy-${Date.now()}`}},{editingId:null,isReadOnly:!1})}):d(n).then(ve=>{ve&&pe(ve,{editingId:n,isReadOnly:!1})}):(b("list"),E(null),T(!1)))},[e,c,d,f,m,n]);const pe=(_e,ve)=>{W(_e.metadata.name),U(_e.metadata.id),z(_e.metadata.description),te(_e.metadata.version),I(_e.metadata.color??"#3b82f6"),F(_e.entryStep),ee(_e.settings.maxIterations),re(_e.steps),q(_e.startCondition??{type:"always"}),ae(""),(ve==null?void 0:ve.editingId)!==void 0&&E(ve.editingId),(ve==null?void 0:ve.isReadOnly)!==void 0&&T(ve.isReadOnly),(ve==null?void 0:ve.selectedNodeKey)!==void 0&&A(null),(ve==null?void 0:ve.selectedEdgeKey)!==void 0&&M(null),b("edit")},ce=async _e=>{const ve=await d(_e);ve&&pe(ve,{editingId:_e,isReadOnly:!1,selectedNodeKey:null,selectedEdgeKey:null})},Se=async()=>{var et;const _e=y??O;if(!_e||!G)return ae("Name is required."),!1;if(J.length===0)return ae("Add at least one step."),!1;let ve=$;if(!ve||!J.some(We=>We.id===ve)){if(ve=((et=J.find(We=>We.id))==null?void 0:et.id)??"",!ve)return ae("All steps need an ID."),!1;F(ve)}oe(!0),ae("");const Oe={metadata:{id:_e,name:G,description:V,version:X||"1.0.0",color:H},entryStep:ve,settings:{maxIterations:P},steps:J,startCondition:Y},$e=y?await _(y,Oe):await p(Oe);return oe(!1),$e.success?(y||E(_e),!0):(ae($e.error??"Failed to save."),!1)},Ze=async()=>{await Se()},_t=async()=>{await Se()&&(n?t():b("list"))},dt=()=>{n?t():b("list")},tn=_e=>{W(_e),y||U(wB(_e))},ge=async _e=>s.some(Oe=>Oe.id===_e)?await f(_e):await d(_e),Ce=async _e=>{const ve=await ge(_e);ve&&pe(ve,{editingId:_e,isReadOnly:!0})},Ie=async _e=>{const ve=await ge(_e);ve&&pe({...ve,metadata:{...ve.metadata,name:ve.metadata.name+" (copy)",id:`${_e}-copy-${Date.now()}`}},{editingId:null,isReadOnly:!1})},Fe=()=>{E(null),W(""),U(""),z(""),te("1.0.0"),I("#3b82f6"),F(""),ee(50),re(structuredClone(K0)),q({type:"always"}),ae(""),A(null),M(null),T(!1),b("edit")},Ve=async _e=>{await x(_e),C()},St=D.useCallback(_e=>{A(_e),M(null)},[]),Ye=D.useCallback(_e=>{M(_e),A(null)},[]),wt=L!==null?Number(L):-1,ct=wt>=0?J[wt]??null:null,nn=D.useCallback(_e=>{re(ve=>ve.map((Oe,$e)=>$e===wt?_e:Oe))},[wt]),ht=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(","))??"?"}]`:zC[Y.type]??Y.type,jn=()=>{const _e=J.length,ve=CB(J),Oe=Re.find($e=>!$e.subagent);re([...J,{id:ve,name:(Oe==null?void 0:Oe.name)??"Agent",type:"agent",phase:"build",agentId:(Oe==null?void 0:Oe.id)??"builder",transitions:[]}]),$||F(ve),St(String(_e))},_n=D.useCallback((_e,ve)=>{_e==="$start"?(F(ve),Ye("start")):re(Oe=>{const $e=Oe.find(We=>We.id===_e),et=$e?$e.transitions.length:0;return Ye(`${_e}:${et}`),Oe.map(We=>We.id===_e?{...We,transitions:[...We.transitions,{when:{type:"always"},goto:ve}]}:We)})},[Ye]),ot=_e=>{if(_e==="start")return null;const ve=_e.lastIndexOf(":"),Oe=_e.slice(0,ve),$e=parseInt(_e.slice(ve+1));return{stepId:Oe,transIdx:$e}},fr=D.useCallback((_e,ve)=>{const Oe=ot(_e);Oe&&re($e=>$e.map(et=>et.id===Oe.stepId?{...et,transitions:et.transitions.map((We,ft)=>ft===Oe.transIdx?ve(We):We)}:et))},[]),Oi=D.useCallback((_e,ve)=>{if(_e==="start"){F(ve);return}fr(_e,Oe=>({...Oe,goto:ve}))},[fr]),Mi=D.useCallback((_e,ve)=>{const Oe=ot(_e);Oe&&(re($e=>{const et=$e.find(ft=>ft.id===Oe.stepId);if(!et)return $e;const We=et.transitions[Oe.transIdx];return We?$e.map(ft=>ft.id===Oe.stepId?{...ft,transitions:ft.transitions.filter((fn,Pt)=>Pt!==Oe.transIdx)}:ft.id===ve?{...ft,transitions:[...ft.transitions,We]}:ft):$e}),M(null))},[]),Cr=D.useCallback(_e=>{if(_e==="start"){F(""),M(null);return}const ve=ot(_e);ve&&(re(Oe=>Oe.map($e=>$e.id===ve.stepId?{...$e,transitions:$e.transitions.filter((et,We)=>We!==ve.transIdx)}:$e)),M(null))},[]),Ii=D.useCallback((_e,ve)=>{if(_e==="start"){q(ve);return}fr(_e,Oe=>({...Oe,when:ve}))},[fr]),Xs=D.useCallback((_e,ve)=>{_e!=="start"&&fr(_e,Oe=>({...Oe,subGroup:ve||void 0}))},[fr]),qa=_e=>ug(_e,Re).name,Nl=()=>{if(!R)return null;if(R==="start"){const fn=J.find(Pt=>Pt.id===$);return{type:"start",fromLabel:"Start",toLabel:fn?qa(fn):"(none)",condition:Y}}const _e=R.lastIndexOf(":"),ve=R.slice(0,_e),Oe=parseInt(R.slice(_e+1)),$e=J.find(fn=>fn.id===ve);if(!$e)return null;const et=$e.transitions[Oe];if(!et)return null;const We=J.find(fn=>fn.id===et.goto),ft=et.goto==="$done"?"Done":We?qa(We):et.goto;return{type:"step",fromLabel:qa($e),toLabel:ft,condition:et.when,subGroup:et.subGroup}};if(S==="edit"){const _e=Nl();return o.jsxs(Ot,{isOpen:e,onClose:dt,title:N?G:y?"Edit Workflow":"New Workflow",size:"full",children:[Z&&o.jsx("div",{className:"text-accent-error text-sm px-3 py-2 bg-accent-error/10 rounded mb-3",children:Z}),o.jsx(yB,{formName:G,formId:O,formDescription:V,formMaxIterations:P,formColor:H,isReadOnly:N,onNameChange:tn,onDescriptionChange:z,onMaxIterationsChange:ee,onColorChange:I}),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"}),!N&&o.jsx("button",{onClick:jn,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(_B,{steps:J,entryStep:$,selectedNodeId:(ct==null?void 0:ct.id)??null,selectedEdgeKey:R,startConditionLabel:ht,agentTypes:Re,isReadOnly:N,onSelectNode:ve=>{if(ve===null){St(null);return}const Oe=J.findIndex($e=>$e.id===ve);St(Oe>=0?String(Oe):null)},onSelectEdge:Ye,onRemoveStep:ve=>{var $e;const Oe=J.findIndex(et=>et.id===ve);if(re(et=>et.filter(We=>We.id!==ve)),wt===Oe&&St(null),$===ve){const et=J.filter(We=>We.id!==ve);F((($e=et[0])==null?void 0:$e.id)??"")}},onCreateTransition:_n,onReconnectTo:Oi,onReconnectFrom:Mi,onDeleteTransition:Cr}),J.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:jn,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:N&&(_e||ct)?o.jsx("p",{className:"text-text-muted text-xs text-center py-8",children:'View only — click "Duplicate & Customize" to edit.'}):_e?_e.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(hp,{}),o.jsx("span",{className:"text-text-primary font-medium",children:_e.toLabel})]}),o.jsxs("div",{children:[o.jsx("label",{className:Ta,children:"Activation Condition"}),o.jsx("select",{value:Y.type,onChange:ve=>q(ve.target.value==="step_result"?{type:"step_result",result:"success"}:ve.target.value==="metadata_all_match"?{type:"metadata_all_match",key:"",field:"",value:""}:ve.target.value==="metadata_all_in"?{type:"metadata_all_in",key:"",field:"",values:[]}:{type:ve.target.value}),className:q0,children:$C.map(ve=>o.jsx("option",{value:ve.value,children:ve.label},ve.value))})]}),Y.type==="step_result"&&o.jsxs("div",{children:[o.jsx("label",{className:Ta,children:"Result"}),$&&(()=>{const ve=J.find(We=>We.id===$),Oe=ve&&(ve.type==="sub_agent"||ve.type==="agent")?Re.find(We=>We.id===(ve.type==="sub_agent"?ve.subAgentType:ve.agentId)):void 0,$e=(Oe==null?void 0:Oe.results)&&Oe.results.length>0,et=(Oe==null?void 0:Oe.results)??[];return $e?o.jsx("select",{value:Y.result??et[0],onChange:We=>q({type:"step_result",result:We.target.value}),className:q0,children:et.map(We=>o.jsx("option",{value:We,children:We},We))}):o.jsx("input",{type:"text",value:Y.result??"success",onChange:We=>q({type:"step_result",result:We.target.value}),placeholder:"e.g. success, passed, failed",className:Qo})})()]}),(Y.type==="metadata_all_match"||Y.type==="metadata_all_in")&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx("label",{className:Ta,children:"Metadata Key"}),o.jsx("input",{type:"text",value:Y.key??"",onChange:ve=>q({...Y,key:ve.target.value}),placeholder:"e.g. criteria, todos, review_findings",className:Qo})]}),o.jsxs("div",{children:[o.jsx("label",{className:Ta,children:"Field"}),o.jsx("input",{type:"text",value:Y.field??"",onChange:ve=>q({...Y,field:ve.target.value}),placeholder:"e.g. status",className:Qo})]}),Y.type==="metadata_all_match"?o.jsxs("div",{children:[o.jsx("label",{className:Ta,children:"Value"}),o.jsx("input",{type:"text",value:Y.value??"",onChange:ve=>q({...Y,value:ve.target.value}),placeholder:"e.g. passed, resolved",className:Qo})]}):o.jsxs("div",{children:[o.jsx("label",{className:Ta,children:"Values (comma-separated)"}),o.jsx("input",{type:"text",value:((fs=Y.values)==null?void 0:fs.join(", "))??"",onChange:ve=>q({...Y,values:ve.target.value.split(",").map(Oe=>Oe.trim()).filter(Boolean)}),placeholder:"e.g. resolved, dismissed",className:Qo})]})]}),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 ve=ot(R),Oe=ve==null?void 0:ve.stepId,$e=(ve==null?void 0:ve.transIdx)??0,et=Oe?J.find(ft=>ft.id===Oe):void 0,We=(et==null?void 0:et.transitions.length)??0;return o.jsx(SB,{fromLabel:_e.fromLabel,toLabel:_e.toLabel,condition:_e.condition,subGroup:"subGroup"in _e?_e.subGroup:void 0,fromStep:_e.type==="step"?J.find(ft=>ft.id===_e.fromLabel):void 0,agentTypes:Re,transitionIndex:$e,totalTransitions:We,onUpdateCondition:ft=>Ii(R,ft),onUpdateSubGroup:ft=>Xs(R,ft),onDelete:()=>Cr(R),onMoveUp:()=>{re(ft=>{const fn=ft.find(yt=>yt.id===Oe);if(!fn||$e===0)return ft;const Pt=[...fn.transitions];return[Pt[$e-1],Pt[$e]]=[Pt[$e],Pt[$e-1]],ft.map(yt=>yt.id===Oe?{...yt,transitions:Pt}:yt)}),M(`${Oe}:${$e-1}`)},onMoveDown:()=>{re(ft=>{const fn=ft.find(yt=>yt.id===Oe);if(!fn||$e===fn.transitions.length-1)return ft;const Pt=[...fn.transitions];return[Pt[$e],Pt[$e+1]]=[Pt[$e+1],Pt[$e]],ft.map(yt=>yt.id===Oe?{...yt,transitions:Pt}:yt)}),M(`${Oe}:${$e+1}`)}})})():ct?o.jsx(bB,{step:ct,isEntry:ct.id===$,agentTypes:Re,transitionCount:ct.transitions.length,templateVariables:u,onUpdate:nn,onRemove:()=>{var ve;if(ct&&(re(J.filter((Oe,$e)=>$e!==wt)),St(null),$===ct.id)){const Oe=J.filter(($e,et)=>et!==wt);F(((ve=Oe[0])==null?void 0:ve.id)??"")}},onSetEntry:()=>F(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:dt,children:"Close"}),N?o.jsx(tt,{variant:"primary",onClick:()=>{W(G+" (copy)"),U(`${y}-copy-${Date.now()}`),E(null),T(!1)},children:"Duplicate & Customize"}):o.jsxs(o.Fragment,{children:[o.jsx(tt,{variant:"primary",onClick:Ze,children:"Save"}),o.jsx(tt,{variant:"primary",onClick:_t,children:"Save & Close"})]})]})]})}return o.jsx(Ot,{isOpen:e,onClose:t,title:"Workflows",size:"lg",children:o.jsx(DS,{description:"Workflows define multi-step agentic processes with branching transitions.",onNew:Fe,loading:l,hasItems:s.length>0||a.length>0,children:o.jsxs("div",{className:"space-y-4",children:[o.jsx(G0,{title:"Built-in",items:s,renderActions:_e=>o.jsx(o.Fragment,{children:o.jsx(Vs,{onClick:()=>Ie(_e.id),children:o.jsx(fu,{})})})}),o.jsx(G0,{title:"Custom",items:a,renderActions:_e=>o.jsxs(o.Fragment,{children:[o.jsx(Vs,{onClick:()=>Ce(_e.id),children:o.jsx(fu,{})}),o.jsx(Vs,{onClick:()=>ce(_e.id),children:o.jsx("span",{className:"text-[10px]",children:"Edit"})}),o.jsx(mu,{onClick:()=>Ie(_e.id)}),v(_e.id,"delete")?o.jsx(vp,{onConfirm:()=>Ve(_e.id),onCancel:C}):o.jsx(bp,{onClick:()=>w(_e.id)})]})})]})})})}function Mr(e,t){const n=new Set(t.map(s=>s.id));return[...e.filter(s=>!n.has(s.id)),...t]}function UC(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 FC(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 kB(e){const t=e.match(/^\/p\/([^/]+)/);return t==null?void 0:t[1]}function EB({isOpen:e,onClose:t,onCloseComplete:n,onSelectCommand:s,onSelectWorkflow:a,onCloseCompleteAction:l,textareaContent:u,onSearchMessages:c,onToggleAutoScroll:d,isAutoScrollActive:f}){const[,m]=hr(),p=en(P=>P.fetchCommands),_=jt(P=>P.fetchWorkflows),x=gt(P=>P.fetchAgents),w=en(P=>P.defaults),C=en(P=>P.userItems),v=en(P=>P.projectItems),S=jt(P=>P.defaults),b=jt(P=>P.userItems),y=jt(P=>P.projectItems),E=gt(P=>P.defaults),N=gt(P=>P.userItems),T=gt(P=>P.projectItems),L=we(P=>{var ee;return(ee=P.currentSession)==null?void 0:ee.mode}),A=we(P=>{var ee;return((ee=P.currentSession)==null?void 0:ee.dangerLevel)??"normal"}),R=we(P=>P.switchMode),M=we(P=>P.switchDangerLevel),G=we(P=>{var ee;return(ee=P.currentSession)==null?void 0:ee.projectId}),W=D.useRef(void 0),[O,U]=D.useState(""),[V,z]=D.useState(0),X=D.useRef(null),te=D.useRef(!1);D.useEffect(()=>{e&&(te.current=!0)},[e]),D.useEffect(()=>{if(e){p(),_(),x(),U(""),z(0);const P=setTimeout(()=>{var ee;return(ee=X.current)==null?void 0:ee.focus()},50);return()=>clearTimeout(P)}},[e,p,_,x]),D.useEffect(()=>{var P;!e&&te.current&&(n==null||n(),(P=W.current)==null||P.call(W),W.current=void 0)},[e,n]);const I=[{id:"create-session",name:"New Session",prefix:"Action > Create",action:()=>{const P=G??kB(window.location.pathname);P&&m(`/p/${P}/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(),d==null||d(!f)}},...Mr(Mr(E,N),T).filter(P=>!P.subagent&&P.id!==L).map(P=>({id:P.id,name:P.name,prefix:"Agent > Switch to",action:()=>R(P.id)})),...Mr(Mr(w,C),v).map(P=>({id:P.id,name:P.name,prefix:"Command > Launch",action:()=>s(P.id,u)})),...Mr(Mr(S,b),y).map(P=>({id:P.id,name:P.name,prefix:"Workflow > Run",action:()=>a(P.id)})),...["normal","dangerous"].filter(P=>P!==A).map(P=>({id:P,name:P.charAt(0).toUpperCase()+P.slice(1),prefix:"Mode > Switch to",action:()=>M(P)}))].filter(P=>UC(`${P.prefix} ${P.name}`,O)),$=I.length-1,F=P=>{FC(P,$,z,()=>{var ee;(ee=I[V])==null||ee.action(),t()},t)};return e?Ha.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:P=>{U(P.target.value),z(0)},onKeyDown:F,placeholder:"Search...",className:"flex-1 bg-transparent text-sm focus:outline-none placeholder:text-text-muted"}),o.jsx(_p,{onClick:t,className:"shrink-0","aria-label":"Close"})]}),o.jsx("div",{className:"overflow-y-auto max-h-[60vh] p-2",children:I.length===0?o.jsx("div",{className:"px-3 py-4 text-center text-text-muted text-sm",children:w.length+C.length+S.length+b.length>0?"No matches":"No agents, commands, or workflows yet"}):I.map((P,ee)=>o.jsxs("button",{type:"button",onClick:()=>{P.action(),t()},className:`w-full text-left px-3 py-2 rounded text-sm transition-colors ${ee===V?"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:[P.prefix," "]}),o.jsx("span",{children:P.name})]},P.id))})]})]}),document.body):null}function jB(e){const t=new Date(e),n=new Date;if(t.getDate()===n.getDate()&&t.getMonth()===n.getMonth()&&t.getFullYear()===n.getFullYear())return t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!1});const a=t.getFullYear(),l=String(t.getMonth()+1).padStart(2,"0"),u=String(t.getDate()).padStart(2,"0"),c=String(t.getHours()).padStart(2,"0"),d=String(t.getMinutes()).padStart(2,"0");return`${a}/${l}/${u} ${c}:${d}`}function NB(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 TB(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 AB(e){var n,s;if(e.type!=="message")return o.jsx(Bv,{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(Vj,{className:"w-3.5 h-3.5"}):o.jsx(Bv,{className:"w-3.5 h-3.5"}):o.jsx(Fj,{className:"w-3.5 h-3.5"})}function Y0(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 LB({isOpen:e,onClose:t,displayItems:n,onNavigate:s}){const[a,l]=D.useState(""),[u,c]=D.useState(0),d=D.useRef(null),f=D.useRef(null),m=D.useMemo(()=>n.filter(v=>{var S,b;return!(v.type==="context-divider"||v.type==="message"&&v.message.role==="assistant"&&!((S=v.message.content)!=null&&S.trim())&&!((b=v.message.thinkingContent)!=null&&b.trim()))}),[n]),p=D.useMemo(()=>a?m.filter(v=>{const S=Y0(v);return UC(S,a)}):m,[m,a]),_=p.length-1;D.useEffect(()=>{if(e){l(""),c(0);const v=setTimeout(()=>{var S;return(S=d.current)==null?void 0:S.focus()},50);return()=>clearTimeout(v)}},[e]),D.useEffect(()=>{e&&f.current&&(f.current.scrollTop=f.current.scrollHeight)},[e]);const x=v=>{FC(v,_,c,()=>{const S=p[u];if(S){const b=n.indexOf(S);b>=0&&s(b),t()}},t)},w=v=>{const S=n.indexOf(v);S>=0&&s(S),t()},C=v=>n.indexOf(v);return e?Ha.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(gp,{}),o.jsx("input",{ref:d,type:"text",value:a,onChange:v=>{l(v.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(_l,{className:"w-4 h-4"})})]}),o.jsx("div",{ref:f,className:"overflow-y-auto max-h-[60vh] p-2",children:p.length===0?o.jsx("div",{className:"px-3 py-4 text-center text-text-muted text-sm",children:m.length>0?"No matches":"No messages yet"}):p.map((v,S)=>{const b=C(v),y=AB(v),E=Y0(v),N=TB(v),T=NB(v),L=v.type==="message"&&v.message.role==="user";return o.jsx("button",{type:"button",onClick:()=>w(v),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:y}),o.jsx("span",{className:`truncate flex-1 ${N}`,children:E})]}),T&&o.jsx("span",{className:"text-text-muted text-xs shrink-0",children:jB(T)})]})},`${b}-${v.type}`)})})]})]}),document.body):null}function DB({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(bl,{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 RB({history:e,selectedIndex:t,onSelect:n,onEscape:s,onNavigate:a}){const l=D.useRef(null),u=D.useRef(null);D.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}},d=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,m)=>o.jsxs("div",{ref:m===t?u:null,role:"listitem",onClick:()=>d(f.content),className:`
295
+ p-2 rounded cursor-pointer transition-colors
296
+ ${m===t?"bg-accent-primary/20 border border-accent-primary":"hover:bg-bg-tertiary"}
297
+ `,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 OB(){const e=gj(),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 MB={maxWidth:1920,maxHeight:1920,quality:.85,maxSizeBytes:1048576};async function IB(e,t={}){const n={...MB,...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=FB(a),u=`data:${e.type};base64,${l}`,c=await VC(u);return{dataUrl:u,mimeType:e.type,size:e.size,width:c.width,height:c.height}}return await PB(e,n)}async function PB(e,t){const n=await zB(e),s=await VC(n),{width:a,height:l}=BB(s.width,s.height,t.maxWidth,t.maxHeight),u=$B();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 d=t.quality,f="";for(let p=0;p<10&&(f=u.toDataURL(e.type.startsWith("image/gif")?"image/png":e.type,d),!(X0(f)<=t.maxSizeBytes||d<=.3));p++)d-=.1;const m=X0(f);return{dataUrl:f,mimeType:e.type.startsWith("image/gif")?"image/png":e.type,size:m,width:a,height:l}}function BB(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 zB(e){return new Promise((t,n)=>{const s=UB(),a=new s;a.onload=()=>t(a.result),a.onerror=()=>n(new Error("Failed to read file")),a.readAsDataURL(e)})}function VC(e){return new Promise((t,n)=>{const s=HB(),a=new s;a.onload=()=>t(a),a.onerror=()=>n(new Error("Failed to load image")),a.src=e})}function $B(){var t;const e=dg();if(!((t=e.document)!=null&&t.createElement))throw new Error("Image compression requires browser canvas APIs");return e.document.createElement("canvas")}function HB(){const e=dg();if(!e.Image)throw new Error("Image compression requires browser image APIs");return e.Image}function UB(){const e=dg();if(!e.FileReader)throw new Error("Image compression requires browser file APIs");return e.FileReader}function dg(){return globalThis}function FB(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 X0(e){const n=e.split(",")[1];return n?Math.round(n.length*3/4):0}function VB(e){return["image/png","image/jpeg","image/gif"].includes(e.type)}function GB(e,t=50*1024*1024){return e.size>t?{valid:!1,error:`Image file is too large (${Q0(e.size)}). Maximum size is ${Q0(t)}.`}:{valid:!0}}function Q0(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}async function wm(e,t,n,s={}){const{maxSizeBytes:a=50*1024*1024,filename:l}=s;if(!VB(e)){n(`Unsupported file type: ${e.type}. Only PNG, JPG, and GIF are supported.`);return}const u=GB(e,a);if(!u.valid){n(u.error??"Image file is too large");return}try{const c=await IB(e,{maxWidth:1920,maxHeight:1920,quality:.85,maxSizeBytes:1048576}),d={id:pS(),filename:l??e.name,mimeType:c.mimeType,size:c.size,data:c.dataUrl};t(d)}catch(c){const d=c instanceof Error?c.message??"Failed to process image":"Failed to process image";n(d)}}function WB({children:e}){return Ha.createPortal(e,document.body)}function qB(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 KB({onSendCommand:e,onSelectWorkflow:t,onSelectWorkflowWithSubGroup:n,onOpenCommandsManager:s,onOpenWorkflowsManager:a,onAttach:l,textareaContent:u,attachments:c}){const[d,f]=D.useState(!1),[m,p]=D.useState("commands"),[_,x]=D.useState(""),[w,C]=D.useState(0),[v,S]=D.useState(null),[b,y]=D.useState(null),E=D.useRef(null),N=D.useRef(null),T=en(ee=>ee.defaults),L=en(ee=>ee.userItems),A=en(ee=>ee.projectItems),R=en(ee=>ee.fetchCommands),M=jt(ee=>ee.defaults),G=jt(ee=>ee.userItems),W=jt(ee=>ee.projectItems),O=jt(ee=>ee.fetchWorkflows),U=Mr(Mr(T,L),A),V=Mr(Mr(M,G),W);D.useEffect(()=>{d&&(m==="commands"?R():m==="workflows"&&O())},[d,m,R,O]),D.useEffect(()=>{d&&(x(""),C(0),requestAnimationFrame(()=>{var ee;return(ee=E.current)==null?void 0:ee.focus()}))},[d,m]),D.useEffect(()=>{if(!d)return;const ee=J=>{var re;(re=N.current)!=null&&re.contains(J.target)||f(!1)};return document.addEventListener("mousedown",ee),()=>document.removeEventListener("mousedown",ee)},[d]);const z=ee=>{switch(ee.key){case"ArrowDown":ee.preventDefault(),C(J=>{const Y=(m==="commands"?U:V).filter(q=>{const Z=_.toLowerCase();return!Z||q.name.toLowerCase().includes(Z)});return Math.min(J+1,Y.length-1)});break;case"ArrowUp":ee.preventDefault(),C(J=>Math.max(J-1,0));break;case"Enter":ee.preventDefault();break;case"Escape":ee.preventDefault(),f(!1);break}},X=ee=>{x(ee),C(0)},te=U.filter(ee=>!_||ee.name.toLowerCase().includes(_.toLowerCase())),H=V.filter(ee=>!_||ee.name.toLowerCase().includes(_.toLowerCase())),I=async ee=>{const J=await en.getState().fetchCommand(ee);J&&e(J.prompt,J.metadata.agentMode,u,c),f(!1)},$=ee=>{t(ee),f(!1)},F=(ee,J)=>{J.stopPropagation(),f(!1),S(ee)},P=(ee,J)=>{J.stopPropagation(),f(!1),y(ee)};return o.jsxs("div",{ref:N,className:"relative",children:[o.jsx("button",{type:"button",onClick:()=>f(!d),className:"px-1.5 py-2 rounded-r bg-bg-secondary text-text-muted hover:text-text-primary hover:bg-bg-tertiary transition-colors border-l border-border/50",title:"More options",children:o.jsx(kS,{className:"w-4 h-4"})}),d&&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:()=>{p("commands"),x(""),C(0)},className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${m==="commands"?"text-accent-primary border-b-2 border-accent-primary":"text-text-muted hover:text-text-primary"}`,children:"Commands"}),o.jsx("button",{type:"button",onClick:()=>{p("workflows"),x(""),C(0)},className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${m==="workflows"?"text-accent-primary border-b-2 border-accent-primary":"text-text-muted hover:text-text-primary"}`,children:"Workflows"}),o.jsx("button",{type:"button",onClick:()=>p("attach"),className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${m==="attach"?"text-accent-primary border-b-2 border-accent-primary":"text-text-muted hover:text-text-primary"}`,children:"Attach"})]}),m!=="attach"&&o.jsx("div",{className:"p-2 border-b border-border",children:o.jsx("input",{ref:E,value:_,onChange:ee=>X(ee.target.value),onKeyDown:z,placeholder:m==="commands"?"Search commands...":"Search workflows...",className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary"})}),o.jsx("div",{className:"overflow-y-auto max-h-64 p-1",children:m==="commands"?te.length===0?o.jsx("div",{className:"px-3 py-2 text-text-muted text-sm",children:U.length===0?"No commands yet":"No matches"}):te.map((ee,J)=>o.jsxs("div",{className:`flex items-center gap-1 px-3 py-2 rounded transition-colors group ${J===w?"bg-accent-primary/20":"hover:bg-bg-tertiary"}`,children:[o.jsx("button",{type:"button",onClick:()=>I(ee.id),className:"flex-1 text-left",children:o.jsx("div",{className:"text-sm text-text-primary font-medium",children:ee.name})}),o.jsx(Vs,{className:"opacity-0 group-hover:opacity-100",onClick:re=>F(ee.id,re)})]},ee.id)):m==="workflows"?H.length===0?o.jsx("div",{className:"px-3 py-2 text-text-muted text-sm",children:V.length===0?"No workflows yet":"No matches"}):H.map((ee,J)=>{const re=qB(ee),Y=ee.color??"#3b82f6";return o.jsxs("div",{className:`flex items-center gap-2 px-3 py-2 rounded transition-colors group ${J===w?"bg-accent-primary/20":"hover:bg-bg-tertiary"}`,children:[o.jsxs("button",{type:"button",onClick:()=>$(ee.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:Y}}),o.jsx("span",{className:"text-sm text-text-primary font-medium flex-1",children:ee.name}),re!==null&&o.jsx("span",{className:"w-1.5 h-1.5 rounded-full flex-shrink-0",style:{backgroundColor:re?"#22c55e":"#6b7280"},title:re?"Entry condition met":"Entry condition not met"})]}),o.jsxs("div",{className:"flex items-center gap-1",children:[ee.subGroups&&ee.subGroups.length>0&&o.jsx(YB,{subGroups:ee.subGroups,onSelect:q=>{f(!1),n(ee.id,q)}}),o.jsx(Vs,{className:"opacity-0 group-hover:opacity-100",onClick:q=>P(ee.id,q)})]})]},ee.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(kj,{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"})]})}),m!=="attach"&&o.jsx("div",{className:"border-t border-border p-1",children:o.jsx("button",{type:"button",onClick:()=>{f(!1),m==="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:m==="commands"?"Manage Commands...":"Manage Workflows..."})})]}),o.jsx(BC,{isOpen:!!v,onClose:()=>S(null),initialEditId:v}),o.jsx(HC,{isOpen:!!b,onClose:()=>y(null),initialEditId:b})]})}function YB({subGroups:e,onSelect:t}){const[n,s]=D.useState(!1),[a,l]=D.useState({top:0,right:0}),u=D.useRef(null),c=D.useRef(null);PC(c,()=>s(!1),n);const d=f=>{if(f.stopPropagation(),!n&&u.current){const m=u.current.getBoundingClientRect();l({top:m.bottom+4,right:window.innerWidth-m.right})}s(!n)};return o.jsxs(o.Fragment,{children:[o.jsx("button",{ref:u,type:"button",onClick:d,className:"p-1 rounded text-text-muted hover:text-text-primary transition-colors",title:"Sub-groups",children:"⋮"}),n&&o.jsx(WB,{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:m=>{m.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 XB({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(bl,{onClick:()=>t(n.queueId),size:"sm"})]},n.queueId))})}function QB({agent:e,isBuiltIn:t,isConfirmingDelete:n,alwaysAllowedNames:s,onView:a,onEdit:l,onDuplicate:u,onDelete:c}){const d=e.allowedTools.filter(f=>!(s!=null&&s.has(f)));return o.jsxs(OS,{isBuiltIn:t,isConfirmingDelete:n,onView:a,onEdit:l,onDuplicate:u,onDelete:c,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:[d.slice(0,5).map(f=>o.jsx("span",{className:"text-[10px] font-mono text-text-muted bg-bg-primary px-1 py-0.5 rounded",children:f},f)),d.length>5&&o.jsxs("span",{className:"text-[10px] text-text-muted",children:["+",d.length-5," more"]})]})]})}function J0({title:e,agents:t,subagents:n,isBuiltIn:s,alwaysAllowedNames:a,onView:l,onDuplicate:u,onEdit:c,onDelete:d}){if(t.length===0&&n.length===0)return null;const f=m=>o.jsx(QB,{agent:m,isBuiltIn:s,isConfirmingDelete:!1,alwaysAllowedNames:a,onView:()=>l(m.id),onEdit:s?void 0:()=>c==null?void 0:c(m.id),onDuplicate:()=>u(m.id),onDelete:s?void 0:()=>d==null?void 0:d(m.id)},m.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(f),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(f)})]})]})]})}function JB(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 Cm(e){const t=[];for(const[n,s]of e)s.size===0?t.push(n):t.push(`${n}:${[...s].join(",")}`);return t}function ZB({formName:e,formId:t,formDescription:n,formSubagent:s,formTools:a,formColor:l,formPrompt:u,formError:c,saving:d,isReadOnly:f,availableTools:m,onNameChange:p,onIdChange:_,onDescriptionChange:x,onSubagentChange:w,onToolsChange:C,onColorChange:v,onPromptChange:S,onSave:b,onCancel:y,onDuplicate:E}){const N=JB(a),T=m.filter(R=>!(s&&R.topLevelOnly)),L=(R,M)=>{const G=new Map(N),W=G.get(R)||new Set,O=new Set(W);O.has(M)?O.delete(M):O.add(M),O.size===0?G.set(R,new Set):G.set(R,O),C(Cm(G))},A=R=>{const M=new Map(N);M.has(R)?M.delete(R):M.set(R,new Set),C(Cm(M))};return o.jsxs("div",{className:"flex flex-col h-full",children:[o.jsxs("div",{className:"space-y-3",children:[c&&o.jsx(Vu,{message:c}),o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsx(br,{label:"Name",value:e,onChange:p,placeholder:"My Agent",readOnly:f}),o.jsx(br,{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(br,{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(!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:"Agent"}),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.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:R=>!f&&v(R.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:T.map(R=>{const M=N.has(R.name),G=R.actions.length>0,W=N.get(R.name)||new Set;return G?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:R.name}),o.jsx("span",{className:"text-[10px]",children:"*"})]},R.name):o.jsx(yl,{trigger:o.jsxs("button",{className:`px-1.5 py-0.5 rounded text-xs font-mono transition-colors flex items-center gap-1 ${M?"bg-accent-primary/25 text-accent-primary":"bg-bg-primary text-text-muted"}`,children:[o.jsx("span",{children:R.name}),G&&o.jsx("span",{className:`text-[10px] ${M&&W.size>0?"text-accent-primary":"text-text-muted"}`,children:"*"})]}),minWidth:"160px",items:[...R.actions.map(O=>({label:o.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",htmlFor:`${R.name}-${O}`,children:[o.jsx("input",{type:"checkbox",id:`${R.name}-${O}`,checked:W.has(O),onChange:()=>L(R.name,O),disabled:f,className:"w-3 h-3 rounded accent-accent-primary"}),o.jsx("span",{children:O})]}),closeOnClick:!1})),{label:M?"Deselect all":"Select all",closeOnClick:!1,onClick:()=>{if(M)A(R.name);else{const O=new Map(N);O.set(R.name,new Set(R.actions)),C(Cm(O))}}}]},R.name):o.jsx("button",{onClick:()=>!f&&A(R.name),className:`px-1.5 py-0.5 rounded text-xs font-mono transition-colors flex items-center gap-1 ${M?"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:R.name})},R.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:R=>!f&&S(R.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(tN,{onCancel:y,onSave:b,saving:d,saveDisabled:!e||!u||f}),f&&o.jsx("div",{className:"flex justify-end mt-2",children:o.jsx("button",{onClick:E,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 e8(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_|_$/g,"")}function t8({isOpen:e,onClose:t,initialEditId:n}){const s=gt(pe=>pe.defaults),a=gt(pe=>pe.userItems),l=gt(pe=>pe.loading),u=gt(pe=>pe.fetchAgents),c=gt(pe=>pe.fetchAgent),d=gt(pe=>pe.fetchDefaultContent),f=gt(pe=>pe.createAgent),m=gt(pe=>pe.updateAgent),p=gt(pe=>pe.deleteAgent),[_,x]=D.useState("list"),[w,C]=D.useState(null),[v,S]=D.useState(!1),[b,y]=D.useState(""),[E,N]=D.useState(""),[T,L]=D.useState(""),[A,R]=D.useState(!0),[M,G]=D.useState([]),[W,O]=D.useState("#6b7280"),[U,V]=D.useState(""),[z,X]=D.useState(""),[te,H]=D.useState(!1),[I,$]=D.useState([]),[F,P]=D.useState(new Set),ee=pe=>{y(pe.metadata.name),N(pe.metadata.id),L(pe.metadata.description),R(pe.metadata.subagent),G(pe.metadata.allowedTools),O(pe.metadata.color??"#6b7280"),V(pe.prompt),X("")},J=(pe,ce,Se)=>{y(pe.metadata.name+" (copy)"),N(`${ce}-copy-${Date.now()}`),L(pe.metadata.description),R(pe.metadata.subagent),G(pe.metadata.allowedTools),O(pe.metadata.color??"#6b7280"),V(pe.prompt),X(""),C(null),S(!1),x("edit")},re=(pe,ce)=>{ee(pe),C(ce),S(!0),x("edit")};D.useEffect(()=>{e&&(u(),Ne("/api/tools").then(pe=>pe.json()).then(pe=>{const ce=pe.tools||[];P(new Set(ce.filter(Se=>Se.alwaysAllowed).map(Se=>Se.name))),$(ce.filter(Se=>!Se.alwaysAllowed))}).catch(()=>{$([]),P(new Set)}),n?s.some(ce=>ce.id===n)?d(n).then(ce=>{ce&&J(ce,n)}):c(n).then(ce=>{ce&&(ee(ce),C(n),S(!1),x("edit"))}):(x("list"),C(null),S(!1)))},[e,u,c,d,n]);const Y=async pe=>{if(s.some(Se=>Se.id===pe)){const Se=await d(pe);if(!Se)return;re(Se,pe)}else{const Se=await c(pe);if(!Se)return;re(Se,pe)}},q=async pe=>{const ce=await d(pe);ce&&J(ce,pe)},Z=()=>{C(null),y(""),N(""),L(""),R(!0),G(["read_file"]),O("#6b7280"),V(""),X(""),S(!1),x("edit")},ae=async pe=>{const ce=await c(pe);ce&&(ee(ce),C(pe),S(!1),x("edit"))},se=async pe=>{await p(pe)},oe=async()=>{const pe=w??E;if(!pe||!b||!U){X("Name and prompt are required.");return}H(!0),X("");const ce={metadata:{id:pe,name:b,description:T,subagent:A,allowedTools:M.filter(Ze=>!F.has(Ze)),color:W},prompt:U},Se=w?await m(w,ce):await f(ce);if(H(!1),!Se.success){X(Se.error??"Failed to save agent.");return}n?t():x("list")},je=()=>{n?t():(x("list"),S(!1))},Le=pe=>{y(pe),w||N(e8(pe))},De=s.filter(pe=>pe.subagent),Re=s.filter(pe=>!pe.subagent),Te=a.filter(pe=>pe.subagent),Ae=a.filter(pe=>!pe.subagent);return _==="edit"?o.jsx(Ot,{isOpen:e,onClose:je,title:v?`${b}`:w?"Edit Agent":"New Agent",size:"xl",children:o.jsx(ZB,{formName:b,formId:E,formDescription:T,formSubagent:A,formTools:M,formColor:W,formPrompt:U,formError:z,saving:te,isReadOnly:v,availableTools:I,onNameChange:Le,onIdChange:N,onDescriptionChange:L,onSubagentChange:pe=>{R(pe),pe&&G(ce=>ce.filter(Se=>{var Ze;return!((Ze=I.find(_t=>_t.name===Se))!=null&&Ze.topLevelOnly)}))},onToolsChange:G,onColorChange:O,onPromptChange:V,onSave:oe,onCancel:je,onDuplicate:()=>{y(b+" (copy)"),N(`${w}-copy-${Date.now()}`),C(null),S(!1)}})}):o.jsx(Ot,{isOpen:e,onClose:t,title:"Agents",size:"lg",children:o.jsx(DS,{description:"Agents define behavior, tools, and prompts for top-level modes and sub-agents.",onNew:Z,loading:l,hasItems:s.length>0||a.length>0,children:o.jsxs("div",{className:"space-y-4",children:[s.length>0&&o.jsx(J0,{title:"Built-in",agents:Re,subagents:De,isBuiltIn:!0,alwaysAllowedNames:F,onView:Y,onDuplicate:q}),a.length>0&&o.jsx(J0,{title:"Custom",agents:Ae,subagents:Te,isBuiltIn:!1,alwaysAllowedNames:F,onView:Y,onDuplicate:q,onEdit:ae,onDelete:se})]})})})}function n8(){const e=we(b=>{var y;return(y=b.currentSession)==null?void 0:y.mode}),t=we(b=>b.switchMode),n=gt(b=>b.defaults),s=gt(b=>b.userItems),a=gt(b=>b.fetchAgents),l=[...n,...s],[u,c]=D.useState(!1),[d,f]=D.useState(!1),[m,p]=D.useState(null),_=D.useRef(null);D.useEffect(()=>{a()},[a]),D.useEffect(()=>{function b(y){_.current&&!_.current.contains(y.target)&&c(!1)}return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[]);const x=xp();if(!e)return null;const w=l.filter(b=>!b.subagent),C=w.find(b=>b.id===e),v=(C==null?void 0:C.name)??e,S=ol(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:v}),o.jsx(dr,{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((b,y)=>{const E=b.id===e,N=ol(l,b.id),T=x.agentSwitching[y],L=T?NS(T):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(b.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:N},children:b.name}),E&&o.jsx(Pr,{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})]},b.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(t8,{isOpen:d,onClose:()=>{f(!1),p(null)},initialEditId:m})]})}function r8(){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 Z0({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 s8({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(Z0,{message:a.message,field:"content",label:"content"}),u&&o.jsx(Z0,{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"})]})}function eS({kwargs:e,onChange:t,mode:n,modelId:s,testResults:a,thinkingField:l,onSeeRaw:u,onTest:c}){var f,m,p,_,x;const d=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[d])==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:(m=a[d])!=null&&m.loading?"Testing...":"Test"}),((p=a[d])==null?void 0:p.result)&&o.jsx(s8,{testKey:d,testResults:a,thinkingField:l,onSeeRaw:u}),((_=a[d])==null?void 0:_.error)&&o.jsx("span",{className:"text-xs text-red-500",children:(x=a[d])==null?void 0:x.error})]})]})}function tS({value:e,onChange:t}){return o.jsxs("div",{children:[o.jsxs("label",{className:"text-xs text-text-secondary block mb-1",children:["Query params ",o.jsx("span",{className:"text-text-muted",children:"(optional JSON)"})]}),o.jsx("input",{type:"text",value:e??"",onChange:n=>t(n.target.value),className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary font-mono"})]})}const i8=[8e3,11434,8080],a8=[{value:"llamacpp",label:"llama.cpp"},{value:"ollama",label:"Ollama"},{value:"vllm",label:"vLLM"},{value:"sglang",label:"SGLang"},{value:"unknown",label:"Other (APIs)"}];function GC({isOpen:e,onClose:t,onSave:n,initialStep:s=1,editProvider:a,editModelId:l}){const[u,c]=D.useState(s),[d,f]=D.useState(""),[m,p]=D.useState(""),[_,x]=D.useState(""),[w,C]=D.useState(""),[v,S]=D.useState(!1),[b,y]=D.useState(!1),[E,N]=D.useState(null),[T,L]=D.useState([]),[A,R]=D.useState(null),[M,G]=D.useState(!1),[W,O]=D.useState(""),[U,V]=D.useState({}),[z,X]=D.useState('{"enable_thinking": true}'),[te,H]=D.useState('{"enable_thinking": false}'),[I,$]=D.useState({}),[F,P]=D.useState(null),ee=D.useRef(null);D.useEffect(()=>{u===1&&e&&requestAnimationFrame(()=>{var Z;return(Z=ee.current)==null?void 0:Z.focus()})},[u,e]);function J(Z,ae){V(se=>({...se,[Z]:{...se[Z],...ae}}))}D.useEffect(()=>{var Z,ae;if(e)if(c(s),f((a==null?void 0:a.name)??""),p((a==null?void 0:a.url)??""),x((a==null?void 0:a.backend)??""),C((a==null?void 0:a.apiKey)??""),S((a==null?void 0:a.isLocal)??!1),N(null),O((a==null?void 0:a.thinkingField)??""),$({}),P(null),(Z=a==null?void 0:a.models)!=null&&Z.length){const se={};for(const oe of a.models)se[oe.id]={contextWindow:oe.contextWindow,supportsVision:oe.supportsVision,thinkingEnabled:oe.thinkingEnabled,thinkingLevel:oe.thinkingLevel??(oe.thinkingEnabled?"max":void 0),nonThinkingEnabled:oe.nonThinkingEnabled,thinkingExtraKwargs:oe.thinkingExtraKwargs,nonThinkingExtraKwargs:oe.nonThinkingExtraKwargs,thinkingQueryParams:oe.thinkingQueryParams,nonThinkingQueryParams:oe.nonThinkingQueryParams,defaultTemperature:oe.defaultTemperature,defaultTopP:oe.defaultTopP,defaultTopK:oe.defaultTopK,defaultMaxTokens:oe.defaultMaxTokens};V(se),L(a.models.map(oe=>({id:oe.id,contextWindow:oe.contextWindow}))),R(l??((ae=a.models[0])==null?void 0:ae.id)??null)}else L([]),V({}),R(null)},[e,s,a==null?void 0:a.id,l]),D.useEffect(()=>{u===2&&m&&T.length===0&&!b&&!E&&re(m)},[u]);async function re(Z){var ae,se;y(!0),N(null),L([]);try{const oe=new URLSearchParams({url:Z});w&&oe.set("apiKey",w);const je=await Ne(`/api/providers/models?${oe.toString()}`);if(je.ok){const Le=await je.json();if((ae=Le.models)!=null&&ae.length){L(Le.models),R(((se=Le.models[0])==null?void 0:se.id)??null);const De={};for(const Re of Le.models)De[Re.id]={contextWindow:Re.contextWindow,thinkingEnabled:!0,thinkingLevel:"max",defaultTemperature:Re.defaultTemperature,defaultTopP:Re.defaultTopP,defaultTopK:Re.defaultTopK,defaultMaxTokens:Re.defaultMaxTokens};V(De)}}else{const Le=await je.json();N(Le.error??`Failed to fetch models from ${Z}`)}}catch(oe){N(`Failed to fetch models from ${Z}: ${oe instanceof Error?oe.message:"Unknown error"}`)}y(!1)}async function Y(Z,ae){const se=Z+"-"+ae;$(De=>({...De,[se]:{loading:!0}}));const oe=U[Z],je={};let Le;if(ae==="thinking"){if(je.reasoning_effort=(oe==null?void 0:oe.thinkingLevel)??"low",z)try{je.chat_template_kwargs=JSON.parse(z)}catch{}if(oe!=null&&oe.thinkingQueryParams)try{Le=JSON.parse(oe.thinkingQueryParams)}catch{}}else{if(je.reasoning_effort="none",te)try{je.chat_template_kwargs=JSON.parse(te)}catch{}if(oe!=null&&oe.nonThinkingQueryParams)try{Le=JSON.parse(oe.nonThinkingQueryParams)}catch{}}try{const De=await Ne("/api/providers/test-params",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:m,model:Z,params:je,queryParams:Le,apiKey:w||void 0})}),Re=await De.json();De.ok?$(Te=>({...Te,[se]:{loading:!1,result:JSON.stringify(Re,null,2),message:Re.message}})):$(Te=>({...Te,[se]:{loading:!1,error:Re.error??"Test failed"}}))}catch(De){$(Re=>({...Re,[se]:{loading:!1,error:De instanceof Error?De.message:"Request failed"}}))}}function q(){const Z=d||"Provider",ae=(a==null?void 0:a.id)??`temp-${Date.now()}`;n({id:ae,name:Z,url:m,backend:_||"unknown",apiKey:w||void 0,isLocal:v||void 0,thinkingField:W||void 0,models:T.map(se=>{var oe,je,Le,De,Re,Te,Ae,pe,ce,Se,Ze,_t,dt;return{id:se.id,contextWindow:((oe=U[se.id])==null?void 0:oe.contextWindow)??se.contextWindow,supportsVision:(je=U[se.id])==null?void 0:je.supportsVision,thinkingEnabled:(Le=U[se.id])==null?void 0:Le.thinkingEnabled,thinkingLevel:(De=U[se.id])==null?void 0:De.thinkingLevel,nonThinkingEnabled:(Re=U[se.id])==null?void 0:Re.nonThinkingEnabled,thinkingExtraKwargs:(Te=U[se.id])==null?void 0:Te.thinkingExtraKwargs,nonThinkingExtraKwargs:(Ae=U[se.id])==null?void 0:Ae.nonThinkingExtraKwargs,thinkingQueryParams:(pe=U[se.id])==null?void 0:pe.thinkingQueryParams,nonThinkingQueryParams:(ce=U[se.id])==null?void 0:ce.nonThinkingQueryParams,temperature:(Se=U[se.id])==null?void 0:Se.temperature,topP:(Ze=U[se.id])==null?void 0:Ze.topP,topK:(_t=U[se.id])==null?void 0:_t.topK,maxTokens:(dt=U[se.id])==null?void 0:dt.maxTokens}})}),t()}return e?o.jsxs("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",onClick:Z=>{Z.target===Z.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(Z=>o.jsx("div",{className:`h-1 flex-1 rounded-full transition-colors ${Z<u?"bg-accent-success":Z===u?"bg-accent-primary":"bg-border"}`},Z))}),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:i8.map(Z=>o.jsxs("button",{type:"button",onClick:()=>{f(""),p(`http://localhost:${Z}`),x(""),N(null)},className:`p-2 rounded border text-center text-sm transition-colors ${m===`http://localhost:${Z}`?"border-accent-primary bg-accent-primary/10 text-accent-primary":"border-border hover:border-text-muted text-text-secondary"}`,children:["localhost:",Z]},Z))})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Provider URL"}),o.jsx("input",{ref:ee,type:"text",value:m,"data-testid":"provider-modal-url",onChange:Z=>{p(Z.target.value),N(null),L([]),V({})},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",autoComplete:"off",value:d,onChange:Z=>f(Z.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:"text",autoComplete:"off",value:w,onChange:Z=>C(Z.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:v,onChange:Z=>S(Z.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.jsxs("select",{value:_,onChange:Z=>x(Z.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:[o.jsx("option",{value:"",disabled:!0,children:"-- Select backend type --"}),a8.map(Z=>o.jsx("option",{value:Z.value,children:Z.label},Z.value))]})]}),o.jsx("button",{onClick:()=>G(!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(wS,{className:"w-4 h-4 text-text-muted"})})]})}),b&&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: ",m]}),o.jsxs("div",{className:"flex gap-2 mt-2",children:[o.jsx("button",{onClick:()=>re(m),className:"text-xs text-accent-primary hover:underline",children:"Retry"}),o.jsx("button",{onClick:()=>c(1),className:"text-xs text-accent-primary hover:underline",children:"Edit URL"})]})]}),T.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:T.map(Z=>{var ae,se,oe,je,Le,De,Re,Te,Ae,pe,ce,Se,Ze,_t,dt,tn,ge,Ce,Ie,Fe,Ve,St,Ye,wt,ct,nn,ht,jn,_n;return o.jsxs("div",{className:"bg-bg-primary border border-border rounded-lg overflow-hidden",children:[o.jsxs("button",{onClick:()=>R(A===Z.id?null:Z.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:Z.id.split("/").pop()}),o.jsxs("span",{className:"text-xs text-text-muted bg-bg-tertiary px-2 py-0.5 rounded",children:[Z.contextWindow.toLocaleString()," ctx"]})]}),o.jsx(dr,{className:`w-4 h-4 text-text-muted transition-transform ${A===Z.id?"rotate-180":""}`})]}),A===Z.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:((ae=U[Z.id])==null?void 0:ae.contextWindow)??Z.contextWindow,onChange:ot=>J(Z.id,{contextWindow:parseInt(ot.target.value)||Z.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:((se=U[Z.id])==null?void 0:se.supportsVision)??!1,onChange:ot=>J(Z.id,{supportsVision:ot.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:((oe=U[Z.id])==null?void 0:oe.thinkingEnabled)??!1,onChange:ot=>J(Z.id,{thinkingEnabled:ot.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"})]}),((je=U[Z.id])==null?void 0:je.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:((Le=U[Z.id])==null?void 0:Le.thinkingLevel)??"max",onChange:ot=>J(Z.id,{thinkingLevel:ot.target.value}),className:"w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-xs text-text-primary"})]}),o.jsx(tS,{value:(De=U[Z.id])==null?void 0:De.thinkingQueryParams,onChange:ot=>J(Z.id,{thinkingQueryParams:ot})}),o.jsx(eS,{kwargs:z,onChange:X,mode:"thinking",modelId:Z.id,testResults:I,thinkingField:W,onSeeRaw:P,onTest:()=>Y(Z.id,"thinking")})]}),o.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:((Re=U[Z.id])==null?void 0:Re.nonThinkingEnabled)??!1,onChange:ot=>J(Z.id,{nonThinkingEnabled:ot.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"})]}),((Te=U[Z.id])==null?void 0:Te.nonThinkingEnabled)&&o.jsxs("div",{className:"ml-6 space-y-2 pl-3 border-l-2 border-accent-warning/30",children:[o.jsx(tS,{value:(Ae=U[Z.id])==null?void 0:Ae.nonThinkingQueryParams,onChange:ot=>J(Z.id,{nonThinkingQueryParams:ot})}),o.jsx(eS,{kwargs:te,onChange:H,mode:"non-thinking",modelId:Z.id,testResults:I,thinkingField:W,onSeeRaw:P,onTest:()=>Y(Z.id,"non-thinking")})]})]}),o.jsxs("div",{children:[o.jsx("span",{className:"text-xs text-accent-primary cursor-pointer hover:underline",onClick:()=>{var ot;return(ot=document.getElementById(`adv-${Z.id}`))==null?void 0:ot.classList.toggle("hidden")},children:"▸ Advanced parameters"}),o.jsxs("div",{id:`adv-${Z.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=U[Z.id])==null?void 0:pe.temperature)??"",onChange:ot=>J(Z.id,{temperature:ot.target.value?parseFloat(ot.target.value):void 0}),placeholder:((Se=(ce=U[Z.id])==null?void 0:ce.defaultTemperature)==null?void 0:Se.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"}),((Ze=U[Z.id])==null?void 0:Ze.defaultTemperature)!==void 0&&o.jsxs("p",{className:"text-xs text-text-muted mt-0.5",children:["default: ",(_t=U[Z.id])==null?void 0:_t.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:((dt=U[Z.id])==null?void 0:dt.topP)??"",onChange:ot=>J(Z.id,{topP:ot.target.value?parseFloat(ot.target.value):void 0}),placeholder:((ge=(tn=U[Z.id])==null?void 0:tn.defaultTopP)==null?void 0:ge.toString())??"Using default",className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary"}),((Ce=U[Z.id])==null?void 0:Ce.defaultTopP)!==void 0&&o.jsxs("p",{className:"text-xs text-text-muted mt-0.5",children:["default: ",(Ie=U[Z.id])==null?void 0:Ie.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:((Fe=U[Z.id])==null?void 0:Fe.topK)??"",onChange:ot=>J(Z.id,{topK:ot.target.value?parseInt(ot.target.value):void 0}),placeholder:((St=(Ve=U[Z.id])==null?void 0:Ve.defaultTopK)==null?void 0:St.toString())??"Using default",className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary"}),((Ye=U[Z.id])==null?void 0:Ye.defaultTopK)!==void 0&&o.jsxs("p",{className:"text-xs text-text-muted mt-0.5",children:["default: ",(wt=U[Z.id])==null?void 0:wt.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:((ct=U[Z.id])==null?void 0:ct.maxTokens)??"",onChange:ot=>J(Z.id,{maxTokens:ot.target.value?parseInt(ot.target.value):void 0}),placeholder:((ht=(nn=U[Z.id])==null?void 0:nn.defaultMaxTokens)==null?void 0:ht.toString())??"Using default",className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary"}),((jn=U[Z.id])==null?void 0:jn.defaultMaxTokens)!==void 0&&o.jsxs("p",{className:"text-xs text-text-muted mt-0.5",children:["default: ",(_n=U[Z.id])==null?void 0:_n.defaultMaxTokens]})]})]})]})]})]})]},Z.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:d||"Provider"}),o.jsx("span",{className:"text-xs px-1.5 py-0.5 rounded-full bg-accent-primary/20 text-accent-primary",children:dp(_||"unknown")})]}),o.jsx("p",{className:"text-xs text-text-muted mb-3",children:m}),T.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:T.length})]}),o.jsx("div",{className:"space-y-1",children:T.map(Z=>{var ae,se;return o.jsxs("div",{className:"text-xs text-text-muted flex items-center gap-2",children:[o.jsxs("span",{children:["• ",Z.id.split("/").pop()]}),o.jsxs("span",{className:"text-text-secondary",children:[Z.contextWindow.toLocaleString()," ctx"]}),((ae=U[Z.id])==null?void 0:ae.thinkingEnabled)&&o.jsx("span",{className:"text-accent-success",children:"thinking"}),((se=U[Z.id])==null?void 0:se.nonThinkingEnabled)&&o.jsx("span",{className:"text-accent-warning",children:"non-thinking"})]},Z.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&&!m,"data-testid":"provider-modal-next",className:"px-5 py-2 bg-accent-primary text-text-primary rounded-lg text-sm font-medium hover:bg-accent-primary/90 disabled:opacity-50 transition-colors",children:u===1?"Next — Test & Configure":"Next — Review"}):o.jsx("button",{onClick:q,"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"})]})]})]}),M&&o.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[60]",onClick:Z=>{Z.target===Z.currentTarget&&G(!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:()=>G(!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:Z=>O(Z.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:()=>G(!1),className:"px-5 py-2 bg-accent-primary text-text-primary rounded-lg text-sm font-medium hover:bg-accent-primary/90 transition-colors",children:"Done"})})]})}),F&&o.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[70]",onClick:Z=>{Z.target===Z.currentTarget&&P(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:()=>P(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:F})]})})]}):null}function o8(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(0)}K`:`${e}`}function l8(){var $;const[,e]=hr(),t=we(F=>F.currentSession),n=we(F=>F.setSessionProvider),[s,a]=D.useState(!1),[l,u]=D.useState([]),[c,d]=D.useState(null),f=D.useRef(null),[m,p]=D.useState(null),[_,x]=D.useState(!1),w=D.useRef(new Set),C=zt(F=>F.providers),v=zt(F=>F.activeProviderId),S=zt(F=>F.defaultModelSelection),b=zt(F=>F.activating),y=zt(F=>F.activateProvider),E=zt(F=>F.refreshModel),N=zt(F=>F.refreshProviderModels);D.useEffect(()=>{function F(P){f.current&&!f.current.contains(P.target)&&(a(!1),u([]),w.current=new Set)}return document.addEventListener("mousedown",F),()=>document.removeEventListener("mousedown",F)},[]),D.useEffect(()=>{if(s){const F=C.map(P=>P.id);u(F),F.forEach(P=>{w.current.has(P)||(w.current.add(P),G(P))})}},[s,C]);const T=C.find(F=>F.id===v),L=(T==null?void 0:T.status)==="disconnected",A=S?S.split("/").pop()??null:null,R=A?(($=A.split("/").pop())==null?void 0:$.replace(/-/g," "))??A:"detecting...",M=(F,P)=>S?S===`${F}/${P}`:!1,G=async F=>{d(F);try{await N(F)}catch{}finally{d(null)}},W=F=>{l.includes(F.id)?u(l.filter(P=>P!==F.id)):(u([...l,F.id]),G(F.id))},O=async F=>{if(F.id===v){W(F);return}t?(n(F.id,void 0),zt.getState().syncFromSession(F.id,""),a(!1),u([])):await y(F.id)&&(a(!1),u([]))},U=F=>{W(F)},V=async(F,P)=>{F.stopPropagation(),w.current.delete(P),await G(P)},z=(F,P)=>{p({providerId:F,model:P}),x(!0)},X=m?C.find(F=>F.id===m.providerId):void 0,te=()=>{p(null),x(!1)},H=async F=>{try{if(!(await Ne(`/api/providers/${F.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:F.name,url:F.url,backend:F.backend,apiKey:F.apiKey,isLocal:F.isLocal,thinkingField:F.thinkingField,models:F.models})})).ok)throw new Error("Failed to update provider");await zt.getState().fetchConfig()}catch{}p(null),x(!1)},I=async(F,P)=>{if(t){n(F,P),zt.getState().syncFromSession(F,P),u([]),a(!1);return}d("activating");try{zt.getState().syncFromSession(F,P),u([]),a(!1);const ee=await Ne(`/api/providers/${F}/activate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:P})});if(ee.ok){const J=await ee.json();zt.getState().syncFromSession(J.activeProviderId,J.model)}}catch{}finally{d(null)}};return C.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:R}),o.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded-full ${T!=null&&T.isLocal?"text-accent-success bg-accent-success/10":"text-accent-warning bg-accent-warning/10"}`,children:T!=null&&T.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:R}),o.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded-full ${T!=null&&T.isLocal?"text-accent-success bg-accent-success/10":"text-accent-warning bg-accent-warning/10"}`,children:T!=null&&T.isLocal?"local":"api"})]}),o.jsx(dr,{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:C.map(F=>{var P;return o.jsxs("div",{children:[o.jsxs("div",{className:`px-3 py-2 flex items-center justify-between ${F.id===v?"bg-bg-tertiary":"hover:bg-bg-tertiary"} ${b?"opacity-50 cursor-wait":"cursor-pointer"}`,children:[o.jsxs("div",{onClick:()=>!b&&O(F),className:"flex flex-col min-w-0 flex-1 cursor-pointer",children:[o.jsx("span",{className:`text-sm font-medium truncate ${F.id===v?"text-accent-primary":"text-text-primary"}`,children:F.name}),o.jsx("span",{className:"text-xs text-text-muted truncate",children:F.backend!=="unknown"&&dp(F.backend)})]}),o.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[F.id===v?o.jsx("span",{className:"text-accent-success",title:"Active",children:o.jsx(Pr,{className:"w-4 h-4"})}):o.jsx("span",{className:"w-4"}),o.jsx("button",{type:"button",onClick:ee=>{ee.stopPropagation(),V(ee,F.id)},className:"p-0.5 hover:bg-bg-tertiary rounded transition-colors",title:"Refresh models",children:o.jsx(pp,{className:`w-4 h-4 ${c===F.id?"animate-spin":""} ${F.id===v?"text-accent-primary":"text-text-muted"}`})}),o.jsx("button",{type:"button",onClick:ee=>{ee.stopPropagation(),U(F)},className:"p-0.5 hover:bg-bg-tertiary rounded transition-colors",title:"Show models",children:o.jsx(dr,{className:`w-4 h-4 transition-transform ${l.includes(F.id)?"rotate-180":""} ${F.id===v?"text-accent-primary":"text-text-muted"}`})})]})]}),l.includes(F.id)&&o.jsx("div",{className:"bg-bg-primary border-t border-border max-h-40 overflow-y-auto",children:c===F.id?o.jsx("div",{className:"px-4 py-2 text-xs text-text-muted",children:"Loading models..."}):(P=F.models)!=null&&P.length?F.models.map(ee=>{var J;return o.jsxs("button",{type:"button",onClick:()=>I(F.id,ee.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":""} ${M(F.id,ee.id)?"text-accent-primary":"text-text-secondary"}`,children:[o.jsx("span",{className:"truncate flex-1",children:((J=ee.id.split("/").pop())==null?void 0:J.replace(/-/g," "))??ee.id}),o.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[o.jsx("span",{className:"text-xs text-text-muted",children:o8(ee.contextWindow)}),o.jsx("button",{type:"button",onClick:re=>{re.stopPropagation(),z(F.id,ee)},className:"opacity-0 group-hover:opacity-100 p-0.5 hover:bg-bg-tertiary rounded transition-opacity",title:"Edit model context",children:o.jsx(Tj,{className:"w-3 h-3 text-text-muted"})})]}),M(F.id,ee.id)&&o.jsx("span",{className:"text-accent-success flex-shrink-0 ml-1",children:o.jsx(Pr,{className:"w-3.5 h-3.5"})})]},ee.id)}):o.jsx("div",{className:"px-4 py-2 text-xs text-text-muted",children:"No models available"})})]},F.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"})})]}),m&&_&&o.jsx(GC,{isOpen:!0,onClose:te,onSave:H,initialStep:2,editProvider:{id:m.providerId,name:(X==null?void 0:X.name)??"",url:(X==null?void 0:X.url)??"",backend:(X==null?void 0:X.backend)??"unknown",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:m.model.id})]})}function c8({input:e,setInput:t,attachments:n,setAttachments:s,dragOver:a,setDragOver:l,errorMessage:u,setErrorMessage:c,scrollContainerRef:d,sessionId:f,sessionMode:m,showHistory:p,history:_,selectedIndex:x,openHistory:w,closeHistory:C,navigateUp:v,navigateDown:S,selectCurrent:b,isAutoScrollActive:y,setAutoScroll:E,onOpenMessageSearch:N,onOpenCommandsModal:T,onOpenWorkflowsModal:L,onSelectWorkflow:A,onSelectWorkflowWithSubGroup:R,clearInput:M}){const G=D.useRef(null),W=D.useRef(null),O=D.useRef(0),U=$u(),V=we(se=>se.sendMessage),z=we(se=>se.stopGeneration),X=we(se=>se.cancelQueued),te=we(se=>se.queuedMessages),H=we(se=>se.restoredInput),I=we(se=>se.clearRestoredInput);D.useEffect(()=>{var se;H!==null&&(t(H),I(),(se=G.current)==null||se.focus())},[H,t,I]);const $=D.useCallback(()=>{const se=G.current;if(!se)return;const oe=e.length>=O.current;O.current=e.length,oe||(se.style.height="auto"),se.style.height=`${Math.min(200,se.scrollHeight)}px`},[e]);D.useEffect(()=>{if(!f)return;const se=`openfox:draft:${f}`,oe=localStorage.getItem(se);oe!==null&&t(oe)},[f,t]),D.useEffect(()=>{var se;(se=G.current)==null||se.focus(),$()},[f,$]),D.useEffect(()=>{if(!f)return;const se=`openfox:draft:${f}`,oe=setTimeout(()=>{e?localStorage.setItem(se,e):localStorage.removeItem(se)},500);return()=>clearTimeout(oe)},[f,e]),D.useEffect(()=>{$()},[e,$]),D.useEffect(()=>{const se=G.current;if(!se)return;const oe=async je=>{var De;if(document.activeElement!==se)return;const Le=(De=je.clipboardData)==null?void 0:De.items;if(Le){for(const Re of Array.from(Le))if(Re.type.startsWith("image/")){je.preventDefault();const Te=Re.getAsFile();if(!Te)continue;await wm(Te,Ae=>s([...n,Ae]),c,{filename:"pasted-image"})}}};return se.addEventListener("paste",oe),()=>se.removeEventListener("paste",oe)},[n,s,c]);const F=se=>{se.preventDefault(),!(!e.trim()&&n.length===0)&&(V(e,n.length>0?n:void 0),M())},P=se=>{if(p)switch(se.key){case"Enter":{se.preventDefault();const oe=b();oe&&(t(oe),C());return}case"Escape":se.preventDefault(),C(),U&&z();return;case"ArrowUp":se.preventDefault(),v();return;case"ArrowDown":se.preventDefault(),S();return}if(se.key==="ArrowUp"&&e.trim()===""&&!p){se.preventDefault(),w();return}se.key==="Enter"&&!se.shiftKey&&(se.preventDefault(),F(se))},ee=D.useCallback(async se=>{const oe=se.target.files;if(!(!oe||oe.length===0)){c(null);for(const je of Array.from(oe))await wm(je,Le=>s([...n,Le]),c);W.current&&(W.current.value="")}},[n,s,c]),J=D.useCallback(se=>{se.preventDefault(),se.stopPropagation(),l(!0)},[l]),re=D.useCallback(se=>{se.preventDefault(),se.stopPropagation(),l(!1)},[l]),Y=D.useCallback(async se=>{se.preventDefault(),se.stopPropagation(),l(!1),c(null);const oe=se.dataTransfer.files;if(!(!oe||oe.length===0))for(const je of Array.from(oe))await wm(je,Le=>s([...n,Le]),c)},[n,s,l,c]),q=D.useCallback(se=>{s(n.filter(oe=>oe.id!==se))},[n,s]),Z=D.useCallback(()=>{var se;(se=W.current)==null||se.click()},[]),ae=()=>{var se;!e.trim()&&n.length===0||((se=d.current)==null||se.scrollTo({top:d.current.scrollHeight,behavior:"smooth"}),V(e,n),M())};return o.jsxs("form",{onSubmit:F,className:"relative p-2 md:p-4 bg-secondary",children:[U&&o.jsx("div",{className:"absolute -top-8 left-2 md:left-4 z-10",children:o.jsx(OB,{})}),o.jsxs("div",{className:"absolute -top-8 right-2 md:right-4 z-10 flex items-center gap-2",children:[o.jsx(kp,{isActive:y,onToggle:E,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"}),o.jsxs("button",{type:"button",onClick:N,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(gp,{}),"Browse history"]})]}),o.jsx("input",{ref:W,type:"file",accept:".png,.jpg,.jpeg,.gif",onChange:ee,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(se=>o.jsx(DB,{attachment:se,onRemove:q},se.id))}),p&&o.jsx(RB,{history:_,selectedIndex:x,onSelect:se=>{t(se),C()},onEscape:C,onNavigate:se=>{se==="up"?v():S()}}),o.jsx(XB,{messages:te,onCancel:X}),o.jsxs("div",{className:`flex items-end gap-3 p-3 rounded transition-colors ${a?"bg-accent-primary/10":"bg-primary"}`,onDragOver:J,onDragLeave:re,onDrop:Y,children:[o.jsx("textarea",{id:zS,ref:G,value:e,onChange:se=>{t(se.target.value),p&&C()},onKeyDown:P,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:[U&&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(ES,{}),"Abort"]}),o.jsxs("div",{className:"flex items-center",children:[o.jsx("button",{type:"button",onClick:ae,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(KB,{onSendCommand:(se,oe,je,Le)=>{var Re;oe&&m!==oe&&we.getState().switchMode(oe);const De=je&&je.trim()?`${je.trim()}
298
+
299
+ ${se}`:se;(Re=d.current)==null||Re.scrollTo({top:d.current.scrollHeight,behavior:"smooth"}),V(De,Le!=null&&Le.length?Le:void 0,{messageKind:"command",isSystemGenerated:!0}),M()},onSelectWorkflow:A,onSelectWorkflowWithSubGroup:R,onOpenCommandsManager:T,onOpenWorkflowsManager:L,onAttach:Z,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(n8,{}),o.jsx(r8,{})]}),o.jsx(l8,{})]})]})}function u8(e){return e==="criterion"||e==="session_metadata"}function d8(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=>u8(s.name))}function h8(e,t=[]){const n=[];let s=null,a=[],l,u=1;const c=new Map,d=new Map,f=[];for(const x of t)x.type==="message"?c.set(x.message.id,x):x.type==="subagent"?d.set(x.subAgentId,x):x.type==="criteria-batch"&&f.push(x);let m=0;const p=()=>{if(a.length>0){const x=f[m];x&&x.type==="criteria-batch"&&x.toolCalls.length===a.length&&x.toolCalls.every((C,v)=>{var S;return C.id===((S=a[v])==null?void 0:S.id)})?n.push(x):n.push({type:"criteria-batch",toolCalls:[...a]}),m++,a=[]}},_=()=>{if(!s)return;const x=s,w=d.get(x.subAgentId);w&&w.type==="subagent"&&w.messages.length===x.messages.length&&w.messages.every((v,S)=>v===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&&(p(),_(),u++,n.push({type:"context-divider",windowSequence:u})),l=x.contextWindowId,d8(x)){_();for(const w of x.toolCalls)a.push(w);continue}if(p(),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 p(),_(),n}function f8(e){const{year:t,month:n,day:s}=GS(e);return`${t}/${n}/${s} ${qu(e)}`}function m8(e,t){return e.length<=t?e:e.substring(0,t)+"..."}const p8=10,g8=150;function x8(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 _8(e){return[...e].sort((s,a)=>new Date(a.timestamp).getTime()-new Date(s.timestamp).getTime()).slice(0,p8).reverse().map(s=>({id:s.id,content:s.content,timestamp:s.timestamp,formattedTimestamp:f8(s.timestamp),trimmedContent:m8(s.content,g8),sessionId:s.sessionId,sessionName:s.sessionName}))}function y8(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(...x8(l));return _8(s)}function v8(e,t=[],n=null){const[s,a]=D.useState(0),[l,u]=D.useState(!1),c=D.useMemo(()=>y8(e,t,n),[e,t,n]),d=D.useCallback(()=>{c.length>0&&(a(c.length-1),u(!0))},[c.length]),f=D.useCallback(()=>{u(!1),a(0)},[]),m=D.useCallback(()=>{a(x=>c.length===0?x:x===0?c.length-1:x-1)},[c.length]),p=D.useCallback(()=>{a(x=>c.length===0?x:x===c.length-1?0:x+1)},[c.length]),_=D.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:d,closeHistory:f,navigateUp:m,navigateDown:p,selectCurrent:_}}D.memo(function({item:t}){const[n,s]=D.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(ds,{content:t.description})})]})]})});function b8({criteriaSidebarOpen:e,onCriteriaSidebarToggle:t}={}){const n=e??!0,[s,a]=D.useState(""),[l,u]=D.useState([]),[c,d]=D.useState(!1),[f,m]=D.useState(null),[p,_]=D.useState(!1),[x,w]=D.useState(!1),[C,v]=D.useState(!1),[S,b]=D.useState(!1),[y,E]=D.useState(null),N=D.useRef(null),T=we(Ae=>Ae.currentSession),L=we(Ae=>Ae.messages),A=we(Ae=>Ae.streamingMessage),R=we(Ae=>Ae.sessions),M=$u(),G=we(Ae=>Ae.sendMessage),W=we(Ae=>Ae.acceptAndBuild),O=we(Ae=>Ae.stopGeneration),U=we(Ae=>Ae.launchRunner),V=gt(Ae=>Ae.defaults),z=gt(Ae=>Ae.userItems),X=[...V,...z].filter(Ae=>!Ae.subagent),{history:te,selectedIndex:H,showHistory:I,openHistory:$,closeHistory:F,navigateUp:P,navigateDown:ee,selectCurrent:J}=v8(L,R,T==null?void 0:T.id);D.useEffect(()=>{const Ae=pe=>{E(pe.detail.stats)};return window.addEventListener("open-turn-stats",Ae),()=>window.removeEventListener("open-turn-stats",Ae)},[]),D.useEffect(()=>{jt.getState().fetchWorkflows()},[]);const re=D.useMemo(()=>A?L.map(Ae=>Ae.id===A.id?A:Ae):L,[L,A]),Y=D.useRef([]),q=D.useMemo(()=>{const Ae=h8(re,Y.current);return Y.current=Ae,Ae},[re]),{isAutoScrollActive:Z,setAutoScroll:ae}=Yu(N,T),se=D.useCallback(Ae=>{var ce;ae(!1);const pe=document.querySelector(`[data-item-index="${Ae}"]`);pe&&(pe.scrollIntoView({behavior:"smooth",block:"start"}),(ce=pe.closest('[data-testid="chat-scroll-container"]'))==null||ce.scrollBy(0,-80))},[ae]);D.useEffect(()=>{const Ae=pe=>{const ce=C||p||x||S||y;pe.key==="Escape"&&M&&!ce&&O(),pe.key==="ScrollLock"&&ae(!Z)};return window.addEventListener("keydown",Ae),()=>window.removeEventListener("keydown",Ae)},[M,O,Z,C,p,x,S,y]);const oe=xp();LS(oe.quickAction,()=>{v(!0)}),Yj(oe.agentSwitching,X,Ae=>{we.getState().switchMode(Ae)});const je=(T==null?void 0:T.mode)==="planner",Le=(T==null?void 0:T.mode)==="builder",De=Ae=>{const pe=s.trim()?s:void 0,ce=l.length>0?l:void 0;je?W(Ae,pe,ce):Le&&U(pe,ce,Ae),Te()},Re=(Ae,pe)=>{const ce=s.trim()?s:void 0,Se=l.length>0?l:void 0;je?W(Ae,ce,Se,pe):Le&&U(ce,Se,Ae,pe),Te()},Te=()=>{a(""),u([]),T!=null&&T.id&&localStorage.removeItem(`openfox:draft:${T.id}`)};return o.jsxs(o.Fragment,{children:[o.jsxs(TT,{criteriaSidebarOpen:n,onCriteriaSidebarToggle:t,messages:re,children:[o.jsx(DT,{}),y&&o.jsx(RT,{stats:y,onClose:()=>E(null)}),o.jsx(fB,{}),o.jsx(dB,{displayItems:q,scrollContainerRef:N,highlightedMessageId:null}),o.jsx(c8,{input:s,setInput:a,attachments:l,setAttachments:u,dragOver:c,setDragOver:d,errorMessage:f,setErrorMessage:m,scrollContainerRef:N,sessionId:T==null?void 0:T.id,sessionMode:T==null?void 0:T.mode,showHistory:I,history:te,selectedIndex:H,openHistory:$,closeHistory:F,navigateUp:P,navigateDown:ee,selectCurrent:J,isAutoScrollActive:Z,setAutoScroll:ae,onOpenMessageSearch:()=>b(!0),onOpenCommandsModal:()=>_(!0),onOpenWorkflowsModal:()=>w(!0),onSelectWorkflow:De,onSelectWorkflowWithSubGroup:Re,clearInput:Te}),o.jsx(BC,{isOpen:p,onClose:()=>_(!1)}),o.jsx(HC,{isOpen:x,onClose:()=>w(!1)}),o.jsx(EB,{isOpen:C,onClose:()=>v(!1),onSearchMessages:()=>b(!0),isAutoScrollActive:Z,onToggleAutoScroll:ae,textareaContent:s,onCloseComplete:$S,onCloseCompleteAction:()=>window.dispatchEvent(new CustomEvent("open-session-dropdown")),onSelectCommand:async(Ae,pe)=>{const ce=await en.getState().fetchCommand(Ae);if(ce){const Se=pe!=null&&pe.trim()?`${pe.trim()}
300
+
301
+ ${ce.prompt}`:ce.prompt;ce.metadata.agentMode&&we.getState().switchMode(ce.metadata.agentMode),G(Se,l!=null&&l.length?l:void 0,{messageKind:"command",isSystemGenerated:!0}),Te()}},onSelectWorkflow:Ae=>{const pe=s.trim()||void 0,ce=l.length>0?l:void 0;(T==null?void 0:T.mode)==="planner"?we.getState().acceptAndBuild(Ae,pe,ce):we.getState().launchRunner(pe,ce,Ae),Te()}})]}),S&&o.jsx(LB,{isOpen:S,onClose:()=>b(!1),displayItems:q,onNavigate:se})]})}function nS({isOpen:e,isRetry:t,onSubmit:n,onCancel:s}){const[a,l]=D.useState(""),u=D.useRef(null);D.useEffect(()=>{e&&(l(""),setTimeout(()=>{var d;return(d=u.current)==null?void 0:d.focus()},100))},[e]);const c=d=>{d.preventDefault(),a.trim()&&n(a)};return o.jsx(Ot,{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(Wu,{ref:u,type:"password",value:a,onChange:d=>l(d.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 S8({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,d=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":d?"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 ${d?"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 w8({onNext:e}){const[t,n]=D.useState([]),[s,a]=D.useState([]),[l,u]=D.useState(!1),[c,d]=D.useState(null),[f,m]=D.useState(null);D.useEffect(()=>{p()},[]);async function p(){try{const y=await Ne("/api/providers");if(y.ok){const N=(await y.json()).providers.map(T=>({id:T.id,name:T.name,url:T.url,backend:T.backend,model:null,apiKey:T.apiKey,isLocal:T.isLocal,thinkingField:T.thinkingField,models:T.models}));n(N),a(N)}}catch{}}async function _(y){const E=y.id.startsWith("temp-"),N={name:y.name,url:y.url,backend:y.backend,apiKey:y.apiKey,isLocal:y.isLocal,thinkingField:y.thinkingField,models:y.models};try{if(E){const T=await Ne("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(N)});if(T.ok){const L=await T.json(),A={...y,id:L.provider.id,model:null};a(R=>[...R,A]),n(R=>[...R,A])}}else await Ne(`/api/providers/${y.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(N)}),a(T=>T.map(L=>L.id===y.id?{...L,...y,model:null}:L)),n(T=>T.map(L=>L.id===y.id?{...L,...y,model:null}:L))}catch{if(E){const T={...y,model:null};a(L=>[...L,T])}}}function x(){d(null),u(!0)}function w(y){d(y),u(!0)}function C(){u(!1),d(null)}function v(y){m(y),t.some(N=>N.id===y)?Ne(`/api/providers/${y}`,{method:"DELETE"}).then(()=>{a(s.filter(N=>N.id!==y)),n(t.filter(N=>N.id!==y)),m(null)}).catch(()=>m(null)):(a(s.filter(N=>N.id!==y)),m(null))}function S(){const y=s.filter(E=>!E.id.startsWith("temp-"));e({providers:y})}const b=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(y=>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:dp(y.backend)}),o.jsx("span",{className:"text-text-primary font-medium",children:y.name}),o.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded-full ${y.isLocal?"text-accent-success bg-accent-success/10":"text-accent-warning bg-accent-warning/10"}`,children:y.isLocal?"local":"api"})]}),o.jsx("p",{className:"text-text-muted text-sm mt-1",children:y.url}),y.model&&o.jsxs("p",{className:"text-text-secondary text-xs mt-0.5",children:["Model: ",y.model]})]}),o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("button",{onClick:()=>w(y),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:()=>v(y.id),disabled:f===y.id,className:"p-2 text-text-muted hover:text-red-500 transition-colors disabled:opacity-50",title:"Remove provider",children:o.jsx(xl,{})})]})]},y.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(Ks,{className:"w-4 h-4"}),"Add Provider"]}),o.jsx("button",{onClick:S,disabled:!b,"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(GC,{isOpen:l,onClose:C,onSave:_,initialStep:1,editProvider:c??void 0})]})}function C8({onNext:e}){const[t,n]=D.useState(""),[s,a]=D.useState(!1);return D.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(Cp,{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 k8({onNext:e}){const[t,n]=D.useState(!1),[s,a]=D.useState("http://localhost:11434"),[l,u]=D.useState("qwen3.5:0.8b"),{copied:c,copy:d}=DC();D.useEffect(()=>{Ne("/api/config").then(m=>m.json()).then(m=>{m.visionFallback&&(n(m.visionFallback.enabled),a(m.visionFallback.url),u(m.visionFallback.model))}).catch(()=>{})},[]);function f(m){if(m){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:()=>d("ollama pull qwen3.5:0.8b"),className:"text-text-muted hover:text-text-primary transition-colors",title:"Copy",children:c?o.jsx(Pr,{className:"w-4 h-4 text-accent-primary"}):o.jsx(Nj,{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:m=>n(m.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:m=>a(m.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:m=>u(m.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 E8({onComplete:e}){const[t,n]=D.useState(1),[s,a]=D.useState(!1),[l,u]=D.useState({});async function c(p){u(_=>({..._,providers:p.providers})),n(2)}async function d(p){u(_=>({..._,...p})),n(3)}async function f(p){a(!0);try{if(!(await Ne("/api/init/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workdir:l.workdir,visionFallback:p.visionFallback})})).ok)throw new Error("Failed to save config");e()}catch(_){console.error("Failed to save onboarding data:",_),a(!1)}}const m=p=>{n(p)};return o.jsxs("div",{className:"w-full max-w-xl mx-auto px-6 py-16 relative",children:[o.jsx(bl,{onClick:e,className:"absolute top-4 right-4 p-2",variant:"modal",size:"xl"}),o.jsx(S8,{currentStep:t,totalSteps:3,labels:["LLM Server","Projects Folder","Vision"],onStepClick:m}),o.jsx("div",{className:"max-w-xl mx-auto",children:s?o.jsxs("div",{className:"text-center",children:[o.jsx(Ks,{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(w8,{onNext:c}),t===2&&o.jsx(C8,{onNext:d}),t===3&&o.jsx(k8,{onNext:f})]})})]})}const rS="openfox_updated_to",sS="update_pending";function j8(){const[e,t]=D.useState(!1),n=localStorage.getItem(rS),s=localStorage.getItem(sS);D.useEffect(()=>{if(!n||!s)return;const l=setTimeout(()=>t(!0),3e4);return()=>clearTimeout(l)},[n,s]);const a=()=>{localStorage.removeItem(rS),localStorage.removeItem(sS),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(Pr,{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(jS,{className:"w-3.5 h-3.5"})})]})}typeof window<"u"&&(Ft.getState().loadUserPresets(),Ft.getState().applySavedTheme());function hg(){return typeof window>"u"?!1:localStorage.getItem("openfox_token")!==null}function WC(){return o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(vl,{})})}function N8({sidebarOpen:e,onSidebarToggle:t}){const[,n]=up("/p/:projectId"),s=n==null?void 0:n.projectId,a=we(d=>d.connectionStatus),l=Rt(d=>d.currentProject),u=hg();return Sj({canLoad:a==="connected"||u,projectId:s,currentProjectId:l==null?void 0:l.id}),!l||l.id!==s?o.jsx(WC,{}):o.jsxs(o.Fragment,{children:[o.jsx(qS,{projectId:s,isOpen:e,onClose:t}),o.jsx("div",{className:"flex-1 min-w-0 bg-primary",children:o.jsx(FN,{})})]})}function T8({sidebarOpen:e,onSidebarToggle:t,rightSidebarOpen:n,onRightSidebarToggle:s}){const[,a]=up("/p/:projectId/s/:sessionId"),l=a==null?void 0:a.projectId,u=a==null?void 0:a.sessionId,[,c]=hr(),d=we(C=>C.connectionStatus),f=we(C=>C.currentSession),m=we(C=>C.error),p=we(C=>C.clearError),_=Rt(C=>C.currentProject),x=hg();return wj({canLoad:d==="connected"||x,projectId:l,sessionId:u,currentProjectId:_==null?void 0:_.id,currentSessionId:f==null?void 0:f.id}),D.useEffect(()=>{(m==null?void 0:m.code)==="NOT_FOUND"&&l&&(p(),c(`/p/${l}`))},[m,l,p,c]),!_||_.id!==l?o.jsx(WC,{}):o.jsxs(o.Fragment,{children:[o.jsx(qS,{projectId:l,isOpen:e,onClose:t}),o.jsx("div",{className:"flex-1 min-w-0 bg-primary",children:o.jsx(b8,{criteriaSidebarOpen:n,onCriteriaSidebarToggle:s})})]})}function A8(){const e=zt(n=>n.fetchConfig);function t(){e(),window.history.back()}return o.jsx("div",{className:"flex-1 overflow-y-auto",children:o.jsx(E8,{onComplete:t})})}function L8(){const{connectionStatus:e}=xj(),t=zt(V=>V.fetchConfig),n=zt(V=>V.refreshProviderModels),s=zt(V=>V.providers),a=zt(V=>V.activeProviderId),[,l]=hr(),u=hg(),[c,d]=D.useState(!1);D.useEffect(()=>{(e==="connected"||u)&&t().then(()=>{d(!0),on.getState().getSettings([...aS,ze.DISPLAY_THEME,ze.DISPLAY_USER_PRESETS,ze.KEYBINDINGS])})},[e,u,t]),D.useEffect(()=>{c&&a&&n(a).then(()=>{const V=zt.getState().defaultModelSelection;(V?V.split("/")[0]:null)!==a&&t()})},[c,a,n,t]);const f=on(V=>V.settings);D.useEffect(()=>{c&&s.length===0&&l("/onboarding")},[c,s.length]),D.useEffect(()=>{const{applyPreset:V,applyTokens:z,setFollowSystemTheme:X,initSystemThemeListener:te}=Ft.getState(),H=f[ze.DISPLAY_THEME],I=f[ze.DISPLAY_USER_PRESETS],$=f[ze.DISPLAY_FOLLOW_SYSTEM_THEME];if(I&&localStorage.setItem("openfox:userPresets",I),H){localStorage.setItem("openfox:theme",H);try{const P=JSON.parse(H);P.preset&&P.tokens?(V(P.preset),Ft.setState({basePreset:P.preset}),z(P.tokens)):P.preset?V(P.preset):P.tokens&&z(P.tokens)}catch{V("dark")}}else V("system");$!==void 0&&Ft.getState().followSystemTheme!==($==="true")&&X($==="true");const F=te();return()=>F()},[f[ze.DISPLAY_THEME],f[ze.DISPLAY_USER_PRESETS]]);const m=()=>{const V=localStorage.getItem("openfox:leftSidebar");return V!==null?V==="true":!0},p=()=>{const V=localStorage.getItem("openfox:rightSidebar");return V!==null?V==="true":!0},[_,x]=D.useState(m),[w,C]=D.useState(p),[v,S]=D.useState(!1),[b,y]=D.useState(!1),[E,N]=D.useState(!1),T=C2();D.useEffect(()=>{const V=()=>{N(window.innerWidth<768)};return V(),window.addEventListener("resize",V),()=>window.removeEventListener("resize",V)},[]);const L=E?v:_,A=E?b:w,R=()=>{E?S(!v):x(!_)},M=()=>{E?y(!b):C(!w)};D.useEffect(()=>{E||localStorage.setItem("openfox:leftSidebar",String(_))},[_,E]),D.useEffect(()=>{E||localStorage.setItem("openfox:rightSidebar",String(w))},[w,E]),D.useEffect(()=>{(e==="connected"||u)&&t()},[e,t,u]);const G=we(V=>V.showPasswordModal),W=we(V=>V.passwordModalRetry),O=we(V=>V.submitPassword),U=we(V=>V.cancelPassword);return e!=="connected"&&!G&&!u?o.jsxs(o.Fragment,{children:[o.jsx(nS,{isOpen:!0,isRetry:W,onSubmit:O,onCancel:U}),o.jsx("div",{className:"h-screen flex items-center justify-center",children:o.jsx(jN,{text:"Connecting to server..."})})]}):o.jsxs(o.Fragment,{children:[o.jsx(nS,{isOpen:G,isRetry:W,onSubmit:O,onCancel:U}),o.jsxs("div",{className:"flex flex-col",style:{height:E?`calc(${T.offsetTop}px + ${T.height}px)`:"100vh"},children:[o.jsx(zN,{}),o.jsx(RN,{onMenuClick:R,onCriteriaToggle:M}),o.jsx("div",{className:"flex-1 flex overflow-hidden",children:o.jsxs(W2,{children:[o.jsx($o,{path:"/onboarding",children:o.jsx(A8,{})}),o.jsx($o,{path:"/p/:projectId/s/:sessionId",children:o.jsx(T8,{sidebarOpen:L,onSidebarToggle:R,rightSidebarOpen:A,onRightSidebarToggle:M})}),o.jsx($o,{path:"/p/:projectId/new",children:o.jsx(UN,{})}),o.jsx($o,{path:"/p/:projectId",children:o.jsx(N8,{sidebarOpen:L,onSidebarToggle:R})}),o.jsx($o,{path:"/",children:o.jsx(HN,{})})]})})]}),o.jsx(j8,{})]})}y2.createRoot(document.getElementById("root")).render(o.jsx(Us.StrictMode,{children:o.jsx(L8,{})}));