openfox 2.0.60 → 2.0.62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-defaults/builder.agent.md +1 -0
- package/dist/agent-defaults/planner.agent.md +1 -0
- package/dist/{chat-handler-MBR6ZQTX.js → chat-handler-TRAITVLO.js} +4 -4
- package/dist/{chunk-MTBQQ5DN.js → chunk-3WL5YCP6.js} +2 -2
- package/dist/{chunk-DOJKA4XO.js → chunk-BKTBHEPY.js} +5 -5
- package/dist/{chunk-NY6IGGKZ.js → chunk-L4WACPUX.js} +65 -6
- package/dist/{chunk-DEWNWF2P.js → chunk-QZRS2RF5.js} +72 -22
- package/dist/{chunk-WNSAJCWT.js → chunk-SVSKQYFH.js} +6 -2
- package/dist/{chunk-3JRYK5UG.js → chunk-WEB4WBUF.js} +306 -88
- package/dist/cli/dev.js +1 -1
- package/dist/cli/index.js +1 -1
- package/dist/{orchestrator-PIZJ42J2.js → orchestrator-TQ23BAFQ.js} +4 -4
- package/dist/package.json +2 -1
- package/dist/{processor-PKKTNKWY.js → processor-3ZOFGZP5.js} +4 -4
- package/dist/{serve-GKS55Y2C.js → serve-CNA5NKOR.js} +6 -6
- package/dist/server/index.js +5 -5
- package/dist/{server-LMH7ZH5X.js → server-CI5IEBOC.js} +5 -5
- package/dist/{settings-2TQA7VTP.js → settings-ASLTSUE2.js} +2 -2
- package/dist/{tools-WGAZKL56.js → tools-33FQNFKC.js} +3 -3
- package/dist/web/assets/{index-D4bVx84a.css → index-BGkyTfuQ.css} +1 -1
- package/dist/web/assets/index-CETZPQXr.js +302 -0
- package/dist/web/index.html +2 -2
- package/dist/web/sw.js +1 -1
- package/package.json +2 -1
- package/dist/web/assets/index-C0YKw2cD.js +0 -302
|
@@ -0,0 +1,302 @@
|
|
|
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 x2=Object.defineProperty;var y2=Object.getPrototypeOf;var _2=Reflect.get;var ub=e=>{throw TypeError(e)};var b2=(e,t,n)=>t in e?x2(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var be=(e,t,n)=>b2(e,typeof t!="symbol"?t+"":t,n),Df=(e,t,n)=>t.has(e)||ub("Cannot "+n);var Cn=(e,t,n)=>(Df(e,t,"read from private field"),n?n.call(e):t.get(e)),fi=(e,t,n)=>t.has(e)?ub("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),xr=(e,t,n,s)=>(Df(e,t,"write to private field"),s?s.call(e,n):t.set(e,n),n),Of=(e,t,n)=>(Df(e,t,"access private method"),n);var db=(e,t,n)=>_2(y2(e),n,t);function v2(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 Gu(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var If={exports:{}},Go={};/**
|
|
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 hb;function S2(){if(hb)return Go;hb=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 Go.Fragment=t,Go.jsx=n,Go.jsxs=n,Go}var fb;function w2(){return fb||(fb=1,If.exports=S2()),If.exports}var o=w2(),Mf={exports:{}},We={};/**
|
|
11
|
+
* @license React
|
|
12
|
+
* react.production.js
|
|
13
|
+
*
|
|
14
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
15
|
+
*
|
|
16
|
+
* This source code is licensed under the MIT license found in the
|
|
17
|
+
* LICENSE file in the root directory of this source tree.
|
|
18
|
+
*/var mb;function C2(){if(mb)return We;mb=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"),p=Symbol.for("react.lazy"),m=Symbol.for("react.activity"),x=Symbol.iterator;function y(B){return B===null||typeof B!="object"?null:(B=x&&B[x]||B["@@iterator"],typeof B=="function"?B:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,b={};function S(B,W,P){this.props=B,this.context=W,this.refs=b,this.updater=P||w}S.prototype.isReactComponent={},S.prototype.setState=function(B,W){if(typeof B!="object"&&typeof B!="function"&&B!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,B,W,"setState")},S.prototype.forceUpdate=function(B){this.updater.enqueueForceUpdate(this,B,"forceUpdate")};function v(){}v.prototype=S.prototype;function _(B,W,P){this.props=B,this.context=W,this.refs=b,this.updater=P||w}var E=_.prototype=new v;E.constructor=_,C(E,S.prototype),E.isPureReactComponent=!0;var j=Array.isArray;function T(){}var R={H:null,A:null,T:null,S:null},A=Object.prototype.hasOwnProperty;function D(B,W,P){var ee=P.ref;return{$$typeof:e,type:B,key:W,ref:ee!==void 0?ee:null,props:P}}function $(B,W){return D(B.type,W,B.props)}function q(B){return typeof B=="object"&&B!==null&&B.$$typeof===e}function G(B){var W={"=":"=0",":":"=2"};return"$"+B.replace(/[=:]/g,function(P){return W[P]})}var I=/\/+/g;function U(B,W){return typeof B=="object"&&B!==null&&B.key!=null?G(""+B.key):W.toString(36)}function V(B){switch(B.status){case"fulfilled":return B.value;case"rejected":throw B.reason;default:switch(typeof B.status=="string"?B.then(T,T):(B.status="pending",B.then(function(W){B.status==="pending"&&(B.status="fulfilled",B.value=W)},function(W){B.status==="pending"&&(B.status="rejected",B.reason=W)})),B.status){case"fulfilled":return B.value;case"rejected":throw B.reason}}throw B}function z(B,W,P,ee,X){var ne=typeof B;(ne==="undefined"||ne==="boolean")&&(B=null);var Y=!1;if(B===null)Y=!0;else switch(ne){case"bigint":case"string":case"number":Y=!0;break;case"object":switch(B.$$typeof){case e:case t:Y=!0;break;case p:return Y=B._init,z(Y(B._payload),W,P,ee,X)}}if(Y)return X=X(B),Y=ee===""?"."+U(B,0):ee,j(X)?(P="",Y!=null&&(P=Y.replace(I,"$&/")+"/"),z(X,W,P,"",function(se){return se})):X!=null&&(q(X)&&(X=$(X,P+(X.key==null||B&&B.key===X.key?"":(""+X.key).replace(I,"$&/")+"/")+Y)),W.push(X)),1;Y=0;var F=ee===""?".":ee+":";if(j(B))for(var te=0;te<B.length;te++)ee=B[te],ne=F+U(ee,te),Y+=z(ee,W,P,ne,X);else if(te=y(B),typeof te=="function")for(B=te.call(B),te=0;!(ee=B.next()).done;)ee=ee.value,ne=F+U(ee,te++),Y+=z(ee,W,P,ne,X);else if(ne==="object"){if(typeof B.then=="function")return z(V(B),W,P,ee,X);throw W=String(B),Error("Objects are not valid as a React child (found: "+(W==="[object Object]"?"object with keys {"+Object.keys(B).join(", ")+"}":W)+"). If you meant to render a collection of children, use an array instead.")}return Y}function J(B,W,P){if(B==null)return B;var ee=[],X=0;return z(B,ee,"","",function(ne){return W.call(P,ne,X++)}),ee}function Z(B){if(B._status===-1){var W=B._result;W=W(),W.then(function(P){(B._status===0||B._status===-1)&&(B._status=1,B._result=P)},function(P){(B._status===0||B._status===-1)&&(B._status=2,B._result=P)}),B._status===-1&&(B._status=0,B._result=W)}if(B._status===1)return B._result.default;throw B._result}var H=typeof reportError=="function"?reportError:function(B){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var W=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof B=="object"&&B!==null&&typeof B.message=="string"?String(B.message):String(B),error:B});if(!window.dispatchEvent(W))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",B);return}console.error(B)},O={map:J,forEach:function(B,W,P){J(B,function(){W.apply(this,arguments)},P)},count:function(B){var W=0;return J(B,function(){W++}),W},toArray:function(B){return J(B,function(W){return W})||[]},only:function(B){if(!q(B))throw Error("React.Children.only expected to receive a single React element child.");return B}};return We.Activity=m,We.Children=O,We.Component=S,We.Fragment=n,We.Profiler=a,We.PureComponent=_,We.StrictMode=s,We.Suspense=d,We.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=R,We.__COMPILER_RUNTIME={__proto__:null,c:function(B){return R.H.useMemoCache(B)}},We.cache=function(B){return function(){return B.apply(null,arguments)}},We.cacheSignal=function(){return null},We.cloneElement=function(B,W,P){if(B==null)throw Error("The argument must be a React element, but you passed "+B+".");var ee=C({},B.props),X=B.key;if(W!=null)for(ne in W.key!==void 0&&(X=""+W.key),W)!A.call(W,ne)||ne==="key"||ne==="__self"||ne==="__source"||ne==="ref"&&W.ref===void 0||(ee[ne]=W[ne]);var ne=arguments.length-2;if(ne===1)ee.children=P;else if(1<ne){for(var Y=Array(ne),F=0;F<ne;F++)Y[F]=arguments[F+2];ee.children=Y}return D(B.type,X,ee)},We.createContext=function(B){return B={$$typeof:u,_currentValue:B,_currentValue2:B,_threadCount:0,Provider:null,Consumer:null},B.Provider=B,B.Consumer={$$typeof:l,_context:B},B},We.createElement=function(B,W,P){var ee,X={},ne=null;if(W!=null)for(ee in W.key!==void 0&&(ne=""+W.key),W)A.call(W,ee)&&ee!=="key"&&ee!=="__self"&&ee!=="__source"&&(X[ee]=W[ee]);var Y=arguments.length-2;if(Y===1)X.children=P;else if(1<Y){for(var F=Array(Y),te=0;te<Y;te++)F[te]=arguments[te+2];X.children=F}if(B&&B.defaultProps)for(ee in Y=B.defaultProps,Y)X[ee]===void 0&&(X[ee]=Y[ee]);return D(B,ne,X)},We.createRef=function(){return{current:null}},We.forwardRef=function(B){return{$$typeof:c,render:B}},We.isValidElement=q,We.lazy=function(B){return{$$typeof:p,_payload:{_status:-1,_result:B},_init:Z}},We.memo=function(B,W){return{$$typeof:f,type:B,compare:W===void 0?null:W}},We.startTransition=function(B){var W=R.T,P={};R.T=P;try{var ee=B(),X=R.S;X!==null&&X(P,ee),typeof ee=="object"&&ee!==null&&typeof ee.then=="function"&&ee.then(T,H)}catch(ne){H(ne)}finally{W!==null&&P.types!==null&&(W.types=P.types),R.T=W}},We.unstable_useCacheRefresh=function(){return R.H.useCacheRefresh()},We.use=function(B){return R.H.use(B)},We.useActionState=function(B,W,P){return R.H.useActionState(B,W,P)},We.useCallback=function(B,W){return R.H.useCallback(B,W)},We.useContext=function(B){return R.H.useContext(B)},We.useDebugValue=function(){},We.useDeferredValue=function(B,W){return R.H.useDeferredValue(B,W)},We.useEffect=function(B,W){return R.H.useEffect(B,W)},We.useEffectEvent=function(B){return R.H.useEffectEvent(B)},We.useId=function(){return R.H.useId()},We.useImperativeHandle=function(B,W,P){return R.H.useImperativeHandle(B,W,P)},We.useInsertionEffect=function(B,W){return R.H.useInsertionEffect(B,W)},We.useLayoutEffect=function(B,W){return R.H.useLayoutEffect(B,W)},We.useMemo=function(B,W){return R.H.useMemo(B,W)},We.useOptimistic=function(B,W){return R.H.useOptimistic(B,W)},We.useReducer=function(B,W,P){return R.H.useReducer(B,W,P)},We.useRef=function(B){return R.H.useRef(B)},We.useState=function(B){return R.H.useState(B)},We.useSyncExternalStore=function(B,W,P){return R.H.useSyncExternalStore(B,W,P)},We.useTransition=function(){return R.H.useTransition()},We.version="19.2.4",We}var pb;function Wu(){return pb||(pb=1,Mf.exports=C2()),Mf.exports}var L=Wu();const Hs=Gu(L),k2=v2({__proto__:null,default:Hs},[L]);var Pf={exports:{}},Wo={},Bf={exports:{}},zf={};/**
|
|
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 gb;function E2(){return gb||(gb=1,(function(e){function t(z,J){var Z=z.length;z.push(J);e:for(;0<Z;){var H=Z-1>>>1,O=z[H];if(0<a(O,J))z[H]=J,z[Z]=O,Z=H;else break e}}function n(z){return z.length===0?null:z[0]}function s(z){if(z.length===0)return null;var J=z[0],Z=z.pop();if(Z!==J){z[0]=Z;e:for(var H=0,O=z.length,B=O>>>1;H<B;){var W=2*(H+1)-1,P=z[W],ee=W+1,X=z[ee];if(0>a(P,Z))ee<O&&0>a(X,P)?(z[H]=X,z[ee]=Z,H=ee):(z[H]=P,z[W]=Z,H=W);else if(ee<O&&0>a(X,Z))z[H]=X,z[ee]=Z,H=ee;else break e}}return J}function a(z,J){var Z=z.sortIndex-J.sortIndex;return Z!==0?Z:z.id-J.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=[],p=1,m=null,x=3,y=!1,w=!1,C=!1,b=!1,S=typeof setTimeout=="function"?setTimeout:null,v=typeof clearTimeout=="function"?clearTimeout:null,_=typeof setImmediate<"u"?setImmediate:null;function E(z){for(var J=n(f);J!==null;){if(J.callback===null)s(f);else if(J.startTime<=z)s(f),J.sortIndex=J.expirationTime,t(d,J);else break;J=n(f)}}function j(z){if(C=!1,E(z),!w)if(n(d)!==null)w=!0,T||(T=!0,G());else{var J=n(f);J!==null&&V(j,J.startTime-z)}}var T=!1,R=-1,A=5,D=-1;function $(){return b?!0:!(e.unstable_now()-D<A)}function q(){if(b=!1,T){var z=e.unstable_now();D=z;var J=!0;try{e:{w=!1,C&&(C=!1,v(R),R=-1),y=!0;var Z=x;try{t:{for(E(z),m=n(d);m!==null&&!(m.expirationTime>z&&$());){var H=m.callback;if(typeof H=="function"){m.callback=null,x=m.priorityLevel;var O=H(m.expirationTime<=z);if(z=e.unstable_now(),typeof O=="function"){m.callback=O,E(z),J=!0;break t}m===n(d)&&s(d),E(z)}else s(d);m=n(d)}if(m!==null)J=!0;else{var B=n(f);B!==null&&V(j,B.startTime-z),J=!1}}break e}finally{m=null,x=Z,y=!1}J=void 0}}finally{J?G():T=!1}}}var G;if(typeof _=="function")G=function(){_(q)};else if(typeof MessageChannel<"u"){var I=new MessageChannel,U=I.port2;I.port1.onmessage=q,G=function(){U.postMessage(null)}}else G=function(){S(q,0)};function V(z,J){R=S(function(){z(e.unstable_now())},J)}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 x},e.unstable_next=function(z){switch(x){case 1:case 2:case 3:var J=3;break;default:J=x}var Z=x;x=J;try{return z()}finally{x=Z}},e.unstable_requestPaint=function(){b=!0},e.unstable_runWithPriority=function(z,J){switch(z){case 1:case 2:case 3:case 4:case 5:break;default:z=3}var Z=x;x=z;try{return J()}finally{x=Z}},e.unstable_scheduleCallback=function(z,J,Z){var H=e.unstable_now();switch(typeof Z=="object"&&Z!==null?(Z=Z.delay,Z=typeof Z=="number"&&0<Z?H+Z:H):Z=H,z){case 1:var O=-1;break;case 2:O=250;break;case 5:O=1073741823;break;case 4:O=1e4;break;default:O=5e3}return O=Z+O,z={id:p++,callback:J,priorityLevel:z,startTime:Z,expirationTime:O,sortIndex:-1},Z>H?(z.sortIndex=Z,t(f,z),n(d)===null&&z===n(f)&&(C?(v(R),R=-1):C=!0,V(j,Z-H))):(z.sortIndex=O,t(d,z),w||y||(w=!0,T||(T=!0,G()))),z},e.unstable_shouldYield=$,e.unstable_wrapCallback=function(z){var J=x;return function(){var Z=x;x=J;try{return z.apply(this,arguments)}finally{x=Z}}}})(zf)),zf}var xb;function j2(){return xb||(xb=1,Bf.exports=E2()),Bf.exports}var $f={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 yb;function N2(){if(yb)return yn;yb=1;var e=Wu();function t(d){var f="https://react.dev/errors/"+d;if(1<arguments.length){f+="?args[]="+encodeURIComponent(arguments[1]);for(var p=2;p<arguments.length;p++)f+="&args[]="+encodeURIComponent(arguments[p])}return"Minified React error #"+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,p){var m=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:m==null?null:""+m,children:d,containerInfo:f,implementation:p}}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 p=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!f||f.nodeType!==1&&f.nodeType!==9&&f.nodeType!==11)throw Error(t(299));return l(d,f,null,p)},yn.flushSync=function(d){var f=u.T,p=s.p;try{if(u.T=null,s.p=2,d)return d()}finally{u.T=f,s.p=p,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 p=f.as,m=c(p,f.crossOrigin),x=typeof f.integrity=="string"?f.integrity:void 0,y=typeof f.fetchPriority=="string"?f.fetchPriority:void 0;p==="style"?s.d.S(d,typeof f.precedence=="string"?f.precedence:void 0,{crossOrigin:m,integrity:x,fetchPriority:y}):p==="script"&&s.d.X(d,{crossOrigin:m,integrity:x,fetchPriority:y,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 p=c(f.as,f.crossOrigin);s.d.M(d,{crossOrigin:p,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0})}}else f==null&&s.d.M(d)},yn.preload=function(d,f){if(typeof d=="string"&&typeof f=="object"&&f!==null&&typeof f.as=="string"){var p=f.as,m=c(p,f.crossOrigin);s.d.L(d,p,{crossOrigin:m,integrity:typeof f.integrity=="string"?f.integrity:void 0,nonce:typeof f.nonce=="string"?f.nonce:void 0,type:typeof f.type=="string"?f.type:void 0,fetchPriority:typeof f.fetchPriority=="string"?f.fetchPriority:void 0,referrerPolicy:typeof f.referrerPolicy=="string"?f.referrerPolicy:void 0,imageSrcSet:typeof f.imageSrcSet=="string"?f.imageSrcSet:void 0,imageSizes:typeof f.imageSizes=="string"?f.imageSizes:void 0,media:typeof f.media=="string"?f.media:void 0})}},yn.preloadModule=function(d,f){if(typeof d=="string")if(f){var p=c(f.as,f.crossOrigin);s.d.m(d,{as:typeof f.as=="string"&&f.as!=="script"?f.as:void 0,crossOrigin:p,integrity:typeof f.integrity=="string"?f.integrity:void 0})}else s.d.m(d)},yn.requestFormReset=function(d){s.d.r(d)},yn.unstable_batchedUpdates=function(d,f){return d(f)},yn.useFormState=function(d,f,p){return u.H.useFormState(d,f,p)},yn.useFormStatus=function(){return u.H.useHostTransitionStatus()},yn.version="19.2.4",yn}var _b;function dS(){if(_b)return $f.exports;_b=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(),$f.exports=N2(),$f.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 bb;function T2(){if(bb)return Wo;bb=1;var e=j2(),t=Wu(),n=dS();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 N=k.alternate;if(N===null){if(g=k.return,g!==null){h=g;continue}break}if(k.child===N.child){for(N=k.child;N;){if(N===h)return d(k),r;if(N===g)return d(k),i;N=N.sibling}throw Error(s(188))}if(h.return!==g.return)h=k,g=N;else{for(var M=!1,K=k.child;K;){if(K===h){M=!0,h=k,g=N;break}if(K===g){M=!0,g=k,h=N;break}K=K.sibling}if(!M){for(K=N.child;K;){if(K===h){M=!0,h=N,g=k;break}if(K===g){M=!0,g=N,h=k;break}K=K.sibling}if(!M)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 p(r){var i=r.tag;if(i===5||i===26||i===27||i===6)return r;for(r=r.child;r!==null;){if(i=p(r),i!==null)return i;r=r.sibling}return null}var m=Object.assign,x=Symbol.for("react.element"),y=Symbol.for("react.transitional.element"),w=Symbol.for("react.portal"),C=Symbol.for("react.fragment"),b=Symbol.for("react.strict_mode"),S=Symbol.for("react.profiler"),v=Symbol.for("react.consumer"),_=Symbol.for("react.context"),E=Symbol.for("react.forward_ref"),j=Symbol.for("react.suspense"),T=Symbol.for("react.suspense_list"),R=Symbol.for("react.memo"),A=Symbol.for("react.lazy"),D=Symbol.for("react.activity"),$=Symbol.for("react.memo_cache_sentinel"),q=Symbol.iterator;function G(r){return r===null||typeof r!="object"?null:(r=q&&r[q]||r["@@iterator"],typeof r=="function"?r:null)}var I=Symbol.for("react.client.reference");function U(r){if(r==null)return null;if(typeof r=="function")return r.$$typeof===I?null:r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case C:return"Fragment";case S:return"Profiler";case b:return"StrictMode";case j:return"Suspense";case T:return"SuspenseList";case D:return"Activity"}if(typeof r=="object")switch(r.$$typeof){case w:return"Portal";case _:return r.displayName||"Context";case v:return(r._context.displayName||"Context")+".Consumer";case E:var i=r.render;return r=r.displayName,r||(r=i.displayName||i.name||"",r=r!==""?"ForwardRef("+r+")":"ForwardRef"),r;case R: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,J=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Z={pending:!1,data:null,method:null,action:null},H=[],O=-1;function B(r){return{current:r}}function W(r){0>O||(r.current=H[O],H[O]=null,O--)}function P(r,i){O++,H[O]=r.current,r.current=i}var ee=B(null),X=B(null),ne=B(null),Y=B(null);function F(r,i){switch(P(ne,i),P(X,r),P(ee,null),i.nodeType){case 9:case 11:r=(r=i.documentElement)&&(r=r.namespaceURI)?D_(r):0;break;default:if(r=i.tagName,i=i.namespaceURI)i=D_(i),r=O_(i,r);else switch(r){case"svg":r=1;break;case"math":r=2;break;default:r=0}}W(ee),P(ee,r)}function te(){W(ee),W(X),W(ne)}function se(r){r.memoizedState!==null&&P(Y,r);var i=ee.current,h=O_(i,r.type);i!==h&&(P(X,r),P(ee,h))}function xe(r){X.current===r&&(W(ee),W(X)),Y.current===r&&(W(Y),Ho._currentValue=Z)}var le,Ee;function ue(r){if(le===void 0)try{throw Error()}catch(h){var i=h.stack.trim().match(/\n( *(at )?)/);le=i&&i[1]||"",Ee=-1<h.stack.indexOf(`
|
|
43
|
+
at`)?" (<anonymous>)":-1<h.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
44
|
+
`+le+r+Ee}var ae=!1;function de(r,i){if(!r||ae)return"";ae=!0;var h=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var g={DetermineComponentFrameRoot:function(){try{if(i){var je=function(){throw Error()};if(Object.defineProperty(je.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(je,[])}catch(ge){var pe=ge}Reflect.construct(r,[],je)}else{try{je.call()}catch(ge){pe=ge}r.call(je.prototype)}}else{try{throw Error()}catch(ge){pe=ge}(je=r())&&typeof je.catch=="function"&&je.catch(function(){})}}catch(ge){if(ge&&pe&&typeof ge.stack=="string")return[ge.stack,pe.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 N=g.DetermineComponentFrameRoot(),M=N[0],K=N[1];if(M&&K){var ie=M.split(`
|
|
45
|
+
`),me=K.split(`
|
|
46
|
+
`);for(k=g=0;g<ie.length&&!ie[g].includes("DetermineComponentFrameRoot");)g++;for(;k<me.length&&!me[k].includes("DetermineComponentFrameRoot");)k++;if(g===ie.length||k===me.length)for(g=ie.length-1,k=me.length-1;1<=g&&0<=k&&ie[g]!==me[k];)k--;for(;1<=g&&0<=k;g--,k--)if(ie[g]!==me[k]){if(g!==1||k!==1)do if(g--,k--,0>k||ie[g]!==me[k]){var Se=`
|
|
47
|
+
`+ie[g].replace(" at new "," at ");return r.displayName&&Se.includes("<anonymous>")&&(Se=Se.replace("<anonymous>",r.displayName)),Se}while(1<=g&&0<=k);break}}}finally{ae=!1,Error.prepareStackTrace=h}return(h=r?r.displayName||r.name:"")?ue(h):""}function oe(r,i){switch(r.tag){case 26:case 27:case 5:return ue(r.type);case 16:return ue("Lazy");case 13:return r.child!==i&&i!==null?ue("Suspense Fallback"):ue("Suspense");case 19:return ue("SuspenseList");case 0:case 15:return de(r.type,!1);case 11:return de(r.type.render,!1);case 1:return de(r.type,!0);case 31:return ue("Activity");default:return""}}function Ne(r){try{var i="",h=null;do i+=oe(r,h),h=r,r=r.return;while(r);return i}catch(g){return`
|
|
48
|
+
Error generating stack: `+g.message+`
|
|
49
|
+
`+g.stack}}var ve=Object.prototype.hasOwnProperty,re=e.unstable_scheduleCallback,_e=e.unstable_cancelCallback,He=e.unstable_shouldYield,et=e.unstable_requestPaint,rt=e.unstable_now,kt=e.unstable_getCurrentPriorityLevel,ye=e.unstable_ImmediatePriority,Ae=e.unstable_UserBlockingPriority,Be=e.unstable_NormalPriority,Ge=e.unstable_LowPriority,Xe=e.unstable_IdlePriority,Dt=e.log,nt=e.unstable_setDisableYieldValue,Ot=null,pt=null;function xn(r){if(typeof Dt=="function"&&nt(r),pt&&typeof pt.setStrictMode=="function")try{pt.setStrictMode(Ot,r)}catch{}}var xt=Math.clz32?Math.clz32:Mi,hr=Math.log,Pn=Math.LN2;function Mi(r){return r>>>=0,r===0?32:31-(hr(r)/Pn|0)|0}var fr=256,Pi=262144,Bi=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 zi(r,i,h){var g=r.pendingLanes;if(g===0)return 0;var k=0,N=r.suspendedLanes,M=r.pingedLanes;r=r.warmLanes;var K=g&134217727;return K!==0?(g=K&~N,g!==0?k=Cr(g):(M&=K,M!==0?k=Cr(M):h||(h=K&~r,h!==0&&(k=Cr(h))))):(K=g&~N,K!==0?k=Cr(K):M!==0?k=Cr(M):h||(h=g&~r,h!==0&&(k=Cr(h)))),k===0?0:i!==0&&i!==k&&(i&N)===0&&(N=k&-k,h=i&-i,N>=h||N===32&&(h&4194048)!==0)?i:k}function Ys(r,i){return(r.pendingLanes&~(r.suspendedLanes&~r.pingedLanes)&i)===0}function eo(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 Ml(){var r=Bi;return Bi<<=1,(Bi&62914560)===0&&(Bi=4194304),r}function $i(r){for(var i=[],h=0;31>h;h++)i.push(r);return i}function hs(r,i){r.pendingLanes|=i,i!==268435456&&(r.suspendedLanes=0,r.pingedLanes=0,r.warmLanes=0)}function we(r,i,h,g,k,N){var M=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,ie=r.expirationTimes,me=r.hiddenUpdates;for(h=M&~h;0<h;){var Se=31-xt(h),je=1<<Se;K[Se]=0,ie[Se]=-1;var pe=me[Se];if(pe!==null)for(me[Se]=null,Se=0;Se<pe.length;Se++){var ge=pe[Se];ge!==null&&(ge.lane&=-536870913)}h&=~je}g!==0&&ke(r,g,0),N!==0&&k===0&&r.tag!==0&&(r.suspendedLanes|=N&~(M&~i))}function ke(r,i,h){r.pendingLanes|=i,r.suspendedLanes&=~i;var g=31-xt(i);r.entangledLanes|=i,r.entanglements[g]=r.entanglements[g]|1073741824|h&261930}function Ie(r,i){var h=r.entangledLanes|=i;for(r=r.entanglements;h;){var g=31-xt(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:tt(h),(h&(r.suspendedLanes|i))!==0?0:h}function tt(r){switch(r){case 2:r=1;break;case 8:r=4;break;case 32:r=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:r=128;break;case 268435456:r=134217728;break;default:r=0}return r}function qe(r){return r&=-r,2<r?8<r?(r&134217727)!==0?32:268435456:8:2}function dt(){var r=J.p;return r!==0?r:(r=window.event,r===void 0?32:rb(r.type))}function dn(r,i){var h=J.p;try{return J.p=r,i()}finally{J.p=h}}var Pt=Math.random().toString(36).slice(2),yt="__reactFiber$"+Pt,En="__reactProps$"+Pt,Hi="__reactContainer$"+Pt,wd="__reactEvents$"+Pt,ak="__reactListeners$"+Pt,ok="__reactHandles$"+Pt,bg="__reactResources$"+Pt,to="__reactMarker$"+Pt;function Cd(r){delete r[yt],delete r[En],delete r[wd],delete r[ak],delete r[ok]}function Ui(r){var i=r[yt];if(i)return i;for(var h=r.parentNode;h;){if(i=h[Hi]||h[yt]){if(h=i.alternate,i.child!==null||h!==null&&h.child!==null)for(r=H_(r);r!==null;){if(h=r[yt])return h;r=H_(r)}return i}r=h,h=r.parentNode}return null}function Fi(r){if(r=r[yt]||r[Hi]){var i=r.tag;if(i===5||i===6||i===13||i===31||i===26||i===27||i===3)return r}return null}function no(r){var i=r.tag;if(i===5||i===26||i===27||i===6)return r.stateNode;throw Error(s(33))}function Vi(r){var i=r[bg];return i||(i=r[bg]={hoistableStyles:new Map,hoistableScripts:new Map}),i}function on(r){r[to]=!0}var vg=new Set,Sg={};function Xs(r,i){Gi(r,i),Gi(r+"Capture",i)}function Gi(r,i){for(Sg[r]=i,r=0;r<i.length;r++)vg.add(i[r])}var lk=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]*$"),wg={},Cg={};function ck(r){return ve.call(Cg,r)?!0:ve.call(wg,r)?!1:lk.test(r)?Cg[r]=!0:(wg[r]=!0,!1)}function Pl(r,i,h){if(ck(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 Bl(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 Br(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 Qn(r){switch(typeof r){case"bigint":case"boolean":case"number":case"string":case"undefined":return r;case"object":return r;default:return""}}function kg(r){var i=r.type;return(r=r.nodeName)&&r.toLowerCase()==="input"&&(i==="checkbox"||i==="radio")}function uk(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,N=g.set;return Object.defineProperty(r,i,{configurable:!0,get:function(){return k.call(this)},set:function(M){h=""+M,N.call(this,M)}}),Object.defineProperty(r,i,{enumerable:g.enumerable}),{getValue:function(){return h},setValue:function(M){h=""+M},stopTracking:function(){r._valueTracker=null,delete r[i]}}}}function kd(r){if(!r._valueTracker){var i=kg(r)?"checked":"value";r._valueTracker=uk(r,i,""+r[i])}}function Eg(r){if(!r)return!1;var i=r._valueTracker;if(!i)return!0;var h=i.getValue(),g="";return r&&(g=kg(r)?r.checked?"true":"false":r.value),r=g,r!==h?(i.setValue(r),!0):!1}function zl(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 dk=/[\n"\\]/g;function Jn(r){return r.replace(dk,function(i){return"\\"+i.charCodeAt(0).toString(16)+" "})}function Ed(r,i,h,g,k,N,M,K){r.name="",M!=null&&typeof M!="function"&&typeof M!="symbol"&&typeof M!="boolean"?r.type=M:r.removeAttribute("type"),i!=null?M==="number"?(i===0&&r.value===""||r.value!=i)&&(r.value=""+Qn(i)):r.value!==""+Qn(i)&&(r.value=""+Qn(i)):M!=="submit"&&M!=="reset"||r.removeAttribute("value"),i!=null?jd(r,M,Qn(i)):h!=null?jd(r,M,Qn(h)):g!=null&&r.removeAttribute("value"),k==null&&N!=null&&(r.defaultChecked=!!N),k!=null&&(r.checked=k&&typeof k!="function"&&typeof k!="symbol"),K!=null&&typeof K!="function"&&typeof K!="symbol"&&typeof K!="boolean"?r.name=""+Qn(K):r.removeAttribute("name")}function jg(r,i,h,g,k,N,M,K){if(N!=null&&typeof N!="function"&&typeof N!="symbol"&&typeof N!="boolean"&&(r.type=N),i!=null||h!=null){if(!(N!=="submit"&&N!=="reset"||i!=null)){kd(r);return}h=h!=null?""+Qn(h):"",i=i!=null?""+Qn(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,M!=null&&typeof M!="function"&&typeof M!="symbol"&&typeof M!="boolean"&&(r.name=M),kd(r)}function jd(r,i,h){i==="number"&&zl(r.ownerDocument)===r||r.defaultValue===""+h||(r.defaultValue=""+h)}function Wi(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=""+Qn(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 Ng(r,i,h){if(i!=null&&(i=""+Qn(i),i!==r.value&&(r.value=i),h==null)){r.defaultValue!==i&&(r.defaultValue=i);return}r.defaultValue=h!=null?""+Qn(h):""}function Tg(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=Qn(i),r.defaultValue=h,g=r.textContent,g===h&&g!==""&&g!==null&&(r.value=g),kd(r)}function qi(r,i){if(i){var h=r.firstChild;if(h&&h===r.lastChild&&h.nodeType===3){h.nodeValue=i;return}}r.textContent=i}var hk=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 Ag(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||hk.has(i)?i==="float"?r.cssFloat=h:r[i]=(""+h).trim():r[i]=h+"px"}function Lg(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&&Ag(r,k,g)}else for(var N in i)i.hasOwnProperty(N)&&Ag(r,N,i[N])}function Nd(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 fk=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"]]),mk=/^[\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 $l(r){return mk.test(""+r)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":r}function zr(){}var Td=null;function Ad(r){return r=r.target||r.srcElement||window,r.correspondingUseElement&&(r=r.correspondingUseElement),r.nodeType===3?r.parentNode:r}var Ki=null,Yi=null;function Rg(r){var i=Fi(r);if(i&&(r=i.stateNode)){var h=r[En]||null;e:switch(r=i.stateNode,i.type){case"input":if(Ed(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="'+Jn(""+i)+'"][type="radio"]'),i=0;i<h.length;i++){var g=h[i];if(g!==r&&g.form===r.form){var k=g[En]||null;if(!k)throw Error(s(90));Ed(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&&Eg(g)}break e;case"textarea":Ng(r,h.value,h.defaultValue);break e;case"select":i=h.value,i!=null&&Wi(r,!!h.multiple,i,!1)}}}var Ld=!1;function Dg(r,i,h){if(Ld)return r(i,h);Ld=!0;try{var g=r(i);return g}finally{if(Ld=!1,(Ki!==null||Yi!==null)&&(jc(),Ki&&(i=Ki,r=Yi,Yi=Ki=null,Rg(i),r)))for(i=0;i<r.length;i++)Rg(r[i])}}function ro(r,i){var h=r.stateNode;if(h===null)return null;var g=h[En]||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 $r=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Rd=!1;if($r)try{var so={};Object.defineProperty(so,"passive",{get:function(){Rd=!0}}),window.addEventListener("test",so,so),window.removeEventListener("test",so,so)}catch{Rd=!1}var fs=null,Dd=null,Hl=null;function Og(){if(Hl)return Hl;var r,i=Dd,h=i.length,g,k="value"in fs?fs.value:fs.textContent,N=k.length;for(r=0;r<h&&i[r]===k[r];r++);var M=h-r;for(g=1;g<=M&&i[h-g]===k[N-g];g++);return Hl=k.slice(r,1<g?1-g:void 0)}function Ul(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 Fl(){return!0}function Ig(){return!1}function jn(r){function i(h,g,k,N,M){this._reactName=h,this._targetInst=k,this.type=g,this.nativeEvent=N,this.target=M,this.currentTarget=null;for(var K in r)r.hasOwnProperty(K)&&(h=r[K],this[K]=h?h(N):N[K]);return this.isDefaultPrevented=(N.defaultPrevented!=null?N.defaultPrevented:N.returnValue===!1)?Fl:Ig,this.isPropagationStopped=Ig,this}return m(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=Fl)},stopPropagation:function(){var h=this.nativeEvent;h&&(h.stopPropagation?h.stopPropagation():typeof h.cancelBubble!="unknown"&&(h.cancelBubble=!0),this.isPropagationStopped=Fl)},persist:function(){},isPersistent:Fl}),i}var Qs={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(r){return r.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Vl=jn(Qs),io=m({},Qs,{view:0,detail:0}),pk=jn(io),Od,Id,ao,Gl=m({},io,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Pd,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!==ao&&(ao&&r.type==="mousemove"?(Od=r.screenX-ao.screenX,Id=r.screenY-ao.screenY):Id=Od=0,ao=r),Od)},movementY:function(r){return"movementY"in r?r.movementY:Id}}),Mg=jn(Gl),gk=m({},Gl,{dataTransfer:0}),xk=jn(gk),yk=m({},io,{relatedTarget:0}),Md=jn(yk),_k=m({},Qs,{animationName:0,elapsedTime:0,pseudoElement:0}),bk=jn(_k),vk=m({},Qs,{clipboardData:function(r){return"clipboardData"in r?r.clipboardData:window.clipboardData}}),Sk=jn(vk),wk=m({},Qs,{data:0}),Pg=jn(wk),Ck={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},kk={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"},Ek={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function jk(r){var i=this.nativeEvent;return i.getModifierState?i.getModifierState(r):(r=Ek[r])?!!i[r]:!1}function Pd(){return jk}var Nk=m({},io,{key:function(r){if(r.key){var i=Ck[r.key]||r.key;if(i!=="Unidentified")return i}return r.type==="keypress"?(r=Ul(r),r===13?"Enter":String.fromCharCode(r)):r.type==="keydown"||r.type==="keyup"?kk[r.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Pd,charCode:function(r){return r.type==="keypress"?Ul(r):0},keyCode:function(r){return r.type==="keydown"||r.type==="keyup"?r.keyCode:0},which:function(r){return r.type==="keypress"?Ul(r):r.type==="keydown"||r.type==="keyup"?r.keyCode:0}}),Tk=jn(Nk),Ak=m({},Gl,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Bg=jn(Ak),Lk=m({},io,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Pd}),Rk=jn(Lk),Dk=m({},Qs,{propertyName:0,elapsedTime:0,pseudoElement:0}),Ok=jn(Dk),Ik=m({},Gl,{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}),Mk=jn(Ik),Pk=m({},Qs,{newState:0,oldState:0}),Bk=jn(Pk),zk=[9,13,27,32],Bd=$r&&"CompositionEvent"in window,oo=null;$r&&"documentMode"in document&&(oo=document.documentMode);var $k=$r&&"TextEvent"in window&&!oo,zg=$r&&(!Bd||oo&&8<oo&&11>=oo),$g=" ",Hg=!1;function Ug(r,i){switch(r){case"keyup":return zk.indexOf(i.keyCode)!==-1;case"keydown":return i.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Fg(r){return r=r.detail,typeof r=="object"&&"data"in r?r.data:null}var Xi=!1;function Hk(r,i){switch(r){case"compositionend":return Fg(i);case"keypress":return i.which!==32?null:(Hg=!0,$g);case"textInput":return r=i.data,r===$g&&Hg?null:r;default:return null}}function Uk(r,i){if(Xi)return r==="compositionend"||!Bd&&Ug(r,i)?(r=Og(),Hl=Dd=fs=null,Xi=!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 zg&&i.locale!=="ko"?null:i.data;default:return null}}var Fk={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 Vg(r){var i=r&&r.nodeName&&r.nodeName.toLowerCase();return i==="input"?!!Fk[r.type]:i==="textarea"}function Gg(r,i,h,g){Ki?Yi?Yi.push(g):Yi=[g]:Ki=g,i=Oc(i,"onChange"),0<i.length&&(h=new Vl("onChange","change",null,h,g),r.push({event:h,listeners:i}))}var lo=null,co=null;function Vk(r){j_(r,0)}function Wl(r){var i=no(r);if(Eg(i))return r}function Wg(r,i){if(r==="change")return i}var qg=!1;if($r){var zd;if($r){var $d="oninput"in document;if(!$d){var Kg=document.createElement("div");Kg.setAttribute("oninput","return;"),$d=typeof Kg.oninput=="function"}zd=$d}else zd=!1;qg=zd&&(!document.documentMode||9<document.documentMode)}function Yg(){lo&&(lo.detachEvent("onpropertychange",Xg),co=lo=null)}function Xg(r){if(r.propertyName==="value"&&Wl(co)){var i=[];Gg(i,co,r,Ad(r)),Dg(Vk,i)}}function Gk(r,i,h){r==="focusin"?(Yg(),lo=i,co=h,lo.attachEvent("onpropertychange",Xg)):r==="focusout"&&Yg()}function Wk(r){if(r==="selectionchange"||r==="keyup"||r==="keydown")return Wl(co)}function qk(r,i){if(r==="click")return Wl(i)}function Kk(r,i){if(r==="input"||r==="change")return Wl(i)}function Yk(r,i){return r===i&&(r!==0||1/r===1/i)||r!==r&&i!==i}var Bn=typeof Object.is=="function"?Object.is:Yk;function uo(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(!ve.call(i,k)||!Bn(r[k],i[k]))return!1}return!0}function Qg(r){for(;r&&r.firstChild;)r=r.firstChild;return r}function Jg(r,i){var h=Qg(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=Qg(h)}}function Zg(r,i){return r&&i?r===i?!0:r&&r.nodeType===3?!1:i&&i.nodeType===3?Zg(r,i.parentNode):"contains"in r?r.contains(i):r.compareDocumentPosition?!!(r.compareDocumentPosition(i)&16):!1:!1}function ex(r){r=r!=null&&r.ownerDocument!=null&&r.ownerDocument.defaultView!=null?r.ownerDocument.defaultView:window;for(var i=zl(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=zl(r.document)}return i}function Hd(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 Xk=$r&&"documentMode"in document&&11>=document.documentMode,Qi=null,Ud=null,ho=null,Fd=!1;function tx(r,i,h){var g=h.window===h?h.document:h.nodeType===9?h:h.ownerDocument;Fd||Qi==null||Qi!==zl(g)||(g=Qi,"selectionStart"in g&&Hd(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}),ho&&uo(ho,g)||(ho=g,g=Oc(Ud,"onSelect"),0<g.length&&(i=new Vl("onSelect","select",null,i,h),r.push({event:i,listeners:g}),i.target=Qi)))}function Js(r,i){var h={};return h[r.toLowerCase()]=i.toLowerCase(),h["Webkit"+r]="webkit"+i,h["Moz"+r]="moz"+i,h}var Ji={animationend:Js("Animation","AnimationEnd"),animationiteration:Js("Animation","AnimationIteration"),animationstart:Js("Animation","AnimationStart"),transitionrun:Js("Transition","TransitionRun"),transitionstart:Js("Transition","TransitionStart"),transitioncancel:Js("Transition","TransitionCancel"),transitionend:Js("Transition","TransitionEnd")},Vd={},nx={};$r&&(nx=document.createElement("div").style,"AnimationEvent"in window||(delete Ji.animationend.animation,delete Ji.animationiteration.animation,delete Ji.animationstart.animation),"TransitionEvent"in window||delete Ji.transitionend.transition);function Zs(r){if(Vd[r])return Vd[r];if(!Ji[r])return r;var i=Ji[r],h;for(h in i)if(i.hasOwnProperty(h)&&h in nx)return Vd[r]=i[h];return r}var rx=Zs("animationend"),sx=Zs("animationiteration"),ix=Zs("animationstart"),Qk=Zs("transitionrun"),Jk=Zs("transitionstart"),Zk=Zs("transitioncancel"),ax=Zs("transitionend"),ox=new Map,Gd="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(" ");Gd.push("scrollEnd");function mr(r,i){ox.set(r,i),Xs(i,[r])}var ql=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)},Zn=[],Zi=0,Wd=0;function Kl(){for(var r=Zi,i=Wd=Zi=0;i<r;){var h=Zn[i];Zn[i++]=null;var g=Zn[i];Zn[i++]=null;var k=Zn[i];Zn[i++]=null;var N=Zn[i];if(Zn[i++]=null,g!==null&&k!==null){var M=g.pending;M===null?k.next=k:(k.next=M.next,M.next=k),g.pending=k}N!==0&&lx(h,k,N)}}function Yl(r,i,h,g){Zn[Zi++]=r,Zn[Zi++]=i,Zn[Zi++]=h,Zn[Zi++]=g,Wd|=g,r.lanes|=g,r=r.alternate,r!==null&&(r.lanes|=g)}function qd(r,i,h,g){return Yl(r,i,h,g),Xl(r)}function ei(r,i){return Yl(r,null,null,i),Xl(r)}function lx(r,i,h){r.lanes|=h;var g=r.alternate;g!==null&&(g.lanes|=h);for(var k=!1,N=r.return;N!==null;)N.childLanes|=h,g=N.alternate,g!==null&&(g.childLanes|=h),N.tag===22&&(r=N.stateNode,r===null||r._visibility&1||(k=!0)),r=N,N=N.return;return r.tag===3?(N=r.stateNode,k&&i!==null&&(k=31-xt(h),r=N.hiddenUpdates,g=r[k],g===null?r[k]=[i]:g.push(i),i.lane=h|536870912),N):null}function Xl(r){if(50<Oo)throw Oo=0,nf=null,Error(s(185));for(var i=r.return;i!==null;)r=i,i=r.return;return r.tag===3?r.stateNode:null}var ea={};function eE(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 eE(r,i,h,g)}function Kd(r){return r=r.prototype,!(!r||!r.isReactComponent)}function Hr(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 cx(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 Ql(r,i,h,g,k,N){var M=0;if(g=r,typeof r=="function")Kd(r)&&(M=1);else if(typeof r=="string")M=i2(r,h,ee.current)?26:r==="html"||r==="head"||r==="body"?27:5;else e:switch(r){case D:return r=zn(31,h,i,k),r.elementType=D,r.lanes=N,r;case C:return ti(h.children,k,N,i);case b:M=8,k|=24;break;case S:return r=zn(12,h,i,k|2),r.elementType=S,r.lanes=N,r;case j:return r=zn(13,h,i,k),r.elementType=j,r.lanes=N,r;case T:return r=zn(19,h,i,k),r.elementType=T,r.lanes=N,r;default:if(typeof r=="object"&&r!==null)switch(r.$$typeof){case _:M=10;break e;case v:M=9;break e;case E:M=11;break e;case R:M=14;break e;case A:M=16,g=null;break e}M=29,h=Error(s(130,r===null?"null":typeof r,"")),g=null}return i=zn(M,h,i,k),i.elementType=r,i.type=g,i.lanes=N,i}function ti(r,i,h,g){return r=zn(7,r,g,i),r.lanes=h,r}function Yd(r,i,h){return r=zn(6,r,null,i),r.lanes=h,r}function ux(r){var i=zn(18,null,null,0);return i.stateNode=r,i}function Xd(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 dx=new WeakMap;function er(r,i){if(typeof r=="object"&&r!==null){var h=dx.get(r);return h!==void 0?h:(i={value:r,source:i,stack:Ne(i)},dx.set(r,i),i)}return{value:r,source:i,stack:Ne(i)}}var ta=[],na=0,Jl=null,fo=0,tr=[],nr=0,ms=null,kr=1,Er="";function Ur(r,i){ta[na++]=fo,ta[na++]=Jl,Jl=r,fo=i}function hx(r,i,h){tr[nr++]=kr,tr[nr++]=Er,tr[nr++]=ms,ms=r;var g=kr;r=Er;var k=32-xt(g)-1;g&=~(1<<k),h+=1;var N=32-xt(i)+k;if(30<N){var M=k-k%5;N=(g&(1<<M)-1).toString(32),g>>=M,k-=M,kr=1<<32-xt(i)+k|h<<k|g,Er=N+r}else kr=1<<N|h<<k|g,Er=r}function Qd(r){r.return!==null&&(Ur(r,1),hx(r,1,0))}function Jd(r){for(;r===Jl;)Jl=ta[--na],ta[na]=null,fo=ta[--na],ta[na]=null;for(;r===ms;)ms=tr[--nr],tr[nr]=null,Er=tr[--nr],tr[nr]=null,kr=tr[--nr],tr[nr]=null}function fx(r,i){tr[nr++]=kr,tr[nr++]=Er,tr[nr++]=ms,kr=i.id,Er=i.overflow,ms=r}var hn=null,It=null,ct=!1,ps=null,rr=!1,Zd=Error(s(519));function gs(r){var i=Error(s(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw mo(er(i,r)),Zd}function mx(r){var i=r.stateNode,h=r.type,g=r.memoizedProps;switch(i[yt]=r,i[En]=g,h){case"dialog":it("cancel",i),it("close",i);break;case"iframe":case"object":case"embed":it("load",i);break;case"video":case"audio":for(h=0;h<Mo.length;h++)it(Mo[h],i);break;case"source":it("error",i);break;case"img":case"image":case"link":it("error",i),it("load",i);break;case"details":it("toggle",i);break;case"input":it("invalid",i),jg(i,g.value,g.defaultValue,g.checked,g.defaultChecked,g.type,g.name,!0);break;case"select":it("invalid",i);break;case"textarea":it("invalid",i),Tg(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||L_(i.textContent,h)?(g.popover!=null&&(it("beforetoggle",i),it("toggle",i)),g.onScroll!=null&&it("scroll",i),g.onScrollEnd!=null&&it("scrollend",i),g.onClick!=null&&(i.onclick=zr),i=!0):i=!1,i||gs(r,!0)}function px(r){for(hn=r.return;hn;)switch(hn.tag){case 5:case 31:case 13:rr=!1;return;case 27:case 3:rr=!0;return;default:hn=hn.return}}function ra(r){if(r!==hn)return!1;if(!ct)return px(r),ct=!0,!1;var i=r.tag,h;if((h=i!==3&&i!==27)&&((h=i===5)&&(h=r.type,h=!(h!=="form"&&h!=="button")||yf(r.type,r.memoizedProps)),h=!h),h&&It&&gs(r),px(r),i===13){if(r=r.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(s(317));It=$_(r)}else if(i===31){if(r=r.memoizedState,r=r!==null?r.dehydrated:null,!r)throw Error(s(317));It=$_(r)}else i===27?(i=It,As(r.type)?(r=wf,wf=null,It=r):It=i):It=hn?ir(r.stateNode.nextSibling):null;return!0}function ni(){It=hn=null,ct=!1}function eh(){var r=ps;return r!==null&&(Ln===null?Ln=r:Ln.push.apply(Ln,r),ps=null),r}function mo(r){ps===null?ps=[r]:ps.push(r)}var th=B(null),ri=null,Fr=null;function xs(r,i,h){P(th,i._currentValue),i._currentValue=h}function Vr(r){r._currentValue=th.current,W(th)}function nh(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 rh(r,i,h,g){var k=r.child;for(k!==null&&(k.return=r);k!==null;){var N=k.dependencies;if(N!==null){var M=k.child;N=N.firstContext;e:for(;N!==null;){var K=N;N=k;for(var ie=0;ie<i.length;ie++)if(K.context===i[ie]){N.lanes|=h,K=N.alternate,K!==null&&(K.lanes|=h),nh(N.return,h,r),g||(M=null);break e}N=K.next}}else if(k.tag===18){if(M=k.return,M===null)throw Error(s(341));M.lanes|=h,N=M.alternate,N!==null&&(N.lanes|=h),nh(M,h,r),M=null}else M=k.child;if(M!==null)M.return=k;else for(M=k;M!==null;){if(M===r){M=null;break}if(k=M.sibling,k!==null){k.return=M.return,M=k;break}M=M.return}k=M}}function sa(r,i,h,g){r=null;for(var k=i,N=!1;k!==null;){if(!N){if((k.flags&524288)!==0)N=!0;else if((k.flags&262144)!==0)break}if(k.tag===10){var M=k.alternate;if(M===null)throw Error(s(387));if(M=M.memoizedProps,M!==null){var K=k.type;Bn(k.pendingProps.value,M.value)||(r!==null?r.push(K):r=[K])}}else if(k===Y.current){if(M=k.alternate,M===null)throw Error(s(387));M.memoizedState.memoizedState!==k.memoizedState.memoizedState&&(r!==null?r.push(Ho):r=[Ho])}k=k.return}r!==null&&rh(i,r,h,g),i.flags|=262144}function Zl(r){for(r=r.firstContext;r!==null;){if(!Bn(r.context._currentValue,r.memoizedValue))return!0;r=r.next}return!1}function si(r){ri=r,Fr=null,r=r.dependencies,r!==null&&(r.firstContext=null)}function fn(r){return gx(ri,r)}function ec(r,i){return ri===null&&si(r),gx(r,i)}function gx(r,i){var h=i._currentValue;if(i={context:i,memoizedValue:h,next:null},Fr===null){if(r===null)throw Error(s(308));Fr=i,r.dependencies={lanes:0,firstContext:i},r.flags|=524288}else Fr=Fr.next=i;return h}var tE=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()})}},nE=e.unstable_scheduleCallback,rE=e.unstable_NormalPriority,Kt={$$typeof:_,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function sh(){return{controller:new tE,data:new Map,refCount:0}}function po(r){r.refCount--,r.refCount===0&&nE(rE,function(){r.controller.abort()})}var go=null,ih=0,ia=0,aa=null;function sE(r,i){if(go===null){var h=go=[];ih=0,ia=cf(),aa={status:"pending",value:void 0,then:function(g){h.push(g)}}}return ih++,i.then(xx,xx),i}function xx(){if(--ih===0&&go!==null){aa!==null&&(aa.status="fulfilled");var r=go;go=null,ia=0,aa=null;for(var i=0;i<r.length;i++)(0,r[i])()}}function iE(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 yx=z.S;z.S=function(r,i){t_=rt(),typeof i=="object"&&i!==null&&typeof i.then=="function"&&sE(r,i),yx!==null&&yx(r,i)};var ii=B(null);function ah(){var r=ii.current;return r!==null?r:Et.pooledCache}function tc(r,i){i===null?P(ii,ii.current):P(ii,i.pool)}function _x(){var r=ah();return r===null?null:{parent:Kt._currentValue,pool:r}}var oa=Error(s(460)),oh=Error(s(474)),nc=Error(s(542)),rc={then:function(){}};function bx(r){return r=r.status,r==="fulfilled"||r==="rejected"}function vx(r,i,h){switch(h=r[h],h===void 0?r.push(i):h!==i&&(i.then(zr,zr),i=h),i.status){case"fulfilled":return i.value;case"rejected":throw r=i.reason,wx(r),r;default:if(typeof i.status=="string")i.then(zr,zr);else{if(r=Et,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,wx(r),r}throw oi=i,oa}}function ai(r){try{var i=r._init;return i(r._payload)}catch(h){throw h!==null&&typeof h=="object"&&typeof h.then=="function"?(oi=h,oa):h}}var oi=null;function Sx(){if(oi===null)throw Error(s(459));var r=oi;return oi=null,r}function wx(r){if(r===oa||r===nc)throw Error(s(483))}var la=null,xo=0;function sc(r){var i=xo;return xo+=1,la===null&&(la=[]),vx(la,r,i)}function yo(r,i){i=i.props.ref,r.ref=i!==void 0?i:null}function ic(r,i){throw i.$$typeof===x?Error(s(525)):(r=Object.prototype.toString.call(i),Error(s(31,r==="[object Object]"?"object with keys {"+Object.keys(i).join(", ")+"}":r)))}function Cx(r){function i(he,ce){if(r){var fe=he.deletions;fe===null?(he.deletions=[ce],he.flags|=16):fe.push(ce)}}function h(he,ce){if(!r)return null;for(;ce!==null;)i(he,ce),ce=ce.sibling;return null}function g(he){for(var ce=new Map;he!==null;)he.key!==null?ce.set(he.key,he):ce.set(he.index,he),he=he.sibling;return ce}function k(he,ce){return he=Hr(he,ce),he.index=0,he.sibling=null,he}function N(he,ce,fe){return he.index=fe,r?(fe=he.alternate,fe!==null?(fe=fe.index,fe<ce?(he.flags|=67108866,ce):fe):(he.flags|=67108866,ce)):(he.flags|=1048576,ce)}function M(he){return r&&he.alternate===null&&(he.flags|=67108866),he}function K(he,ce,fe,Ce){return ce===null||ce.tag!==6?(ce=Yd(fe,he.mode,Ce),ce.return=he,ce):(ce=k(ce,fe),ce.return=he,ce)}function ie(he,ce,fe,Ce){var ze=fe.type;return ze===C?Se(he,ce,fe.props.children,Ce,fe.key):ce!==null&&(ce.elementType===ze||typeof ze=="object"&&ze!==null&&ze.$$typeof===A&&ai(ze)===ce.type)?(ce=k(ce,fe.props),yo(ce,fe),ce.return=he,ce):(ce=Ql(fe.type,fe.key,fe.props,null,he.mode,Ce),yo(ce,fe),ce.return=he,ce)}function me(he,ce,fe,Ce){return ce===null||ce.tag!==4||ce.stateNode.containerInfo!==fe.containerInfo||ce.stateNode.implementation!==fe.implementation?(ce=Xd(fe,he.mode,Ce),ce.return=he,ce):(ce=k(ce,fe.children||[]),ce.return=he,ce)}function Se(he,ce,fe,Ce,ze){return ce===null||ce.tag!==7?(ce=ti(fe,he.mode,Ce,ze),ce.return=he,ce):(ce=k(ce,fe),ce.return=he,ce)}function je(he,ce,fe){if(typeof ce=="string"&&ce!==""||typeof ce=="number"||typeof ce=="bigint")return ce=Yd(""+ce,he.mode,fe),ce.return=he,ce;if(typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case y:return fe=Ql(ce.type,ce.key,ce.props,null,he.mode,fe),yo(fe,ce),fe.return=he,fe;case w:return ce=Xd(ce,he.mode,fe),ce.return=he,ce;case A:return ce=ai(ce),je(he,ce,fe)}if(V(ce)||G(ce))return ce=ti(ce,he.mode,fe,null),ce.return=he,ce;if(typeof ce.then=="function")return je(he,sc(ce),fe);if(ce.$$typeof===_)return je(he,ec(he,ce),fe);ic(he,ce)}return null}function pe(he,ce,fe,Ce){var ze=ce!==null?ce.key:null;if(typeof fe=="string"&&fe!==""||typeof fe=="number"||typeof fe=="bigint")return ze!==null?null:K(he,ce,""+fe,Ce);if(typeof fe=="object"&&fe!==null){switch(fe.$$typeof){case y:return fe.key===ze?ie(he,ce,fe,Ce):null;case w:return fe.key===ze?me(he,ce,fe,Ce):null;case A:return fe=ai(fe),pe(he,ce,fe,Ce)}if(V(fe)||G(fe))return ze!==null?null:Se(he,ce,fe,Ce,null);if(typeof fe.then=="function")return pe(he,ce,sc(fe),Ce);if(fe.$$typeof===_)return pe(he,ce,ec(he,fe),Ce);ic(he,fe)}return null}function ge(he,ce,fe,Ce,ze){if(typeof Ce=="string"&&Ce!==""||typeof Ce=="number"||typeof Ce=="bigint")return he=he.get(fe)||null,K(ce,he,""+Ce,ze);if(typeof Ce=="object"&&Ce!==null){switch(Ce.$$typeof){case y:return he=he.get(Ce.key===null?fe:Ce.key)||null,ie(ce,he,Ce,ze);case w:return he=he.get(Ce.key===null?fe:Ce.key)||null,me(ce,he,Ce,ze);case A:return Ce=ai(Ce),ge(he,ce,fe,Ce,ze)}if(V(Ce)||G(Ce))return he=he.get(fe)||null,Se(ce,he,Ce,ze,null);if(typeof Ce.then=="function")return ge(he,ce,fe,sc(Ce),ze);if(Ce.$$typeof===_)return ge(he,ce,fe,ec(ce,Ce),ze);ic(ce,Ce)}return null}function Me(he,ce,fe,Ce){for(var ze=null,ht=null,Pe=ce,Qe=ce=0,lt=null;Pe!==null&&Qe<fe.length;Qe++){Pe.index>Qe?(lt=Pe,Pe=null):lt=Pe.sibling;var ft=pe(he,Pe,fe[Qe],Ce);if(ft===null){Pe===null&&(Pe=lt);break}r&&Pe&&ft.alternate===null&&i(he,Pe),ce=N(ft,ce,Qe),ht===null?ze=ft:ht.sibling=ft,ht=ft,Pe=lt}if(Qe===fe.length)return h(he,Pe),ct&&Ur(he,Qe),ze;if(Pe===null){for(;Qe<fe.length;Qe++)Pe=je(he,fe[Qe],Ce),Pe!==null&&(ce=N(Pe,ce,Qe),ht===null?ze=Pe:ht.sibling=Pe,ht=Pe);return ct&&Ur(he,Qe),ze}for(Pe=g(Pe);Qe<fe.length;Qe++)lt=ge(Pe,he,Qe,fe[Qe],Ce),lt!==null&&(r&<.alternate!==null&&Pe.delete(lt.key===null?Qe:lt.key),ce=N(lt,ce,Qe),ht===null?ze=lt:ht.sibling=lt,ht=lt);return r&&Pe.forEach(function(Is){return i(he,Is)}),ct&&Ur(he,Qe),ze}function Fe(he,ce,fe,Ce){if(fe==null)throw Error(s(151));for(var ze=null,ht=null,Pe=ce,Qe=ce=0,lt=null,ft=fe.next();Pe!==null&&!ft.done;Qe++,ft=fe.next()){Pe.index>Qe?(lt=Pe,Pe=null):lt=Pe.sibling;var Is=pe(he,Pe,ft.value,Ce);if(Is===null){Pe===null&&(Pe=lt);break}r&&Pe&&Is.alternate===null&&i(he,Pe),ce=N(Is,ce,Qe),ht===null?ze=Is:ht.sibling=Is,ht=Is,Pe=lt}if(ft.done)return h(he,Pe),ct&&Ur(he,Qe),ze;if(Pe===null){for(;!ft.done;Qe++,ft=fe.next())ft=je(he,ft.value,Ce),ft!==null&&(ce=N(ft,ce,Qe),ht===null?ze=ft:ht.sibling=ft,ht=ft);return ct&&Ur(he,Qe),ze}for(Pe=g(Pe);!ft.done;Qe++,ft=fe.next())ft=ge(Pe,he,Qe,ft.value,Ce),ft!==null&&(r&&ft.alternate!==null&&Pe.delete(ft.key===null?Qe:ft.key),ce=N(ft,ce,Qe),ht===null?ze=ft:ht.sibling=ft,ht=ft);return r&&Pe.forEach(function(g2){return i(he,g2)}),ct&&Ur(he,Qe),ze}function wt(he,ce,fe,Ce){if(typeof fe=="object"&&fe!==null&&fe.type===C&&fe.key===null&&(fe=fe.props.children),typeof fe=="object"&&fe!==null){switch(fe.$$typeof){case y:e:{for(var ze=fe.key;ce!==null;){if(ce.key===ze){if(ze=fe.type,ze===C){if(ce.tag===7){h(he,ce.sibling),Ce=k(ce,fe.props.children),Ce.return=he,he=Ce;break e}}else if(ce.elementType===ze||typeof ze=="object"&&ze!==null&&ze.$$typeof===A&&ai(ze)===ce.type){h(he,ce.sibling),Ce=k(ce,fe.props),yo(Ce,fe),Ce.return=he,he=Ce;break e}h(he,ce);break}else i(he,ce);ce=ce.sibling}fe.type===C?(Ce=ti(fe.props.children,he.mode,Ce,fe.key),Ce.return=he,he=Ce):(Ce=Ql(fe.type,fe.key,fe.props,null,he.mode,Ce),yo(Ce,fe),Ce.return=he,he=Ce)}return M(he);case w:e:{for(ze=fe.key;ce!==null;){if(ce.key===ze)if(ce.tag===4&&ce.stateNode.containerInfo===fe.containerInfo&&ce.stateNode.implementation===fe.implementation){h(he,ce.sibling),Ce=k(ce,fe.children||[]),Ce.return=he,he=Ce;break e}else{h(he,ce);break}else i(he,ce);ce=ce.sibling}Ce=Xd(fe,he.mode,Ce),Ce.return=he,he=Ce}return M(he);case A:return fe=ai(fe),wt(he,ce,fe,Ce)}if(V(fe))return Me(he,ce,fe,Ce);if(G(fe)){if(ze=G(fe),typeof ze!="function")throw Error(s(150));return fe=ze.call(fe),Fe(he,ce,fe,Ce)}if(typeof fe.then=="function")return wt(he,ce,sc(fe),Ce);if(fe.$$typeof===_)return wt(he,ce,ec(he,fe),Ce);ic(he,fe)}return typeof fe=="string"&&fe!==""||typeof fe=="number"||typeof fe=="bigint"?(fe=""+fe,ce!==null&&ce.tag===6?(h(he,ce.sibling),Ce=k(ce,fe),Ce.return=he,he=Ce):(h(he,ce),Ce=Yd(fe,he.mode,Ce),Ce.return=he,he=Ce),M(he)):h(he,ce)}return function(he,ce,fe,Ce){try{xo=0;var ze=wt(he,ce,fe,Ce);return la=null,ze}catch(Pe){if(Pe===oa||Pe===nc)throw Pe;var ht=zn(29,Pe,null,he.mode);return ht.lanes=Ce,ht.return=he,ht}finally{}}}var li=Cx(!0),kx=Cx(!1),ys=!1;function lh(r){r.updateQueue={baseState:r.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function ch(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 _s(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,(gt&2)!==0){var k=g.pending;return k===null?i.next=i:(i.next=k.next,k.next=i),g.pending=i,i=Xl(r),lx(r,null,h),i}return Yl(r,g,i,h),Xl(r)}function _o(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,Ie(r,h)}}function uh(r,i){var h=r.updateQueue,g=r.alternate;if(g!==null&&(g=g.updateQueue,h===g)){var k=null,N=null;if(h=h.firstBaseUpdate,h!==null){do{var M={lane:h.lane,tag:h.tag,payload:h.payload,callback:null,next:null};N===null?k=N=M:N=N.next=M,h=h.next}while(h!==null);N===null?k=N=i:N=N.next=i}else k=N=i;h={baseState:g.baseState,firstBaseUpdate:k,lastBaseUpdate:N,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 dh=!1;function bo(){if(dh){var r=aa;if(r!==null)throw r}}function vo(r,i,h,g){dh=!1;var k=r.updateQueue;ys=!1;var N=k.firstBaseUpdate,M=k.lastBaseUpdate,K=k.shared.pending;if(K!==null){k.shared.pending=null;var ie=K,me=ie.next;ie.next=null,M===null?N=me:M.next=me,M=ie;var Se=r.alternate;Se!==null&&(Se=Se.updateQueue,K=Se.lastBaseUpdate,K!==M&&(K===null?Se.firstBaseUpdate=me:K.next=me,Se.lastBaseUpdate=ie))}if(N!==null){var je=k.baseState;M=0,Se=me=ie=null,K=N;do{var pe=K.lane&-536870913,ge=pe!==K.lane;if(ge?(ot&pe)===pe:(g&pe)===pe){pe!==0&&pe===ia&&(dh=!0),Se!==null&&(Se=Se.next={lane:0,tag:K.tag,payload:K.payload,callback:null,next:null});e:{var Me=r,Fe=K;pe=i;var wt=h;switch(Fe.tag){case 1:if(Me=Fe.payload,typeof Me=="function"){je=Me.call(wt,je,pe);break e}je=Me;break e;case 3:Me.flags=Me.flags&-65537|128;case 0:if(Me=Fe.payload,pe=typeof Me=="function"?Me.call(wt,je,pe):Me,pe==null)break e;je=m({},je,pe);break e;case 2:ys=!0}}pe=K.callback,pe!==null&&(r.flags|=64,ge&&(r.flags|=8192),ge=k.callbacks,ge===null?k.callbacks=[pe]:ge.push(pe))}else ge={lane:pe,tag:K.tag,payload:K.payload,callback:K.callback,next:null},Se===null?(me=Se=ge,ie=je):Se=Se.next=ge,M|=pe;if(K=K.next,K===null){if(K=k.shared.pending,K===null)break;ge=K,K=ge.next,ge.next=null,k.lastBaseUpdate=ge,k.shared.pending=null}}while(!0);Se===null&&(ie=je),k.baseState=ie,k.firstBaseUpdate=me,k.lastBaseUpdate=Se,N===null&&(k.shared.lanes=0),ks|=M,r.lanes=M,r.memoizedState=je}}function Ex(r,i){if(typeof r!="function")throw Error(s(191,r));r.call(i)}function jx(r,i){var h=r.callbacks;if(h!==null)for(r.callbacks=null,r=0;r<h.length;r++)Ex(h[r],i)}var ca=B(null),ac=B(0);function Nx(r,i){r=Zr,P(ac,r),P(ca,i),Zr=r|i.baseLanes}function hh(){P(ac,Zr),P(ca,ca.current)}function fh(){Zr=ac.current,W(ca),W(ac)}var $n=B(null),sr=null;function vs(r){var i=r.alternate;P(Ft,Ft.current&1),P($n,r),sr===null&&(i===null||ca.current!==null||i.memoizedState!==null)&&(sr=r)}function mh(r){P(Ft,Ft.current),P($n,r),sr===null&&(sr=r)}function Tx(r){r.tag===22?(P(Ft,Ft.current),P($n,r),sr===null&&(sr=r)):Ss()}function Ss(){P(Ft,Ft.current),P($n,$n.current)}function Hn(r){W($n),sr===r&&(sr=null),W(Ft)}var Ft=B(0);function oc(r){for(var i=r;i!==null;){if(i.tag===13){var h=i.memoizedState;if(h!==null&&(h=h.dehydrated,h===null||vf(h)||Sf(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 Gr=0,Ye=null,vt=null,Yt=null,lc=!1,ua=!1,ci=!1,cc=0,So=0,da=null,aE=0;function zt(){throw Error(s(321))}function ph(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 gh(r,i,h,g,k,N){return Gr=N,Ye=i,i.memoizedState=null,i.updateQueue=null,i.lanes=0,z.H=r===null||r.memoizedState===null?hy:Lh,ci=!1,N=h(g,k),ci=!1,ua&&(N=Lx(i,h,g,k)),Ax(r),N}function Ax(r){z.H=ko;var i=vt!==null&&vt.next!==null;if(Gr=0,Yt=vt=Ye=null,lc=!1,So=0,da=null,i)throw Error(s(300));r===null||Xt||(r=r.dependencies,r!==null&&Zl(r)&&(Xt=!0))}function Lx(r,i,h,g){Ye=r;var k=0;do{if(ua&&(da=null),So=0,ua=!1,25<=k)throw Error(s(301));if(k+=1,Yt=vt=null,r.updateQueue!=null){var N=r.updateQueue;N.lastEffect=null,N.events=null,N.stores=null,N.memoCache!=null&&(N.memoCache.index=0)}z.H=fy,N=i(h,g)}while(ua);return N}function oE(){var r=z.H,i=r.useState()[0];return i=typeof i.then=="function"?wo(i):i,r=r.useState()[0],(vt!==null?vt.memoizedState:null)!==r&&(Ye.flags|=1024),i}function xh(){var r=cc!==0;return cc=0,r}function yh(r,i,h){i.updateQueue=r.updateQueue,i.flags&=-2053,r.lanes&=~h}function _h(r){if(lc){for(r=r.memoizedState;r!==null;){var i=r.queue;i!==null&&(i.pending=null),r=r.next}lc=!1}Gr=0,Yt=vt=Ye=null,ua=!1,So=cc=0,da=null}function wn(){var r={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Yt===null?Ye.memoizedState=Yt=r:Yt=Yt.next=r,Yt}function Vt(){if(vt===null){var r=Ye.alternate;r=r!==null?r.memoizedState:null}else r=vt.next;var i=Yt===null?Ye.memoizedState:Yt.next;if(i!==null)Yt=i,vt=r;else{if(r===null)throw Ye.alternate===null?Error(s(467)):Error(s(310));vt=r,r={memoizedState:vt.memoizedState,baseState:vt.baseState,baseQueue:vt.baseQueue,queue:vt.queue,next:null},Yt===null?Ye.memoizedState=Yt=r:Yt=Yt.next=r}return Yt}function uc(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function wo(r){var i=So;return So+=1,da===null&&(da=[]),r=vx(da,r,i),i=Ye,(Yt===null?i.memoizedState:Yt.next)===null&&(i=i.alternate,z.H=i===null||i.memoizedState===null?hy:Lh),r}function dc(r){if(r!==null&&typeof r=="object"){if(typeof r.then=="function")return wo(r);if(r.$$typeof===_)return fn(r)}throw Error(s(438,String(r)))}function bh(r){var i=null,h=Ye.updateQueue;if(h!==null&&(i=h.memoCache),i==null){var g=Ye.alternate;g!==null&&(g=g.updateQueue,g!==null&&(g=g.memoCache,g!=null&&(i={data:g.data.map(function(k){return k.slice()}),index:0})))}if(i==null&&(i={data:[],index:0}),h===null&&(h=uc(),Ye.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]=$;return i.index++,h}function Wr(r,i){return typeof i=="function"?i(r):i}function hc(r){var i=Vt();return vh(i,vt,r)}function vh(r,i,h){var g=r.queue;if(g===null)throw Error(s(311));g.lastRenderedReducer=h;var k=r.baseQueue,N=g.pending;if(N!==null){if(k!==null){var M=k.next;k.next=N.next,N.next=M}i.baseQueue=k=N,g.pending=null}if(N=r.baseState,k===null)r.memoizedState=N;else{i=k.next;var K=M=null,ie=null,me=i,Se=!1;do{var je=me.lane&-536870913;if(je!==me.lane?(ot&je)===je:(Gr&je)===je){var pe=me.revertLane;if(pe===0)ie!==null&&(ie=ie.next={lane:0,revertLane:0,gesture:null,action:me.action,hasEagerState:me.hasEagerState,eagerState:me.eagerState,next:null}),je===ia&&(Se=!0);else if((Gr&pe)===pe){me=me.next,pe===ia&&(Se=!0);continue}else je={lane:0,revertLane:me.revertLane,gesture:null,action:me.action,hasEagerState:me.hasEagerState,eagerState:me.eagerState,next:null},ie===null?(K=ie=je,M=N):ie=ie.next=je,Ye.lanes|=pe,ks|=pe;je=me.action,ci&&h(N,je),N=me.hasEagerState?me.eagerState:h(N,je)}else pe={lane:je,revertLane:me.revertLane,gesture:me.gesture,action:me.action,hasEagerState:me.hasEagerState,eagerState:me.eagerState,next:null},ie===null?(K=ie=pe,M=N):ie=ie.next=pe,Ye.lanes|=je,ks|=je;me=me.next}while(me!==null&&me!==i);if(ie===null?M=N:ie.next=K,!Bn(N,r.memoizedState)&&(Xt=!0,Se&&(h=aa,h!==null)))throw h;r.memoizedState=N,r.baseState=M,r.baseQueue=ie,g.lastRenderedState=N}return k===null&&(g.lanes=0),[r.memoizedState,g.dispatch]}function Sh(r){var i=Vt(),h=i.queue;if(h===null)throw Error(s(311));h.lastRenderedReducer=r;var g=h.dispatch,k=h.pending,N=i.memoizedState;if(k!==null){h.pending=null;var M=k=k.next;do N=r(N,M.action),M=M.next;while(M!==k);Bn(N,i.memoizedState)||(Xt=!0),i.memoizedState=N,i.baseQueue===null&&(i.baseState=N),h.lastRenderedState=N}return[N,g]}function Rx(r,i,h){var g=Ye,k=Vt(),N=ct;if(N){if(h===void 0)throw Error(s(407));h=h()}else h=i();var M=!Bn((vt||k).memoizedState,h);if(M&&(k.memoizedState=h,Xt=!0),k=k.queue,kh(Ix.bind(null,g,k,r),[r]),k.getSnapshot!==i||M||Yt!==null&&Yt.memoizedState.tag&1){if(g.flags|=2048,ha(9,{destroy:void 0},Ox.bind(null,g,k,h,i),null),Et===null)throw Error(s(349));N||(Gr&127)!==0||Dx(g,i,h)}return h}function Dx(r,i,h){r.flags|=16384,r={getSnapshot:i,value:h},i=Ye.updateQueue,i===null?(i=uc(),Ye.updateQueue=i,i.stores=[r]):(h=i.stores,h===null?i.stores=[r]:h.push(r))}function Ox(r,i,h,g){i.value=h,i.getSnapshot=g,Mx(i)&&Px(r)}function Ix(r,i,h){return h(function(){Mx(i)&&Px(r)})}function Mx(r){var i=r.getSnapshot;r=r.value;try{var h=i();return!Bn(r,h)}catch{return!0}}function Px(r){var i=ei(r,2);i!==null&&Rn(i,r,2)}function wh(r){var i=wn();if(typeof r=="function"){var h=r;if(r=h(),ci){xn(!0);try{h()}finally{xn(!1)}}}return i.memoizedState=i.baseState=r,i.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Wr,lastRenderedState:r},i}function Bx(r,i,h,g){return r.baseState=h,vh(r,vt,typeof g=="function"?g:Wr)}function lE(r,i,h,g,k){if(pc(r))throw Error(s(485));if(r=i.action,r!==null){var N={payload:k,action:r,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(M){N.listeners.push(M)}};z.T!==null?h(!0):N.isTransition=!1,g(N),h=i.pending,h===null?(N.next=i.pending=N,zx(i,N)):(N.next=h.next,i.pending=h.next=N)}}function zx(r,i){var h=i.action,g=i.payload,k=r.state;if(i.isTransition){var N=z.T,M={};z.T=M;try{var K=h(k,g),ie=z.S;ie!==null&&ie(M,K),$x(r,i,K)}catch(me){Ch(r,i,me)}finally{N!==null&&M.types!==null&&(N.types=M.types),z.T=N}}else try{N=h(k,g),$x(r,i,N)}catch(me){Ch(r,i,me)}}function $x(r,i,h){h!==null&&typeof h=="object"&&typeof h.then=="function"?h.then(function(g){Hx(r,i,g)},function(g){return Ch(r,i,g)}):Hx(r,i,h)}function Hx(r,i,h){i.status="fulfilled",i.value=h,Ux(i),r.state=h,i=r.pending,i!==null&&(h=i.next,h===i?r.pending=null:(h=h.next,i.next=h,zx(r,h)))}function Ch(r,i,h){var g=r.pending;if(r.pending=null,g!==null){g=g.next;do i.status="rejected",i.reason=h,Ux(i),i=i.next;while(i!==g)}r.action=null}function Ux(r){r=r.listeners;for(var i=0;i<r.length;i++)(0,r[i])()}function Fx(r,i){return i}function Vx(r,i){if(ct){var h=Et.formState;if(h!==null){e:{var g=Ye;if(ct){if(It){t:{for(var k=It,N=rr;k.nodeType!==8;){if(!N){k=null;break t}if(k=ir(k.nextSibling),k===null){k=null;break t}}N=k.data,k=N==="F!"||N==="F"?k:null}if(k){It=ir(k.nextSibling),g=k.data==="F!";break e}}gs(g)}g=!1}g&&(i=h[0])}}return h=wn(),h.memoizedState=h.baseState=i,g={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Fx,lastRenderedState:i},h.queue=g,h=cy.bind(null,Ye,g),g.dispatch=h,g=wh(!1),N=Ah.bind(null,Ye,!1,g.queue),g=wn(),k={state:i,dispatch:null,action:r,pending:null},g.queue=k,h=lE.bind(null,Ye,k,N,h),k.dispatch=h,g.memoizedState=r,[i,h,!1]}function Gx(r){var i=Vt();return Wx(i,vt,r)}function Wx(r,i,h){if(i=vh(r,i,Fx)[0],r=hc(Wr)[0],typeof i=="object"&&i!==null&&typeof i.then=="function")try{var g=wo(i)}catch(M){throw M===oa?nc:M}else g=i;i=Vt();var k=i.queue,N=k.dispatch;return h!==i.memoizedState&&(Ye.flags|=2048,ha(9,{destroy:void 0},cE.bind(null,k,h),null)),[g,N,r]}function cE(r,i){r.action=i}function qx(r){var i=Vt(),h=vt;if(h!==null)return Wx(i,h,r);Vt(),i=i.memoizedState,h=Vt();var g=h.queue.dispatch;return h.memoizedState=r,[i,g,!1]}function ha(r,i,h,g){return r={tag:r,create:h,deps:g,inst:i,next:null},i=Ye.updateQueue,i===null&&(i=uc(),Ye.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 Kx(){return Vt().memoizedState}function fc(r,i,h,g){var k=wn();Ye.flags|=r,k.memoizedState=ha(1|i,{destroy:void 0},h,g===void 0?null:g)}function mc(r,i,h,g){var k=Vt();g=g===void 0?null:g;var N=k.memoizedState.inst;vt!==null&&g!==null&&ph(g,vt.memoizedState.deps)?k.memoizedState=ha(i,N,h,g):(Ye.flags|=r,k.memoizedState=ha(1|i,N,h,g))}function Yx(r,i){fc(8390656,8,r,i)}function kh(r,i){mc(2048,8,r,i)}function uE(r){Ye.flags|=4;var i=Ye.updateQueue;if(i===null)i=uc(),Ye.updateQueue=i,i.events=[r];else{var h=i.events;h===null?i.events=[r]:h.push(r)}}function Xx(r){var i=Vt().memoizedState;return uE({ref:i,nextImpl:r}),function(){if((gt&2)!==0)throw Error(s(440));return i.impl.apply(void 0,arguments)}}function Qx(r,i){return mc(4,2,r,i)}function Jx(r,i){return mc(4,4,r,i)}function Zx(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 ey(r,i,h){h=h!=null?h.concat([r]):null,mc(4,4,Zx.bind(null,i,r),h)}function Eh(){}function ty(r,i){var h=Vt();i=i===void 0?null:i;var g=h.memoizedState;return i!==null&&ph(i,g[1])?g[0]:(h.memoizedState=[r,i],r)}function ny(r,i){var h=Vt();i=i===void 0?null:i;var g=h.memoizedState;if(i!==null&&ph(i,g[1]))return g[0];if(g=r(),ci){xn(!0);try{r()}finally{xn(!1)}}return h.memoizedState=[g,i],g}function jh(r,i,h){return h===void 0||(Gr&1073741824)!==0&&(ot&261930)===0?r.memoizedState=i:(r.memoizedState=h,r=r_(),Ye.lanes|=r,ks|=r,h)}function ry(r,i,h,g){return Bn(h,i)?h:ca.current!==null?(r=jh(r,h,g),Bn(r,i)||(Xt=!0),r):(Gr&42)===0||(Gr&1073741824)!==0&&(ot&261930)===0?(Xt=!0,r.memoizedState=h):(r=r_(),Ye.lanes|=r,ks|=r,i)}function sy(r,i,h,g,k){var N=J.p;J.p=N!==0&&8>N?N:8;var M=z.T,K={};z.T=K,Ah(r,!1,i,h);try{var ie=k(),me=z.S;if(me!==null&&me(K,ie),ie!==null&&typeof ie=="object"&&typeof ie.then=="function"){var Se=iE(ie,g);Co(r,i,Se,Vn(r))}else Co(r,i,g,Vn(r))}catch(je){Co(r,i,{then:function(){},status:"rejected",reason:je},Vn())}finally{J.p=N,M!==null&&K.types!==null&&(M.types=K.types),z.T=M}}function dE(){}function Nh(r,i,h,g){if(r.tag!==5)throw Error(s(476));var k=iy(r).queue;sy(r,k,i,Z,h===null?dE:function(){return ay(r),h(g)})}function iy(r){var i=r.memoizedState;if(i!==null)return i;i={memoizedState:Z,baseState:Z,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Wr,lastRenderedState:Z},next:null};var h={};return i.next={memoizedState:h,baseState:h,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Wr,lastRenderedState:h},next:null},r.memoizedState=i,r=r.alternate,r!==null&&(r.memoizedState=i),i}function ay(r){var i=iy(r);i.next===null&&(i=r.alternate.memoizedState),Co(r,i.next.queue,{},Vn())}function Th(){return fn(Ho)}function oy(){return Vt().memoizedState}function ly(){return Vt().memoizedState}function hE(r){for(var i=r.return;i!==null;){switch(i.tag){case 24:case 3:var h=Vn();r=_s(h);var g=bs(i,r,h);g!==null&&(Rn(g,i,h),_o(g,i,h)),i={cache:sh()},r.payload=i;return}i=i.return}}function fE(r,i,h){var g=Vn();h={lane:g,revertLane:0,gesture:null,action:h,hasEagerState:!1,eagerState:null,next:null},pc(r)?uy(i,h):(h=qd(r,i,h,g),h!==null&&(Rn(h,r,g),dy(h,i,g)))}function cy(r,i,h){var g=Vn();Co(r,i,h,g)}function Co(r,i,h,g){var k={lane:g,revertLane:0,gesture:null,action:h,hasEagerState:!1,eagerState:null,next:null};if(pc(r))uy(i,k);else{var N=r.alternate;if(r.lanes===0&&(N===null||N.lanes===0)&&(N=i.lastRenderedReducer,N!==null))try{var M=i.lastRenderedState,K=N(M,h);if(k.hasEagerState=!0,k.eagerState=K,Bn(K,M))return Yl(r,i,k,0),Et===null&&Kl(),!1}catch{}finally{}if(h=qd(r,i,k,g),h!==null)return Rn(h,r,g),dy(h,i,g),!0}return!1}function Ah(r,i,h,g){if(g={lane:2,revertLane:cf(),gesture:null,action:g,hasEagerState:!1,eagerState:null,next:null},pc(r)){if(i)throw Error(s(479))}else i=qd(r,h,g,2),i!==null&&Rn(i,r,2)}function pc(r){var i=r.alternate;return r===Ye||i!==null&&i===Ye}function uy(r,i){ua=lc=!0;var h=r.pending;h===null?i.next=i:(i.next=h.next,h.next=i),r.pending=i}function dy(r,i,h){if((h&4194048)!==0){var g=i.lanes;g&=r.pendingLanes,h|=g,i.lanes=h,Ie(r,h)}}var ko={readContext:fn,use:dc,useCallback:zt,useContext:zt,useEffect:zt,useImperativeHandle:zt,useLayoutEffect:zt,useInsertionEffect:zt,useMemo:zt,useReducer:zt,useRef:zt,useState:zt,useDebugValue:zt,useDeferredValue:zt,useTransition:zt,useSyncExternalStore:zt,useId:zt,useHostTransitionStatus:zt,useFormState:zt,useActionState:zt,useOptimistic:zt,useMemoCache:zt,useCacheRefresh:zt};ko.useEffectEvent=zt;var hy={readContext:fn,use:dc,useCallback:function(r,i){return wn().memoizedState=[r,i===void 0?null:i],r},useContext:fn,useEffect:Yx,useImperativeHandle:function(r,i,h){h=h!=null?h.concat([r]):null,fc(4194308,4,Zx.bind(null,i,r),h)},useLayoutEffect:function(r,i){return fc(4194308,4,r,i)},useInsertionEffect:function(r,i){fc(4,2,r,i)},useMemo:function(r,i){var h=wn();i=i===void 0?null:i;var g=r();if(ci){xn(!0);try{r()}finally{xn(!1)}}return h.memoizedState=[g,i],g},useReducer:function(r,i,h){var g=wn();if(h!==void 0){var k=h(i);if(ci){xn(!0);try{h(i)}finally{xn(!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=fE.bind(null,Ye,r),[g.memoizedState,r]},useRef:function(r){var i=wn();return r={current:r},i.memoizedState=r},useState:function(r){r=wh(r);var i=r.queue,h=cy.bind(null,Ye,i);return i.dispatch=h,[r.memoizedState,h]},useDebugValue:Eh,useDeferredValue:function(r,i){var h=wn();return jh(h,r,i)},useTransition:function(){var r=wh(!1);return r=sy.bind(null,Ye,r.queue,!0,!1),wn().memoizedState=r,[!1,r]},useSyncExternalStore:function(r,i,h){var g=Ye,k=wn();if(ct){if(h===void 0)throw Error(s(407));h=h()}else{if(h=i(),Et===null)throw Error(s(349));(ot&127)!==0||Dx(g,i,h)}k.memoizedState=h;var N={value:h,getSnapshot:i};return k.queue=N,Yx(Ix.bind(null,g,N,r),[r]),g.flags|=2048,ha(9,{destroy:void 0},Ox.bind(null,g,N,h,i),null),h},useId:function(){var r=wn(),i=Et.identifierPrefix;if(ct){var h=Er,g=kr;h=(g&~(1<<32-xt(g)-1)).toString(32)+h,i="_"+i+"R_"+h,h=cc++,0<h&&(i+="H"+h.toString(32)),i+="_"}else h=aE++,i="_"+i+"r_"+h.toString(32)+"_";return r.memoizedState=i},useHostTransitionStatus:Th,useFormState:Vx,useActionState:Vx,useOptimistic:function(r){var i=wn();i.memoizedState=i.baseState=r;var h={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return i.queue=h,i=Ah.bind(null,Ye,!0,h),h.dispatch=i,[r,i]},useMemoCache:bh,useCacheRefresh:function(){return wn().memoizedState=hE.bind(null,Ye)},useEffectEvent:function(r){var i=wn(),h={impl:r};return i.memoizedState=h,function(){if((gt&2)!==0)throw Error(s(440));return h.impl.apply(void 0,arguments)}}},Lh={readContext:fn,use:dc,useCallback:ty,useContext:fn,useEffect:kh,useImperativeHandle:ey,useInsertionEffect:Qx,useLayoutEffect:Jx,useMemo:ny,useReducer:hc,useRef:Kx,useState:function(){return hc(Wr)},useDebugValue:Eh,useDeferredValue:function(r,i){var h=Vt();return ry(h,vt.memoizedState,r,i)},useTransition:function(){var r=hc(Wr)[0],i=Vt().memoizedState;return[typeof r=="boolean"?r:wo(r),i]},useSyncExternalStore:Rx,useId:oy,useHostTransitionStatus:Th,useFormState:Gx,useActionState:Gx,useOptimistic:function(r,i){var h=Vt();return Bx(h,vt,r,i)},useMemoCache:bh,useCacheRefresh:ly};Lh.useEffectEvent=Xx;var fy={readContext:fn,use:dc,useCallback:ty,useContext:fn,useEffect:kh,useImperativeHandle:ey,useInsertionEffect:Qx,useLayoutEffect:Jx,useMemo:ny,useReducer:Sh,useRef:Kx,useState:function(){return Sh(Wr)},useDebugValue:Eh,useDeferredValue:function(r,i){var h=Vt();return vt===null?jh(h,r,i):ry(h,vt.memoizedState,r,i)},useTransition:function(){var r=Sh(Wr)[0],i=Vt().memoizedState;return[typeof r=="boolean"?r:wo(r),i]},useSyncExternalStore:Rx,useId:oy,useHostTransitionStatus:Th,useFormState:qx,useActionState:qx,useOptimistic:function(r,i){var h=Vt();return vt!==null?Bx(h,vt,r,i):(h.baseState=r,[r,h.queue.dispatch])},useMemoCache:bh,useCacheRefresh:ly};fy.useEffectEvent=Xx;function Rh(r,i,h,g){i=r.memoizedState,h=h(g,i),h=h==null?i:m({},i,h),r.memoizedState=h,r.lanes===0&&(r.updateQueue.baseState=h)}var Dh={enqueueSetState:function(r,i,h){r=r._reactInternals;var g=Vn(),k=_s(g);k.payload=i,h!=null&&(k.callback=h),i=bs(r,k,g),i!==null&&(Rn(i,r,g),_o(i,r,g))},enqueueReplaceState:function(r,i,h){r=r._reactInternals;var g=Vn(),k=_s(g);k.tag=1,k.payload=i,h!=null&&(k.callback=h),i=bs(r,k,g),i!==null&&(Rn(i,r,g),_o(i,r,g))},enqueueForceUpdate:function(r,i){r=r._reactInternals;var h=Vn(),g=_s(h);g.tag=2,i!=null&&(g.callback=i),i=bs(r,g,h),i!==null&&(Rn(i,r,h),_o(i,r,h))}};function my(r,i,h,g,k,N,M){return r=r.stateNode,typeof r.shouldComponentUpdate=="function"?r.shouldComponentUpdate(g,N,M):i.prototype&&i.prototype.isPureReactComponent?!uo(h,g)||!uo(k,N):!0}function py(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&&Dh.enqueueReplaceState(i,i.state,null)}function ui(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=m({},h));for(var k in r)h[k]===void 0&&(h[k]=r[k])}return h}function gy(r){ql(r)}function xy(r){console.error(r)}function yy(r){ql(r)}function gc(r,i){try{var h=r.onUncaughtError;h(i.value,{componentStack:i.stack})}catch(g){setTimeout(function(){throw g})}}function _y(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 Oh(r,i,h){return h=_s(h),h.tag=3,h.payload={element:null},h.callback=function(){gc(r,i)},h}function by(r){return r=_s(r),r.tag=3,r}function vy(r,i,h,g){var k=h.type.getDerivedStateFromError;if(typeof k=="function"){var N=g.value;r.payload=function(){return k(N)},r.callback=function(){_y(i,h,g)}}var M=h.stateNode;M!==null&&typeof M.componentDidCatch=="function"&&(r.callback=function(){_y(i,h,g),typeof k!="function"&&(Es===null?Es=new Set([this]):Es.add(this));var K=g.stack;this.componentDidCatch(g.value,{componentStack:K!==null?K:""})})}function mE(r,i,h,g,k){if(h.flags|=32768,g!==null&&typeof g=="object"&&typeof g.then=="function"){if(i=h.alternate,i!==null&&sa(i,h,k,!0),h=$n.current,h!==null){switch(h.tag){case 31:case 13:return sr===null?Nc():h.alternate===null&&$t===0&&($t=3),h.flags&=-257,h.flags|=65536,h.lanes=k,g===rc?h.flags|=16384:(i=h.updateQueue,i===null?h.updateQueue=new Set([g]):i.add(g),af(r,g,k)),!1;case 22:return h.flags|=65536,g===rc?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)),af(r,g,k)),!1}throw Error(s(435,h.tag))}return af(r,g,k),Nc(),!1}if(ct)return i=$n.current,i!==null?((i.flags&65536)===0&&(i.flags|=256),i.flags|=65536,i.lanes=k,g!==Zd&&(r=Error(s(422),{cause:g}),mo(er(r,h)))):(g!==Zd&&(i=Error(s(423),{cause:g}),mo(er(i,h))),r=r.current.alternate,r.flags|=65536,k&=-k,r.lanes|=k,g=er(g,h),k=Oh(r.stateNode,g,k),uh(r,k),$t!==4&&($t=2)),!1;var N=Error(s(520),{cause:g});if(N=er(N,h),Do===null?Do=[N]:Do.push(N),$t!==4&&($t=2),i===null)return!0;g=er(g,h),h=i;do{switch(h.tag){case 3:return h.flags|=65536,r=k&-k,h.lanes|=r,r=Oh(h.stateNode,g,r),uh(h,r),!1;case 1:if(i=h.type,N=h.stateNode,(h.flags&128)===0&&(typeof i.getDerivedStateFromError=="function"||N!==null&&typeof N.componentDidCatch=="function"&&(Es===null||!Es.has(N))))return h.flags|=65536,k&=-k,h.lanes|=k,k=by(k),vy(k,r,h,g),uh(h,k),!1}h=h.return}while(h!==null);return!1}var Ih=Error(s(461)),Xt=!1;function mn(r,i,h,g){i.child=r===null?kx(i,null,h,g):li(i,r.child,h,g)}function Sy(r,i,h,g,k){h=h.render;var N=i.ref;if("ref"in g){var M={};for(var K in g)K!=="ref"&&(M[K]=g[K])}else M=g;return si(i),g=gh(r,i,h,M,N,k),K=xh(),r!==null&&!Xt?(yh(r,i,k),qr(r,i,k)):(ct&&K&&Qd(i),i.flags|=1,mn(r,i,g,k),i.child)}function wy(r,i,h,g,k){if(r===null){var N=h.type;return typeof N=="function"&&!Kd(N)&&N.defaultProps===void 0&&h.compare===null?(i.tag=15,i.type=N,Cy(r,i,N,g,k)):(r=Ql(h.type,null,g,i,i.mode,k),r.ref=i.ref,r.return=i,i.child=r)}if(N=r.child,!Fh(r,k)){var M=N.memoizedProps;if(h=h.compare,h=h!==null?h:uo,h(M,g)&&r.ref===i.ref)return qr(r,i,k)}return i.flags|=1,r=Hr(N,g),r.ref=i.ref,r.return=i,i.child=r}function Cy(r,i,h,g,k){if(r!==null){var N=r.memoizedProps;if(uo(N,g)&&r.ref===i.ref)if(Xt=!1,i.pendingProps=g=N,Fh(r,k))(r.flags&131072)!==0&&(Xt=!0);else return i.lanes=r.lanes,qr(r,i,k)}return Mh(r,i,h,g,k)}function ky(r,i,h,g){var k=g.children,N=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(N=N!==null?N.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&~N}else g=0,i.child=null;return Ey(r,i,N,h,g)}if((h&536870912)!==0)i.memoizedState={baseLanes:0,cachePool:null},r!==null&&tc(i,N!==null?N.cachePool:null),N!==null?Nx(i,N):hh(),Tx(i);else return g=i.lanes=536870912,Ey(r,i,N!==null?N.baseLanes|h:h,h,g)}else N!==null?(tc(i,N.cachePool),Nx(i,N),Ss(),i.memoizedState=null):(r!==null&&tc(i,null),hh(),Ss());return mn(r,i,k,h),i.child}function Eo(r,i){return r!==null&&r.tag===22||i.stateNode!==null||(i.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),i.sibling}function Ey(r,i,h,g,k){var N=ah();return N=N===null?null:{parent:Kt._currentValue,pool:N},i.memoizedState={baseLanes:h,cachePool:N},r!==null&&tc(i,null),hh(),Tx(i),r!==null&&sa(r,i,g,!0),i.childLanes=k,null}function xc(r,i){return i=_c({mode:i.mode,children:i.children},r.mode),i.ref=r.ref,r.child=i,i.return=r,i}function jy(r,i,h){return li(i,r.child,null,h),r=xc(i,i.pendingProps),r.flags|=2,Hn(i),i.memoizedState=null,r}function pE(r,i,h){var g=i.pendingProps,k=(i.flags&128)!==0;if(i.flags&=-129,r===null){if(ct){if(g.mode==="hidden")return r=xc(i,g),i.lanes=536870912,Eo(null,r);if(mh(i),(r=It)?(r=z_(r,rr),r=r!==null&&r.data==="&"?r:null,r!==null&&(i.memoizedState={dehydrated:r,treeContext:ms!==null?{id:kr,overflow:Er}:null,retryLane:536870912,hydrationErrors:null},h=ux(r),h.return=i,i.child=h,hn=i,It=null)):r=null,r===null)throw gs(i);return i.lanes=536870912,null}return xc(i,g)}var N=r.memoizedState;if(N!==null){var M=N.dehydrated;if(mh(i),k)if(i.flags&256)i.flags&=-257,i=jy(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||sa(r,i,h,!1),k=(h&r.childLanes)!==0,Xt||k){if(g=Et,g!==null&&(M=$e(g,h),M!==0&&M!==N.retryLane))throw N.retryLane=M,ei(r,M),Rn(g,r,M),Ih;Nc(),i=jy(r,i,h)}else r=N.treeContext,It=ir(M.nextSibling),hn=i,ct=!0,ps=null,rr=!1,r!==null&&fx(i,r),i=xc(i,g),i.flags|=4096;return i}return r=Hr(r.child,{mode:g.mode,children:g.children}),r.ref=i.ref,i.child=r,r.return=i,r}function yc(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 Mh(r,i,h,g,k){return si(i),h=gh(r,i,h,g,void 0,k),g=xh(),r!==null&&!Xt?(yh(r,i,k),qr(r,i,k)):(ct&&g&&Qd(i),i.flags|=1,mn(r,i,h,k),i.child)}function Ny(r,i,h,g,k,N){return si(i),i.updateQueue=null,h=Lx(i,g,h,k),Ax(r),g=xh(),r!==null&&!Xt?(yh(r,i,N),qr(r,i,N)):(ct&&g&&Qd(i),i.flags|=1,mn(r,i,h,N),i.child)}function Ty(r,i,h,g,k){if(si(i),i.stateNode===null){var N=ea,M=h.contextType;typeof M=="object"&&M!==null&&(N=fn(M)),N=new h(g,N),i.memoizedState=N.state!==null&&N.state!==void 0?N.state:null,N.updater=Dh,i.stateNode=N,N._reactInternals=i,N=i.stateNode,N.props=g,N.state=i.memoizedState,N.refs={},lh(i),M=h.contextType,N.context=typeof M=="object"&&M!==null?fn(M):ea,N.state=i.memoizedState,M=h.getDerivedStateFromProps,typeof M=="function"&&(Rh(i,h,M,g),N.state=i.memoizedState),typeof h.getDerivedStateFromProps=="function"||typeof N.getSnapshotBeforeUpdate=="function"||typeof N.UNSAFE_componentWillMount!="function"&&typeof N.componentWillMount!="function"||(M=N.state,typeof N.componentWillMount=="function"&&N.componentWillMount(),typeof N.UNSAFE_componentWillMount=="function"&&N.UNSAFE_componentWillMount(),M!==N.state&&Dh.enqueueReplaceState(N,N.state,null),vo(i,g,N,k),bo(),N.state=i.memoizedState),typeof N.componentDidMount=="function"&&(i.flags|=4194308),g=!0}else if(r===null){N=i.stateNode;var K=i.memoizedProps,ie=ui(h,K);N.props=ie;var me=N.context,Se=h.contextType;M=ea,typeof Se=="object"&&Se!==null&&(M=fn(Se));var je=h.getDerivedStateFromProps;Se=typeof je=="function"||typeof N.getSnapshotBeforeUpdate=="function",K=i.pendingProps!==K,Se||typeof N.UNSAFE_componentWillReceiveProps!="function"&&typeof N.componentWillReceiveProps!="function"||(K||me!==M)&&py(i,N,g,M),ys=!1;var pe=i.memoizedState;N.state=pe,vo(i,g,N,k),bo(),me=i.memoizedState,K||pe!==me||ys?(typeof je=="function"&&(Rh(i,h,je,g),me=i.memoizedState),(ie=ys||my(i,h,ie,g,pe,me,M))?(Se||typeof N.UNSAFE_componentWillMount!="function"&&typeof N.componentWillMount!="function"||(typeof N.componentWillMount=="function"&&N.componentWillMount(),typeof N.UNSAFE_componentWillMount=="function"&&N.UNSAFE_componentWillMount()),typeof N.componentDidMount=="function"&&(i.flags|=4194308)):(typeof N.componentDidMount=="function"&&(i.flags|=4194308),i.memoizedProps=g,i.memoizedState=me),N.props=g,N.state=me,N.context=M,g=ie):(typeof N.componentDidMount=="function"&&(i.flags|=4194308),g=!1)}else{N=i.stateNode,ch(r,i),M=i.memoizedProps,Se=ui(h,M),N.props=Se,je=i.pendingProps,pe=N.context,me=h.contextType,ie=ea,typeof me=="object"&&me!==null&&(ie=fn(me)),K=h.getDerivedStateFromProps,(me=typeof K=="function"||typeof N.getSnapshotBeforeUpdate=="function")||typeof N.UNSAFE_componentWillReceiveProps!="function"&&typeof N.componentWillReceiveProps!="function"||(M!==je||pe!==ie)&&py(i,N,g,ie),ys=!1,pe=i.memoizedState,N.state=pe,vo(i,g,N,k),bo();var ge=i.memoizedState;M!==je||pe!==ge||ys||r!==null&&r.dependencies!==null&&Zl(r.dependencies)?(typeof K=="function"&&(Rh(i,h,K,g),ge=i.memoizedState),(Se=ys||my(i,h,Se,g,pe,ge,ie)||r!==null&&r.dependencies!==null&&Zl(r.dependencies))?(me||typeof N.UNSAFE_componentWillUpdate!="function"&&typeof N.componentWillUpdate!="function"||(typeof N.componentWillUpdate=="function"&&N.componentWillUpdate(g,ge,ie),typeof N.UNSAFE_componentWillUpdate=="function"&&N.UNSAFE_componentWillUpdate(g,ge,ie)),typeof N.componentDidUpdate=="function"&&(i.flags|=4),typeof N.getSnapshotBeforeUpdate=="function"&&(i.flags|=1024)):(typeof N.componentDidUpdate!="function"||M===r.memoizedProps&&pe===r.memoizedState||(i.flags|=4),typeof N.getSnapshotBeforeUpdate!="function"||M===r.memoizedProps&&pe===r.memoizedState||(i.flags|=1024),i.memoizedProps=g,i.memoizedState=ge),N.props=g,N.state=ge,N.context=ie,g=Se):(typeof N.componentDidUpdate!="function"||M===r.memoizedProps&&pe===r.memoizedState||(i.flags|=4),typeof N.getSnapshotBeforeUpdate!="function"||M===r.memoizedProps&&pe===r.memoizedState||(i.flags|=1024),g=!1)}return N=g,yc(r,i),g=(i.flags&128)!==0,N||g?(N=i.stateNode,h=g&&typeof h.getDerivedStateFromError!="function"?null:N.render(),i.flags|=1,r!==null&&g?(i.child=li(i,r.child,null,k),i.child=li(i,null,h,k)):mn(r,i,h,k),i.memoizedState=N.state,r=i.child):r=qr(r,i,k),r}function Ay(r,i,h,g){return ni(),i.flags|=256,mn(r,i,h,g),i.child}var Ph={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Bh(r){return{baseLanes:r,cachePool:_x()}}function zh(r,i,h){return r=r!==null?r.childLanes&~h:0,i&&(r|=Fn),r}function Ly(r,i,h){var g=i.pendingProps,k=!1,N=(i.flags&128)!==0,M;if((M=N)||(M=r!==null&&r.memoizedState===null?!1:(Ft.current&2)!==0),M&&(k=!0,i.flags&=-129),M=(i.flags&32)!==0,i.flags&=-33,r===null){if(ct){if(k?vs(i):Ss(),(r=It)?(r=z_(r,rr),r=r!==null&&r.data!=="&"?r:null,r!==null&&(i.memoizedState={dehydrated:r,treeContext:ms!==null?{id:kr,overflow:Er}:null,retryLane:536870912,hydrationErrors:null},h=ux(r),h.return=i,i.child=h,hn=i,It=null)):r=null,r===null)throw gs(i);return Sf(r)?i.lanes=32:i.lanes=536870912,null}var K=g.children;return g=g.fallback,k?(Ss(),k=i.mode,K=_c({mode:"hidden",children:K},k),g=ti(g,k,h,null),K.return=i,g.return=i,K.sibling=g,i.child=K,g=i.child,g.memoizedState=Bh(h),g.childLanes=zh(r,M,h),i.memoizedState=Ph,Eo(null,g)):(vs(i),$h(i,K))}var ie=r.memoizedState;if(ie!==null&&(K=ie.dehydrated,K!==null)){if(N)i.flags&256?(vs(i),i.flags&=-257,i=Hh(r,i,h)):i.memoizedState!==null?(Ss(),i.child=r.child,i.flags|=128,i=null):(Ss(),K=g.fallback,k=i.mode,g=_c({mode:"visible",children:g.children},k),K=ti(K,k,h,null),K.flags|=2,g.return=i,K.return=i,g.sibling=K,i.child=g,li(i,r.child,null,h),g=i.child,g.memoizedState=Bh(h),g.childLanes=zh(r,M,h),i.memoizedState=Ph,i=Eo(null,g));else if(vs(i),Sf(K)){if(M=K.nextSibling&&K.nextSibling.dataset,M)var me=M.dgst;M=me,g=Error(s(419)),g.stack="",g.digest=M,mo({value:g,source:null,stack:null}),i=Hh(r,i,h)}else if(Xt||sa(r,i,h,!1),M=(h&r.childLanes)!==0,Xt||M){if(M=Et,M!==null&&(g=$e(M,h),g!==0&&g!==ie.retryLane))throw ie.retryLane=g,ei(r,g),Rn(M,r,g),Ih;vf(K)||Nc(),i=Hh(r,i,h)}else vf(K)?(i.flags|=192,i.child=r.child,i=null):(r=ie.treeContext,It=ir(K.nextSibling),hn=i,ct=!0,ps=null,rr=!1,r!==null&&fx(i,r),i=$h(i,g.children),i.flags|=4096);return i}return k?(Ss(),K=g.fallback,k=i.mode,ie=r.child,me=ie.sibling,g=Hr(ie,{mode:"hidden",children:g.children}),g.subtreeFlags=ie.subtreeFlags&65011712,me!==null?K=Hr(me,K):(K=ti(K,k,h,null),K.flags|=2),K.return=i,g.return=i,g.sibling=K,i.child=g,Eo(null,g),g=i.child,K=r.child.memoizedState,K===null?K=Bh(h):(k=K.cachePool,k!==null?(ie=Kt._currentValue,k=k.parent!==ie?{parent:ie,pool:ie}:k):k=_x(),K={baseLanes:K.baseLanes|h,cachePool:k}),g.memoizedState=K,g.childLanes=zh(r,M,h),i.memoizedState=Ph,Eo(r.child,g)):(vs(i),h=r.child,r=h.sibling,h=Hr(h,{mode:"visible",children:g.children}),h.return=i,h.sibling=null,r!==null&&(M=i.deletions,M===null?(i.deletions=[r],i.flags|=16):M.push(r)),i.child=h,i.memoizedState=null,h)}function $h(r,i){return i=_c({mode:"visible",children:i},r.mode),i.return=r,r.child=i}function _c(r,i){return r=zn(22,r,null,i),r.lanes=0,r}function Hh(r,i,h){return li(i,r.child,null,h),r=$h(i,i.pendingProps.children),r.flags|=2,i.memoizedState=null,r}function Ry(r,i,h){r.lanes|=i;var g=r.alternate;g!==null&&(g.lanes|=i),nh(r.return,i,h)}function Uh(r,i,h,g,k,N){var M=r.memoizedState;M===null?r.memoizedState={isBackwards:i,rendering:null,renderingStartTime:0,last:g,tail:h,tailMode:k,treeForkCount:N}:(M.isBackwards=i,M.rendering=null,M.renderingStartTime=0,M.last=g,M.tail=h,M.tailMode=k,M.treeForkCount=N)}function Dy(r,i,h){var g=i.pendingProps,k=g.revealOrder,N=g.tail;g=g.children;var M=Ft.current,K=(M&2)!==0;if(K?(M=M&1|2,i.flags|=128):M&=1,P(Ft,M),mn(r,i,g,h),g=ct?fo:0,!K&&r!==null&&(r.flags&128)!==0)e:for(r=i.child;r!==null;){if(r.tag===13)r.memoizedState!==null&&Ry(r,h,i);else if(r.tag===19)Ry(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&&oc(r)===null&&(k=h),h=h.sibling;h=k,h===null?(k=i.child,i.child=null):(k=h.sibling,h.sibling=null),Uh(i,!1,k,h,N,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&&oc(r)===null){i.child=k;break}r=k.sibling,k.sibling=h,h=k,k=r}Uh(i,!0,h,null,N,g);break;case"together":Uh(i,!1,null,null,void 0,g);break;default:i.memoizedState=null}return i.child}function qr(r,i,h){if(r!==null&&(i.dependencies=r.dependencies),ks|=i.lanes,(h&i.childLanes)===0)if(r!==null){if(sa(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=Hr(r,r.pendingProps),i.child=h,h.return=i;r.sibling!==null;)r=r.sibling,h=h.sibling=Hr(r,r.pendingProps),h.return=i;h.sibling=null}return i.child}function Fh(r,i){return(r.lanes&i)!==0?!0:(r=r.dependencies,!!(r!==null&&Zl(r)))}function gE(r,i,h){switch(i.tag){case 3:F(i,i.stateNode.containerInfo),xs(i,Kt,r.memoizedState.cache),ni();break;case 27:case 5:se(i);break;case 4:F(i,i.stateNode.containerInfo);break;case 10:xs(i,i.type,i.memoizedProps.value);break;case 31:if(i.memoizedState!==null)return i.flags|=128,mh(i),null;break;case 13:var g=i.memoizedState;if(g!==null)return g.dehydrated!==null?(vs(i),i.flags|=128,null):(h&i.child.childLanes)!==0?Ly(r,i,h):(vs(i),r=qr(r,i,h),r!==null?r.sibling:null);vs(i);break;case 19:var k=(r.flags&128)!==0;if(g=(h&i.childLanes)!==0,g||(sa(r,i,h,!1),g=(h&i.childLanes)!==0),k){if(g)return Dy(r,i,h);i.flags|=128}if(k=i.memoizedState,k!==null&&(k.rendering=null,k.tail=null,k.lastEffect=null),P(Ft,Ft.current),g)break;return null;case 22:return i.lanes=0,ky(r,i,h,i.pendingProps);case 24:xs(i,Kt,r.memoizedState.cache)}return qr(r,i,h)}function Oy(r,i,h){if(r!==null)if(r.memoizedProps!==i.pendingProps)Xt=!0;else{if(!Fh(r,h)&&(i.flags&128)===0)return Xt=!1,gE(r,i,h);Xt=(r.flags&131072)!==0}else Xt=!1,ct&&(i.flags&1048576)!==0&&hx(i,fo,i.index);switch(i.lanes=0,i.tag){case 16:e:{var g=i.pendingProps;if(r=ai(i.elementType),i.type=r,typeof r=="function")Kd(r)?(g=ui(r,g),i.tag=1,i=Ty(null,i,r,g,h)):(i.tag=0,i=Mh(null,i,r,g,h));else{if(r!=null){var k=r.$$typeof;if(k===E){i.tag=11,i=Sy(null,i,r,g,h);break e}else if(k===R){i.tag=14,i=wy(null,i,r,g,h);break e}}throw i=U(r)||r,Error(s(306,i,""))}}return i;case 0:return Mh(r,i,i.type,i.pendingProps,h);case 1:return g=i.type,k=ui(g,i.pendingProps),Ty(r,i,g,k,h);case 3:e:{if(F(i,i.stateNode.containerInfo),r===null)throw Error(s(387));g=i.pendingProps;var N=i.memoizedState;k=N.element,ch(r,i),vo(i,g,null,h);var M=i.memoizedState;if(g=M.cache,xs(i,Kt,g),g!==N.cache&&rh(i,[Kt],h,!0),bo(),g=M.element,N.isDehydrated)if(N={element:g,isDehydrated:!1,cache:M.cache},i.updateQueue.baseState=N,i.memoizedState=N,i.flags&256){i=Ay(r,i,g,h);break e}else if(g!==k){k=er(Error(s(424)),i),mo(k),i=Ay(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(It=ir(r.firstChild),hn=i,ct=!0,ps=null,rr=!0,h=kx(i,null,g,h),i.child=h;h;)h.flags=h.flags&-3|4096,h=h.sibling}else{if(ni(),g===k){i=qr(r,i,h);break e}mn(r,i,g,h)}i=i.child}return i;case 26:return yc(r,i),r===null?(h=G_(i.type,null,i.pendingProps,null))?i.memoizedState=h:ct||(h=i.type,r=i.pendingProps,g=Ic(ne.current).createElement(h),g[yt]=i,g[En]=r,pn(g,h,r),on(g),i.stateNode=g):i.memoizedState=G_(i.type,r.memoizedProps,i.pendingProps,r.memoizedState),null;case 27:return se(i),r===null&&ct&&(g=i.stateNode=U_(i.type,i.pendingProps,ne.current),hn=i,rr=!0,k=It,As(i.type)?(wf=k,It=ir(g.firstChild)):It=k),mn(r,i,i.pendingProps.children,h),yc(r,i),r===null&&(i.flags|=4194304),i.child;case 5:return r===null&&ct&&((k=g=It)&&(g=WE(g,i.type,i.pendingProps,rr),g!==null?(i.stateNode=g,hn=i,It=ir(g.firstChild),rr=!1,k=!0):k=!1),k||gs(i)),se(i),k=i.type,N=i.pendingProps,M=r!==null?r.memoizedProps:null,g=N.children,yf(k,N)?g=null:M!==null&&yf(k,M)&&(i.flags|=32),i.memoizedState!==null&&(k=gh(r,i,oE,null,null,h),Ho._currentValue=k),yc(r,i),mn(r,i,g,h),i.child;case 6:return r===null&&ct&&((r=h=It)&&(h=qE(h,i.pendingProps,rr),h!==null?(i.stateNode=h,hn=i,It=null,r=!0):r=!1),r||gs(i)),null;case 13:return Ly(r,i,h);case 4:return F(i,i.stateNode.containerInfo),g=i.pendingProps,r===null?i.child=li(i,null,g,h):mn(r,i,g,h),i.child;case 11:return Sy(r,i,i.type,i.pendingProps,h);case 7:return mn(r,i,i.pendingProps,h),i.child;case 8:return mn(r,i,i.pendingProps.children,h),i.child;case 12:return mn(r,i,i.pendingProps.children,h),i.child;case 10:return g=i.pendingProps,xs(i,i.type,g.value),mn(r,i,g.children,h),i.child;case 9:return k=i.type._context,g=i.pendingProps.children,si(i),k=fn(k),g=g(k),i.flags|=1,mn(r,i,g,h),i.child;case 14:return wy(r,i,i.type,i.pendingProps,h);case 15:return Cy(r,i,i.type,i.pendingProps,h);case 19:return Dy(r,i,h);case 31:return pE(r,i,h);case 22:return ky(r,i,h,i.pendingProps);case 24:return si(i),g=fn(Kt),r===null?(k=ah(),k===null&&(k=Et,N=sh(),k.pooledCache=N,N.refCount++,N!==null&&(k.pooledCacheLanes|=h),k=N),i.memoizedState={parent:g,cache:k},lh(i),xs(i,Kt,k)):((r.lanes&h)!==0&&(ch(r,i),vo(i,null,null,h),bo()),k=r.memoizedState,N=i.memoizedState,k.parent!==g?(k={parent:g,cache:g},i.memoizedState=k,i.lanes===0&&(i.memoizedState=i.updateQueue.baseState=k),xs(i,Kt,g)):(g=N.cache,xs(i,Kt,g),g!==k.cache&&rh(i,[Kt],h,!0))),mn(r,i,i.pendingProps.children,h),i.child;case 29:throw i.pendingProps}throw Error(s(156,i.tag))}function Kr(r){r.flags|=4}function Vh(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(o_())r.flags|=8192;else throw oi=rc,oh}else r.flags&=-16777217}function Iy(r,i){if(i.type!=="stylesheet"||(i.state.loading&4)!==0)r.flags&=-16777217;else if(r.flags|=16777216,!X_(i))if(o_())r.flags|=8192;else throw oi=rc,oh}function bc(r,i){i!==null&&(r.flags|=4),r.flags&16384&&(i=r.tag!==22?Ml():536870912,r.lanes|=i,ga|=i)}function jo(r,i){if(!ct)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 Mt(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 xE(r,i,h){var g=i.pendingProps;switch(Jd(i),i.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Mt(i),null;case 1:return Mt(i),null;case 3:return h=i.stateNode,g=null,r!==null&&(g=r.memoizedState.cache),i.memoizedState.cache!==g&&(i.flags|=2048),Vr(Kt),te(),h.pendingContext&&(h.context=h.pendingContext,h.pendingContext=null),(r===null||r.child===null)&&(ra(i)?Kr(i):r===null||r.memoizedState.isDehydrated&&(i.flags&256)===0||(i.flags|=1024,eh())),Mt(i),null;case 26:var k=i.type,N=i.memoizedState;return r===null?(Kr(i),N!==null?(Mt(i),Iy(i,N)):(Mt(i),Vh(i,k,null,g,h))):N?N!==r.memoizedState?(Kr(i),Mt(i),Iy(i,N)):(Mt(i),i.flags&=-16777217):(r=r.memoizedProps,r!==g&&Kr(i),Mt(i),Vh(i,k,r,g,h)),null;case 27:if(xe(i),h=ne.current,k=i.type,r!==null&&i.stateNode!=null)r.memoizedProps!==g&&Kr(i);else{if(!g){if(i.stateNode===null)throw Error(s(166));return Mt(i),null}r=ee.current,ra(i)?mx(i):(r=U_(k,g,h),i.stateNode=r,Kr(i))}return Mt(i),null;case 5:if(xe(i),k=i.type,r!==null&&i.stateNode!=null)r.memoizedProps!==g&&Kr(i);else{if(!g){if(i.stateNode===null)throw Error(s(166));return Mt(i),null}if(N=ee.current,ra(i))mx(i);else{var M=Ic(ne.current);switch(N){case 1:N=M.createElementNS("http://www.w3.org/2000/svg",k);break;case 2:N=M.createElementNS("http://www.w3.org/1998/Math/MathML",k);break;default:switch(k){case"svg":N=M.createElementNS("http://www.w3.org/2000/svg",k);break;case"math":N=M.createElementNS("http://www.w3.org/1998/Math/MathML",k);break;case"script":N=M.createElement("div"),N.innerHTML="<script><\/script>",N=N.removeChild(N.firstChild);break;case"select":N=typeof g.is=="string"?M.createElement("select",{is:g.is}):M.createElement("select"),g.multiple?N.multiple=!0:g.size&&(N.size=g.size);break;default:N=typeof g.is=="string"?M.createElement(k,{is:g.is}):M.createElement(k)}}N[yt]=i,N[En]=g;e:for(M=i.child;M!==null;){if(M.tag===5||M.tag===6)N.appendChild(M.stateNode);else if(M.tag!==4&&M.tag!==27&&M.child!==null){M.child.return=M,M=M.child;continue}if(M===i)break e;for(;M.sibling===null;){if(M.return===null||M.return===i)break e;M=M.return}M.sibling.return=M.return,M=M.sibling}i.stateNode=N;e:switch(pn(N,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&&Kr(i)}}return Mt(i),Vh(i,i.type,r===null?null:r.memoizedProps,i.pendingProps,h),null;case 6:if(r&&i.stateNode!=null)r.memoizedProps!==g&&Kr(i);else{if(typeof g!="string"&&i.stateNode===null)throw Error(s(166));if(r=ne.current,ra(i)){if(r=i.stateNode,h=i.memoizedProps,g=null,k=hn,k!==null)switch(k.tag){case 27:case 5:g=k.memoizedProps}r[yt]=i,r=!!(r.nodeValue===h||g!==null&&g.suppressHydrationWarning===!0||L_(r.nodeValue,h)),r||gs(i,!0)}else r=Ic(r).createTextNode(g),r[yt]=i,i.stateNode=r}return Mt(i),null;case 31:if(h=i.memoizedState,r===null||r.memoizedState!==null){if(g=ra(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 ni(),(i.flags&128)===0&&(i.memoizedState=null),i.flags|=4;Mt(i),r=!1}else h=eh(),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 Mt(i),null;case 13:if(g=i.memoizedState,r===null||r.memoizedState!==null&&r.memoizedState.dehydrated!==null){if(k=ra(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 ni(),(i.flags&128)===0&&(i.memoizedState=null),i.flags|=4;Mt(i),k=!1}else k=eh(),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),N=null,g.memoizedState!==null&&g.memoizedState.cachePool!==null&&(N=g.memoizedState.cachePool.pool),N!==k&&(g.flags|=2048)),h!==r&&h&&(i.child.flags|=8192),bc(i,i.updateQueue),Mt(i),null);case 4:return te(),r===null&&ff(i.stateNode.containerInfo),Mt(i),null;case 10:return Vr(i.type),Mt(i),null;case 19:if(W(Ft),g=i.memoizedState,g===null)return Mt(i),null;if(k=(i.flags&128)!==0,N=g.rendering,N===null)if(k)jo(g,!1);else{if($t!==0||r!==null&&(r.flags&128)!==0)for(r=i.child;r!==null;){if(N=oc(r),N!==null){for(i.flags|=128,jo(g,!1),r=N.updateQueue,i.updateQueue=r,bc(i,r),i.subtreeFlags=0,r=h,h=i.child;h!==null;)cx(h,r),h=h.sibling;return P(Ft,Ft.current&1|2),ct&&Ur(i,g.treeForkCount),i.child}r=r.sibling}g.tail!==null&&rt()>kc&&(i.flags|=128,k=!0,jo(g,!1),i.lanes=4194304)}else{if(!k)if(r=oc(N),r!==null){if(i.flags|=128,k=!0,r=r.updateQueue,i.updateQueue=r,bc(i,r),jo(g,!0),g.tail===null&&g.tailMode==="hidden"&&!N.alternate&&!ct)return Mt(i),null}else 2*rt()-g.renderingStartTime>kc&&h!==536870912&&(i.flags|=128,k=!0,jo(g,!1),i.lanes=4194304);g.isBackwards?(N.sibling=i.child,i.child=N):(r=g.last,r!==null?r.sibling=N:i.child=N,g.last=N)}return g.tail!==null?(r=g.tail,g.rendering=r,g.tail=r.sibling,g.renderingStartTime=rt(),r.sibling=null,h=Ft.current,P(Ft,k?h&1|2:h&1),ct&&Ur(i,g.treeForkCount),r):(Mt(i),null);case 22:case 23:return Hn(i),fh(),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&&(Mt(i),i.subtreeFlags&6&&(i.flags|=8192)):Mt(i),h=i.updateQueue,h!==null&&bc(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&&W(ii),null;case 24:return h=null,r!==null&&(h=r.memoizedState.cache),i.memoizedState.cache!==h&&(i.flags|=2048),Vr(Kt),Mt(i),null;case 25:return null;case 30:return null}throw Error(s(156,i.tag))}function yE(r,i){switch(Jd(i),i.tag){case 1:return r=i.flags,r&65536?(i.flags=r&-65537|128,i):null;case 3:return Vr(Kt),te(),r=i.flags,(r&65536)!==0&&(r&128)===0?(i.flags=r&-65537|128,i):null;case 26:case 27:case 5:return xe(i),null;case 31:if(i.memoizedState!==null){if(Hn(i),i.alternate===null)throw Error(s(340));ni()}return r=i.flags,r&65536?(i.flags=r&-65537|128,i):null;case 13:if(Hn(i),r=i.memoizedState,r!==null&&r.dehydrated!==null){if(i.alternate===null)throw Error(s(340));ni()}return r=i.flags,r&65536?(i.flags=r&-65537|128,i):null;case 19:return W(Ft),null;case 4:return te(),null;case 10:return Vr(i.type),null;case 22:case 23:return Hn(i),fh(),r!==null&&W(ii),r=i.flags,r&65536?(i.flags=r&-65537|128,i):null;case 24:return Vr(Kt),null;case 25:return null;default:return null}}function My(r,i){switch(Jd(i),i.tag){case 3:Vr(Kt),te();break;case 26:case 27:case 5:xe(i);break;case 4:te();break;case 31:i.memoizedState!==null&&Hn(i);break;case 13:Hn(i);break;case 19:W(Ft);break;case 10:Vr(i.type);break;case 22:case 23:Hn(i),fh(),r!==null&&W(ii);break;case 24:Vr(Kt)}}function No(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 N=h.create,M=h.inst;g=N(),M.destroy=g}h=h.next}while(h!==k)}}catch(K){bt(i,i.return,K)}}function ws(r,i,h){try{var g=i.updateQueue,k=g!==null?g.lastEffect:null;if(k!==null){var N=k.next;g=N;do{if((g.tag&r)===r){var M=g.inst,K=M.destroy;if(K!==void 0){M.destroy=void 0,k=i;var ie=h,me=K;try{me()}catch(Se){bt(k,ie,Se)}}}g=g.next}while(g!==N)}}catch(Se){bt(i,i.return,Se)}}function Py(r){var i=r.updateQueue;if(i!==null){var h=r.stateNode;try{jx(i,h)}catch(g){bt(r,r.return,g)}}}function By(r,i,h){h.props=ui(r.type,r.memoizedProps),h.state=r.memoizedState;try{h.componentWillUnmount()}catch(g){bt(r,i,g)}}function To(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 zy(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 Gh(r,i,h){try{var g=r.stateNode;$E(g,r.type,h,i),g[En]=i}catch(k){bt(r,r.return,k)}}function $y(r){return r.tag===5||r.tag===3||r.tag===26||r.tag===27&&As(r.type)||r.tag===4}function Wh(r){e:for(;;){for(;r.sibling===null;){if(r.return===null||$y(r.return))return null;r=r.return}for(r.sibling.return=r.return,r=r.sibling;r.tag!==5&&r.tag!==6&&r.tag!==18;){if(r.tag===27&&As(r.type)||r.flags&2||r.child===null||r.tag===4)continue e;r.child.return=r,r=r.child}if(!(r.flags&2))return r.stateNode}}function qh(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=zr));else if(g!==4&&(g===27&&As(r.type)&&(h=r.stateNode,i=null),r=r.child,r!==null))for(qh(r,i,h),r=r.sibling;r!==null;)qh(r,i,h),r=r.sibling}function vc(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&&As(r.type)&&(h=r.stateNode),r=r.child,r!==null))for(vc(r,i,h),r=r.sibling;r!==null;)vc(r,i,h),r=r.sibling}function Hy(r){var i=r.stateNode,h=r.memoizedProps;try{for(var g=r.type,k=i.attributes;k.length;)i.removeAttributeNode(k[0]);pn(i,g,h),i[yt]=r,i[En]=h}catch(N){bt(r,r.return,N)}}var Yr=!1,Qt=!1,Kh=!1,Uy=typeof WeakSet=="function"?WeakSet:Set,ln=null;function _E(r,i){if(r=r.containerInfo,gf=Uc,r=ex(r),Hd(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,N=g.focusNode;g=g.focusOffset;try{h.nodeType,N.nodeType}catch{h=null;break e}var M=0,K=-1,ie=-1,me=0,Se=0,je=r,pe=null;t:for(;;){for(var ge;je!==h||k!==0&&je.nodeType!==3||(K=M+k),je!==N||g!==0&&je.nodeType!==3||(ie=M+g),je.nodeType===3&&(M+=je.nodeValue.length),(ge=je.firstChild)!==null;)pe=je,je=ge;for(;;){if(je===r)break t;if(pe===h&&++me===k&&(K=M),pe===N&&++Se===g&&(ie=M),(ge=je.nextSibling)!==null)break;je=pe,pe=je.parentNode}je=ge}h=K===-1||ie===-1?null:{start:K,end:ie}}else h=null}h=h||{start:0,end:0}}else h=null;for(xf={focusedElem:r,selectionRange:h},Uc=!1,ln=i;ln!==null;)if(i=ln,r=i.child,(i.subtreeFlags&1028)!==0&&r!==null)r.return=i,ln=r;else for(;ln!==null;){switch(i=ln,N=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&&N!==null){r=void 0,h=i,k=N.memoizedProps,N=N.memoizedState,g=h.stateNode;try{var Me=ui(h.type,k);r=g.getSnapshotBeforeUpdate(Me,N),g.__reactInternalSnapshotBeforeUpdate=r}catch(Fe){bt(h,h.return,Fe)}}break;case 3:if((r&1024)!==0){if(r=i.stateNode.containerInfo,h=r.nodeType,h===9)bf(r);else if(h===1)switch(r.nodeName){case"HEAD":case"HTML":case"BODY":bf(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,ln=r;break}ln=i.return}}function Fy(r,i,h){var g=h.flags;switch(h.tag){case 0:case 11:case 15:Qr(r,h),g&4&&No(5,h);break;case 1:if(Qr(r,h),g&4)if(r=h.stateNode,i===null)try{r.componentDidMount()}catch(M){bt(h,h.return,M)}else{var k=ui(h.type,i.memoizedProps);i=i.memoizedState;try{r.componentDidUpdate(k,i,r.__reactInternalSnapshotBeforeUpdate)}catch(M){bt(h,h.return,M)}}g&64&&Py(h),g&512&&To(h,h.return);break;case 3:if(Qr(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{jx(r,i)}catch(M){bt(h,h.return,M)}}break;case 27:i===null&&g&4&&Hy(h);case 26:case 5:Qr(r,h),i===null&&g&4&&zy(h),g&512&&To(h,h.return);break;case 12:Qr(r,h);break;case 31:Qr(r,h),g&4&&Wy(r,h);break;case 13:Qr(r,h),g&4&&qy(r,h),g&64&&(r=h.memoizedState,r!==null&&(r=r.dehydrated,r!==null&&(h=NE.bind(null,h),KE(r,h))));break;case 22:if(g=h.memoizedState!==null||Yr,!g){i=i!==null&&i.memoizedState!==null||Qt,k=Yr;var N=Qt;Yr=g,(Qt=i)&&!N?Jr(r,h,(h.subtreeFlags&8772)!==0):Qr(r,h),Yr=k,Qt=N}break;case 30:break;default:Qr(r,h)}}function Vy(r){var i=r.alternate;i!==null&&(r.alternate=null,Vy(i)),r.child=null,r.deletions=null,r.sibling=null,r.tag===5&&(i=r.stateNode,i!==null&&Cd(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,Nn=!1;function Xr(r,i,h){for(h=h.child;h!==null;)Gy(r,i,h),h=h.sibling}function Gy(r,i,h){if(pt&&typeof pt.onCommitFiberUnmount=="function")try{pt.onCommitFiberUnmount(Ot,h)}catch{}switch(h.tag){case 26:Qt||jr(h,i),Xr(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=Nn;As(h.type)&&(Bt=h.stateNode,Nn=!1),Xr(r,i,h),Bo(h.stateNode),Bt=g,Nn=k;break;case 5:Qt||jr(h,i);case 6:if(g=Bt,k=Nn,Bt=null,Xr(r,i,h),Bt=g,Nn=k,Bt!==null)if(Nn)try{(Bt.nodeType===9?Bt.body:Bt.nodeName==="HTML"?Bt.ownerDocument.body:Bt).removeChild(h.stateNode)}catch(N){bt(h,i,N)}else try{Bt.removeChild(h.stateNode)}catch(N){bt(h,i,N)}break;case 18:Bt!==null&&(Nn?(r=Bt,P_(r.nodeType===9?r.body:r.nodeName==="HTML"?r.ownerDocument.body:r,h.stateNode),Ca(r)):P_(Bt,h.stateNode));break;case 4:g=Bt,k=Nn,Bt=h.stateNode.containerInfo,Nn=!0,Xr(r,i,h),Bt=g,Nn=k;break;case 0:case 11:case 14:case 15:ws(2,h,i),Qt||ws(4,h,i),Xr(r,i,h);break;case 1:Qt||(jr(h,i),g=h.stateNode,typeof g.componentWillUnmount=="function"&&By(h,i,g)),Xr(r,i,h);break;case 21:Xr(r,i,h);break;case 22:Qt=(g=Qt)||h.memoizedState!==null,Xr(r,i,h),Qt=g;break;default:Xr(r,i,h)}}function Wy(r,i){if(i.memoizedState===null&&(r=i.alternate,r!==null&&(r=r.memoizedState,r!==null))){r=r.dehydrated;try{Ca(r)}catch(h){bt(i,i.return,h)}}}function qy(r,i){if(i.memoizedState===null&&(r=i.alternate,r!==null&&(r=r.memoizedState,r!==null&&(r=r.dehydrated,r!==null))))try{Ca(r)}catch(h){bt(i,i.return,h)}}function bE(r){switch(r.tag){case 31:case 13:case 19:var i=r.stateNode;return i===null&&(i=r.stateNode=new Uy),i;case 22:return r=r.stateNode,i=r._retryCache,i===null&&(i=r._retryCache=new Uy),i;default:throw Error(s(435,r.tag))}}function Sc(r,i){var h=bE(r);i.forEach(function(g){if(!h.has(g)){h.add(g);var k=TE.bind(null,r,g);g.then(k,k)}})}function Tn(r,i){var h=i.deletions;if(h!==null)for(var g=0;g<h.length;g++){var k=h[g],N=r,M=i,K=M;e:for(;K!==null;){switch(K.tag){case 27:if(As(K.type)){Bt=K.stateNode,Nn=!1;break e}break;case 5:Bt=K.stateNode,Nn=!1;break e;case 3:case 4:Bt=K.stateNode.containerInfo,Nn=!0;break e}K=K.return}if(Bt===null)throw Error(s(160));Gy(N,M,k),Bt=null,Nn=!1,N=k.alternate,N!==null&&(N.return=null),k.return=null}if(i.subtreeFlags&13886)for(i=i.child;i!==null;)Ky(i,r),i=i.sibling}var pr=null;function Ky(r,i){var h=r.alternate,g=r.flags;switch(r.tag){case 0:case 11:case 14:case 15:Tn(i,r),An(r),g&4&&(ws(3,r,r.return),No(3,r),ws(5,r,r.return));break;case 1:Tn(i,r),An(r),g&512&&(Qt||h===null||jr(h,h.return)),g&64&&Yr&&(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(Tn(i,r),An(r),g&512&&(Qt||h===null||jr(h,h.return)),g&4){var N=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":N=k.getElementsByTagName("title")[0],(!N||N[to]||N[yt]||N.namespaceURI==="http://www.w3.org/2000/svg"||N.hasAttribute("itemprop"))&&(N=k.createElement(g),k.head.insertBefore(N,k.querySelector("head > title"))),pn(N,g,h),N[yt]=r,on(N),g=N;break e;case"link":var M=K_("link","href",k).get(g+(h.href||""));if(M){for(var K=0;K<M.length;K++)if(N=M[K],N.getAttribute("href")===(h.href==null||h.href===""?null:h.href)&&N.getAttribute("rel")===(h.rel==null?null:h.rel)&&N.getAttribute("title")===(h.title==null?null:h.title)&&N.getAttribute("crossorigin")===(h.crossOrigin==null?null:h.crossOrigin)){M.splice(K,1);break t}}N=k.createElement(g),pn(N,g,h),k.head.appendChild(N);break;case"meta":if(M=K_("meta","content",k).get(g+(h.content||""))){for(K=0;K<M.length;K++)if(N=M[K],N.getAttribute("content")===(h.content==null?null:""+h.content)&&N.getAttribute("name")===(h.name==null?null:h.name)&&N.getAttribute("property")===(h.property==null?null:h.property)&&N.getAttribute("http-equiv")===(h.httpEquiv==null?null:h.httpEquiv)&&N.getAttribute("charset")===(h.charSet==null?null:h.charSet)){M.splice(K,1);break t}}N=k.createElement(g),pn(N,g,h),k.head.appendChild(N);break;default:throw Error(s(468,g))}N[yt]=r,on(N),g=N}r.stateNode=g}else Y_(k,r.type,r.stateNode);else r.stateNode=q_(k,g,r.memoizedProps);else N!==g?(N===null?h.stateNode!==null&&(h=h.stateNode,h.parentNode.removeChild(h)):N.count--,g===null?Y_(k,r.type,r.stateNode):q_(k,g,r.memoizedProps)):g===null&&r.stateNode!==null&&Gh(r,r.memoizedProps,h.memoizedProps)}break;case 27:Tn(i,r),An(r),g&512&&(Qt||h===null||jr(h,h.return)),h!==null&&g&4&&Gh(r,r.memoizedProps,h.memoizedProps);break;case 5:if(Tn(i,r),An(r),g&512&&(Qt||h===null||jr(h,h.return)),r.flags&32){k=r.stateNode;try{qi(k,"")}catch(Me){bt(r,r.return,Me)}}g&4&&r.stateNode!=null&&(k=r.memoizedProps,Gh(r,k,h!==null?h.memoizedProps:k)),g&1024&&(Kh=!0);break;case 6:if(Tn(i,r),An(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(Bc=null,k=pr,pr=Mc(i.containerInfo),Tn(i,r),pr=k,An(r),g&4&&h!==null&&h.memoizedState.isDehydrated)try{Ca(i.containerInfo)}catch(Me){bt(r,r.return,Me)}Kh&&(Kh=!1,Yy(r));break;case 4:g=pr,pr=Mc(r.stateNode.containerInfo),Tn(i,r),An(r),pr=g;break;case 12:Tn(i,r),An(r);break;case 31:Tn(i,r),An(r),g&4&&(g=r.updateQueue,g!==null&&(r.updateQueue=null,Sc(r,g)));break;case 13:Tn(i,r),An(r),r.child.flags&8192&&r.memoizedState!==null!=(h!==null&&h.memoizedState!==null)&&(Cc=rt()),g&4&&(g=r.updateQueue,g!==null&&(r.updateQueue=null,Sc(r,g)));break;case 22:k=r.memoizedState!==null;var ie=h!==null&&h.memoizedState!==null,me=Yr,Se=Qt;if(Yr=me||k,Qt=Se||ie,Tn(i,r),Qt=Se,Yr=me,An(r),g&8192)e:for(i=r.stateNode,i._visibility=k?i._visibility&-2:i._visibility|1,k&&(h===null||ie||Yr||Qt||di(r)),h=null,i=r;;){if(i.tag===5||i.tag===26){if(h===null){ie=h=i;try{if(N=ie.stateNode,k)M=N.style,typeof M.setProperty=="function"?M.setProperty("display","none","important"):M.display="none";else{K=ie.stateNode;var je=ie.memoizedProps.style,pe=je!=null&&je.hasOwnProperty("display")?je.display:null;K.style.display=pe==null||typeof pe=="boolean"?"":(""+pe).trim()}}catch(Me){bt(ie,ie.return,Me)}}}else if(i.tag===6){if(h===null){ie=i;try{ie.stateNode.nodeValue=k?"":ie.memoizedProps}catch(Me){bt(ie,ie.return,Me)}}}else if(i.tag===18){if(h===null){ie=i;try{var ge=ie.stateNode;k?B_(ge,!0):B_(ie.stateNode,!1)}catch(Me){bt(ie,ie.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,Sc(r,h))));break;case 19:Tn(i,r),An(r),g&4&&(g=r.updateQueue,g!==null&&(r.updateQueue=null,Sc(r,g)));break;case 30:break;case 21:break;default:Tn(i,r),An(r)}}function An(r){var i=r.flags;if(i&2){try{for(var h,g=r.return;g!==null;){if($y(g)){h=g;break}g=g.return}if(h==null)throw Error(s(160));switch(h.tag){case 27:var k=h.stateNode,N=Wh(r);vc(r,N,k);break;case 5:var M=h.stateNode;h.flags&32&&(qi(M,""),h.flags&=-33);var K=Wh(r);vc(r,K,M);break;case 3:case 4:var ie=h.stateNode.containerInfo,me=Wh(r);qh(r,me,ie);break;default:throw Error(s(161))}}catch(Se){bt(r,r.return,Se)}r.flags&=-3}i&4096&&(r.flags&=-4097)}function Yy(r){if(r.subtreeFlags&1024)for(r=r.child;r!==null;){var i=r;Yy(i),i.tag===5&&i.flags&1024&&i.stateNode.reset(),r=r.sibling}}function Qr(r,i){if(i.subtreeFlags&8772)for(i=i.child;i!==null;)Fy(r,i.alternate,i),i=i.sibling}function di(r){for(r=r.child;r!==null;){var i=r;switch(i.tag){case 0:case 11:case 14:case 15:ws(4,i,i.return),di(i);break;case 1:jr(i,i.return);var h=i.stateNode;typeof h.componentWillUnmount=="function"&&By(i,i.return,h),di(i);break;case 27:Bo(i.stateNode);case 26:case 5:jr(i,i.return),di(i);break;case 22:i.memoizedState===null&&di(i);break;case 30:di(i);break;default:di(i)}r=r.sibling}}function Jr(r,i,h){for(h=h&&(i.subtreeFlags&8772)!==0,i=i.child;i!==null;){var g=i.alternate,k=r,N=i,M=N.flags;switch(N.tag){case 0:case 11:case 15:Jr(k,N,h),No(4,N);break;case 1:if(Jr(k,N,h),g=N,k=g.stateNode,typeof k.componentDidMount=="function")try{k.componentDidMount()}catch(me){bt(g,g.return,me)}if(g=N,k=g.updateQueue,k!==null){var K=g.stateNode;try{var ie=k.shared.hiddenCallbacks;if(ie!==null)for(k.shared.hiddenCallbacks=null,k=0;k<ie.length;k++)Ex(ie[k],K)}catch(me){bt(g,g.return,me)}}h&&M&64&&Py(N),To(N,N.return);break;case 27:Hy(N);case 26:case 5:Jr(k,N,h),h&&g===null&&M&4&&zy(N),To(N,N.return);break;case 12:Jr(k,N,h);break;case 31:Jr(k,N,h),h&&M&4&&Wy(k,N);break;case 13:Jr(k,N,h),h&&M&4&&qy(k,N);break;case 22:N.memoizedState===null&&Jr(k,N,h),To(N,N.return);break;case 30:break;default:Jr(k,N,h)}i=i.sibling}}function Yh(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&&po(h))}function Xh(r,i){r=null,i.alternate!==null&&(r=i.alternate.memoizedState.cache),i=i.memoizedState.cache,i!==r&&(i.refCount++,r!=null&&po(r))}function gr(r,i,h,g){if(i.subtreeFlags&10256)for(i=i.child;i!==null;)Xy(r,i,h,g),i=i.sibling}function Xy(r,i,h,g){var k=i.flags;switch(i.tag){case 0:case 11:case 15:gr(r,i,h,g),k&2048&&No(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&&po(r)));break;case 12:if(k&2048){gr(r,i,h,g),r=i.stateNode;try{var N=i.memoizedProps,M=N.id,K=N.onPostCommit;typeof K=="function"&&K(M,i.alternate===null?"mount":"update",r.passiveEffectDuration,-0)}catch(ie){bt(i,i.return,ie)}}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:N=i.stateNode,M=i.alternate,i.memoizedState!==null?N._visibility&2?gr(r,i,h,g):Ao(r,i):N._visibility&2?gr(r,i,h,g):(N._visibility|=2,fa(r,i,h,g,(i.subtreeFlags&10256)!==0||!1)),k&2048&&Yh(M,i);break;case 24:gr(r,i,h,g),k&2048&&Xh(i.alternate,i);break;default:gr(r,i,h,g)}}function fa(r,i,h,g,k){for(k=k&&((i.subtreeFlags&10256)!==0||!1),i=i.child;i!==null;){var N=r,M=i,K=h,ie=g,me=M.flags;switch(M.tag){case 0:case 11:case 15:fa(N,M,K,ie,k),No(8,M);break;case 23:break;case 22:var Se=M.stateNode;M.memoizedState!==null?Se._visibility&2?fa(N,M,K,ie,k):Ao(N,M):(Se._visibility|=2,fa(N,M,K,ie,k)),k&&me&2048&&Yh(M.alternate,M);break;case 24:fa(N,M,K,ie,k),k&&me&2048&&Xh(M.alternate,M);break;default:fa(N,M,K,ie,k)}i=i.sibling}}function Ao(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:Ao(h,g),k&2048&&Yh(g.alternate,g);break;case 24:Ao(h,g),k&2048&&Xh(g.alternate,g);break;default:Ao(h,g)}i=i.sibling}}var Lo=8192;function ma(r,i,h){if(r.subtreeFlags&Lo)for(r=r.child;r!==null;)Qy(r,i,h),r=r.sibling}function Qy(r,i,h){switch(r.tag){case 26:ma(r,i,h),r.flags&Lo&&r.memoizedState!==null&&a2(h,pr,r.memoizedState,r.memoizedProps);break;case 5:ma(r,i,h);break;case 3:case 4:var g=pr;pr=Mc(r.stateNode.containerInfo),ma(r,i,h),pr=g;break;case 22:r.memoizedState===null&&(g=r.alternate,g!==null&&g.memoizedState!==null?(g=Lo,Lo=16777216,ma(r,i,h),Lo=g):ma(r,i,h));break;default:ma(r,i,h)}}function Jy(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 Ro(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];ln=g,e_(g,r)}Jy(r)}if(r.subtreeFlags&10256)for(r=r.child;r!==null;)Zy(r),r=r.sibling}function Zy(r){switch(r.tag){case 0:case 11:case 15:Ro(r),r.flags&2048&&ws(9,r,r.return);break;case 3:Ro(r);break;case 12:Ro(r);break;case 22:var i=r.stateNode;r.memoizedState!==null&&i._visibility&2&&(r.return===null||r.return.tag!==13)?(i._visibility&=-3,wc(r)):Ro(r);break;default:Ro(r)}}function wc(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];ln=g,e_(g,r)}Jy(r)}for(r=r.child;r!==null;){switch(i=r,i.tag){case 0:case 11:case 15:ws(8,i,i.return),wc(i);break;case 22:h=i.stateNode,h._visibility&2&&(h._visibility&=-3,wc(i));break;default:wc(i)}r=r.sibling}}function e_(r,i){for(;ln!==null;){var h=ln;switch(h.tag){case 0:case 11:case 15:ws(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:po(h.memoizedState.cache)}if(g=h.child,g!==null)g.return=h,ln=g;else e:for(h=r;ln!==null;){g=ln;var k=g.sibling,N=g.return;if(Vy(g),g===h){ln=null;break e}if(k!==null){k.return=N,ln=k;break e}ln=N}}}var vE={getCacheForType:function(r){var i=fn(Kt),h=i.data.get(r);return h===void 0&&(h=r(),i.data.set(r,h)),h},cacheSignal:function(){return fn(Kt).controller.signal}},SE=typeof WeakMap=="function"?WeakMap:Map,gt=0,Et=null,st=null,ot=0,_t=0,Un=null,Cs=!1,pa=!1,Qh=!1,Zr=0,$t=0,ks=0,hi=0,Jh=0,Fn=0,ga=0,Do=null,Ln=null,Zh=!1,Cc=0,t_=0,kc=1/0,Ec=null,Es=null,tn=0,js=null,xa=null,es=0,ef=0,tf=null,n_=null,Oo=0,nf=null;function Vn(){return(gt&2)!==0&&ot!==0?ot&-ot:z.T!==null?cf():dt()}function r_(){if(Fn===0)if((ot&536870912)===0||ct){var r=Pi;Pi<<=1,(Pi&3932160)===0&&(Pi=262144),Fn=r}else Fn=536870912;return r=$n.current,r!==null&&(r.flags|=32),Fn}function Rn(r,i,h){(r===Et&&(_t===2||_t===9)||r.cancelPendingCommit!==null)&&(ya(r,0),Ns(r,ot,Fn,!1)),hs(r,h),((gt&2)===0||r!==Et)&&(r===Et&&((gt&2)===0&&(hi|=h),$t===4&&Ns(r,ot,Fn,!1)),Nr(r))}function s_(r,i,h){if((gt&6)!==0)throw Error(s(327));var g=!h&&(i&127)===0&&(i&r.expiredLanes)===0||Ys(r,i),k=g?kE(r,i):sf(r,i,!0),N=g;do{if(k===0){pa&&!g&&Ns(r,i,0,!1);break}else{if(h=r.current.alternate,N&&!wE(h)){k=sf(r,i,!1),N=!1;continue}if(k===2){if(N=i,r.errorRecoveryDisabledLanes&N)var M=0;else M=r.pendingLanes&-536870913,M=M!==0?M:M&536870912?536870912:0;if(M!==0){i=M;e:{var K=r;k=Do;var ie=K.current.memoizedState.isDehydrated;if(ie&&(ya(K,M).flags|=256),M=sf(K,M,!1),M!==2){if(Qh&&!ie){K.errorRecoveryDisabledLanes|=N,hi|=N,k=4;break e}N=Ln,Ln=k,N!==null&&(Ln===null?Ln=N:Ln.push.apply(Ln,N))}k=M}if(N=!1,k!==2)continue}}if(k===1){ya(r,0),Ns(r,i,0,!0);break}e:{switch(g=r,N=k,N){case 0:case 1:throw Error(s(345));case 4:if((i&4194048)!==i)break;case 6:Ns(g,i,Fn,!Cs);break e;case 2:Ln=null;break;case 3:case 5:break;default:throw Error(s(329))}if((i&62914560)===i&&(k=Cc+300-rt(),10<k)){if(Ns(g,i,Fn,!Cs),zi(g,0,!0)!==0)break e;es=i,g.timeoutHandle=I_(i_.bind(null,g,h,Ln,Ec,Zh,i,Fn,hi,ga,Cs,N,"Throttled",-0,0),k);break e}i_(g,h,Ln,Ec,Zh,i,Fn,hi,ga,Cs,N,null,-0,0)}}break}while(!0);Nr(r)}function i_(r,i,h,g,k,N,M,K,ie,me,Se,je,pe,ge){if(r.timeoutHandle=-1,je=i.subtreeFlags,je&8192||(je&16785408)===16785408){je={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:zr},Qy(i,N,je);var Me=(N&62914560)===N?Cc-rt():(N&4194048)===N?t_-rt():0;if(Me=o2(je,Me),Me!==null){es=N,r.cancelPendingCommit=Me(f_.bind(null,r,i,N,h,g,k,M,K,ie,Se,je,null,pe,ge)),Ns(r,N,M,!me);return}}f_(r,i,N,h,g,k,M,K,ie)}function wE(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],N=k.getSnapshot;k=k.value;try{if(!Bn(N(),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 Ns(r,i,h,g){i&=~Jh,i&=~hi,r.suspendedLanes|=i,r.pingedLanes&=~i,g&&(r.warmLanes|=i),g=r.expirationTimes;for(var k=i;0<k;){var N=31-xt(k),M=1<<N;g[N]=-1,k&=~M}h!==0&&ke(r,h,i)}function jc(){return(gt&6)===0?(Io(0),!1):!0}function rf(){if(st!==null){if(_t===0)var r=st.return;else r=st,Fr=ri=null,_h(r),la=null,xo=0,r=st;for(;r!==null;)My(r.alternate,r),r=r.return;st=null}}function ya(r,i){var h=r.timeoutHandle;h!==-1&&(r.timeoutHandle=-1,FE(h)),h=r.cancelPendingCommit,h!==null&&(r.cancelPendingCommit=null,h()),es=0,rf(),Et=r,st=h=Hr(r.current,null),ot=i,_t=0,Un=null,Cs=!1,pa=Ys(r,i),Qh=!1,ga=Fn=Jh=hi=ks=$t=0,Ln=Do=null,Zh=!1,(i&8)!==0&&(i|=i&32);var g=r.entangledLanes;if(g!==0)for(r=r.entanglements,g&=i;0<g;){var k=31-xt(g),N=1<<k;i|=r[k],g&=~N}return Zr=i,Kl(),h}function a_(r,i){Ye=null,z.H=ko,i===oa||i===nc?(i=Sx(),_t=3):i===oh?(i=Sx(),_t=4):_t=i===Ih?8:i!==null&&typeof i=="object"&&typeof i.then=="function"?6:1,Un=i,st===null&&($t=1,gc(r,er(i,r.current)))}function o_(){var r=$n.current;return r===null?!0:(ot&4194048)===ot?sr===null:(ot&62914560)===ot||(ot&536870912)!==0?r===sr:!1}function l_(){var r=z.H;return z.H=ko,r===null?ko:r}function c_(){var r=z.A;return z.A=vE,r}function Nc(){$t=4,Cs||(ot&4194048)!==ot&&$n.current!==null||(pa=!0),(ks&134217727)===0&&(hi&134217727)===0||Et===null||Ns(Et,ot,Fn,!1)}function sf(r,i,h){var g=gt;gt|=2;var k=l_(),N=c_();(Et!==r||ot!==i)&&(Ec=null,ya(r,i)),i=!1;var M=$t;e:do try{if(_t!==0&&st!==null){var K=st,ie=Un;switch(_t){case 8:rf(),M=6;break e;case 3:case 2:case 9:case 6:$n.current===null&&(i=!0);var me=_t;if(_t=0,Un=null,_a(r,K,ie,me),h&&pa){M=0;break e}break;default:me=_t,_t=0,Un=null,_a(r,K,ie,me)}}CE(),M=$t;break}catch(Se){a_(r,Se)}while(!0);return i&&r.shellSuspendCounter++,Fr=ri=null,gt=g,z.H=k,z.A=N,st===null&&(Et=null,ot=0,Kl()),M}function CE(){for(;st!==null;)u_(st)}function kE(r,i){var h=gt;gt|=2;var g=l_(),k=c_();Et!==r||ot!==i?(Ec=null,kc=rt()+500,ya(r,i)):pa=Ys(r,i);e:do try{if(_t!==0&&st!==null){i=st;var N=Un;t:switch(_t){case 1:_t=0,Un=null,_a(r,i,N,1);break;case 2:case 9:if(bx(N)){_t=0,Un=null,d_(i);break}i=function(){_t!==2&&_t!==9||Et!==r||(_t=7),Nr(r)},N.then(i,i);break e;case 3:_t=7;break e;case 4:_t=5;break e;case 7:bx(N)?(_t=0,Un=null,d_(i)):(_t=0,Un=null,_a(r,i,N,7));break;case 5:var M=null;switch(st.tag){case 26:M=st.memoizedState;case 5:case 27:var K=st;if(M?X_(M):K.stateNode.complete){_t=0,Un=null;var ie=K.sibling;if(ie!==null)st=ie;else{var me=K.return;me!==null?(st=me,Tc(me)):st=null}break t}}_t=0,Un=null,_a(r,i,N,5);break;case 6:_t=0,Un=null,_a(r,i,N,6);break;case 8:rf(),$t=6;break e;default:throw Error(s(462))}}EE();break}catch(Se){a_(r,Se)}while(!0);return Fr=ri=null,z.H=g,z.A=k,gt=h,st!==null?0:(Et=null,ot=0,Kl(),$t)}function EE(){for(;st!==null&&!He();)u_(st)}function u_(r){var i=Oy(r.alternate,r,Zr);r.memoizedProps=r.pendingProps,i===null?Tc(r):st=i}function d_(r){var i=r,h=i.alternate;switch(i.tag){case 15:case 0:i=Ny(h,i,i.pendingProps,i.type,void 0,ot);break;case 11:i=Ny(h,i,i.pendingProps,i.type.render,i.ref,ot);break;case 5:_h(i);default:My(h,i),i=st=cx(i,Zr),i=Oy(h,i,Zr)}r.memoizedProps=r.pendingProps,i===null?Tc(r):st=i}function _a(r,i,h,g){Fr=ri=null,_h(i),la=null,xo=0;var k=i.return;try{if(mE(r,k,i,h,ot)){$t=1,gc(r,er(h,r.current)),st=null;return}}catch(N){if(k!==null)throw st=k,N;$t=1,gc(r,er(h,r.current)),st=null;return}i.flags&32768?(ct||g===1?r=!0:pa||(ot&536870912)!==0?r=!1:(Cs=r=!0,(g===2||g===9||g===3||g===6)&&(g=$n.current,g!==null&&g.tag===13&&(g.flags|=16384))),h_(i,r)):Tc(i)}function Tc(r){var i=r;do{if((i.flags&32768)!==0){h_(i,Cs);return}r=i.return;var h=xE(i.alternate,i,Zr);if(h!==null){st=h;return}if(i=i.sibling,i!==null){st=i;return}st=i=r}while(i!==null);$t===0&&($t=5)}function h_(r,i){do{var h=yE(r.alternate,r);if(h!==null){h.flags&=32767,st=h;return}if(h=r.return,h!==null&&(h.flags|=32768,h.subtreeFlags=0,h.deletions=null),!i&&(r=r.sibling,r!==null)){st=r;return}st=r=h}while(r!==null);$t=6,st=null}function f_(r,i,h,g,k,N,M,K,ie){r.cancelPendingCommit=null;do Ac();while(tn!==0);if((gt&6)!==0)throw Error(s(327));if(i!==null){if(i===r.current)throw Error(s(177));if(N=i.lanes|i.childLanes,N|=Wd,we(r,h,N,M,K,ie),r===Et&&(st=Et=null,ot=0),xa=i,js=r,es=h,ef=N,tf=k,n_=g,(i.subtreeFlags&10256)!==0||(i.flags&10256)!==0?(r.callbackNode=null,r.callbackPriority=0,AE(Be,function(){return y_(),null})):(r.callbackNode=null,r.callbackPriority=0),g=(i.flags&13878)!==0,(i.subtreeFlags&13878)!==0||g){g=z.T,z.T=null,k=J.p,J.p=2,M=gt,gt|=4;try{_E(r,i,h)}finally{gt=M,J.p=k,z.T=g}}tn=1,m_(),p_(),g_()}}function m_(){if(tn===1){tn=0;var r=js,i=xa,h=(i.flags&13878)!==0;if((i.subtreeFlags&13878)!==0||h){h=z.T,z.T=null;var g=J.p;J.p=2;var k=gt;gt|=4;try{Ky(i,r);var N=xf,M=ex(r.containerInfo),K=N.focusedElem,ie=N.selectionRange;if(M!==K&&K&&K.ownerDocument&&Zg(K.ownerDocument.documentElement,K)){if(ie!==null&&Hd(K)){var me=ie.start,Se=ie.end;if(Se===void 0&&(Se=me),"selectionStart"in K)K.selectionStart=me,K.selectionEnd=Math.min(Se,K.value.length);else{var je=K.ownerDocument||document,pe=je&&je.defaultView||window;if(pe.getSelection){var ge=pe.getSelection(),Me=K.textContent.length,Fe=Math.min(ie.start,Me),wt=ie.end===void 0?Fe:Math.min(ie.end,Me);!ge.extend&&Fe>wt&&(M=wt,wt=Fe,Fe=M);var he=Jg(K,Fe),ce=Jg(K,wt);if(he&&ce&&(ge.rangeCount!==1||ge.anchorNode!==he.node||ge.anchorOffset!==he.offset||ge.focusNode!==ce.node||ge.focusOffset!==ce.offset)){var fe=je.createRange();fe.setStart(he.node,he.offset),ge.removeAllRanges(),Fe>wt?(ge.addRange(fe),ge.extend(ce.node,ce.offset)):(fe.setEnd(ce.node,ce.offset),ge.addRange(fe))}}}}for(je=[],ge=K;ge=ge.parentNode;)ge.nodeType===1&&je.push({element:ge,left:ge.scrollLeft,top:ge.scrollTop});for(typeof K.focus=="function"&&K.focus(),K=0;K<je.length;K++){var Ce=je[K];Ce.element.scrollLeft=Ce.left,Ce.element.scrollTop=Ce.top}}Uc=!!gf,xf=gf=null}finally{gt=k,J.p=g,z.T=h}}r.current=i,tn=2}}function p_(){if(tn===2){tn=0;var r=js,i=xa,h=(i.flags&8772)!==0;if((i.subtreeFlags&8772)!==0||h){h=z.T,z.T=null;var g=J.p;J.p=2;var k=gt;gt|=4;try{Fy(r,i.alternate,i)}finally{gt=k,J.p=g,z.T=h}}tn=3}}function g_(){if(tn===4||tn===3){tn=0,et();var r=js,i=xa,h=es,g=n_;(i.subtreeFlags&10256)!==0||(i.flags&10256)!==0?tn=5:(tn=0,xa=js=null,x_(r,r.pendingLanes));var k=r.pendingLanes;if(k===0&&(Es=null),qe(h),i=i.stateNode,pt&&typeof pt.onCommitFiberRoot=="function")try{pt.onCommitFiberRoot(Ot,i,void 0,(i.current.flags&128)===128)}catch{}if(g!==null){i=z.T,k=J.p,J.p=2,z.T=null;try{for(var N=r.onRecoverableError,M=0;M<g.length;M++){var K=g[M];N(K.value,{componentStack:K.stack})}}finally{z.T=i,J.p=k}}(es&3)!==0&&Ac(),Nr(r),k=r.pendingLanes,(h&261930)!==0&&(k&42)!==0?r===nf?Oo++:(Oo=0,nf=r):Oo=0,Io(0)}}function x_(r,i){(r.pooledCacheLanes&=i)===0&&(i=r.pooledCache,i!=null&&(r.pooledCache=null,po(i)))}function Ac(){return m_(),p_(),g_(),y_()}function y_(){if(tn!==5)return!1;var r=js,i=ef;ef=0;var h=qe(es),g=z.T,k=J.p;try{J.p=32>h?32:h,z.T=null,h=tf,tf=null;var N=js,M=es;if(tn=0,xa=js=null,es=0,(gt&6)!==0)throw Error(s(331));var K=gt;if(gt|=4,Zy(N.current),Xy(N,N.current,M,h),gt=K,Io(0,!1),pt&&typeof pt.onPostCommitFiberRoot=="function")try{pt.onPostCommitFiberRoot(Ot,N)}catch{}return!0}finally{J.p=k,z.T=g,x_(r,i)}}function __(r,i,h){i=er(h,i),i=Oh(r.stateNode,i,2),r=bs(r,i,2),r!==null&&(hs(r,2),Nr(r))}function bt(r,i,h){if(r.tag===3)__(r,r,h);else for(;i!==null;){if(i.tag===3){__(i,r,h);break}else if(i.tag===1){var g=i.stateNode;if(typeof i.type.getDerivedStateFromError=="function"||typeof g.componentDidCatch=="function"&&(Es===null||!Es.has(g))){r=er(h,r),h=by(2),g=bs(i,h,2),g!==null&&(vy(h,g,i,r),hs(g,2),Nr(g));break}}i=i.return}}function af(r,i,h){var g=r.pingCache;if(g===null){g=r.pingCache=new SE;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)||(Qh=!0,k.add(h),r=jE.bind(null,r,i,h),i.then(r,r))}function jE(r,i,h){var g=r.pingCache;g!==null&&g.delete(i),r.pingedLanes|=r.suspendedLanes&h,r.warmLanes&=~h,Et===r&&(ot&h)===h&&($t===4||$t===3&&(ot&62914560)===ot&&300>rt()-Cc?(gt&2)===0&&ya(r,0):Jh|=h,ga===ot&&(ga=0)),Nr(r)}function b_(r,i){i===0&&(i=Ml()),r=ei(r,i),r!==null&&(hs(r,i),Nr(r))}function NE(r){var i=r.memoizedState,h=0;i!==null&&(h=i.retryLane),b_(r,h)}function TE(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),b_(r,h)}function AE(r,i){return re(r,i)}var Lc=null,ba=null,of=!1,Rc=!1,lf=!1,Ts=0;function Nr(r){r!==ba&&r.next===null&&(ba===null?Lc=ba=r:ba=ba.next=r),Rc=!0,of||(of=!0,RE())}function Io(r,i){if(!lf&&Rc){lf=!0;do for(var h=!1,g=Lc;g!==null;){if(r!==0){var k=g.pendingLanes;if(k===0)var N=0;else{var M=g.suspendedLanes,K=g.pingedLanes;N=(1<<31-xt(42|r)+1)-1,N&=k&~(M&~K),N=N&201326741?N&201326741|1:N?N|2:0}N!==0&&(h=!0,C_(g,N))}else N=ot,N=zi(g,g===Et?N:0,g.cancelPendingCommit!==null||g.timeoutHandle!==-1),(N&3)===0||Ys(g,N)||(h=!0,C_(g,N));g=g.next}while(h);lf=!1}}function LE(){v_()}function v_(){Rc=of=!1;var r=0;Ts!==0&&UE()&&(r=Ts);for(var i=rt(),h=null,g=Lc;g!==null;){var k=g.next,N=S_(g,i);N===0?(g.next=null,h===null?Lc=k:h.next=k,k===null&&(ba=h)):(h=g,(r!==0||(N&3)!==0)&&(Rc=!0)),g=k}tn!==0&&tn!==5||Io(r),Ts!==0&&(Ts=0)}function S_(r,i){for(var h=r.suspendedLanes,g=r.pingedLanes,k=r.expirationTimes,N=r.pendingLanes&-62914561;0<N;){var M=31-xt(N),K=1<<M,ie=k[M];ie===-1?((K&h)===0||(K&g)!==0)&&(k[M]=eo(K,i)):ie<=i&&(r.expiredLanes|=K),N&=~K}if(i=Et,h=ot,h=zi(r,r===i?h:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),g=r.callbackNode,h===0||r===i&&(_t===2||_t===9)||r.cancelPendingCommit!==null)return g!==null&&g!==null&&_e(g),r.callbackNode=null,r.callbackPriority=0;if((h&3)===0||Ys(r,h)){if(i=h&-h,i===r.callbackPriority)return i;switch(g!==null&&_e(g),qe(h)){case 2:case 8:h=Ae;break;case 32:h=Be;break;case 268435456:h=Xe;break;default:h=Be}return g=w_.bind(null,r),h=re(h,g),r.callbackPriority=i,r.callbackNode=h,i}return g!==null&&g!==null&&_e(g),r.callbackPriority=2,r.callbackNode=null,2}function w_(r,i){if(tn!==0&&tn!==5)return r.callbackNode=null,r.callbackPriority=0,null;var h=r.callbackNode;if(Ac()&&r.callbackNode!==h)return null;var g=ot;return g=zi(r,r===Et?g:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),g===0?null:(s_(r,g,i),S_(r,rt()),r.callbackNode!=null&&r.callbackNode===h?w_.bind(null,r):null)}function C_(r,i){if(Ac())return null;s_(r,i,!0)}function RE(){VE(function(){(gt&6)!==0?re(ye,LE):v_()})}function cf(){if(Ts===0){var r=ia;r===0&&(r=fr,fr<<=1,(fr&261888)===0&&(fr=256)),Ts=r}return Ts}function k_(r){return r==null||typeof r=="symbol"||typeof r=="boolean"?null:typeof r=="function"?r:$l(""+r)}function E_(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 DE(r,i,h,g,k){if(i==="submit"&&h&&h.stateNode===k){var N=k_((k[En]||null).action),M=g.submitter;M&&(i=(i=M[En]||null)?k_(i.formAction):M.getAttribute("formAction"),i!==null&&(N=i,M=null));var K=new Vl("action","action",null,g,k);r.push({event:K,listeners:[{instance:null,listener:function(){if(g.defaultPrevented){if(Ts!==0){var ie=M?E_(k,M):new FormData(k);Nh(h,{pending:!0,data:ie,method:k.method,action:N},null,ie)}}else typeof N=="function"&&(K.preventDefault(),ie=M?E_(k,M):new FormData(k),Nh(h,{pending:!0,data:ie,method:k.method,action:N},N,ie))},currentTarget:k}]})}}for(var uf=0;uf<Gd.length;uf++){var df=Gd[uf],OE=df.toLowerCase(),IE=df[0].toUpperCase()+df.slice(1);mr(OE,"on"+IE)}mr(rx,"onAnimationEnd"),mr(sx,"onAnimationIteration"),mr(ix,"onAnimationStart"),mr("dblclick","onDoubleClick"),mr("focusin","onFocus"),mr("focusout","onBlur"),mr(Qk,"onTransitionRun"),mr(Jk,"onTransitionStart"),mr(Zk,"onTransitionCancel"),mr(ax,"onTransitionEnd"),Gi("onMouseEnter",["mouseout","mouseover"]),Gi("onMouseLeave",["mouseout","mouseover"]),Gi("onPointerEnter",["pointerout","pointerover"]),Gi("onPointerLeave",["pointerout","pointerover"]),Xs("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),Xs("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),Xs("onBeforeInput",["compositionend","keypress","textInput","paste"]),Xs("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),Xs("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),Xs("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Mo="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(" "),ME=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(Mo));function j_(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 N=void 0;if(i)for(var M=g.length-1;0<=M;M--){var K=g[M],ie=K.instance,me=K.currentTarget;if(K=K.listener,ie!==N&&k.isPropagationStopped())break e;N=K,k.currentTarget=me;try{N(k)}catch(Se){ql(Se)}k.currentTarget=null,N=ie}else for(M=0;M<g.length;M++){if(K=g[M],ie=K.instance,me=K.currentTarget,K=K.listener,ie!==N&&k.isPropagationStopped())break e;N=K,k.currentTarget=me;try{N(k)}catch(Se){ql(Se)}k.currentTarget=null,N=ie}}}}function it(r,i){var h=i[wd];h===void 0&&(h=i[wd]=new Set);var g=r+"__bubble";h.has(g)||(N_(i,r,2,!1),h.add(g))}function hf(r,i,h){var g=0;i&&(g|=4),N_(h,r,g,i)}var Dc="_reactListening"+Math.random().toString(36).slice(2);function ff(r){if(!r[Dc]){r[Dc]=!0,vg.forEach(function(h){h!=="selectionchange"&&(ME.has(h)||hf(h,!1,r),hf(h,!0,r))});var i=r.nodeType===9?r:r.ownerDocument;i===null||i[Dc]||(i[Dc]=!0,hf("selectionchange",!1,i))}}function N_(r,i,h,g){switch(rb(i)){case 2:var k=u2;break;case 8:k=d2;break;default:k=Nf}h=k.bind(null,i,h,r),k=void 0,!Rd||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 mf(r,i,h,g,k){var N=g;if((i&1)===0&&(i&2)===0&&g!==null)e:for(;;){if(g===null)return;var M=g.tag;if(M===3||M===4){var K=g.stateNode.containerInfo;if(K===k)break;if(M===4)for(M=g.return;M!==null;){var ie=M.tag;if((ie===3||ie===4)&&M.stateNode.containerInfo===k)return;M=M.return}for(;K!==null;){if(M=Ui(K),M===null)return;if(ie=M.tag,ie===5||ie===6||ie===26||ie===27){g=N=M;continue e}K=K.parentNode}}g=g.return}Dg(function(){var me=N,Se=Ad(h),je=[];e:{var pe=ox.get(r);if(pe!==void 0){var ge=Vl,Me=r;switch(r){case"keypress":if(Ul(h)===0)break e;case"keydown":case"keyup":ge=Tk;break;case"focusin":Me="focus",ge=Md;break;case"focusout":Me="blur",ge=Md;break;case"beforeblur":case"afterblur":ge=Md;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":ge=Mg;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":ge=xk;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":ge=Rk;break;case rx:case sx:case ix:ge=bk;break;case ax:ge=Ok;break;case"scroll":case"scrollend":ge=pk;break;case"wheel":ge=Mk;break;case"copy":case"cut":case"paste":ge=Sk;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":ge=Bg;break;case"toggle":case"beforetoggle":ge=Bk}var Fe=(i&4)!==0,wt=!Fe&&(r==="scroll"||r==="scrollend"),he=Fe?pe!==null?pe+"Capture":null:pe;Fe=[];for(var ce=me,fe;ce!==null;){var Ce=ce;if(fe=Ce.stateNode,Ce=Ce.tag,Ce!==5&&Ce!==26&&Ce!==27||fe===null||he===null||(Ce=ro(ce,he),Ce!=null&&Fe.push(Po(ce,Ce,fe))),wt)break;ce=ce.return}0<Fe.length&&(pe=new ge(pe,Me,null,h,Se),je.push({event:pe,listeners:Fe}))}}if((i&7)===0){e:{if(pe=r==="mouseover"||r==="pointerover",ge=r==="mouseout"||r==="pointerout",pe&&h!==Td&&(Me=h.relatedTarget||h.fromElement)&&(Ui(Me)||Me[Hi]))break e;if((ge||pe)&&(pe=Se.window===Se?Se:(pe=Se.ownerDocument)?pe.defaultView||pe.parentWindow:window,ge?(Me=h.relatedTarget||h.toElement,ge=me,Me=Me?Ui(Me):null,Me!==null&&(wt=l(Me),Fe=Me.tag,Me!==wt||Fe!==5&&Fe!==27&&Fe!==6)&&(Me=null)):(ge=null,Me=me),ge!==Me)){if(Fe=Mg,Ce="onMouseLeave",he="onMouseEnter",ce="mouse",(r==="pointerout"||r==="pointerover")&&(Fe=Bg,Ce="onPointerLeave",he="onPointerEnter",ce="pointer"),wt=ge==null?pe:no(ge),fe=Me==null?pe:no(Me),pe=new Fe(Ce,ce+"leave",ge,h,Se),pe.target=wt,pe.relatedTarget=fe,Ce=null,Ui(Se)===me&&(Fe=new Fe(he,ce+"enter",Me,h,Se),Fe.target=fe,Fe.relatedTarget=wt,Ce=Fe),wt=Ce,ge&&Me)t:{for(Fe=PE,he=ge,ce=Me,fe=0,Ce=he;Ce;Ce=Fe(Ce))fe++;Ce=0;for(var ze=ce;ze;ze=Fe(ze))Ce++;for(;0<fe-Ce;)he=Fe(he),fe--;for(;0<Ce-fe;)ce=Fe(ce),Ce--;for(;fe--;){if(he===ce||ce!==null&&he===ce.alternate){Fe=he;break t}he=Fe(he),ce=Fe(ce)}Fe=null}else Fe=null;ge!==null&&T_(je,pe,ge,Fe,!1),Me!==null&&wt!==null&&T_(je,wt,Me,Fe,!0)}}e:{if(pe=me?no(me):window,ge=pe.nodeName&&pe.nodeName.toLowerCase(),ge==="select"||ge==="input"&&pe.type==="file")var ht=Wg;else if(Vg(pe))if(qg)ht=Kk;else{ht=Wk;var Pe=Gk}else ge=pe.nodeName,!ge||ge.toLowerCase()!=="input"||pe.type!=="checkbox"&&pe.type!=="radio"?me&&Nd(me.elementType)&&(ht=Wg):ht=qk;if(ht&&(ht=ht(r,me))){Gg(je,ht,h,Se);break e}Pe&&Pe(r,pe,me),r==="focusout"&&me&&pe.type==="number"&&me.memoizedProps.value!=null&&jd(pe,"number",pe.value)}switch(Pe=me?no(me):window,r){case"focusin":(Vg(Pe)||Pe.contentEditable==="true")&&(Qi=Pe,Ud=me,ho=null);break;case"focusout":ho=Ud=Qi=null;break;case"mousedown":Fd=!0;break;case"contextmenu":case"mouseup":case"dragend":Fd=!1,tx(je,h,Se);break;case"selectionchange":if(Xk)break;case"keydown":case"keyup":tx(je,h,Se)}var Qe;if(Bd)e:{switch(r){case"compositionstart":var lt="onCompositionStart";break e;case"compositionend":lt="onCompositionEnd";break e;case"compositionupdate":lt="onCompositionUpdate";break e}lt=void 0}else Xi?Ug(r,h)&&(lt="onCompositionEnd"):r==="keydown"&&h.keyCode===229&&(lt="onCompositionStart");lt&&(zg&&h.locale!=="ko"&&(Xi||lt!=="onCompositionStart"?lt==="onCompositionEnd"&&Xi&&(Qe=Og()):(fs=Se,Dd="value"in fs?fs.value:fs.textContent,Xi=!0)),Pe=Oc(me,lt),0<Pe.length&&(lt=new Pg(lt,r,null,h,Se),je.push({event:lt,listeners:Pe}),Qe?lt.data=Qe:(Qe=Fg(h),Qe!==null&&(lt.data=Qe)))),(Qe=$k?Hk(r,h):Uk(r,h))&&(lt=Oc(me,"onBeforeInput"),0<lt.length&&(Pe=new Pg("onBeforeInput","beforeinput",null,h,Se),je.push({event:Pe,listeners:lt}),Pe.data=Qe)),DE(je,r,me,h,Se)}j_(je,i)})}function Po(r,i,h){return{instance:r,listener:i,currentTarget:h}}function Oc(r,i){for(var h=i+"Capture",g=[];r!==null;){var k=r,N=k.stateNode;if(k=k.tag,k!==5&&k!==26&&k!==27||N===null||(k=ro(r,h),k!=null&&g.unshift(Po(r,k,N)),k=ro(r,i),k!=null&&g.push(Po(r,k,N))),r.tag===3)return g;r=r.return}return[]}function PE(r){if(r===null)return null;do r=r.return;while(r&&r.tag!==5&&r.tag!==27);return r||null}function T_(r,i,h,g,k){for(var N=i._reactName,M=[];h!==null&&h!==g;){var K=h,ie=K.alternate,me=K.stateNode;if(K=K.tag,ie!==null&&ie===g)break;K!==5&&K!==26&&K!==27||me===null||(ie=me,k?(me=ro(h,N),me!=null&&M.unshift(Po(h,me,ie))):k||(me=ro(h,N),me!=null&&M.push(Po(h,me,ie)))),h=h.return}M.length!==0&&r.push({event:i,listeners:M})}var BE=/\r\n?/g,zE=/\u0000|\uFFFD/g;function A_(r){return(typeof r=="string"?r:""+r).replace(BE,`
|
|
50
|
+
`).replace(zE,"")}function L_(r,i){return i=A_(i),A_(r)===i}function St(r,i,h,g,k,N){switch(h){case"children":typeof g=="string"?i==="body"||i==="textarea"&&g===""||qi(r,g):(typeof g=="number"||typeof g=="bigint")&&i!=="body"&&qi(r,""+g);break;case"className":Bl(r,"class",g);break;case"tabIndex":Bl(r,"tabindex",g);break;case"dir":case"role":case"viewBox":case"width":case"height":Bl(r,h,g);break;case"style":Lg(r,g,N);break;case"data":if(i!=="object"){Bl(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=$l(""+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 N=="function"&&(h==="formAction"?(i!=="input"&&St(r,i,"name",k.name,k,null),St(r,i,"formEncType",k.formEncType,k,null),St(r,i,"formMethod",k.formMethod,k,null),St(r,i,"formTarget",k.formTarget,k,null)):(St(r,i,"encType",k.encType,k,null),St(r,i,"method",k.method,k,null),St(r,i,"target",k.target,k,null)));if(g==null||typeof g=="symbol"||typeof g=="boolean"){r.removeAttribute(h);break}g=$l(""+g),r.setAttribute(h,g);break;case"onClick":g!=null&&(r.onclick=zr);break;case"onScroll":g!=null&&it("scroll",r);break;case"onScrollEnd":g!=null&&it("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=$l(""+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":it("beforetoggle",r),it("toggle",r),Pl(r,"popover",g);break;case"xlinkActuate":Br(r,"http://www.w3.org/1999/xlink","xlink:actuate",g);break;case"xlinkArcrole":Br(r,"http://www.w3.org/1999/xlink","xlink:arcrole",g);break;case"xlinkRole":Br(r,"http://www.w3.org/1999/xlink","xlink:role",g);break;case"xlinkShow":Br(r,"http://www.w3.org/1999/xlink","xlink:show",g);break;case"xlinkTitle":Br(r,"http://www.w3.org/1999/xlink","xlink:title",g);break;case"xlinkType":Br(r,"http://www.w3.org/1999/xlink","xlink:type",g);break;case"xmlBase":Br(r,"http://www.w3.org/XML/1998/namespace","xml:base",g);break;case"xmlLang":Br(r,"http://www.w3.org/XML/1998/namespace","xml:lang",g);break;case"xmlSpace":Br(r,"http://www.w3.org/XML/1998/namespace","xml:space",g);break;case"is":Pl(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=fk.get(h)||h,Pl(r,h,g))}}function pf(r,i,h,g,k,N){switch(h){case"style":Lg(r,g,N);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"?qi(r,g):(typeof g=="number"||typeof g=="bigint")&&qi(r,""+g);break;case"onScroll":g!=null&&it("scroll",r);break;case"onScrollEnd":g!=null&&it("scrollend",r);break;case"onClick":g!=null&&(r.onclick=zr);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Sg.hasOwnProperty(h))e:{if(h[0]==="o"&&h[1]==="n"&&(k=h.endsWith("Capture"),i=h.slice(2,k?h.length-7:void 0),N=r[En]||null,N=N!=null?N[h]:null,typeof N=="function"&&r.removeEventListener(i,N,k),typeof g=="function")){typeof N!="function"&&N!==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,""):Pl(r,h,g)}}}function pn(r,i,h){switch(i){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":it("error",r),it("load",r);var g=!1,k=!1,N;for(N in h)if(h.hasOwnProperty(N)){var M=h[N];if(M!=null)switch(N){case"src":g=!0;break;case"srcSet":k=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(s(137,i));default:St(r,i,N,M,h,null)}}k&&St(r,i,"srcSet",h.srcSet,h,null),g&&St(r,i,"src",h.src,h,null);return;case"input":it("invalid",r);var K=N=M=k=null,ie=null,me=null;for(g in h)if(h.hasOwnProperty(g)){var Se=h[g];if(Se!=null)switch(g){case"name":k=Se;break;case"type":M=Se;break;case"checked":ie=Se;break;case"defaultChecked":me=Se;break;case"value":N=Se;break;case"defaultValue":K=Se;break;case"children":case"dangerouslySetInnerHTML":if(Se!=null)throw Error(s(137,i));break;default:St(r,i,g,Se,h,null)}}jg(r,N,K,ie,me,M,k,!1);return;case"select":it("invalid",r),g=M=N=null;for(k in h)if(h.hasOwnProperty(k)&&(K=h[k],K!=null))switch(k){case"value":N=K;break;case"defaultValue":M=K;break;case"multiple":g=K;default:St(r,i,k,K,h,null)}i=N,h=M,r.multiple=!!g,i!=null?Wi(r,!!g,i,!1):h!=null&&Wi(r,!!g,h,!0);return;case"textarea":it("invalid",r),N=k=g=null;for(M in h)if(h.hasOwnProperty(M)&&(K=h[M],K!=null))switch(M){case"value":g=K;break;case"defaultValue":k=K;break;case"children":N=K;break;case"dangerouslySetInnerHTML":if(K!=null)throw Error(s(91));break;default:St(r,i,M,K,h,null)}Tg(r,g,k,N);return;case"option":for(ie in h)if(h.hasOwnProperty(ie)&&(g=h[ie],g!=null))switch(ie){case"selected":r.selected=g&&typeof g!="function"&&typeof g!="symbol";break;default:St(r,i,ie,g,h,null)}return;case"dialog":it("beforetoggle",r),it("toggle",r),it("cancel",r),it("close",r);break;case"iframe":case"object":it("load",r);break;case"video":case"audio":for(g=0;g<Mo.length;g++)it(Mo[g],r);break;case"image":it("error",r),it("load",r);break;case"details":it("toggle",r);break;case"embed":case"source":case"link":it("error",r),it("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(me in h)if(h.hasOwnProperty(me)&&(g=h[me],g!=null))switch(me){case"children":case"dangerouslySetInnerHTML":throw Error(s(137,i));default:St(r,i,me,g,h,null)}return;default:if(Nd(i)){for(Se in h)h.hasOwnProperty(Se)&&(g=h[Se],g!==void 0&&pf(r,i,Se,g,h,void 0));return}}for(K in h)h.hasOwnProperty(K)&&(g=h[K],g!=null&&St(r,i,K,g,h,null))}function $E(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,N=null,M=null,K=null,ie=null,me=null,Se=null;for(ge in h){var je=h[ge];if(h.hasOwnProperty(ge)&&je!=null)switch(ge){case"checked":break;case"value":break;case"defaultValue":ie=je;default:g.hasOwnProperty(ge)||St(r,i,ge,null,g,je)}}for(var pe in g){var ge=g[pe];if(je=h[pe],g.hasOwnProperty(pe)&&(ge!=null||je!=null))switch(pe){case"type":N=ge;break;case"name":k=ge;break;case"checked":me=ge;break;case"defaultChecked":Se=ge;break;case"value":M=ge;break;case"defaultValue":K=ge;break;case"children":case"dangerouslySetInnerHTML":if(ge!=null)throw Error(s(137,i));break;default:ge!==je&&St(r,i,pe,ge,g,je)}}Ed(r,M,K,ie,me,Se,N,k);return;case"select":ge=M=K=pe=null;for(N in h)if(ie=h[N],h.hasOwnProperty(N)&&ie!=null)switch(N){case"value":break;case"multiple":ge=ie;default:g.hasOwnProperty(N)||St(r,i,N,null,g,ie)}for(k in g)if(N=g[k],ie=h[k],g.hasOwnProperty(k)&&(N!=null||ie!=null))switch(k){case"value":pe=N;break;case"defaultValue":K=N;break;case"multiple":M=N;default:N!==ie&&St(r,i,k,N,g,ie)}i=K,h=M,g=ge,pe!=null?Wi(r,!!h,pe,!1):!!g!=!!h&&(i!=null?Wi(r,!!h,i,!0):Wi(r,!!h,h?[]:"",!1));return;case"textarea":ge=pe=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:St(r,i,K,null,g,k)}for(M in g)if(k=g[M],N=h[M],g.hasOwnProperty(M)&&(k!=null||N!=null))switch(M){case"value":pe=k;break;case"defaultValue":ge=k;break;case"children":break;case"dangerouslySetInnerHTML":if(k!=null)throw Error(s(91));break;default:k!==N&&St(r,i,M,k,g,N)}Ng(r,pe,ge);return;case"option":for(var Me in h)if(pe=h[Me],h.hasOwnProperty(Me)&&pe!=null&&!g.hasOwnProperty(Me))switch(Me){case"selected":r.selected=!1;break;default:St(r,i,Me,null,g,pe)}for(ie in g)if(pe=g[ie],ge=h[ie],g.hasOwnProperty(ie)&&pe!==ge&&(pe!=null||ge!=null))switch(ie){case"selected":r.selected=pe&&typeof pe!="function"&&typeof pe!="symbol";break;default:St(r,i,ie,pe,g,ge)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var Fe in h)pe=h[Fe],h.hasOwnProperty(Fe)&&pe!=null&&!g.hasOwnProperty(Fe)&&St(r,i,Fe,null,g,pe);for(me in g)if(pe=g[me],ge=h[me],g.hasOwnProperty(me)&&pe!==ge&&(pe!=null||ge!=null))switch(me){case"children":case"dangerouslySetInnerHTML":if(pe!=null)throw Error(s(137,i));break;default:St(r,i,me,pe,g,ge)}return;default:if(Nd(i)){for(var wt in h)pe=h[wt],h.hasOwnProperty(wt)&&pe!==void 0&&!g.hasOwnProperty(wt)&&pf(r,i,wt,void 0,g,pe);for(Se in g)pe=g[Se],ge=h[Se],!g.hasOwnProperty(Se)||pe===ge||pe===void 0&&ge===void 0||pf(r,i,Se,pe,g,ge);return}}for(var he in h)pe=h[he],h.hasOwnProperty(he)&&pe!=null&&!g.hasOwnProperty(he)&&St(r,i,he,null,g,pe);for(je in g)pe=g[je],ge=h[je],!g.hasOwnProperty(je)||pe===ge||pe==null&&ge==null||St(r,i,je,pe,g,ge)}function R_(r){switch(r){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function HE(){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],N=k.transferSize,M=k.initiatorType,K=k.duration;if(N&&K&&R_(M)){for(M=0,K=k.responseEnd,g+=1;g<h.length;g++){var ie=h[g],me=ie.startTime;if(me>K)break;var Se=ie.transferSize,je=ie.initiatorType;Se&&R_(je)&&(ie=ie.responseEnd,M+=Se*(ie<K?1:(K-me)/(ie-me)))}if(--g,i+=8*(N+M)/(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 gf=null,xf=null;function Ic(r){return r.nodeType===9?r:r.ownerDocument}function D_(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 O_(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 yf(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 _f=null;function UE(){var r=window.event;return r&&r.type==="popstate"?r===_f?!1:(_f=r,!0):(_f=null,!1)}var I_=typeof setTimeout=="function"?setTimeout:void 0,FE=typeof clearTimeout=="function"?clearTimeout:void 0,M_=typeof Promise=="function"?Promise:void 0,VE=typeof queueMicrotask=="function"?queueMicrotask:typeof M_<"u"?function(r){return M_.resolve(null).then(r).catch(GE)}:I_;function GE(r){setTimeout(function(){throw r})}function As(r){return r==="head"}function P_(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),Ca(i);return}g--}else if(h==="$"||h==="$?"||h==="$~"||h==="$!"||h==="&")g++;else if(h==="html")Bo(r.ownerDocument.documentElement);else if(h==="head"){h=r.ownerDocument.head,Bo(h);for(var N=h.firstChild;N;){var M=N.nextSibling,K=N.nodeName;N[to]||K==="SCRIPT"||K==="STYLE"||K==="LINK"&&N.rel.toLowerCase()==="stylesheet"||h.removeChild(N),N=M}}else h==="body"&&Bo(r.ownerDocument.body);h=k}while(h);Ca(i)}function B_(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 bf(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":bf(h),Cd(h);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(h.rel.toLowerCase()==="stylesheet")continue}r.removeChild(h)}}function WE(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[to])switch(i){case"meta":if(!r.hasAttribute("itemprop"))break;return r;case"link":if(N=r.getAttribute("rel"),N==="stylesheet"&&r.hasAttribute("data-precedence"))break;if(N!==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(N=r.getAttribute("src"),(N!==(k.src==null?null:k.src)||r.getAttribute("type")!==(k.type==null?null:k.type)||r.getAttribute("crossorigin")!==(k.crossOrigin==null?null:k.crossOrigin))&&N&&r.hasAttribute("async")&&!r.hasAttribute("itemprop"))break;return r;default:return r}}else if(i==="input"&&r.type==="hidden"){var N=k.name==null?null:""+k.name;if(k.type==="hidden"&&r.getAttribute("name")===N)return r}else return r;if(r=ir(r.nextSibling),r===null)break}return null}function qE(r,i,h){if(i==="")return null;for(;r.nodeType!==3;)if((r.nodeType!==1||r.nodeName!=="INPUT"||r.type!=="hidden")&&!h||(r=ir(r.nextSibling),r===null))return null;return r}function z_(r,i){for(;r.nodeType!==8;)if((r.nodeType!==1||r.nodeName!=="INPUT"||r.type!=="hidden")&&!i||(r=ir(r.nextSibling),r===null))return null;return r}function vf(r){return r.data==="$?"||r.data==="$~"}function Sf(r){return r.data==="$!"||r.data==="$?"&&r.ownerDocument.readyState!=="loading"}function KE(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 ir(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 wf=null;function $_(r){r=r.nextSibling;for(var i=0;r;){if(r.nodeType===8){var h=r.data;if(h==="/$"||h==="/&"){if(i===0)return ir(r.nextSibling);i--}else h!=="$"&&h!=="$!"&&h!=="$?"&&h!=="$~"&&h!=="&"||i++}r=r.nextSibling}return null}function H_(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 U_(r,i,h){switch(i=Ic(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 Bo(r){for(var i=r.attributes;i.length;)r.removeAttributeNode(i[0]);Cd(r)}var ar=new Map,F_=new Set;function Mc(r){return typeof r.getRootNode=="function"?r.getRootNode():r.nodeType===9?r:r.ownerDocument}var ts=J.d;J.d={f:YE,r:XE,D:QE,C:JE,L:ZE,m:e2,X:n2,S:t2,M:r2};function YE(){var r=ts.f(),i=jc();return r||i}function XE(r){var i=Fi(r);i!==null&&i.tag===5&&i.type==="form"?ay(i):ts.r(r)}var va=typeof document>"u"?null:document;function V_(r,i,h){var g=va;if(g&&typeof i=="string"&&i){var k=Jn(i);k='link[rel="'+r+'"][href="'+k+'"]',typeof h=="string"&&(k+='[crossorigin="'+h+'"]'),F_.has(k)||(F_.add(k),r={rel:r,crossOrigin:h,href:i},g.querySelector(k)===null&&(i=g.createElement("link"),pn(i,"link",r),on(i),g.head.appendChild(i)))}}function QE(r){ts.D(r),V_("dns-prefetch",r,null)}function JE(r,i){ts.C(r,i),V_("preconnect",r,i)}function ZE(r,i,h){ts.L(r,i,h);var g=va;if(g&&r&&i){var k='link[rel="preload"][as="'+Jn(i)+'"]';i==="image"&&h&&h.imageSrcSet?(k+='[imagesrcset="'+Jn(h.imageSrcSet)+'"]',typeof h.imageSizes=="string"&&(k+='[imagesizes="'+Jn(h.imageSizes)+'"]')):k+='[href="'+Jn(r)+'"]';var N=k;switch(i){case"style":N=Sa(r);break;case"script":N=wa(r)}ar.has(N)||(r=m({rel:"preload",href:i==="image"&&h&&h.imageSrcSet?void 0:r,as:i},h),ar.set(N,r),g.querySelector(k)!==null||i==="style"&&g.querySelector(zo(N))||i==="script"&&g.querySelector($o(N))||(i=g.createElement("link"),pn(i,"link",r),on(i),g.head.appendChild(i)))}}function e2(r,i){ts.m(r,i);var h=va;if(h&&r){var g=i&&typeof i.as=="string"?i.as:"script",k='link[rel="modulepreload"][as="'+Jn(g)+'"][href="'+Jn(r)+'"]',N=k;switch(g){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":N=wa(r)}if(!ar.has(N)&&(r=m({rel:"modulepreload",href:r},i),ar.set(N,r),h.querySelector(k)===null)){switch(g){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(h.querySelector($o(N)))return}g=h.createElement("link"),pn(g,"link",r),on(g),h.head.appendChild(g)}}}function t2(r,i,h){ts.S(r,i,h);var g=va;if(g&&r){var k=Vi(g).hoistableStyles,N=Sa(r);i=i||"default";var M=k.get(N);if(!M){var K={loading:0,preload:null};if(M=g.querySelector(zo(N)))K.loading=5;else{r=m({rel:"stylesheet",href:r,"data-precedence":i},h),(h=ar.get(N))&&Cf(r,h);var ie=M=g.createElement("link");on(ie),pn(ie,"link",r),ie._p=new Promise(function(me,Se){ie.onload=me,ie.onerror=Se}),ie.addEventListener("load",function(){K.loading|=1}),ie.addEventListener("error",function(){K.loading|=2}),K.loading|=4,Pc(M,i,g)}M={type:"stylesheet",instance:M,count:1,state:K},k.set(N,M)}}}function n2(r,i){ts.X(r,i);var h=va;if(h&&r){var g=Vi(h).hoistableScripts,k=wa(r),N=g.get(k);N||(N=h.querySelector($o(k)),N||(r=m({src:r,async:!0},i),(i=ar.get(k))&&kf(r,i),N=h.createElement("script"),on(N),pn(N,"link",r),h.head.appendChild(N)),N={type:"script",instance:N,count:1,state:null},g.set(k,N))}}function r2(r,i){ts.M(r,i);var h=va;if(h&&r){var g=Vi(h).hoistableScripts,k=wa(r),N=g.get(k);N||(N=h.querySelector($o(k)),N||(r=m({src:r,async:!0,type:"module"},i),(i=ar.get(k))&&kf(r,i),N=h.createElement("script"),on(N),pn(N,"link",r),h.head.appendChild(N)),N={type:"script",instance:N,count:1,state:null},g.set(k,N))}}function G_(r,i,h,g){var k=(k=ne.current)?Mc(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=Sa(h.href),h=Vi(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=Sa(h.href);var N=Vi(k).hoistableStyles,M=N.get(r);if(M||(k=k.ownerDocument||k,M={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},N.set(r,M),(N=k.querySelector(zo(r)))&&!N._p&&(M.instance=N,M.state.loading=5),ar.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},ar.set(r,h),N||s2(k,r,h,M.state))),i&&g===null)throw Error(s(528,""));return M}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=wa(h),h=Vi(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 Sa(r){return'href="'+Jn(r)+'"'}function zo(r){return'link[rel="stylesheet"]['+r+"]"}function W_(r){return m({},r,{"data-precedence":r.precedence,precedence:null})}function s2(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}),pn(i,"link",h),on(i),r.head.appendChild(i))}function wa(r){return'[src="'+Jn(r)+'"]'}function $o(r){return"script[async]"+r}function q_(r,i,h){if(i.count++,i.instance===null)switch(i.type){case"style":var g=r.querySelector('style[data-href~="'+Jn(h.href)+'"]');if(g)return i.instance=g,on(g),g;var k=m({},h,{"data-href":h.href,"data-precedence":h.precedence,href:null,precedence:null});return g=(r.ownerDocument||r).createElement("style"),on(g),pn(g,"style",k),Pc(g,h.precedence,r),i.instance=g;case"stylesheet":k=Sa(h.href);var N=r.querySelector(zo(k));if(N)return i.state.loading|=4,i.instance=N,on(N),N;g=W_(h),(k=ar.get(k))&&Cf(g,k),N=(r.ownerDocument||r).createElement("link"),on(N);var M=N;return M._p=new Promise(function(K,ie){M.onload=K,M.onerror=ie}),pn(N,"link",g),i.state.loading|=4,Pc(N,h.precedence,r),i.instance=N;case"script":return N=wa(h.src),(k=r.querySelector($o(N)))?(i.instance=k,on(k),k):(g=h,(k=ar.get(N))&&(g=m({},h),kf(g,k)),r=r.ownerDocument||r,k=r.createElement("script"),on(k),pn(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,Pc(g,h.precedence,r));return i.instance}function Pc(r,i,h){for(var g=h.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),k=g.length?g[g.length-1]:null,N=k,M=0;M<g.length;M++){var K=g[M];if(K.dataset.precedence===i)N=K;else if(N!==k)break}N?N.parentNode.insertBefore(r,N.nextSibling):(i=h.nodeType===9?h.head:h,i.insertBefore(r,i.firstChild))}function Cf(r,i){r.crossOrigin==null&&(r.crossOrigin=i.crossOrigin),r.referrerPolicy==null&&(r.referrerPolicy=i.referrerPolicy),r.title==null&&(r.title=i.title)}function kf(r,i){r.crossOrigin==null&&(r.crossOrigin=i.crossOrigin),r.referrerPolicy==null&&(r.referrerPolicy=i.referrerPolicy),r.integrity==null&&(r.integrity=i.integrity)}var Bc=null;function K_(r,i,h){if(Bc===null){var g=new Map,k=Bc=new Map;k.set(h,g)}else k=Bc,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 N=h[k];if(!(N[to]||N[yt]||r==="link"&&N.getAttribute("rel")==="stylesheet")&&N.namespaceURI!=="http://www.w3.org/2000/svg"){var M=N.getAttribute(i)||"";M=r+M;var K=g.get(M);K?K.push(N):g.set(M,[N])}}return g}function Y_(r,i,h){r=r.ownerDocument||r,r.head.insertBefore(h,i==="title"?r.querySelector("head > title"):null)}function i2(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 X_(r){return!(r.type==="stylesheet"&&(r.state.loading&3)===0)}function a2(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=Sa(g.href),N=i.querySelector(zo(k));if(N){i=N._p,i!==null&&typeof i=="object"&&typeof i.then=="function"&&(r.count++,r=zc.bind(r),i.then(r,r)),h.state.loading|=4,h.instance=N,on(N);return}N=i.ownerDocument||i,g=W_(g),(k=ar.get(k))&&Cf(g,k),N=N.createElement("link"),on(N);var M=N;M._p=new Promise(function(K,ie){M.onload=K,M.onerror=ie}),pn(N,"link",g),h.instance=N}r.stylesheets===null&&(r.stylesheets=new Map),r.stylesheets.set(h,i),(i=h.state.preload)&&(h.state.loading&3)===0&&(r.count++,h=zc.bind(r),i.addEventListener("load",h),i.addEventListener("error",h))}}var Ef=0;function o2(r,i){return r.stylesheets&&r.count===0&&Hc(r,r.stylesheets),0<r.count||0<r.imgCount?function(h){var g=setTimeout(function(){if(r.stylesheets&&Hc(r,r.stylesheets),r.unsuspend){var N=r.unsuspend;r.unsuspend=null,N()}},6e4+i);0<r.imgBytes&&Ef===0&&(Ef=62500*HE());var k=setTimeout(function(){if(r.waitingForImages=!1,r.count===0&&(r.stylesheets&&Hc(r,r.stylesheets),r.unsuspend)){var N=r.unsuspend;r.unsuspend=null,N()}},(r.imgBytes>Ef?50:800)+i);return r.unsuspend=h,function(){r.unsuspend=null,clearTimeout(g),clearTimeout(k)}}:null}function zc(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Hc(this,this.stylesheets);else if(this.unsuspend){var r=this.unsuspend;this.unsuspend=null,r()}}}var $c=null;function Hc(r,i){r.stylesheets=null,r.unsuspend!==null&&(r.count++,$c=new Map,i.forEach(l2,r),$c=null,zc.call(r))}function l2(r,i){if(!(i.state.loading&4)){var h=$c.get(r);if(h)var g=h.get(null);else{h=new Map,$c.set(r,h);for(var k=r.querySelectorAll("link[data-precedence],style[data-precedence]"),N=0;N<k.length;N++){var M=k[N];(M.nodeName==="LINK"||M.getAttribute("media")!=="not all")&&(h.set(M.dataset.precedence,M),g=M)}g&&h.set(null,g)}k=i.instance,M=k.getAttribute("data-precedence"),N=h.get(M)||g,N===g&&h.set(null,k),h.set(M,k),this.count++,g=zc.bind(this),k.addEventListener("load",g),k.addEventListener("error",g),N?N.parentNode.insertBefore(k,N.nextSibling):(r=r.nodeType===9?r.head:r,r.insertBefore(k,r.firstChild)),i.state.loading|=4}}var Ho={$$typeof:_,Provider:null,Consumer:null,_currentValue:Z,_currentValue2:Z,_threadCount:0};function c2(r,i,h,g,k,N,M,K,ie){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=$i(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=$i(0),this.hiddenUpdates=$i(null),this.identifierPrefix=g,this.onUncaughtError=k,this.onCaughtError=N,this.onRecoverableError=M,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=ie,this.incompleteTransitions=new Map}function Q_(r,i,h,g,k,N,M,K,ie,me,Se,je){return r=new c2(r,i,h,M,ie,me,Se,je,K),i=1,N===!0&&(i|=24),N=zn(3,null,null,i),r.current=N,N.stateNode=r,i=sh(),i.refCount++,r.pooledCache=i,i.refCount++,N.memoizedState={element:g,isDehydrated:h,cache:i},lh(N),r}function J_(r){return r?(r=ea,r):ea}function Z_(r,i,h,g,k,N){k=J_(k),g.context===null?g.context=k:g.pendingContext=k,g=_s(i),g.payload={element:h},N=N===void 0?null:N,N!==null&&(g.callback=N),h=bs(r,g,i),h!==null&&(Rn(h,r,i),_o(h,r,i))}function eb(r,i){if(r=r.memoizedState,r!==null&&r.dehydrated!==null){var h=r.retryLane;r.retryLane=h!==0&&h<i?h:i}}function jf(r,i){eb(r,i),(r=r.alternate)&&eb(r,i)}function tb(r){if(r.tag===13||r.tag===31){var i=ei(r,67108864);i!==null&&Rn(i,r,67108864),jf(r,67108864)}}function nb(r){if(r.tag===13||r.tag===31){var i=Vn();i=tt(i);var h=ei(r,i);h!==null&&Rn(h,r,i),jf(r,i)}}var Uc=!0;function u2(r,i,h,g){var k=z.T;z.T=null;var N=J.p;try{J.p=2,Nf(r,i,h,g)}finally{J.p=N,z.T=k}}function d2(r,i,h,g){var k=z.T;z.T=null;var N=J.p;try{J.p=8,Nf(r,i,h,g)}finally{J.p=N,z.T=k}}function Nf(r,i,h,g){if(Uc){var k=Tf(g);if(k===null)mf(r,i,g,Fc,h),sb(r,g);else if(f2(k,r,i,h,g))g.stopPropagation();else if(sb(r,g),i&4&&-1<h2.indexOf(r)){for(;k!==null;){var N=Fi(k);if(N!==null)switch(N.tag){case 3:if(N=N.stateNode,N.current.memoizedState.isDehydrated){var M=Cr(N.pendingLanes);if(M!==0){var K=N;for(K.pendingLanes|=2,K.entangledLanes|=2;M;){var ie=1<<31-xt(M);K.entanglements[1]|=ie,M&=~ie}Nr(N),(gt&6)===0&&(kc=rt()+500,Io(0))}}break;case 31:case 13:K=ei(N,2),K!==null&&Rn(K,N,2),jc(),jf(N,2)}if(N=Tf(g),N===null&&mf(r,i,g,Fc,h),N===k)break;k=N}k!==null&&g.stopPropagation()}else mf(r,i,g,null,h)}}function Tf(r){return r=Ad(r),Af(r)}var Fc=null;function Af(r){if(Fc=null,r=Ui(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 Fc=r,null}function rb(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(kt()){case ye:return 2;case Ae:return 8;case Be:case Ge:return 32;case Xe:return 268435456;default:return 32}default:return 32}}var Lf=!1,Ls=null,Rs=null,Ds=null,Uo=new Map,Fo=new Map,Os=[],h2="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 sb(r,i){switch(r){case"focusin":case"focusout":Ls=null;break;case"dragenter":case"dragleave":Rs=null;break;case"mouseover":case"mouseout":Ds=null;break;case"pointerover":case"pointerout":Uo.delete(i.pointerId);break;case"gotpointercapture":case"lostpointercapture":Fo.delete(i.pointerId)}}function Vo(r,i,h,g,k,N){return r===null||r.nativeEvent!==N?(r={blockedOn:i,domEventName:h,eventSystemFlags:g,nativeEvent:N,targetContainers:[k]},i!==null&&(i=Fi(i),i!==null&&tb(i)),r):(r.eventSystemFlags|=g,i=r.targetContainers,k!==null&&i.indexOf(k)===-1&&i.push(k),r)}function f2(r,i,h,g,k){switch(i){case"focusin":return Ls=Vo(Ls,r,i,h,g,k),!0;case"dragenter":return Rs=Vo(Rs,r,i,h,g,k),!0;case"mouseover":return Ds=Vo(Ds,r,i,h,g,k),!0;case"pointerover":var N=k.pointerId;return Uo.set(N,Vo(Uo.get(N)||null,r,i,h,g,k)),!0;case"gotpointercapture":return N=k.pointerId,Fo.set(N,Vo(Fo.get(N)||null,r,i,h,g,k)),!0}return!1}function ib(r){var i=Ui(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,dn(r.priority,function(){nb(h)});return}}else if(i===31){if(i=c(h),i!==null){r.blockedOn=i,dn(r.priority,function(){nb(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 Vc(r){if(r.blockedOn!==null)return!1;for(var i=r.targetContainers;0<i.length;){var h=Tf(r.nativeEvent);if(h===null){h=r.nativeEvent;var g=new h.constructor(h.type,h);Td=g,h.target.dispatchEvent(g),Td=null}else return i=Fi(h),i!==null&&tb(i),r.blockedOn=h,!1;i.shift()}return!0}function ab(r,i,h){Vc(r)&&h.delete(i)}function m2(){Lf=!1,Ls!==null&&Vc(Ls)&&(Ls=null),Rs!==null&&Vc(Rs)&&(Rs=null),Ds!==null&&Vc(Ds)&&(Ds=null),Uo.forEach(ab),Fo.forEach(ab)}function Gc(r,i){r.blockedOn===i&&(r.blockedOn=null,Lf||(Lf=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,m2)))}var Wc=null;function ob(r){Wc!==r&&(Wc=r,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){Wc===r&&(Wc=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(Af(g||h)===null)continue;break}var N=Fi(h);N!==null&&(r.splice(i,3),i-=3,Nh(N,{pending:!0,data:k,method:h.method,action:g},g,k))}}))}function Ca(r){function i(ie){return Gc(ie,r)}Ls!==null&&Gc(Ls,r),Rs!==null&&Gc(Rs,r),Ds!==null&&Gc(Ds,r),Uo.forEach(i),Fo.forEach(i);for(var h=0;h<Os.length;h++){var g=Os[h];g.blockedOn===r&&(g.blockedOn=null)}for(;0<Os.length&&(h=Os[0],h.blockedOn===null);)ib(h),h.blockedOn===null&&Os.shift();if(h=(r.ownerDocument||r).$$reactFormReplay,h!=null)for(g=0;g<h.length;g+=3){var k=h[g],N=h[g+1],M=k[En]||null;if(typeof N=="function")M||ob(h);else if(M){var K=null;if(N&&N.hasAttribute("formAction")){if(k=N,M=N[En]||null)K=M.formAction;else if(Af(k)!==null)continue}else K=M.action;typeof K=="function"?h[g+1]=K:(h.splice(g,3),g-=3),ob(h)}}}function lb(){function r(N){N.canIntercept&&N.info==="react-transition"&&N.intercept({handler:function(){return new Promise(function(M){return k=M})},focusReset:"manual",scroll:"manual"})}function i(){k!==null&&(k(),k=null),g||setTimeout(h,20)}function h(){if(!g&&!navigation.transition){var N=navigation.currentEntry;N&&N.url!=null&&navigation.navigate(N.url,{state:N.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 Rf(r){this._internalRoot=r}qc.prototype.render=Rf.prototype.render=function(r){var i=this._internalRoot;if(i===null)throw Error(s(409));var h=i.current,g=Vn();Z_(h,g,r,i,null,null)},qc.prototype.unmount=Rf.prototype.unmount=function(){var r=this._internalRoot;if(r!==null){this._internalRoot=null;var i=r.containerInfo;Z_(r.current,2,null,r,null,null),jc(),i[Hi]=null}};function qc(r){this._internalRoot=r}qc.prototype.unstable_scheduleHydration=function(r){if(r){var i=dt();r={blockedOn:null,target:r,priority:i};for(var h=0;h<Os.length&&i!==0&&i<Os[h].priority;h++);Os.splice(h,0,r),h===0&&ib(r)}};var cb=t.version;if(cb!=="19.2.4")throw Error(s(527,cb,"19.2.4"));J.findDOMNode=function(r){var i=r._reactInternals;if(i===void 0)throw typeof r.render=="function"?Error(s(188)):(r=Object.keys(r).join(","),Error(s(268,r)));return r=f(i),r=r!==null?p(r):null,r=r===null?null:r.stateNode,r};var p2={bundleType:0,version:"19.2.4",rendererPackageName:"react-dom",currentDispatcherRef:z,reconcilerVersion:"19.2.4"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Kc=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Kc.isDisabled&&Kc.supportsFiber)try{Ot=Kc.inject(p2),pt=Kc}catch{}}return Wo.createRoot=function(r,i){if(!a(r))throw Error(s(299));var h=!1,g="",k=gy,N=xy,M=yy;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&&(N=i.onCaughtError),i.onRecoverableError!==void 0&&(M=i.onRecoverableError)),i=Q_(r,1,!1,null,null,h,g,null,k,N,M,lb),r[Hi]=i.current,ff(r),new Rf(i)},Wo.hydrateRoot=function(r,i,h){if(!a(r))throw Error(s(299));var g=!1,k="",N=gy,M=xy,K=yy,ie=null;return h!=null&&(h.unstable_strictMode===!0&&(g=!0),h.identifierPrefix!==void 0&&(k=h.identifierPrefix),h.onUncaughtError!==void 0&&(N=h.onUncaughtError),h.onCaughtError!==void 0&&(M=h.onCaughtError),h.onRecoverableError!==void 0&&(K=h.onRecoverableError),h.formState!==void 0&&(ie=h.formState)),i=Q_(r,1,!0,i,h??null,g,k,ie,N,M,K,lb),i.context=J_(null),h=i.current,g=Vn(),g=tt(g),k=_s(g),k.callback=null,bs(h,k,g),h=g,i.current.lanes=h,hs(i,h),Nr(i),r[Hi]=i.current,ff(r),new qc(i)},Wo.version="19.2.4",Wo}var vb;function A2(){if(vb)return Pf.exports;vb=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(),Pf.exports=T2(),Pf.exports}var L2=A2();const R2=Gu(L2),Sb=e=>{let t;const n=new Set,s=(f,p)=>{const m=typeof f=="function"?f(t):f;if(!Object.is(m,t)){const x=t;t=p??(typeof m!="object"||m===null)?m:Object.assign({},t,m),n.forEach(y=>y(t,x))}},a=()=>t,c={setState:s,getState:a,getInitialState:()=>d,subscribe:f=>(n.add(f),()=>n.delete(f))},d=t=e(s,a,c);return c},D2=(e=>e?Sb(e):Sb),O2=e=>e;function I2(e,t=O2){const n=Hs.useSyncExternalStore(e.subscribe,Hs.useCallback(()=>t(e.getState()),[e,t]),Hs.useCallback(()=>t(e.getInitialState()),[e,t]));return Hs.useDebugValue(n),n}const wb=e=>{const t=D2(e),n=s=>I2(t,s);return Object.assign(n,t),n},Xn=(e=>e?wb(e):wb);async function Te(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 M2(e,t){try{return(await Te(`/api/sessions/${e}/replay`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messageId:t})})).ok}catch{return!1}}const Oe={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",DISPLAY_MAX_VISIBLE_ITEMS:"display.maxVisibleItems",LLM_DYNAMIC_SYSTEM_PROMPT:"llm.dynamicSystemPrompt",CACHE_WARMING:"cache.warming",KEYBINDINGS:"keybindings",RETRY_PATTERNS:"agent.retryPatterns",SKILLS_DIRECTORIES:"skills.directories",SEARCH_ENGINE:"search.engine",SEARCH_TAVILY_API_KEY:"search.tavilyApiKey",SEARCH_SEARXNG_URL:"search.searxngUrl",SEARCH_SEARXNG_API_KEY:"search.searxngApiKey"};function Yc(e,t){return n=>({loading:{...n.loading,[e]:t}})}function Cb(e,t){return n=>({settings:{...n.settings,[e]:t},loading:{...n.loading,[e]:!1}})}const bp=[Oe.DISPLAY_SHOW_THINKING,Oe.DISPLAY_SHOW_VERBOSE_TOOL_OUTPUT,Oe.DISPLAY_SHOW_STATS,Oe.DISPLAY_SHOW_AGENT_DEFINITIONS,Oe.DISPLAY_SHOW_WORKFLOW_BARS,Oe.DISPLAY_SHOW_SYNTAX_HIGHLIGHTING,Oe.DISPLAY_FOLLOW_SYSTEM_THEME,Oe.DISPLAY_SHOW_OPEN_IN_EDITOR,Oe.DISPLAY_MAX_VISIBLE_ITEMS];function Ri(){return{showThinking:qt(e=>e.settings[Oe.DISPLAY_SHOW_THINKING]??"true")==="true",showVerboseToolOutput:qt(e=>e.settings[Oe.DISPLAY_SHOW_VERBOSE_TOOL_OUTPUT]??"true")==="true",showStats:qt(e=>e.settings[Oe.DISPLAY_SHOW_STATS]??"true")==="true",showAgentDefinitions:qt(e=>e.settings[Oe.DISPLAY_SHOW_AGENT_DEFINITIONS]??"true")==="true",showWorkflowBars:qt(e=>e.settings[Oe.DISPLAY_SHOW_WORKFLOW_BARS]??"true")==="true",showSyntaxHighlighting:qt(e=>e.settings[Oe.DISPLAY_SHOW_SYNTAX_HIGHLIGHTING]??"true")==="true",maxVisibleItems:Number(qt(e=>e.settings[Oe.DISPLAY_MAX_VISIBLE_ITEMS]??"300"))}}const qt=Xn(e=>({settings:{},loading:{},getSetting:async t=>{e(Yc(t,!0));try{const s=await(await Te(`/api/settings/${t}`)).json();return e(Cb(t,s.value??"")),s.value}catch{return e(Yc(t,!1)),null}},getSettings:async t=>{if(t.length!==0)try{const s=await(await Te(`/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(Yc(t,!0));try{const a=await(await Te(`/api/settings/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:n})})).json();e(Cb(t,a.value??""))}catch{e(Yc(t,!1))}}})),Hf=Object.freeze(Object.defineProperty({__proto__:null,DISPLAY_SETTINGS_KEYS:bp,SETTINGS_KEYS:Oe,useDisplaySettings:Ri,useSettingsStore:qt},Symbol.toStringTag,{value:"Module"}));function P2(){const[e,t]=L.useState({offsetTop:0,height:window.innerHeight,keyboardVisible:!1}),n=L.useRef(window.innerHeight);return L.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 B2(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 Uf={exports:{}},Ff={};/**
|
|
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 kb;function z2(){if(kb)return Ff;kb=1;var e=Wu();function t(m,x){return m===x&&(m!==0||1/m===1/x)||m!==m&&x!==x}var n=typeof Object.is=="function"?Object.is:t,s=e.useState,a=e.useEffect,l=e.useLayoutEffect,u=e.useDebugValue;function c(m,x){var y=x(),w=s({inst:{value:y,getSnapshot:x}}),C=w[0].inst,b=w[1];return l(function(){C.value=y,C.getSnapshot=x,d(C)&&b({inst:C})},[m,y,x]),a(function(){return d(C)&&b({inst:C}),m(function(){d(C)&&b({inst:C})})},[m]),u(y),y}function d(m){var x=m.getSnapshot;m=m.value;try{var y=x();return!n(m,y)}catch{return!0}}function f(m,x){return x()}var p=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?f:c;return Ff.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:p,Ff}var Eb;function $2(){return Eb||(Eb=1,Uf.exports=z2()),Uf.exports}var H2=$2();const U2=k2.useInsertionEffect,F2=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",V2=F2?L.useLayoutEffect:L.useEffect,G2=U2||V2,hS=e=>{const t=L.useRef([e,(...n)=>t[0](...n)]).current;return G2(()=>{t[0]=e}),t[1]},W2="popstate",vp="pushState",Sp="replaceState",q2="hashchange",jb=[W2,vp,Sp,q2],K2=e=>{for(const t of jb)addEventListener(t,e);return()=>{for(const t of jb)removeEventListener(t,e)}},fS=(e,t)=>H2.useSyncExternalStore(K2,e,t),Nb=()=>location.search,Y2=({ssrSearch:e}={})=>fS(Nb,e!=null?()=>e:Nb),Tb=()=>location.pathname,X2=({ssrPath:e}={})=>fS(Tb,e!=null?()=>e:Tb),Q2=(e,{replace:t=!1,state:n=null}={})=>history[t?Sp:vp](n,"",e),J2=(e={})=>[X2(e),Q2],Ab=Symbol.for("wouter_v3");if(typeof history<"u"&&typeof window[Ab]>"u"){for(const e of[vp,Sp]){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,Ab,{value:!0})}const Z2=(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())?"~"+t:t.slice(e.length)||"/",mS=(e="")=>e==="/"?"":e,ej=(e,t)=>e[0]==="~"?e.slice(1):mS(t)+e,tj=(e="",t)=>Z2(Lb(mS(e)),Lb(t)),Lb=e=>{try{return decodeURI(e)}catch{return e}},pS={hook:J2,searchHook:Y2,parser:B2,base:"",ssrPath:void 0,ssrSearch:void 0,ssrContext:void 0,hrefs:e=>e,aroundNav:(e,t,n)=>e(t,n)},gS=L.createContext(pS),Va=()=>L.useContext(gS),xS={},yS=L.createContext(xS),nj=()=>L.useContext(yS),qu=e=>{const[t,n]=e.hook(e);return[tj(e.base,t),hS((s,a)=>e.aroundNav(n,ej(s,e.base),a))]},Yn=()=>qu(Va()),wp=(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((m,x)=>[m,d[x]])):u.groups;let p={...d};return f&&Object.assign(p,f),p})(),...s?[c]:[]]:[!1,null]},Ga=e=>wp(Va().parser,e,Yn()[0]),rj=({children:e,...t})=>{var p,m,x;const n=Va(),s=t.hook?pS:n;let a=s;const[l,u=t.ssrSearch??""]=((p=t.ssrPath)==null?void 0:p.split("?"))??[];l&&(t.ssrSearch=u,t.ssrPath=l),t.hrefs=t.hrefs??((m=t.hook)==null?void 0:m.hrefs),t.searchHook=t.searchHook??((x=t.hook)==null?void 0:x.searchHook);let c=L.useRef({}),d=c.current,f=d;for(let y in s){const w=y==="base"?s[y]+(t[y]??""):t[y]??s[y];d===f&&w!==f[y]&&(c.current=f={...f}),f[y]=w,(w!==s[y]||w!==a[y])&&(a=f)}return L.createElement(gS.Provider,{value:a,children:e})},Rb=({children:e,component:t},n)=>t?L.createElement(t,{params:n}):typeof e=="function"?e(n):e,sj=e=>{let t=L.useRef(xS);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},qo=({path:e,nest:t,match:n,...s})=>{const a=Va(),[l]=qu(a),[u,c,d]=n??wp(a.parser,e,l,t),f=sj({...nj(),...c});if(!u)return null;const p=d?L.createElement(rj,{base:d},Rb(s,f)):Rb(s,f);return L.createElement(yS.Provider,{value:f,children:p})},qn=L.forwardRef((e,t)=>{const n=Va(),[s,a]=qu(n),{to:l="",href:u=l,onClick:c,asChild:d,children:f,className:p,replace:m,state:x,transition:y,...w}=e,C=hS(S=>{S.ctrlKey||S.metaKey||S.altKey||S.shiftKey||S.button!==0||(c==null||c(S),S.defaultPrevented||(S.preventDefault(),a(u,e)))}),b=n.hrefs(u[0]==="~"?u.slice(1):n.base+u,n);return d&&L.isValidElement(f)?L.cloneElement(f,{onClick:C,href:b}):L.createElement("a",{...w,onClick:C,href:b,className:p!=null&&p.call?p(s===u):p,children:f,ref:t})}),_S=e=>Array.isArray(e)?e.flatMap(t=>_S(t&&t.type===L.Fragment?t.props.children:t)):[e],ij=({children:e,location:t})=>{const n=Va(),[s]=qu(n);for(const a of _S(e)){let l=0;if(L.isValidElement(a)&&(l=wp(n.parser,a.props.path,t||s,a.props.nest))[0])return L.cloneElement(a,{match:l})}return null};function aj(e){return typeof e=="object"&&e!==null&&"type"in e&&"payload"in e}function bS(){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 oj{constructor(t){be(this,"ws",null);be(this,"handlers",new Set);be(this,"statusHandler",null);be(this,"baseUrl");be(this,"isReconnecting",!1);be(this,"connectingPromise",null);be(this,"lastCloseCode",0);be(this,"reconnectAttempts",0);be(this,"manualReconnectScheduled",!1);be(this,"pwaRecoveryAttempted",!1);this.baseUrl=t}getUrl(){const t=localStorage.getItem("openfox_token");if(t){const n=this.baseUrl.includes("?")?"&":"?";return`${this.baseUrl}${n}token=${encodeURIComponent(t)}`}return this.baseUrl}setToken(t){localStorage.setItem("openfox_token",t)}clearToken(){localStorage.removeItem("openfox_token")}hasToken(){return!!localStorage.getItem("openfox_token")}getLastCloseCode(){return this.lastCloseCode}onStatusChange(t){this.statusHandler=t}connect(){var t,n,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.reconnectAttempts=0,this.connectingPromise=null,(d=this.statusHandler)==null||d.call(this,"connected"),a()},this.ws.onclose=d=>{var f,p,m;clearTimeout(c),this.lastCloseCode=d.code,((f=this.ws)==null?void 0:f.readyState)===WebSocket.CONNECTING?(this.connectingPromise=null,(p=this.statusHandler)==null||p.call(this,"disconnected"),l(new Error(`Connection closed: ${d.code}`))):(this.connectingPromise=null,(m=this.statusHandler)==null||m.call(this,"disconnected"),this.attemptReconnect())},this.ws.onerror=d=>{clearTimeout(c),console.error("WebSocket error:",d),this.connectingPromise=null,l(d)},this.ws.onmessage=d=>{try{const f=JSON.parse(d.data);aj(f)&&this.handlers.forEach(p=>p(f))}catch(f){console.error("Failed to parse WebSocket message:",f)}}}catch(u){this.connectingPromise=null,l(u)}}),this.connectingPromise)))}async recoverPwaStuckConnection(){if(this.pwaRecoveryAttempted||!window.matchMedia("(display-mode: standalone)").matches||!("serviceWorker"in navigator))return;this.pwaRecoveryAttempted=!0;const n=await navigator.serviceWorker.getRegistrations();n.length!==0&&(console.warn("[WS] PWA mode detected with stale service worker — unregistering and reloading"),await Promise.all(n.map(s=>s.unregister())),window.location.reload())}attemptReconnect(){var s;if(this.lastCloseCode===4e3&&this.hasToken()){console.warn("[WS] Auth failure or initial failure with token - not auto-reconnecting, awaiting user action");return}if(this.isReconnecting||this.manualReconnectScheduled)return;this.isReconnecting=!0,(s=this.statusHandler)==null||s.call(this,"reconnecting");const n=Math.min(1e3*Math.pow(2,this.reconnectAttempts||0),3e4);this.reconnectAttempts=(this.reconnectAttempts||0)+1,setTimeout(()=>{this.isReconnecting=!1,this.manualReconnectScheduled=!1,this.connect().catch(()=>{this.reconnectAttempts>=3&&this.recoverPwaStuckConnection()})},n)}reconnect(){this.manualReconnectScheduled=!0,this.isReconnecting=!1,this.lastCloseCode=0,this.connectingPromise=null,this.connect().catch(()=>{this.recoverPwaStuckConnection()})}disconnect(){this.isReconnecting=!1,this.reconnectAttempts=0,this.ws&&(this.ws.close(),this.ws=null)}resetReconnectAttempts(){this.reconnectAttempts=0}send(t,n){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)throw new Error("WebSocket not connected");const s=bS(),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 lj=window.location.protocol==="https:"?"wss:":"ws:";let Pm=window.location.port;Pm||(Pm=window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"?"10469":window.location.protocol==="https:"?"443":"80");const cj=`${lj}//${window.location.hostname}:${Pm}/ws`,Ut=new oj(cj),uj=3e4;function vS(e){switch(e){case"vllm":return"vLLM";case"sglang":return"SGLang";case"ollama":return"Ollama";case"llamacpp":return"llama.cpp";case"lmstudio":return"LM Studio";case"openai":return"OpenAI";case"anthropic":return"Anthropic";case"opencode-go":return"OpenCode Go";case"unknown":return"Other"}}const nn=Xn((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 Te("/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 Te("/api/model/refresh",{method:"POST"});if(!n.ok)throw new Error("Failed to refresh model");const s=await n.json();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 Te(`/api/providers/${n}/activate`,{method:"POST"});if(!l.ok){const c=await l.json();throw new Error(c.error??"Failed to activate provider")}const u=await l.json();return e({activeProviderId:u.activeProviderId,model:u.model,backend:u.backend,providers:a.map(c=>({...c,isActive:c.id===u.activeProviderId})),activating:!1}),!0}catch(l){return e({error:l instanceof Error?l.message:"Failed to switch provider",activating:!1}),!1}},setDefaultModel:async(n,s)=>{const{providers:a}=t();try{const l=await Te("/api/default-model",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerId:n,model:s})});if(!l.ok)return!1;const u=await l.json();return e({activeProviderId:n,model:s,defaultModelSelection:u.defaultModelSelection,providers:a.map(c=>({...c,isActive:c.id===n}))}),!0}catch{return!1}},refreshProviderModels:async n=>{e({activating:!0,error:null});try{const s=await Te(`/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()},uj);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=Xn((e,t)=>({projects:[],currentProject:null,loading:!1,listProjects:async()=>{e({loading:!0});try{const s=await(await Te("/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 Te("/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 Te(`/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 Te(`/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 Te(`/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 Te(`/api/projects/${n}/star`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isStarred:s})});if(!l.ok)return!1;if(((a=t().currentProject)==null?void 0:a.id)===n){const u=await l.json();e({currentProject:u.project})}return await t().listProjects(),!0}catch{return!1}},clearProject:()=>{e({currentProject:null})}})),Ws=async(e,t,n)=>{try{const s=await Te(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"}}},Ku=async(e,t,n)=>{try{const s=await Te(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 SS(e){let t=null;function n(){t===null&&(t=requestAnimationFrame(()=>{t=null,e()}))}return n}let Xc=[];const ll=Xn()((e,t)=>{function n(){if(Xc.length===0)return;const a=Xc;Xc=[],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=SS(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 Te(`/api/sessions/${l}/background-process/${a}/stop`,{method:"POST"})).ok&&t().removeProcess(a)}catch{}},appendLog:(a,l,u)=>{Xc.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(p=>({processes:[...p.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}}}}}),dj={messageId:null,deltaContent:"",thinkingContent:"",toolOutput:[]};let yu=null;function hj(e){yu=e}function bi(){return dj}function Vf(){yu==null||yu()}let Qc=[];const Dr=Xn()((e,t)=>{function n(){if(Qc.length===0)return;const a=Qc;Qc=[],e(l=>({logs:[...l.logs,...a]}))}const s=SS(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 Te(`/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 Te(`/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 Te(`/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 Te(`/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 Te(`/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 Te(`/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 Te(`/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;Qc.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}}}}}),fj=[{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"}],mj=[{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"}],wS={complete:"/sounds/notification.mp3",waiting_for_user:"/sounds/waiting-for-user.mp3",phase_done:"/sounds/achievement.mp3",phase_blocked:"/sounds/intervention.mp3",new_message:"/sounds/typing.mp3"},Us={soundEnabled:!0,browserNotification:!1,customSoundUrl:null},CS={soundEnabled:!1,browserNotification:!1,customSoundUrl:null},Bm={soundEnabled:!0,browserNotificationEnabled:!1,events:{complete:{...Us},waiting_for_user:{...Us},phase_done:{...Us},phase_blocked:{...Us},new_message:{...CS}},agentOverrides:{}};function kS(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 Si=Xn((e,t)=>({settings:Bm,loaded:!1,load:()=>{qt.getState().getSetting(Oe.NOTIFICATION_SETTINGS);const s=qt.subscribe(l=>{const u=l.settings[Oe.NOTIFICATION_SETTINGS];if(u!==void 0)try{const c=JSON.parse(u);e({settings:Db(c),loaded:!0})}catch{e({loaded:!0})}}),a=qt.getState().settings[Oe.NOTIFICATION_SETTINGS];if(a)try{const l=JSON.parse(a);e({settings:Db(l),loaded:!0})}catch{e({loaded:!0})}return s},update:n=>{e({settings:n}),Gf(n)},updateEvent:(n,s)=>{const a=t().settings,l={...a,events:{...a.events,[n]:{...a.events[n],...s}}};e({settings:l}),Gf(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}),Gf(c)}}));function Gf(e){qt.getState().setSetting(Oe.NOTIFICATION_SETTINGS,JSON.stringify(e))}function Db(e){var t,n,s,a,l;return{soundEnabled:e.soundEnabled??Bm.soundEnabled,browserNotificationEnabled:e.browserNotificationEnabled??Bm.browserNotificationEnabled,events:{complete:{...Us,...(t=e.events)==null?void 0:t.complete},waiting_for_user:{...Us,...(n=e.events)==null?void 0:n.waiting_for_user},phase_done:{...Us,...(s=e.events)==null?void 0:s.phase_done},phase_blocked:{...Us,...(a=e.events)==null?void 0:a.phase_blocked},new_message:{...CS,...(l=e.events)==null?void 0:l.new_message}},agentOverrides:e.agentOverrides??{}}}const Ob=new Map;function pj(e){let t=Ob.get(e);return t||(t=new Audio(e),t.volume=.5,Ob.set(e,t)),t}let ES=typeof Notification<"u"?Notification.permission:"denied";function gj(){return typeof Notification>"u"?Promise.resolve("denied"):Notification.requestPermission().then(e=>(ES=e,e))}const xj={complete:"Task Complete",waiting_for_user:"Waiting for Input",phase_done:"Phase Complete",phase_blocked:"Phase Blocked",new_message:"New Message"},yj={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 _j(e){typeof Notification>"u"||ES==="granted"&&(document.hasFocus()||new Notification(xj[e],{body:yj[e],icon:"/fox.svg",tag:`openfox-${e}`}))}function kl(e,t){const{settings:n}=Si.getState(),s=kS(n,e,t);if(n.soundEnabled&&s.soundEnabled){const a=s.customSoundUrl??wS[e],l=pj(a);l.currentTime=0,l.play().catch(()=>{})}n.browserNotificationEnabled&&s.browserNotification&&_j(e)}const bj=e=>kl("complete",e),vj=e=>kl("phase_done",e),Sj=e=>kl("phase_blocked",e),Ib=e=>kl("waiting_for_user",e),wj=e=>kl("new_message",e),Mb=new Map;function il(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 Cj(e,t){if(e.type==="chat.done"){const n=e.payload,s=il(t,e.sessionId),a=n.agentType??s;n.reason==="complete"&&bj(a),n.reason==="waiting_for_user"&&Ib(a);return}if(e.type==="chat.path_confirmation"){const n=il(t,e.sessionId);Ib(n);return}if(e.type==="task.completed"){const n=il(t,e.sessionId);vj(n);return}if(e.type==="phase.changed"&&e.sessionId){const n=e.payload,s=Mb.get(e.sessionId)??null;if(Mb.set(e.sessionId,n.phase),s===n.phase)return;const a=il(t,e.sessionId);n.phase==="blocked"&&Sj(a)}}const Wf=new Set;function Gt(e,t){return t!==null&&e.sessionId===t}function kj(e,t,n){return e.id!==void 0||Gt(e,t)||n===!0&&e.sessionId!==void 0}function Ej(e,t){return e.includes(t)?e:[...e,t]}function Pb(e,t){return e.filter(n=>n!==t)}function jj(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 Nj(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 Bb(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 zb(e,t,n){var c,d,f,p,m,x,y,w,C,b,S,v,_,E,j,T,R,A,D,$,q,G;const s=n();Cj(e,s);const a=((c=s.currentSession)==null?void 0:c.id)??null,l=()=>{const I=e.sessionId;!I||I===a||t(U=>({unreadSessionIds:Ej(U.unreadSessionIds,I)}))},u=(I,U,V)=>({messages:I.messages.map(z=>z.id===U?V(z):z)});switch(e.type){case"session.state":{const I=e.payload;if(!kj(e,a,s.pendingSessionCreate))break;const U=n().pendingSessionCreate===!0;t({currentSession:I.session,sessions:jj(n().sessions,I.session),unreadSessionIds:Pb(n().unreadSessionIds,I.session.id),messages:I.messages,currentTodos:[],pendingPathConfirmations:I.pendingConfirmations??[],pendingQuestions:I.pendingQuestions??[],error:null,...U?{pendingSessionCreate:I.session.id}:{}});break}case"session.list":{const I=e.payload;t(U=>({sessions:Nj(I.sessions,U.sessions,U.currentSession)}));break}case"session.deleted":{const I=e.payload;t(U=>({unreadSessionIds:Pb(U.unreadSessionIds,I.sessionId)})),n().listSessions();break}case"session.deletedAll":{n().listSessions();break}case"session.running":{const I=e.payload;Bb(e,t,n,U=>({...U,isRunning:I.isRunning})),I.isRunning||t({abortInProgress:!1,queuedMessages:[]}),I.isRunning&&t({restoredInput:null});break}case"chat.message":{if(!Gt(e,((d=n().currentSession)==null?void 0:d.id)??null)){l();break}const I=e.payload;t(U=>{if(U.messages.some(z=>z.id===I.message.id))return U;const V=I.message.role==="user";return{messages:[...U.messages,I.message],sessions:U.sessions.map(z=>z.id===e.sessionId&&V?{...z,messageCount:z.messageCount+1}:z)}});break}case"chat.message_updated":{if(!Gt(e,((f=n().currentSession)==null?void 0:f.id)??null)){l();break}const I=e.payload,U=n().messages.find(V=>V.id===I.messageId);I.updates.isStreaming===!1&&(U==null||U.isStreaming),t(V=>({messages:V.messages.map(z=>z.id===I.messageId?{...z,...I.updates}:z)}));break}case"chat.delta":{if(!Gt(e,((p=n().currentSession)==null?void 0:p.id)??null)){l();break}const I=e.payload;if(!Wf.has(I.messageId)){Wf.add(I.messageId);const V=I.subAgentType?"sub-agent":il(n(),e.sessionId);wj(V)}const U=bi();U.messageId=I.messageId,U.deltaContent+=I.content,Vf();break}case"chat.thinking":{if(!Gt(e,((m=n().currentSession)==null?void 0:m.id)??null)){l();break}const I=e.payload,U=bi();U.messageId=I.messageId,U.thinkingContent+=I.content,Vf();break}case"chat.tool_preparing":{if(!Gt(e,((x=n().currentSession)==null?void 0:x.id)??null)){l();break}const I=e.payload;t(U=>{var O;const V=U.messages.find(B=>B.id===I.messageId);if(!V)return{};if((O=V.toolCalls)==null?void 0:O.find((B,W)=>W===I.index))return{};const J=V.preparingToolCalls??[],Z=J.findIndex(B=>B.index===I.index);let H;return Z>=0?H=J.map((B,W)=>W===Z?{...B,arguments:I.arguments}:B):H=[...J,{index:I.index,name:I.name,...I.arguments?{arguments:I.arguments}:{}}],{messages:U.messages.map(B=>B.id===I.messageId?{...B,preparingToolCalls:H}:B)}});break}case"chat.tool_call":{if(!Gt(e,((y=n().currentSession)==null?void 0:y.id)??null)){l();break}const I=e.payload,U=V=>{var H;const z=(H=V.preparingToolCalls)==null?void 0:H.filter((O,B)=>{var W;return O.name===I.tool?(W=V.preparingToolCalls)==null?void 0:W.slice(0,B).some(ee=>ee.name===I.tool):!0}),J=bi(),Z=J.toolOutput.filter(O=>O.callId===I.callId);return Z.length>0&&(J.toolOutput=J.toolOutput.filter(O=>O.callId!==I.callId)),{...V,toolCalls:[...V.toolCalls??[],{id:I.callId,name:I.tool,arguments:I.args,startedAt:Date.now(),...Z.length>0?{streamingOutput:Z.map(O=>({stream:O.stream,content:O.content,timestamp:Date.now()}))}:{}}],...z&&z.length>0?{preparingToolCalls:z}:{preparingToolCalls:void 0}}};t(V=>u(V,I.messageId,U));break}case"chat.tool_output":{if(!Gt(e,((w=n().currentSession)==null?void 0:w.id)??null)){l();break}const I=e.payload,U=bi();U.messageId=I.messageId,U.toolOutput.push({messageId:I.messageId,callId:I.callId,stream:I.stream,content:I.output}),Vf();break}case"chat.tool_result":{if(!Gt(e,((C=n().currentSession)==null?void 0:C.id)??null)){l();break}const I=e.payload,U=V=>{var J;const z=(J=V.toolCalls)==null?void 0:J.map(Z=>Z.id===I.callId?{...Z,result:I.result}:Z);return{...V,toolCalls:z}};t(V=>u(V,I.messageId,U));break}case"chat.vision_fallback":{if(!Gt(e,((b=n().currentSession)==null?void 0:b.id)??null)){l();break}const I=e.payload;t(U=>{const V=`${I.messageId}-${I.attachmentId}`,z={...U.visionFallbackByMessage};return z[V]={type:I.type,attachmentId:I.attachmentId,filename:I.filename,description:I.description},{visionFallbackByMessage:z}});break}case"chat.todo":{if(!Gt(e,((S=n().currentSession)==null?void 0:S.id)??null)){l();break}const I=e.payload;t({currentTodos:I.todos});break}case"chat.progress":{if(!Gt(e,((v=n().currentSession)==null?void 0:v.id)??null)){l();break}const I=e.payload;console.warn("Progress:",I.message,I.phase);break}case"chat.format_retry":{if(!Gt(e,((_=n().currentSession)==null?void 0:_.id)??null)){l();break}const I=e.payload;console.warn("Format retry:",I.attempt,"/",I.maxAttempts);break}case"chat.done":{if(!Gt(e,((E=n().currentSession)==null?void 0:E.id)??null)){l();break}const I=bi();I.messageId=null,I.deltaContent="",I.thinkingContent="",I.toolOutput=[],Wf.delete(e.payload.messageId);const U=e.payload,V=U.stats;t(z=>({messages:z.messages.map(J=>J.id===U.messageId?{...J,isStreaming:!1,stats:V??J.stats,completeReason:U.reason,preparingToolCalls:void 0}:J),visionFallbackByMessage:{}}));break}case"chat.error":{if(!Gt(e,((j=n().currentSession)==null?void 0:j.id)??null)){l();break}const I=bi(),U=e.payload;console.error("Chat error:",U.error,"recoverable:",U.recoverable),U.recoverable||(I.messageId=null,I.deltaContent="",I.thinkingContent="",I.toolOutput=[]),t(V=>({error:{code:"CHAT_ERROR",message:U.error},...U.recoverable?{}:{messages:V.messages}}));break}case"chat.path_confirmation":{if(!Gt(e,((T=n().currentSession)==null?void 0:T.id)??null)){l();break}const I=e.payload,U={callId:I.callId,tool:I.tool,paths:I.paths,workdir:I.workdir,reason:I.reason};t(V=>({pendingPathConfirmations:[...V.pendingPathConfirmations,U]}));break}case"chat.ask_user":{if(!Gt(e,((R=n().currentSession)==null?void 0:R.id)??null)){l();return}const I=e.payload,U={callId:I.callId,question:I.question,type:I.type??"text",options:I.options??void 0};t(V=>({pendingQuestions:[...V.pendingQuestions.filter(z=>z.callId!==I.callId),U]}));break}case"mode.changed":{if(!Gt(e,((A=n().currentSession)==null?void 0:A.id)??null)){l();break}const I=e.payload;t(U=>({currentSession:U.currentSession?{...U.currentSession,mode:I.mode}:null}));break}case"phase.changed":{const I=e.payload;Bb(e,t,n,U=>({...U,phase:I.phase}));break}case"criteria.updated":{if(!Gt(e,((D=n().currentSession)==null?void 0:D.id)??null)){l();break}const I=e.payload;t(U=>({currentSession:U.currentSession?{...U.currentSession,criteria:I.criteria}:null}));break}case"metadata.updated":{if(!Gt(e,(($=n().currentSession)==null?void 0:$.id)??null)){l();break}const I=e.payload;t(U=>({currentSession:U.currentSession?{...U.currentSession,metadataEntries:{...U.currentSession.metadataEntries,[I.key]:I.entries}}:null}));break}case"context.state":{const I=e.payload,U=Gt(e,((q=n().currentSession)==null?void 0:q.id)??null);I.subAgentId?U&&n().updateSubAgentContextState(I.subAgentId,I.context):U?t({contextState:I.context}):l();break}case"session.name_generated":{const I=e.payload,U=e.sessionId,V=(G=n().currentSession)==null?void 0:G.id;t(z=>{const J=z.sessions.map(H=>H.id===U?{...H,title:I.name,updatedAt:new Date().toISOString()}:H),Z=V===U?z.currentSession?{...z.currentSession,title:I.name,updatedAt:new Date().toISOString()}:null:z.currentSession;return{sessions:J,currentSession:Z}});break}case"queue.state":{const I=e.payload;t({queuedMessages:I.messages??[]});break}case"mcp.servers.changed":{window.dispatchEvent(new CustomEvent("mcp-servers-changed"));break}case"git.status":{const I=e.payload;t({gitStatus:{branch:I.branch,diff:I.diff}});break}case"devServer.output":case"devServer.state":{Dr.getState().handleMessage(e);break}case"backgroundProcess.started":case"backgroundProcess.output":case"backgroundProcess.exited":case"backgroundProcess.removed":{ll.getState().handleMessage(e.type,e.payload);break}case"error":{const I=e.payload;console.error("Server error:",I),t({error:{code:I.code,message:I.message}});break}}}let Ko=!1,Tr=null;const qf=new Set,Jc=new Map;function $b(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 Hb(e,t,n,s,a){try{const u=await(await Te(`/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 De=Xn((e,t)=>(hj(()=>{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 p=f.messages.find(m=>m.id===n.messageId);if(p){const m={...p};if(s&&(m.content=m.content+u),a&&(m.thinkingContent=(m.thinkingContent??"")+c),l){const x=new Set;m.toolCalls=$b(m.toolCalls,d,x);const y=d.filter(w=>!x.has(w.callId));y.length>0&&n.toolOutput.push(...y)}return{messages:f.messages.map(x=>x.id===n.messageId?m:x)}}if(l){const m=new Set,x=f.messages.map(w=>w.id!==n.messageId?w:{...w,toolCalls:$b(w.toolCalls,d,m)}),y=d.filter(w=>!m.has(w.callId));return y.length>0&&n.toolOutput.push(...y),{messages:x}}return f})}),{connectionStatus:"disconnected",showPasswordModal:!1,passwordModalRetry:!1,sessions:[],currentSession:null,unreadSessionIds:[],messages:[],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 Te("/api/auth")).json()).requiresAuth}catch{}if(s&&!Ut.hasToken()){e({showPasswordModal:!0,passwordModalRetry:!1,connectionStatus:"reconnecting"});return}Ut.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 Ut.connect(),Ko||(Ko=!0,Tr=Ut.subscribe(a=>{zb(a,e,t)}))}catch(a){console.error("Failed to connect:",a);const l=Ut.getLastCloseCode();if(!Ut.hasToken()&&(l===1006||l===4e3)){e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"});return}Tr&&(Tr(),Tr=null),Ko=!1,e({connectionStatus:"disconnected"})}},reconnect:()=>{Ut.disconnect(),Tr&&(Tr(),Tr=null),Ko=!1,e({connectionStatus:"disconnected"}),t().connect()},disconnect:()=>{Ut.disconnect(),Tr&&(Tr(),Tr=null),Ko=!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();Ut.setToken(a),e({showPasswordModal:!1}),t().connect();const{listProjects:l}=Rt.getState(),{fetchConfig:u}=nn.getState();l(),u(),t().connect()}catch{e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"})}},cancelPassword:()=>{Ut.clearToken(),e({showPasswordModal:!1,connectionStatus:"disconnected"})},createSession:async(n,s)=>{if(t().pendingSessionCreate)return null;try{e({pendingSessionCreate:!0});const l=await Te("/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{Ut.send("session.load",{sessionId:u.session.id})}catch{}return u.session}catch{return e({pendingSessionCreate:!1}),null}},loadSession:async n=>{if(!qf.has(n)){qf.add(n);try{const s=t().currentSession;!s||s.id!==n?e({currentSession:null,unreadSessionIds:t().unreadSessionIds.filter(c=>c!==n),subAgentContextStates:{},messages:[],currentTodos:[],contextState:null,pendingPathConfirmations:[],pendingQuestions:[],queuedMessages:[],abortInProgress:!1,restoredInput:null,error:null,pendingSessionCreate:!1}):e({unreadSessionIds:t().unreadSessionIds.filter(c=>c!==n)});const a=await Te(`/api/sessions/${n}`);if(!a.ok)return;const l=await a.json(),u=l.messages??[];e({currentSession:l.session,messages:u,contextState:l.contextState,queuedMessages:l.queueState??[],pendingQuestions:l.pendingQuestions??[]}),Ut.send("session.load",{sessionId:n});try{const c=await Te(`/api/sessions/${n}/background-processes`);if(c.ok){const d=await c.json();ll.getState().setProcesses(d.processes??[])}}catch{}}catch{}finally{qf.delete(n)}}},listSessions:async(n,s=20)=>{const a=n??"global";if(Jc.has(a))return Jc.get(a);const l=(async()=>{try{const u=new URLSearchParams;u.set("limit",String(s)),n&&u.set("projectId",n);const d=await(await Te(`/api/sessions?${u.toString()}`)).json(),f=d.sessions??[];e(p=>({sessions:f.map(m=>{var y,w;const x=p.sessions.find(C=>C.id===m.id);return{...m,title:m.title??(x==null?void 0:x.title),mode:((y=p.currentSession)==null?void 0:y.id)===m.id?p.currentSession.mode:(x==null?void 0:x.mode)??m.mode,phase:((w=p.currentSession)==null?void 0:w.id)===m.id?p.currentSession.phase:(x==null?void 0:x.phase)??m.phase,isRunning:m.isRunning&&(x==null?void 0:x.isRunning)!==!1,messageCount:m.messageCount,recentUserPrompts:m.recentUserPrompts}}),sessionsHasMore:n?d.hasMore??!1:!0}))}catch{}finally{Jc.delete(a)}})();return Jc.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 Te(`/api/sessions?${a.toString()}`)).json(),c=u.sessions??[];e(d=>({sessions:[...d.sessions,...c.map(f=>{const p=d.sessions.find(m=>m.id===f.id);return(p==null?void 0:p.isRunning)===!1?{...f,isRunning:!1}:f})],sessionsHasMore:u.hasMore??!1,sessionsPaginationLoading:!1}))}catch{e({sessionsPaginationLoading:!1})}}},deleteSession:async n=>{var s;try{return(await Te(`/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 Te(`/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 Te(`/api/projects/${n}/sessions`,{method:"DELETE"})).ok?(await t().listSessions(),!0):!1}catch{return!1}},clearSession:()=>{e(n=>({currentSession:null,messages:[],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)try{const c=n==null?void 0:n.trim(),d=s&&s.length>0,f={};c&&(f.content=n),d&&(f.attachments=s),a!=null&&a.messageKind&&(f.messageKind=a.messageKind);const m=await(await Te(`/api/sessions/${l}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)})).json();m.queueState&&e({queuedMessages:m.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 Te(`/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)try{await Te(`/api/sessions/${n}/continue`,{method:"POST"})}catch(a){console.error("Error continuing generation:",a)}},launchWorkflow:(n,s,a,l)=>{const u={};n!=null&&n.trim()&&(u.content=n),s&&s.length>0&&(u.attachments=s),a&&(u.workflowId=a),l&&(u.subGroup=l),Ut.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 Te(`/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 Te(`/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)}},editCriteria:async n=>{var a;const s=(a=t().currentSession)==null?void 0:a.id;if(s)try{const l=await Te(`/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:()=>{Ut.send("context.compact",{})},setSessionProvider:async(n,s)=>{var a;try{const l=(a=t().currentSession)==null?void 0:a.id;if(!l)return null;const u=await Te(`/api/sessions/${l}/provider`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerId:n,...s?{model:s}:{}})});if(!u.ok)return null;const c=await u.json();return e({currentSession:c.session,messages:c.messages??[],contextState:c.contextState}),c.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 Te(`/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 Te(`/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 Hb(l,n,s,a,e)},queueCompletion:async(n,s,a)=>{var u;const l=(u=t().currentSession)==null?void 0:u.id;l&&await Hb(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 Te(`/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=>{zb(n,e,t)}}));function Yu(){return De(e=>{var t;return((t=e.currentSession)==null?void 0:t.isRunning)??!1})}function Tj(){return De(e=>e.abortInProgress)}function Aj(){const e=De(a=>a.connect),t=De(a=>a.connectionStatus),n=Si(a=>a.load),s=Ga("/p/:projectId/s/:sessionId/readonly")[0];return L.useEffect(()=>{s||e()},[e,s]),L.useEffect(()=>{s||t==="connected"&&n()},[t,n,s]),{connectionStatus:t}}const Lj="modulepreload",Rj=function(e){return"/"+e},Ub={},Q=function(t,n,s){let a=Promise.resolve();if(n&&n.length>0){let u=function(f){return Promise.all(f.map(p=>Promise.resolve(p).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),d=(c==null?void 0:c.nonce)||(c==null?void 0:c.getAttribute("nonce"));a=u(n.map(f=>{if(f=Rj(f),f in Ub)return;Ub[f]=!0;const p=f.endsWith(".css"),m=p?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${f}"]${m}`))return;const x=document.createElement("link");if(x.rel=p?"stylesheet":Lj,p||(x.as="script"),x.crossOrigin="",x.href=f,d&&x.setAttribute("nonce",d),document.head.appendChild(x),p)return new Promise((y,w)=>{x.addEventListener("load",y),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)})},Dj=[{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"}],Oj=[{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"}}],jS={tokens:Dj,presets:Oj},NS=jS.tokens,Ir=jS.presets;function Fb(){try{const e=localStorage.getItem("openfox:userPresets");if(e)return JSON.parse(e)}catch{}return[]}const Ht=Xn((e,t)=>({currentPreset:"dark",basePreset:"",customTokens:{},isCustom:!1,isCustomizing:!1,userPresets:Fb(),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{...NS.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(()=>Hf);return{useSettingsStore:a}},void 0);await s.getState().setSetting(Oe.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(()=>Hf);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:Fb()})},saveUserPresets:()=>{localStorage.setItem("openfox:userPresets",JSON.stringify(t().userPresets)),Q(async()=>{const{useSettingsStore:n}=await Promise.resolve().then(()=>Hf);return{useSettingsStore:n}},void 0).then(({useSettingsStore:n})=>{n.getState().setSetting(Oe.DISPLAY_USER_PRESETS,JSON.stringify(t().userPresets)).catch(()=>{})})}}));function Ij({canLoad:e,projectId:t,currentProjectId:n}){const s=Rt(u=>u.loadProject),a=De(u=>u.listSessions),l=De(u=>u.clearSession);L.useEffect(()=>{e&&t&&(n!==t&&s(t),a(t),l())},[e,t,n,s,a,l])}function Mj({canLoad:e,projectId:t,sessionId:n,currentProjectId:s,currentSessionId:a}){const l=De(f=>f.loadSession),u=Rt(f=>f.loadProject),c=De(f=>f.listSessions),d=De(f=>f.pendingSessionCreate);L.useEffect(()=>{e&&t&&s!==t&&u(t)},[e,t,s,u]),L.useEffect(()=>{e&&n&&a!==n&&l(n),e&&t&&c(t)},[e,n,a,l,c,d,t])}function Pj({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 TS({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 Bj({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 zj({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 $j({className:e="w-4 h-4"}){return o.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:o.jsx("path",{d:"M9.5 3.25a2.25 2.25 0 1 1 3 2.122V6A2.5 2.5 0 0 1 10 8.5H6a1 1 0 0 0-1 1v1.128a2.251 2.251 0 1 1-1.5 0V5.372a2.25 2.25 0 1 1 1.5 0v1.836A2.493 2.493 0 0 1 6 7h4a1 1 0 0 0 1-1v-.628A2.25 2.25 0 0 1 9.5 3.25Zm-6 0a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Zm8.25-.75a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5ZM4.25 12a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Z"})})}function Mr({className:e="w-3.5 h-3.5 text-text-muted"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}function On({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 Hj({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 Cp({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 Uj({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 kp({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 wu({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 El({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 Fj({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 Vj({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 Gj({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 AS({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 Wj({className:e="w-4 h-4"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"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 Vb({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 LS({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 qj({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 Kj({className:e="w-3 h-3",color:t}){return o.jsx("svg",{className:e,fill:t??"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{d:"M8 5v14l11-7z"})})}function qs({className:e="w-3 h-3 text-accent-primary"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}function Yj({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 Ep({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 Xj({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 Qj({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 RS({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 DS({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 OS({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 Jj({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 Zj({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 Wa({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 pl({className:e="w-3.5 h-3.5"}){return o.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:o.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})}function eN({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 zm({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 qa({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 IS({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 tN({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 nN({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 Gb({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 $m(){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 Wb(e,t){const n=Ut.ws;!n||n.readyState!==WebSocket.OPEN||n.send(JSON.stringify({id:$m(),type:e,payload:t}))}const _r=Xn((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 Te(`/api/terminals?projectId=${encodeURIComponent(n)}`);if(s.ok){const a=await s.json();e({sessions:a});const l=Ut.ws;if(l&&l.readyState===WebSocket.OPEN)for(const u of a)l.send(JSON.stringify({id:$m(),type:"terminal.subscribe",payload:{sessionId:u.id}}))}}catch(s){console.error("Failed to fetch terminals:",s)}},createSession:async(n,s)=>{try{const a=await Te("/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=Ut.ws;u&&u.readyState===WebSocket.OPEN&&u.send(JSON.stringify({id:$m(),type:"terminal.subscribe",payload:{sessionId:l.id}}))}}catch(a){console.error("Failed to create terminal:",a)}},writeSession:(n,s)=>{Wb("terminal.write",{sessionId:n,data:s})},resizeSession:(n,s,a)=>{Wb("terminal.resize",{sessionId:n,cols:s,rows:a})},killSession:async n=>{try{(await Te(`/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}}}}));Ut.subscribe(e=>{var t;(t=e.type)!=null&&t.startsWith("terminal.")&&_r.getState().handleMessage(e)});const Da={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 Hm(e){if(!e)return structuredClone(Da);try{const t=JSON.parse(e);return{terminalToggle:t.terminalToggle??structuredClone(Da.terminalToggle),quickAction:t.quickAction??structuredClone(Da.quickAction),agentSwitching:t.agentSwitching??structuredClone(Da.agentSwitching)}}catch{return structuredClone(Da)}}function qb(e){return e.code.startsWith("Digit")?e.code.slice(-1):e.code.startsWith("Key")?e.code.slice(3).toLowerCase():e.key}function MS(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 rN(e){return e.type==="double-press"}function PS(e){return e.type==="chord"}function sN(e,t){return t.length===1&&/^[a-z]$/i.test(t)?e.code===`Key${t.toUpperCase()}`:t.length===1&&/^[0-9]$/.test(t)?e.code===`Digit${t}`:e.key.toLowerCase()===t.toLowerCase()}function BS(e,t){const n=t.modifiers.includes("ctrl"),s=t.modifiers.includes("meta"),a=t.modifiers.includes("alt"),l=t.modifiers.includes("shift");return sN(e,t.key)&&e.ctrlKey===n&&e.metaKey===s&&e.altKey===a&&e.shiftKey===l}function jp(){const e=qt(t=>t.settings[Oe.KEYBINDINGS]);return Hm(e)}function iN(e,t,n){const s=L.useRef(0),a=L.useRef(t);a.current=t,L.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",p=e.key==="Alt",m=e.key==="Meta";if(!d&&c.ctrlKey||!f&&c.shiftKey||!p&&c.altKey||!m&&c.metaKey)return;const x=Date.now();x-s.current<l?(c.preventDefault(),c.stopPropagation(),a.current(),s.current=0):s.current=x};return window.addEventListener("keydown",u,n!=null&&n.capture?!0:void 0),()=>window.removeEventListener("keydown",u,n!=null&&n.capture?!0:void 0)},[e,n==null?void 0:n.capture])}function aN(e,t){const n=L.useRef(t);n.current=t,L.useEffect(()=>{if(!e)return;const s=a=>{BS(a,e)&&(a.preventDefault(),n.current())};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[e])}function zS(e,t,n){iN(e&&rN(e)?e:void 0,t,n),aN(e&&PS(e)?e:void 0,t)}function oN(e,t,n){const s=L.useRef(n);s.current=n,L.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&&PS(c)&&BS(l,c)){l.preventDefault(),s.current(d.id);return}}};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[e,t])}var Ka=dS();const Xu=L.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})})}));Xu.displayName="IconButton";const lN="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z",Fs=L.forwardRef((e,t)=>o.jsx(Xu,{ref:t,icon:lN,title:"Edit",...e}));Fs.displayName="EditButton";const cN="M6 18L18 6M6 6l12 12",Np=L.forwardRef((e,t)=>o.jsx(Xu,{ref:t,icon:cN,...e}));Np.displayName="CloseButton";const uN={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 jt({label:e,title:t,headerRight:n,size:s="md",minHeight:a,children:l,footer:u,className:c,onClose:d,isOpen:f,closeOnBackdropClick:p=!0,closeOnEscape:m=!0,showCloseButton:x=!0,scrollable:y=!0}){const[w,C]=L.useState(!1),b=f!==void 0,S=b?f:w,v=L.useCallback(()=>{b||C(!0)},[b]),_=L.useCallback(()=>{b||C(!1),d==null||d()},[b,d]);L.useEffect(()=>{if(!S||!m)return;const j=T=>{T.key==="Escape"&&(T.stopPropagation(),_())};return document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)},[S,_,m]);const E=e&&(typeof e=="string"?o.jsx("button",{type:"button",onClick:v,className:c,children:e}):o.jsx("span",{onClick:v,className:c,style:{cursor:"pointer"},children:e}));return o.jsxs(o.Fragment,{children:[E,S&&(typeof document<"u"?Ka.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:p?_:void 0}),o.jsxs("div",{className:`relative w-full ${uN[s]} max-h-[90vh] bg-bg-secondary border border-border rounded shadow-xl flex flex-col`,children:[(t||n||x)&&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,x&&o.jsx(Np,{onClick:_,"aria-label":"Close"})]})]}),o.jsx("div",{className:`p-4 flex-1 min-h-0${y?" overflow-y-auto":" overflow-hidden flex flex-col"}`,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 dN({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:mj.map(({url:l,label:u})=>o.jsx("option",{value:l,title:u,children:u.split(" ")[0]},l))}),o.jsx(On,{className:"absolute right-0.5 top-1/2 -translate-y-1/2 w-3 h-3 pointer-events-none text-text-muted"})]})}const Kb=[{key:"general",label:"General"},{key:"build",label:"Agent"},{key:"sub-agent",label:"Sub-agent"}];function hN(){const e=Si(d=>d.settings),t=Si(d=>d.update),n=Si(d=>d.updateEvent),s=Si(d=>d.updateAgentOverride),a=Si(d=>d.load);L.useEffect(()=>{a()},[a]);const l=async()=>{await gj()==="granted"&&t({...e,browserNotificationEnabled:!0})},u=(d,f,p,m)=>{d==="general"?n(f,{[p]:m}):s(d,f,{[p]:m})},c=(d,f,p)=>{d==="general"?n(f,{customSoundUrl:p}):s(d,f,{customSoundUrl:p})};return o.jsxs("div",{className:"space-y-6",children:[o.jsxs("div",{className:"space-y-3",children:[o.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Master Controls"}),o.jsx(Yb,{label:"Sound notifications",description:"Play sounds when events occur",checked:e.soundEnabled,onChange:d=>t({...e,soundEnabled:d})}),o.jsx(Yb,{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"}),Kb.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:fj.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})}),Kb.map(f=>{const p=kS(e,d.key,f.key==="general"?void 0:f.key),m=wS[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:p.soundEnabled,onChange:x=>u(f.key,d.key,"soundEnabled",x.target.checked),disabled:!e.soundEnabled,className:"rounded border-border",title:"Sound"})}),o.jsx("label",{className:"flex items-center gap-1 text-text-secondary",children:o.jsx("input",{type:"checkbox",checked:p.browserNotification,onChange:x=>u(f.key,d.key,"browserNotification",x.target.checked),disabled:!e.browserNotificationEnabled,className:"rounded border-border",title:"Browser"})})]}),p.soundEnabled&&e.soundEnabled&&o.jsx(dN,{value:p.customSoundUrl,defaultUrl:m,disabled:!e.soundEnabled,onChange:x=>c(f.key,d.key,x)})]})},f.key)})]},d.key))})]})})]})]})}function Yb({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 Ve=L.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})});Ve.displayName="Button";async function Xb(e,t,n){try{const s=await Te(e,t);return s.ok?(await n(),{success:!0}):{success:!1,error:(await s.json()).error}}catch{return{success:!1,error:"Network error"}}}const gn=Xn((e,t)=>({defaults:[],userItems:[],projectItems:[],items:[],selectedDirectory:null,diagnostics:[],loading:!1,fetchSkills:async()=>{e({loading:!0});try{const s=await(await Te("/api/skills")).json();e({defaults:s.defaults??[],userItems:s.userItems??[],projectItems:s.projectItems??[],items:s.items??[],selectedDirectory:s.selectedDirectory??null,diagnostics:s.diagnostics??[],loading:!1})}catch{e({loading:!1})}},toggleSkill:async n=>{try{const a=await(await Te(`/api/skills/${n}/toggle`,{method:"POST"})).json();e(l=>({defaults:l.defaults.map(u=>u.id===n?{...u,enabled:a.enabled}:u),userItems:l.userItems.map(u=>u.id===n?{...u,enabled:a.enabled}:u),projectItems:l.projectItems.map(u=>u.id===n?{...u,enabled:a.enabled}:u),items:l.items.map(u=>u.id===n?{...u,enabled:a.enabled}:u)}))}catch{}},fetchSkill:async n=>{try{const s=await Te(`/api/skills/${n}`);return s.ok?await s.json():null}catch{return null}},fetchDefaultContent:async n=>{try{const s=await Te(`/api/skills/defaults/${n}`);return s.ok?await s.json():null}catch{return null}},createSkill:async(n,s)=>{const a=await Ws("POST","/api/skills",{...n,destination:s});return a.success&&await t().fetchSkills(),a},updateSkill:async(n,s)=>{const a=await Ws("PUT",`/api/skills/${n}`,s);return a.success&&await t().fetchSkills(),a},deleteSkill:async n=>{try{const s=await Te(`/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)=>Ku(`/api/skills/${n}/duplicate`,()=>t().fetchSkills(),s),selectDirectory:async n=>Xb("/api/skills/library",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n})},t().fetchSkills),removeDirectory:async()=>{await Te("/api/skills/library",{method:"DELETE"}),await t().fetchSkills()},installSkill:async n=>{const s=new FormData;s.append("packageName",n.packageName),s.append("paths",JSON.stringify(n.files.map(a=>a.path)));for(const a of n.files)s.append("files",a.file,a.file.name);return Xb("/api/skills/install",{method:"POST",body:s},t().fetchSkills)}}));function Qu(){const[e,t]=L.useState({id:null,type:null}),n=L.useCallback(l=>t({id:l,type:"delete"}),[]),s=L.useCallback(()=>t({id:null,type:null}),[]),a=L.useCallback((l,u)=>e.id===l&&e.type===u,[e.id,e.type]);return{requestDelete:n,clearConfirm:s,isConfirming:a}}function Tp({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 Ap({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(Wa,{})})}function Cu({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(Cp,{})})}function vr({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 fN({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(Ve,{variant:"secondary",onClick:e,children:"Cancel"}),o.jsx(Ve,{variant:"primary",onClick:t,disabled:n||s,children:n?"Saving...":"Save"})]})}function Ju({message:e}){return o.jsx("div",{className:"text-accent-error text-sm px-3 py-2 bg-accent-error/10 rounded",children:e})}function $S({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(Ve,{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 HS({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 US({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(Ve,{variant:"primary",size:"sm",onClick:t,children:n})})]})}function Lp({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 FS({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:p}){return o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsx(vr,{label:n,value:e,onChange:f,placeholder:a,hint:u}),o.jsx(vr,{label:s,value:t,onChange:p,readOnly:c,placeholder:l,hint:c?d:void 0,mono:!0})]})}function VS(e={}){const{initialData:t={}}=e,[n,s]=L.useState("list"),[a,l]=L.useState(null),[u,c]=L.useState(""),[d,f]=L.useState(!1),[p,m]=L.useState(t),x=L.useCallback(()=>{m(t),c(""),l(null)},[t]),y=L.useCallback(S=>{s(S),S==="list"&&x()},[x]),w=L.useCallback(S=>{m(v=>typeof S=="function"?S(v):S)},[]),C=L.useCallback((S,v={})=>{l(S),s("edit"),m({...v}),c("")},[]),b=L.useCallback(()=>{l(null),s("edit"),m(t),c("")},[t]);return{view:n,editingId:a,formError:u,saving:d,formData:p,setView:y,setEditingId:l,setFormError:c,setFormData:w,setSaving:f,resetForm:x,startEditing:C,startNew:b}}const mN={sm:"w-4 h-4",md:"w-8 h-8",lg:"w-12 h-12"};function Di({size:e="md",className:t=""}){return o.jsx("div",{className:`animate-spin border-2 border-accent-primary border-t-transparent rounded-full ${mN[e]} ${t}`})}function pN({text:e,...t}){return o.jsxs("div",{className:"text-center",children:[o.jsx(Di,{...t,className:"mx-auto mb-4"}),e&&o.jsx("div",{className:"text-text-secondary",children:e})]})}const Ni=L.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}));Ni.displayName="Input";function Zu({onSelect:e,onClose:t,initialPath:n}){const[s,a]=L.useState(null),[l,u]=L.useState(!0),[c,d]=L.useState(""),[f,p]=L.useState(-1),m=L.useRef(null),x=L.useRef(null),y=L.useCallback(async _=>{u(!0),d(""),p(-1);try{const E=_?`/api/directories?path=${encodeURIComponent(_)}`:"/api/directories",T=await(await Te(E)).json();a(T)}catch(E){console.error("Failed to load directories:",E)}finally{u(!1)}},[]);L.useEffect(()=>{y(n)},[n,y]);const w=((s==null?void 0:s.current)??"").split("/").filter(Boolean).map((_,E,j)=>({name:_,path:"/"+j.slice(0,E+1).join("/")})),C=(s==null?void 0:s.directories.filter(_=>c===""||_.name.toLowerCase().includes(c.toLowerCase())))??[],b=[...!c&&(s!=null&&s.parent)?[{type:"parent",path:s.parent,name:".."}]:[],...C.map(_=>({type:"dir",path:_.path,name:_.name}))];L.useEffect(()=>{p(c?0:-1)},[c,C.length]),L.useEffect(()=>{if(f>=0&&x.current){const _=x.current.querySelector(`[data-index="${f}"]`);_==null||_.scrollIntoView({block:"nearest"})}},[f]);const S=_=>{var E;if(_.key==="ArrowDown")_.preventDefault(),p(j=>Math.min(j+1,b.length-1));else if(_.key==="ArrowUp")_.preventDefault(),p(j=>Math.max(j-1,0));else if(_.key==="Enter"){if(f<0||!b[f]||_.target instanceof HTMLElement&&_.target.dataset.select==="true")return;_.preventDefault(),_.shiftKey?y(b[f].path):e(b[f].path)}else _.key==="Escape"&&(d(""),(E=m.current)==null||E.focus())},v=o.jsx("div",{className:"flex flex-col gap-2",children:o.jsx("button",{onClick:t,className:"w-full text-center text-text-muted hover:text-text-secondary text-sm",children:"Cancel"})});return o.jsx(jt,{isOpen:!0,onClose:t,title:"Select Folder",size:"lg",footer:v,scrollable:!1,children:o.jsxs("div",{ref:x,className:"flex flex-col flex-1 min-h-0 -m-4",onKeyDown:S,children:[o.jsxs("div",{className:"flex-shrink-0 bg-bg-secondary border-b border-border",children:[s&&o.jsx("div",{className:"px-3 pt-3 pb-1",children:o.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[o.jsxs("div",{className:"flex items-center flex-wrap min-w-0",children:[w.map((_,E)=>o.jsxs("span",{className:"flex items-center shrink-0",children:[o.jsx("span",{className:"text-text-muted",children:"/"}),o.jsx("button",{onClick:()=>y(_.path),className:`px-1 ${E===w.length-1?"text-accent-primary font-medium":"text-text-secondary hover:text-accent-primary"}`,children:_.name})]},_.path)),w.length===0&&o.jsx("button",{onClick:()=>y("/"),className:"text-text-muted hover:text-accent-primary",children:"/"})]}),(s==null?void 0:s.current)&&o.jsx("button",{onClick:()=>e(s.current),className:"ml-auto shrink-0 px-4 py-2 text-sm font-medium rounded-lg bg-accent-primary text-text-primary hover:bg-accent-primary/90",children:"Select"})]})}),o.jsx("div",{className:"px-4 py-2",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(pl,{})}),o.jsx(Ni,{autoFocus:!0,ref:m,value:c,onChange:_=>d(_.target.value),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(Di,{size:"sm"})}):b.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:b.map((_,E)=>o.jsxs("div",{"data-index":E,className:`group flex items-center ${E===f?"bg-accent-primary/20":"hover:bg-bg-tertiary/50"}`,children:[o.jsxs("button",{onClick:()=>{y(_.path)},className:"flex-1 flex items-center gap-3 p-3 text-left min-w-0",tabIndex:-1,children:[_.type==="parent"?o.jsx(Pj,{className:"w-5 h-5 text-text-muted shrink-0"}):o.jsx(El,{className:"w-5 h-5 shrink-0"}),o.jsx("span",{className:"truncate",children:_.name}),_.type==="dir"&&o.jsx(On,{className:`w-5 h-5 text-text-muted shrink-0 ml-1 ${E===f?"opacity-100":"opacity-0 group-hover:opacity-100"}`,rotate:-90})]}),_.type==="dir"&&o.jsx("button",{"data-select":"true",tabIndex:E===f?0:-1,onClick:j=>{j.stopPropagation(),e(_.path)},className:`mr-2 shrink-0 px-4 py-2 text-sm font-medium rounded-lg bg-accent-primary text-text-primary hover:bg-accent-primary/90 ${E===f?"opacity-100":"opacity-0 group-hover:opacity-100"}`,"aria-label":`Select ${_.name}`,children:"Select"})]},_.path))})})]})})}function GS(e,t){if(!e||!t.some(n=>n.path==="SKILL.md"))throw new Error("Drop one folder containing SKILL.md.");return{packageName:e,files:t}}function gN(e){const t=[...e];if(!t.length)throw new Error("Choose one skill folder.");const n=new Set(t.map(a=>a.webkitRelativePath.split("/")[0]).filter(Boolean));if(n.size!==1)throw new Error("Choose exactly one skill folder.");const s=[...n][0];return GS(s,t.map(a=>({path:a.webkitRelativePath.slice(s.length+1),file:a})))}function xN(e){return new Promise((t,n)=>e.file(t,n))}async function WS(e,t=""){const n=e.createReader(),s=[];for(;;){const l=await new Promise((u,c)=>n.readEntries(u,c));if(!l.length)break;s.push(...l)}return(await Promise.all(s.map(async l=>{const u=t?`${t}/${l.name}`:l.name;return l.isDirectory?WS(l,u):[{path:u,file:await xN(l)}]}))).flat()}async function yN(e){const t=[...e.items].filter(s=>s.kind==="file").map(s=>{var a;return((a=s.webkitGetAsEntry)==null?void 0:a.call(s))??null}).filter(s=>!!s);if(t.length!==1||!t[0].isDirectory)throw new Error("Drop exactly one skill folder.");const n=t[0];return GS(n.name,await WS(n))}function _N({selectedDirectory:e,onSelect:t,onRemove:n,onRefresh:s,onInstall:a}){const[l,u]=L.useState(!1),[c,d]=L.useState(!1),[f,p]=L.useState(""),m=L.useRef(null);L.useEffect(()=>{var C;(C=m.current)==null||C.setAttribute("webkitdirectory","")},[]);const x=async C=>{if(!window.confirm("Skills may contain instructions and scripts. Select this folder for discovery without executing package content?"))return;const S=await t(C);if(S&&!S.success){p(S.error??"Cannot use selected folder.");return}u(!1)},y=async C=>{d(!0),p("");const b=await a(C);d(!1),b.success||p(b.error??"Failed to install skill package.")},w=async C=>{if(C.preventDefault(),!(!(e!=null&&e.available)||c))try{await y(await yN(C.dataTransfer))}catch(b){p(b instanceof Error?b.message:"Invalid skill folder.")}};return o.jsxs("section",{className:"mb-4 rounded border border-border bg-bg-tertiary/30 p-3",children:[o.jsxs("div",{className:"flex items-start justify-between gap-3",children:[o.jsxs("div",{className:"min-w-0",children:[o.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Skills folder"}),o.jsx("p",{className:"mt-1 truncate text-xs text-text-muted",children:(e==null?void 0:e.configuredPath)??"No shared folder selected"})]}),o.jsxs("div",{className:"flex shrink-0 gap-2",children:[o.jsx(Ve,{variant:"secondary",onClick:()=>u(!0),children:"Change folder"}),e&&o.jsxs(o.Fragment,{children:[o.jsx(Ve,{variant:"secondary",onClick:s,children:"Refresh"}),e.custom&&o.jsx(Ve,{variant:"secondary",onClick:n,children:"Use default"})]})]})]}),o.jsx("button",{type:"button",disabled:!(e!=null&&e.available)||c,onClick:()=>{var C;return(C=m.current)==null?void 0:C.click()},onDragOver:C=>C.preventDefault(),onDrop:w,className:"mt-3 w-full rounded border border-dashed border-border px-4 py-5 text-center text-xs text-text-secondary disabled:cursor-not-allowed disabled:opacity-50",children:e!=null&&e.available?c?"Installing skill package...":"Drop one skill folder here":"Choose a skills folder to enable drag and drop."}),o.jsx("input",{ref:m,hidden:!0,type:"file",multiple:!0,onChange:C=>{var b;if((b=C.target.files)!=null&&b.length)try{y(gN(C.target.files))}catch(S){p(S instanceof Error?S.message:"Invalid skill folder.")}finally{C.target.value=""}}}),f&&o.jsx("p",{className:"mt-2 text-xs text-error",children:f}),l&&o.jsx(Zu,{initialPath:(e==null?void 0:e.resolvedPath)??void 0,onSelect:x,onClose:()=>u(!1)})]})}function Rp({enabled:e,onClick:t,label:n}){return o.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":n,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 qS({isBuiltIn:e,isConfirmingDelete:t,onView:n,onEdit:s,onDuplicate:a,onDelete:l,actions:u,children:c}){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:c}),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(wu,{})}),o.jsx(Cu,{onClick:a}),!e&&s&&o.jsx(Fs,{onClick:s}),!e&&l&&(t?o.jsx(Tp,{onConfirm:()=>{l==null||l()},onCancel:()=>{}}):o.jsx(Ap,{onClick:()=>l==null?void 0:l()})),u]})]})}function bN({id:e,name:t,description:n,isBuiltIn:s,isConfirmingDelete:a,onView:l,onEdit:u,onDuplicate:c,onDelete:d,actions:f}){return o.jsxs(qS,{isBuiltIn:s,isConfirmingDelete:a,onView:l,onEdit:u,onDuplicate:c,onDelete:d,actions:f,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 Qb({skill:e,isBuiltIn:t,isConfirmingDelete:n,onView:s,onEdit:a,onDuplicate:l,onDelete:u,onToggle:c,readOnly:d=!1}){return o.jsx(bN,{id:e.id,name:e.name,description:e.description,isBuiltIn:t,isConfirmingDelete:n,onView:s,onEdit:d?void 0:a,onDuplicate:l,onDelete:d?void 0:u,actions:o.jsx(Rp,{enabled:e.enabled,onClick:c,label:`Activation for ${e.name}`})})}function vN({skill:e,deleting:t,error:n,onClose:s,onConfirm:a}){return o.jsxs(jt,{isOpen:e!==null,onClose:s,title:"Delete skill?",size:"sm",closeOnBackdropClick:!t,closeOnEscape:!t,footer:o.jsxs("div",{className:"flex justify-end gap-2",children:[o.jsx(Ve,{variant:"secondary",onClick:s,disabled:t,children:"Cancel"}),o.jsx(Ve,{variant:"danger",onClick:a,disabled:t,children:t?"Deleting...":"Delete skill"})]}),children:[o.jsx("p",{className:"text-sm font-medium text-text-primary",children:"This skill files will be deleted."}),o.jsx("p",{className:"mt-2 text-sm text-text-secondary",children:"The full skill folder and all its contents will be removed."}),e&&o.jsx("p",{className:"mt-3 break-all font-mono text-xs text-text-muted",children:e.path}),n&&o.jsx("p",{className:"mt-3 text-sm text-error",children:n})]})}function SN({isOpen:e}){const t=gn(te=>te.defaults),n=gn(te=>te.userItems),s=gn(te=>te.projectItems),a=gn(te=>te.items),l=gn(te=>te.selectedDirectory),u=gn(te=>te.diagnostics),c=gn(te=>te.loading),d=gn(te=>te.fetchSkills),f=gn(te=>te.fetchSkill),p=gn(te=>te.fetchDefaultContent),m=gn(te=>te.createSkill),x=gn(te=>te.updateSkill),y=gn(te=>te.deleteSkill),w=gn(te=>te.selectDirectory),C=gn(te=>te.removeDirectory),b=gn(te=>te.installSkill),S=gn(te=>te.toggleSkill),[v,_]=L.useState(null),[E,j]=L.useState(!1),[T,R]=L.useState(""),{view:A,editingId:D,formError:$,saving:q,formData:G,setView:I,setEditingId:U,setFormError:V,setFormData:z,setSaving:J}=VS(),{clearConfirm:Z}=Qu();L.useEffect(()=>{e&&(d(),I("list"),U(null),Z())},[e,d,Z]);const H=(te,se,xe,le)=>{z({name:le??te.metadata.name,id:xe??te.metadata.id,description:te.metadata.description??"",version:te.metadata.version??"1.0.0",prompt:te.prompt,isReadOnly:se,destination:"user"})},O=async te=>{if(t.some(xe=>xe.id===te)){const xe=await p(te);if(!xe)return;H(xe,!0),U(te),V(""),I("edit")}else{const xe=await f(te);if(!xe)return;H(xe,!0),U(te),V(""),I("edit")}},B=async te=>{const xe=t.some(Ee=>Ee.id===te)?await p(te):await f(te);if(!xe)return;const le=`${te}-copy-${Date.now()}`;H(xe,!1,le,`${xe.metadata.name} (copy)`),U(null),V(""),I("edit")},W=()=>{z({name:"",id:"",description:"",version:"1.0.0",prompt:"",isReadOnly:!1,destination:"user"}),I("edit")},P=async te=>{const se=await f(te);se&&(H(se,!1),U(te),V(""),I("edit"))},ee=async()=>{if(!v)return;j(!0),R("");const te=await y(v.id);if(j(!1),!te.success){R(te.error??"Failed to delete skill.");return}await d(),_(null),Z()},X=async()=>{const te=D??G.id;if(!te||!G.name||!G.prompt){V("Name, ID, and prompt are required.");return}J(!0),V("");const se={metadata:{id:te,name:G.name,description:G.description,version:G.version},prompt:G.prompt},xe=D?await x(D,se):await m(se,G.destination);if(J(!1),!xe.success){V(xe.error??"Failed to save skill.");return}I("list")},ne=te=>{z(se=>({...se,name:te})),D||z(se=>({...se,id:te.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}))},Y=G.isReadOnly;if(A==="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:Y?G.name:D?"Edit Skill":"New Skill"}),o.jsx("button",{onClick:()=>I("list"),className:"text-text-muted hover:text-text-primary",children:"Cancel"})]}),$&&o.jsx(Ju,{message:$}),o.jsxs("div",{className:"space-y-3 mb-3",children:[o.jsx(FS,{name:G.name,id:G.id,nameLabel:"Name",idLabel:"ID",namePlaceholder:"My Skill",idPlaceholder:"my-skill",readOnlyId:!0,onNameChange:ne,onIdChange:()=>{}}),o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsx(vr,{label:"Description",value:G.description,onChange:te=>z(se=>({...se,description:te})),placeholder:"What this skill does...",readOnly:Y}),o.jsx(vr,{label:"Version",value:G.version,onChange:te=>z(se=>({...se,version:te})),placeholder:"1.0.0",readOnly:Y})]})]}),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:G.prompt,onChange:te=>z(se=>({...se,prompt:te.target.value})),readOnly:Y,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"})]}),!D&&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:G.destination,onChange:te=>z(se=>({...se,destination:te.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(Ve,{variant:"secondary",onClick:()=>I("list"),children:"Cancel"}),Y?o.jsx(Ve,{variant:"primary",onClick:()=>{z(te=>({...te,name:te.name+" (copy)",id:`${D}-copy-${Date.now()}`,isReadOnly:!1})),U(null)},children:"Duplicate & Customize"}):o.jsx(Ve,{variant:"primary",onClick:X,disabled:q||!G.name||!G.id||!G.prompt,children:q?"Saving...":"Save"})]})]});function F({items:te}){return te.map(se=>o.jsx(Qb,{skill:se,isBuiltIn:!1,isConfirmingDelete:!1,onView:()=>O(se.id),onEdit:()=>P(se.id),onDuplicate:()=>B(se.id),onDelete:()=>{R(""),_(se)},onToggle:()=>S(se.id),readOnly:se.readOnly},se.id))}return o.jsxs("div",{children:[o.jsx(vN,{skill:v,deleting:E,error:T,onClose:()=>{E||_(null)},onConfirm:ee}),o.jsx(_N,{selectedDirectory:l,onSelect:w,onRemove:C,onRefresh:d,onInstall:b}),u.length>0&&o.jsx("div",{className:"mb-3 rounded border border-accent-warning/40 bg-accent-warning/10 p-2 text-xs text-text-secondary",children:u.map((te,se)=>o.jsx("p",{children:te},`${te}-${se}`))}),o.jsx(US,{description:"Skills provide domain-specific knowledge that agents can load on demand.",onNew:W}),o.jsxs(Lp,{loading:c,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(te=>o.jsx(Qb,{skill:te,isBuiltIn:!0,isConfirmingDelete:!1,onView:()=>O(te.id),onDuplicate:()=>B(te.id),onToggle:()=>S(te.id)},te.id))})]}),n.length>0&&o.jsx(HS,{children:o.jsx(F,{items:n})}),a.some(te=>["global-shared","selected","project-shared"].includes(te.source))&&o.jsxs("div",{className:"mt-4",children:[o.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Shared"}),o.jsx("div",{className:"space-y-2",children:o.jsx(F,{items:a.filter(te=>["global-shared","selected","project-shared"].includes(te.source))})})]}),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(F,{items:s})})]})]})]})}function jl(){const e=qt(a=>a.settings),t=qt(a=>a.loading),n=qt(a=>a.getSetting),s=qt(a=>a.setSetting);return{settings:e,loading:t,getSetting:n,setSetting:s}}function wN({isOpen:e}){const{settings:t,loading:n,getSetting:s,setSetting:a}=jl(),l=t[Oe.GLOBAL_INSTRUCTIONS]??"",u=n[Oe.GLOBAL_INSTRUCTIONS]??!1,[c,d]=L.useState(l),[f,p]=L.useState(!1),[m,x]=L.useState(!1);L.useEffect(()=>{e&&s(Oe.GLOBAL_INSTRUCTIONS)},[e,s]),L.useEffect(()=>{d(l),p(!1)},[l]);const y=async()=>{x(!0),await a(Oe.GLOBAL_INSTRUCTIONS,c),x(!1),p(!1)},w=()=>{d(l),p(!1)},C=u||m;return o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm font-medium text-text-primary mb-2",children:"Global Instructions"}),o.jsx("p",{className:"text-sm text-text-muted mb-2",children:"These instructions are injected into every prompt, regardless of project."}),o.jsx("textarea",{value:c,onChange:b=>{d(b.target.value),p(!0)},placeholder:"Enter global instructions that apply to all projects...",className:"w-full min-h-80 px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono resize-y focus:outline-none focus:ring-1 focus:ring-accent-primary",disabled:C})]}),o.jsxs("div",{className:"flex justify-end gap-2",children:[o.jsx(Ve,{variant:"secondary",onClick:w,disabled:!f,children:"Discard"}),o.jsx(Ve,{variant:"primary",onClick:y,disabled:!f||C,children:m?"Saving...":"Save"})]})]})}function CN(e){const t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(t){const n=parseInt(t[1]??"0",16),s=parseInt(t[2]??"0",16),a=parseInt(t[3]??"0",16);return`${n} ${s} ${a}`}return e}function vi(e){const t=e.split(" ").map(n=>parseInt(n,10));return t.length===3&&t.every(n=>!isNaN(n))?`#${t.map(n=>(n??0).toString(16).padStart(2,"0")).join("")}`:e}function kN({isOpen:e,isNew:t,basePresetId:n,presetName:s,initialTokens:a,onClose:l,onSave:u}){const[c,d]=L.useState(a),[f,p]=L.useState(s);L.useEffect(()=>{d(a),p(s)},[a,s]);const m=(b,S)=>{const v=S.startsWith("#")?CN(S):S;d(_=>({..._,[b]:v}))},x=()=>{u(f.trim()||"Untitled",{...c})},y=NS.reduce((b,S)=>{const v=S.category;return b[v]||(b[v]=[]),b[v].push(S),b},{}),w={background:"Backgrounds",surface:"Surfaces",text:"Text",accent:"Accents",border:"Border"},C=Ir.find(b=>b.id===n);return o.jsx(jt,{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:x,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:b=>p(b.target.value),className:"w-full px-3 py-2 bg-bg-tertiary border border-border rounded text-sm text-text-primary focus:outline-none focus:ring-1 focus:ring-accent-primary"})]}),!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(y).map(([b,S])=>o.jsxs("div",{className:"space-y-3",children:[o.jsx("h4",{className:"text-xs font-medium text-text-muted uppercase",children:w[b]??b}),o.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:S.map(v=>o.jsxs("div",{className:"flex flex-col gap-1",children:[o.jsx("label",{htmlFor:v.key,className:"text-xs text-text-muted",children:v.label}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("input",{type:"color",id:v.key,value:vi(c[v.key]??v.defaultValue),onChange:_=>m(v.key,_.target.value),className:"w-8 h-8 rounded cursor-pointer border border-border bg-transparent flex-shrink-0"}),o.jsx("input",{type:"text",value:c[v.key]??v.defaultValue,onChange:_=>m(v.key,_.target.value),className:"flex-1 min-w-0 px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary font-mono focus:outline-none focus:ring-1 focus:ring-accent-primary"})]})]},v.key))})]},b))]})})}function EN(){const[e,t]=L.useState(null),n=Ht(_=>_.currentPreset),s=Ht(_=>_.isCustom),a=Ht(_=>_.basePreset),l=Ht(_=>_.isSystem),u=Ht(_=>_.applyPreset),c=Ht(_=>_.applyUserPreset),d=Ht(_=>_.deleteUserPreset),f=Ht(_=>_.saveTheme),p=Ht(_=>_.userPresets),m=_=>{_==="system"?(u(_),f(JSON.stringify({preset:"system"})).catch(()=>{})):(u(_),f(JSON.stringify({preset:_})).catch(()=>{}))},x=_=>{c(_)},y=_=>{const E=Ir.find(j=>j.id===_);E&&t({type:"new",presetIndex:p.length,basePresetId:_,presetName:E.name+" Copy",tokens:{...E.tokens}})},w=_=>{const E=p[_];if(!E)return;const j=Ir.find(R=>R.id===E.basePreset),T=j?{...j.tokens,...E.tokens}:E.tokens;t({type:"edit",presetIndex:_,basePresetId:E.basePreset,presetName:E.name,tokens:T})},C=(_,E)=>{if(!e)return;const j=[...p];if(e.type==="new"){const T={id:"custom-"+Date.now(),name:_,basePreset:e.basePresetId,tokens:E};j.push(T);const R=j.length-1;Ht.setState({userPresets:j}),Ht.getState().saveUserPresets(),Ht.getState().applyUserPreset(R)}else{const T=j[e.presetIndex];T&&(j[e.presetIndex]={...T,name:_,tokens:E}),Ht.setState({userPresets:j}),Ht.getState().saveUserPresets(),Ht.getState().applyUserPreset(e.presetIndex)}t(null)},b=()=>{t(null)},S=(_,E)=>{_.stopPropagation(),d(E)},v=l?"system":s?a:n;return o.jsxs("div",{className:"space-y-4",children:[o.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Theme"}),o.jsx("div",{className:"flex flex-wrap gap-2 pb-2",children:Ir.map(_=>{const E=_.id===v&&!s;return o.jsxs("div",{className:"relative group",children:[o.jsxs("button",{type:"button",onClick:()=>m(_.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:_.id==="system"?"transparent":vi(_.tokens["color-bg-primary"]??"#000"),borderColor:vi(_.tokens["color-border"]??"#000")},children:_.id==="system"?o.jsx("div",{className:"w-4 h-4 rounded-full",style:{background:"linear-gradient(135deg, #000 50%, #fff 50%)"}}):o.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:vi(_.tokens["color-text-primary"]??"#fff")}})}),o.jsx("span",{className:"text-xs",children:_.name})]}),_.id!=="system"&&o.jsx("button",{type:"button",onClick:j=>{j.stopPropagation(),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:"✎"})})]},_.id)})}),p.length>0&&o.jsxs(o.Fragment,{children:[o.jsx("h4",{className:"text-xs font-medium text-text-muted uppercase",children:"My Themes"}),o.jsx("div",{className:"grid grid-cols-5 gap-2",children:p.map((_,E)=>{const j=Ir.find(R=>R.id===_.basePreset),T=j?{...j.tokens,..._.tokens}:_.tokens;return o.jsxs("div",{className:"relative group",children:[o.jsxs("button",{type:"button",onClick:()=>x(E),className:`w-full flex flex-col items-center gap-2 px-3 py-3 rounded-lg border transition-colors ${s&&a===_.basePreset&&v===_.basePreset?"border-accent-primary bg-bg-tertiary text-text-primary":"border-border bg-bg-secondary text-text-muted hover:border-text-muted"}`,children:[o.jsx("div",{className:"w-8 h-8 rounded border flex items-center justify-center",style:{backgroundColor:vi(T["color-bg-primary"]??"#000"),borderColor:vi(T["color-border"]??"#000")},children:o.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:vi(T["color-text-primary"]??"#fff")}})}),o.jsx("span",{className:"text-xs truncate w-full text-center",children:_.name})]}),o.jsx("button",{type:"button",onClick:R=>{R.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:R=>S(R,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(qa,{className:"w-3 h-3"})})]},_.id)})})]}),e&&o.jsx(kN,{isOpen:!0,isNew:e.type==="new",presetIndex:e.presetIndex,basePresetId:e.basePresetId,presetName:e.presetName,initialTokens:e.tokens,onClose:b,onSave:C})]})}function jN(){return o.jsx(EN,{})}function NN(){const{settings:e,loading:t,getSetting:n,setSetting:s}=jl(),a=t[Oe.DISPLAY_SHOW_THINKING]??!1,l=e[Oe.DISPLAY_MAX_VISIBLE_ITEMS]??"300",[u,c]=L.useState(l);L.useEffect(()=>{n(Oe.DISPLAY_MAX_VISIBLE_ITEMS)},[n]),L.useEffect(()=>{c(l)},[l]);const d=()=>{const w=parseInt(u,10),C=isNaN(w)||w<0?0:Math.min(w,9999);c(String(C)),s(Oe.DISPLAY_MAX_VISIBLE_ITEMS,String(C))},f=[{key:Oe.DISPLAY_SHOW_THINKING,label:"Show thinking blocks",description:"Display AI reasoning content in the feed"},{key:Oe.DISPLAY_SHOW_VERBOSE_TOOL_OUTPUT,label:"Show expanded tool output",description:"Always show full tool call details instead of compact view"},{key:Oe.DISPLAY_SHOW_STATS,label:"Show stats bar",description:"Display model, tokens, and timing information"},{key:Oe.DISPLAY_SHOW_AGENT_DEFINITIONS,label:"Show agent definitions",description:"Display agent definition injections in the feed"},{key:Oe.DISPLAY_SHOW_WORKFLOW_BARS,label:"Show workflow bars",description:"Display workflow start and end markers"},{key:Oe.DISPLAY_SHOW_SYNTAX_HIGHLIGHTING,label:"Show syntax highlighting",description:"Nicer formatting, but costly - applies to code blocks, diffs, and file previews"}],p=Object.fromEntries(f.map(w=>[w.key,e[w.key]??"true"])),[m,x]=L.useState(()=>Object.fromEntries(f.map(w=>[w.key,p[w.key]==="true"])));L.useEffect(()=>{f.forEach(w=>n(w.key))},[n]),L.useEffect(()=>{x(Object.fromEntries(f.map(w=>[w.key,p[w.key]==="true"])))},[JSON.stringify(p)]);const y=async w=>{const C=String(!m[w]);x(b=>({...b,[w]:!b[w]})),await s(w,C)};return a?o.jsx("div",{className:"text-sm text-text-muted",children:"Loading..."}):o.jsxs("div",{className:"space-y-6",children:[o.jsx(jN,{}),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:f.map(({key:w,label:C,description:b})=>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:C}),o.jsx("div",{className:"text-xs text-text-muted mt-0.5",children:b})]}),o.jsx("button",{type:"button",onClick:()=>y(w),className:`relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors ${m[w]?"bg-accent-primary":"bg-bg-tertiary"}`,children:o.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${m[w]?"translate-x-6":"translate-x-1"}`})})]},w))})]}),o.jsx("div",{className:"border-t border-border pt-4",children:o.jsxs("label",{className:"flex items-center justify-between gap-3",children:[o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"text-sm text-text-primary font-medium",children:"Max visible items"}),o.jsx("div",{className:"text-xs text-text-muted mt-0.5",children:"Keep only the last N items in the feed. Set to 0 to show all."})]}),o.jsx("input",{type:"number",min:0,max:9999,value:u,onChange:w=>{const C=w.target.value.replace(/[^0-9]/g,"");c(C)},onBlur:d,onKeyDown:w=>{w.key==="Enter"&&d()},className:"w-20 px-2 py-1 text-sm text-text-primary bg-bg-tertiary border border-border rounded text-right"})]})})]})}function TN(e){try{return new RegExp(e),!0}catch{return!1}}function AN({value:e,onChange:t}){const[n,s]=L.useState({}),a=(d,f)=>{const p=e.patterns.map((m,x)=>x===d?{...m,...f}:m);t({...e,patterns:p})},l=d=>{const f=e.patterns.filter((p,m)=>m!==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(p=>({...p,[d]:f.length>0&&!TN(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),p=isNaN(f)?10:Math.max(1,Math.min(100,f));t({...e,maxRetriesPerTurn:p})},className:"mt-1 block w-24 px-2 py-1 text-sm bg-bg-secondary border border-border rounded"})]}),e.patterns.length===0?o.jsx("p",{className:"text-sm text-text-muted",children:"No retry patterns configured."}):o.jsxs("table",{className:"w-full text-sm",children:[o.jsx("thead",{children:o.jsxs("tr",{className:"text-left text-text-muted border-b border-border",children:[o.jsx("th",{className:"pb-2 pr-2 w-12",children:"Active"}),o.jsx("th",{className:"pb-2 pr-2",children:"Field"}),o.jsx("th",{className:"pb-2 pr-2",children:"Pattern"}),o.jsx("th",{className:"pb-2 pr-2",children:"Action"}),o.jsx("th",{className:"pb-2 w-8"})]})}),o.jsx("tbody",{children:e.patterns.map((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:p=>a(f,{field:p.target.value}),className:"px-2 py-1 bg-bg-secondary border border-border rounded text-sm",children:[o.jsx("option",{value:"content",children:"content"}),o.jsx("option",{value:"thinking",children:"thinking"}),o.jsx("option",{value:"both",children:"both"})]})}),o.jsx("td",{className:"py-2 pr-2",children:o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("input",{type:"text",value:d.pattern,onChange:p=>c(f,p.target.value),placeholder:"regex pattern",className:"flex-1 px-2 py-1 bg-bg-secondary border border-border rounded text-sm font-mono"}),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(Ve,{variant:"secondary",onClick:u,children:"Add Pattern"})]})}function LN({onClose:e}){const[,t]=Yn(),{settings:n,getSetting:s,setSetting:a}=jl(),l=n[Oe.DISPLAY_SHOW_OPEN_IN_EDITOR]==="true",u=n[Oe.LLM_DYNAMIC_SYSTEM_PROMPT]==="true",c=n[Oe.CACHE_WARMING]==="true",[d,f]=L.useState({openInEditor:l,dynamicPrompt:u,cacheWarming:c}),[p,m]=L.useState({patterns:[],maxRetriesPerTurn:10});L.useEffect(()=>{f({openInEditor:l,dynamicPrompt:u,cacheWarming:c})},[l,u,c]),L.useEffect(()=>{s(Oe.DISPLAY_SHOW_OPEN_IN_EDITOR),s(Oe.LLM_DYNAMIC_SYSTEM_PROMPT),s(Oe.CACHE_WARMING),s(Oe.RETRY_PATTERNS)},[s]),L.useEffect(()=>{const S=n[Oe.RETRY_PATTERNS];if(S)try{m(JSON.parse(S))}catch{}},[n]);const x=L.useCallback(S=>{m(S),a(Oe.RETRY_PATTERNS,JSON.stringify(S))},[a]),y=()=>{const S=!d.openInEditor;f(v=>({...v,openInEditor:S})),a(Oe.DISPLAY_SHOW_OPEN_IN_EDITOR,String(S))},w=()=>{const S=!d.dynamicPrompt;f(v=>({...v,dynamicPrompt:S})),a(Oe.LLM_DYNAMIC_SYSTEM_PROMPT,String(S))},C=()=>{const S=!d.cacheWarming;f(v=>({...v,cacheWarming:S})),a(Oe.CACHE_WARMING,String(S))};function b(){e(),t("/onboarding")}return o.jsxs("div",{className:"space-y-6",children:[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:"Manage providers, workdir and vision fallback."}),o.jsx(Ve,{variant:"secondary",onClick:b,children:"Launch Onboarding"})]}),o.jsx("hr",{className:"border-border"}),o.jsx("div",{children:o.jsx(Kf,{title:'Show "Open in VSCode" links',description:"Display a link on file reads to open the file directly in VS Code.",enabled:d.openInEditor,onToggle:y})}),o.jsx("hr",{className:"border-border"}),o.jsx(Kf,{title:"Speculative Cache Warming",description:"On first keystroke in an empty session, prefill the LLM KV cache to reduce time-to-first-token.",enabled:d.cacheWarming,onToggle:C,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-sm text-text-muted mb-3",children:'Define regex patterns that, when matched against LLM responses mid-stream, trigger an automatic retry with a "continue" prompt. The content that triggered the match is preserved in the chat feed.'}),o.jsx(AN,{value:p,onChange:x})]}),o.jsx("hr",{className:"border-border"}),o.jsx(Kf,{title:"Dynamic System Prompt",description:"Rebuild the system prompt on every turn. Recommended value: off.",enabled:d.dynamicPrompt,onToggle:w,boldTitle:!0})]})}function Kf({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-sm text-text-muted mt-0.5",children:t})]}),o.jsx("div",{className:"flex-shrink-0",children:o.jsx(Rp,{enabled:n,onClick:s})})]})}function RN({label:e,binding:t,isRecording:n,onStartRecording:s,onBindingRecorded:a,onCancelRecording:l}){const u=L.useRef(null),c=L.useRef(0),d=L.useRef("");return L.useEffect(()=>{if(!n)return;const f=new Set(["Control","Shift","Alt","Meta"]);let p=[];const m=y=>{if(y.preventDefault(),y.stopPropagation(),y.key==="Escape"){l();return}if(f.has(y.key)){y.ctrlKey&&!p.includes("ctrl")&&p.push("ctrl"),y.metaKey&&!p.includes("meta")&&p.push("meta"),y.altKey&&!p.includes("alt")&&p.push("alt"),y.shiftKey&&!p.includes("shift")&&p.push("shift");return}if(p.length>0||y.ctrlKey||y.metaKey||y.altKey||y.shiftKey){const b=[...p];y.ctrlKey&&!b.includes("ctrl")&&b.push("ctrl"),y.metaKey&&!b.includes("meta")&&b.push("meta"),y.altKey&&!b.includes("alt")&&b.push("alt"),y.shiftKey&&!b.includes("shift")&&b.push("shift"),a({type:"chord",key:qb(y),modifiers:b});return}const w=Date.now(),C=qb(y);if(C===d.current&&w-c.current<400){a({type:"double-press",key:C,threshold:300});return}c.current=w,d.current=C},x=y=>{y.key==="Control"&&(p=p.filter(w=>w!=="ctrl")),y.key==="Shift"&&(p=p.filter(w=>w!=="shift")),y.key==="Alt"&&(p=p.filter(w=>w!=="alt")),y.key==="Meta"&&(p=p.filter(w=>w!=="meta"))};return window.addEventListener("keydown",m,!0),window.addEventListener("keyup",x,!0),()=>{window.removeEventListener("keydown",m,!0),window.removeEventListener("keyup",x,!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:MS(t)})})]})}function DN(){const{settings:e,loading:t,setSetting:n}=jl(),s=e[Oe.KEYBINDINGS],a=t[Oe.KEYBINDINGS]??!1,l=Hm(s),[u,c]=L.useState(null),d=[{id:"terminalToggle",label:"Toggle Terminal",binding:l.terminalToggle},{id:"quickAction",label:"Quick Action",binding:l.quickAction},...l.agentSwitching.map((x,y)=>({id:`agentSwitching.${y}`,label:`Switch to Agent ${y+1}`,binding:x}))],f=x=>{c(x)},p=L.useCallback(x=>{if(!u)return;const y=Hm(s),w=structuredClone(y);if(u.startsWith("agentSwitching.")){const C=parseInt(u.split(".")[1],10);w.agentSwitching[C]=x}else u==="terminalToggle"?w.terminalToggle=x:u==="quickAction"&&(w.quickAction=x);c(null),n(Oe.KEYBINDINGS,JSON.stringify(w))},[u,s,n]),m=()=>{n(Oe.KEYBINDINGS,JSON.stringify(Da))};return o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"flex items-center justify-between mb-2",children:[o.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Keyboard Shortcuts"}),o.jsx("button",{type:"button",onClick:m,disabled:a,className:"text-xs text-text-muted hover:text-text-primary px-2 py-1 rounded hover:bg-bg-tertiary transition-colors disabled:opacity-30",children:"Reset to defaults"})]}),a?o.jsx("div",{className:"text-sm text-text-muted",children:"Loading..."}):o.jsx("div",{className:"space-y-1",children:d.map(x=>o.jsx(RN,{label:x.label,binding:x.binding,isRecording:u===x.id,onStartRecording:()=>f(x.id),onBindingRecorded:p,onCancelRecording:()=>c(null)},x.id))})]})}function Jb(e){return e>=1e3?`~${(e/1e3).toFixed(1)}K`:`~${e}`}function Yf(e,t,n,s=250){const a=L.useRef(!0);L.useEffect(()=>{if(a.current){a.current=!1;return}const l=setTimeout(()=>{n(t,e)},s);return()=>clearTimeout(l)},[e,t,s,n])}function Zb(){const[e,t]=L.useState("Test"),[n,s]=L.useState(""),[a,l]=L.useState(!1),u=L.useCallback(async c=>{t("Testing..."),s(""),l(!1);try{const d=await c();d.success?(t("Success"),l(!0),setTimeout(()=>{t("Test"),l(!1)},3e3)):(s(d.error??"Test failed"),t("Test"))}catch{s("Connection error"),t("Test")}},[]);return[e,n,a,u]}function ON(){const{settings:e,getSetting:t,setSetting:n}=jl(),[s,a]=L.useState(""),[l,u]=L.useState(""),[c,d]=L.useState(""),[f,p]=L.useState("");Yf(l,Oe.SEARCH_TAVILY_API_KEY,n),Yf(c,Oe.SEARCH_SEARXNG_URL,n),Yf(f,Oe.SEARCH_SEARXNG_API_KEY,n);const[m,x,y,w]=Zb(),[C,b,S,v]=Zb();L.useEffect(()=>{t(Oe.SEARCH_ENGINE),t(Oe.SEARCH_TAVILY_API_KEY),t(Oe.SEARCH_SEARXNG_URL),t(Oe.SEARCH_SEARXNG_API_KEY)},[t]),L.useEffect(()=>{e[Oe.SEARCH_ENGINE]!==void 0&&(a(e[Oe.SEARCH_ENGINE]??""),u(e[Oe.SEARCH_TAVILY_API_KEY]??""),d(e[Oe.SEARCH_SEARXNG_URL]??""),p(e[Oe.SEARCH_SEARXNG_API_KEY]??""))},[e]);function _(le){a(le),n(Oe.SEARCH_ENGINE,le)}function E(){w(async()=>(await Te("/api/search/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({engine:"tavily",tavilyApiKey:l||void 0})})).json())}function j(){v(async()=>(await Te("/api/search/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({engine:"searxng",searxngUrl:c||void 0,searxngApiKey:f||void 0})})).json())}const[T,R]=L.useState([]),[A,D]=L.useState(!0),[$,q]=L.useState(!1),[G,I]=L.useState(new Set),[U,V]=L.useState(new Set),[z,J]=L.useState({name:"",transport:"stdio",command:"",args:"",env:"",url:"",headers:""}),[Z,H]=L.useState(""),[O,B]=L.useState(!1),{requestDelete:W,clearConfirm:P,isConfirming:ee}=Qu(),X=L.useCallback(async()=>{try{const Ee=await(await Te("/api/mcp/servers")).json();R(Ee.servers??[])}catch{}D(!1)},[]);L.useEffect(()=>{X()},[X]),L.useEffect(()=>{const le=()=>X();return window.addEventListener("mcp-servers-changed",le),()=>window.removeEventListener("mcp-servers-changed",le)},[X]);const ne=le=>{I(Ee=>{const ue=new Set(Ee);return ue.has(le)?ue.delete(le):ue.add(le),ue})},Y=async()=>{if(H(""),!z.name){H("Name is required");return}if(z.transport==="stdio"&&!z.command){H("Command is required for stdio transport");return}if(z.transport==="http"&&!z.url){H("URL is required for HTTP transport");return}B(!0);try{const le=ae=>{const de={};return ae.split(`
|
|
60
|
+
`).filter(Boolean).forEach(oe=>{const Ne=oe.indexOf("=");Ne>0&&(de[oe.slice(0,Ne).trim()]=oe.slice(Ne+1).trim())}),de},Ee={name:z.name,transport:z.transport};if(z.transport==="stdio"){Ee.command=z.command;const ae=z.args?z.args.split(" ").filter(Boolean):void 0;ae&&ae.length>0&&(Ee.args=ae);const de=le(z.env);Object.keys(de).length>0&&(Ee.env=de)}else{Ee.url=z.url;const ae=le(z.headers);Object.keys(ae).length>0&&(Ee.headers=ae)}const ue=await Te("/api/mcp/servers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Ee)});if(!ue.ok){const ae=await ue.json();throw new Error(ae.error??"Failed to add server")}q(!1),J({name:"",transport:"stdio",command:"",args:"",env:"",url:"",headers:""}),await X()}catch(le){H(le instanceof Error?le.message:String(le))}finally{B(!1)}},F=async le=>{try{const Ee=await Te(`/api/mcp/servers/${encodeURIComponent(le)}`,{method:"DELETE"});if(!Ee.ok){const ue=await Ee.json();console.error("Failed to remove MCP server:",ue.error)}P(),await X()}catch(Ee){console.error("Failed to remove MCP server:",Ee)}},te=async(le,Ee,ue)=>{try{const ae=await Te(`/api/mcp/servers/${encodeURIComponent(le)}/tools/${encodeURIComponent(Ee)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:ue})});if(!ae.ok){const de=await ae.json();console.error("Failed to toggle tool:",de.error)}await X()}catch(ae){console.error("Failed to toggle tool:",ae)}},se=le=>{switch(le){case"connected":return"text-accent-success";case"error":return"text-accent-error";default:return"text-text-muted"}},xe=le=>{switch(le){case"connected":return"●";case"error":return"●";default:return"○"}};return o.jsxs("div",{className:"space-y-8",children:[o.jsxs("div",{children:[o.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Search Engine"}),o.jsx("p",{className:"text-sm text-text-muted mb-3",children:"Configure a web search engine for the web_search tool."}),o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs font-medium text-text-primary mb-1",children:"Engine"}),o.jsx("div",{className:"flex gap-2",children:["","tavily","searxng"].map(le=>o.jsx("button",{onClick:()=>_(le),className:`px-3 py-1.5 rounded text-sm border transition-colors ${s===le?"bg-accent-primary/10 border-accent-primary text-accent-primary":"border-border text-text-muted hover:text-text-primary"}`,children:le||"Off"},le))})]}),s==="tavily"&&o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs font-medium text-text-primary mb-1",children:"Tavily API Key"}),o.jsxs("div",{className:"flex gap-2 items-center",children:[o.jsx(Ni,{type:"password",value:l,onChange:le=>u(le.target.value),placeholder:"tvly-...",className:"flex-1"}),o.jsx(Ve,{variant:"secondary",onClick:E,style:y?{color:"rgb(63, 185, 80)"}:void 0,children:m})]}),x&&o.jsx("p",{className:"text-xs text-red-500 mt-1",children:x}),o.jsxs("p",{className:"text-xs text-text-muted mt-1",children:["Get a free API key at"," ",o.jsx("a",{href:"https://app.tavily.com",target:"_blank",rel:"noopener noreferrer",className:"text-accent-primary hover:underline",children:"tavily.com"})]})]}),s==="searxng"&&o.jsxs("div",{className:"space-y-3",children:[o.jsxs("div",{children:[o.jsx("label",{className:"block text-xs font-medium text-text-primary mb-1",children:"SearXNG URL"}),o.jsx(Ni,{type:"url",value:c,onChange:le=>d(le.target.value),placeholder:"http://localhost:4000",className:"w-full"})]}),o.jsxs("div",{children:[o.jsxs("label",{className:"block text-xs font-medium text-text-primary mb-1",children:["API Key ",o.jsx("span",{className:"text-text-muted",children:"(optional)"})]}),o.jsx(Ni,{type:"password",value:f,onChange:le=>p(le.target.value),placeholder:"Optional API key",className:"w-full"})]}),o.jsx(Ve,{variant:"secondary",onClick:j,style:S?{color:"rgb(63, 185, 80)"}:void 0,children:C}),b&&o.jsx("p",{className:"text-xs text-red-500",children:b})]})]})]}),o.jsx("hr",{className:"border-border"}),o.jsxs("div",{children:[o.jsxs("div",{className:"flex items-center justify-between mb-3",children:[o.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"MCP Servers"}),o.jsx(Ve,{variant:"primary",size:"sm",onClick:()=>q(!0),children:"+ Add Server"})]}),o.jsx("p",{className:"text-sm text-text-muted mb-3",children:"MCP servers provide external tools that extend OpenFox's capabilities."}),o.jsx(Lp,{loading:A,hasItems:T.length>0,loadingLabel:"Loading MCP servers...",emptyLabel:"No MCP servers configured.",children:T.map(le=>{var Ee;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:()=>ne(le.name),children:[o.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[o.jsx("span",{className:`text-sm ${se(le.status)}`,children:xe(le.status)}),o.jsx("span",{className:"text-sm font-medium text-text-primary",children:le.name}),o.jsx("span",{className:"text-xs text-text-muted",children:le.config.transport}),o.jsxs("span",{className:"text-xs text-text-muted",children:["(",le.tools.length," tools)"]}),o.jsxs("span",{className:"text-xs text-text-muted",children:[Jb(le.estimatedTokens)," tokens"]})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[le.status==="error"&&le.error&&o.jsx("span",{className:"text-xs text-accent-error truncate max-w-[200px]",title:le.error,children:le.error}),o.jsx("span",{className:"text-xs text-text-muted",children:G.has(le.name)?"▲":"▼"})]})]}),G.has(le.name)&&o.jsxs("div",{className:"border-t border-border px-3 py-2 space-y-1.5",children:[le.config.command&&o.jsxs("div",{className:"text-xs text-text-muted font-mono",children:[le.config.command," ",((Ee=le.config.args)==null?void 0:Ee.join(" "))??""]}),le.config.url&&o.jsx("div",{className:"text-xs text-text-muted font-mono",children:le.config.url}),le.tools.length===0?o.jsx("div",{className:"text-xs text-text-muted",children:"No tools available"}):o.jsx("div",{className:"space-y-1",children:le.tools.map(ue=>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:ue.name}),ue.description&&ue.description.length>80?o.jsxs("button",{onClick:()=>{const ae=`${le.name}:${ue.name}`;V(de=>{const oe=new Set(de);return oe.has(ae)?oe.delete(ae):oe.add(ae),oe})},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:ue.description}),o.jsx(On,{rotate:U.has(`${le.name}:${ue.name}`)?180:0,className:"w-3 h-3 flex-shrink-0"})]}):ue.description?o.jsx("span",{className:"text-xs text-text-muted ml-2",children:ue.description}):null]}),o.jsx("span",{className:"text-xs text-text-muted mr-2 flex-shrink-0",children:Jb(ue.estimatedTokens)}),o.jsx(Rp,{enabled:ue.enabled,onClick:()=>te(le.name,ue.name,!ue.enabled)})]}),ue.description&&ue.description.length>80&&U.has(`${le.name}:${ue.name}`)&&o.jsx("div",{className:"text-xs text-text-muted mt-1 ml-1",children:ue.description})]},ue.name))}),o.jsx("div",{className:"pt-2 flex items-center justify-end gap-2",children:ee(le.name,"delete")?o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:ue=>{ue.stopPropagation(),F(le.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:ue=>{ue.stopPropagation(),P()},className:"px-2 py-1 rounded text-xs text-text-muted hover:bg-bg-primary transition-colors",children:"Cancel"})]}):o.jsx("button",{onClick:ue=>{ue.stopPropagation(),W(le.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"})})]})]},le.name)})}),$&&o.jsx(jt,{isOpen:$,onClose:()=>{q(!1),H("")},title:"Add MCP Server",size:"sm",children:o.jsxs("div",{className:"space-y-3",children:[o.jsx(vr,{label:"Name",value:z.name,onChange:le=>J({...z,name:le}),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:()=>J({...z,transport:"stdio"}),className:`px-3 py-1.5 rounded text-xs font-medium transition-colors ${z.transport==="stdio"?"bg-accent-primary text-white":"bg-bg-tertiary text-text-secondary hover:bg-bg-primary"}`,children:"Stdio"}),o.jsx("button",{onClick:()=>J({...z,transport:"http"}),className:`px-3 py-1.5 rounded text-xs font-medium transition-colors ${z.transport==="http"?"bg-accent-primary text-white":"bg-bg-tertiary text-text-secondary hover:bg-bg-primary"}`,children:"HTTP"})]})]}),z.transport==="stdio"?o.jsxs(o.Fragment,{children:[o.jsx(vr,{label:"Command",value:z.command,onChange:le=>J({...z,command:le}),placeholder:"e.g. npx"}),o.jsx(vr,{label:"Arguments",value:z.args,onChange:le=>J({...z,args:le}),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:z.env,onChange:le=>J({...z,env:le.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(vr,{label:"URL",value:z.url,onChange:le=>J({...z,url:le}),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:z.headers,onChange:le=>J({...z,headers:le.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})]})]}),Z&&o.jsx(Ju,{message:Z}),o.jsxs("div",{className:"flex justify-end gap-2 pt-2 border-t border-border",children:[o.jsx(Ve,{variant:"secondary",onClick:()=>{q(!1),H(""),B(!1),J({name:"",transport:"stdio",command:"",args:"",env:"",url:"",headers:""})},disabled:O,children:"Cancel"}),o.jsx(Ve,{variant:"primary",onClick:Y,disabled:O,children:O?"Adding...":"Add"})]})]})})]})]})}function IN({isOpen:e,onClose:t}){const[n,s]=L.useState("instructions"),a=()=>{try{Ut.send("context.checkDynamic",{})}catch{}t()};return o.jsx(jt,{isOpen:e,onClose:a,title:"Settings",size:"xl",minHeight:"500px",children:o.jsxs("div",{"data-global-settings":!0,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(mi,{label:"Instructions",active:n==="instructions",onClick:()=>s("instructions")}),o.jsx(mi,{label:"Tools",active:n==="tools",onClick:()=>s("tools")}),o.jsx(mi,{label:"Skills",active:n==="skills",onClick:()=>s("skills")}),o.jsx(mi,{label:"Notifications",active:n==="notifications",onClick:()=>s("notifications")}),o.jsx(mi,{label:"Display",active:n==="display",onClick:()=>s("display")}),o.jsx(mi,{label:"Keybindings",active:n==="keybindings",onClick:()=>s("keybindings")}),o.jsx(mi,{label:"Advanced",active:n==="advanced",onClick:()=>s("advanced")})]}),n==="instructions"&&o.jsx(wN,{isOpen:e}),n==="skills"&&o.jsx(SN,{isOpen:e}),n==="notifications"&&o.jsx("div",{className:"max-h-[60vh] overflow-y-auto",children:o.jsx(hN,{})}),n==="display"&&o.jsx(NN,{}),n==="keybindings"&&o.jsx(DN,{}),n==="tools"&&o.jsx("div",{className:"max-h-[60vh] overflow-y-auto",children:o.jsx(ON,{})}),n==="advanced"&&o.jsx(LN,{onClose:t})]})})}function mi({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 Xf={exports:{}},ev;function MN(){return ev||(ev=1,(function(e,t){(function(n,s){e.exports=s()})(globalThis,(()=>(()=>{var n={4567:function(u,c,d){var f=this&&this.__decorate||function(v,_,E,j){var T,R=arguments.length,A=R<3?_:j===null?j=Object.getOwnPropertyDescriptor(_,E):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(v,_,E,j);else for(var D=v.length-1;D>=0;D--)(T=v[D])&&(A=(R<3?T(A):R>3?T(_,E,A):T(_,E))||A);return R>3&&A&&Object.defineProperty(_,E,A),A},p=this&&this.__param||function(v,_){return function(E,j){_(E,j,v)}};Object.defineProperty(c,"__esModule",{value:!0}),c.AccessibilityManager=void 0;const m=d(9042),x=d(9924),y=d(844),w=d(4725),C=d(2585),b=d(3656);let S=c.AccessibilityManager=class extends y.Disposable{constructor(v,_,E,j){super(),this._terminal=v,this._coreBrowserService=E,this._renderService=j,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=this._coreBrowserService.mainDocument.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=this._coreBrowserService.mainDocument.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let T=0;T<this._terminal.rows;T++)this._rowElements[T]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[T]);if(this._topBoundaryFocusListener=T=>this._handleBoundaryFocus(T,0),this._bottomBoundaryFocusListener=T=>this._handleBoundaryFocus(T,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=this._coreBrowserService.mainDocument.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new x.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize((T=>this._handleResize(T.rows)))),this.register(this._terminal.onRender((T=>this._refreshRows(T.start,T.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((T=>this._handleChar(T)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
|
|
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,b.addDisposableDomListener)(document,"selectionchange",(()=>this._handleSelectionChange()))),this.register(this._coreBrowserService.onDprChange((()=>this._refreshRowsDimensions()))),this._refreshRows(),this.register((0,y.toDisposable)((()=>{this._accessibilityContainer.remove(),this._rowElements.length=0})))}_handleTab(v){for(let _=0;_<v;_++)this._handleChar(" ")}_handleChar(v){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==v&&(this._charsToAnnounce+=v):this._charsToAnnounce+=v,v===`
|
|
62
|
+
`&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=m.tooMuchOutput)))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(v){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(v)||this._charsToConsume.push(v)}_refreshRows(v,_){this._liveRegionDebouncer.refresh(v,_,this._terminal.rows)}_renderRows(v,_){const E=this._terminal.buffer,j=E.lines.length.toString();for(let T=v;T<=_;T++){const R=E.lines.get(E.ydisp+T),A=[],D=(R==null?void 0:R.translateToString(!0,void 0,void 0,A))||"",$=(E.ydisp+T+1).toString(),q=this._rowElements[T];q&&(D.length===0?(q.innerText=" ",this._rowColumns.set(q,[0,1])):(q.textContent=D,this._rowColumns.set(q,A)),q.setAttribute("aria-posinset",$),q.setAttribute("aria-setsize",j))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(v,_){const E=v.target,j=this._rowElements[_===0?1:this._rowElements.length-2];if(E.getAttribute("aria-posinset")===(_===0?"1":`${this._terminal.buffer.lines.length}`)||v.relatedTarget!==j)return;let T,R;if(_===0?(T=E,R=this._rowElements.pop(),this._rowContainer.removeChild(R)):(T=this._rowElements.shift(),R=E,this._rowContainer.removeChild(T)),T.removeEventListener("focus",this._topBoundaryFocusListener),R.removeEventListener("focus",this._bottomBoundaryFocusListener),_===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(_===0?-1:1),this._rowElements[_===0?1:this._rowElements.length-2].focus(),v.preventDefault(),v.stopImmediatePropagation()}_handleSelectionChange(){var D;if(this._rowElements.length===0)return;const v=document.getSelection();if(!v)return;if(v.isCollapsed)return void(this._rowContainer.contains(v.anchorNode)&&this._terminal.clearSelection());if(!v.anchorNode||!v.focusNode)return void console.error("anchorNode and/or focusNode are null");let _={node:v.anchorNode,offset:v.anchorOffset},E={node:v.focusNode,offset:v.focusOffset};if((_.node.compareDocumentPosition(E.node)&Node.DOCUMENT_POSITION_PRECEDING||_.node===E.node&&_.offset>E.offset)&&([_,E]=[E,_]),_.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(_={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(_.node))return;const j=this._rowElements.slice(-1)[0];if(E.node.compareDocumentPosition(j)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(E={node:j,offset:((D=j.textContent)==null?void 0:D.length)??0}),!this._rowContainer.contains(E.node))return;const T=({node:$,offset:q})=>{const G=$ instanceof Text?$.parentNode:$;let I=parseInt(G==null?void 0:G.getAttribute("aria-posinset"),10)-1;if(isNaN(I))return console.warn("row is invalid. Race condition?"),null;const U=this._rowColumns.get(G);if(!U)return console.warn("columns is null. Race condition?"),null;let V=q<U.length?U[q]:U.slice(-1)[0]+1;return V>=this._terminal.cols&&(++I,V=0),{row:I,column:V}},R=T(_),A=T(E);if(R&&A){if(R.row>A.row||R.row===A.row&&R.column>=A.column)throw new Error("invalid range");this._terminal.select(R.column,R.row,(A.row-R.row)*this._terminal.cols-R.column+A.column)}}_handleResize(v){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let _=this._rowContainer.children.length;_<this._terminal.rows;_++)this._rowElements[_]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[_]);for(;this._rowElements.length>v;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const v=this._coreBrowserService.mainDocument.createElement("div");return v.setAttribute("role","listitem"),v.tabIndex=-1,this._refreshRowDimensions(v),v}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){this._accessibilityContainer.style.width=`${this._renderService.dimensions.css.canvas.width}px`,this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let v=0;v<this._terminal.rows;v++)this._refreshRowDimensions(this._rowElements[v])}}_refreshRowDimensions(v){v.style.height=`${this._renderService.dimensions.css.cell.height}px`}};c.AccessibilityManager=S=f([p(1,C.IInstantiationService),p(2,w.ICoreBrowserService),p(3,w.IRenderService)],S)},3614:(u,c)=>{function d(x){return x.replace(/\r?\n/g,"\r")}function f(x,y){return y?"\x1B[200~"+x+"\x1B[201~":x}function p(x,y,w,C){x=f(x=d(x),w.decPrivateModes.bracketedPasteMode&&C.rawOptions.ignoreBracketedPasteMode!==!0),w.triggerDataEvent(x,!0),y.value=""}function m(x,y,w){const C=w.getBoundingClientRect(),b=x.clientX-C.left-10,S=x.clientY-C.top-10;y.style.width="20px",y.style.height="20px",y.style.left=`${b}px`,y.style.top=`${S}px`,y.style.zIndex="1000",y.focus()}Object.defineProperty(c,"__esModule",{value:!0}),c.rightClickHandler=c.moveTextAreaUnderMouseCursor=c.paste=c.handlePasteEvent=c.copyHandler=c.bracketTextForPaste=c.prepareTextForTerminal=void 0,c.prepareTextForTerminal=d,c.bracketTextForPaste=f,c.copyHandler=function(x,y){x.clipboardData&&x.clipboardData.setData("text/plain",y.selectionText),x.preventDefault()},c.handlePasteEvent=function(x,y,w,C){x.stopPropagation(),x.clipboardData&&p(x.clipboardData.getData("text/plain"),y,w,C)},c.paste=p,c.moveTextAreaUnderMouseCursor=m,c.rightClickHandler=function(x,y,w,C,b){m(x,y,w),b&&C.rightClickSelect(x),y.value=C.selectionText,y.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(p,m,x){this._css.set(p,m,x)}getCss(p,m){return this._css.get(p,m)}setColor(p,m,x){this._color.set(p,m,x)}getColor(p,m){return this._color.get(p,m)}clear(){this._color.clear(),this._css.clear()}}},3656:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.addDisposableDomListener=void 0,c.addDisposableDomListener=function(d,f,p,m){d.addEventListener(f,p,m);let x=!1;return{dispose:()=>{x||(x=!0,d.removeEventListener(f,p,m))}}}},3551:function(u,c,d){var f=this&&this.__decorate||function(S,v,_,E){var j,T=arguments.length,R=T<3?v:E===null?E=Object.getOwnPropertyDescriptor(v,_):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(S,v,_,E);else for(var A=S.length-1;A>=0;A--)(j=S[A])&&(R=(T<3?j(R):T>3?j(v,_,R):j(v,_))||R);return T>3&&R&&Object.defineProperty(v,_,R),R},p=this&&this.__param||function(S,v){return function(_,E){v(_,E,S)}};Object.defineProperty(c,"__esModule",{value:!0}),c.Linkifier=void 0;const m=d(3656),x=d(8460),y=d(844),w=d(2585),C=d(4725);let b=c.Linkifier=class extends y.Disposable{get currentLink(){return this._currentLink}constructor(S,v,_,E,j){super(),this._element=S,this._mouseService=v,this._renderService=_,this._bufferService=E,this._linkProviderService=j,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new x.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new x.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,y.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,y.toDisposable)((()=>{var T;this._lastMouseEvent=void 0,(T=this._activeProviderReplies)==null||T.clear()}))),this.register(this._bufferService.onResize((()=>{this._clearCurrentLink(),this._wasResized=!0}))),this.register((0,m.addDisposableDomListener)(this._element,"mouseleave",(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this.register((0,m.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,m.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,m.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_handleMouseMove(S){this._lastMouseEvent=S;const v=this._positionFromMouseEvent(S,this._element,this._mouseService);if(!v)return;this._isMouseOut=!1;const _=S.composedPath();for(let E=0;E<_.length;E++){const j=_[E];if(j.classList.contains("xterm"))break;if(j.classList.contains("xterm-hover"))return}this._lastBufferCell&&v.x===this._lastBufferCell.x&&v.y===this._lastBufferCell.y||(this._handleHover(v),this._lastBufferCell=v)}_handleHover(S){if(this._activeLine!==S.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(S,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,S)||(this._clearCurrentLink(),this._askForLink(S,!0))}_askForLink(S,v){var E,j;this._activeProviderReplies&&v||((E=this._activeProviderReplies)==null||E.forEach((T=>{T==null||T.forEach((R=>{R.link.dispose&&R.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=S.y);let _=!1;for(const[T,R]of this._linkProviderService.linkProviders.entries())v?(j=this._activeProviderReplies)!=null&&j.get(T)&&(_=this._checkLinkProviderResult(T,S,_)):R.provideLinks(S.y,(A=>{var $,q;if(this._isMouseOut)return;const D=A==null?void 0:A.map((G=>({link:G})));($=this._activeProviderReplies)==null||$.set(T,D),_=this._checkLinkProviderResult(T,S,_),((q=this._activeProviderReplies)==null?void 0:q.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(S.y,this._activeProviderReplies)}))}_removeIntersectingLinks(S,v){const _=new Set;for(let E=0;E<v.size;E++){const j=v.get(E);if(j)for(let T=0;T<j.length;T++){const R=j[T],A=R.link.range.start.y<S?0:R.link.range.start.x,D=R.link.range.end.y>S?this._bufferService.cols:R.link.range.end.x;for(let $=A;$<=D;$++){if(_.has($)){j.splice(T--,1);break}_.add($)}}}}_checkLinkProviderResult(S,v,_){var T;if(!this._activeProviderReplies)return _;const E=this._activeProviderReplies.get(S);let j=!1;for(let R=0;R<S;R++)this._activeProviderReplies.has(R)&&!this._activeProviderReplies.get(R)||(j=!0);if(!j&&E){const R=E.find((A=>this._linkAtPosition(A.link,v)));R&&(_=!0,this._handleNewLink(R))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!_)for(let R=0;R<this._activeProviderReplies.size;R++){const A=(T=this._activeProviderReplies.get(R))==null?void 0:T.find((D=>this._linkAtPosition(D.link,v)));if(A){_=!0,this._handleNewLink(A);break}}return _}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(S){if(!this._currentLink)return;const v=this._positionFromMouseEvent(S,this._element,this._mouseService);v&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,v)&&this._currentLink.link.activate(S,this._currentLink.link.text)}_clearCurrentLink(S,v){this._currentLink&&this._lastMouseEvent&&(!S||!v||this._currentLink.link.range.start.y>=S&&this._currentLink.link.range.end.y<=v)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,y.disposeArray)(this._linkCacheDisposables))}_handleNewLink(S){if(!this._lastMouseEvent)return;const v=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);v&&this._linkAtPosition(S.link,v)&&(this._currentLink=S,this._currentLink.state={decorations:{underline:S.link.decorations===void 0||S.link.decorations.underline,pointerCursor:S.link.decorations===void 0||S.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,S.link,this._lastMouseEvent),S.link.decorations={},Object.defineProperties(S.link.decorations,{pointerCursor:{get:()=>{var _,E;return(E=(_=this._currentLink)==null?void 0:_.state)==null?void 0:E.decorations.pointerCursor},set:_=>{var E;(E=this._currentLink)!=null&&E.state&&this._currentLink.state.decorations.pointerCursor!==_&&(this._currentLink.state.decorations.pointerCursor=_,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",_))}},underline:{get:()=>{var _,E;return(E=(_=this._currentLink)==null?void 0:_.state)==null?void 0:E.decorations.underline},set:_=>{var E,j,T;(E=this._currentLink)!=null&&E.state&&((T=(j=this._currentLink)==null?void 0:j.state)==null?void 0:T.decorations.underline)!==_&&(this._currentLink.state.decorations.underline=_,this._currentLink.state.isHovered&&this._fireUnderlineEvent(S.link,_))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((_=>{if(!this._currentLink)return;const E=_.start===0?0:_.start+1+this._bufferService.buffer.ydisp,j=this._bufferService.buffer.ydisp+1+_.end;if(this._currentLink.link.range.start.y>=E&&this._currentLink.link.range.end.y<=j&&(this._clearCurrentLink(E,j),this._lastMouseEvent)){const T=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);T&&this._askForLink(T,!1)}}))))}_linkHover(S,v,_){var E;(E=this._currentLink)!=null&&E.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(v,!0),this._currentLink.state.decorations.pointerCursor&&S.classList.add("xterm-cursor-pointer")),v.hover&&v.hover(_,v.text)}_fireUnderlineEvent(S,v){const _=S.range,E=this._bufferService.buffer.ydisp,j=this._createLinkUnderlineEvent(_.start.x-1,_.start.y-E-1,_.end.x,_.end.y-E-1,void 0);(v?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(j)}_linkLeave(S,v,_){var E;(E=this._currentLink)!=null&&E.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(v,!1),this._currentLink.state.decorations.pointerCursor&&S.classList.remove("xterm-cursor-pointer")),v.leave&&v.leave(_,v.text)}_linkAtPosition(S,v){const _=S.range.start.y*this._bufferService.cols+S.range.start.x,E=S.range.end.y*this._bufferService.cols+S.range.end.x,j=v.y*this._bufferService.cols+v.x;return _<=j&&j<=E}_positionFromMouseEvent(S,v,_){const E=_.getCoords(S,v,this._bufferService.cols,this._bufferService.rows);if(E)return{x:E[0],y:E[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(S,v,_,E,j){return{x1:S,y1:v,x2:_,y2:E,cols:this._bufferService.cols,fg:j}}};c.Linkifier=b=f([p(1,C.IMouseService),p(2,C.IRenderService),p(3,w.IBufferService),p(4,C.ILinkProviderService)],b)},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,b,S,v){var _,E=arguments.length,j=E<3?b:v===null?v=Object.getOwnPropertyDescriptor(b,S):v;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")j=Reflect.decorate(C,b,S,v);else for(var T=C.length-1;T>=0;T--)(_=C[T])&&(j=(E<3?_(j):E>3?_(b,S,j):_(b,S))||j);return E>3&&j&&Object.defineProperty(b,S,j),j},p=this&&this.__param||function(C,b){return function(S,v){b(S,v,C)}};Object.defineProperty(c,"__esModule",{value:!0}),c.OscLinkProvider=void 0;const m=d(511),x=d(2585);let y=c.OscLinkProvider=class{constructor(C,b,S){this._bufferService=C,this._optionsService=b,this._oscLinkService=S}provideLinks(C,b){var D;const S=this._bufferService.buffer.lines.get(C-1);if(!S)return void b(void 0);const v=[],_=this._optionsService.rawOptions.linkHandler,E=new m.CellData,j=S.getTrimmedLength();let T=-1,R=-1,A=!1;for(let $=0;$<j;$++)if(R!==-1||S.hasContent($)){if(S.loadCell($,E),E.hasExtendedAttrs()&&E.extended.urlId){if(R===-1){R=$,T=E.extended.urlId;continue}A=E.extended.urlId!==T}else R!==-1&&(A=!0);if(A||R!==-1&&$===j-1){const q=(D=this._oscLinkService.getLinkData(T))==null?void 0:D.uri;if(q){const G={start:{x:R+1,y:C},end:{x:$+(A||$!==j-1?0:1),y:C}};let I=!1;if(!(_!=null&&_.allowNonHttpProtocols))try{const U=new URL(q);["http:","https:"].includes(U.protocol)||(I=!0)}catch{I=!0}I||v.push({text:q,range:G,activate:(U,V)=>_?_.activate(U,V,G):w(0,V),hover:(U,V)=>{var z;return(z=_==null?void 0:_.hover)==null?void 0:z.call(_,U,V,G)},leave:(U,V)=>{var z;return(z=_==null?void 0:_.leave)==null?void 0:z.call(_,U,V,G)}})}A=!1,E.hasExtendedAttrs()&&E.extended.urlId?(R=$,T=E.extended.urlId):(R=-1,T=-1)}}b(v)}};function w(C,b){if(confirm(`Do you want to navigate to ${b}?
|
|
63
|
+
|
|
64
|
+
WARNING: This link could potentially be dangerous`)){const S=window.open();if(S){try{S.opener=null}catch{}S.location.href=b}else console.warn("Opening link blocked as opener could not be cleared")}}c.OscLinkProvider=y=f([p(0,x.IBufferService),p(1,x.IOptionsService),p(2,x.IOscLinkService)],y)},6193:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.RenderDebouncer=void 0,c.RenderDebouncer=class{constructor(d,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,p){this._rowCount=p,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),p=d(3656),m=d(3551),x=d(9042),y=d(3730),w=d(1680),C=d(3107),b=d(5744),S=d(2950),v=d(1296),_=d(428),E=d(4269),j=d(5114),T=d(8934),R=d(3230),A=d(9312),D=d(4725),$=d(6731),q=d(8055),G=d(8969),I=d(8460),U=d(844),V=d(6114),z=d(8437),J=d(2584),Z=d(7399),H=d(5941),O=d(9074),B=d(2585),W=d(5435),P=d(4567),ee=d(779);class X extends G.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 I.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onKey=this.register(new I.EventEmitter),this.onKey=this._onKey.event,this._onRender=this.register(new I.EventEmitter),this.onRender=this._onRender.event,this._onSelectionChange=this.register(new I.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this.register(new I.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onBell=this.register(new I.EventEmitter),this.onBell=this._onBell.event,this._onFocus=this.register(new I.EventEmitter),this._onBlur=this.register(new I.EventEmitter),this._onA11yCharEmitter=this.register(new I.EventEmitter),this._onA11yTabEmitter=this.register(new I.EventEmitter),this._onWillOpen=this.register(new I.EventEmitter),this._setup(),this._decorationService=this._instantiationService.createInstance(O.DecorationService),this._instantiationService.setService(B.IDecorationService,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(ee.LinkProviderService),this._instantiationService.setService(D.ILinkProviderService,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(y.OscLinkProvider)),this.register(this._inputHandler.onRequestBell((()=>this._onBell.fire()))),this.register(this._inputHandler.onRequestRefreshRows(((F,te)=>this.refresh(F,te)))),this.register(this._inputHandler.onRequestSendFocus((()=>this._reportFocus()))),this.register(this._inputHandler.onRequestReset((()=>this.reset()))),this.register(this._inputHandler.onRequestWindowsOptionsReport((F=>this._reportWindowsOptions(F)))),this.register(this._inputHandler.onColor((F=>this._handleColorEvent(F)))),this.register((0,I.forwardEvent)(this._inputHandler.onCursorMove,this._onCursorMove)),this.register((0,I.forwardEvent)(this._inputHandler.onTitleChange,this._onTitleChange)),this.register((0,I.forwardEvent)(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this.register((0,I.forwardEvent)(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this.register(this._bufferService.onResize((F=>this._afterResize(F.cols,F.rows)))),this.register((0,U.toDisposable)((()=>{var F,te;this._customKeyEventHandler=void 0,(te=(F=this.element)==null?void 0:F.parentNode)==null||te.removeChild(this.element)})))}_handleColorEvent(Y){if(this._themeService)for(const F of Y){let te,se="";switch(F.index){case 256:te="foreground",se="10";break;case 257:te="background",se="11";break;case 258:te="cursor",se="12";break;default:te="ansi",se="4;"+F.index}switch(F.type){case 0:const xe=q.color.toColorRGB(te==="ansi"?this._themeService.colors.ansi[F.index]:this._themeService.colors[te]);this.coreService.triggerDataEvent(`${J.C0.ESC}]${se};${(0,H.toRgbString)(xe)}${J.C1_ESCAPED.ST}`);break;case 1:if(te==="ansi")this._themeService.modifyColors((le=>le.ansi[F.index]=q.channels.toColor(...F.color)));else{const le=te;this._themeService.modifyColors((Ee=>Ee[le]=q.channels.toColor(...F.color)))}break;case 2:this._themeService.restoreColor(F.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(J.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(J.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,F=this.buffer.lines.get(Y);if(!F)return;const te=Math.min(this.buffer.x,this.cols-1),se=this._renderService.dimensions.css.cell.height,xe=F.getWidth(te),le=this._renderService.dimensions.css.cell.width*xe,Ee=this.buffer.y*this._renderService.dimensions.css.cell.height,ue=te*this._renderService.dimensions.css.cell.width;this.textarea.style.left=ue+"px",this.textarea.style.top=Ee+"px",this.textarea.style.width=le+"px",this.textarea.style.height=se+"px",this.textarea.style.lineHeight=se+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this.register((0,p.addDisposableDomListener)(this.element,"copy",(F=>{this.hasSelection()&&(0,f.copyHandler)(F,this._selectionService)})));const Y=F=>(0,f.handlePasteEvent)(F,this.textarea,this.coreService,this.optionsService);this.register((0,p.addDisposableDomListener)(this.textarea,"paste",Y)),this.register((0,p.addDisposableDomListener)(this.element,"paste",Y)),V.isFirefox?this.register((0,p.addDisposableDomListener)(this.element,"mousedown",(F=>{F.button===2&&(0,f.rightClickHandler)(F,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))):this.register((0,p.addDisposableDomListener)(this.element,"contextmenu",(F=>{(0,f.rightClickHandler)(F,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))),V.isLinux&&this.register((0,p.addDisposableDomListener)(this.element,"auxclick",(F=>{F.button===1&&(0,f.moveTextAreaUnderMouseCursor)(F,this.textarea,this.screenElement)})))}_bindKeys(){this.register((0,p.addDisposableDomListener)(this.textarea,"keyup",(Y=>this._keyUp(Y)),!0)),this.register((0,p.addDisposableDomListener)(this.textarea,"keydown",(Y=>this._keyDown(Y)),!0)),this.register((0,p.addDisposableDomListener)(this.textarea,"keypress",(Y=>this._keyPress(Y)),!0)),this.register((0,p.addDisposableDomListener)(this.textarea,"compositionstart",(()=>this._compositionHelper.compositionstart()))),this.register((0,p.addDisposableDomListener)(this.textarea,"compositionupdate",(Y=>this._compositionHelper.compositionupdate(Y)))),this.register((0,p.addDisposableDomListener)(this.textarea,"compositionend",(()=>this._compositionHelper.compositionend()))),this.register((0,p.addDisposableDomListener)(this.textarea,"input",(Y=>this._inputEvent(Y)),!0)),this.register(this.onRender((()=>this._compositionHelper.updateCompositionElements())))}open(Y){var te;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"),((te=this.element)==null?void 0:te.ownerDocument.defaultView)&&this._coreBrowserService)return void(this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView));this._document=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 F=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),F.appendChild(this._viewportElement),this._viewportScrollArea=this._document.createElement("div"),this._viewportScrollArea.classList.add("xterm-scroll-area"),this._viewportElement.appendChild(this._viewportScrollArea),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this.register((0,p.addDisposableDomListener)(this.screenElement,"mousemove",(se=>this.updateCursorStyle(se)))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),F.appendChild(this.screenElement),this.textarea=this._document.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",x.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(j.CoreBrowserService,this.textarea,Y.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(D.ICoreBrowserService,this._coreBrowserService),this.register((0,p.addDisposableDomListener)(this.textarea,"focus",(se=>this._handleTextAreaFocus(se)))),this.register((0,p.addDisposableDomListener)(this.textarea,"blur",(()=>this._handleTextAreaBlur()))),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(_.CharSizeService,this._document,this._helperContainer),this._instantiationService.setService(D.ICharSizeService,this._charSizeService),this._themeService=this._instantiationService.createInstance($.ThemeService),this._instantiationService.setService(D.IThemeService,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(E.CharacterJoinerService),this._instantiationService.setService(D.ICharacterJoinerService,this._characterJoinerService),this._renderService=this.register(this._instantiationService.createInstance(R.RenderService,this.rows,this.screenElement)),this._instantiationService.setService(D.IRenderService,this._renderService),this.register(this._renderService.onRenderedViewportChange((se=>this._onRender.fire(se)))),this.onResize((se=>this._renderService.resize(se.cols,se.rows))),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(S.CompositionHelper,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(T.MouseService),this._instantiationService.setService(D.IMouseService,this._mouseService),this.linkifier=this.register(this._instantiationService.createInstance(m.Linkifier,this.screenElement)),this.element.appendChild(F);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this.viewport=this._instantiationService.createInstance(w.Viewport,this._viewportElement,this._viewportScrollArea),this.viewport.onRequestScrollLines((se=>this.scrollLines(se.amount,se.suppressScrollEvent,1))),this.register(this._inputHandler.onRequestSyncScrollBar((()=>this.viewport.syncScrollArea()))),this.register(this.viewport),this.register(this.onCursorMove((()=>{this._renderService.handleCursorMove(),this._syncTextArea()}))),this.register(this.onResize((()=>this._renderService.handleResize(this.cols,this.rows)))),this.register(this.onBlur((()=>this._renderService.handleBlur()))),this.register(this.onFocus((()=>this._renderService.handleFocus()))),this.register(this._renderService.onDimensionsChange((()=>this.viewport.syncScrollArea()))),this._selectionService=this.register(this._instantiationService.createInstance(A.SelectionService,this.element,this.screenElement,this.linkifier)),this._instantiationService.setService(D.ISelectionService,this._selectionService),this.register(this._selectionService.onRequestScrollLines((se=>this.scrollLines(se.amount,se.suppressScrollEvent)))),this.register(this._selectionService.onSelectionChange((()=>this._onSelectionChange.fire()))),this.register(this._selectionService.onRequestRedraw((se=>this._renderService.handleSelectionChanged(se.start,se.end,se.columnSelectMode)))),this.register(this._selectionService.onLinuxMouseSelection((se=>{this.textarea.value=se,this.textarea.focus(),this.textarea.select()}))),this.register(this._onScroll.event((se=>{this.viewport.syncScrollArea(),this._selectionService.refresh()}))),this.register((0,p.addDisposableDomListener)(this._viewportElement,"scroll",(()=>this._selectionService.refresh()))),this.register(this._instantiationService.createInstance(C.BufferDecorationRenderer,this.screenElement)),this.register((0,p.addDisposableDomListener)(this.element,"mousedown",(se=>this._selectionService.handleMouseDown(se)))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(P.AccessibilityManager,this)),this.register(this.optionsService.onSpecificOptionChange("screenReaderMode",(se=>this._handleScreenReaderModeOptionChange(se)))),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(b.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRulerWidth",(se=>{!this._overviewRulerRenderer&&se&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(b.OverviewRulerRenderer,this._viewportElement,this.screenElement)))})),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(v.DomRenderer,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){const Y=this,F=this.element;function te(le){const Ee=Y._mouseService.getMouseReportCoords(le,Y.screenElement);if(!Ee)return!1;let ue,ae;switch(le.overrideType||le.type){case"mousemove":ae=32,le.buttons===void 0?(ue=3,le.button!==void 0&&(ue=le.button<3?le.button:3)):ue=1&le.buttons?0:4&le.buttons?1:2&le.buttons?2:3;break;case"mouseup":ae=0,ue=le.button<3?le.button:3;break;case"mousedown":ae=1,ue=le.button<3?le.button:3;break;case"wheel":if(Y._customWheelEventHandler&&Y._customWheelEventHandler(le)===!1||Y.viewport.getLinesScrolled(le)===0)return!1;ae=le.deltaY<0?0:1,ue=4;break;default:return!1}return!(ae===void 0||ue===void 0||ue>4)&&Y.coreMouseService.triggerMouseEvent({col:Ee.col,row:Ee.row,x:Ee.x,y:Ee.y,button:ue,action:ae,ctrl:le.ctrlKey,alt:le.altKey,shift:le.shiftKey})}const se={mouseup:null,wheel:null,mousedrag:null,mousemove:null},xe={mouseup:le=>(te(le),le.buttons||(this._document.removeEventListener("mouseup",se.mouseup),se.mousedrag&&this._document.removeEventListener("mousemove",se.mousedrag)),this.cancel(le)),wheel:le=>(te(le),this.cancel(le,!0)),mousedrag:le=>{le.buttons&&te(le)},mousemove:le=>{le.buttons||te(le)}};this.register(this.coreMouseService.onProtocolChange((le=>{le?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(le)),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&le?se.mousemove||(F.addEventListener("mousemove",xe.mousemove),se.mousemove=xe.mousemove):(F.removeEventListener("mousemove",se.mousemove),se.mousemove=null),16&le?se.wheel||(F.addEventListener("wheel",xe.wheel,{passive:!1}),se.wheel=xe.wheel):(F.removeEventListener("wheel",se.wheel),se.wheel=null),2&le?se.mouseup||(se.mouseup=xe.mouseup):(this._document.removeEventListener("mouseup",se.mouseup),se.mouseup=null),4&le?se.mousedrag||(se.mousedrag=xe.mousedrag):(this._document.removeEventListener("mousemove",se.mousedrag),se.mousedrag=null)}))),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,p.addDisposableDomListener)(F,"mousedown",(le=>{if(le.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(le))return te(le),se.mouseup&&this._document.addEventListener("mouseup",se.mouseup),se.mousedrag&&this._document.addEventListener("mousemove",se.mousedrag),this.cancel(le)}))),this.register((0,p.addDisposableDomListener)(F,"wheel",(le=>{if(!se.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(le)===!1)return!1;if(!this.buffer.hasScrollback){const Ee=this.viewport.getLinesScrolled(le);if(Ee===0)return;const ue=J.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(le.deltaY<0?"A":"B");let ae="";for(let de=0;de<Math.abs(Ee);de++)ae+=ue;return this.coreService.triggerDataEvent(ae,!0),this.cancel(le,!0)}return this.viewport.handleWheel(le)?this.cancel(le):void 0}}),{passive:!1})),this.register((0,p.addDisposableDomListener)(F,"touchstart",(le=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(le),this.cancel(le)}),{passive:!0})),this.register((0,p.addDisposableDomListener)(F,"touchmove",(le=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(le)?void 0:this.cancel(le)}),{passive:!1}))}refresh(Y,F){var te;(te=this._renderService)==null||te.refreshRows(Y,F)}updateCursorStyle(Y){var F;(F=this._selectionService)!=null&&F.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,F,te=0){var se;te===1?(super.scrollLines(Y,F,te),this.refresh(0,this.rows-1)):(se=this.viewport)==null||se.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 F=this._characterJoinerService.register(Y);return this.refresh(0,this.rows-1),F}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,F,te){this._selectionService.setSelection(Y,F,te)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(this._selectionService&&this._selectionService.hasSelection)return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var Y;(Y=this._selectionService)==null||Y.clearSelection()}selectAll(){var Y;(Y=this._selectionService)==null||Y.selectAll()}selectLines(Y,F){var te;(te=this._selectionService)==null||te.selectLines(Y,F)}_keyDown(Y){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(Y)===!1)return!1;const F=this.browser.isMac&&this.options.macOptionIsMeta&&Y.altKey;if(!F&&!this._compositionHelper.keydown(Y))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;F||Y.key!=="Dead"&&Y.key!=="AltGraph"||(this._unprocessedDeadKey=!0);const te=(0,Z.evaluateKeyboardEvent)(Y,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(Y),te.type===3||te.type===2){const se=this.rows-1;return this.scrollLines(te.type===2?-se:se),this.cancel(Y,!0)}return te.type===1&&this.selectAll(),!!this._isThirdLevelShift(this.browser,Y)||(te.cancel&&this.cancel(Y,!0),!te.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):(te.key!==J.C0.ETX&&te.key!==J.C0.CR||(this.textarea.value=""),this._onKey.fire({key:te.key,domEvent:Y}),this._showCursor(),this.coreService.triggerDataEvent(te.key,!0),!this.optionsService.rawOptions.screenReaderMode||Y.altKey||Y.ctrlKey?this.cancel(Y,!0):void(this._keyDownHandled=!0))))}_isThirdLevelShift(Y,F){const te=Y.isMac&&!this.options.macOptionIsMeta&&F.altKey&&!F.ctrlKey&&!F.metaKey||Y.isWindows&&F.altKey&&F.ctrlKey&&!F.metaKey||Y.isWindows&&F.getModifierState("AltGraph");return F.type==="keypress"?te:te&&(!F.keyCode||F.keyCode>47)}_keyUp(Y){this._keyDownSeen=!1,this._customKeyEventHandler&&this._customKeyEventHandler(Y)===!1||((function(F){return F.keyCode===16||F.keyCode===17||F.keyCode===18})(Y)||this.focus(),this.updateCursorStyle(Y),this._keyPressHandled=!1)}_keyPress(Y){let F;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(Y)===!1)return!1;if(this.cancel(Y),Y.charCode)F=Y.charCode;else if(Y.which===null||Y.which===void 0)F=Y.keyCode;else{if(Y.which===0||Y.charCode===0)return!1;F=Y.which}return!(!F||(Y.altKey||Y.ctrlKey||Y.metaKey)&&!this._isThirdLevelShift(this.browser,Y)||(F=String.fromCharCode(F),this._onKey.fire({key:F,domEvent:Y}),this._showCursor(),this.coreService.triggerDataEvent(F,!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 F=Y.data;return this.coreService.triggerDataEvent(F,!0),this.cancel(Y),!0}return!1}resize(Y,F){Y!==this.cols||F!==this.rows?super.resize(Y,F):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(Y,F){var te,se;(te=this._charSizeService)==null||te.measure(),(se=this.viewport)==null||se.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 F=1;F<this.rows;F++)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 F,te;this.options.rows=this.rows,this.options.cols=this.cols;const Y=this._customKeyEventHandler;this._setup(),super.reset(),(F=this._selectionService)==null||F.reset(),this._decorationService.reset(),(te=this.viewport)==null||te.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(J.C0.ESC+"[I"):this.coreService.triggerDataEvent(J.C0.ESC+"[O")}_reportWindowsOptions(Y){if(this._renderService)switch(Y){case W.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:const F=this._renderService.dimensions.css.canvas.width.toFixed(0),te=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${J.C0.ESC}[4;${te};${F}t`);break;case W.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:const se=this._renderService.dimensions.css.cell.width.toFixed(0),xe=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${J.C0.ESC}[6;${xe};${se}t`)}}cancel(Y,F){if(this.options.cancelEvents||F)return Y.preventDefault(),Y.stopPropagation(),!1}}c.Terminal=X},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,p){this._rowCount=p,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 m=Date.now();if(m-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=m,this._innerRefresh();else if(!this._additionalRefreshRequested){const x=m-this._lastRefreshMs,y=this._debounceThresholdMS-x;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout((()=>{this._lastRefreshMs=Date.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0}),y)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;const d=Math.max(this._rowStart,0),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,v,_,E){var j,T=arguments.length,R=T<3?v:E===null?E=Object.getOwnPropertyDescriptor(v,_):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(S,v,_,E);else for(var A=S.length-1;A>=0;A--)(j=S[A])&&(R=(T<3?j(R):T>3?j(v,_,R):j(v,_))||R);return T>3&&R&&Object.defineProperty(v,_,R),R},p=this&&this.__param||function(S,v){return function(_,E){v(_,E,S)}};Object.defineProperty(c,"__esModule",{value:!0}),c.Viewport=void 0;const m=d(3656),x=d(4725),y=d(8460),w=d(844),C=d(2585);let b=c.Viewport=class extends w.Disposable{constructor(S,v,_,E,j,T,R,A){super(),this._viewportElement=S,this._scrollArea=v,this._bufferService=_,this._optionsService=E,this._charSizeService=j,this._renderService=T,this._coreBrowserService=R,this.scrollBarWidth=0,this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._wheelPartialScroll=0,this._refreshAnimationFrame=null,this._ignoreNextScrollEvent=!1,this._smoothScrollState={startTime:0,origin:-1,target:-1},this._onRequestScrollLines=this.register(new y.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this.scrollBarWidth=this._viewportElement.offsetWidth-this._scrollArea.offsetWidth||15,this.register((0,m.addDisposableDomListener)(this._viewportElement,"scroll",this._handleScroll.bind(this))),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((D=>this._activeBuffer=D.activeBuffer))),this._renderDimensions=this._renderService.dimensions,this.register(this._renderService.onDimensionsChange((D=>this._renderDimensions=D))),this._handleThemeChange(A.colors),this.register(A.onChangeColors((D=>this._handleThemeChange(D)))),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.syncScrollArea()))),setTimeout((()=>this.syncScrollArea()))}_handleThemeChange(S){this._viewportElement.style.backgroundColor=S.background.css}reset(){this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._coreBrowserService.window.requestAnimationFrame((()=>this.syncScrollArea()))}_refresh(S){if(S)return this._innerRefresh(),void(this._refreshAnimationFrame!==null&&this._coreBrowserService.window.cancelAnimationFrame(this._refreshAnimationFrame));this._refreshAnimationFrame===null&&(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._charSizeService.height>0){this._currentRowHeight=this._renderDimensions.device.cell.height/this._coreBrowserService.dpr,this._currentDeviceCellHeight=this._renderDimensions.device.cell.height,this._lastRecordedViewportHeight=this._viewportElement.offsetHeight;const v=Math.round(this._currentRowHeight*this._lastRecordedBufferLength)+(this._lastRecordedViewportHeight-this._renderDimensions.css.canvas.height);this._lastRecordedBufferHeight!==v&&(this._lastRecordedBufferHeight=v,this._scrollArea.style.height=this._lastRecordedBufferHeight+"px")}const S=this._bufferService.buffer.ydisp*this._currentRowHeight;this._viewportElement.scrollTop!==S&&(this._ignoreNextScrollEvent=!0,this._viewportElement.scrollTop=S),this._refreshAnimationFrame=null}syncScrollArea(S=!1){if(this._lastRecordedBufferLength!==this._bufferService.buffer.lines.length)return this._lastRecordedBufferLength=this._bufferService.buffer.lines.length,void this._refresh(S);this._lastRecordedViewportHeight===this._renderService.dimensions.css.canvas.height&&this._lastScrollTop===this._activeBuffer.ydisp*this._currentRowHeight&&this._renderDimensions.device.cell.height===this._currentDeviceCellHeight||this._refresh(S)}_handleScroll(S){if(this._lastScrollTop=this._viewportElement.scrollTop,!this._viewportElement.offsetParent)return;if(this._ignoreNextScrollEvent)return this._ignoreNextScrollEvent=!1,void this._onRequestScrollLines.fire({amount:0,suppressScrollEvent:!0});const v=Math.round(this._lastScrollTop/this._currentRowHeight)-this._bufferService.buffer.ydisp;this._onRequestScrollLines.fire({amount:v,suppressScrollEvent:!0})}_smoothScroll(){if(this._isDisposed||this._smoothScrollState.origin===-1||this._smoothScrollState.target===-1)return;const S=this._smoothScrollPercent();this._viewportElement.scrollTop=this._smoothScrollState.origin+Math.round(S*(this._smoothScrollState.target-this._smoothScrollState.origin)),S<1?this._coreBrowserService.window.requestAnimationFrame((()=>this._smoothScroll())):this._clearSmoothScrollState()}_smoothScrollPercent(){return this._optionsService.rawOptions.smoothScrollDuration&&this._smoothScrollState.startTime?Math.max(Math.min((Date.now()-this._smoothScrollState.startTime)/this._optionsService.rawOptions.smoothScrollDuration,1),0):1}_clearSmoothScrollState(){this._smoothScrollState.startTime=0,this._smoothScrollState.origin=-1,this._smoothScrollState.target=-1}_bubbleScroll(S,v){const _=this._viewportElement.scrollTop+this._lastRecordedViewportHeight;return!(v<0&&this._viewportElement.scrollTop!==0||v>0&&_<this._lastRecordedBufferHeight)||(S.cancelable&&S.preventDefault(),!1)}handleWheel(S){const v=this._getPixelsScrolled(S);return v!==0&&(this._optionsService.rawOptions.smoothScrollDuration?(this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target===-1?this._smoothScrollState.target=this._viewportElement.scrollTop+v:this._smoothScrollState.target+=v,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()):this._viewportElement.scrollTop+=v,this._bubbleScroll(S,v))}scrollLines(S){if(S!==0)if(this._optionsService.rawOptions.smoothScrollDuration){const v=S*this._currentRowHeight;this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target=this._smoothScrollState.origin+v,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()}else this._onRequestScrollLines.fire({amount:S,suppressScrollEvent:!1})}_getPixelsScrolled(S){if(S.deltaY===0||S.shiftKey)return 0;let v=this._applyScrollModifier(S.deltaY,S);return S.deltaMode===WheelEvent.DOM_DELTA_LINE?v*=this._currentRowHeight:S.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(v*=this._currentRowHeight*this._bufferService.rows),v}getBufferElements(S,v){var A;let _,E="";const j=[],T=v??this._bufferService.buffer.lines.length,R=this._bufferService.buffer.lines;for(let D=S;D<T;D++){const $=R.get(D);if(!$)continue;const q=(A=R.get(D+1))==null?void 0:A.isWrapped;if(E+=$.translateToString(!q),!q||D===R.length-1){const G=document.createElement("div");G.textContent=E,j.push(G),E.length>0&&(_=G),E=""}}return{bufferElements:j,cursorElement:_}}getLinesScrolled(S){if(S.deltaY===0||S.shiftKey)return 0;let v=this._applyScrollModifier(S.deltaY,S);return S.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(v/=this._currentRowHeight+0,this._wheelPartialScroll+=v,v=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):S.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(v*=this._bufferService.rows),v}_applyScrollModifier(S,v){const _=this._optionsService.rawOptions.fastScrollModifier;return _==="alt"&&v.altKey||_==="ctrl"&&v.ctrlKey||_==="shift"&&v.shiftKey?S*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:S*this._optionsService.rawOptions.scrollSensitivity}handleTouchStart(S){this._lastTouchY=S.touches[0].pageY}handleTouchMove(S){const v=this._lastTouchY-S.touches[0].pageY;return this._lastTouchY=S.touches[0].pageY,v!==0&&(this._viewportElement.scrollTop+=v,this._bubbleScroll(S,v))}};c.Viewport=b=f([p(2,C.IBufferService),p(3,C.IOptionsService),p(4,x.ICharSizeService),p(5,x.IRenderService),p(6,x.ICoreBrowserService),p(7,x.IThemeService)],b)},3107:function(u,c,d){var f=this&&this.__decorate||function(C,b,S,v){var _,E=arguments.length,j=E<3?b:v===null?v=Object.getOwnPropertyDescriptor(b,S):v;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")j=Reflect.decorate(C,b,S,v);else for(var T=C.length-1;T>=0;T--)(_=C[T])&&(j=(E<3?_(j):E>3?_(b,S,j):_(b,S))||j);return E>3&&j&&Object.defineProperty(b,S,j),j},p=this&&this.__param||function(C,b){return function(S,v){b(S,v,C)}};Object.defineProperty(c,"__esModule",{value:!0}),c.BufferDecorationRenderer=void 0;const m=d(4725),x=d(844),y=d(2585);let w=c.BufferDecorationRenderer=class extends x.Disposable{constructor(C,b,S,v,_){super(),this._screenElement=C,this._bufferService=b,this._coreBrowserService=S,this._decorationService=v,this._renderService=_,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,x.toDisposable)((()=>{this._container.remove(),this._decorationElements.clear()})))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback((()=>{this._doRefreshDecorations(),this._animationFrame=void 0})))}_doRefreshDecorations(){for(const C of this._decorationService.decorations)this._renderDecoration(C);this._dimensionsChanged=!1}_renderDecoration(C){this._refreshStyle(C),this._dimensionsChanged&&this._refreshXPosition(C)}_createElement(C){var v;const b=this._coreBrowserService.mainDocument.createElement("div");b.classList.add("xterm-decoration"),b.classList.toggle("xterm-decoration-top-layer",((v=C==null?void 0:C.options)==null?void 0:v.layer)==="top"),b.style.width=`${Math.round((C.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,b.style.height=(C.options.height||1)*this._renderService.dimensions.css.cell.height+"px",b.style.top=(C.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height+"px",b.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;const S=C.options.x??0;return S&&S>this._bufferService.cols&&(b.style.display="none"),this._refreshXPosition(C,b),b}_refreshStyle(C){const b=C.marker.line-this._bufferService.buffers.active.ydisp;if(b<0||b>=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=b*this._renderService.dimensions.css.cell.height+"px",S.style.display=this._altBufferIsActive?"none":"block",C.onRenderEmitter.fire(S)}}_refreshXPosition(C,b=C.element){if(!b)return;const S=C.options.x??0;(C.options.anchor||"left")==="right"?b.style.right=S?S*this._renderService.dimensions.css.cell.width+"px":"":b.style.left=S?S*this._renderService.dimensions.css.cell.width+"px":""}_removeDecoration(C){var b;(b=this._decorationElements.get(C))==null||b.remove(),this._decorationElements.delete(C),C.dispose()}};c.BufferDecorationRenderer=w=f([p(1,y.IBufferService),p(2,m.ICoreBrowserService),p(3,y.IDecorationService),p(4,m.IRenderService)],w)},5871:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.ColorZoneStore=void 0,c.ColorZoneStore=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(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,p){return f>=d.startBufferLine-this._linePadding[p||"full"]&&f<=d.endBufferLine+this._linePadding[p||"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(_,E,j,T){var R,A=arguments.length,D=A<3?E:T===null?T=Object.getOwnPropertyDescriptor(E,j):T;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")D=Reflect.decorate(_,E,j,T);else for(var $=_.length-1;$>=0;$--)(R=_[$])&&(D=(A<3?R(D):A>3?R(E,j,D):R(E,j))||D);return A>3&&D&&Object.defineProperty(E,j,D),D},p=this&&this.__param||function(_,E){return function(j,T){E(j,T,_)}};Object.defineProperty(c,"__esModule",{value:!0}),c.OverviewRulerRenderer=void 0;const m=d(5871),x=d(4725),y=d(844),w=d(2585),C={full:0,left:0,center:0,right:0},b={full:0,left:0,center:0,right:0},S={full:0,left:0,center:0,right:0};let v=c.OverviewRulerRenderer=class extends y.Disposable{get _width(){return this._optionsService.options.overviewRulerWidth||0}constructor(_,E,j,T,R,A,D){var q;super(),this._viewportElement=_,this._screenElement=E,this._bufferService=j,this._decorationService=T,this._renderService=R,this._optionsService=A,this._coreBrowserService=D,this._colorZoneStore=new m.ColorZoneStore,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(q=this._viewportElement.parentElement)==null||q.insertBefore(this._canvas,this._viewportElement);const $=this._canvas.getContext("2d");if(!$)throw new Error("Ctx cannot be null");this._ctx=$,this._registerDecorationListeners(),this._registerBufferChangeListeners(),this._registerDimensionChangeListeners(),this.register((0,y.toDisposable)((()=>{var G;(G=this._canvas)==null||G.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 _=Math.floor(this._canvas.width/3),E=Math.ceil(this._canvas.width/3);b.full=this._canvas.width,b.left=_,b.center=E,b.right=_,this._refreshDrawHeightConstants(),S.full=0,S.left=0,S.center=b.left,S.right=b.left+b.center}_refreshDrawHeightConstants(){C.full=Math.round(2*this._coreBrowserService.dpr);const _=this._canvas.height/this._bufferService.buffer.lines.length,E=Math.round(Math.max(Math.min(_,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 _=this._colorZoneStore.zones;for(const E of _)E.position!=="full"&&this._renderColorZone(E);for(const E of _)E.position==="full"&&this._renderColorZone(E);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderColorZone(_){this._ctx.fillStyle=_.color,this._ctx.fillRect(S[_.position||"full"],Math.round((this._canvas.height-1)*(_.startBufferLine/this._bufferService.buffers.active.lines.length)-C[_.position||"full"]/2),b[_.position||"full"],Math.round((this._canvas.height-1)*((_.endBufferLine-_.startBufferLine)/this._bufferService.buffers.active.lines.length)+C[_.position||"full"]))}_queueRefresh(_,E){this._shouldUpdateDimensions=_||this._shouldUpdateDimensions,this._shouldUpdateAnchor=E||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>{this._refreshDecorations(),this._animationFrame=void 0})))}};c.OverviewRulerRenderer=v=f([p(2,w.IBufferService),p(3,w.IDecorationService),p(4,x.IRenderService),p(5,w.IOptionsService),p(6,x.ICoreBrowserService)],v)},2950:function(u,c,d){var f=this&&this.__decorate||function(C,b,S,v){var _,E=arguments.length,j=E<3?b:v===null?v=Object.getOwnPropertyDescriptor(b,S):v;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")j=Reflect.decorate(C,b,S,v);else for(var T=C.length-1;T>=0;T--)(_=C[T])&&(j=(E<3?_(j):E>3?_(b,S,j):_(b,S))||j);return E>3&&j&&Object.defineProperty(b,S,j),j},p=this&&this.__param||function(C,b){return function(S,v){b(S,v,C)}};Object.defineProperty(c,"__esModule",{value:!0}),c.CompositionHelper=void 0;const m=d(4725),x=d(2585),y=d(2584);let w=c.CompositionHelper=class{get isComposing(){return this._isComposing}constructor(C,b,S,v,_,E){this._textarea=C,this._compositionView=b,this._bufferService=S,this._optionsService=v,this._coreService=_,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 b={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout((()=>{if(this._isSendingComposition){let S;this._isSendingComposition=!1,b.start+=this._dataAlreadySent.length,S=this._isComposing?this._textarea.value.substring(b.start,b.end):this._textarea.value.substring(b.start),S.length>0&&this._coreService.triggerDataEvent(S,!0)}}),0)}else{this._isSendingComposition=!1;const b=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(b,!0)}}_handleAnyTextareaChanges(){const C=this._textarea.value;setTimeout((()=>{if(!this._isComposing){const b=this._textarea.value,S=b.replace(C,"");this._dataAlreadySent=S,b.length>C.length?this._coreService.triggerDataEvent(S,!0):b.length<C.length?this._coreService.triggerDataEvent(`${y.C0.DEL}`,!0):b.length===C.length&&b!==C&&this._coreService.triggerDataEvent(b,!0)}}),0)}updateCompositionElements(C){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){const b=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),S=this._renderService.dimensions.css.cell.height,v=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,_=b*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=_+"px",this._compositionView.style.top=v+"px",this._compositionView.style.height=S+"px",this._compositionView.style.lineHeight=S+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";const E=this._compositionView.getBoundingClientRect();this._textarea.style.left=_+"px",this._textarea.style.top=v+"px",this._textarea.style.width=Math.max(E.width,1)+"px",this._textarea.style.height=Math.max(E.height,1)+"px",this._textarea.style.lineHeight=E.height+"px"}C||setTimeout((()=>this.updateCompositionElements(!0)),0)}}};c.CompositionHelper=w=f([p(2,x.IBufferService),p(3,x.IOptionsService),p(4,x.ICoreService),p(5,m.IRenderService)],w)},9806:(u,c)=>{function d(f,p,m){const x=m.getBoundingClientRect(),y=f.getComputedStyle(m),w=parseInt(y.getPropertyValue("padding-left")),C=parseInt(y.getPropertyValue("padding-top"));return[p.clientX-x.left-w,p.clientY-x.top-C]}Object.defineProperty(c,"__esModule",{value:!0}),c.getCoords=c.getCoordsRelativeToElement=void 0,c.getCoordsRelativeToElement=d,c.getCoords=function(f,p,m,x,y,w,C,b,S){if(!w)return;const v=d(f,p,m);return v?(v[0]=Math.ceil((v[0]+(S?C/2:0))/C),v[1]=Math.ceil(v[1]/b),v[0]=Math.min(Math.max(v[0],1),x+(S?1:0)),v[1]=Math.min(Math.max(v[1],1),y),v):void 0}},9504:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.moveToCellSequence=void 0;const f=d(2584);function p(b,S,v,_){const E=b-m(b,v),j=S-m(S,v),T=Math.abs(E-j)-(function(R,A,D){let $=0;const q=R-m(R,D),G=A-m(A,D);for(let I=0;I<Math.abs(q-G);I++){const U=x(R,A)==="A"?-1:1,V=D.buffer.lines.get(q+U*I);V!=null&&V.isWrapped&&$++}return $})(b,S,v);return C(T,w(x(b,S),_))}function m(b,S){let v=0,_=S.buffer.lines.get(b),E=_==null?void 0:_.isWrapped;for(;E&&b>=0&&b<S.rows;)v++,_=S.buffer.lines.get(--b),E=_==null?void 0:_.isWrapped;return v}function x(b,S){return b>S?"A":"B"}function y(b,S,v,_,E,j){let T=b,R=S,A="";for(;T!==v||R!==_;)T+=E?1:-1,E&&T>j.cols-1?(A+=j.buffer.translateBufferLineToString(R,!1,b,T),T=0,b=0,R++):!E&&T<0&&(A+=j.buffer.translateBufferLineToString(R,!1,0,b+1),T=j.cols-1,b=T,R--);return A+j.buffer.translateBufferLineToString(R,!1,b,T)}function w(b,S){const v=S?"O":"[";return f.C0.ESC+v+b}function C(b,S){b=Math.floor(b);let v="";for(let _=0;_<b;_++)v+=S;return v}c.moveToCellSequence=function(b,S,v,_){const E=v.buffer.x,j=v.buffer.y;if(!v.buffer.hasScrollback)return(function(A,D,$,q,G,I){return p(D,q,G,I).length===0?"":C(y(A,D,A,D-m(D,G),!1,G).length,w("D",I))})(E,j,0,S,v,_)+p(j,S,v,_)+(function(A,D,$,q,G,I){let U;U=p(D,q,G,I).length>0?q-m(q,G):D;const V=q,z=(function(J,Z,H,O,B,W){let P;return P=p(H,O,B,W).length>0?O-m(O,B):Z,J<H&&P<=O||J>=H&&P<O?"C":"D"})(A,D,$,q,G,I);return C(y(A,U,$,V,z==="C",G).length,w(z,I))})(E,j,b,S,v,_);let T;if(j===S)return T=E>b?"D":"C",C(Math.abs(E-b),w(T,_));T=j>S?"D":"C";const R=Math.abs(j-S);return C((function(A,D){return D.cols-A})(j>S?b:E,v)+(R-1)*v.cols+1+((j>S?E:b)-1),w(T,_))}},1296:function(u,c,d){var f=this&&this.__decorate||function(I,U,V,z){var J,Z=arguments.length,H=Z<3?U:z===null?z=Object.getOwnPropertyDescriptor(U,V):z;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")H=Reflect.decorate(I,U,V,z);else for(var O=I.length-1;O>=0;O--)(J=I[O])&&(H=(Z<3?J(H):Z>3?J(U,V,H):J(U,V))||H);return Z>3&&H&&Object.defineProperty(U,V,H),H},p=this&&this.__param||function(I,U){return function(V,z){U(V,z,I)}};Object.defineProperty(c,"__esModule",{value:!0}),c.DomRenderer=void 0;const m=d(3787),x=d(2550),y=d(2223),w=d(6171),C=d(6052),b=d(4725),S=d(8055),v=d(8460),_=d(844),E=d(2585),j="xterm-dom-renderer-owner-",T="xterm-rows",R="xterm-fg-",A="xterm-bg-",D="xterm-focus",$="xterm-selection";let q=1,G=c.DomRenderer=class extends _.Disposable{constructor(I,U,V,z,J,Z,H,O,B,W,P,ee,X){super(),this._terminal=I,this._document=U,this._element=V,this._screenElement=z,this._viewportElement=J,this._helperContainer=Z,this._linkifier2=H,this._charSizeService=B,this._optionsService=W,this._bufferService=P,this._coreBrowserService=ee,this._themeService=X,this._terminalClass=q++,this._rowElements=[],this._selectionRenderModel=(0,C.createSelectionRenderModel)(),this.onRequestRedraw=this.register(new v.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($),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((ne=>this._injectCss(ne)))),this._injectCss(this._themeService.colors),this._rowFactory=O.createInstance(m.DomRendererRowFactory,document),this._element.classList.add(j+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this.register(this._linkifier2.onShowLinkUnderline((ne=>this._handleLinkHover(ne)))),this.register(this._linkifier2.onHideLinkUnderline((ne=>this._handleLinkLeave(ne)))),this.register((0,_.toDisposable)((()=>{this._element.classList.remove(j+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()}))),this._widthCache=new x.WidthCache(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){const I=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*I,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*I),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/I),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/I),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(I){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let U=`${this._terminalSelector} .${T} { color: ${I.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(I.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}`,J=`blink_block_${this._terminalClass}`;U+=`@keyframes ${V} { 50% { border-bottom-style: hidden; }}`,U+=`@keyframes ${z} { 50% { box-shadow: none; }}`,U+=`@keyframes ${J} { 0% { background-color: ${I.cursor.css}; color: ${I.cursorAccent.css}; } 50% { background-color: inherit; color: ${I.cursor.css}; }}`,U+=`${this._terminalSelector} .${T}.${D} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${V} 1s step-end infinite;}${this._terminalSelector} .${T}.${D} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${z} 1s step-end infinite;}${this._terminalSelector} .${T}.${D} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${J} 1s step-end infinite;}${this._terminalSelector} .${T} .xterm-cursor.xterm-cursor-block { background-color: ${I.cursor.css}; color: ${I.cursorAccent.css};}${this._terminalSelector} .${T} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${I.cursor.css} !important; color: ${I.cursorAccent.css} !important;}${this._terminalSelector} .${T} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${I.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${T} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${I.cursor.css} inset;}${this._terminalSelector} .${T} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${I.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,U+=`${this._terminalSelector} .${$} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${$} div { position: absolute; background-color: ${I.selectionBackgroundOpaque.css};}${this._terminalSelector} .${$} div { position: absolute; background-color: ${I.selectionInactiveBackgroundOpaque.css};}`;for(const[Z,H]of I.ansi.entries())U+=`${this._terminalSelector} .${R}${Z} { color: ${H.css}; }${this._terminalSelector} .${R}${Z}.xterm-dim { color: ${S.color.multiplyOpacity(H,.5).css}; }${this._terminalSelector} .${A}${Z} { background-color: ${H.css}; }`;U+=`${this._terminalSelector} .${R}${y.INVERTED_DEFAULT_COLOR} { color: ${S.color.opaque(I.background).css}; }${this._terminalSelector} .${R}${y.INVERTED_DEFAULT_COLOR}.xterm-dim { color: ${S.color.multiplyOpacity(S.color.opaque(I.background),.5).css}; }${this._terminalSelector} .${A}${y.INVERTED_DEFAULT_COLOR} { background-color: ${I.foreground.css}; }`,this._themeStyleElement.textContent=U}_setDefaultSpacing(){const I=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${I}px`,this._rowFactory.defaultSpacing=I}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(I,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(I,U){this._refreshRowElements(I,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(D),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(D),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(I,U,V){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(I,U,V),this.renderRows(0,this._bufferService.rows-1),!I||!U)return;this._selectionRenderModel.update(this._terminal,I,U,V);const z=this._selectionRenderModel.viewportStartRow,J=this._selectionRenderModel.viewportEndRow,Z=this._selectionRenderModel.viewportCappedStartRow,H=this._selectionRenderModel.viewportCappedEndRow;if(Z>=this._bufferService.rows||H<0)return;const O=this._document.createDocumentFragment();if(V){const B=I[0]>U[0];O.appendChild(this._createSelectionElement(Z,B?U[0]:I[0],B?I[0]:U[0],H-Z+1))}else{const B=z===Z?I[0]:0,W=Z===J?U[0]:this._bufferService.cols;O.appendChild(this._createSelectionElement(Z,B,W));const P=H-Z-1;if(O.appendChild(this._createSelectionElement(Z+1,0,this._bufferService.cols,P)),Z!==H){const ee=J===H?U[0]:this._bufferService.cols;O.appendChild(this._createSelectionElement(H,0,ee))}}this._selectionContainer.appendChild(O)}_createSelectionElement(I,U,V,z=1){const J=this._document.createElement("div"),Z=U*this.dimensions.css.cell.width;let H=this.dimensions.css.cell.width*(V-U);return Z+H>this.dimensions.css.canvas.width&&(H=this.dimensions.css.canvas.width-Z),J.style.height=z*this.dimensions.css.cell.height+"px",J.style.top=I*this.dimensions.css.cell.height+"px",J.style.left=`${Z}px`,J.style.width=`${H}px`,J}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 I of this._rowElements)I.replaceChildren()}renderRows(I,U){const V=this._bufferService.buffer,z=V.ybase+V.y,J=Math.min(V.x,this._bufferService.cols-1),Z=this._optionsService.rawOptions.cursorBlink,H=this._optionsService.rawOptions.cursorStyle,O=this._optionsService.rawOptions.cursorInactiveStyle;for(let B=I;B<=U;B++){const W=B+V.ydisp,P=this._rowElements[B],ee=V.lines.get(W);if(!P||!ee)break;P.replaceChildren(...this._rowFactory.createRow(ee,W,W===z,H,O,J,Z,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${j}${this._terminalClass}`}_handleLinkHover(I){this._setCellUnderline(I.x1,I.x2,I.y1,I.y2,I.cols,!0)}_handleLinkLeave(I){this._setCellUnderline(I.x1,I.x2,I.y1,I.y2,I.cols,!1)}_setCellUnderline(I,U,V,z,J,Z){V<0&&(I=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),J=Math.min(J,this._bufferService.cols);const O=this._bufferService.buffer,B=O.ybase+O.y,W=Math.min(O.x,J-1),P=this._optionsService.rawOptions.cursorBlink,ee=this._optionsService.rawOptions.cursorStyle,X=this._optionsService.rawOptions.cursorInactiveStyle;for(let ne=V;ne<=z;++ne){const Y=ne+O.ydisp,F=this._rowElements[ne],te=O.lines.get(Y);if(!F||!te)break;F.replaceChildren(...this._rowFactory.createRow(te,Y,Y===B,ee,X,W,P,this.dimensions.css.cell.width,this._widthCache,Z?ne===V?I:0:-1,Z?(ne===z?U:J)-1:-1))}}};c.DomRenderer=G=f([p(7,E.IInstantiationService),p(8,b.ICharSizeService),p(9,E.IOptionsService),p(10,E.IBufferService),p(11,b.ICoreBrowserService),p(12,b.IThemeService)],G)},3787:function(u,c,d){var f=this&&this.__decorate||function(T,R,A,D){var $,q=arguments.length,G=q<3?R:D===null?D=Object.getOwnPropertyDescriptor(R,A):D;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")G=Reflect.decorate(T,R,A,D);else for(var I=T.length-1;I>=0;I--)($=T[I])&&(G=(q<3?$(G):q>3?$(R,A,G):$(R,A))||G);return q>3&&G&&Object.defineProperty(R,A,G),G},p=this&&this.__param||function(T,R){return function(A,D){R(A,D,T)}};Object.defineProperty(c,"__esModule",{value:!0}),c.DomRendererRowFactory=void 0;const m=d(2223),x=d(643),y=d(511),w=d(2585),C=d(8055),b=d(4725),S=d(4269),v=d(6171),_=d(3734);let E=c.DomRendererRowFactory=class{constructor(T,R,A,D,$,q,G){this._document=T,this._characterJoinerService=R,this._optionsService=A,this._coreBrowserService=D,this._coreService=$,this._decorationService=q,this._themeService=G,this._workCell=new y.CellData,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(T,R,A){this._selectionStart=T,this._selectionEnd=R,this._columnSelectMode=A}createRow(T,R,A,D,$,q,G,I,U,V,z){const J=[],Z=this._characterJoinerService.getJoinedCharacters(R),H=this._themeService.colors;let O,B=T.getNoBgTrimmedLength();A&&B<q+1&&(B=q+1);let W=0,P="",ee=0,X=0,ne=0,Y=!1,F=0,te=!1,se=0;const xe=[],le=V!==-1&&z!==-1;for(let Ee=0;Ee<B;Ee++){T.loadCell(Ee,this._workCell);let ue=this._workCell.getWidth();if(ue===0)continue;let ae=!1,de=Ee,oe=this._workCell;if(Z.length>0&&Ee===Z[0][0]){ae=!0;const nt=Z.shift();oe=new S.JoinedCellData(this._workCell,T.translateToString(!0,nt[0],nt[1]),nt[1]-nt[0]),de=nt[1]-1,ue=oe.getWidth()}const Ne=this._isCellInSelection(Ee,R),ve=A&&Ee===q,re=le&&Ee>=V&&Ee<=z;let _e=!1;this._decorationService.forEachDecorationAtCell(Ee,R,void 0,(nt=>{_e=!0}));let He=oe.getChars()||x.WHITESPACE_CELL_CHAR;if(He===" "&&(oe.isUnderline()||oe.isOverline())&&(He=" "),se=ue*I-U.get(He,oe.isBold(),oe.isItalic()),O){if(W&&(Ne&&te||!Ne&&!te&&oe.bg===ee)&&(Ne&&te&&H.selectionForeground||oe.fg===X)&&oe.extended.ext===ne&&re===Y&&se===F&&!ve&&!ae&&!_e){oe.isInvisible()?P+=x.WHITESPACE_CELL_CHAR:P+=He,W++;continue}W&&(O.textContent=P),O=this._document.createElement("span"),W=0,P=""}else O=this._document.createElement("span");if(ee=oe.bg,X=oe.fg,ne=oe.extended.ext,Y=re,F=se,te=Ne,ae&&q>=Ee&&q<=de&&(q=Ee),!this._coreService.isCursorHidden&&ve&&this._coreService.isCursorInitialized){if(xe.push("xterm-cursor"),this._coreBrowserService.isFocused)G&&xe.push("xterm-cursor-blink"),xe.push(D==="bar"?"xterm-cursor-bar":D==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if($)switch($){case"outline":xe.push("xterm-cursor-outline");break;case"block":xe.push("xterm-cursor-block");break;case"bar":xe.push("xterm-cursor-bar");break;case"underline":xe.push("xterm-cursor-underline")}}if(oe.isBold()&&xe.push("xterm-bold"),oe.isItalic()&&xe.push("xterm-italic"),oe.isDim()&&xe.push("xterm-dim"),P=oe.isInvisible()?x.WHITESPACE_CELL_CHAR:oe.getChars()||x.WHITESPACE_CELL_CHAR,oe.isUnderline()&&(xe.push(`xterm-underline-${oe.extended.underlineStyle}`),P===" "&&(P=" "),!oe.isUnderlineColorDefault()))if(oe.isUnderlineColorRGB())O.style.textDecorationColor=`rgb(${_.AttributeData.toColorRGB(oe.getUnderlineColor()).join(",")})`;else{let nt=oe.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&oe.isBold()&&nt<8&&(nt+=8),O.style.textDecorationColor=H.ansi[nt].css}oe.isOverline()&&(xe.push("xterm-overline"),P===" "&&(P=" ")),oe.isStrikethrough()&&xe.push("xterm-strikethrough"),re&&(O.style.textDecoration="underline");let et=oe.getFgColor(),rt=oe.getFgColorMode(),kt=oe.getBgColor(),ye=oe.getBgColorMode();const Ae=!!oe.isInverse();if(Ae){const nt=et;et=kt,kt=nt;const Ot=rt;rt=ye,ye=Ot}let Be,Ge,Xe,Dt=!1;switch(this._decorationService.forEachDecorationAtCell(Ee,R,void 0,(nt=>{nt.options.layer!=="top"&&Dt||(nt.backgroundColorRGB&&(ye=50331648,kt=nt.backgroundColorRGB.rgba>>8&16777215,Be=nt.backgroundColorRGB),nt.foregroundColorRGB&&(rt=50331648,et=nt.foregroundColorRGB.rgba>>8&16777215,Ge=nt.foregroundColorRGB),Dt=nt.options.layer==="top")})),!Dt&&Ne&&(Be=this._coreBrowserService.isFocused?H.selectionBackgroundOpaque:H.selectionInactiveBackgroundOpaque,kt=Be.rgba>>8&16777215,ye=50331648,Dt=!0,H.selectionForeground&&(rt=50331648,et=H.selectionForeground.rgba>>8&16777215,Ge=H.selectionForeground)),Dt&&xe.push("xterm-decoration-top"),ye){case 16777216:case 33554432:Xe=H.ansi[kt],xe.push(`xterm-bg-${kt}`);break;case 50331648:Xe=C.channels.toColor(kt>>16,kt>>8&255,255&kt),this._addStyle(O,`background-color:#${j((kt>>>0).toString(16),"0",6)}`);break;default:Ae?(Xe=H.foreground,xe.push(`xterm-bg-${m.INVERTED_DEFAULT_COLOR}`)):Xe=H.background}switch(Be||oe.isDim()&&(Be=C.color.multiplyOpacity(Xe,.5)),rt){case 16777216:case 33554432:oe.isBold()&&et<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(et+=8),this._applyMinimumContrast(O,Xe,H.ansi[et],oe,Be,void 0)||xe.push(`xterm-fg-${et}`);break;case 50331648:const nt=C.channels.toColor(et>>16&255,et>>8&255,255&et);this._applyMinimumContrast(O,Xe,nt,oe,Be,Ge)||this._addStyle(O,`color:#${j(et.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(O,Xe,H.foreground,oe,Be,Ge)||Ae&&xe.push(`xterm-fg-${m.INVERTED_DEFAULT_COLOR}`)}xe.length&&(O.className=xe.join(" "),xe.length=0),ve||ae||_e?O.textContent=P:W++,se!==this.defaultSpacing&&(O.style.letterSpacing=`${se}px`),J.push(O),Ee=de}return O&&W&&(O.textContent=P),J}_applyMinimumContrast(T,R,A,D,$,q){if(this._optionsService.rawOptions.minimumContrastRatio===1||(0,v.treatGlyphAsBackgroundColor)(D.getCode()))return!1;const G=this._getContrastCache(D);let I;if($||q||(I=G.getColor(R.rgba,A.rgba)),I===void 0){const U=this._optionsService.rawOptions.minimumContrastRatio/(D.isDim()?2:1);I=C.color.ensureContrastRatio($||R,q||A,U),G.setColor(($||R).rgba,(q||A).rgba,I??null)}return!!I&&(this._addStyle(T,`color:${I.css}`),!0)}_getContrastCache(T){return T.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(T,R){T.setAttribute("style",`${T.getAttribute("style")||""}${R};`)}_isCellInSelection(T,R){const A=this._selectionStart,D=this._selectionEnd;return!(!A||!D)&&(this._columnSelectMode?A[0]<=D[0]?T>=A[0]&&R>=A[1]&&T<D[0]&&R<=D[1]:T<A[0]&&R>=A[1]&&T>=D[0]&&R<=D[1]:R>A[1]&&R<D[1]||A[1]===D[1]&&R===A[1]&&T>=A[0]&&T<D[0]||A[1]<D[1]&&R===D[1]&&T<D[0]||A[1]<D[1]&&R===A[1]&&T>=A[0])}};function j(T,R,A){for(;T.length<A;)T=R+T;return T}c.DomRendererRowFactory=E=f([p(1,b.ICharacterJoinerService),p(2,w.IOptionsService),p(3,b.ICoreBrowserService),p(4,w.ICoreService),p(5,w.IDecorationService),p(6,b.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 p=d.createElement("span");p.classList.add("xterm-char-measure-element");const m=d.createElement("span");m.classList.add("xterm-char-measure-element"),m.style.fontWeight="bold";const x=d.createElement("span");x.classList.add("xterm-char-measure-element"),x.style.fontStyle="italic";const y=d.createElement("span");y.classList.add("xterm-char-measure-element"),y.style.fontWeight="bold",y.style.fontStyle="italic",this._measureElements=[p,m,x,y],this._container.appendChild(p),this._container.appendChild(m),this._container.appendChild(x),this._container.appendChild(y),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,p,m){d===this._font&&f===this._fontSize&&p===this._weight&&m===this._weightBold||(this._font=d,this._fontSize=f,this._weight=p,this._weightBold=m,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${p}`,this._measureElements[1].style.fontWeight=`${m}`,this._measureElements[2].style.fontWeight=`${p}`,this._measureElements[3].style.fontWeight=`${m}`,this.clear())}get(d,f,p){let m=0;if(!f&&!p&&d.length===1&&(m=d.charCodeAt(0))<256){if(this._flat[m]!==-9999)return this._flat[m];const w=this._measure(d,0);return w>0&&(this._flat[m]=w),w}let x=d;f&&(x+="B"),p&&(x+="I");let y=this._holey.get(x);if(y===void 0){let w=0;f&&(w|=1),p&&(w|=2),y=this._measure(d,w),y>0&&this._holey.set(x,y)}return y}_measure(d,f){const p=this._measureElements[f];return p.textContent=d.repeat(32),p.offsetWidth/32}}},2223:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.TEXT_BASELINE=c.DIM_OPACITY=c.INVERTED_DEFAULT_COLOR=void 0;const 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(p){return 57508<=p&&p<=57558}function f(p){return p>=128512&&p<=128591||p>=127744&&p<=128511||p>=128640&&p<=128767||p>=9728&&p<=9983||p>=9984&&p<=10175||p>=65024&&p<=65039||p>=129280&&p<=129535||p>=127462&&p<=127487}Object.defineProperty(c,"__esModule",{value:!0}),c.computeNextVariantOffset=c.createRenderDimensions=c.treatGlyphAsBackgroundColor=c.allowRescaling=c.isEmoji=c.isRestrictedPowerlineGlyph=c.isPowerlineGlyph=c.throwIfFalsy=void 0,c.throwIfFalsy=function(p){if(!p)throw new Error("value must not be falsy");return p},c.isPowerlineGlyph=d,c.isRestrictedPowerlineGlyph=function(p){return 57520<=p&&p<=57527},c.isEmoji=f,c.allowRescaling=function(p,m,x,y){return m===1&&x>Math.ceil(1.5*y)&&p!==void 0&&p>255&&!f(p)&&!d(p)&&!(function(w){return 57344<=w&&w<=63743})(p)},c.treatGlyphAsBackgroundColor=function(p){return d(p)||(function(m){return 9472<=m&&m<=9631})(p)},c.createRenderDimensions=function(){return{css:{canvas:{width:0,height:0},cell:{width:0,height:0}},device:{canvas:{width:0,height:0},cell:{width:0,height:0},char:{width:0,height:0,left:0,top:0}}}},c.computeNextVariantOffset=function(p,m,x=0){return(p-(2*Math.round(m)-x))%(2*Math.round(m))}},6052:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.createSelectionRenderModel=void 0;class d{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(p,m,x,y=!1){if(this.selectionStart=m,this.selectionEnd=x,!m||!x||m[0]===x[0]&&m[1]===x[1])return void this.clear();const w=p.buffers.active.ydisp,C=m[1]-w,b=x[1]-w,S=Math.max(C,0),v=Math.min(b,p.rows-1);S>=p.rows||v<0?this.clear():(this.hasSelection=!0,this.columnSelectMode=y,this.viewportStartRow=C,this.viewportEndRow=b,this.viewportCappedStartRow=S,this.viewportCappedEndRow=v,this.startCol=m[0],this.endCol=x[0])}isCellSelected(p,m,x){return!!this.hasSelection&&(x-=p.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?m>=this.startCol&&x>=this.viewportCappedStartRow&&m<this.endCol&&x<=this.viewportCappedEndRow:m<this.startCol&&x>=this.viewportCappedStartRow&&m>=this.endCol&&x<=this.viewportCappedEndRow:x>this.viewportStartRow&&x<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&x===this.viewportStartRow&&m>=this.startCol&&m<this.endCol||this.viewportStartRow<this.viewportEndRow&&x===this.viewportEndRow&&m<this.endCol||this.viewportStartRow<this.viewportEndRow&&x===this.viewportStartRow&&m>=this.startCol)}}c.createSelectionRenderModel=function(){return new d}},456:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.SelectionModel=void 0,c.SelectionModel=class{constructor(d){this._bufferService=d,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:this.selectionEnd&&this.selectionStart&&this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){const d=this.selectionStart[0]+this.selectionStartLength;return d>this._bufferService.cols?d%this._bufferService.cols==0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(d/this._bufferService.cols)-1]:[d%this._bufferService.cols,this.selectionStart[1]+Math.floor(d/this._bufferService.cols)]:[d,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){const d=this.selectionStart[0]+this.selectionStartLength;return d>this._bufferService.cols?[d%this._bufferService.cols,this.selectionStart[1]+Math.floor(d/this._bufferService.cols)]:[Math.max(d,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){const d=this.selectionStart,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(v,_,E,j){var T,R=arguments.length,A=R<3?_:j===null?j=Object.getOwnPropertyDescriptor(_,E):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(v,_,E,j);else for(var D=v.length-1;D>=0;D--)(T=v[D])&&(A=(R<3?T(A):R>3?T(_,E,A):T(_,E))||A);return R>3&&A&&Object.defineProperty(_,E,A),A},p=this&&this.__param||function(v,_){return function(E,j){_(E,j,v)}};Object.defineProperty(c,"__esModule",{value:!0}),c.CharSizeService=void 0;const m=d(2585),x=d(8460),y=d(844);let w=c.CharSizeService=class extends y.Disposable{get hasValidSize(){return this.width>0&&this.height>0}constructor(v,_,E){super(),this._optionsService=E,this.width=0,this.height=0,this._onCharSizeChange=this.register(new x.EventEmitter),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this.register(new S(this._optionsService))}catch{this._measureStrategy=this.register(new b(v,_,this._optionsService))}this.register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],(()=>this.measure())))}measure(){const v=this._measureStrategy.measure();v.width===this.width&&v.height===this.height||(this.width=v.width,this.height=v.height,this._onCharSizeChange.fire())}};c.CharSizeService=w=f([p(2,m.IOptionsService)],w);class C extends y.Disposable{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(_,E){_!==void 0&&_>0&&E!==void 0&&E>0&&(this._result.width=_,this._result.height=E)}}class b extends C{constructor(_,E,j){super(),this._document=_,this._parentElement=E,this._optionsService=j,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(_){super(),this._optionsService=_,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 _=this._ctx.measureText("W");return this._validateAndSet(_.width,_.fontBoundingBoxAscent+_.fontBoundingBoxDescent),this._result}}},4269:function(u,c,d){var f=this&&this.__decorate||function(S,v,_,E){var j,T=arguments.length,R=T<3?v:E===null?E=Object.getOwnPropertyDescriptor(v,_):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(S,v,_,E);else for(var A=S.length-1;A>=0;A--)(j=S[A])&&(R=(T<3?j(R):T>3?j(v,_,R):j(v,_))||R);return T>3&&R&&Object.defineProperty(v,_,R),R},p=this&&this.__param||function(S,v){return function(_,E){v(_,E,S)}};Object.defineProperty(c,"__esModule",{value:!0}),c.CharacterJoinerService=c.JoinedCellData=void 0;const m=d(3734),x=d(643),y=d(511),w=d(2585);class C extends m.AttributeData{constructor(v,_,E){super(),this.content=0,this.combinedData="",this.fg=v.fg,this.bg=v.bg,this.combinedData=_,this._width=E}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(v){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}c.JoinedCellData=C;let b=c.CharacterJoinerService=class KS{constructor(v){this._bufferService=v,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new y.CellData}register(v){const _={id:this._nextCharacterJoinerId++,handler:v};return this._characterJoiners.push(_),_.id}deregister(v){for(let _=0;_<this._characterJoiners.length;_++)if(this._characterJoiners[_].id===v)return this._characterJoiners.splice(_,1),!0;return!1}getJoinedCharacters(v){if(this._characterJoiners.length===0)return[];const _=this._bufferService.buffer.lines.get(v);if(!_||_.length===0)return[];const E=[],j=_.translateToString(!0);let T=0,R=0,A=0,D=_.getFg(0),$=_.getBg(0);for(let q=0;q<_.getTrimmedLength();q++)if(_.loadCell(q,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==D||this._workCell.bg!==$){if(q-T>1){const G=this._getJoinedRanges(j,A,R,_,T);for(let I=0;I<G.length;I++)E.push(G[I])}T=q,A=R,D=this._workCell.fg,$=this._workCell.bg}R+=this._workCell.getChars().length||x.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-T>1){const q=this._getJoinedRanges(j,A,R,_,T);for(let G=0;G<q.length;G++)E.push(q[G])}return E}_getJoinedRanges(v,_,E,j,T){const R=v.substring(_,E);let A=[];try{A=this._characterJoiners[0].handler(R)}catch(D){console.error(D)}for(let D=1;D<this._characterJoiners.length;D++)try{const $=this._characterJoiners[D].handler(R);for(let q=0;q<$.length;q++)KS._mergeRanges(A,$[q])}catch($){console.error($)}return this._stringRangesToCellRanges(A,j,T),A}_stringRangesToCellRanges(v,_,E){let j=0,T=!1,R=0,A=v[j];if(A){for(let D=E;D<this._bufferService.cols;D++){const $=_.getWidth(D),q=_.getString(D).length||x.WHITESPACE_CELL_CHAR.length;if($!==0){if(!T&&A[0]<=R&&(A[0]=D,T=!0),A[1]<=R){if(A[1]=D,A=v[++j],!A)break;A[0]<=R?(A[0]=D,T=!0):T=!1}R+=q}}A&&(A[1]=this._bufferService.cols)}}static _mergeRanges(v,_){let E=!1;for(let j=0;j<v.length;j++){const T=v[j];if(E){if(_[1]<=T[0])return v[j-1][1]=_[1],v;if(_[1]<=T[1])return v[j-1][1]=Math.max(_[1],T[1]),v.splice(j,1),v;v.splice(j,1),j--}else{if(_[1]<=T[0])return v.splice(j,0,_),v;if(_[1]<=T[1])return T[0]=Math.min(_[0],T[0]),v;_[0]<T[1]&&(T[0]=Math.min(_[0],T[0]),E=!0)}}return E?v[v.length-1][1]=_[1]:v.push(_),v}};c.CharacterJoinerService=b=f([p(0,w.IBufferService)],b)},5114:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.CoreBrowserService=void 0;const f=d(844),p=d(8460),m=d(3656);class x extends f.Disposable{constructor(C,b,S){super(),this._textarea=C,this._window=b,this.mainDocument=S,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=new y(this._window),this._onDprChange=this.register(new p.EventEmitter),this.onDprChange=this._onDprChange.event,this._onWindowChange=this.register(new p.EventEmitter),this.onWindowChange=this._onWindowChange.event,this.register(this.onWindowChange((v=>this._screenDprMonitor.setWindow(v)))),this.register((0,p.forwardEvent)(this._screenDprMonitor.onDprChange,this._onDprChange)),this._textarea.addEventListener("focus",(()=>this._isFocused=!0)),this._textarea.addEventListener("blur",(()=>this._isFocused=!1))}get window(){return this._window}set window(C){this._window!==C&&(this._window=C,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask((()=>this._cachedIsFocused=void 0))),this._cachedIsFocused}}c.CoreBrowserService=x;class y extends f.Disposable{constructor(C){super(),this._parentWindow=C,this._windowResizeListener=this.register(new f.MutableDisposable),this._onDprChange=this.register(new p.EventEmitter),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this.register((0,f.toDisposable)((()=>this.clearListener())))}setWindow(C){this._parentWindow=C,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=(0,m.addDisposableDomListener)(this._parentWindow,"resize",(()=>this._setDprAndFireIfDiffers()))}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var C;this._outerListener&&((C=this._resolutionMediaMatchList)==null||C.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){this._resolutionMediaMatchList&&this._outerListener&&(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}}},779:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.LinkProviderService=void 0;const f=d(844);class p extends f.Disposable{constructor(){super(),this.linkProviders=[],this.register((0,f.toDisposable)((()=>this.linkProviders.length=0)))}registerLinkProvider(x){return this.linkProviders.push(x),{dispose:()=>{const y=this.linkProviders.indexOf(x);y!==-1&&this.linkProviders.splice(y,1)}}}}c.LinkProviderService=p},8934:function(u,c,d){var f=this&&this.__decorate||function(w,C,b,S){var v,_=arguments.length,E=_<3?C:S===null?S=Object.getOwnPropertyDescriptor(C,b):S;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(w,C,b,S);else for(var j=w.length-1;j>=0;j--)(v=w[j])&&(E=(_<3?v(E):_>3?v(C,b,E):v(C,b))||E);return _>3&&E&&Object.defineProperty(C,b,E),E},p=this&&this.__param||function(w,C){return function(b,S){C(b,S,w)}};Object.defineProperty(c,"__esModule",{value:!0}),c.MouseService=void 0;const m=d(4725),x=d(9806);let y=c.MouseService=class{constructor(w,C){this._renderService=w,this._charSizeService=C}getCoords(w,C,b,S,v){return(0,x.getCoords)(window,w,C,b,S,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,v)}getMouseReportCoords(w,C){const b=(0,x.getCoordsRelativeToElement)(window,w,C);if(this._charSizeService.hasValidSize)return b[0]=Math.min(Math.max(b[0],0),this._renderService.dimensions.css.canvas.width-1),b[1]=Math.min(Math.max(b[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(b[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(b[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(b[0]),y:Math.floor(b[1])}}};c.MouseService=y=f([p(0,m.IRenderService),p(1,m.ICharSizeService)],y)},3230:function(u,c,d){var f=this&&this.__decorate||function(v,_,E,j){var T,R=arguments.length,A=R<3?_:j===null?j=Object.getOwnPropertyDescriptor(_,E):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(v,_,E,j);else for(var D=v.length-1;D>=0;D--)(T=v[D])&&(A=(R<3?T(A):R>3?T(_,E,A):T(_,E))||A);return R>3&&A&&Object.defineProperty(_,E,A),A},p=this&&this.__param||function(v,_){return function(E,j){_(E,j,v)}};Object.defineProperty(c,"__esModule",{value:!0}),c.RenderService=void 0;const m=d(6193),x=d(4725),y=d(8460),w=d(844),C=d(7226),b=d(2585);let S=c.RenderService=class extends w.Disposable{get dimensions(){return this._renderer.value.dimensions}constructor(v,_,E,j,T,R,A,D){super(),this._rowCount=v,this._charSizeService=j,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 y.EventEmitter),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this.register(new y.EventEmitter),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this.register(new y.EventEmitter),this.onRender=this._onRender.event,this._onRefreshRequest=this.register(new y.EventEmitter),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new m.RenderDebouncer((($,q)=>this._renderRows($,q)),A),this.register(this._renderDebouncer),this.register(A.onDprChange((()=>this.handleDevicePixelRatioChange()))),this.register(R.onResize((()=>this._fullRefresh()))),this.register(R.buffers.onBufferActivate((()=>{var $;return($=this._renderer.value)==null?void 0:$.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(R.cols,R.rows),this._fullRefresh()}))),this.register(E.onMultipleOptionChange(["cursorBlink","cursorStyle"],(()=>this.refreshRows(R.buffer.y,R.buffer.y,!0)))),this.register(D.onChangeColors((()=>this._fullRefresh()))),this._registerIntersectionObserver(A.window,_),this.register(A.onWindowChange(($=>this._registerIntersectionObserver($,_))))}_registerIntersectionObserver(v,_){if("IntersectionObserver"in v){const E=new v.IntersectionObserver((j=>this._handleIntersectionChange(j[j.length-1])),{threshold:0});E.observe(_),this._observerDisposable.value=(0,w.toDisposable)((()=>E.disconnect()))}}_handleIntersectionChange(v){this._isPaused=v.isIntersecting===void 0?v.intersectionRatio===0:!v.isIntersecting,this._isPaused||this._charSizeService.hasValidSize||this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(v,_,E=!1){this._isPaused?this._needsFullRefresh=!0:(E||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(v,_,this._rowCount))}_renderRows(v,_){this._renderer.value&&(v=Math.min(v,this._rowCount-1),_=Math.min(_,this._rowCount-1),this._renderer.value.renderRows(v,_),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:v,end:_}),this._onRender.fire({start:v,end:_}),this._isNextRenderRedrawOnly=!0)}resize(v,_){this._rowCount=_,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(v){this._renderer.value=v,this._renderer.value&&(this._renderer.value.onRequestRedraw((_=>this.refreshRows(_.start,_.end,!0))),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(v){return this._renderDebouncer.addRefreshCallback(v)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var v,_;this._renderer.value&&((_=(v=this._renderer.value).clearTextureAtlas)==null||_.call(v),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(v,_){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set((()=>{var E;return(E=this._renderer.value)==null?void 0:E.handleResize(v,_)})):this._renderer.value.handleResize(v,_),this._fullRefresh())}handleCharSizeChanged(){var v;(v=this._renderer.value)==null||v.handleCharSizeChanged()}handleBlur(){var v;(v=this._renderer.value)==null||v.handleBlur()}handleFocus(){var v;(v=this._renderer.value)==null||v.handleFocus()}handleSelectionChanged(v,_,E){var j;this._selectionState.start=v,this._selectionState.end=_,this._selectionState.columnSelectMode=E,(j=this._renderer.value)==null||j.handleSelectionChanged(v,_,E)}handleCursorMove(){var v;(v=this._renderer.value)==null||v.handleCursorMove()}clear(){var v;(v=this._renderer.value)==null||v.clear()}};c.RenderService=S=f([p(2,b.IOptionsService),p(3,x.ICharSizeService),p(4,b.IDecorationService),p(5,b.IBufferService),p(6,x.ICoreBrowserService),p(7,x.IThemeService)],S)},9312:function(u,c,d){var f=this&&this.__decorate||function(A,D,$,q){var G,I=arguments.length,U=I<3?D:q===null?q=Object.getOwnPropertyDescriptor(D,$):q;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")U=Reflect.decorate(A,D,$,q);else for(var V=A.length-1;V>=0;V--)(G=A[V])&&(U=(I<3?G(U):I>3?G(D,$,U):G(D,$))||U);return I>3&&U&&Object.defineProperty(D,$,U),U},p=this&&this.__param||function(A,D){return function($,q){D($,q,A)}};Object.defineProperty(c,"__esModule",{value:!0}),c.SelectionService=void 0;const m=d(9806),x=d(9504),y=d(456),w=d(4725),C=d(8460),b=d(844),S=d(6114),v=d(4841),_=d(511),E=d(2585),j=" ",T=new RegExp(j,"g");let R=c.SelectionService=class extends b.Disposable{constructor(A,D,$,q,G,I,U,V,z){super(),this._element=A,this._screenElement=D,this._linkifier=$,this._bufferService=q,this._coreService=G,this._mouseService=I,this._optionsService=U,this._renderService=V,this._coreBrowserService=z,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new _.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=J=>this._handleMouseMove(J),this._mouseUpListener=J=>this._handleMouseUp(J),this._coreService.onUserInput((()=>{this.hasSelection&&this.clearSelection()})),this._trimListener=this._bufferService.buffer.lines.onTrim((J=>this._handleTrim(J))),this.register(this._bufferService.buffers.onBufferActivate((J=>this._handleBufferActivate(J)))),this.enable(),this._model=new y.SelectionModel(this._bufferService),this._activeSelectionMode=0,this.register((0,b.toDisposable)((()=>{this._removeMouseDownListeners()})))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){const A=this._model.finalSelectionStart,D=this._model.finalSelectionEnd;return!(!A||!D||A[0]===D[0]&&A[1]===D[1])}get selectionText(){const A=this._model.finalSelectionStart,D=this._model.finalSelectionEnd;if(!A||!D)return"";const $=this._bufferService.buffer,q=[];if(this._activeSelectionMode===3){if(A[0]===D[0])return"";const G=A[0]<D[0]?A[0]:D[0],I=A[0]<D[0]?D[0]:A[0];for(let U=A[1];U<=D[1];U++){const V=$.translateBufferLineToString(U,!0,G,I);q.push(V)}}else{const G=A[1]===D[1]?D[0]:void 0;q.push($.translateBufferLineToString(A[1],!0,A[0],G));for(let I=A[1]+1;I<=D[1]-1;I++){const U=$.lines.get(I),V=$.translateBufferLineToString(I,!0);U!=null&&U.isWrapped?q[q.length-1]+=V:q.push(V)}if(A[1]!==D[1]){const I=$.lines.get(D[1]),U=$.translateBufferLineToString(D[1],!0,0,D[0]);I&&I.isWrapped?q[q.length-1]+=U:q.push(U)}}return q.map((G=>G.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 D=this._getMouseBufferCoords(A),$=this._model.finalSelectionStart,q=this._model.finalSelectionEnd;return!!($&&q&&D)&&this._areCoordsInSelection(D,$,q)}isCellInSelection(A,D){const $=this._model.finalSelectionStart,q=this._model.finalSelectionEnd;return!(!$||!q)&&this._areCoordsInSelection([A,D],$,q)}_areCoordsInSelection(A,D,$){return A[1]>D[1]&&A[1]<$[1]||D[1]===$[1]&&A[1]===D[1]&&A[0]>=D[0]&&A[0]<$[0]||D[1]<$[1]&&A[1]===$[1]&&A[0]<$[0]||D[1]<$[1]&&A[1]===D[1]&&A[0]>=D[0]}_selectWordAtCursor(A,D){var G,I;const $=(I=(G=this._linkifier.currentLink)==null?void 0:G.link)==null?void 0:I.range;if($)return this._model.selectionStart=[$.start.x-1,$.start.y-1],this._model.selectionStartLength=(0,v.getRangeLength)($,this._bufferService.cols),this._model.selectionEnd=void 0,!0;const q=this._getMouseBufferCoords(A);return!!q&&(this._selectWordAt(q,D),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(A,D){this._model.clearSelection(),A=Math.max(A,0),D=Math.min(D,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,A],this._model.selectionEnd=[this._bufferService.cols,D],this.refresh(),this._onSelectionChange.fire()}_handleTrim(A){this._model.handleTrim(A)&&this.refresh()}_getMouseBufferCoords(A){const D=this._mouseService.getCoords(A,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(D)return D[0]--,D[1]--,D[1]+=this._bufferService.buffer.ydisp,D}_getMouseEventScrollAmount(A){let D=(0,m.getCoordsRelativeToElement)(this._coreBrowserService.window,A,this._screenElement)[1];const $=this._renderService.dimensions.css.canvas.height;return D>=0&&D<=$?0:(D>$&&(D-=$),D=Math.min(Math.max(D,-50),50),D/=50,D/Math.abs(D)+Math.round(14*D))}shouldForceSelection(A){return S.isMac?A.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:A.shiftKey}handleMouseDown(A){if(this._mouseDownTimeStamp=A.timeStamp,(A.button!==2||!this.hasSelection)&&A.button===0){if(!this._enabled){if(!this.shouldForceSelection(A))return;A.stopPropagation()}A.preventDefault(),this._dragScrollAmount=0,this._enabled&&A.shiftKey?this._handleIncrementalClick(A):A.detail===1?this._handleSingleClick(A):A.detail===2?this._handleDoubleClick(A):A.detail===3&&this._handleTripleClick(A),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval((()=>this._dragScroll()),50)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(A){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(A))}_handleSingleClick(A){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(A)?3:0,this._model.selectionStart=this._getMouseBufferCoords(A),!this._model.selectionStart)return;this._model.selectionEnd=void 0;const D=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);D&&D.length!==this._model.selectionStart[0]&&D.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(A){this._selectWordAtCursor(A,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(A){const D=this._getMouseBufferCoords(A);D&&(this._activeSelectionMode=2,this._selectLineAt(D[1]))}shouldColumnSelect(A){return A.altKey&&!(S.isMac&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(A){if(A.stopImmediatePropagation(),!this._model.selectionStart)return;const D=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(A),!this._model.selectionEnd)return void this.refresh(!0);this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(A),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));const $=this._bufferService.buffer;if(this._model.selectionEnd[1]<$.lines.length){const q=$.lines.get(this._model.selectionEnd[1]);q&&q.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}D&&D[0]===this._model.selectionEnd[0]&&D[1]===this._model.selectionEnd[1]||this.refresh(!0)}_dragScroll(){if(this._model.selectionEnd&&this._model.selectionStart&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});const A=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(A.ydisp+this._bufferService.rows,A.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=A.ydisp),this.refresh()}}_handleMouseUp(A){const D=A.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&D<500&&A.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){const $=this._mouseService.getCoords(A,this._element,this._bufferService.cols,this._bufferService.rows,!1);if($&&$[0]!==void 0&&$[1]!==void 0){const q=(0,x.moveToCellSequence)($[0]-1,$[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(q,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){const A=this._model.finalSelectionStart,D=this._model.finalSelectionEnd,$=!(!A||!D||A[0]===D[0]&&A[1]===D[1]);$?A&&D&&(this._oldSelectionStart&&this._oldSelectionEnd&&A[0]===this._oldSelectionStart[0]&&A[1]===this._oldSelectionStart[1]&&D[0]===this._oldSelectionEnd[0]&&D[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(A,D,$)):this._oldHasSelection&&this._fireOnSelectionChange(A,D,$)}_fireOnSelectionChange(A,D,$){this._oldSelectionStart=A,this._oldSelectionEnd=D,this._oldHasSelection=$,this._onSelectionChange.fire()}_handleBufferActivate(A){this.clearSelection(),this._trimListener.dispose(),this._trimListener=A.activeBuffer.lines.onTrim((D=>this._handleTrim(D)))}_convertViewportColToCharacterIndex(A,D){let $=D;for(let q=0;D>=q;q++){const G=A.loadCell(q,this._workCell).getChars().length;this._workCell.getWidth()===0?$--:G>1&&D!==q&&($+=G-1)}return $}setSelection(A,D,$){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[A,D],this._model.selectionStartLength=$,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(A){this._isClickInSelection(A)||(this._selectWordAtCursor(A,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(A,D,$=!0,q=!0){if(A[0]>=this._bufferService.cols)return;const G=this._bufferService.buffer,I=G.lines.get(A[1]);if(!I)return;const U=G.translateBufferLineToString(A[1],!1);let V=this._convertViewportColToCharacterIndex(I,A[0]),z=V;const J=A[0]-V;let Z=0,H=0,O=0,B=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],X=A[0];I.getWidth(ee)===0&&(Z++,ee--),I.getWidth(X)===2&&(H++,X++);const ne=I.getString(X).length;for(ne>1&&(B+=ne-1,z+=ne-1);ee>0&&V>0&&!this._isCharWordSeparator(I.loadCell(ee-1,this._workCell));){I.loadCell(ee-1,this._workCell);const Y=this._workCell.getChars().length;this._workCell.getWidth()===0?(Z++,ee--):Y>1&&(O+=Y-1,V-=Y-1),V--,ee--}for(;X<I.length&&z+1<U.length&&!this._isCharWordSeparator(I.loadCell(X+1,this._workCell));){I.loadCell(X+1,this._workCell);const Y=this._workCell.getChars().length;this._workCell.getWidth()===2?(H++,X++):Y>1&&(B+=Y-1,z+=Y-1),z++,X++}}z++;let W=V+J-Z+O,P=Math.min(this._bufferService.cols,z-V+Z+H-O-B);if(D||U.slice(V,z).trim()!==""){if($&&W===0&&I.getCodePoint(0)!==32){const ee=G.lines.get(A[1]-1);if(ee&&I.isWrapped&&ee.getCodePoint(this._bufferService.cols-1)!==32){const X=this._getWordAt([this._bufferService.cols-1,A[1]-1],!1,!0,!1);if(X){const ne=this._bufferService.cols-X.start;W-=ne,P+=ne}}}if(q&&W+P===this._bufferService.cols&&I.getCodePoint(this._bufferService.cols-1)!==32){const ee=G.lines.get(A[1]+1);if(ee!=null&&ee.isWrapped&&ee.getCodePoint(0)!==32){const X=this._getWordAt([0,A[1]+1],!1,!1,!0);X&&(P+=X.length)}}return{start:W,length:P}}}_selectWordAt(A,D){const $=this._getWordAt(A,D);if($){for(;$.start<0;)$.start+=this._bufferService.cols,A[1]--;this._model.selectionStart=[$.start,A[1]],this._model.selectionStartLength=$.length}}_selectToWordAt(A){const D=this._getWordAt(A,!0);if(D){let $=A[1];for(;D.start<0;)D.start+=this._bufferService.cols,$--;if(!this._model.areSelectionValuesReversed())for(;D.start+D.length>this._bufferService.cols;)D.length-=this._bufferService.cols,$++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?D.start:D.start+D.length,$]}}_isCharWordSeparator(A){return A.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(A.getChars())>=0}_selectLineAt(A){const D=this._bufferService.buffer.getWrappedRangeForLine(A),$={start:{x:0,y:D.first},end:{x:this._bufferService.cols-1,y:D.last}};this._model.selectionStart=[0,D.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=(0,v.getRangeLength)($,this._bufferService.cols)}};c.SelectionService=R=f([p(3,E.IBufferService),p(4,E.ICoreService),p(5,w.IMouseService),p(6,E.IOptionsService),p(7,w.IRenderService),p(8,w.ICoreBrowserService)],R)},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(R,A,D,$){var q,G=arguments.length,I=G<3?A:$===null?$=Object.getOwnPropertyDescriptor(A,D):$;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")I=Reflect.decorate(R,A,D,$);else for(var U=R.length-1;U>=0;U--)(q=R[U])&&(I=(G<3?q(I):G>3?q(A,D,I):q(A,D))||I);return G>3&&I&&Object.defineProperty(A,D,I),I},p=this&&this.__param||function(R,A){return function(D,$){A(D,$,R)}};Object.defineProperty(c,"__esModule",{value:!0}),c.ThemeService=c.DEFAULT_ANSI_COLORS=void 0;const m=d(7239),x=d(8055),y=d(8460),w=d(844),C=d(2585),b=x.css.toColor("#ffffff"),S=x.css.toColor("#000000"),v=x.css.toColor("#ffffff"),_=x.css.toColor("#000000"),E={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117};c.DEFAULT_ANSI_COLORS=Object.freeze((()=>{const R=[x.css.toColor("#2e3436"),x.css.toColor("#cc0000"),x.css.toColor("#4e9a06"),x.css.toColor("#c4a000"),x.css.toColor("#3465a4"),x.css.toColor("#75507b"),x.css.toColor("#06989a"),x.css.toColor("#d3d7cf"),x.css.toColor("#555753"),x.css.toColor("#ef2929"),x.css.toColor("#8ae234"),x.css.toColor("#fce94f"),x.css.toColor("#729fcf"),x.css.toColor("#ad7fa8"),x.css.toColor("#34e2e2"),x.css.toColor("#eeeeec")],A=[0,95,135,175,215,255];for(let D=0;D<216;D++){const $=A[D/36%6|0],q=A[D/6%6|0],G=A[D%6];R.push({css:x.channels.toCss($,q,G),rgba:x.channels.toRgba($,q,G)})}for(let D=0;D<24;D++){const $=8+10*D;R.push({css:x.channels.toCss($,$,$),rgba:x.channels.toRgba($,$,$)})}return R})());let j=c.ThemeService=class extends w.Disposable{get colors(){return this._colors}constructor(R){super(),this._optionsService=R,this._contrastCache=new m.ColorContrastCache,this._halfContrastCache=new m.ColorContrastCache,this._onChangeColors=this.register(new y.EventEmitter),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:b,background:S,cursor:v,cursorAccent:_,selectionForeground:void 0,selectionBackgroundTransparent:E,selectionBackgroundOpaque:x.color.blend(S,E),selectionInactiveBackgroundTransparent:E,selectionInactiveBackgroundOpaque:x.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(R={}){const A=this._colors;if(A.foreground=T(R.foreground,b),A.background=T(R.background,S),A.cursor=T(R.cursor,v),A.cursorAccent=T(R.cursorAccent,_),A.selectionBackgroundTransparent=T(R.selectionBackground,E),A.selectionBackgroundOpaque=x.color.blend(A.background,A.selectionBackgroundTransparent),A.selectionInactiveBackgroundTransparent=T(R.selectionInactiveBackground,A.selectionBackgroundTransparent),A.selectionInactiveBackgroundOpaque=x.color.blend(A.background,A.selectionInactiveBackgroundTransparent),A.selectionForeground=R.selectionForeground?T(R.selectionForeground,x.NULL_COLOR):void 0,A.selectionForeground===x.NULL_COLOR&&(A.selectionForeground=void 0),x.color.isOpaque(A.selectionBackgroundTransparent)&&(A.selectionBackgroundTransparent=x.color.opacity(A.selectionBackgroundTransparent,.3)),x.color.isOpaque(A.selectionInactiveBackgroundTransparent)&&(A.selectionInactiveBackgroundTransparent=x.color.opacity(A.selectionInactiveBackgroundTransparent,.3)),A.ansi=c.DEFAULT_ANSI_COLORS.slice(),A.ansi[0]=T(R.black,c.DEFAULT_ANSI_COLORS[0]),A.ansi[1]=T(R.red,c.DEFAULT_ANSI_COLORS[1]),A.ansi[2]=T(R.green,c.DEFAULT_ANSI_COLORS[2]),A.ansi[3]=T(R.yellow,c.DEFAULT_ANSI_COLORS[3]),A.ansi[4]=T(R.blue,c.DEFAULT_ANSI_COLORS[4]),A.ansi[5]=T(R.magenta,c.DEFAULT_ANSI_COLORS[5]),A.ansi[6]=T(R.cyan,c.DEFAULT_ANSI_COLORS[6]),A.ansi[7]=T(R.white,c.DEFAULT_ANSI_COLORS[7]),A.ansi[8]=T(R.brightBlack,c.DEFAULT_ANSI_COLORS[8]),A.ansi[9]=T(R.brightRed,c.DEFAULT_ANSI_COLORS[9]),A.ansi[10]=T(R.brightGreen,c.DEFAULT_ANSI_COLORS[10]),A.ansi[11]=T(R.brightYellow,c.DEFAULT_ANSI_COLORS[11]),A.ansi[12]=T(R.brightBlue,c.DEFAULT_ANSI_COLORS[12]),A.ansi[13]=T(R.brightMagenta,c.DEFAULT_ANSI_COLORS[13]),A.ansi[14]=T(R.brightCyan,c.DEFAULT_ANSI_COLORS[14]),A.ansi[15]=T(R.brightWhite,c.DEFAULT_ANSI_COLORS[15]),R.extendedAnsi){const D=Math.min(A.ansi.length-16,R.extendedAnsi.length);for(let $=0;$<D;$++)A.ansi[$+16]=T(R.extendedAnsi[$],c.DEFAULT_ANSI_COLORS[$+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(R){this._restoreColor(R),this._onChangeColors.fire(this.colors)}_restoreColor(R){if(R!==void 0)switch(R){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[R]=this._restoreColors.ansi[R]}else for(let A=0;A<this._restoreColors.ansi.length;++A)this._colors.ansi[A]=this._restoreColors.ansi[A]}modifyColors(R){R(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(R,A){if(R!==void 0)try{return x.css.toColor(R)}catch{}return A}c.ThemeService=j=f([p(0,C.IOptionsService)],j)},6349:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.CircularList=void 0;const f=d(8460),p=d(844);class m extends p.Disposable{constructor(y){super(),this._maxLength=y,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(y){if(this._maxLength===y)return;const w=new Array(y);for(let C=0;C<Math.min(y,this.length);C++)w[C]=this._array[this._getCyclicIndex(C)];this._array=w,this._maxLength=y,this._startIndex=0}get length(){return this._length}set length(y){if(y>this._length)for(let w=this._length;w<y;w++)this._array[w]=void 0;this._length=y}get(y){return this._array[this._getCyclicIndex(y)]}set(y,w){this._array[this._getCyclicIndex(y)]=w}push(y){this._array[this._getCyclicIndex(this._length)]=y,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(y,w,...C){if(w){for(let b=y;b<this._length-w;b++)this._array[this._getCyclicIndex(b)]=this._array[this._getCyclicIndex(b+w)];this._length-=w,this.onDeleteEmitter.fire({index:y,amount:w})}for(let b=this._length-1;b>=y;b--)this._array[this._getCyclicIndex(b+C.length)]=this._array[this._getCyclicIndex(b)];for(let b=0;b<C.length;b++)this._array[this._getCyclicIndex(y+b)]=C[b];if(C.length&&this.onInsertEmitter.fire({index:y,amount:C.length}),this._length+C.length>this._maxLength){const b=this._length+C.length-this._maxLength;this._startIndex+=b,this._length=this._maxLength,this.onTrimEmitter.fire(b)}else this._length+=C.length}trimStart(y){y>this._length&&(y=this._length),this._startIndex+=y,this._length-=y,this.onTrimEmitter.fire(y)}shiftElements(y,w,C){if(!(w<=0)){if(y<0||y>=this._length)throw new Error("start argument out of range");if(y+C<0)throw new Error("Cannot shift elements in list beyond index 0");if(C>0){for(let S=w-1;S>=0;S--)this.set(y+S+C,this.get(y+S));const b=y+w+C-this._length;if(b>0)for(this._length+=b;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let b=0;b<w;b++)this.set(y+b+C,this.get(y+b))}}_getCyclicIndex(y){return(this._startIndex+y)%this._maxLength}}c.CircularList=m},1439:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.clone=void 0,c.clone=function d(f,p=5){if(typeof f!="object")return f;const m=Array.isArray(f)?[]:{};for(const x in f)m[x]=p<=1?f[x]:f[x]&&d(f[x],p-1);return m}},8055:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.contrastRatio=c.toPaddedHex=c.rgba=c.rgb=c.css=c.color=c.channels=c.NULL_COLOR=void 0;let d=0,f=0,p=0,m=0;var x,y,w,C,b;function S(_){const E=_.toString(16);return E.length<2?"0"+E:E}function v(_,E){return _<E?(E+.05)/(_+.05):(_+.05)/(E+.05)}c.NULL_COLOR={css:"#00000000",rgba:0},(function(_){_.toCss=function(E,j,T,R){return R!==void 0?`#${S(E)}${S(j)}${S(T)}${S(R)}`:`#${S(E)}${S(j)}${S(T)}`},_.toRgba=function(E,j,T,R=255){return(E<<24|j<<16|T<<8|R)>>>0},_.toColor=function(E,j,T,R){return{css:_.toCss(E,j,T,R),rgba:_.toRgba(E,j,T,R)}}})(x||(c.channels=x={})),(function(_){function E(j,T){return m=Math.round(255*T),[d,f,p]=b.toChannels(j.rgba),{css:x.toCss(d,f,p,m),rgba:x.toRgba(d,f,p,m)}}_.blend=function(j,T){if(m=(255&T.rgba)/255,m===1)return{css:T.css,rgba:T.rgba};const R=T.rgba>>24&255,A=T.rgba>>16&255,D=T.rgba>>8&255,$=j.rgba>>24&255,q=j.rgba>>16&255,G=j.rgba>>8&255;return d=$+Math.round((R-$)*m),f=q+Math.round((A-q)*m),p=G+Math.round((D-G)*m),{css:x.toCss(d,f,p),rgba:x.toRgba(d,f,p)}},_.isOpaque=function(j){return(255&j.rgba)==255},_.ensureContrastRatio=function(j,T,R){const A=b.ensureContrastRatio(j.rgba,T.rgba,R);if(A)return x.toColor(A>>24&255,A>>16&255,A>>8&255)},_.opaque=function(j){const T=(255|j.rgba)>>>0;return[d,f,p]=b.toChannels(T),{css:x.toCss(d,f,p),rgba:T}},_.opacity=E,_.multiplyOpacity=function(j,T){return m=255&j.rgba,E(j,m*T/255)},_.toColorRGB=function(j){return[j.rgba>>24&255,j.rgba>>16&255,j.rgba>>8&255]}})(y||(c.color=y={})),(function(_){let E,j;try{const T=document.createElement("canvas");T.width=1,T.height=1;const R=T.getContext("2d",{willReadFrequently:!0});R&&(E=R,E.globalCompositeOperation="copy",j=E.createLinearGradient(0,0,1,1))}catch{}_.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),p=parseInt(T.slice(3,4).repeat(2),16),x.toColor(d,f,p);case 5:return d=parseInt(T.slice(1,2).repeat(2),16),f=parseInt(T.slice(2,3).repeat(2),16),p=parseInt(T.slice(3,4).repeat(2),16),m=parseInt(T.slice(4,5).repeat(2),16),x.toColor(d,f,p,m);case 7:return{css:T,rgba:(parseInt(T.slice(1),16)<<8|255)>>>0};case 9:return{css:T,rgba:parseInt(T.slice(1),16)>>>0}}const R=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(R)return d=parseInt(R[1]),f=parseInt(R[2]),p=parseInt(R[3]),m=Math.round(255*(R[5]===void 0?1:parseFloat(R[5]))),x.toColor(d,f,p,m);if(!E||!j)throw new Error("css.toColor: Unsupported css format");if(E.fillStyle=j,E.fillStyle=T,typeof E.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(E.fillRect(0,0,1,1),[d,f,p,m]=E.getImageData(0,0,1,1).data,m!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:x.toRgba(d,f,p,m),css:T}}})(w||(c.css=w={})),(function(_){function E(j,T,R){const A=j/255,D=T/255,$=R/255;return .2126*(A<=.03928?A/12.92:Math.pow((A+.055)/1.055,2.4))+.7152*(D<=.03928?D/12.92:Math.pow((D+.055)/1.055,2.4))+.0722*($<=.03928?$/12.92:Math.pow(($+.055)/1.055,2.4))}_.relativeLuminance=function(j){return E(j>>16&255,j>>8&255,255&j)},_.relativeLuminance2=E})(C||(c.rgb=C={})),(function(_){function E(T,R,A){const D=T>>24&255,$=T>>16&255,q=T>>8&255;let G=R>>24&255,I=R>>16&255,U=R>>8&255,V=v(C.relativeLuminance2(G,I,U),C.relativeLuminance2(D,$,q));for(;V<A&&(G>0||I>0||U>0);)G-=Math.max(0,Math.ceil(.1*G)),I-=Math.max(0,Math.ceil(.1*I)),U-=Math.max(0,Math.ceil(.1*U)),V=v(C.relativeLuminance2(G,I,U),C.relativeLuminance2(D,$,q));return(G<<24|I<<16|U<<8|255)>>>0}function j(T,R,A){const D=T>>24&255,$=T>>16&255,q=T>>8&255;let G=R>>24&255,I=R>>16&255,U=R>>8&255,V=v(C.relativeLuminance2(G,I,U),C.relativeLuminance2(D,$,q));for(;V<A&&(G<255||I<255||U<255);)G=Math.min(255,G+Math.ceil(.1*(255-G))),I=Math.min(255,I+Math.ceil(.1*(255-I))),U=Math.min(255,U+Math.ceil(.1*(255-U))),V=v(C.relativeLuminance2(G,I,U),C.relativeLuminance2(D,$,q));return(G<<24|I<<16|U<<8|255)>>>0}_.blend=function(T,R){if(m=(255&R)/255,m===1)return R;const A=R>>24&255,D=R>>16&255,$=R>>8&255,q=T>>24&255,G=T>>16&255,I=T>>8&255;return d=q+Math.round((A-q)*m),f=G+Math.round((D-G)*m),p=I+Math.round(($-I)*m),x.toRgba(d,f,p)},_.ensureContrastRatio=function(T,R,A){const D=C.relativeLuminance(T>>8),$=C.relativeLuminance(R>>8);if(v(D,$)<A){if($<D){const I=E(T,R,A),U=v(D,C.relativeLuminance(I>>8));if(U<A){const V=j(T,R,A);return U>v(D,C.relativeLuminance(V>>8))?I:V}return I}const q=j(T,R,A),G=v(D,C.relativeLuminance(q>>8));if(G<A){const I=E(T,R,A);return G>v(D,C.relativeLuminance(I>>8))?q:I}return q}},_.reduceLuminance=E,_.increaseLuminance=j,_.toChannels=function(T){return[T>>24&255,T>>16&255,T>>8&255,255&T]}})(b||(c.rgba=b={})),c.toPaddedHex=S,c.contrastRatio=v},8969:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.CoreTerminal=void 0;const f=d(844),p=d(2585),m=d(4348),x=d(7866),y=d(744),w=d(7302),C=d(6975),b=d(8460),S=d(1753),v=d(1480),_=d(7994),E=d(9282),j=d(5435),T=d(5981),R=d(2660);let A=!1;class D extends f.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new b.EventEmitter),this._onScroll.event((q=>{var G;(G=this._onScrollApi)==null||G.fire(q.position)}))),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(q){for(const G in q)this.optionsService.options[G]=q[G]}constructor(q){super(),this._windowsWrappingHeuristics=this.register(new f.MutableDisposable),this._onBinary=this.register(new b.EventEmitter),this.onBinary=this._onBinary.event,this._onData=this.register(new b.EventEmitter),this.onData=this._onData.event,this._onLineFeed=this.register(new b.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onResize=this.register(new b.EventEmitter),this.onResize=this._onResize.event,this._onWriteParsed=this.register(new b.EventEmitter),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this.register(new b.EventEmitter),this._instantiationService=new m.InstantiationService,this.optionsService=this.register(new w.OptionsService(q)),this._instantiationService.setService(p.IOptionsService,this.optionsService),this._bufferService=this.register(this._instantiationService.createInstance(y.BufferService)),this._instantiationService.setService(p.IBufferService,this._bufferService),this._logService=this.register(this._instantiationService.createInstance(x.LogService)),this._instantiationService.setService(p.ILogService,this._logService),this.coreService=this.register(this._instantiationService.createInstance(C.CoreService)),this._instantiationService.setService(p.ICoreService,this.coreService),this.coreMouseService=this.register(this._instantiationService.createInstance(S.CoreMouseService)),this._instantiationService.setService(p.ICoreMouseService,this.coreMouseService),this.unicodeService=this.register(this._instantiationService.createInstance(v.UnicodeService)),this._instantiationService.setService(p.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(_.CharsetService),this._instantiationService.setService(p.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(R.OscLinkService),this._instantiationService.setService(p.IOscLinkService,this._oscLinkService),this._inputHandler=this.register(new j.InputHandler(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this.register((0,b.forwardEvent)(this._inputHandler.onLineFeed,this._onLineFeed)),this.register(this._inputHandler),this.register((0,b.forwardEvent)(this._bufferService.onResize,this._onResize)),this.register((0,b.forwardEvent)(this.coreService.onData,this._onData)),this.register((0,b.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((G=>{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((G=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this._writeBuffer=this.register(new T.WriteBuffer(((G,I)=>this._inputHandler.parse(G,I)))),this.register((0,b.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(q,G){this._writeBuffer.write(q,G)}writeSync(q,G){this._logService.logLevel<=p.LogLevelEnum.WARN&&!A&&(this._logService.warn("writeSync is unreliable and will be removed soon."),A=!0),this._writeBuffer.writeSync(q,G)}input(q,G=!0){this.coreService.triggerDataEvent(q,G)}resize(q,G){isNaN(q)||isNaN(G)||(q=Math.max(q,y.MINIMUM_COLS),G=Math.max(G,y.MINIMUM_ROWS),this._bufferService.resize(q,G))}scroll(q,G=!1){this._bufferService.scroll(q,G)}scrollLines(q,G,I){this._bufferService.scrollLines(q,G,I)}scrollPages(q){this.scrollLines(q*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(q){const G=q-this._bufferService.buffer.ydisp;G!==0&&this.scrollLines(G)}registerEscHandler(q,G){return this._inputHandler.registerEscHandler(q,G)}registerDcsHandler(q,G){return this._inputHandler.registerDcsHandler(q,G)}registerCsiHandler(q,G){return this._inputHandler.registerCsiHandler(q,G)}registerOscHandler(q,G){return this._inputHandler.registerOscHandler(q,G)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let q=!1;const G=this.optionsService.rawOptions.windowsPty;G&&G.buildNumber!==void 0&&G.buildNumber!==void 0?q=G.backend==="conpty"&&G.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(q=!0),q?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){const q=[];q.push(this.onLineFeed(E.updateWindowsModeWrappedState.bind(null,this._bufferService))),q.push(this.registerCsiHandler({final:"H"},(()=>((0,E.updateWindowsModeWrappedState)(this._bufferService),!1)))),this._windowsWrappingHeuristics.value=(0,f.toDisposable)((()=>{for(const G of q)G.dispose()}))}}}c.CoreTerminal=D},8460:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.runAndSubscribe=c.forwardEvent=c.EventEmitter=void 0,c.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=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 p=[];for(let m=0;m<this._listeners.length;m++)p.push(this._listeners[m]);for(let m=0;m<p.length;m++)p[m].call(void 0,d,f)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},c.forwardEvent=function(d,f){return d((p=>f.fire(p)))},c.runAndSubscribe=function(d,f){return f(void 0),d((p=>f(p)))}},5435:function(u,c,d){var f=this&&this.__decorate||function(Z,H,O,B){var W,P=arguments.length,ee=P<3?H:B===null?B=Object.getOwnPropertyDescriptor(H,O):B;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")ee=Reflect.decorate(Z,H,O,B);else for(var X=Z.length-1;X>=0;X--)(W=Z[X])&&(ee=(P<3?W(ee):P>3?W(H,O,ee):W(H,O))||ee);return P>3&&ee&&Object.defineProperty(H,O,ee),ee},p=this&&this.__param||function(Z,H){return function(O,B){H(O,B,Z)}};Object.defineProperty(c,"__esModule",{value:!0}),c.InputHandler=c.WindowsOptionsReportType=void 0;const m=d(2584),x=d(7116),y=d(2015),w=d(844),C=d(482),b=d(8437),S=d(8460),v=d(643),_=d(511),E=d(3734),j=d(2585),T=d(1480),R=d(6242),A=d(6351),D=d(5941),$={"(":0,")":1,"*":2,"+":3,"-":1,".":2},q=131072;function G(Z,H){if(Z>24)return H.setWinLines||!1;switch(Z){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 I;(function(Z){Z[Z.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",Z[Z.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(I||(c.WindowsOptionsReportType=I={}));let U=0;class V extends w.Disposable{getAttrData(){return this._curAttrData}constructor(H,O,B,W,P,ee,X,ne,Y=new y.EscapeSequenceParser){super(),this._bufferService=H,this._charsetService=O,this._coreService=B,this._logService=W,this._optionsService=P,this._oscLinkService=ee,this._coreMouseService=X,this._unicodeService=ne,this._parser=Y,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new C.StringToUtf32,this._utf8Decoder=new C.Utf8ToUtf32,this._workCell=new _.CellData,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=b.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=b.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((F=>this._activeBuffer=F.activeBuffer))),this._parser.setCsiHandlerFallback(((F,te)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(F),params:te.toArray()})})),this._parser.setEscHandlerFallback((F=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(F)})})),this._parser.setExecuteHandlerFallback((F=>{this._logService.debug("Unknown EXECUTE code: ",{code:F})})),this._parser.setOscHandlerFallback(((F,te,se)=>{this._logService.debug("Unknown OSC code: ",{identifier:F,action:te,data:se})})),this._parser.setDcsHandlerFallback(((F,te,se)=>{te==="HOOK"&&(se=se.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(F),action:te,payload:se})})),this._parser.setPrintHandler(((F,te,se)=>this.print(F,te,se))),this._parser.registerCsiHandler({final:"@"},(F=>this.insertChars(F))),this._parser.registerCsiHandler({intermediates:" ",final:"@"},(F=>this.scrollLeft(F))),this._parser.registerCsiHandler({final:"A"},(F=>this.cursorUp(F))),this._parser.registerCsiHandler({intermediates:" ",final:"A"},(F=>this.scrollRight(F))),this._parser.registerCsiHandler({final:"B"},(F=>this.cursorDown(F))),this._parser.registerCsiHandler({final:"C"},(F=>this.cursorForward(F))),this._parser.registerCsiHandler({final:"D"},(F=>this.cursorBackward(F))),this._parser.registerCsiHandler({final:"E"},(F=>this.cursorNextLine(F))),this._parser.registerCsiHandler({final:"F"},(F=>this.cursorPrecedingLine(F))),this._parser.registerCsiHandler({final:"G"},(F=>this.cursorCharAbsolute(F))),this._parser.registerCsiHandler({final:"H"},(F=>this.cursorPosition(F))),this._parser.registerCsiHandler({final:"I"},(F=>this.cursorForwardTab(F))),this._parser.registerCsiHandler({final:"J"},(F=>this.eraseInDisplay(F,!1))),this._parser.registerCsiHandler({prefix:"?",final:"J"},(F=>this.eraseInDisplay(F,!0))),this._parser.registerCsiHandler({final:"K"},(F=>this.eraseInLine(F,!1))),this._parser.registerCsiHandler({prefix:"?",final:"K"},(F=>this.eraseInLine(F,!0))),this._parser.registerCsiHandler({final:"L"},(F=>this.insertLines(F))),this._parser.registerCsiHandler({final:"M"},(F=>this.deleteLines(F))),this._parser.registerCsiHandler({final:"P"},(F=>this.deleteChars(F))),this._parser.registerCsiHandler({final:"S"},(F=>this.scrollUp(F))),this._parser.registerCsiHandler({final:"T"},(F=>this.scrollDown(F))),this._parser.registerCsiHandler({final:"X"},(F=>this.eraseChars(F))),this._parser.registerCsiHandler({final:"Z"},(F=>this.cursorBackwardTab(F))),this._parser.registerCsiHandler({final:"`"},(F=>this.charPosAbsolute(F))),this._parser.registerCsiHandler({final:"a"},(F=>this.hPositionRelative(F))),this._parser.registerCsiHandler({final:"b"},(F=>this.repeatPrecedingCharacter(F))),this._parser.registerCsiHandler({final:"c"},(F=>this.sendDeviceAttributesPrimary(F))),this._parser.registerCsiHandler({prefix:">",final:"c"},(F=>this.sendDeviceAttributesSecondary(F))),this._parser.registerCsiHandler({final:"d"},(F=>this.linePosAbsolute(F))),this._parser.registerCsiHandler({final:"e"},(F=>this.vPositionRelative(F))),this._parser.registerCsiHandler({final:"f"},(F=>this.hVPosition(F))),this._parser.registerCsiHandler({final:"g"},(F=>this.tabClear(F))),this._parser.registerCsiHandler({final:"h"},(F=>this.setMode(F))),this._parser.registerCsiHandler({prefix:"?",final:"h"},(F=>this.setModePrivate(F))),this._parser.registerCsiHandler({final:"l"},(F=>this.resetMode(F))),this._parser.registerCsiHandler({prefix:"?",final:"l"},(F=>this.resetModePrivate(F))),this._parser.registerCsiHandler({final:"m"},(F=>this.charAttributes(F))),this._parser.registerCsiHandler({final:"n"},(F=>this.deviceStatus(F))),this._parser.registerCsiHandler({prefix:"?",final:"n"},(F=>this.deviceStatusPrivate(F))),this._parser.registerCsiHandler({intermediates:"!",final:"p"},(F=>this.softReset(F))),this._parser.registerCsiHandler({intermediates:" ",final:"q"},(F=>this.setCursorStyle(F))),this._parser.registerCsiHandler({final:"r"},(F=>this.setScrollRegion(F))),this._parser.registerCsiHandler({final:"s"},(F=>this.saveCursor(F))),this._parser.registerCsiHandler({final:"t"},(F=>this.windowOptions(F))),this._parser.registerCsiHandler({final:"u"},(F=>this.restoreCursor(F))),this._parser.registerCsiHandler({intermediates:"'",final:"}"},(F=>this.insertColumns(F))),this._parser.registerCsiHandler({intermediates:"'",final:"~"},(F=>this.deleteColumns(F))),this._parser.registerCsiHandler({intermediates:'"',final:"q"},(F=>this.selectProtected(F))),this._parser.registerCsiHandler({intermediates:"$",final:"p"},(F=>this.requestMode(F,!0))),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},(F=>this.requestMode(F,!1))),this._parser.setExecuteHandler(m.C0.BEL,(()=>this.bell())),this._parser.setExecuteHandler(m.C0.LF,(()=>this.lineFeed())),this._parser.setExecuteHandler(m.C0.VT,(()=>this.lineFeed())),this._parser.setExecuteHandler(m.C0.FF,(()=>this.lineFeed())),this._parser.setExecuteHandler(m.C0.CR,(()=>this.carriageReturn())),this._parser.setExecuteHandler(m.C0.BS,(()=>this.backspace())),this._parser.setExecuteHandler(m.C0.HT,(()=>this.tab())),this._parser.setExecuteHandler(m.C0.SO,(()=>this.shiftOut())),this._parser.setExecuteHandler(m.C0.SI,(()=>this.shiftIn())),this._parser.setExecuteHandler(m.C1.IND,(()=>this.index())),this._parser.setExecuteHandler(m.C1.NEL,(()=>this.nextLine())),this._parser.setExecuteHandler(m.C1.HTS,(()=>this.tabSet())),this._parser.registerOscHandler(0,new R.OscHandler((F=>(this.setTitle(F),this.setIconName(F),!0)))),this._parser.registerOscHandler(1,new R.OscHandler((F=>this.setIconName(F)))),this._parser.registerOscHandler(2,new R.OscHandler((F=>this.setTitle(F)))),this._parser.registerOscHandler(4,new R.OscHandler((F=>this.setOrReportIndexedColor(F)))),this._parser.registerOscHandler(8,new R.OscHandler((F=>this.setHyperlink(F)))),this._parser.registerOscHandler(10,new R.OscHandler((F=>this.setOrReportFgColor(F)))),this._parser.registerOscHandler(11,new R.OscHandler((F=>this.setOrReportBgColor(F)))),this._parser.registerOscHandler(12,new R.OscHandler((F=>this.setOrReportCursorColor(F)))),this._parser.registerOscHandler(104,new R.OscHandler((F=>this.restoreIndexedColor(F)))),this._parser.registerOscHandler(110,new R.OscHandler((F=>this.restoreFgColor(F)))),this._parser.registerOscHandler(111,new R.OscHandler((F=>this.restoreBgColor(F)))),this._parser.registerOscHandler(112,new R.OscHandler((F=>this.restoreCursorColor(F)))),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 F in x.CHARSETS)this._parser.registerEscHandler({intermediates:"(",final:F},(()=>this.selectCharset("("+F))),this._parser.registerEscHandler({intermediates:")",final:F},(()=>this.selectCharset(")"+F))),this._parser.registerEscHandler({intermediates:"*",final:F},(()=>this.selectCharset("*"+F))),this._parser.registerEscHandler({intermediates:"+",final:F},(()=>this.selectCharset("+"+F))),this._parser.registerEscHandler({intermediates:"-",final:F},(()=>this.selectCharset("-"+F))),this._parser.registerEscHandler({intermediates:".",final:F},(()=>this.selectCharset("."+F))),this._parser.registerEscHandler({intermediates:"/",final:F},(()=>this.selectCharset("/"+F)));this._parser.registerEscHandler({intermediates:"#",final:"8"},(()=>this.screenAlignmentPattern())),this._parser.setErrorHandler((F=>(this._logService.error("Parsing error: ",F),F))),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new A.DcsHandler(((F,te)=>this.requestStatusString(F,te))))}_preserveStack(H,O,B,W){this._parseStack.paused=!0,this._parseStack.cursorStartX=H,this._parseStack.cursorStartY=O,this._parseStack.decodedLength=B,this._parseStack.position=W}_logSlowResolvingAsync(H){this._logService.logLevel<=j.LogLevelEnum.WARN&&Promise.race([H,new Promise(((O,B)=>setTimeout((()=>B("#SLOW_TIMEOUT")),5e3)))]).catch((O=>{if(O!=="#SLOW_TIMEOUT")throw O;console.warn("async parser handler taking longer than 5000 ms")}))}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(H,O){let B,W=this._activeBuffer.x,P=this._activeBuffer.y,ee=0;const X=this._parseStack.paused;if(X){if(B=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,O))return this._logSlowResolvingAsync(B),B;W=this._parseStack.cursorStartX,P=this._parseStack.cursorStartY,this._parseStack.paused=!1,H.length>q&&(ee=this._parseStack.position+q)}if(this._logService.logLevel<=j.LogLevelEnum.DEBUG&&this._logService.debug("parsing data"+(typeof H=="string"?` "${H}"`:` "${Array.prototype.map.call(H,(F=>String.fromCharCode(F))).join("")}"`),typeof H=="string"?H.split("").map((F=>F.charCodeAt(0))):H),this._parseBuffer.length<H.length&&this._parseBuffer.length<q&&(this._parseBuffer=new Uint32Array(Math.min(H.length,q))),X||this._dirtyRowTracker.clearRange(),H.length>q)for(let F=ee;F<H.length;F+=q){const te=F+q<H.length?F+q:H.length,se=typeof H=="string"?this._stringDecoder.decode(H.substring(F,te),this._parseBuffer):this._utf8Decoder.decode(H.subarray(F,te),this._parseBuffer);if(B=this._parser.parse(this._parseBuffer,se))return this._preserveStack(W,P,se,F),this._logSlowResolvingAsync(B),B}else if(!X){const F=typeof H=="string"?this._stringDecoder.decode(H,this._parseBuffer):this._utf8Decoder.decode(H,this._parseBuffer);if(B=this._parser.parse(this._parseBuffer,F))return this._preserveStack(W,P,F,0),this._logSlowResolvingAsync(B),B}this._activeBuffer.x===W&&this._activeBuffer.y===P||this._onCursorMove.fire();const ne=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(ne,this._bufferService.rows-1))}print(H,O,B){let W,P;const ee=this._charsetService.charset,X=this._optionsService.rawOptions.screenReaderMode,ne=this._bufferService.cols,Y=this._coreService.decPrivateModes.wraparound,F=this._coreService.modes.insertMode,te=this._curAttrData;let se=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&B-O>0&&se.getWidth(this._activeBuffer.x-1)===2&&se.setCellFromCodepoint(this._activeBuffer.x-1,0,1,te);let xe=this._parser.precedingJoinState;for(let le=O;le<B;++le){if(W=H[le],W<127&&ee){const de=ee[String.fromCharCode(W)];de&&(W=de.charCodeAt(0))}const Ee=this._unicodeService.charProperties(W,xe);P=T.UnicodeService.extractWidth(Ee);const ue=T.UnicodeService.extractShouldJoin(Ee),ae=ue?T.UnicodeService.extractWidth(xe):0;if(xe=Ee,X&&this._onA11yChar.fire((0,C.stringFromCodePoint)(W)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+P-ae>ne){if(Y){const de=se;let oe=this._activeBuffer.x-ae;for(this._activeBuffer.x=ae,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),se=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),ae>0&&se instanceof b.BufferLine&&se.copyCellsFrom(de,oe,0,ae,!1);oe<ne;)de.setCellFromCodepoint(oe++,0,1,te)}else if(this._activeBuffer.x=ne-1,P===2)continue}if(ue&&this._activeBuffer.x){const de=se.getWidth(this._activeBuffer.x-1)?1:2;se.addCodepointToCell(this._activeBuffer.x-de,W,P);for(let oe=P-ae;--oe>=0;)se.setCellFromCodepoint(this._activeBuffer.x++,0,0,te)}else if(F&&(se.insertCells(this._activeBuffer.x,P-ae,this._activeBuffer.getNullCell(te)),se.getWidth(ne-1)===2&&se.setCellFromCodepoint(ne-1,v.NULL_CELL_CODE,v.NULL_CELL_WIDTH,te)),se.setCellFromCodepoint(this._activeBuffer.x++,W,P,te),P>0)for(;--P;)se.setCellFromCodepoint(this._activeBuffer.x++,0,0,te)}this._parser.precedingJoinState=xe,this._activeBuffer.x<ne&&B-O>0&&se.getWidth(this._activeBuffer.x)===0&&!se.hasContent(this._activeBuffer.x)&&se.setCellFromCodepoint(this._activeBuffer.x,0,1,te),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(H,O){return H.final!=="t"||H.prefix||H.intermediates?this._parser.registerCsiHandler(H,O):this._parser.registerCsiHandler(H,(B=>!G(B.params[0],this._optionsService.rawOptions.windowOptions)||O(B)))}registerDcsHandler(H,O){return this._parser.registerDcsHandler(H,new A.DcsHandler(O))}registerEscHandler(H,O){return this._parser.registerEscHandler(H,O)}registerOscHandler(H,O){return this._parser.registerOscHandler(H,new R.OscHandler(O))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var 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 O=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);O.hasWidth(this._activeBuffer.x)&&!O.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;const 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,O){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=H,this._activeBuffer.y=this._activeBuffer.scrollTop+O):(this._activeBuffer.x=H,this._activeBuffer.y=O),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(H,O){this._restrictCursor(),this._setCursor(this._activeBuffer.x+H,this._activeBuffer.y+O)}cursorUp(H){const O=this._activeBuffer.y-this._activeBuffer.scrollTop;return O>=0?this._moveCursor(0,-Math.min(O,H.params[0]||1)):this._moveCursor(0,-(H.params[0]||1)),!0}cursorDown(H){const O=this._activeBuffer.scrollBottom-this._activeBuffer.y;return O>=0?this._moveCursor(0,Math.min(O,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 O=H.params[0];return O===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:O===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(H){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let O=H.params[0]||1;for(;O--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(H){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let O=H.params[0]||1;for(;O--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(H){const O=H.params[0];return O===1&&(this._curAttrData.bg|=536870912),O!==2&&O!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(H,O,B,W=!1,P=!1){const ee=this._activeBuffer.lines.get(this._activeBuffer.ybase+H);ee.replaceCells(O,B,this._activeBuffer.getNullCell(this._eraseAttrData()),P),W&&(ee.isWrapped=!1)}_resetBufferLine(H,O=!1){const B=this._activeBuffer.lines.get(this._activeBuffer.ybase+H);B&&(B.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),O),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+H),B.isWrapped=!1)}eraseInDisplay(H,O=!1){let B;switch(this._restrictCursor(this._bufferService.cols),H.params[0]){case 0:for(B=this._activeBuffer.y,this._dirtyRowTracker.markDirty(B),this._eraseInBufferLine(B++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,O);B<this._bufferService.rows;B++)this._resetBufferLine(B,O);this._dirtyRowTracker.markDirty(B);break;case 1:for(B=this._activeBuffer.y,this._dirtyRowTracker.markDirty(B),this._eraseInBufferLine(B,0,this._activeBuffer.x+1,!0,O),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(B+1).isWrapped=!1);B--;)this._resetBufferLine(B,O);this._dirtyRowTracker.markDirty(0);break;case 2:for(B=this._bufferService.rows,this._dirtyRowTracker.markDirty(B-1);B--;)this._resetBufferLine(B,O);this._dirtyRowTracker.markDirty(0);break;case 3:const W=this._activeBuffer.lines.length-this._bufferService.rows;W>0&&(this._activeBuffer.lines.trimStart(W),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-W,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-W,0),this._onScroll.fire(0))}return!0}eraseInLine(H,O=!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,O);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,O);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,O)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(H){this._restrictCursor();let O=H.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const B=this._activeBuffer.ybase+this._activeBuffer.y,W=this._bufferService.rows-1-this._activeBuffer.scrollBottom,P=this._bufferService.rows-1+this._activeBuffer.ybase-W+1;for(;O--;)this._activeBuffer.lines.splice(P-1,1),this._activeBuffer.lines.splice(B,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(H){this._restrictCursor();let O=H.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const B=this._activeBuffer.ybase+this._activeBuffer.y;let W;for(W=this._bufferService.rows-1-this._activeBuffer.scrollBottom,W=this._bufferService.rows-1+this._activeBuffer.ybase-W;O--;)this._activeBuffer.lines.splice(B,1),this._activeBuffer.lines.splice(W,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 O=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return O&&(O.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 O=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return O&&(O.deleteCells(this._activeBuffer.x,H.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(H){let O=H.params[0]||1;for(;O--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(H){let O=H.params[0]||1;for(;O--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(b.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 O=H.params[0]||1;for(let B=this._activeBuffer.scrollTop;B<=this._activeBuffer.scrollBottom;++B){const W=this._activeBuffer.lines.get(this._activeBuffer.ybase+B);W.deleteCells(0,O,this._activeBuffer.getNullCell(this._eraseAttrData())),W.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 O=H.params[0]||1;for(let B=this._activeBuffer.scrollTop;B<=this._activeBuffer.scrollBottom;++B){const W=this._activeBuffer.lines.get(this._activeBuffer.ybase+B);W.insertCells(0,O,this._activeBuffer.getNullCell(this._eraseAttrData())),W.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 O=H.params[0]||1;for(let B=this._activeBuffer.scrollTop;B<=this._activeBuffer.scrollBottom;++B){const W=this._activeBuffer.lines.get(this._activeBuffer.ybase+B);W.insertCells(this._activeBuffer.x,O,this._activeBuffer.getNullCell(this._eraseAttrData())),W.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 O=H.params[0]||1;for(let B=this._activeBuffer.scrollTop;B<=this._activeBuffer.scrollBottom;++B){const W=this._activeBuffer.lines.get(this._activeBuffer.ybase+B);W.deleteCells(this._activeBuffer.x,O,this._activeBuffer.getNullCell(this._eraseAttrData())),W.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(H){this._restrictCursor();const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return O&&(O.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 O=this._parser.precedingJoinState;if(!O)return!0;const B=H.params[0]||1,W=T.UnicodeService.extractWidth(O),P=this._activeBuffer.x-W,ee=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(P),X=new Uint32Array(ee.length*B);let ne=0;for(let F=0;F<ee.length;){const te=ee.codePointAt(F)||0;X[ne++]=te,F+=te>65535?2:1}let Y=ne;for(let F=1;F<B;++F)X.copyWithin(Y,0,ne),Y+=ne;return this.print(X,0,Y),!0}sendDeviceAttributesPrimary(H){return H.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(m.C0.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(m.C0.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(H){return H.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(m.C0.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(m.C0.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(H.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(m.C0.ESC+"[>83;40003;0c")),!0}_is(H){return(this._optionsService.rawOptions.termName+"").indexOf(H)===0}setMode(H){for(let O=0;O<H.length;O++)switch(H.params[O]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(H){for(let O=0;O<H.length;O++)switch(H.params[O]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,x.DEFAULT_CHARSET),this._charsetService.setgCharset(1,x.DEFAULT_CHARSET),this._charsetService.setgCharset(2,x.DEFAULT_CHARSET),this._charsetService.setgCharset(3,x.DEFAULT_CHARSET);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0}return!0}resetMode(H){for(let O=0;O<H.length;O++)switch(H.params[O]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(H){for(let O=0;O<H.length;O++)switch(H.params[O]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),H.params[O]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1}return!0}requestMode(H,O){const B=this._coreService.decPrivateModes,{activeProtocol:W,activeEncoding:P}=this._coreMouseService,ee=this._coreService,{buffers:X,cols:ne}=this._bufferService,{active:Y,alt:F}=X,te=this._optionsService.rawOptions,se=ue=>ue?1:2,xe=H.params[0];return le=xe,Ee=O?xe===2?4:xe===4?se(ee.modes.insertMode):xe===12?3:xe===20?se(te.convertEol):0:xe===1?se(B.applicationCursorKeys):xe===3?te.windowOptions.setWinLines?ne===80?2:ne===132?1:0:0:xe===6?se(B.origin):xe===7?se(B.wraparound):xe===8?3:xe===9?se(W==="X10"):xe===12?se(te.cursorBlink):xe===25?se(!ee.isCursorHidden):xe===45?se(B.reverseWraparound):xe===66?se(B.applicationKeypad):xe===67?4:xe===1e3?se(W==="VT200"):xe===1002?se(W==="DRAG"):xe===1003?se(W==="ANY"):xe===1004?se(B.sendFocus):xe===1005?4:xe===1006?se(P==="SGR"):xe===1015?4:xe===1016?se(P==="SGR_PIXELS"):xe===1048?1:xe===47||xe===1047||xe===1049?se(Y===F):xe===2004?se(B.bracketedPasteMode):0,ee.triggerDataEvent(`${m.C0.ESC}[${O?"":"?"}${le};${Ee}$y`),!0;var le,Ee}_updateAttrColor(H,O,B,W,P){return O===2?(H|=50331648,H&=-16777216,H|=E.AttributeData.fromColorRGB([B,W,P])):O===5&&(H&=-50331904,H|=33554432|255&B),H}_extractColor(H,O,B){const W=[0,0,-1,0,0,0];let P=0,ee=0;do{if(W[ee+P]=H.params[O+ee],H.hasSubParams(O+ee)){const X=H.getSubParams(O+ee);let ne=0;do W[1]===5&&(P=1),W[ee+ne+1+P]=X[ne];while(++ne<X.length&&ne+ee+1+P<W.length);break}if(W[1]===5&&ee+P>=2||W[1]===2&&ee+P>=5)break;W[1]&&(P=1)}while(++ee+O<H.length&&ee+P<W.length);for(let X=2;X<W.length;++X)W[X]===-1&&(W[X]=0);switch(W[0]){case 38:B.fg=this._updateAttrColor(B.fg,W[1],W[3],W[4],W[5]);break;case 48:B.bg=this._updateAttrColor(B.bg,W[1],W[3],W[4],W[5]);break;case 58:B.extended=B.extended.clone(),B.extended.underlineColor=this._updateAttrColor(B.extended.underlineColor,W[1],W[3],W[4],W[5])}return ee}_processUnderline(H,O){O.extended=O.extended.clone(),(!~H||H>5)&&(H=1),O.extended.underlineStyle=H,O.fg|=268435456,H===0&&(O.fg&=-268435457),O.updateExtended()}_processSGR0(H){H.fg=b.DEFAULT_ATTR_DATA.fg,H.bg=b.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 O=H.length;let B;const W=this._curAttrData;for(let P=0;P<O;P++)B=H.params[P],B>=30&&B<=37?(W.fg&=-50331904,W.fg|=16777216|B-30):B>=40&&B<=47?(W.bg&=-50331904,W.bg|=16777216|B-40):B>=90&&B<=97?(W.fg&=-50331904,W.fg|=16777224|B-90):B>=100&&B<=107?(W.bg&=-50331904,W.bg|=16777224|B-100):B===0?this._processSGR0(W):B===1?W.fg|=134217728:B===3?W.bg|=67108864:B===4?(W.fg|=268435456,this._processUnderline(H.hasSubParams(P)?H.getSubParams(P)[0]:1,W)):B===5?W.fg|=536870912:B===7?W.fg|=67108864:B===8?W.fg|=1073741824:B===9?W.fg|=2147483648:B===2?W.bg|=134217728:B===21?this._processUnderline(2,W):B===22?(W.fg&=-134217729,W.bg&=-134217729):B===23?W.bg&=-67108865:B===24?(W.fg&=-268435457,this._processUnderline(0,W)):B===25?W.fg&=-536870913:B===27?W.fg&=-67108865:B===28?W.fg&=-1073741825:B===29?W.fg&=2147483647:B===39?(W.fg&=-67108864,W.fg|=16777215&b.DEFAULT_ATTR_DATA.fg):B===49?(W.bg&=-67108864,W.bg|=16777215&b.DEFAULT_ATTR_DATA.bg):B===38||B===48||B===58?P+=this._extractColor(H,P,W):B===53?W.bg|=1073741824:B===55?W.bg&=-1073741825:B===59?(W.extended=W.extended.clone(),W.extended.underlineColor=-1,W.updateExtended()):B===100?(W.fg&=-67108864,W.fg|=16777215&b.DEFAULT_ATTR_DATA.fg,W.bg&=-67108864,W.bg|=16777215&b.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",B);return!0}deviceStatus(H){switch(H.params[0]){case 5:this._coreService.triggerDataEvent(`${m.C0.ESC}[0n`);break;case 6:const O=this._activeBuffer.y+1,B=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${m.C0.ESC}[${O};${B}R`)}return!0}deviceStatusPrivate(H){if(H.params[0]===6){const O=this._activeBuffer.y+1,B=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${m.C0.ESC}[?${O};${B}R`)}return!0}softReset(H){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=b.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 O=H.params[0]||1;switch(O){case 1:case 2:this._optionsService.options.cursorStyle="block";break;case 3:case 4:this._optionsService.options.cursorStyle="underline";break;case 5:case 6:this._optionsService.options.cursorStyle="bar"}const B=O%2==1;return this._optionsService.options.cursorBlink=B,!0}setScrollRegion(H){const O=H.params[0]||1;let B;return(H.length<2||(B=H.params[1])>this._bufferService.rows||B===0)&&(B=this._bufferService.rows),B>O&&(this._activeBuffer.scrollTop=O-1,this._activeBuffer.scrollBottom=B-1,this._setCursor(0,0)),!0}windowOptions(H){if(!G(H.params[0],this._optionsService.rawOptions.windowOptions))return!0;const O=H.length>1?H.params[1]:0;switch(H.params[0]){case 14:O!==2&&this._onRequestWindowsOptionsReport.fire(I.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(I.GET_CELL_SIZE_PIXELS);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${m.C0.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:O!==0&&O!==2||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),O!==0&&O!==1||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:O!==0&&O!==2||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),O!==0&&O!==1||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(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 O=[],B=H.split(";");for(;B.length>1;){const W=B.shift(),P=B.shift();if(/^\d+$/.exec(W)){const ee=parseInt(W);if(J(ee))if(P==="?")O.push({type:0,index:ee});else{const X=(0,D.parseColor)(P);X&&O.push({type:1,index:ee,color:X})}}}return O.length&&this._onColor.fire(O),!0}setHyperlink(H){const O=H.split(";");return!(O.length<2)&&(O[1]?this._createHyperlink(O[0],O[1]):!O[0]&&this._finishHyperlink())}_createHyperlink(H,O){this._getCurrentLinkId()&&this._finishHyperlink();const B=H.split(":");let W;const P=B.findIndex((ee=>ee.startsWith("id=")));return P!==-1&&(W=B[P].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:W,uri:O}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(H,O){const B=H.split(";");for(let W=0;W<B.length&&!(O>=this._specialColors.length);++W,++O)if(B[W]==="?")this._onColor.fire([{type:0,index:this._specialColors[O]}]);else{const P=(0,D.parseColor)(B[W]);P&&this._onColor.fire([{type:1,index:this._specialColors[O],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 O=[],B=H.split(";");for(let W=0;W<B.length;++W)if(/^\d+$/.exec(B[W])){const P=parseInt(B[W]);J(P)&&O.push({type:2,index:P})}return O.length&&this._onColor.fire(O),!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,x.DEFAULT_CHARSET),!0}selectCharset(H){return H.length!==2?(this.selectDefaultCharset(),!0):(H[0]==="/"||this._charsetService.setgCharset($[H[0]],x.CHARSETS[H[1]]||x.DEFAULT_CHARSET),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){const 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=b.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=b.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 _.CellData;H.content=4194373,H.fg=this._curAttrData.fg,H.bg=this._curAttrData.bg,this._setCursor(0,0);for(let O=0;O<this._bufferService.rows;++O){const B=this._activeBuffer.ybase+this._activeBuffer.y+O,W=this._activeBuffer.lines.get(B);W&&(W.fill(H),W.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(H,O){const B=this._bufferService.buffer,W=this._optionsService.rawOptions;return(P=>(this._coreService.triggerDataEvent(`${m.C0.ESC}${P}${m.C0.ESC}\\`),!0))(H==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:H==='"p'?'P1$r61;1"p':H==="r"?`P1$r${B.scrollTop+1};${B.scrollBottom+1}r`:H==="m"?"P1$r0m":H===" q"?`P1$r${{block:2,underline:4,bar:6}[W.cursorStyle]-(W.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(H,O){this._dirtyRowTracker.markRangeDirty(H,O)}}c.InputHandler=V;let z=class{constructor(Z){this._bufferService=Z,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(Z){Z<this.start?this.start=Z:Z>this.end&&(this.end=Z)}markRangeDirty(Z,H){Z>H&&(U=Z,Z=H,H=U),Z<this.start&&(this.start=Z),H>this.end&&(this.end=H)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function J(Z){return 0<=Z&&Z<256}z=f([p(0,j.IBufferService)],z)},844:(u,c)=>{function d(f){for(const p of f)p.dispose();f.length=0}Object.defineProperty(c,"__esModule",{value:!0}),c.getDisposeArrayDisposable=c.disposeArray=c.toDisposable=c.MutableDisposable=c.Disposable=void 0,c.Disposable=class{constructor(){this._disposables=[],this._isDisposed=!1}dispose(){this._isDisposed=!0;for(const f of this._disposables)f.dispose();this._disposables.length=0}register(f){return this._disposables.push(f),f}unregister(f){const p=this._disposables.indexOf(f);p!==-1&&this._disposables.splice(p,1)}},c.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(f){var p;this._isDisposed||f===this._value||((p=this._value)==null||p.dispose(),this._value=f)}clear(){this.value=void 0}dispose(){var f;this._isDisposed=!0,(f=this._value)==null||f.dispose(),this._value=void 0}},c.toDisposable=function(f){return{dispose:f}},c.disposeArray=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(p,m,x){this._data[p]||(this._data[p]={}),this._data[p][m]=x}get(p,m){return this._data[p]?this._data[p][m]:void 0}clear(){this._data={}}}c.TwoKeyMap=d,c.FourKeyMap=class{constructor(){this._data=new d}set(f,p,m,x,y){this._data.get(f,p)||this._data.set(f,p,new d),this._data.get(f,p).set(m,x,y)}get(f,p,m,x){var y;return(y=this._data.get(f,p))==null?void 0:y.get(m,x)}clear(){this._data.clear()}}},6114:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.isChromeOS=c.isLinux=c.isWindows=c.isIphone=c.isIpad=c.isMac=c.getSafariVersion=c.isSafari=c.isLegacyEdge=c.isFirefox=c.isNode=void 0,c.isNode=typeof process<"u"&&"title"in process;const d=c.isNode?"node":navigator.userAgent,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 p=d.match(/Version\/(\d+)/);return p===null||p.length<2?0:parseInt(p[1])},c.isMac=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(f),c.isIpad=f==="iPad",c.isIphone=f==="iPhone",c.isWindows=["Windows","Win16","Win32","WinCE"].includes(f),c.isLinux=f.indexOf("Linux")>=0,c.isChromeOS=/\bCrOS\b/.test(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 p=this._getKey(f);if(p===void 0||(d=this._search(p),d===-1)||this._getKey(this._array[d])!==p)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])===p);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,p){if(this._array.length!==0&&(d=this._search(f),!(d<0||d>=this._array.length)&&this._getKey(this._array[d])===f))do p(this._array[d]);while(++d<this._array.length&&this._getKey(this._array[d])===f)}values(){return[...this._array].values()}_search(f){let p=0,m=this._array.length-1;for(;m>=p;){let x=p+m>>1;const y=this._getKey(this._array[x]);if(y>f)m=x-1;else{if(!(y<f)){for(;x>0&&this._getKey(this._array[x-1])===f;)x--;return x}p=x+1}}return p}}},7226:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.DebouncedIdleTask=c.IdleTaskQueue=c.PriorityTaskQueue=void 0;const f=d(6114);class p{constructor(){this._tasks=[],this._i=0}enqueue(y){this._tasks.push(y),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(y){this._idleCallback=void 0;let w=0,C=0,b=y.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=y.timeRemaining(),1.5*C>S)return b-w<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(b-w))}ms`),void this._start();b=S}this.clear()}}class m extends p{_requestCallback(y){return setTimeout((()=>y(this._createDeadline(16))))}_cancelCallback(y){clearTimeout(y)}_createDeadline(y){const w=Date.now()+y;return{timeRemaining:()=>Math.max(0,w-Date.now())}}}c.PriorityTaskQueue=m,c.IdleTaskQueue=!f.isNode&&"requestIdleCallback"in window?class extends p{_requestCallback(x){return requestIdleCallback(x)}_cancelCallback(x){cancelIdleCallback(x)}}:m,c.DebouncedIdleTask=class{constructor(){this._queue=new c.IdleTaskQueue}set(x){this._queue.clear(),this._queue.enqueue(x)}flush(){this._queue.flush()}}},9282:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.updateWindowsModeWrappedState=void 0;const f=d(643);c.updateWindowsModeWrappedState=function(p){const m=p.buffer.lines.get(p.buffer.ybase+p.buffer.y-1),x=m==null?void 0:m.get(p.cols-1),y=p.buffer.lines.get(p.buffer.ybase+p.buffer.y);y&&x&&(y.isWrapped=x[f.CHAR_DATA_CODE_INDEX]!==f.NULL_CELL_CODE&&x[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(m){return[m>>>16&255,m>>>8&255,255&m]}static fromColorRGB(m){return(255&m[0])<<16|(255&m[1])<<8|255&m[2]}clone(){const m=new d;return m.fg=this.fg,m.bg=this.bg,m.extended=this.extended.clone(),m}isInverse(){return 67108864&this.fg}isBold(){return 134217728&this.fg}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:268435456&this.fg}isBlink(){return 536870912&this.fg}isInvisible(){return 1073741824&this.fg}isItalic(){return 67108864&this.bg}isDim(){return 134217728&this.bg}isStrikethrough(){return 2147483648&this.fg}isProtected(){return 536870912&this.bg}isOverline(){return 1073741824&this.bg}getFgColorMode(){return 50331648&this.fg}getBgColorMode(){return 50331648&this.bg}isFgRGB(){return(50331648&this.fg)==50331648}isBgRGB(){return(50331648&this.bg)==50331648}isFgPalette(){return(50331648&this.fg)==16777216||(50331648&this.fg)==33554432}isBgPalette(){return(50331648&this.bg)==16777216||(50331648&this.bg)==33554432}isFgDefault(){return(50331648&this.fg)==0}isBgDefault(){return(50331648&this.bg)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}}getBgColor(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}}hasExtendedAttrs(){return 268435456&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(268435456&this.bg&&~this.extended.underlineColor)switch(50331648&this.extended.underlineColor){case 16777216:case 33554432:return 255&this.extended.underlineColor;case 50331648:return 16777215&this.extended.underlineColor;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return 268435456&this.bg&&~this.extended.underlineColor?50331648&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==16777216||(50331648&this.extended.underlineColor)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==0:this.isFgDefault()}getUnderlineStyle(){return 268435456&this.fg?268435456&this.bg?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}}c.AttributeData=d;class f{get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(m){this._ext=m}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(m){this._ext&=-469762049,this._ext|=m<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(m){this._ext&=-67108864,this._ext|=67108863&m}get urlId(){return this._urlId}set urlId(m){this._urlId=m}get underlineVariantOffset(){const m=(3758096384&this._ext)>>29;return m<0?4294967288^m:m}set underlineVariantOffset(m){this._ext&=536870911,this._ext|=m<<29&3758096384}constructor(m=0,x=0){this._ext=0,this._urlId=0,this._ext=m,this._urlId=x}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),p=d(7226),m=d(3734),x=d(8437),y=d(4634),w=d(511),C=d(643),b=d(4863),S=d(7116);c.MAX_BUFFER_SIZE=4294967295,c.Buffer=class{constructor(v,_,E){this._hasScrollback=v,this._optionsService=_,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=x.DEFAULT_ATTR_DATA.clone(),this.savedCharset=S.DEFAULT_CHARSET,this.markers=[],this._nullCell=w.CellData.fromCharData([0,C.NULL_CELL_CHAR,C.NULL_CELL_WIDTH,C.NULL_CELL_CODE]),this._whitespaceCell=w.CellData.fromCharData([0,C.WHITESPACE_CELL_CHAR,C.WHITESPACE_CELL_WIDTH,C.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new p.IdleTaskQueue,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new f.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(v){return v?(this._nullCell.fg=v.fg,this._nullCell.bg=v.bg,this._nullCell.extended=v.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new m.ExtendedAttrs),this._nullCell}getWhitespaceCell(v){return v?(this._whitespaceCell.fg=v.fg,this._whitespaceCell.bg=v.bg,this._whitespaceCell.extended=v.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new m.ExtendedAttrs),this._whitespaceCell}getBlankLine(v,_){return new x.BufferLine(this._bufferService.cols,this.getNullCell(v),_)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){const v=this.ybase+this.y-this.ydisp;return v>=0&&v<this._rows}_getCorrectBufferLength(v){if(!this._hasScrollback)return v;const _=v+this._optionsService.rawOptions.scrollback;return _>c.MAX_BUFFER_SIZE?c.MAX_BUFFER_SIZE:_}fillViewportRows(v){if(this.lines.length===0){v===void 0&&(v=x.DEFAULT_ATTR_DATA);let _=this._rows;for(;_--;)this.lines.push(this.getBlankLine(v))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new f.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(v,_){const E=this.getNullCell(x.DEFAULT_ATTR_DATA);let j=0;const T=this._getCorrectBufferLength(_);if(T>this.lines.maxLength&&(this.lines.maxLength=T),this.lines.length>0){if(this._cols<v)for(let A=0;A<this.lines.length;A++)j+=+this.lines.get(A).resize(v,E);let R=0;if(this._rows<_)for(let A=this._rows;A<_;A++)this.lines.length<_+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new x.BufferLine(v,E)):this.ybase>0&&this.lines.length<=this.ybase+this.y+R+1?(this.ybase--,R++,this.ydisp>0&&this.ydisp--):this.lines.push(new x.BufferLine(v,E)));else for(let A=this._rows;A>_;A--)this.lines.length>_+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,v-1),this.y=Math.min(this.y,_-1),R&&(this.y+=R),this.savedX=Math.min(this.savedX,v-1),this.scrollTop=0}if(this.scrollBottom=_-1,this._isReflowEnabled&&(this._reflow(v,_),this._cols>v))for(let R=0;R<this.lines.length;R++)j+=+this.lines.get(R).resize(v,E);this._cols=v,this._rows=_,this._memoryCleanupQueue.clear(),j>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue((()=>this._batchedMemoryCleanup())))}_batchedMemoryCleanup(){let v=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,v=!1);let _=0;for(;this._memoryCleanupPosition<this.lines.length;)if(_+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),_>100)return!0;return v}get _isReflowEnabled(){const v=this._optionsService.rawOptions.windowsPty;return v&&v.buildNumber?this._hasScrollback&&v.backend==="conpty"&&v.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(v,_){this._cols!==v&&(v>this._cols?this._reflowLarger(v,_):this._reflowSmaller(v,_))}_reflowLarger(v,_){const E=(0,y.reflowLargerGetLinesToRemove)(this.lines,this._cols,v,this.ybase+this.y,this.getNullCell(x.DEFAULT_ATTR_DATA));if(E.length>0){const j=(0,y.reflowLargerCreateNewLayout)(this.lines,E);(0,y.reflowLargerApplyNewLayout)(this.lines,j.layout),this._reflowLargerAdjustViewport(v,_,j.countRemoved)}}_reflowLargerAdjustViewport(v,_,E){const j=this.getNullCell(x.DEFAULT_ATTR_DATA);let T=E;for(;T-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<_&&this.lines.push(new x.BufferLine(v,j))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-E,0)}_reflowSmaller(v,_){const E=this.getNullCell(x.DEFAULT_ATTR_DATA),j=[];let T=0;for(let R=this.lines.length-1;R>=0;R--){let A=this.lines.get(R);if(!A||!A.isWrapped&&A.getTrimmedLength()<=v)continue;const D=[A];for(;A.isWrapped&&R>0;)A=this.lines.get(--R),D.unshift(A);const $=this.ybase+this.y;if($>=R&&$<R+D.length)continue;const q=D[D.length-1].getTrimmedLength(),G=(0,y.reflowSmallerGetNewLineLengths)(D,this._cols,v),I=G.length-D.length;let U;U=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+I):Math.max(0,this.lines.length-this.lines.maxLength+I);const V=[];for(let B=0;B<I;B++){const W=this.getBlankLine(x.DEFAULT_ATTR_DATA,!0);V.push(W)}V.length>0&&(j.push({start:R+D.length+T,newLines:V}),T+=V.length),D.push(...V);let z=G.length-1,J=G[z];J===0&&(z--,J=G[z]);let Z=D.length-I-1,H=q;for(;Z>=0;){const B=Math.min(H,J);if(D[z]===void 0)break;if(D[z].copyCellsFrom(D[Z],H-B,J-B,B,!0),J-=B,J===0&&(z--,J=G[z]),H-=B,H===0){Z--;const W=Math.max(Z,0);H=(0,y.getWrappedLineTrimmedLength)(D,W,this._cols)}}for(let B=0;B<D.length;B++)G[B]<v&&D[B].setCell(G[B],E);let O=I-U;for(;O-- >0;)this.ybase===0?this.y<_-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+T)-_&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+I,this.ybase+_-1)}if(j.length>0){const R=[],A=[];for(let z=0;z<this.lines.length;z++)A.push(this.lines.get(z));const D=this.lines.length;let $=D-1,q=0,G=j[q];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+T);let I=0;for(let z=Math.min(this.lines.maxLength-1,D+T-1);z>=0;z--)if(G&&G.start>$+I){for(let J=G.newLines.length-1;J>=0;J--)this.lines.set(z--,G.newLines[J]);z++,R.push({index:$+1,amount:G.newLines.length}),I+=G.newLines.length,G=j[++q]}else this.lines.set(z,A[$--]);let U=0;for(let z=R.length-1;z>=0;z--)R[z].index+=U,this.lines.onInsertEmitter.fire(R[z]),U+=R[z].amount;const V=Math.max(0,D+T-this.lines.maxLength);V>0&&this.lines.onTrimEmitter.fire(V)}}translateBufferLineToString(v,_,E=0,j){const T=this.lines.get(v);return T?T.translateToString(_,E,j):""}getWrappedRangeForLine(v){let _=v,E=v;for(;_>0&&this.lines.get(_).isWrapped;)_--;for(;E+1<this.lines.length&&this.lines.get(E+1).isWrapped;)E++;return{first:_,last:E}}setupTabStops(v){for(v!=null?this.tabs[v]||(v=this.prevStop(v)):(this.tabs={},v=0);v<this._cols;v+=this._optionsService.rawOptions.tabStopWidth)this.tabs[v]=!0}prevStop(v){for(v==null&&(v=this.x);!this.tabs[--v]&&v>0;);return v>=this._cols?this._cols-1:v<0?0:v}nextStop(v){for(v==null&&(v=this.x);!this.tabs[++v]&&v<this._cols;);return v>=this._cols?this._cols-1:v<0?0:v}clearMarkers(v){this._isClearing=!0;for(let _=0;_<this.markers.length;_++)this.markers[_].line===v&&(this.markers[_].dispose(),this.markers.splice(_--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let v=0;v<this.markers.length;v++)this.markers[v].dispose(),this.markers.splice(v--,1);this._isClearing=!1}addMarker(v){const _=new b.Marker(v);return this.markers.push(_),_.register(this.lines.onTrim((E=>{_.line-=E,_.line<0&&_.dispose()}))),_.register(this.lines.onInsert((E=>{_.line>=E.index&&(_.line+=E.amount)}))),_.register(this.lines.onDelete((E=>{_.line>=E.index&&_.line<E.index+E.amount&&_.dispose(),_.line>E.index&&(_.line-=E.amount)}))),_.register(_.onDispose((()=>this._removeMarker(_)))),_}_removeMarker(v){this._isClearing||this.markers.splice(this.markers.indexOf(v),1)}}},8437:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.BufferLine=c.DEFAULT_ATTR_DATA=void 0;const f=d(3734),p=d(511),m=d(643),x=d(482);c.DEFAULT_ATTR_DATA=Object.freeze(new f.AttributeData);let y=0;class w{constructor(b,S,v=!1){this.isWrapped=v,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*b);const _=S||p.CellData.fromCharData([0,m.NULL_CELL_CHAR,m.NULL_CELL_WIDTH,m.NULL_CELL_CODE]);for(let E=0;E<b;++E)this.setCell(E,_);this.length=b}get(b){const S=this._data[3*b+0],v=2097151&S;return[this._data[3*b+1],2097152&S?this._combined[b]:v?(0,x.stringFromCodePoint)(v):"",S>>22,2097152&S?this._combined[b].charCodeAt(this._combined[b].length-1):v]}set(b,S){this._data[3*b+1]=S[m.CHAR_DATA_ATTR_INDEX],S[m.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[b]=S[1],this._data[3*b+0]=2097152|b|S[m.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*b+0]=S[m.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|S[m.CHAR_DATA_WIDTH_INDEX]<<22}getWidth(b){return this._data[3*b+0]>>22}hasWidth(b){return 12582912&this._data[3*b+0]}getFg(b){return this._data[3*b+1]}getBg(b){return this._data[3*b+2]}hasContent(b){return 4194303&this._data[3*b+0]}getCodePoint(b){const S=this._data[3*b+0];return 2097152&S?this._combined[b].charCodeAt(this._combined[b].length-1):2097151&S}isCombined(b){return 2097152&this._data[3*b+0]}getString(b){const S=this._data[3*b+0];return 2097152&S?this._combined[b]:2097151&S?(0,x.stringFromCodePoint)(2097151&S):""}isProtected(b){return 536870912&this._data[3*b+2]}loadCell(b,S){return y=3*b,S.content=this._data[y+0],S.fg=this._data[y+1],S.bg=this._data[y+2],2097152&S.content&&(S.combinedData=this._combined[b]),268435456&S.bg&&(S.extended=this._extendedAttrs[b]),S}setCell(b,S){2097152&S.content&&(this._combined[b]=S.combinedData),268435456&S.bg&&(this._extendedAttrs[b]=S.extended),this._data[3*b+0]=S.content,this._data[3*b+1]=S.fg,this._data[3*b+2]=S.bg}setCellFromCodepoint(b,S,v,_){268435456&_.bg&&(this._extendedAttrs[b]=_.extended),this._data[3*b+0]=S|v<<22,this._data[3*b+1]=_.fg,this._data[3*b+2]=_.bg}addCodepointToCell(b,S,v){let _=this._data[3*b+0];2097152&_?this._combined[b]+=(0,x.stringFromCodePoint)(S):2097151&_?(this._combined[b]=(0,x.stringFromCodePoint)(2097151&_)+(0,x.stringFromCodePoint)(S),_&=-2097152,_|=2097152):_=S|4194304,v&&(_&=-12582913,_|=v<<22),this._data[3*b+0]=_}insertCells(b,S,v){if((b%=this.length)&&this.getWidth(b-1)===2&&this.setCellFromCodepoint(b-1,0,1,v),S<this.length-b){const _=new p.CellData;for(let E=this.length-b-S-1;E>=0;--E)this.setCell(b+S+E,this.loadCell(b+E,_));for(let E=0;E<S;++E)this.setCell(b+E,v)}else for(let _=b;_<this.length;++_)this.setCell(_,v);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,v)}deleteCells(b,S,v){if(b%=this.length,S<this.length-b){const _=new p.CellData;for(let E=0;E<this.length-b-S;++E)this.setCell(b+E,this.loadCell(b+S+E,_));for(let E=this.length-S;E<this.length;++E)this.setCell(E,v)}else for(let _=b;_<this.length;++_)this.setCell(_,v);b&&this.getWidth(b-1)===2&&this.setCellFromCodepoint(b-1,0,1,v),this.getWidth(b)!==0||this.hasContent(b)||this.setCellFromCodepoint(b,0,1,v)}replaceCells(b,S,v,_=!1){if(_)for(b&&this.getWidth(b-1)===2&&!this.isProtected(b-1)&&this.setCellFromCodepoint(b-1,0,1,v),S<this.length&&this.getWidth(S-1)===2&&!this.isProtected(S)&&this.setCellFromCodepoint(S,0,1,v);b<S&&b<this.length;)this.isProtected(b)||this.setCell(b,v),b++;else for(b&&this.getWidth(b-1)===2&&this.setCellFromCodepoint(b-1,0,1,v),S<this.length&&this.getWidth(S-1)===2&&this.setCellFromCodepoint(S,0,1,v);b<S&&b<this.length;)this.setCell(b++,v)}resize(b,S){if(b===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;const v=3*b;if(b>this.length){if(this._data.buffer.byteLength>=4*v)this._data=new Uint32Array(this._data.buffer,0,v);else{const _=new Uint32Array(v);_.set(this._data),this._data=_}for(let _=this.length;_<b;++_)this.setCell(_,S)}else{this._data=this._data.subarray(0,v);const _=Object.keys(this._combined);for(let j=0;j<_.length;j++){const T=parseInt(_[j],10);T>=b&&delete this._combined[T]}const E=Object.keys(this._extendedAttrs);for(let j=0;j<E.length;j++){const T=parseInt(E[j],10);T>=b&&delete this._extendedAttrs[T]}}return this.length=b,4*v*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){const b=new Uint32Array(this._data.length);return b.set(this._data),this._data=b,1}return 0}fill(b,S=!1){if(S)for(let v=0;v<this.length;++v)this.isProtected(v)||this.setCell(v,b);else{this._combined={},this._extendedAttrs={};for(let v=0;v<this.length;++v)this.setCell(v,b)}}copyFrom(b){this.length!==b.length?this._data=new Uint32Array(b._data):this._data.set(b._data),this.length=b.length,this._combined={};for(const S in b._combined)this._combined[S]=b._combined[S];this._extendedAttrs={};for(const S in b._extendedAttrs)this._extendedAttrs[S]=b._extendedAttrs[S];this.isWrapped=b.isWrapped}clone(){const b=new w(0);b._data=new Uint32Array(this._data),b.length=this.length;for(const S in this._combined)b._combined[S]=this._combined[S];for(const S in this._extendedAttrs)b._extendedAttrs[S]=this._extendedAttrs[S];return b.isWrapped=this.isWrapped,b}getTrimmedLength(){for(let b=this.length-1;b>=0;--b)if(4194303&this._data[3*b+0])return b+(this._data[3*b+0]>>22);return 0}getNoBgTrimmedLength(){for(let b=this.length-1;b>=0;--b)if(4194303&this._data[3*b+0]||50331648&this._data[3*b+2])return b+(this._data[3*b+0]>>22);return 0}copyCellsFrom(b,S,v,_,E){const j=b._data;if(E)for(let R=_-1;R>=0;R--){for(let A=0;A<3;A++)this._data[3*(v+R)+A]=j[3*(S+R)+A];268435456&j[3*(S+R)+2]&&(this._extendedAttrs[v+R]=b._extendedAttrs[S+R])}else for(let R=0;R<_;R++){for(let A=0;A<3;A++)this._data[3*(v+R)+A]=j[3*(S+R)+A];268435456&j[3*(S+R)+2]&&(this._extendedAttrs[v+R]=b._extendedAttrs[S+R])}const T=Object.keys(b._combined);for(let R=0;R<T.length;R++){const A=parseInt(T[R],10);A>=S&&(this._combined[A-S+v]=b._combined[A])}}translateToString(b,S,v,_){S=S??0,v=v??this.length,b&&(v=Math.min(v,this.getTrimmedLength())),_&&(_.length=0);let E="";for(;S<v;){const j=this._data[3*S+0],T=2097151&j,R=2097152&j?this._combined[S]:T?(0,x.stringFromCodePoint)(T):m.WHITESPACE_CELL_CHAR;if(E+=R,_)for(let A=0;A<R.length;++A)_.push(S);S+=j>>22||1}return _&&_.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,p,m){if(p===f.length-1)return f[p].getTrimmedLength();const x=!f[p].hasContent(m-1)&&f[p].getWidth(m-1)===1,y=f[p+1].getWidth(0)===2;return x&&y?m-1:m}Object.defineProperty(c,"__esModule",{value:!0}),c.getWrappedLineTrimmedLength=c.reflowSmallerGetNewLineLengths=c.reflowLargerApplyNewLayout=c.reflowLargerCreateNewLayout=c.reflowLargerGetLinesToRemove=void 0,c.reflowLargerGetLinesToRemove=function(f,p,m,x,y){const w=[];for(let C=0;C<f.length-1;C++){let b=C,S=f.get(++b);if(!S.isWrapped)continue;const v=[f.get(C)];for(;b<f.length&&S.isWrapped;)v.push(S),S=f.get(++b);if(x>=C&&x<b){C+=v.length-1;continue}let _=0,E=d(v,_,p),j=1,T=0;for(;j<v.length;){const A=d(v,j,p),D=A-T,$=m-E,q=Math.min(D,$);v[_].copyCellsFrom(v[j],T,E,q,!1),E+=q,E===m&&(_++,E=0),T+=q,T===A&&(j++,T=0),E===0&&_!==0&&v[_-1].getWidth(m-1)===2&&(v[_].copyCellsFrom(v[_-1],m-1,E++,1,!1),v[_-1].setCell(m-1,y))}v[_].replaceCells(E,m,y);let R=0;for(let A=v.length-1;A>0&&(A>_||v[A].getTrimmedLength()===0);A--)R++;R>0&&(w.push(C+v.length-R),w.push(R)),C+=v.length-1}return w},c.reflowLargerCreateNewLayout=function(f,p){const m=[];let x=0,y=p[x],w=0;for(let C=0;C<f.length;C++)if(y===C){const b=p[++x];f.onDeleteEmitter.fire({index:C-w,amount:b}),C+=b-1,w+=b,y=p[++x]}else m.push(C);return{layout:m,countRemoved:w}},c.reflowLargerApplyNewLayout=function(f,p){const m=[];for(let x=0;x<p.length;x++)m.push(f.get(p[x]));for(let x=0;x<m.length;x++)f.set(x,m[x]);f.length=p.length},c.reflowSmallerGetNewLineLengths=function(f,p,m){const x=[],y=f.map(((S,v)=>d(f,v,p))).reduce(((S,v)=>S+v));let w=0,C=0,b=0;for(;b<y;){if(y-b<m){x.push(y-b);break}w+=m;const S=d(f,C,p);w>S&&(w-=S,C++);const v=f[C].getWidth(w-1)===2;v&&w--;const _=v?m-1:m;x.push(_),b+=_}return x},c.getWrappedLineTrimmedLength=d},5295:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.BufferSet=void 0;const f=d(8460),p=d(844),m=d(9092);class x extends p.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 m.Buffer(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new m.Buffer(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(w){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(w),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(w,C){this._normal.resize(w,C),this._alt.resize(w,C),this.setupTabStops(w)}setupTabStops(w){this._normal.setupTabStops(w),this._alt.setupTabStops(w)}}c.BufferSet=x},511:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.CellData=void 0;const f=d(482),p=d(643),m=d(3734);class x extends m.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new m.ExtendedAttrs,this.combinedData=""}static fromCharData(w){const C=new x;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[p.CHAR_DATA_ATTR_INDEX],this.bg=0;let C=!1;if(w[p.CHAR_DATA_CHAR_INDEX].length>2)C=!0;else if(w[p.CHAR_DATA_CHAR_INDEX].length===2){const b=w[p.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=b&&b<=56319){const S=w[p.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=S&&S<=57343?this.content=1024*(b-55296)+S-56320+65536|w[p.CHAR_DATA_WIDTH_INDEX]<<22:C=!0}else C=!0}else this.content=w[p.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|w[p.CHAR_DATA_WIDTH_INDEX]<<22;C&&(this.combinedData=w[p.CHAR_DATA_CHAR_INDEX],this.content=2097152|w[p.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}c.CellData=x},643:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.WHITESPACE_CELL_CODE=c.WHITESPACE_CELL_WIDTH=c.WHITESPACE_CELL_CHAR=c.NULL_CELL_CODE=c.NULL_CELL_WIDTH=c.NULL_CELL_CHAR=c.CHAR_DATA_CODE_INDEX=c.CHAR_DATA_WIDTH_INDEX=c.CHAR_DATA_CHAR_INDEX=c.CHAR_DATA_ATTR_INDEX=c.DEFAULT_EXT=c.DEFAULT_ATTR=c.DEFAULT_COLOR=void 0,c.DEFAULT_COLOR=0,c.DEFAULT_ATTR=256|c.DEFAULT_COLOR<<9,c.DEFAULT_EXT=0,c.CHAR_DATA_ATTR_INDEX=0,c.CHAR_DATA_CHAR_INDEX=1,c.CHAR_DATA_WIDTH_INDEX=2,c.CHAR_DATA_CODE_INDEX=3,c.NULL_CELL_CHAR="",c.NULL_CELL_WIDTH=1,c.NULL_CELL_CODE=0,c.WHITESPACE_CELL_CHAR=" ",c.WHITESPACE_CELL_WIDTH=1,c.WHITESPACE_CELL_CODE=32},4863:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.Marker=void 0;const f=d(8460),p=d(844);class m{get id(){return this._id}constructor(y){this.line=y,this.isDisposed=!1,this._disposables=[],this._id=m._nextId++,this._onDispose=this.register(new f.EventEmitter),this.onDispose=this._onDispose.event}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),(0,p.disposeArray)(this._disposables),this._disposables.length=0)}register(y){return this._disposables.push(y),y}}c.Marker=m,m._nextId=1},7116:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.DEFAULT_CHARSET=c.CHARSETS=void 0,c.CHARSETS={},c.DEFAULT_CHARSET=c.CHARSETS.B,c.CHARSETS[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"},c.CHARSETS.A={"#":"£"},c.CHARSETS.B=void 0,c.CHARSETS[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},c.CHARSETS.C=c.CHARSETS[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},c.CHARSETS.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},c.CHARSETS.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},c.CHARSETS.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},c.CHARSETS.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},c.CHARSETS.E=c.CHARSETS[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},c.CHARSETS.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},c.CHARSETS.H=c.CHARSETS[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},c.CHARSETS["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"}},2584:(u,c)=>{var d,f,p;Object.defineProperty(c,"__esModule",{value:!0}),c.C1_ESCAPED=c.C1=c.C0=void 0,(function(m){m.NUL="\0",m.SOH="",m.STX="",m.ETX="",m.EOT="",m.ENQ="",m.ACK="",m.BEL="\x07",m.BS="\b",m.HT=" ",m.LF=`
|
|
67
|
+
`,m.VT="\v",m.FF="\f",m.CR="\r",m.SO="",m.SI="",m.DLE="",m.DC1="",m.DC2="",m.DC3="",m.DC4="",m.NAK="",m.SYN="",m.ETB="",m.CAN="",m.EM="",m.SUB="",m.ESC="\x1B",m.FS="",m.GS="",m.RS="",m.US="",m.SP=" ",m.DEL=""})(d||(c.C0=d={})),(function(m){m.PAD="",m.HOP="",m.BPH="",m.NBH="",m.IND="",m.NEL="
",m.SSA="",m.ESA="",m.HTS="",m.HTJ="",m.VTS="",m.PLD="",m.PLU="",m.RI="",m.SS2="",m.SS3="",m.DCS="",m.PU1="",m.PU2="",m.STS="",m.CCH="",m.MW="",m.SPA="",m.EPA="",m.SOS="",m.SGCI="",m.SCI="",m.CSI="",m.ST="",m.OSC="",m.PM="",m.APC=""})(f||(c.C1=f={})),(function(m){m.ST=`${d.ESC}\\`})(p||(c.C1_ESCAPED=p={}))},7399:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.evaluateKeyboardEvent=void 0;const f=d(2584),p={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};c.evaluateKeyboardEvent=function(m,x,y,w){const C={type:0,cancel:!1,key:void 0},b=(m.shiftKey?1:0)|(m.altKey?2:0)|(m.ctrlKey?4:0)|(m.metaKey?8:0);switch(m.keyCode){case 0:m.key==="UIKeyInputUpArrow"?C.key=x?f.C0.ESC+"OA":f.C0.ESC+"[A":m.key==="UIKeyInputLeftArrow"?C.key=x?f.C0.ESC+"OD":f.C0.ESC+"[D":m.key==="UIKeyInputRightArrow"?C.key=x?f.C0.ESC+"OC":f.C0.ESC+"[C":m.key==="UIKeyInputDownArrow"&&(C.key=x?f.C0.ESC+"OB":f.C0.ESC+"[B");break;case 8:C.key=m.ctrlKey?"\b":f.C0.DEL,m.altKey&&(C.key=f.C0.ESC+C.key);break;case 9:if(m.shiftKey){C.key=f.C0.ESC+"[Z";break}C.key=f.C0.HT,C.cancel=!0;break;case 13:C.key=m.altKey?f.C0.ESC+f.C0.CR:f.C0.CR,C.cancel=!0;break;case 27:C.key=f.C0.ESC,m.altKey&&(C.key=f.C0.ESC+f.C0.ESC),C.cancel=!0;break;case 37:if(m.metaKey)break;b?(C.key=f.C0.ESC+"[1;"+(b+1)+"D",C.key===f.C0.ESC+"[1;3D"&&(C.key=f.C0.ESC+(y?"b":"[1;5D"))):C.key=x?f.C0.ESC+"OD":f.C0.ESC+"[D";break;case 39:if(m.metaKey)break;b?(C.key=f.C0.ESC+"[1;"+(b+1)+"C",C.key===f.C0.ESC+"[1;3C"&&(C.key=f.C0.ESC+(y?"f":"[1;5C"))):C.key=x?f.C0.ESC+"OC":f.C0.ESC+"[C";break;case 38:if(m.metaKey)break;b?(C.key=f.C0.ESC+"[1;"+(b+1)+"A",y||C.key!==f.C0.ESC+"[1;3A"||(C.key=f.C0.ESC+"[1;5A")):C.key=x?f.C0.ESC+"OA":f.C0.ESC+"[A";break;case 40:if(m.metaKey)break;b?(C.key=f.C0.ESC+"[1;"+(b+1)+"B",y||C.key!==f.C0.ESC+"[1;3B"||(C.key=f.C0.ESC+"[1;5B")):C.key=x?f.C0.ESC+"OB":f.C0.ESC+"[B";break;case 45:m.shiftKey||m.ctrlKey||(C.key=f.C0.ESC+"[2~");break;case 46:C.key=b?f.C0.ESC+"[3;"+(b+1)+"~":f.C0.ESC+"[3~";break;case 36:C.key=b?f.C0.ESC+"[1;"+(b+1)+"H":x?f.C0.ESC+"OH":f.C0.ESC+"[H";break;case 35:C.key=b?f.C0.ESC+"[1;"+(b+1)+"F":x?f.C0.ESC+"OF":f.C0.ESC+"[F";break;case 33:m.shiftKey?C.type=2:m.ctrlKey?C.key=f.C0.ESC+"[5;"+(b+1)+"~":C.key=f.C0.ESC+"[5~";break;case 34:m.shiftKey?C.type=3:m.ctrlKey?C.key=f.C0.ESC+"[6;"+(b+1)+"~":C.key=f.C0.ESC+"[6~";break;case 112:C.key=b?f.C0.ESC+"[1;"+(b+1)+"P":f.C0.ESC+"OP";break;case 113:C.key=b?f.C0.ESC+"[1;"+(b+1)+"Q":f.C0.ESC+"OQ";break;case 114:C.key=b?f.C0.ESC+"[1;"+(b+1)+"R":f.C0.ESC+"OR";break;case 115:C.key=b?f.C0.ESC+"[1;"+(b+1)+"S":f.C0.ESC+"OS";break;case 116:C.key=b?f.C0.ESC+"[15;"+(b+1)+"~":f.C0.ESC+"[15~";break;case 117:C.key=b?f.C0.ESC+"[17;"+(b+1)+"~":f.C0.ESC+"[17~";break;case 118:C.key=b?f.C0.ESC+"[18;"+(b+1)+"~":f.C0.ESC+"[18~";break;case 119:C.key=b?f.C0.ESC+"[19;"+(b+1)+"~":f.C0.ESC+"[19~";break;case 120:C.key=b?f.C0.ESC+"[20;"+(b+1)+"~":f.C0.ESC+"[20~";break;case 121:C.key=b?f.C0.ESC+"[21;"+(b+1)+"~":f.C0.ESC+"[21~";break;case 122:C.key=b?f.C0.ESC+"[23;"+(b+1)+"~":f.C0.ESC+"[23~";break;case 123:C.key=b?f.C0.ESC+"[24;"+(b+1)+"~":f.C0.ESC+"[24~";break;default:if(!m.ctrlKey||m.shiftKey||m.altKey||m.metaKey)if(y&&!w||!m.altKey||m.metaKey)!y||m.altKey||m.ctrlKey||m.shiftKey||!m.metaKey?m.key&&!m.ctrlKey&&!m.altKey&&!m.metaKey&&m.keyCode>=48&&m.key.length===1?C.key=m.key:m.key&&m.ctrlKey&&(m.key==="_"&&(C.key=f.C0.US),m.key==="@"&&(C.key=f.C0.NUL)):m.keyCode===65&&(C.type=1);else{const S=p[m.keyCode],v=S==null?void 0:S[m.shiftKey?1:0];if(v)C.key=f.C0.ESC+v;else if(m.keyCode>=65&&m.keyCode<=90){const _=m.ctrlKey?m.keyCode-64:m.keyCode+32;let E=String.fromCharCode(_);m.shiftKey&&(E=E.toUpperCase()),C.key=f.C0.ESC+E}else if(m.keyCode===32)C.key=f.C0.ESC+(m.ctrlKey?f.C0.NUL:" ");else if(m.key==="Dead"&&m.code.startsWith("Key")){let _=m.code.slice(3,4);m.shiftKey||(_=_.toLowerCase()),C.key=f.C0.ESC+_,C.cancel=!0}}else m.keyCode>=65&&m.keyCode<=90?C.key=String.fromCharCode(m.keyCode-64):m.keyCode===32?C.key=f.C0.NUL:m.keyCode>=51&&m.keyCode<=55?C.key=String.fromCharCode(m.keyCode-51+27):m.keyCode===56?C.key=f.C0.DEL:m.keyCode===219?C.key=f.C0.ESC:m.keyCode===220?C.key=f.C0.FS:m.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,p=d.length){let m="";for(let x=f;x<p;++x){let y=d[x];y>65535?(y-=65536,m+=String.fromCharCode(55296+(y>>10))+String.fromCharCode(y%1024+56320)):m+=String.fromCharCode(y)}return m},c.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(d,f){const p=d.length;if(!p)return 0;let m=0,x=0;if(this._interim){const y=d.charCodeAt(x++);56320<=y&&y<=57343?f[m++]=1024*(this._interim-55296)+y-56320+65536:(f[m++]=this._interim,f[m++]=y),this._interim=0}for(let y=x;y<p;++y){const w=d.charCodeAt(y);if(55296<=w&&w<=56319){if(++y>=p)return this._interim=w,m;const C=d.charCodeAt(y);56320<=C&&C<=57343?f[m++]=1024*(w-55296)+C-56320+65536:(f[m++]=w,f[m++]=C)}else w!==65279&&(f[m++]=w)}return m}},c.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(d,f){const p=d.length;if(!p)return 0;let m,x,y,w,C=0,b=0,S=0;if(this.interim[0]){let E=!1,j=this.interim[0];j&=(224&j)==192?31:(240&j)==224?15:7;let T,R=0;for(;(T=63&this.interim[++R])&&R<4;)j<<=6,j|=T;const A=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,D=A-R;for(;S<D;){if(S>=p)return 0;if(T=d[S++],(192&T)!=128){S--,E=!0;break}this.interim[R++]=T,j<<=6,j|=63&T}E||(A===2?j<128?S--:f[C++]=j:A===3?j<2048||j>=55296&&j<=57343||j===65279||(f[C++]=j):j<65536||j>1114111||(f[C++]=j)),this.interim.fill(0)}const v=p-4;let _=S;for(;_<p;){for(;!(!(_<v)||128&(m=d[_])||128&(x=d[_+1])||128&(y=d[_+2])||128&(w=d[_+3]));)f[C++]=m,f[C++]=x,f[C++]=y,f[C++]=w,_+=4;if(m=d[_++],m<128)f[C++]=m;else if((224&m)==192){if(_>=p)return this.interim[0]=m,C;if(x=d[_++],(192&x)!=128){_--;continue}if(b=(31&m)<<6|63&x,b<128){_--;continue}f[C++]=b}else if((240&m)==224){if(_>=p)return this.interim[0]=m,C;if(x=d[_++],(192&x)!=128){_--;continue}if(_>=p)return this.interim[0]=m,this.interim[1]=x,C;if(y=d[_++],(192&y)!=128){_--;continue}if(b=(15&m)<<12|(63&x)<<6|63&y,b<2048||b>=55296&&b<=57343||b===65279)continue;f[C++]=b}else if((248&m)==240){if(_>=p)return this.interim[0]=m,C;if(x=d[_++],(192&x)!=128){_--;continue}if(_>=p)return this.interim[0]=m,this.interim[1]=x,C;if(y=d[_++],(192&y)!=128){_--;continue}if(_>=p)return this.interim[0]=m,this.interim[1]=x,this.interim[2]=y,C;if(w=d[_++],(192&w)!=128){_--;continue}if(b=(7&m)<<18|(63&x)<<12|(63&y)<<6|63&w,b<65536||b>1114111)continue;f[C++]=b}}return C}}},225:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.UnicodeV6=void 0;const f=d(1480),p=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],m=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]];let x;c.UnicodeV6=class{constructor(){if(this.version="6",!x){x=new Uint8Array(65536),x.fill(1),x[0]=0,x.fill(0,1,32),x.fill(0,127,160),x.fill(2,4352,4448),x[9001]=2,x[9002]=2,x.fill(2,11904,42192),x[12351]=1,x.fill(2,44032,55204),x.fill(2,63744,64256),x.fill(2,65040,65050),x.fill(2,65072,65136),x.fill(2,65280,65377),x.fill(2,65504,65511);for(let y=0;y<p.length;++y)x.fill(0,p[y][0],p[y][1]+1)}}wcwidth(y){return y<32?0:y<127?1:y<65536?x[y]:(function(w,C){let b,S=0,v=C.length-1;if(w<C[0][0]||w>C[v][1])return!1;for(;v>=S;)if(b=S+v>>1,w>C[b][1])S=b+1;else{if(!(w<C[b][0]))return!0;v=b-1}return!1})(y,m)?0:y>=131072&&y<=196605||y>=196608&&y<=262141?2:1}charProperties(y,w){let C=this.wcwidth(y),b=C===0&&w!==0;if(b){const S=f.UnicodeService.extractWidth(w);S===0?b=!1:S>C&&(C=S)}return f.UnicodeService.createPropertyValue(0,C,b)}}},5981:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.WriteBuffer=void 0;const f=d(8460),p=d(844);class m extends p.Disposable{constructor(y){super(),this._action=y,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this.register(new f.EventEmitter),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(y,w){if(w!==void 0&&this._syncCalls>w)return void(this._syncCalls=0);if(this._pendingData+=y.length,this._writeBuffer.push(y),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let C;for(this._isSyncWriting=!0;C=this._writeBuffer.shift();){this._action(C);const b=this._callbacks.shift();b&&b()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(y,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+=y.length,this._writeBuffer.push(y),this._callbacks.push(w),void this._innerWrite();setTimeout((()=>this._innerWrite()))}this._pendingData+=y.length,this._writeBuffer.push(y),this._callbacks.push(w)}_innerWrite(y=0,w=!0){const C=y||Date.now();for(;this._writeBuffer.length>this._bufferOffset;){const b=this._writeBuffer[this._bufferOffset],S=this._action(b,w);if(S){const _=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(_)}const v=this._callbacks[this._bufferOffset];if(v&&v(),this._bufferOffset++,this._pendingData-=b.length,Date.now()-C>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout((()=>this._innerWrite()))):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}}c.WriteBuffer=m},5941:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.toRgbString=c.parseColor=void 0;const d=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,f=/^[\da-f]+$/;function p(m,x){const y=m.toString(16),w=y.length<2?"0"+y:y;switch(x){case 4:return y[0];case 8:return w;case 12:return(w+w).slice(0,3);default:return w+w}}c.parseColor=function(m){if(!m)return;let x=m.toLowerCase();if(x.indexOf("rgb:")===0){x=x.slice(4);const y=d.exec(x);if(y){const w=y[1]?15:y[4]?255:y[7]?4095:65535;return[Math.round(parseInt(y[1]||y[4]||y[7]||y[10],16)/w*255),Math.round(parseInt(y[2]||y[5]||y[8]||y[11],16)/w*255),Math.round(parseInt(y[3]||y[6]||y[9]||y[12],16)/w*255)]}}else if(x.indexOf("#")===0&&(x=x.slice(1),f.exec(x)&&[3,6,9,12].includes(x.length))){const y=x.length/3,w=[0,0,0];for(let C=0;C<3;++C){const b=parseInt(x.slice(y*C,y*C+y),16);w[C]=y===1?b<<4:y===2?b:y===3?b>>4:b>>8}return w}},c.toRgbString=function(m,x=16){const[y,w,C]=m;return`rgb:${p(y,x)}/${p(w,x)}/${p(C,x)}`}},5770:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.PAYLOAD_LIMIT=void 0,c.PAYLOAD_LIMIT=1e7},6351:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.DcsHandler=c.DcsParser=void 0;const f=d(482),p=d(8742),m=d(5770),x=[];c.DcsParser=class{constructor(){this._handlers=Object.create(null),this._active=x,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=x}registerHandler(w,C){this._handlers[w]===void 0&&(this._handlers[w]=[]);const b=this._handlers[w];return b.push(C),{dispose:()=>{const S=b.indexOf(C);S!==-1&&b.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=x,this._ident=0}hook(w,C){if(this.reset(),this._ident=w,this._active=this._handlers[w]||x,this._active.length)for(let b=this._active.length-1;b>=0;b--)this._active[b].hook(C);else this._handlerFb(this._ident,"HOOK",C)}put(w,C,b){if(this._active.length)for(let S=this._active.length-1;S>=0;S--)this._active[S].put(w,C,b);else this._handlerFb(this._ident,"PUT",(0,f.utf32ToString)(w,C,b))}unhook(w,C=!0){if(this._active.length){let b=!1,S=this._active.length-1,v=!1;if(this._stack.paused&&(S=this._stack.loopPosition-1,b=C,v=this._stack.fallThrough,this._stack.paused=!1),!v&&b===!1){for(;S>=0&&(b=this._active[S].unhook(w),b!==!0);S--)if(b instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=S,this._stack.fallThrough=!1,b;S--}for(;S>=0;S--)if(b=this._active[S].unhook(!1),b instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=S,this._stack.fallThrough=!0,b}else this._handlerFb(this._ident,"UNHOOK",w);this._active=x,this._ident=0}};const y=new p.Params;y.addParam(0),c.DcsHandler=class{constructor(w){this._handler=w,this._data="",this._params=y,this._hitLimit=!1}hook(w){this._params=w.length>1||w.params[0]?w.clone():y,this._data="",this._hitLimit=!1}put(w,C,b){this._hitLimit||(this._data+=(0,f.utf32ToString)(w,C,b),this._data.length>m.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(w){let C=!1;if(this._hitLimit)C=!1;else if(w&&(C=this._handler(this._data,this._params),C instanceof Promise))return C.then((b=>(this._params=y,this._data="",this._hitLimit=!1,b)));return this._params=y,this._data="",this._hitLimit=!1,C}}},2015:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.EscapeSequenceParser=c.VT500_TRANSITION_TABLE=c.TransitionTable=void 0;const f=d(844),p=d(8742),m=d(6242),x=d(6351);class y{constructor(S){this.table=new Uint8Array(S)}setDefault(S,v){this.table.fill(S<<4|v)}add(S,v,_,E){this.table[v<<8|S]=_<<4|E}addMany(S,v,_,E){for(let j=0;j<S.length;j++)this.table[v<<8|S[j]]=_<<4|E}}c.TransitionTable=y;const w=160;c.VT500_TRANSITION_TABLE=(function(){const b=new y(4095),S=Array.apply(null,Array(256)).map(((R,A)=>A)),v=(R,A)=>S.slice(R,A),_=v(32,127),E=v(0,24);E.push(25),E.push.apply(E,v(28,32));const j=v(0,14);let T;for(T in b.setDefault(1,0),b.addMany(_,0,2,0),j)b.addMany([24,26,153,154],T,3,0),b.addMany(v(128,144),T,3,0),b.addMany(v(144,152),T,3,0),b.add(156,T,0,0),b.add(27,T,11,1),b.add(157,T,4,8),b.addMany([152,158,159],T,0,7),b.add(155,T,11,3),b.add(144,T,11,9);return b.addMany(E,0,3,0),b.addMany(E,1,3,1),b.add(127,1,0,1),b.addMany(E,8,0,8),b.addMany(E,3,3,3),b.add(127,3,0,3),b.addMany(E,4,3,4),b.add(127,4,0,4),b.addMany(E,6,3,6),b.addMany(E,5,3,5),b.add(127,5,0,5),b.addMany(E,2,3,2),b.add(127,2,0,2),b.add(93,1,4,8),b.addMany(_,8,5,8),b.add(127,8,5,8),b.addMany([156,27,24,26,7],8,6,0),b.addMany(v(28,32),8,0,8),b.addMany([88,94,95],1,0,7),b.addMany(_,7,0,7),b.addMany(E,7,0,7),b.add(156,7,0,0),b.add(127,7,0,7),b.add(91,1,11,3),b.addMany(v(64,127),3,7,0),b.addMany(v(48,60),3,8,4),b.addMany([60,61,62,63],3,9,4),b.addMany(v(48,60),4,8,4),b.addMany(v(64,127),4,7,0),b.addMany([60,61,62,63],4,0,6),b.addMany(v(32,64),6,0,6),b.add(127,6,0,6),b.addMany(v(64,127),6,0,0),b.addMany(v(32,48),3,9,5),b.addMany(v(32,48),5,9,5),b.addMany(v(48,64),5,0,6),b.addMany(v(64,127),5,7,0),b.addMany(v(32,48),4,9,5),b.addMany(v(32,48),1,9,2),b.addMany(v(32,48),2,9,2),b.addMany(v(48,127),2,10,0),b.addMany(v(48,80),1,10,0),b.addMany(v(81,88),1,10,0),b.addMany([89,90,92],1,10,0),b.addMany(v(96,127),1,10,0),b.add(80,1,11,9),b.addMany(E,9,0,9),b.add(127,9,0,9),b.addMany(v(28,32),9,0,9),b.addMany(v(32,48),9,9,12),b.addMany(v(48,60),9,8,10),b.addMany([60,61,62,63],9,9,10),b.addMany(E,11,0,11),b.addMany(v(32,128),11,0,11),b.addMany(v(28,32),11,0,11),b.addMany(E,10,0,10),b.add(127,10,0,10),b.addMany(v(28,32),10,0,10),b.addMany(v(48,60),10,8,10),b.addMany([60,61,62,63],10,0,11),b.addMany(v(32,48),10,9,12),b.addMany(E,12,0,12),b.add(127,12,0,12),b.addMany(v(28,32),12,0,12),b.addMany(v(32,48),12,9,12),b.addMany(v(48,64),12,0,11),b.addMany(v(64,127),12,12,13),b.addMany(v(64,127),10,12,13),b.addMany(v(64,127),9,12,13),b.addMany(E,13,13,13),b.addMany(_,13,13,13),b.add(127,13,0,13),b.addMany([27,156,24,26],13,14,0),b.add(w,0,2,0),b.add(w,8,5,8),b.add(w,6,0,6),b.add(w,11,0,11),b.add(w,13,13,13),b})();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 p.Params,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(v,_,E)=>{},this._executeHandlerFb=v=>{},this._csiHandlerFb=(v,_)=>{},this._escHandlerFb=v=>{},this._errorHandlerFb=v=>v,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this.register((0,f.toDisposable)((()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)}))),this._oscParser=this.register(new m.OscParser),this._dcsParser=this.register(new x.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},(()=>!0))}_identifier(S,v=[64,126]){let _=0;if(S.prefix){if(S.prefix.length>1)throw new Error("only one byte as prefix supported");if(_=S.prefix.charCodeAt(0),_&&60>_||_>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 j=0;j<S.intermediates.length;++j){const T=S.intermediates.charCodeAt(j);if(32>T||T>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");_<<=8,_|=T}}if(S.final.length!==1)throw new Error("final must be a single byte");const E=S.final.charCodeAt(0);if(v[0]>E||E>v[1])throw new Error(`final must be in range ${v[0]} .. ${v[1]}`);return _<<=8,_|=E,_}identToString(S){const v=[];for(;S;)v.push(String.fromCharCode(255&S)),S>>=8;return v.reverse().join("")}setPrintHandler(S){this._printHandler=S}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(S,v){const _=this._identifier(S,[48,126]);this._escHandlers[_]===void 0&&(this._escHandlers[_]=[]);const E=this._escHandlers[_];return E.push(v),{dispose:()=>{const j=E.indexOf(v);j!==-1&&E.splice(j,1)}}}clearEscHandler(S){this._escHandlers[this._identifier(S,[48,126])]&&delete this._escHandlers[this._identifier(S,[48,126])]}setEscHandlerFallback(S){this._escHandlerFb=S}setExecuteHandler(S,v){this._executeHandlers[S.charCodeAt(0)]=v}clearExecuteHandler(S){this._executeHandlers[S.charCodeAt(0)]&&delete this._executeHandlers[S.charCodeAt(0)]}setExecuteHandlerFallback(S){this._executeHandlerFb=S}registerCsiHandler(S,v){const _=this._identifier(S);this._csiHandlers[_]===void 0&&(this._csiHandlers[_]=[]);const E=this._csiHandlers[_];return E.push(v),{dispose:()=>{const j=E.indexOf(v);j!==-1&&E.splice(j,1)}}}clearCsiHandler(S){this._csiHandlers[this._identifier(S)]&&delete this._csiHandlers[this._identifier(S)]}setCsiHandlerFallback(S){this._csiHandlerFb=S}registerDcsHandler(S,v){return this._dcsParser.registerHandler(this._identifier(S),v)}clearDcsHandler(S){this._dcsParser.clearHandler(this._identifier(S))}setDcsHandlerFallback(S){this._dcsParser.setHandlerFallback(S)}registerOscHandler(S,v){return this._oscParser.registerHandler(S,v)}clearOscHandler(S){this._oscParser.clearHandler(S)}setOscHandlerFallback(S){this._oscParser.setHandlerFallback(S)}setErrorHandler(S){this._errorHandler=S}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(S,v,_,E,j){this._parseStack.state=S,this._parseStack.handlers=v,this._parseStack.handlerPos=_,this._parseStack.transition=E,this._parseStack.chunkPos=j}parse(S,v,_){let E,j=0,T=0,R=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,R=this._parseStack.chunkPos+1;else{if(_===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");const A=this._parseStack.handlers;let D=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(_===!1&&D>-1){for(;D>=0&&(E=A[D](this._params),E!==!0);D--)if(E instanceof Promise)return this._parseStack.handlerPos=D,E}this._parseStack.handlers=[];break;case 4:if(_===!1&&D>-1){for(;D>=0&&(E=A[D](),E!==!0);D--)if(E instanceof Promise)return this._parseStack.handlerPos=D,E}this._parseStack.handlers=[];break;case 6:if(j=S[this._parseStack.chunkPos],E=this._dcsParser.unhook(j!==24&&j!==26,_),E)return E;j===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(j=S[this._parseStack.chunkPos],E=this._oscParser.end(j!==24&&j!==26,_),E)return E;j===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,R=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=15&this._parseStack.transition}for(let A=R;A<v;++A){switch(j=S[A],T=this._transitions.table[this.currentState<<8|(j<160?j:w)],T>>4){case 2:for(let I=A+1;;++I){if(I>=v||(j=S[I])<32||j>126&&j<w){this._printHandler(S,A,I),A=I-1;break}if(++I>=v||(j=S[I])<32||j>126&&j<w){this._printHandler(S,A,I),A=I-1;break}if(++I>=v||(j=S[I])<32||j>126&&j<w){this._printHandler(S,A,I),A=I-1;break}if(++I>=v||(j=S[I])<32||j>126&&j<w){this._printHandler(S,A,I),A=I-1;break}}break;case 3:this._executeHandlers[j]?this._executeHandlers[j]():this._executeHandlerFb(j),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:A,code:j,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:const D=this._csiHandlers[this._collect<<8|j];let $=D?D.length-1:-1;for(;$>=0&&(E=D[$](this._params),E!==!0);$--)if(E instanceof Promise)return this._preserveStack(3,D,$,T,A),E;$<0&&this._csiHandlerFb(this._collect<<8|j,this._params),this.precedingJoinState=0;break;case 8:do switch(j){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(j-48)}while(++A<v&&(j=S[A])>47&&j<60);A--;break;case 9:this._collect<<=8,this._collect|=j;break;case 10:const q=this._escHandlers[this._collect<<8|j];let G=q?q.length-1:-1;for(;G>=0&&(E=q[G](),E!==!0);G--)if(E instanceof Promise)return this._preserveStack(4,q,G,T,A),E;G<0&&this._escHandlerFb(this._collect<<8|j),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|j,this._params);break;case 13:for(let I=A+1;;++I)if(I>=v||(j=S[I])===24||j===26||j===27||j>127&&j<w){this._dcsParser.put(S,A,I),A=I-1;break}break;case 14:if(E=this._dcsParser.unhook(j!==24&&j!==26),E)return this._preserveStack(6,[],0,T,A),E;j===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 I=A+1;;I++)if(I>=v||(j=S[I])<32||j>127&&j<w){this._oscParser.put(S,A,I),A=I-1;break}break;case 6:if(E=this._oscParser.end(j!==24&&j!==26),E)return this._preserveStack(5,[],0,T,A),E;j===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),p=d(482),m=[];c.OscParser=class{constructor(){this._state=0,this._active=m,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(x,y){this._handlers[x]===void 0&&(this._handlers[x]=[]);const w=this._handlers[x];return w.push(y),{dispose:()=>{const C=w.indexOf(y);C!==-1&&w.splice(C,1)}}}clearHandler(x){this._handlers[x]&&delete this._handlers[x]}setHandlerFallback(x){this._handlerFb=x}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=m}reset(){if(this._state===2)for(let x=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;x>=0;--x)this._active[x].end(!1);this._stack.paused=!1,this._active=m,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||m,this._active.length)for(let x=this._active.length-1;x>=0;x--)this._active[x].start();else this._handlerFb(this._id,"START")}_put(x,y,w){if(this._active.length)for(let C=this._active.length-1;C>=0;C--)this._active[C].put(x,y,w);else this._handlerFb(this._id,"PUT",(0,p.utf32ToString)(x,y,w))}start(){this.reset(),this._state=1}put(x,y,w){if(this._state!==3){if(this._state===1)for(;y<w;){const C=x[y++];if(C===59){this._state=2,this._start();break}if(C<48||57<C)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+C-48}this._state===2&&w-y>0&&this._put(x,y,w)}}end(x,y=!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,b=!1;if(this._stack.paused&&(C=this._stack.loopPosition-1,w=y,b=this._stack.fallThrough,this._stack.paused=!1),!b&&w===!1){for(;C>=0&&(w=this._active[C].end(x),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",x);this._active=m,this._id=-1,this._state=0}}},c.OscHandler=class{constructor(x){this._handler=x,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(x,y,w){this._hitLimit||(this._data+=(0,p.utf32ToString)(x,y,w),this._data.length>f.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(x){let y=!1;if(this._hitLimit)y=!1;else if(x&&(y=this._handler(this._data),y instanceof Promise))return y.then((w=>(this._data="",this._hitLimit=!1,w)));return this._data="",this._hitLimit=!1,y}}},8742:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.Params=void 0;const d=2147483647;class f{static fromArray(m){const x=new f;if(!m.length)return x;for(let y=Array.isArray(m[0])?1:0;y<m.length;++y){const w=m[y];if(Array.isArray(w))for(let C=0;C<w.length;++C)x.addSubParam(w[C]);else x.addParam(w)}return x}constructor(m=32,x=32){if(this.maxLength=m,this.maxSubParamsLength=x,x>256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(m),this.length=0,this._subParams=new Int32Array(x),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(m),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}clone(){const m=new f(this.maxLength,this.maxSubParamsLength);return m.params.set(this.params),m.length=this.length,m._subParams.set(this._subParams),m._subParamsLength=this._subParamsLength,m._subParamsIdx.set(this._subParamsIdx),m._rejectDigits=this._rejectDigits,m._rejectSubDigits=this._rejectSubDigits,m._digitIsSub=this._digitIsSub,m}toArray(){const m=[];for(let x=0;x<this.length;++x){m.push(this.params[x]);const y=this._subParamsIdx[x]>>8,w=255&this._subParamsIdx[x];w-y>0&&m.push(Array.prototype.slice.call(this._subParams,y,w))}return m}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(m){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(m<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=m>d?d:m}}addSubParam(m){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(m<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=m>d?d:m,this._subParamsIdx[this.length-1]++}}hasSubParams(m){return(255&this._subParamsIdx[m])-(this._subParamsIdx[m]>>8)>0}getSubParams(m){const x=this._subParamsIdx[m]>>8,y=255&this._subParamsIdx[m];return y-x>0?this._subParams.subarray(x,y):null}getSubParamsAll(){const m={};for(let x=0;x<this.length;++x){const y=this._subParamsIdx[x]>>8,w=255&this._subParamsIdx[x];w-y>0&&(m[x]=this._subParams.slice(y,w))}return m}addDigit(m){let x;if(this._rejectDigits||!(x=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;const y=this._digitIsSub?this._subParams:this.params,w=y[x-1];y[x-1]=~w?Math.min(10*w+m,d):m}}c.Params=f},5741:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.AddonManager=void 0,c.AddonManager=class{constructor(){this._addons=[]}dispose(){for(let d=this._addons.length-1;d>=0;d--)this._addons[d].instance.dispose()}loadAddon(d,f){const p={instance:f,dispose:f.dispose,isDisposed:!1};this._addons.push(p),f.dispose=()=>this._wrappedAddonDispose(p),f.activate(d)}_wrappedAddonDispose(d){if(d.isDisposed)return;let f=-1;for(let p=0;p<this._addons.length;p++)if(this._addons[p]===d){f=p;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),p=d(511);c.BufferApiView=class{constructor(m,x){this._buffer=m,this.type=x}init(m){return this._buffer=m,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(m){const x=this._buffer.lines.get(m);if(x)return new f.BufferLineApiView(x)}getNullCell(){return new p.CellData}}},3785:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.BufferLineApiView=void 0;const f=d(511);c.BufferLineApiView=class{constructor(p){this._line=p}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(p,m){if(!(p<0||p>=this._line.length))return m?(this._line.loadCell(p,m),m):this._line.loadCell(p,new f.CellData)}translateToString(p,m,x){return this._line.translateToString(p,m,x)}}},8285:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.BufferNamespaceApi=void 0;const f=d(8771),p=d(8460),m=d(844);class x extends m.Disposable{constructor(w){super(),this._core=w,this._onBufferChange=this.register(new p.EventEmitter),this.onBufferChange=this._onBufferChange.event,this._normal=new f.BufferApiView(this._core.buffers.normal,"normal"),this._alternate=new f.BufferApiView(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate((()=>this._onBufferChange.fire(this.active)))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}}c.BufferNamespaceApi=x},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,(p=>f(p.toArray())))}addCsiHandler(d,f){return this.registerCsiHandler(d,f)}registerDcsHandler(d,f){return this._core.registerDcsHandler(d,((p,m)=>f(p,m.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(b,S,v,_){var E,j=arguments.length,T=j<3?S:_===null?_=Object.getOwnPropertyDescriptor(S,v):_;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")T=Reflect.decorate(b,S,v,_);else for(var R=b.length-1;R>=0;R--)(E=b[R])&&(T=(j<3?E(T):j>3?E(S,v,T):E(S,v))||T);return j>3&&T&&Object.defineProperty(S,v,T),T},p=this&&this.__param||function(b,S){return function(v,_){S(v,_,b)}};Object.defineProperty(c,"__esModule",{value:!0}),c.BufferService=c.MINIMUM_ROWS=c.MINIMUM_COLS=void 0;const m=d(8460),x=d(844),y=d(5295),w=d(2585);c.MINIMUM_COLS=2,c.MINIMUM_ROWS=1;let C=c.BufferService=class extends x.Disposable{get buffer(){return this.buffers.active}constructor(b){super(),this.isUserScrolling=!1,this._onResize=this.register(new m.EventEmitter),this.onResize=this._onResize.event,this._onScroll=this.register(new m.EventEmitter),this.onScroll=this._onScroll.event,this.cols=Math.max(b.rawOptions.cols||0,c.MINIMUM_COLS),this.rows=Math.max(b.rawOptions.rows||0,c.MINIMUM_ROWS),this.buffers=this.register(new y.BufferSet(b,this))}resize(b,S){this.cols=b,this.rows=S,this.buffers.resize(b,S),this._onResize.fire({cols:b,rows:S})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(b,S=!1){const v=this.buffer;let _;_=this._cachedBlankLine,_&&_.length===this.cols&&_.getFg(0)===b.fg&&_.getBg(0)===b.bg||(_=v.getBlankLine(b,S),this._cachedBlankLine=_),_.isWrapped=S;const E=v.ybase+v.scrollTop,j=v.ybase+v.scrollBottom;if(v.scrollTop===0){const T=v.lines.isFull;j===v.lines.length-1?T?v.lines.recycle().copyFrom(_):v.lines.push(_.clone()):v.lines.splice(j+1,0,_.clone()),T?this.isUserScrolling&&(v.ydisp=Math.max(v.ydisp-1,0)):(v.ybase++,this.isUserScrolling||v.ydisp++)}else{const T=j-E+1;v.lines.shiftElements(E+1,T-1,-1),v.lines.set(j,_.clone())}this.isUserScrolling||(v.ydisp=v.ybase),this._onScroll.fire(v.ydisp)}scrollLines(b,S,v){const _=this.buffer;if(b<0){if(_.ydisp===0)return;this.isUserScrolling=!0}else b+_.ydisp>=_.ybase&&(this.isUserScrolling=!1);const E=_.ydisp;_.ydisp=Math.max(Math.min(_.ydisp+b,_.ybase),0),E!==_.ydisp&&(S||this._onScroll.fire(_.ydisp))}};c.BufferService=C=f([p(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(_,E,j,T){var R,A=arguments.length,D=A<3?E:T===null?T=Object.getOwnPropertyDescriptor(E,j):T;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")D=Reflect.decorate(_,E,j,T);else for(var $=_.length-1;$>=0;$--)(R=_[$])&&(D=(A<3?R(D):A>3?R(E,j,D):R(E,j))||D);return A>3&&D&&Object.defineProperty(E,j,D),D},p=this&&this.__param||function(_,E){return function(j,T){E(j,T,_)}};Object.defineProperty(c,"__esModule",{value:!0}),c.CoreMouseService=void 0;const m=d(2585),x=d(8460),y=d(844),w={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:_=>_.button!==4&&_.action===1&&(_.ctrl=!1,_.alt=!1,_.shift=!1,!0)},VT200:{events:19,restrict:_=>_.action!==32},DRAG:{events:23,restrict:_=>_.action!==32||_.button!==3},ANY:{events:31,restrict:_=>!0}};function C(_,E){let j=(_.ctrl?16:0)|(_.shift?4:0)|(_.alt?8:0);return _.button===4?(j|=64,j|=_.action):(j|=3&_.button,4&_.button&&(j|=64),8&_.button&&(j|=128),_.action===32?j|=32:_.action!==0||E||(j|=3)),j}const b=String.fromCharCode,S={DEFAULT:_=>{const E=[C(_,!1)+32,_.col+32,_.row+32];return E[0]>255||E[1]>255||E[2]>255?"":`\x1B[M${b(E[0])}${b(E[1])}${b(E[2])}`},SGR:_=>{const E=_.action===0&&_.button!==4?"m":"M";return`\x1B[<${C(_,!0)};${_.col};${_.row}${E}`},SGR_PIXELS:_=>{const E=_.action===0&&_.button!==4?"m":"M";return`\x1B[<${C(_,!0)};${_.x};${_.y}${E}`}};let v=c.CoreMouseService=class extends y.Disposable{constructor(_,E){super(),this._bufferService=_,this._coreService=E,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._onProtocolChange=this.register(new x.EventEmitter),this.onProtocolChange=this._onProtocolChange.event;for(const j of Object.keys(w))this.addProtocol(j,w[j]);for(const j of Object.keys(S))this.addEncoding(j,S[j]);this.reset()}addProtocol(_,E){this._protocols[_]=E}addEncoding(_,E){this._encodings[_]=E}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(_){if(!this._protocols[_])throw new Error(`unknown protocol "${_}"`);this._activeProtocol=_,this._onProtocolChange.fire(this._protocols[_].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(_){if(!this._encodings[_])throw new Error(`unknown encoding "${_}"`);this._activeEncoding=_}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null}triggerMouseEvent(_){if(_.col<0||_.col>=this._bufferService.cols||_.row<0||_.row>=this._bufferService.rows||_.button===4&&_.action===32||_.button===3&&_.action!==32||_.button!==4&&(_.action===2||_.action===3)||(_.col++,_.row++,_.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,_,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(_))return!1;const E=this._encodings[this._activeEncoding](_);return E&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(E):this._coreService.triggerDataEvent(E,!0)),this._lastEvent=_,!0}explainEvents(_){return{down:!!(1&_),up:!!(2&_),drag:!!(4&_),move:!!(8&_),wheel:!!(16&_)}}_equalEvents(_,E,j){if(j){if(_.x!==E.x||_.y!==E.y)return!1}else if(_.col!==E.col||_.row!==E.row)return!1;return _.button===E.button&&_.action===E.action&&_.ctrl===E.ctrl&&_.alt===E.alt&&_.shift===E.shift}};c.CoreMouseService=v=f([p(0,m.IBufferService),p(1,m.ICoreService)],v)},6975:function(u,c,d){var f=this&&this.__decorate||function(v,_,E,j){var T,R=arguments.length,A=R<3?_:j===null?j=Object.getOwnPropertyDescriptor(_,E):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(v,_,E,j);else for(var D=v.length-1;D>=0;D--)(T=v[D])&&(A=(R<3?T(A):R>3?T(_,E,A):T(_,E))||A);return R>3&&A&&Object.defineProperty(_,E,A),A},p=this&&this.__param||function(v,_){return function(E,j){_(E,j,v)}};Object.defineProperty(c,"__esModule",{value:!0}),c.CoreService=void 0;const m=d(1439),x=d(8460),y=d(844),w=d(2585),C=Object.freeze({insertMode:!1}),b=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0});let S=c.CoreService=class extends y.Disposable{constructor(v,_,E){super(),this._bufferService=v,this._logService=_,this._optionsService=E,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this.register(new x.EventEmitter),this.onData=this._onData.event,this._onUserInput=this.register(new x.EventEmitter),this.onUserInput=this._onUserInput.event,this._onBinary=this.register(new x.EventEmitter),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this.register(new x.EventEmitter),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=(0,m.clone)(C),this.decPrivateModes=(0,m.clone)(b)}reset(){this.modes=(0,m.clone)(C),this.decPrivateModes=(0,m.clone)(b)}triggerDataEvent(v,_=!1){if(this._optionsService.rawOptions.disableStdin)return;const E=this._bufferService.buffer;_&&this._optionsService.rawOptions.scrollOnUserInput&&E.ybase!==E.ydisp&&this._onRequestScrollToBottom.fire(),_&&this._onUserInput.fire(),this._logService.debug(`sending data "${v}"`,(()=>v.split("").map((j=>j.charCodeAt(0))))),this._onData.fire(v)}triggerBinaryEvent(v){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${v}"`,(()=>v.split("").map((_=>_.charCodeAt(0))))),this._onBinary.fire(v))}};c.CoreService=S=f([p(0,w.IBufferService),p(1,w.ILogService),p(2,w.IOptionsService)],S)},9074:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.DecorationService=void 0;const f=d(8055),p=d(8460),m=d(844),x=d(6106);let y=0,w=0;class C extends m.Disposable{get decorations(){return this._decorations.values()}constructor(){super(),this._decorations=new x.SortedList((v=>v==null?void 0:v.marker.line)),this._onDecorationRegistered=this.register(new p.EventEmitter),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this.register(new p.EventEmitter),this.onDecorationRemoved=this._onDecorationRemoved.event,this.register((0,m.toDisposable)((()=>this.reset())))}registerDecoration(v){if(v.marker.isDisposed)return;const _=new b(v);if(_){const E=_.marker.onDispose((()=>_.dispose()));_.onDispose((()=>{_&&(this._decorations.delete(_)&&this._onDecorationRemoved.fire(_),E.dispose())})),this._decorations.insert(_),this._onDecorationRegistered.fire(_)}return _}reset(){for(const v of this._decorations.values())v.dispose();this._decorations.clear()}*getDecorationsAtCell(v,_,E){let j=0,T=0;for(const R of this._decorations.getKeyIterator(_))j=R.options.x??0,T=j+(R.options.width??1),v>=j&&v<T&&(!E||(R.options.layer??"bottom")===E)&&(yield R)}forEachDecorationAtCell(v,_,E,j){this._decorations.forEachByKey(_,(T=>{y=T.options.x??0,w=y+(T.options.width??1),v>=y&&v<w&&(!E||(T.options.layer??"bottom")===E)&&j(T)}))}}c.DecorationService=C;class b extends m.Disposable{get isDisposed(){return this._isDisposed}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=f.css.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=f.css.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}constructor(v){super(),this.options=v,this.onRenderEmitter=this.register(new p.EventEmitter),this.onRender=this.onRenderEmitter.event,this._onDispose=this.register(new p.EventEmitter),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=v.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}dispose(){this._onDispose.fire(),super.dispose()}}},4348:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.InstantiationService=c.ServiceCollection=void 0;const f=d(2585),p=d(8343);class m{constructor(...y){this._entries=new Map;for(const[w,C]of y)this.set(w,C)}set(y,w){const C=this._entries.get(y);return this._entries.set(y,w),C}forEach(y){for(const[w,C]of this._entries.entries())y(w,C)}has(y){return this._entries.has(y)}get(y){return this._entries.get(y)}}c.ServiceCollection=m,c.InstantiationService=class{constructor(){this._services=new m,this._services.set(f.IInstantiationService,this)}setService(x,y){this._services.set(x,y)}getService(x){return this._services.get(x)}createInstance(x,...y){const w=(0,p.getServiceDependencies)(x).sort(((S,v)=>S.index-v.index)),C=[];for(const S of w){const v=this._services.get(S.id);if(!v)throw new Error(`[createInstance] ${x.name} depends on UNKNOWN service ${S.id}.`);C.push(v)}const b=w.length>0?w[0].index:y.length;if(y.length!==b)throw new Error(`[createInstance] First service dependency of ${x.name} at position ${b+1} conflicts with ${y.length} static arguments`);return new x(...y,...C)}}},7866:function(u,c,d){var f=this&&this.__decorate||function(b,S,v,_){var E,j=arguments.length,T=j<3?S:_===null?_=Object.getOwnPropertyDescriptor(S,v):_;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")T=Reflect.decorate(b,S,v,_);else for(var R=b.length-1;R>=0;R--)(E=b[R])&&(T=(j<3?E(T):j>3?E(S,v,T):E(S,v))||T);return j>3&&T&&Object.defineProperty(S,v,T),T},p=this&&this.__param||function(b,S){return function(v,_){S(v,_,b)}};Object.defineProperty(c,"__esModule",{value:!0}),c.traceCall=c.setTraceLogger=c.LogService=void 0;const m=d(844),x=d(2585),y={trace:x.LogLevelEnum.TRACE,debug:x.LogLevelEnum.DEBUG,info:x.LogLevelEnum.INFO,warn:x.LogLevelEnum.WARN,error:x.LogLevelEnum.ERROR,off:x.LogLevelEnum.OFF};let w,C=c.LogService=class extends m.Disposable{get logLevel(){return this._logLevel}constructor(b){super(),this._optionsService=b,this._logLevel=x.LogLevelEnum.OFF,this._updateLogLevel(),this.register(this._optionsService.onSpecificOptionChange("logLevel",(()=>this._updateLogLevel()))),w=this}_updateLogLevel(){this._logLevel=y[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(b){for(let S=0;S<b.length;S++)typeof b[S]=="function"&&(b[S]=b[S]())}_log(b,S,v){this._evalLazyOptionalParams(v),b.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+S,...v)}trace(b,...S){var v;this._logLevel<=x.LogLevelEnum.TRACE&&this._log(((v=this._optionsService.options.logger)==null?void 0:v.trace.bind(this._optionsService.options.logger))??console.log,b,S)}debug(b,...S){var v;this._logLevel<=x.LogLevelEnum.DEBUG&&this._log(((v=this._optionsService.options.logger)==null?void 0:v.debug.bind(this._optionsService.options.logger))??console.log,b,S)}info(b,...S){var v;this._logLevel<=x.LogLevelEnum.INFO&&this._log(((v=this._optionsService.options.logger)==null?void 0:v.info.bind(this._optionsService.options.logger))??console.info,b,S)}warn(b,...S){var v;this._logLevel<=x.LogLevelEnum.WARN&&this._log(((v=this._optionsService.options.logger)==null?void 0:v.warn.bind(this._optionsService.options.logger))??console.warn,b,S)}error(b,...S){var v;this._logLevel<=x.LogLevelEnum.ERROR&&this._log(((v=this._optionsService.options.logger)==null?void 0:v.error.bind(this._optionsService.options.logger))??console.error,b,S)}};c.LogService=C=f([p(0,x.IOptionsService)],C),c.setTraceLogger=function(b){w=b},c.traceCall=function(b,S,v){if(typeof v.value!="function")throw new Error("not supported");const _=v.value;v.value=function(...E){if(w.logLevel!==x.LogLevelEnum.TRACE)return _.apply(this,E);w.trace(`GlyphRenderer#${_.name}(${E.map((T=>JSON.stringify(T))).join(", ")})`);const j=_.apply(this,E);return w.trace(`GlyphRenderer#${_.name} return`,j),j}}},7302:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.OptionsService=c.DEFAULT_OPTIONS=void 0;const f=d(8460),p=d(844),m=d(6114);c.DEFAULT_OPTIONS={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"courier-new, courier, monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},rescaleOverlappingGlyphs:!1,rightClickSelectsWord:m.isMac,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRulerWidth:0};const x=["normal","bold","100","200","300","400","500","600","700","800","900"];class y extends p.Disposable{constructor(C){super(),this._onOptionChange=this.register(new f.EventEmitter),this.onOptionChange=this._onOptionChange.event;const b={...c.DEFAULT_OPTIONS};for(const S in C)if(S in b)try{const v=C[S];b[S]=this._sanitizeAndValidateOption(S,v)}catch(v){console.error(v)}this.rawOptions=b,this.options={...b},this._setupOptions(),this.register((0,p.toDisposable)((()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null})))}onSpecificOptionChange(C,b){return this.onOptionChange((S=>{S===C&&b(this.rawOptions[C])}))}onMultipleOptionChange(C,b){return this.onOptionChange((S=>{C.indexOf(S)!==-1&&b()}))}_setupOptions(){const C=S=>{if(!(S in c.DEFAULT_OPTIONS))throw new Error(`No option with key "${S}"`);return this.rawOptions[S]},b=(S,v)=>{if(!(S in c.DEFAULT_OPTIONS))throw new Error(`No option with key "${S}"`);v=this._sanitizeAndValidateOption(S,v),this.rawOptions[S]!==v&&(this.rawOptions[S]=v,this._onOptionChange.fire(S))};for(const S in this.rawOptions){const v={get:C.bind(this,S),set:b.bind(this,S)};Object.defineProperty(this.options,S,v)}}_sanitizeAndValidateOption(C,b){switch(C){case"cursorStyle":if(b||(b=c.DEFAULT_OPTIONS[C]),!(function(S){return S==="block"||S==="underline"||S==="bar"})(b))throw new Error(`"${b}" is not a valid value for ${C}`);break;case"wordSeparator":b||(b=c.DEFAULT_OPTIONS[C]);break;case"fontWeight":case"fontWeightBold":if(typeof b=="number"&&1<=b&&b<=1e3)break;b=x.includes(b)?b:c.DEFAULT_OPTIONS[C];break;case"cursorWidth":b=Math.floor(b);case"lineHeight":case"tabStopWidth":if(b<1)throw new Error(`${C} cannot be less than 1, value: ${b}`);break;case"minimumContrastRatio":b=Math.max(1,Math.min(21,Math.round(10*b)/10));break;case"scrollback":if((b=Math.min(b,4294967295))<0)throw new Error(`${C} cannot be less than 0, value: ${b}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(b<=0)throw new Error(`${C} cannot be less than or equal to 0, value: ${b}`);break;case"rows":case"cols":if(!b&&b!==0)throw new Error(`${C} must be numeric, value: ${b}`);break;case"windowsPty":b=b??{}}return b}}c.OptionsService=y},2660:function(u,c,d){var f=this&&this.__decorate||function(y,w,C,b){var S,v=arguments.length,_=v<3?w:b===null?b=Object.getOwnPropertyDescriptor(w,C):b;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")_=Reflect.decorate(y,w,C,b);else for(var E=y.length-1;E>=0;E--)(S=y[E])&&(_=(v<3?S(_):v>3?S(w,C,_):S(w,C))||_);return v>3&&_&&Object.defineProperty(w,C,_),_},p=this&&this.__param||function(y,w){return function(C,b){w(C,b,y)}};Object.defineProperty(c,"__esModule",{value:!0}),c.OscLinkService=void 0;const m=d(2585);let x=c.OscLinkService=class{constructor(y){this._bufferService=y,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(y){const w=this._bufferService.buffer;if(y.id===void 0){const E=w.addMarker(w.ybase+w.y),j={data:y,id:this._nextId++,lines:[E]};return E.onDispose((()=>this._removeMarkerFromLink(j,E))),this._dataByLinkId.set(j.id,j),j.id}const C=y,b=this._getEntryIdKey(C),S=this._entriesWithId.get(b);if(S)return this.addLineToLink(S.id,w.ybase+w.y),S.id;const v=w.addMarker(w.ybase+w.y),_={id:this._nextId++,key:this._getEntryIdKey(C),data:C,lines:[v]};return v.onDispose((()=>this._removeMarkerFromLink(_,v))),this._entriesWithId.set(_.key,_),this._dataByLinkId.set(_.id,_),_.id}addLineToLink(y,w){const C=this._dataByLinkId.get(y);if(C&&C.lines.every((b=>b.line!==w))){const b=this._bufferService.buffer.addMarker(w);C.lines.push(b),b.onDispose((()=>this._removeMarkerFromLink(C,b)))}}getLinkData(y){var w;return(w=this._dataByLinkId.get(y))==null?void 0:w.data}_getEntryIdKey(y){return`${y.id};;${y.uri}`}_removeMarkerFromLink(y,w){const C=y.lines.indexOf(w);C!==-1&&(y.lines.splice(C,1),y.lines.length===0&&(y.data.id!==void 0&&this._entriesWithId.delete(y.key),this._dataByLinkId.delete(y.id)))}};c.OscLinkService=x=f([p(0,m.IBufferService)],x)},8343:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.createDecorator=c.getServiceDependencies=c.serviceRegistry=void 0;const d="di$target",f="di$dependencies";c.serviceRegistry=new Map,c.getServiceDependencies=function(p){return p[f]||[]},c.createDecorator=function(p){if(c.serviceRegistry.has(p))return c.serviceRegistry.get(p);const m=function(x,y,w){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(C,b,S){b[d]===b?b[f].push({id:C,index:S}):(b[f]=[{id:C,index:S}],b[d]=b)})(m,x,w)};return m.toString=()=>p,c.serviceRegistry.set(p,m),m}},2585:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.IDecorationService=c.IUnicodeService=c.IOscLinkService=c.IOptionsService=c.ILogService=c.LogLevelEnum=c.IInstantiationService=c.ICharsetService=c.ICoreService=c.ICoreMouseService=c.IBufferService=void 0;const f=d(8343);var p;c.IBufferService=(0,f.createDecorator)("BufferService"),c.ICoreMouseService=(0,f.createDecorator)("CoreMouseService"),c.ICoreService=(0,f.createDecorator)("CoreService"),c.ICharsetService=(0,f.createDecorator)("CharsetService"),c.IInstantiationService=(0,f.createDecorator)("InstantiationService"),(function(m){m[m.TRACE=0]="TRACE",m[m.DEBUG=1]="DEBUG",m[m.INFO=2]="INFO",m[m.WARN=3]="WARN",m[m.ERROR=4]="ERROR",m[m.OFF=5]="OFF"})(p||(c.LogLevelEnum=p={})),c.ILogService=(0,f.createDecorator)("LogService"),c.IOptionsService=(0,f.createDecorator)("OptionsService"),c.IOscLinkService=(0,f.createDecorator)("OscLinkService"),c.IUnicodeService=(0,f.createDecorator)("UnicodeService"),c.IDecorationService=(0,f.createDecorator)("DecorationService")},1480:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.UnicodeService=void 0;const f=d(8460),p=d(225);class m{static extractShouldJoin(y){return(1&y)!=0}static extractWidth(y){return y>>1&3}static extractCharKind(y){return y>>3}static createPropertyValue(y,w,C=!1){return(16777215&y)<<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 y=new p.UnicodeV6;this.register(y),this._active=y.version,this._activeProvider=y}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(y){if(!this._providers[y])throw new Error(`unknown Unicode version "${y}"`);this._active=y,this._activeProvider=this._providers[y],this._onChange.fire(y)}register(y){this._providers[y.version]=y}wcwidth(y){return this._activeProvider.wcwidth(y)}getStringCellWidth(y){let w=0,C=0;const b=y.length;for(let S=0;S<b;++S){let v=y.charCodeAt(S);if(55296<=v&&v<=56319){if(++S>=b)return w+this.wcwidth(v);const j=y.charCodeAt(S);56320<=j&&j<=57343?v=1024*(v-55296)+j-56320+65536:w+=this.wcwidth(j)}const _=this.charProperties(v,C);let E=m.extractWidth(_);m.extractShouldJoin(_)&&(E-=m.extractWidth(C)),w+=E,C=_}return w}charProperties(y,w){return this._activeProvider.charProperties(y,w)}}c.UnicodeService=m}},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),p=a(5741),m=a(8285),x=a(7975),y=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 p.AddonManager),this._publicOptions={...this._core.options};const v=E=>this._core.options[E],_=(E,j)=>{this._checkReadonlyOptions(E),this._core.options[E]=j};for(const E in this._core.options){const j={get:v.bind(this,E),set:_.bind(this,E)};Object.defineProperty(this._publicOptions,E,j)}}_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 x.ParserApi(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new y.UnicodeApi(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this.register(new m.BufferNamespaceApi(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){const S=this._core.coreService.decPrivateModes;let v="none";switch(this._core.coreMouseService.activeProtocol){case"X10":v="x10";break;case"VT200":v="vt200";break;case"DRAG":v="drag";break;case"ANY":v="any"}return{applicationCursorKeysMode:S.applicationCursorKeys,applicationKeypadMode:S.applicationKeypad,bracketedPasteMode:S.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:v,originMode:S.origin,reverseWraparoundMode:S.reverseWraparound,sendFocusMode:S.sendFocus,wraparoundMode:S.wraparound}}get options(){return this._publicOptions}set options(S){for(const v in S)this._publicOptions[v]=S[v]}blur(){this._core.blur()}focus(){this._core.focus()}input(S,v=!0){this._core.input(S,v)}resize(S,v){this._verifyIntegers(S,v),this._core.resize(S,v)}open(S){this._core.open(S)}attachCustomKeyEventHandler(S){this._core.attachCustomKeyEventHandler(S)}attachCustomWheelEventHandler(S){this._core.attachCustomWheelEventHandler(S)}registerLinkProvider(S){return this._core.registerLinkProvider(S)}registerCharacterJoiner(S){return this._checkProposedApi(),this._core.registerCharacterJoiner(S)}deregisterCharacterJoiner(S){this._checkProposedApi(),this._core.deregisterCharacterJoiner(S)}registerMarker(S=0){return this._verifyIntegers(S),this._core.registerMarker(S)}registerDecoration(S){return this._checkProposedApi(),this._verifyPositiveIntegers(S.x??0,S.width??0,S.height??0),this._core.registerDecoration(S)}hasSelection(){return this._core.hasSelection()}select(S,v,_){this._verifyIntegers(S,v,_),this._core.select(S,v,_)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(S,v){this._verifyIntegers(S,v),this._core.selectLines(S,v)}dispose(){super.dispose()}scrollLines(S){this._verifyIntegers(S),this._core.scrollLines(S)}scrollPages(S){this._verifyIntegers(S),this._core.scrollPages(S)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(S){this._verifyIntegers(S),this._core.scrollToLine(S)}clear(){this._core.clear()}write(S,v){this._core.write(S,v)}writeln(S,v){this._core.write(S),this._core.write(`\r
|
|
68
|
+
`,v)}paste(S){this._core.paste(S)}refresh(S,v){this._verifyIntegers(S,v),this._core.refresh(S,v)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(S){this._addonManager.loadAddon(this,S)}static get strings(){return c}_verifyIntegers(...S){for(const v of S)if(v===1/0||isNaN(v)||v%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...S){for(const v of S)if(v&&(v===1/0||isNaN(v)||v%1!=0||v<0))throw new Error("This API only accepts positive integers")}}u.Terminal=C})(),l})()))})(Xf)),Xf.exports}var PN=MN();/**
|
|
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 BN=2,zN=1,$N=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 x;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:((x=this._terminal.options.overviewRuler)==null?void 0:x.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,p=a-d,m=l-f-n;return{cols:Math.max(BN,Math.floor(m/t.css.cell.width)),rows:Math.max(zN,Math.floor(p/t.css.cell.height))}}};function HN({sessionId:e,onClose:t,onEscape:n,autoFocus:s}){const a=L.useRef(null),l=L.useRef(e),u=L.useRef(null),c=L.useRef(null),d=_r(p=>p.writeSession),f=_r(p=>p.resizeSession);return L.useEffect(()=>{l.current=e},[e]),L.useEffect(()=>{if(!n)return;const p=m=>{m.key==="Escape"&&(m.preventDefault(),m.stopPropagation(),n())};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[n]),L.useEffect(()=>{if(!a.current)return;const p=new PN.Terminal({fontFamily:'"JetBrains Mono", monospace',fontSize:13,theme:{background:"#1a1a1a",foreground:"#e0e0e0",cursor:"#ffffff",cursorAccent:"#1a1a1a"},cursorBlink:!0,cursorStyle:"bar",convertEol:!0}),m=new $N;p.loadAddon(m),u.current={term:p,fitAddon:m},a.current.addEventListener("keydown",C=>{C.key==="Escape"&&n&&(C.preventDefault(),C.stopPropagation(),n())}),p.open(a.current);const x=a.current.querySelector(".xterm");x&&(x.style.padding="8px"),m.fit(),s&&setTimeout(()=>{p.focus()},150);const y=new ResizeObserver(()=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{requestAnimationFrame(()=>{var b;m.fit&&m.fit();const C=(b=u.current)==null?void 0:b.term;C&&C.cols>0&&C.rows>0&&f(l.current,C.cols,C.rows)})},100)});y.observe(a.current),p.onData(C=>{if(C==="\x1B"&&n){n();return}d(l.current,C)}),p.onKey(C=>{C.key==="\x1B"&&n&&(C.domEvent.stopPropagation(),n())});const w=Ut.subscribe(C=>{const b=C.payload;if(C.type==="terminal.output"&&(b==null?void 0:b.sessionId)===l.current){const S=b==null?void 0:b.data;S&&p.write(S)}});return()=>{w(),y.disconnect(),c.current&&clearTimeout(c.current),p.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(IS,{})})]}),o.jsx("div",{ref:a,className:"flex-1 relative overflow-hidden",tabIndex:0,onKeyDown:p=>{p.key==="Escape"&&n&&(p.preventDefault(),p.stopPropagation(),n())}})]})}const YS="openfox-chat-textarea";function Um(){const e=document.getElementById(YS);e&&e.focus()}function UN(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 FN({isOpen:e,onClose:t}){const n=_r(w=>w.createSession),s=_r(w=>w.killSession),a=_r(w=>w.sessions),l=_r(w=>w.setWorkdir),u=_r(w=>w.fetchSessions),c=Rt(w=>w.currentProject),[d,f]=L.useState(!0),p=L.useRef(null),m=L.useRef(!1),x=L.useRef(!1),y=L.useCallback(()=>{t()},[t]);return L.useEffect(()=>{c!=null&&c.workdir&&l(c.workdir)},[c==null?void 0:c.workdir,l]),L.useEffect(()=>{e?(f(!0),u(c==null?void 0:c.id).finally(()=>f(!1))):Um()},[e,u,c==null?void 0:c.id]),L.useEffect(()=>{e&&a.length===0&&!d&&!x.current&&(x.current=!0,n(void 0,c==null?void 0:c.id))},[e,a.length,d,n,c==null?void 0:c.id]),L.useEffect(()=>{e?(m.current=!0,setTimeout(()=>{var w;(w=p.current)==null||w.focus(),setTimeout(()=>{m.current=!1},200)},100)):x.current=!1},[e]),L.useEffect(()=>{if(!e)return;const w=C=>{m.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:y}),o.jsxs("div",{ref:p,tabIndex:-1,className:"fixed inset-x-0 top-0 z-[100] h-[50vh] bg-bg-primary border-b border-border flex flex-col animate-slide-down outline-none",onClick:w=>w.stopPropagation(),onKeyDown:w=>{w.key==="Escape"&&(w.preventDefault(),y())},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(Yj,{})}),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(qa,{})})]})]}),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 ${UN(a.length)} gap-2 h-full auto-rows-fr`,children:a.map(w=>o.jsx(HN,{sessionId:w.id,onClose:()=>s(w.id),onEscape:y,autoFocus:a.length===1},w.id))})})]})]}):null}function Nl({items:e,footerItems:t=[],trigger:n,minWidth:s="120px",isOpen:a,onOpenChange:l}){const[u,c]=L.useState(!1),d=a!==void 0,f=d?a:u,p=I=>{if(d){const U=typeof I=="function"?I(u):I;l==null||l(U)}else c(I)},[m,x]=L.useState(null),y=L.useRef(null),w=L.useRef(null),[C,b]=L.useState(0),S=L.useRef(0),v=L.useMemo(()=>[...e,...t],[e,t]),_=L.useRef(v),E=L.useCallback(()=>{if(!y.current)return;const I=y.current.getBoundingClientRect(),U=200,z=window.innerHeight-I.bottom<U;x({top:z?I.top-U-4:I.bottom+4,left:I.left,alignToTop:z})},[]);L.useEffect(()=>{_.current=v},[v]),L.useEffect(()=>{function I(U){if(w.current){const V=U.target;w.current.contains(V)||p(!1)}}return f&&document.addEventListener("mousedown",I),()=>{document.removeEventListener("mousedown",I)}},[f]),L.useEffect(()=>{f&&E()},[f,E]),L.useEffect(()=>{if(!f)return;setTimeout(()=>{var U;(U=w.current)==null||U.focus()},0);function I(U){const V=_.current,z=V.filter(Z=>!j(Z)),J=T(S.current,V);switch(U.key){case"ArrowDown":if(U.preventDefault(),U.stopPropagation(),J<z.length-1){const Z=R(S.current+1,V);S.current=Z,b(Z)}break;case"ArrowUp":if(U.preventDefault(),U.stopPropagation(),J>0){const Z=A(S.current-1,V);S.current=Z,b(Z)}break;case"Enter":U.preventDefault(),U.stopPropagation(),D(S.current,V);break;case"Escape":U.preventDefault(),U.stopPropagation(),p(!1);break}}return window.addEventListener("keydown",I,!0),()=>window.removeEventListener("keydown",I,!0)},[f,v]);function j(I){var z;const U=I.label;return U?String(((z=U.props)==null?void 0:z.className)??"").includes("cursor-default"):!1}function T(I,U){let V=0;for(let z=0;z<I;z++){const J=U[z];J&&!j(J)&&V++}return V}function R(I,U){for(let V=I;V<U.length;V++){const z=U[V];if(z&&!j(z))return V}return I}function A(I,U){for(let V=I;V>=0;V--){const z=U[V];if(z&&!j(z))return V}return I}function D(I,U){var z;const V=U[I];!V||j(V)||((z=V.onClick)==null||z.call(V),V.href&&(window.history.pushState(null,"",V.href),window.dispatchEvent(new PopStateEvent("popstate"))),p(!1))}L.useEffect(()=>{f&&(b(v.findIndex(I=>!j(I))),S.current=v.findIndex(I=>!j(I)))},[f,v]);const $=I=>{I.stopPropagation(),f||E(),p(!f)};function q(I,U,V,z){const Z=!j(I)&&z===C,H=o.jsxs(o.Fragment,{children:[I.icon&&o.jsx("span",{className:"w-4 h-4 flex-shrink-0",children:I.icon}),I.label]}),O=U!==V-1;return I.href?o.jsx(qn,{href:I.href,onClick:B=>{var W;(W=I.onClick)==null||W.call(I,B),p(!1)},onAuxClick:()=>p(!1),className:`w-full px-3 py-2 text-left text-sm flex items-center gap-2 transition-colors ${I.danger?"text-accent-error hover:bg-accent-error/10":Z?"bg-accent-primary/20 text-text-primary":"hover:bg-bg-tertiary text-text-primary"} ${O?"border-b border-border":""}`,children:H},z):o.jsx("button",{onClick:B=>{var W;(W=I.onClick)==null||W.call(I,B),I.closeOnClick!==!1&&p(!1)},className:`w-full px-3 py-2 text-left text-sm flex items-center gap-2 transition-colors ${I.danger?"text-accent-error hover:bg-accent-error/10":Z?"bg-accent-primary/20 text-text-primary":"hover:bg-bg-tertiary text-text-primary"} ${O?"border-b border-border":""}`,children:H},z)}const G=m&&o.jsxs("div",{ref:w,"data-testid":"session-dropdown-menu",className:`fixed bg-bg-secondary border border-border rounded shadow-lg z-50 ${m.alignToTop?"mb-1":"mt-1"}`,style:{top:m.top,left:m.left,minWidth:s},tabIndex:-1,children:[o.jsx("div",{className:"max-h-[60vh] overflow-y-auto",children:e.map((I,U)=>q(I,U,e.length,U))}),t.length>0&&o.jsx("div",{className:"border-t border-border",children:t.map((I,U)=>q(I,U,t.length,e.length+U))})]});return o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"relative",children:o.jsx("div",{ref:y,onClick:$,children:n})}),f&&Ka.createPortal(G,document.body)]})}function VN(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 XS({isOpen:e,onClose:t,path:n,onRetry:s}){const[a,l]=L.useState(!1),[u,c]=L.useState(null),[d,f]=L.useState(null);L.useEffect(()=>{e&&p()},[e]);const p=async()=>{try{const E=await(await Te("/api/projects/check-permissions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n})})).json();f({sudoAvailable:E.sudoAvailable,userInGroup:E.userInGroup,groupHasWrite:E.groupHasWrite,groupName:E.groupName||null})}catch{f({sudoAvailable:!1,userInGroup:!1,groupHasWrite:!1,groupName:null})}},m=L.useCallback(async _=>{l(!0),c(null);try{const j=await(await Te("/api/projects/fix-permissions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n,action:_})})).json();j.success?(s(),t()):j.sudoAvailable?c("Failed to fix permissions: "+(j.error||"Unknown error")):c(`Passwordless sudo is not available. Please fix permissions manually:
|
|
80
|
+
|
|
81
|
+
`+(_==="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]),x=(d==null?void 0:d.userInGroup)??!1,y=(d==null?void 0:d.groupHasWrite)??!1,w=(d==null?void 0:d.sudoAvailable)??!1,C=(d==null?void 0:d.groupName)??"",b=x&&!y,S=!x&&y,v=!x&&!y;return o.jsx(jt,{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:b?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:[b&&o.jsxs(o.Fragment,{children:[o.jsx(Ve,{type:"button",variant:"primary",onClick:()=>m("group"),disabled:a||!w,className:"w-full",children:a?"Granting access...":"Extend group permissions"}),o.jsx("div",{className:"text-xs text-text-secondary",children:"Or manually execute:"}),o.jsxs("code",{className:"text-xs text-text-muted p-2 bg-bg-tertiary rounded break-all",children:['sudo chmod g+w "',n,'"']})]}),S&&o.jsxs(o.Fragment,{children:[o.jsx(Ve,{type:"button",variant:"primary",onClick:()=>m("join_group"),disabled:a||!w,className:"w-full",children:a?"Joining group...":"Join group"}),o.jsx("div",{className:"text-xs text-text-secondary",children:"Or manually execute:"}),o.jsxs("code",{className:"text-xs text-text-muted p-2 bg-bg-tertiary rounded break-all",children:["sudo usermod -aG ",C," $USER"]})]}),v&&o.jsxs(o.Fragment,{children:[o.jsx(Ve,{type:"button",variant:"primary",onClick:()=>m("join_group_and_group"),disabled:a||!w,className:"w-full",children:a?"Joining group...":"Join group & grant write permissions"}),o.jsx("div",{className:"text-xs text-text-secondary",children:"Or manually execute:"}),o.jsxs("code",{className:"text-xs text-text-muted p-2 bg-bg-tertiary rounded break-all",children:["sudo usermod -aG ",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(Ve,{type:"button",variant:"secondary",onClick:t,disabled:a,children:"Cancel"})})]}):null]})})}function QS({isOpen:e,onClose:t}){const[,n]=Yn(),s=Rt(j=>j.listProjects),[a,l]=L.useState(""),[u,c]=L.useState(null),[d,f]=L.useState(!1),[p,m]=L.useState(""),[x,y]=L.useState(null),w=L.useRef(null);L.useEffect(()=>{e&&(Te("/api/config").then(j=>j.json()).then(j=>{j.workdir&&m(j.workdir)}),l(""),c(null),f(!1),y(null),setTimeout(()=>{var j;(j=w.current)==null||j.focus()},100))},[e]);const C=L.useCallback(async j=>{j.preventDefault();const T=VN(a);if(!T.valid){c(T.error);return}const R=`${p}/${a}`;await v(R)},[a,n,t,p]),b=L.useCallback(()=>{y(null)},[]),S=L.useCallback(async()=>{const j=`${p}/${a}`;await v(j)},[p,a,n,t,y,c,f]);async function v(j){f(!0),c(null),y(null);try{const T=await Te("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:a,workdir:j})});if(!T.ok){const D=await T.json().catch(()=>({}));if(D.code==="EACCES"){y(j),f(!1);return}throw new Error(D.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 _=L.useCallback(()=>{l(""),c(null),t()},[t]),E=a?`${p}/${a}`:"";return o.jsxs(o.Fragment,{children:[o.jsx(jt,{isOpen:e,onClose:_,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(Ni,{ref:w,id:"project-name",value:a,onChange:j=>{l(j.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(Ve,{type:"button",variant:"secondary",onClick:_,disabled:d,children:"Cancel"}),o.jsx(Ve,{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(qs,{className:"h-4 w-4"}),"Creating..."]}):"Create"})]})]})}),x&&o.jsx(XS,{isOpen:!!x,onClose:b,path:x,onRetry:S})]})}function JS(){const[e,t]=L.useState(null);return L.useEffect(()=>{Te("/api/config").then(n=>n.json()).then(n=>{n.workdir&&t(n.workdir)})},[]),e}function tv({projects:e,currentProject:t}){const[,n]=Yn(),s=Rt(b=>b.loadProject),a=Rt(b=>b.toggleStar),l=Rt(b=>b.createProject),u=Rt(b=>b.listProjects),[c,d]=L.useState(!1),[f,p]=L.useState(!1),m=JS(),x=L.useCallback(async b=>{const S=b.split("/").filter(Boolean).pop()??"",v=await l(S,b);return v&&"id"in v?(await u(),p(!1),n(`/p/${v.id}`),!0):!1},[l,u,n]),w=L.useMemo(()=>{const b=e.filter(v=>v.isStarred).sort((v,_)=>v.name.localeCompare(_.name)),S=e.filter(v=>!v.isStarred).sort((v,_)=>v.name.localeCompare(_.name));return[...b,...S]},[e]).map(b=>({label:o.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[o.jsx("span",{className:"truncate flex-1",children:b.name}),o.jsx("button",{onClick:S=>{S.stopPropagation(),S.preventDefault(),S.nativeEvent.stopImmediatePropagation(),a(b.id,!b.isStarred)},className:"flex-shrink-0 p-1 hover:bg-bg-tertiary rounded transition-colors",title:b.isStarred?"Unstar project":"Star project",children:b.isStarred?o.jsx(RS,{className:"w-3.5 h-3.5 text-yellow-500"}):o.jsx(DS,{className:"w-3.5 h-3.5 text-text-muted hover:text-yellow-500"})})]}),icon:b.id===(t==null?void 0:t.id)?o.jsx(Mr,{}):void 0,href:`/p/${b.id}`,closeOnClick:!0,onClick:()=>{s(b.id)}})),C=[{label:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(El,{className:"w-4 h-4"}),o.jsx("span",{children:"Open Project"})]}),onClick:()=>p(!0)},{label:o.jsxs("div",{className:"flex items-center gap-2 text-accent-primary",children:[o.jsx(qs,{className:"w-4 h-4"}),o.jsx("span",{children:"New Project"})]}),onClick:()=>d(!0)}];return o.jsxs(o.Fragment,{children:[o.jsx(Nl,{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(On,{})]}),minWidth:"250px"}),c&&o.jsx(QS,{isOpen:c,onClose:()=>d(!1)}),f&&o.jsx(Zu,{initialPath:m??void 0,onSelect:x,onClose:()=>p(!1)})]})}function ZS(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 ed(e){const t=new Date(e),n=String(t.getHours()).padStart(2,"0"),s=String(t.getMinutes()).padStart(2,"0");return`${n}:${s}`}function GN(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=ed(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 e1(e){const t=new Date(e);return{year:t.getFullYear(),month:String(t.getMonth()+1).padStart(2,"0"),day:String(t.getDate()).padStart(2,"0")}}function WN(e){const{year:t,month:n,day:s}=e1(e);return`${t}-${n}-${s}`}function t1(e){const t=new Map;for(const a of e){const l=WN(a.updatedAt);t.has(l)||t.set(l,[]),t.get(l).push(a)}for(const[a,l]of t)l.sort((u,c)=>{const 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 qN({sessions:e,currentProject:t,currentSession:n,isOpen:s,onOpenChange:a}){var p;const l=De(m=>m.loadSession),u=e.filter(m=>m.projectId===t.id).slice(0,15),c=t1(u),d=L.useMemo(()=>{const m=[];m.push({label:o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(qs,{className:"w-4 h-4 text-accent-primary"}),o.jsx("span",{className:"text-sm",children:"New session"})]}),href:`/p/${t.id}/new`,onClick:()=>{}});for(const[x,y]of c){const w=y[0];if(w){m.push({label:o.jsx("div",{className:"px-3 py-2 text-text-muted text-xs font-medium cursor-default",children:ZS(w.updatedAt)}),onClick:()=>{}});for(const C of y)m.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:ed(C.updatedAt)})]}),icon:C.id===(n==null?void 0:n.id)?o.jsx(Mr,{}):void 0,href:`/p/${t.id}/s/${C.id}`,onClick:()=>{l(C.id)}})}}return m},[t.id,c,n==null?void 0:n.id]),f=n?((p=n.metadata)==null?void 0:p.title)??n.id.slice(0,8):"No session selected";return o.jsx(Nl,{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(On,{})]}),minWidth:"280px"})}function KN({items:e,trigger:t,isActive:n=!1}){const[s,a]=L.useState(!1),l=L.useRef(null);return L.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(On,{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 YN({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(qs,{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(Mr,{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(zj,{className:"w-3 h-3"}),o.jsx("span",{className:"text-sm",children:"Projects"})]})}];return o.jsx(KN,{items:l,trigger:o.jsx("span",{className:"text-sm text-text-secondary font-medium",children:e.name})})}function XN({onMenuClick:e,onCriteriaToggle:t}){const[n,s]=L.useState(!1),[a,l]=L.useState(!1),[u,c]=L.useState(!!document.fullscreenElement),[d,f]=Yn();L.useEffect(()=>{const j=()=>c(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",j),()=>document.removeEventListener("fullscreenchange",j)},[]);const p=d.startsWith("/p/"),m=/^\/p\/[^/]+\/s\/[^/]+$/.test(d),x=De(j=>j.currentSession),y=De(j=>j.sessions),w=Rt(j=>j.currentProject),C=Rt(j=>j.projects),b=nn(j=>j.startAutoRefresh),S=nn(j=>j.stopAutoRefresh),v=_r(j=>j.setOpen),_=_r(j=>j.isOpen);L.useEffect(()=>{const j=()=>l(!0);return window.addEventListener("open-session-dropdown",j),()=>window.removeEventListener("open-session-dropdown",j)},[]);const E=jp();return zS(E.terminalToggle,()=>{_r.getState().toggleOpen()},{capture:!0}),L.useEffect(()=>(b(),()=>S()),[b,S]),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&&m&&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(Vb,{})}),o.jsx(qn,{href:"/",className:"text-accent-primary font-semibold text-sm hover:underline flex-shrink-0 hidden md:inline",children:"OpenFox"}),w&&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(tv,{projects:C,currentProject:w})}),o.jsx("span",{className:"md:hidden",children:o.jsx(YN,{currentProject:w,sessions:y,currentSession:x,projectIdFromUrl:p&&d.split("/")[2]||null},w==null?void 0:w.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(qN,{sessions:y,currentProject:w,currentSession:x,isOpen:a,onOpenChange:l})})]}),!w&&o.jsx("span",{className:"hidden md:inline",children:o.jsx(tv,{projects:C})})]}),o.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[m&&o.jsx("button",{onClick:()=>{var j,T,R;document.fullscreenElement?(j=document.exitFullscreen)==null||j.call(document):(R=(T=document.documentElement).requestFullscreen)==null||R.call(T)},className:"max-sm:block hidden p-2 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:u?"Exit fullscreen":"Enter fullscreen",children:u?o.jsx(Fj,{}):o.jsx(Vj,{})}),p&&o.jsx("button",{onClick:()=>v(!_),className:`p-2.5 rounded hover:bg-bg-tertiary transition-colors ${_?"text-accent-primary":"text-text-muted hover:text-text-primary"}`,title:"Toggle terminal (double Ctrl)",children:o.jsx(Zj,{})}),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(Xj,{})}),o.jsx("button",{onClick:()=>{localStorage.removeItem("openfox_token"),f("/")},className:"p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Logout",children:o.jsx(Wj,{})}),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(Vb,{})})]}),o.jsx(IN,{isOpen:n,onClose:()=>s(!1)}),o.jsx(FN,{isOpen:_,onClose:()=>v(!1)})]})}function QN({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(Ve,{variant:"secondary",onClick:e,children:a}),o.jsx(Ve,{variant:"primary",onClick:t,disabled:s??n,children:l})]})}function JN({isOpen:e,onClose:t,project:n}){const s=Rt(E=>E.updateProject),a=()=>{try{Ut.send("context.checkDynamic",{})}catch{}t()},[l,u]=L.useState(n.customInstructions??""),[c,d]=L.useState(n.dangerLevel??""),[f,p]=L.useState(!1),[m,x]=L.useState(!1),[y,w]=L.useState(!1),C=f||m;L.useEffect(()=>{u(n.customInstructions??""),d(n.dangerLevel??""),p(!1),x(!1)},[n]);const b=E=>{u(E.target.value),p(!0)},S=E=>{d(E),x(!0)},v=async()=>{w(!0);const E=c===""?null:c;await s(n.id,{customInstructions:l||null,dangerLevel:E}),w(!1),p(!1),x(!1),a()},_=()=>{u(n.customInstructions??""),d(n.dangerLevel??""),p(!1),x(!1),a()};return o.jsx(jt,{isOpen:e,onClose:_,title:`${n.name} Settings`,size:"lg",footer:o.jsx(QN,{onCancel:_,onSave:v,saving:y,saveDisabled:!C||y}),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:b,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:y})]})]})})}const ZN={sm:"w-3 h-3",md:"w-4 h-4",lg:"w-5 h-5",xl:"w-6 h-6"},eT="M6 18L18 6M6 6l12 12";function Tl({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(Xu,{onClick:e,icon:eT,iconSize:ZN[n],className:`${a} ${t}`,title:"Close"})}function n1({projectId:e,isOpen:t=!0,onClose:n}){const[,s]=Yn(),[a,l]=L.useState(!1),u=De(j=>j.sessions),c=De(j=>j.currentSession),d=De(j=>j.unreadSessionIds),f=De(j=>j.deleteSession),p=De(j=>j.deleteAllSessions),m=De(j=>j.loadMoreSessions),x=De(j=>j.sessionsHasMore),y=De(j=>j.sessionsPaginationLoading),w=Rt(j=>j.currentProject),C=L.useRef(null),b=L.useCallback(()=>{x&&!y&&w&&m(w.id)},[x,y,w,m]);L.useEffect(()=>{if(!C.current||!x)return;const j=new IntersectionObserver(T=>{const R=T[0];R&&R.isIntersecting&&b()},{threshold:.1});return j.observe(C.current),()=>j.disconnect()},[x,b]);const S=u.filter(j=>j.projectId===(w==null?void 0:w.id)),v=(j,T)=>{T==null||T.stopPropagation(),confirm("Delete this session?")&&(f(j),(c==null?void 0:c.id)===j&&s(`/p/${e}`))},_=(j,T)=>{T==null||T.stopPropagation();const R=u.find($=>$.id===j),A=(R==null?void 0:R.title)??j.slice(0,6),D=prompt("Rename session:",A);if(D!==null&&D.trim()!==""){const $=De.getState().renameSession;$(j,D.trim())}},E=()=>{confirm("Delete all sessions in this project? This cannot be undone.")&&(p(e),s(`/p/${e}`))};return o.jsxs(o.Fragment,{children:[t&&n&&o.jsx("div",{className:"md:hidden fixed inset-0 bg-black/50 z-40",onClick:n}),o.jsxs("aside",{className:`
|
|
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(Nl,{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(kp,{})})}),n&&o.jsx(Tl,{onClick:n,className:"md:hidden",variant:"sidebar",size:"md"})]}),w&&o.jsx(JN,{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:tT(S,c,d,v,_,e)}),y&&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 tT(e,t,n,s,a,l){const u=t1(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:ZS(f.updatedAt)}),d.map(p=>{const m=(t==null?void 0:t.id)===p.id,x=n.includes(p.id),y=p.isRunning;return o.jsx("div",{className:`w-full px-4 py-3 text-left hover:bg-bg-tertiary/50 transition-colors group ${m?"bg-bg-tertiary":""}`,children:o.jsxs(qn,{href:`/p/${l}/s/${p.id}`,className:`block ${m?"text-accent-primary":"text-text-primary"} hover:text-accent-primary`,children:[o.jsxs("div",{className:"flex justify-between items-center mb-1",children:[o.jsx("span",{className:`font-medium truncate text-sm ${m?"text-accent-primary":"text-text-primary"}`,children:p.title??p.id.slice(0,6)}),o.jsx(Nl,{items:[{label:"Rename session",onClick:w=>a(p.id,w)},{label:"Delete session",onClick:w=>s(p.id,w),danger:!0}],trigger:o.jsx("button",{onClick:w=>w.preventDefault(),className:"p-1.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-all",title:"Options",children:o.jsx(kp,{})})})]}),o.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[y?o.jsx(Qj,{}):x&&!m?o.jsx("span",{"aria-label":"Unread activity",title:"Unread activity",className:"w-2 h-2 rounded-full bg-amber-400 flex-shrink-0"}):null,o.jsx("span",{className:"text-text-muted text-xs flex-shrink-0",children:ed(p.updatedAt)}),o.jsxs("span",{className:"text-text-muted text-xs flex-shrink-0",children:[p.messageCount," messages"]})]})]})},p.id)})]},c):null})}const nv=["⠋","⠙","⠹","⠸","⠼","⠴"];function nT(){var c;const e=Rt(d=>d.currentProject),t=De(d=>d.currentSession),n=Yu(),s=!1,a=L.useRef(0),l=L.useRef(null);L.useEffect(()=>(n?(l.current=window.setInterval(()=>{a.current=(a.current+1)%nv.length,u()},150),u()):(l.current&&(clearInterval(l.current),l.current=null),u()),()=>{l.current&&(clearInterval(l.current),l.current=null)}),[n,e,t,s]);const u=()=>{var m;const f=(m=t==null?void 0:t.metadata)==null?void 0:m.title,p=n?`${nv[a.current]} `:"";e&&f?document.title=`${p}${e.name} - ${f} | OpenFox`:e?document.title=`${p}${e.name} | OpenFox`:document.title=`${p}OpenFox`};return typeof window<"u"&&((c=t==null?void 0:t.metadata)!=null&&c.title)&&window.document.documentElement.setAttribute("data-session-title",t.metadata.title),null}function r1(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 s1({isOpen:e,onClose:t,projectName:n,onConfirm:s}){const a=()=>{s(),t()};return o.jsx(jt,{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(Ve,{variant:"secondary",onClick:t,children:"Cancel"}),o.jsx(Ve,{variant:"danger",onClick:a,children:"Delete"})]})]})})}function rT({isOpen:e,onClose:t}){const[,n]=Yn(),[s,a]=L.useState(!1),l=JS(),[u,c]=L.useState(!1),d=Rt(A=>A.projects),f=Rt(A=>A.createProject),p=Rt(A=>A.listProjects),m=Rt(A=>A.deleteProject),[x,y]=L.useState(null),[w,C]=L.useState(null);L.useEffect(()=>{e&&p()},[e,p]);const b=A=>{n(`/p/${A}`),t()},S=(A,D)=>{D.stopPropagation(),y(A)},v=()=>{x&&(m(x.id),y(null))},_=async A=>j(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 j(A){const D=A.split("/").filter(Boolean).pop()??"",$=await f(D,A);return p(),E($)?(C($.error.path||A),!1):$&&"id"in $?(n(`/p/${$.id}`),t(),!0):!1}const T=L.useCallback(()=>{C(null)},[]),R=L.useCallback(async()=>{const A=w;C(null),A&&await j(A)},[w]);return e?o.jsxs(jt,{isOpen:e,onClose:t,title:"Open Project",size:"xl",footer:o.jsx("div",{className:"flex justify-end gap-2",children:o.jsx(Ve,{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:()=>b(A.id),className:"flex-1 flex items-center gap-3 text-left",children:[o.jsx(El,{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:r1(A.workdir,32)})]})]}),o.jsx("button",{onClick:D=>S(A,D),className:"text-accent-error/70 hover:text-accent-error p-1",title:"Delete project",children:o.jsx(Wa,{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(Ve,{variant:"primary",onClick:()=>c(!0),children:"Select existing project"}),o.jsx(Ve,{variant:"secondary",onClick:()=>a(!0),"data-testid":"open-project-create-button",children:"Create new project"})]})})]}),s&&o.jsx(QS,{isOpen:s,onClose:()=>a(!1)}),x&&o.jsx(s1,{isOpen:!0,onClose:()=>y(null),projectName:x.name,onConfirm:v}),u&&o.jsx(Zu,{initialPath:l??void 0,onSelect:A=>{_(A)},onClose:()=>c(!1)}),w&&o.jsx(XS,{isOpen:!0,onClose:T,path:w,onRetry:R})]}):null}function Or(e,t){const n=new Set(t.map(s=>s.id));return[...e.filter(s=>!n.has(s.id)),...t]}function Pa(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 i1(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 rv(e,t){if(!t)return e;const n=e.toLowerCase(),s=t.toLowerCase(),a=new Array(e.length).fill(!1),l=n.indexOf(s);if(l>=0)for(let f=l;f<l+s.length;f++)a[f]=!0;else{let f=0;for(let p=0;p<e.length&&f<s.length;p++)n[p]===s[f]&&(a[p]=!0,f++)}const u=[];let c="",d=a[0]??!1;for(let f=0;f<e.length;f++)a[f]===d?c+=e[f]:(u.push(d?o.jsx("span",{className:"font-semibold text-accent-primary",children:c},u.length):c),c=e[f],d=a[f]);return u.push(d?o.jsx("span",{className:"font-semibold text-accent-primary",children:c},u.length):c),o.jsx(o.Fragment,{children:u})}function sT(){const[e,t]=L.useState(!1),[n,s]=L.useState(null),[a,l]=L.useState(""),[u,c]=L.useState(""),d=L.useRef(null),f=De(U=>U.sessions),p=Rt(U=>U.projects),m=Rt(U=>U.loading),x=Rt(U=>U.listProjects),y=De(U=>U.listSessions),w=Rt(U=>U.deleteProject),C=De(U=>U.connectionStatus);L.useEffect(()=>{C==="connected"&&(x(),y())},[C,x,y]),L.useEffect(()=>{const U=setTimeout(()=>c(a),150);return()=>clearTimeout(U)},[a]);const{matchCount:b,filteredSessionIds:S,relevanceScores:v,matchTypes:_,promptSnippets:E}=L.useMemo(()=>{if(!u)return{matchCount:0,filteredSessionIds:null,relevanceScores:null,matchTypes:null,promptSnippets:null};const U=new Map(p.map(H=>[H.id,H])),V=new Map,z=new Map,J=new Map,Z=f.filter(H=>{var Y;const O=U.get(H.projectId),B=(O==null?void 0:O.name)??"",W=H.title??"",P=((Y=H.recentUserPrompts)==null?void 0:Y.map(F=>F.content))??[],ee=P.join(" ");let X=0,ne="";if(Pa(W,u)&&(X+=10,ne="title"),Pa(ee,u)){X+=3,ne=ne==="title"?"title":"prompts";const F=P.find(te=>Pa(te,u));if(F){const te=F.toLowerCase().indexOf(u.toLowerCase());if(te>=0){const se=Math.max(0,te-30),xe=Math.min(F.length,te+u.length+30);J.set(H.id,(se>0?"…":"")+F.slice(se,xe)+(xe<F.length?"…":""))}else J.set(H.id,F.slice(0,80)+(F.length>80?"…":""))}}return Pa(B,u)&&(X+=1,ne=ne||"project"),V.set(H.id,X),z.set(H.id,ne),X>0});return{matchCount:Z.length,filteredSessionIds:new Set(Z.map(H=>H.id)),relevanceScores:V,matchTypes:z,promptSnippets:J}},[f,u,p]),j=L.useMemo(()=>{const U=new Map;for(const V of f){const z=new Date(V.updatedAt).getTime(),J=U.get(V.projectId)??0;z>J&&U.set(V.projectId,z)}return U},[f]),T=L.useMemo(()=>{const U=new Map;for(const V of f){const z=U.get(V.projectId);z?z.push(V):U.set(V.projectId,[V])}for(const[,V]of U)V.sort((z,J)=>new Date(J.updatedAt).getTime()-new Date(z.updatedAt).getTime());return U},[f]),R=L.useMemo(()=>{let U=p;return u&&S&&(U=p.filter(V=>{const z=T.get(V.id);return z==null?void 0:z.some(J=>S.has(J.id))})),[...U].sort((V,z)=>{const J=j.get(V.id)??new Date(V.updatedAt).getTime();return(j.get(z.id)??new Date(z.updatedAt).getTime())-J})},[p,T,u,S,j]),A=L.useCallback(U=>{const V=T.get(U);return V?u&&S&&v?V.filter(z=>S.has(z.id)).sort((z,J)=>{const Z=(v.get(J.id)??0)-(v.get(z.id)??0);return Z!==0?Z:new Date(J.updatedAt).getTime()-new Date(z.updatedAt).getTime()}):V.slice(0,5):[]},[T,u,S,v]),D=()=>{t(!0)},$=()=>{var U;l(""),c(""),(U=d.current)==null||U.focus()},q=U=>{var V;U.key==="Escape"&&($(),(V=d.current)==null||V.blur())},G=u.length>0,I=G&&b===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(Ve,{variant:"primary",onClick:D,children:"Open Project"})]}),f.length>0&&o.jsxs("div",{className:"mb-4 md:mb-6 relative",children:[o.jsxs("div",{className:"relative flex items-center",children:[o.jsx(pl,{className:"absolute left-3 w-4 h-4 text-text-muted pointer-events-none"}),o.jsx("input",{ref:d,type:"text",value:a,onChange:U=>l(U.target.value),onKeyDown:q,placeholder:"Search sessions by title or keyword...",className:"w-full bg-bg-secondary border border-border rounded-lg pl-10 pr-10 py-2.5 text-sm text-text-primary placeholder-text-muted focus:outline-none focus:ring-2 focus:ring-accent-primary/50 focus:border-accent-primary transition-colors"}),a&&o.jsx("button",{type:"button",onClick:$,className:"absolute right-3 p-0.5 rounded text-text-muted hover:text-text-primary hover:bg-bg-tertiary transition-colors","aria-label":"Clear search",children:o.jsx(qa,{className:"w-4 h-4"})})]}),G&&!I&&o.jsxs("div",{className:"mt-1.5 text-xs text-text-muted px-1",children:[b," ",b===1?"match":"matches"]})]}),I?o.jsxs("div",{className:"text-center py-16 text-text-muted",children:[o.jsx(pl,{className:"w-10 h-10 mx-auto mb-4 opacity-40"}),o.jsxs("p",{className:"text-lg",children:["No sessions matching ",o.jsxs("span",{className:"text-text-primary font-medium",children:["“",u,"”"]})]}),o.jsx("p",{className:"mt-2 text-sm",children:"Try a different keyword or clear the search"})]}):R.map(U=>{const V=A(U.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/${U.id}`,className:"flex items-center gap-2 cursor-pointer hover:opacity-80 transition-opacity flex-1",children:[o.jsx(El,{className:"w-5 h-5 text-accent-primary flex-shrink-0"}),o.jsx("span",{className:"text-text-primary font-semibold",children:U.name})]}),o.jsx(qn,{href:`/p/${U.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:U.id,name:U.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(Wa,{className:"w-4 h-4"})})]}),o.jsx("div",{className:"divide-y divide-border",children:V.length>0?V.map(z=>{const J=p.find(B=>z.projectId===B.id),Z=J?`/p/${J.id}/s/${z.id}`:"#",H=z.title??z.id.slice(0,8),O=_==null?void 0:_.get(z.id);return o.jsx(qn,{href:Z,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.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:"text-sm text-text-muted truncate",children:G&&O==="title"?rv(H,u):H}),G&&O&&O!=="title"&&o.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mt-1",children:[o.jsx("span",{className:"text-[10px] font-medium text-accent-primary border border-accent-primary/30 bg-accent-primary/8 rounded px-1 py-0.5 leading-none",children:O==="prompts"?"prompts":"project"}),O==="prompts"&&(E==null?void 0:E.get(z.id))&&o.jsx("span",{className:"text-[11px] text-text-muted truncate max-w-[250px]",children:rv(E.get(z.id),u)})]})]})}),o.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[o.jsx("span",{className:"text-text-muted text-xs",children:GN(z.updatedAt)}),o.jsxs("span",{className:"text-text-muted text-xs",children:[z.messageCount," msgs"]})]})]})},z.id)}):o.jsx("div",{className:"p-3 md:p-4 text-text-muted text-sm",children:"No sessions yet"})})]})},U.id)}),!G&&R.length===0&&!m&&o.jsx("div",{className:"text-center py-12 text-text-muted",children:"No projects yet. Open a project to get started."}),m&&o.jsx("div",{className:"flex justify-center py-12",children:o.jsx(Di,{})})]}),e&&o.jsx(rT,{isOpen:e,onClose:()=>t(!1)}),n&&o.jsx(s1,{isOpen:!0,onClose:()=>s(null),projectName:n.name,onConfirm:()=>w(n.id)})]})}function iT(){const[,e]=Ga("/p/:projectId/new"),[,t]=Yn(),n=e==null?void 0:e.projectId,s=De(u=>u.createSession),a=De(u=>u.resetPendingSessionCreate),l=L.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 L.useEffect(()=>{l()},[l]),o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Di,{})})}function aT(){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 Yo=e=>Math.round(e*10)/10;function oT(e){return typeof e.totalTime=="number"&&!Number.isNaN(e.totalTime)}function Fm(e){return{providerId:e.providerId,providerName:e.providerName,backend:e.backend,model:e.model}}function lT(e){return`${e.providerId}::${e.model}`}function cT(e){return`${e.providerName} > ${e.model}`}function sv(e){let t=0,n=0,s=0,a=0,l=0,u=0;const c=[],d=[];let f=0;for(const[x,y]of e.entries()){const w=y.stats,C=Fm(w);t+=w.totalTime,n+=w.toolTime,s+=w.prefillTokens,a+=w.generationTokens;const b=w.prefillSpeed>0?w.prefillTokens/w.prefillSpeed:0,S=w.generationSpeed>0?w.generationTokens/w.generationSpeed:0;l+=b,u+=S,c.push({messageId:y.id,timestamp:y.timestamp,...C,mode:w.mode,responseIndex:x+1,prefillTokens:w.prefillTokens,generationTokens:w.generationTokens,prefillSpeed:w.prefillSpeed,generationSpeed:w.generationSpeed,totalTime:w.totalTime,aiTime:w.totalTime-w.toolTime,toolTime:w.toolTime});const v=w.llmCalls??[];for(const _ of v)f+=1,d.push({messageId:y.id,timestamp:_.timestamp??y.timestamp,providerId:_.providerId,providerName:_.providerName,backend:_.backend,model:_.model,mode:w.mode,responseIndex:x+1,sessionCallIndex:f,callIndex:_.callIndex,promptTokens:_.promptTokens,completionTokens:_.completionTokens,ttft:_.ttft,completionTime:_.completionTime,prefillSpeed:_.prefillSpeed,generationSpeed:_.generationSpeed,totalTime:_.totalTime,..._.temperature!==void 0&&{temperature:_.temperature},..._.topP!==void 0&&{topP:_.topP},..._.topK!==void 0&&{topK:_.topK},..._.maxTokens!==void 0&&{maxTokens:_.maxTokens}})}const p=l>0?Yo(s/l):0,m=u>0?Yo(a/u):0;return{totalTime:Yo(t),aiTime:Yo(t-n),toolTime:Yo(n),prefillTokens:s,generationTokens:a,avgPrefillSpeed:p,avgGenerationSpeed:m,responseCount:e.length,llmCallCount:d.length,dataPoints:c,callDataPoints:d}}function uT(e){const t=e.filter(a=>a.stats!==void 0&&a.stats!==null&&oT(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=lT(Fm(a.stats)),u=n.get(l)??[];n.set(l,[...u,a])}const s=Array.from(n.entries()).map(([a,l])=>{const u=Fm(l[0].stats),c=sv(l);return{...u,key:a,label:cT(u),...c}});return{...sv(t),modelGroups:s}}function dT(e){return L.useMemo(()=>uT(e),[e])}function a1(){var a;const e=De(l=>l.gitStatus),t=De(l=>l.currentSession),[n,s]=L.useState(!0);return L.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 ku(e){return e.toLocaleString("en-US").replace(/,/g," ")}function iv(e){return Number.isFinite(e)?e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toFixed(1):"0"}function hT(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 av=["▁","▂","▃","▄","▅","▆","▇","█"];function fT(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 mT(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 pT(e,t){if(e.length===0||t<=0)return{blocks:"",minX:0,maxX:0,minY:0,maxY:0};const n=[...e].sort((x,y)=>x.x-y.x),s=n[0].x,a=n[n.length-1].x,l=Math.min(...n.map(x=>x.y)),u=Math.max(...n.map(x=>x.y)),{minY:c,maxY:d}=mT(l,u),f=Math.max(0,c),p=Array.from({length:t},()=>" "),m=new Map;for(const x of n){const y=a===s?0:Math.round((x.x-s)/(a-s)*(t-1)),w=m.get(y)??[];m.set(y,[...w,x.y])}for(const[x,y]of m){const w=Math.max(...y);p[x]=av[fT(w,c,d)]??av[0]}return{blocks:p.join(""),minX:s,maxX:a,minY:f,maxY:d}}function ov(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toFixed(1)}function lv({data:e,width:t=60,height:n=78,label:s,xLabel:a,yLabel:l,showAxes:u=!0,formatY:c=ov,formatX:d=ov}){const f=L.useMemo(()=>{const p=pT(e,t),m=Math.max(t*6,240),x=10,y=8,C=[...e].sort((_,E)=>_.x-E.x).map(_=>{const E=p.maxX===p.minX?m/2:x+(_.x-p.minX)/(p.maxX-p.minX)*(m-x*2),j=p.maxY===p.minY?n/2:y+(p.maxY-_.y)/(p.maxY-p.minY)*(n-y*2);return{..._,cx:E,cy:j,leftPercent:E/m*100,topPercent:j/n*100}}),b=C.map((_,E)=>`${E===0?"M":"L"} ${_.cx.toFixed(1)} ${_.cy.toFixed(1)}`).join(" "),v=[p.maxY,(p.maxY+p.minY)/2,p.minY].map(_=>({value:_,y:p.maxY===p.minY?n/2:y+(p.maxY-_)/(p.maxY-p.minY)*(n-y*2)}));return{...p,chartWidth:m,points:C,path:b,gridLines:v}},[e,n,t]);return e.length===0?o.jsxs("div",{className:"font-mono text-text-muted text-xs",children:[s&&o.jsx("div",{className:"mb-1",children:s}),o.jsx("div",{children:"No data"})]}):o.jsxs("div",{className:"font-mono text-xs",children:[s&&o.jsx("div",{className:"text-text-secondary mb-2",children:s}),o.jsxs("div",{className:"flex gap-3",children:[u&&o.jsx("div",{className:"w-12 h-[78px] flex flex-col justify-between text-right text-text-muted",children:f.gridLines.map(p=>o.jsx("span",{children:c(p.value)},`${p.value}-${p.y}`))}),o.jsx("div",{className:"flex-1 min-w-0",children:o.jsxs("div",{className:"relative h-[78px]",children:[o.jsxs("svg",{viewBox:`0 0 ${f.chartWidth} ${n}`,className:"w-full h-[78px] overflow-visible",preserveAspectRatio:"none","aria-hidden":"true",children:[f.gridLines.map(p=>o.jsx("line",{x1:"0",x2:f.chartWidth,y1:p.y,y2:p.y,stroke:"currentColor",strokeDasharray:"3 4",className:"text-border/60"},`grid-${p.y}`)),f.points.map(p=>o.jsx("line",{x1:p.cx,x2:p.cx,y1:n-4,y2:p.cy,stroke:"currentColor",className:"text-border/40"},`guide-${p.cx}-${p.cy}`)),f.points.length>1&&o.jsx("path",{d:f.path,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-accent-primary/45"})]}),f.points.map(p=>o.jsx("div",{className:"absolute -translate-x-1/2 -translate-y-1/2",style:{left:`${p.leftPercent}%`,top:`${p.topPercent}%`},title:`${d(p.x)} -> ${c(p.y)}`,children:o.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-accent-primary/20 flex items-center justify-center",children:o.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-accent-primary"})})},`point-${p.x}-${p.y}`))]})})]}),u&&o.jsxs("div",{className:"flex items-start gap-3 text-text-muted mt-1",children:[o.jsx("span",{className:"w-12"}),o.jsxs("span",{className:"flex-1 flex justify-between",children:[o.jsx("span",{children: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 gT({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(lv,{data:l,width:a,label:t,xLabel:s}),o.jsx(lv,{data:u,width:a,label:n,xLabel:s})]})}function xT(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 yT(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 _T(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 bT(e){return e.callDataPoints.length>0?_T(e):yT(e)}function Qf(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 al(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toFixed(1)}function vT(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 Eu(e){return`${al(e)} t/s`}function o1(e){try{return new Date(e).toLocaleTimeString("en-US",{hour12:!1})}catch{return e}}function ST(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 wT({isOpen:e,onClose:t,stats:n}){const s=L.useRef(null),[a,l]=L.useState({}),[u,c]=L.useState(()=>{var w;return((w=n.modelGroups[0])==null?void 0:w.key)??""});L.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=L.useMemo(()=>n.modelGroups.find(w=>w.key===u)??n.modelGroups[0],[u,n.modelGroups]),f=L.useMemo(()=>d?xT(d):[],[d]),p=L.useMemo(()=>d?bT(d):{mode:"responses",xLabel:"response",prefillLabel:"",generationLabel:"",points:[]},[d]),m=L.useCallback(w=>{l(C=>({...C,[w]:!C[w]}))},[]),x=L.useCallback(()=>{if(!d)return;const w=ST(d);navigator.clipboard.writeText(JSON.stringify(w,null,2)).catch(C=>console.error("Failed to copy:",C))},[d]),y=L.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}),b=document.createElement("a");b.download=`openfox-stats-${new Date().toISOString().slice(0,10)}.png`,b.href=C.toDataURL("image/png"),b.click()}catch(w){console.error("Failed to export PNG:",w),x()}},[x]);return o.jsx(jt,{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(ns,{label:"AI Time",value:Qf(d.aiTime)}),o.jsx(ns,{label:"Total Time",value:Qf(d.totalTime)}),o.jsx(ns,{label:"Tool Time",value:Qf(d.toolTime)}),o.jsx(ns,{label:"Responses",value:d.responseCount.toString()}),o.jsx(ns,{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(ns,{label:"Prefill Tokens",value:Ti(d.prefillTokens),subValue:`@ ${al(d.avgPrefillSpeed)} tok/s`}),o.jsx(ns,{label:"Gen Tokens",value:Ti(d.generationTokens),subValue:`@ ${al(d.avgGenerationSpeed)} tok/s`}),o.jsx(ns,{label:"Avg PP Speed",value:`${al(d.avgPrefillSpeed)}`,subValue:"tok/s"}),o.jsx(ns,{label:"Avg TG Speed",value:`${al(d.avgGenerationSpeed)}`,subValue:"tok/s"})]})]}),d&&p.points.length>1&&o.jsxs("section",{children:[o.jsxs("div",{className:"flex items-center justify-between mb-3",children:[o.jsx("h3",{className:"text-sm font-semibold text-text-secondary uppercase tracking-wide",children:"Performance Progression"}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("button",{onClick:x,className:"px-2 py-1 text-xs text-text-muted hover:text-text-primary hover:bg-bg-tertiary rounded transition-colors",children:"Copy JSON"}),o.jsx("button",{onClick:y,className:"px-2 py-1 text-xs text-text-muted hover:text-text-primary hover:bg-bg-tertiary rounded transition-colors",children:"Save PNG"})]})]}),o.jsx("div",{className:"bg-bg-tertiary/50 rounded p-4",children:o.jsx(gT,{data:p.points,width:50,prefillLabel:p.prefillLabel,generationLabel:p.generationLabel,xLabel:p.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(L.Fragment,{children:[o.jsx(CT,{row:w,index:C,isExpanded:a[w.messageId]??!1,onToggle:w.isExpandable?()=>m(w.messageId):void 0}),(a[w.messageId]??!1)&&w.calls.map((b,S)=>o.jsx(kT,{dataPoint:b,index:S},`${b.messageId}-${b.callIndex}`))]},w.messageId))})]})})]})]})})}function ns({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 CT({row:e,index:t,isExpanded:n,onToggle:s}){const a=e.calls.length>0?vT(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:o1(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:Eu(e.prefillSpeed)}),o.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:Eu(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 kT({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:o1(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:Eu(e.prefillSpeed)}),o.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:Eu(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 ET={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"}},jT=["open","in_progress","pending","completed","resolved","dismissed","passed","failed"];function NT(e){return ET[e]??{icon:"○",color:"text-text-muted"}}function l1(e){const t=document.createElement("textarea");return t.innerHTML=e,t.value}const td=L.memo(function({status:t,className:n="text-xs leading-tight flex-shrink-0"}){const{icon:s,color:a}=NT(t);return o.jsx("span",{className:`${a} ${n}`,children:s})});function cv({entries:e,title:t}){const n=L.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:jT.map(s=>{const a=n[s];return a?o.jsxs("span",{className:"flex items-center gap-0.5",children:[o.jsx(td,{status:s}),o.jsx("span",{children:a})]},s):null})})]})}const TT=L.memo(function({entries:t,title:n,onClearAll:s}){const[a,l]=L.useState(!1),u=L.useCallback(()=>{l(!1),s==null||s()},[s]);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((c,d)=>o.jsxs("div",{className:`flex items-start gap-1 px-1.5 py-1 ${d>0?"border-t border-border":""}`,children:[o.jsx(td,{status:c.status}),o.jsxs("div",{className:"flex-1 min-w-0 text-xs truncate",children:[o.jsxs("span",{className:"text-text-muted",children:["[",c.id,"]"]})," ",l1(c.description)]})]},c.id??d))}),s&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"px-1.5 py-1 border-t border-border bg-secondary flex items-center gap-2",children:o.jsxs("button",{onClick:()=>l(!0),className:"flex items-center gap-1 text-xs text-text-muted hover:text-accent-error transition-colors ml-auto cursor-pointer",title:"Clear all",children:[o.jsx(Wa,{className:"w-3 h-3"}),"Clear all"]})}),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-2 justify-between",children:[o.jsx("span",{className:"text-xs text-accent-error",children:"Clear all?"}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("button",{onClick:u,className:"text-xs text-accent-error hover:text-accent-error/70 transition-colors cursor-pointer",children:"Yes"}),o.jsx("button",{onClick:()=>l(!1),className:"text-xs text-text-muted hover:text-text-primary transition-colors cursor-pointer",children:"No"})]})]})})]})]})});async function c1(e,t,n){t({loading:!0});try{const a=await(await Te(e)).json();t({defaults:a.defaults??[],userItems:a.userItems??[],...n?{projectItems:a.projectItems??[]}:{},loading:!1})}catch{t({loading:!1})}}const AT="#6b7280";function gl(e,t){var n;return((n=e.find(s=>s.id===t))==null?void 0:n.color)??AT}const mt=Xn(e=>{const t=async()=>{await c1("/api/agents",e,!0)};return{defaults:[],userItems:[],projectItems:[],loading:!1,fetchAgents:t,fetchAgent:async n=>{try{const s=await Te(`/api/agents/${n}`);return s.ok?await s.json():null}catch{return null}},fetchDefaultContent:async n=>{try{const s=await Te(`/api/agents/defaults/${n}`);return s.ok?await s.json():null}catch{return null}},createAgent:async(n,s)=>{const a=await Ws("POST","/api/agents",{...n,destination:s});return a.success&&await t(),a},updateAgent:async(n,s)=>{const a=await Ws("PUT",`/api/agents/${n}`,s);return a.success&&await t(),a},deleteAgent:async n=>{try{const s=await Te(`/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)=>Ku(`/api/agents/${n}/duplicate`,t,s)}}),Ct=Xn((e,t)=>({defaults:[],userItems:[],projectItems:[],activeWorkflowId:"default",loading:!1,templateVariables:[],fetchTemplateVariables:async()=>{try{const s=await(await Te("/api/workflows/template-variables")).json();e({templateVariables:s.variables??[]})}catch{}},fetchWorkflows:async()=>{e({loading:!0});try{const s=await(await Te("/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 Te(`/api/workflows/${n}`);return s.ok?await s.json():null}catch{return null}},fetchDefaultContent:async n=>{try{const s=await Te(`/api/workflows/defaults/${n}`);return s.ok?await s.json():null}catch{return null}},createWorkflow:async(n,s)=>{const a=await Ws("POST","/api/workflows",{...n,destination:s});return a.success&&await t().fetchWorkflows(),a},updateWorkflow:async(n,s)=>{const a=await Ws("PUT",`/api/workflows/${n}`,s);return a.success&&await t().fetchWorkflows(),a},deleteWorkflow:async n=>{try{const s=await Te(`/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)=>Ku(`/api/workflows/${n}/duplicate`,()=>t().fetchWorkflows(),s)})),LT={pending:"completed",completed:"passed",passed:"failed",failed:"pending"};async function RT(e,t){await Te(`/api/sessions/${e}/criteria`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({criteria:t})})}function Zc({id:e,agents:t}){const n=gl(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 DT({id:e}){const t=Ct(u=>u.defaults),n=Ct(u=>u.userItems),a=L.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 OT({entries:e,sessionId:t}){const[n,s]=L.useState(e),[a,l]=L.useState(!1),[u,c]=L.useState(null),[d,f]=L.useState(""),[p,m]=L.useState(""),[x,y]=L.useState(!1),[w,C]=L.useState(!1),b=mt(z=>z.defaults),S=mt(z=>z.userItems),v=mt(z=>z.projectItems),_=L.useMemo(()=>[...b,...S,...v],[b,S,v]),E=L.useRef(null),j=L.useRef(null);L.useEffect(()=>{s(e)},[e]),L.useEffect(()=>{var z;a&&((z=E.current)==null||z.focus())},[a]),L.useEffect(()=>{var z;u&&((z=j.current)==null||z.focus())},[u]);const T=L.useCallback(z=>{s(z),RT(t,z)},[t]),R=L.useCallback(()=>{var H;const z=d.trim();if(!z)return;const J=String(n.length),Z=[...n,{id:J,description:z,status:"pending"}];T(Z),f(""),(H=E.current)==null||H.focus()},[n,d,T]),A=L.useCallback(()=>{l(!1),f("")},[]),D=L.useCallback((z,J)=>{c(z),m(J)},[]),$=L.useCallback(()=>{if(!u)return;const z=p.trim(),J=n.map(Z=>Z.id===u?{...Z,description:z||Z.description}:Z);T(J),c(null)},[u,p,n,T]),q=L.useCallback(z=>{const J=n.map(Z=>Z.id===z?{...Z,status:LT[Z.status]??"pending"}:Z);T(J)},[n,T]),G=L.useCallback(z=>{T(n.filter(J=>J.id!==z))},[n,T]),I=L.useCallback(()=>{T([]),y(!1)},[T]),U=L.useCallback(z=>{z.key==="Enter"&&(z.preventDefault(),R()),z.key==="Escape"&&A()},[R,A]),V=L.useCallback(z=>{z.key==="Enter"&&$(),z.key==="Escape"&&c(null)},[$]);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,J)=>{const Z=z.status,H=u===z.id;return o.jsxs("div",{className:`flex items-start gap-1 px-1.5 py-1 group ${J>0?"border-t border-border":""}`,children:[o.jsx("button",{onClick:()=>q(z.id),className:"text-xs leading-tight flex-shrink-0 cursor-pointer hover:opacity-70 transition-opacity",title:`Status: ${z.status} (click to cycle)`,children:o.jsx(td,{status:Z})}),o.jsx("div",{className:"flex-1 min-w-0",children:H?o.jsx("input",{ref:j,value:p,onChange:O=>m(O.target.value),onBlur:$,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:()=>D(z.id,z.description),className:"text-xs text-text-primary text-left hover:text-accent-primary transition-colors w-full truncate cursor-pointer",title:"Click to edit",children:["[",z.id,"] ",l1(z.description)]})}),o.jsx("button",{onClick:()=>G(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(qa,{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:R,className:"flex items-center gap-1 text-xs text-accent-primary hover:text-accent-primary/70 transition-colors cursor-pointer",title:"Add criterion",children:[o.jsx(qs,{className:"w-3 h-3"}),"Add"]}),o.jsx("button",{onClick:A,className:"flex items-center gap-1 text-xs text-text-muted hover:text-text-primary transition-colors cursor-pointer",title:"Cancel",children:"Cancel"})]}):o.jsxs("button",{onClick:()=>l(!0),className:"flex items-center gap-1 text-xs text-text-muted hover:text-accent-primary transition-colors cursor-pointer",title:"Add criterion",children:[o.jsx(qs,{className:"w-3 h-3"}),"Add"]}),n.length>0&&o.jsxs("button",{onClick:()=>y(!0),className:"flex items-center gap-1 text-xs text-text-muted hover:text-accent-error transition-colors ml-auto cursor-pointer",title:"Clear all criteria",children:[o.jsx(Wa,{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(AS,{className:"w-3 h-3"})})]}),x&&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:I,className:"text-xs text-accent-error hover:text-accent-error/70 transition-colors cursor-pointer",children:"Yes"}),o.jsx("button",{onClick:()=>y(!1),className:"text-xs text-text-muted hover:text-text-primary transition-colors cursor-pointer",children:"No"})]})]})}),o.jsx(jt,{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(Zc,{id:"planner",agents:_})," 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(DT,{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(Zc,{id:"builder",agents:_}),' agent, that will be forced to continue until it marks all criteria as "completed"']}),o.jsxs("li",{children:["Then launch the ",o.jsx(Zc,{id:"verifier",agents:_})," 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(Zc,{id:"code_reviewer",agents:_})," 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 IT({isOpen:e,onClose:t}){const n=Dr(C=>C.config),s=Dr(C=>C.saveConfig),[a,l]=L.useState(""),[u,c]=L.useState(""),[d,f]=L.useState(!1),[p,m]=L.useState(!1),[x,y]=L.useState(!1);L.useEffect(()=>{e&&(l((n==null?void 0:n.command)??""),c((n==null?void 0:n.url)??""),f((n==null?void 0:n.hotReload)??!1),m((n==null?void 0:n.disableInspect)??!1))},[e,n]);const w=async()=>{!a.trim()||!u.trim()||(y(!0),await s({command:a.trim(),url:u.trim(),hotReload:d,disableInspect:p}),y(!1),t())};return o.jsx(jt,{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:p,onChange:C=>m(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:x||!a.trim()||!u.trim(),children:x?"Saving...":"Save"})]})]})})}const uv={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"},MT={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"},dv={1:"font-bold",2:"opacity-75",4:"underline",7:"bg-bg-secondary"},PT="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 p=uv[f];p&&d.push(p)}else if(f>=40&&f<=47){const p=MT[f];p&&d.push(p)}else if(f>=90&&f<=97){const p=uv[f];p&&d.push(p)}else if(f in dv){const p=dv[f];p&&d.push(p)}else f===39?d.push(PT):f===49&&(a=a.split(" ").filter(p=>!p.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:zT(e),className:"text-text-primary"}]}}function zT(e){return e.replace(new RegExp("\x1B\\[([0-9;]+)m","g"),"")}function ju(e){const t=BT(e),n=[];return t.forEach((s,a)=>{const l=s.text.split(`
|
|
90
|
+
`);l.forEach((u,c)=>{n.push(Hs.createElement("span",{key:`${a}-${c}`,className:s.className,style:{display:"inline-block",whiteSpace:"pre-wrap"}},u)),c<l.length-1&&n.push(Hs.createElement("br",{key:`${a}-${c}-br`}))})}),n.length===1?n[0]:n}function u1({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:ju(s.content)},a))})}function Dp({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(On,{className:"w-3 h-3"}),e?"live":"scroll to bottom"]})}const nd=(e,t)=>{const n=L.useRef(!0),s=L.useRef(null),[a,l]=L.useState(!0),u=()=>{const c=e.current;c&&(c.scrollTop=c.scrollHeight)};return L.useEffect(()=>{const c=e.current;if(!c)return;const d=y=>{if(y.deltaY>0){requestAnimationFrame(()=>requestAnimationFrame(()=>{c.scrollHeight-c.scrollTop-c.offsetHeight<100&&(n.current=!0,l(!0))}));return}n.current=!1,l(!1)},f=y=>{y.touches[0]&&(s.current=y.touches[0].clientY)},p=y=>{if(s.current===null)return;const w=y.touches[0];if(!w)return;if(w.clientY-s.current>0){n.current=!1,l(!1);return}requestAnimationFrame(()=>requestAnimationFrame(()=>{c.scrollHeight-c.scrollTop-c.offsetHeight<100&&(n.current=!0,l(!0))}))},m=new MutationObserver(()=>{n.current&&requestAnimationFrame(u)}),x=setInterval(()=>{n.current&&u()},1e3);return c.addEventListener("wheel",d,{passive:!0}),c.addEventListener("touchstart",f,{passive:!0}),c.addEventListener("touchmove",p,{passive:!0}),m.observe(c,{childList:!0,subtree:!0,characterData:!0}),()=>{c.removeEventListener("wheel",d),c.removeEventListener("touchstart",f),c.removeEventListener("touchmove",p),m.disconnect(),clearInterval(x)}},[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()}}},d1=L.memo(function({title:t,logs:n,onClose:s,preClassName:a}){const l=L.useRef(null),{isAutoScrollActive:u,setAutoScroll:c}=nd(l,null);return o.jsx(jt,{isOpen:!0,onClose:s,title:t,size:"full",headerRight:o.jsx(Dp,{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(u1,{logs:n,preClassName:a})})})}),$T=L.memo(function({logs:t,anchorRef:n,isHiding:s,isAutoScrollActive:a,onSetAutoScroll:l}){const[u,c]=L.useState(null),d=L.useRef(null),f=L.useRef(l);return f.current=l,L.useEffect(()=>{var m;const p=(m=n.current)==null?void 0:m.getBoundingClientRect();p&&c({bottom:window.innerHeight-p.bottom,right:window.innerWidth-p.right,width:p.width,height:p.height})},[n]),L.useEffect(()=>{const p=d.current;if(!p)return;const m=x=>{if(x.deltaY<0){f.current(!1);return}x.deltaY>0&&requestAnimationFrame(()=>requestAnimationFrame(()=>{p.scrollHeight-p.scrollTop-p.offsetHeight<100&&f.current(!0)}))};return p.addEventListener("wheel",m,{passive:!0}),()=>p.removeEventListener("wheel",m)},[]),L.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((p,m)=>o.jsx("span",{className:p.stream==="stderr"?"text-accent-warning":"",children:ju(p.content)},m))})})}),HT=L.memo(function({workdir:t}){const n=Dr(G=>G.setWorkdir),s=Dr(G=>G.status),a=Dr(G=>G.config),l=Dr(G=>G.logs),u=Dr(G=>G.start),c=Dr(G=>G.stop),d=Dr(G=>G.fetchLogs),[f,p]=L.useState(!1),[m,x]=L.useState(!1),[y,w]=L.useState(!1),[C,b]=L.useState(!1),S=L.useRef(null),{isAutoScrollActive:v,setAutoScroll:_}=nd(S,null),E=L.useRef(null),j=L.useRef(null),T=L.useRef(null),R=()=>{const G=s==null?void 0:s.inspectProxyPort;if(!G){s!=null&&s.url&&window.open(s.url,"_blank");return}const I=`${window.location.protocol}//${window.location.hostname}:${G}`;window.open(I,"_blank")},A=(s==null?void 0:s.state)??"off",D=a!==null,$=A==="running"||A==="warning";L.useEffect(()=>{n(t??null)},[t,n]),L.useEffect(()=>{$&&d()},[$,d]);const q=()=>{$?c():u()};return o.jsxs("div",{className:"mt-2 pt-3 border-t border-border space-y-3",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:`inline-block w-2.5 h-2.5 rounded-full flex-shrink-0 ${A==="running"?"bg-accent-success":A==="warning"?"bg-accent-warning":A==="error"?"bg-accent-error":"bg-text-muted"}`}),o.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:"Dev Server"})]}),o.jsx("button",{onClick:()=>p(!0),className:"p-1.5 rounded hover:bg-bg-tertiary transition-colors text-text-muted",title:"Configure dev server",children:o.jsx(Gj,{})})]}),D?o.jsx(o.Fragment,{children:A==="running"||A==="warning"?o.jsxs("div",{className:"flex gap-2",children:[o.jsxs("button",{onClick:q,className:"flex-1 flex items-center justify-center gap-1.5 rounded font-medium text-sm px-3 py-1.5 bg-bg-tertiary text-text-primary hover:bg-border transition-colors",children:[o.jsx(OS,{}),"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(qj,{}),"Open"]})]}):o.jsx("button",{onClick:q,className:"w-full rounded font-medium text-sm px-3 py-1.5 bg-accent-primary/25 text-text-primary hover:bg-accent-primary/40 transition-colors",children:"Start"})}):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:T,className:`relative ${D&&$?"":"hidden"}`,onMouseEnter:()=>{!D||!$||(j.current&&clearTimeout(j.current),E.current=setTimeout(()=>{w(!0),b(!1)},500))},onMouseLeave:()=>{E.current&&clearTimeout(E.current),b(!0),j.current=setTimeout(()=>w(!1),150)},children:[o.jsx(u1,{logs:l,preRef:S,preClassName:"text-sm bg-bg-primary p-2 rounded overflow-auto max-h-[200px] border border-border"}),D&&$&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"absolute bottom-1 right-1 z-50 flex items-center gap-1",children:[(y||C)&&o.jsx(Dp,{isActive:v,onToggle:_,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"})]}),(y||C)&&T.current&&Ka.createPortal(o.jsx($T,{logs:l,anchorRef:T,isHiding:C,isAutoScrollActive:v,onSetAutoScroll:_}),document.body)]})]}),o.jsx(IT,{isOpen:f,onClose:()=>p(!1)}),m&&o.jsx(d1,{title:"Dev Server Logs",logs:l,onClose:()=>x(!1)})]})}),UT=L.memo(function({sessionId:t}){var y;const n=ll(w=>w.processes),s=ll(w=>w.stopProcess),[a,l]=L.useState(null),[u,c]=L.useState([]),d=n.filter(w=>w.status!=="exited"),f=d.filter(w=>w.status==="running").length;if(n.length===0)return null;const p=w=>{switch(w){case"running":return"bg-accent-success";case"starting":return"bg-accent-warning";case"stopping":return"bg-accent-warning";case"exited":return"bg-text-muted";default:return"bg-text-muted"}},m=w=>{const C=ll.getState().logs[w]??[];c(C.map(b=>({content:b.content,stream:b.stream}))),l(w)},x=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 ${p(w.status)}`}),o.jsx("span",{className:"text-sm text-text-primary truncate",title:w.name,children:w.name}),o.jsxs("span",{className:"text-xs text-text-muted",children:["[",w.status,"]"]})]}),o.jsxs("div",{className:"flex gap-1 ml-2",children:[o.jsx("button",{onClick:()=>m(w.id),className:"px-2 py-1 text-xs rounded bg-bg-tertiary hover:bg-border text-text-secondary transition-colors",title:"View logs",children:"Logs"}),o.jsx("button",{onClick:()=>x(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(d1,{title:((y=d.find(w=>w.id===a))==null?void 0:y.name)??"",logs:u,onClose:()=>{l(null),c([])}})]})});function FT({isOpen:e,onClose:t,versionInfo:n}){const[s,a]=L.useState("ready"),[l,u]=L.useState(""),[c,d]=L.useState(n),[f,p]=L.useState(null),[m,x]=L.useState(null);L.useEffect(()=>{if(e){if(n){d(n);return}fetch("/api/auto-update/check").then(b=>b.json()).then(b=>{d({current:b.current,latest:b.latest})}).catch(()=>{})}},[e]),L.useEffect(()=>{if(!e||s!=="updating"&&s!=="restarting")return;const b=setInterval(()=>{u(S=>S.length>=3?"":S+".")},400);return()=>clearInterval(b)},[e,s]);const y=L.useCallback(async()=>{a("updating"),x(null);try{const S=await(await Te("/api/auto-update",{method:"POST"})).json();if(S.success){const v=S.version??"unknown";p(v),localStorage.setItem("openfox_updated_to",v),localStorage.setItem("update_pending","true"),S.isService?(a("restarting"),await Te("/api/auto-update/restart",{method:"POST"}).catch(()=>{}),setTimeout(()=>window.location.reload(),5e3)):a("complete")}else x(S.error??"Update failed"),a("failed")}catch(b){x(b instanceof Error?b.message:"Update request failed"),a("failed")}},[]);L.useEffect(()=>{e&&(a("ready"),u(""),p(null),x(null))},[e]);const w=s!=="updating"&&s!=="restarting",C=s==="failed"?"Update Failed":s==="complete"||s==="restarting"?"Update Complete":"New OpenFox Version Available";return o.jsxs(jt,{isOpen:e,onClose:w?t:void 0,title:C,size:"sm",closeOnBackdropClick:w,showCloseButton:w,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"||s==="restarting")&&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:[s==="restarting"?"Restarting":"Updating",l]})]}),s==="complete"&&o.jsx("div",{className:"flex flex-col gap-3 mt-2",children:o.jsxs("div",{className:"bg-bg-tertiary rounded px-3 py-2 text-xs text-text-secondary",children:["OpenFox has been updated to v",f??(c==null?void 0:c.latest),"."," Please restart OpenFox to use the new version."]})}),s==="failed"&&o.jsxs("div",{className:"flex flex-col gap-3 mt-2",children:[o.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-accent-danger/10 border border-accent-danger/30 rounded text-xs",children:[o.jsx("span",{children:"⚠️"}),o.jsx("p",{className:"text-text-secondary",children:m})]}),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:y,className:"w-full px-3 py-2 text-sm rounded bg-accent-primary hover:brightness-110 transition-all text-white font-medium",children:"Update OpenFox"}),(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 VT({file:e}){const t=r1(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 GT(){const{diff:e}=a1();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(VT,{file:t},n))})})}function hv({messages:e,workdir:t}){var C,b,S,v;const[n,s]=L.useState(!1),[a,l]=L.useState(!1),[u,c]=L.useState(!1),[d,f]=L.useState(!1),p=dT(e),{branch:m}=a1(),x=nn(_=>_.version),y=De(_=>_.currentSession),w=L.useCallback(async()=>{l(!0);try{const _=await fetch("/api/auto-update/check");if(_.ok){const E=await _.json();c(E.isUpdateAvailable)}}catch{}finally{l(!1)}},[]);return L.useEffect(()=>{w()},[w]),o.jsxs("div",{className:"flex flex-col h-full",children:[p&&o.jsxs("div",{className:"mb-4",children:[o.jsx("button",{onClick:()=>s(!0),className:"w-full flex items-center justify-center px-3 py-2 rounded bg-bg-tertiary hover:bg-bg-secondary transition-colors",title:"View detailed response and call-level stats",children:o.jsxs("div",{className:"flex items-center gap-2 text-sm text-text-muted",children:[o.jsx("span",{className:"text-text-secondary",children:hT(p.aiTime)}),o.jsx("span",{className:"w-px h-3 bg-border"}),o.jsx("span",{className:"text-text-secondary",children:iv(p.avgPrefillSpeed)}),o.jsx("span",{children:"pp"}),o.jsx("span",{className:"w-px h-3 bg-border"}),o.jsx("span",{className:"text-text-secondary",children:iv(p.avgGenerationSpeed)}),o.jsx("span",{children:"tg"})]})}),o.jsx(wT,{isOpen:n,onClose:()=>s(!1),stats:p})]}),o.jsx("div",{className:"flex flex-col flex-1 overflow-y-auto",children:o.jsxs("div",{className:"mt-4",children:[o.jsx(cv,{entries:((C=y==null?void 0:y.metadataEntries)==null?void 0:C.criteria)??[],title:"Acceptance Criteria"}),y&&o.jsx(OT,{entries:((b=y==null?void 0:y.metadataEntries)==null?void 0:b.criteria)??[],sessionId:y.id}),y&&(((v=(S=y.metadataEntries)==null?void 0:S.review_findings)==null?void 0:v.length)??0)>0&&o.jsxs("div",{className:"mt-6",children:[o.jsx(cv,{entries:y.metadataEntries.review_findings,title:"Review Findings"}),o.jsx(TT,{entries:y.metadataEntries.review_findings,onClearAll:async()=>{try{await Te(`/api/sessions/${y.id}/review-findings`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({review_findings:[]})})}catch(_){console.error("Failed to clear review findings:",_)}}})]})]})}),m&&o.jsxs("div",{className:"mt-4 flex items-center gap-2 text-sm",children:[o.jsx($j,{}),o.jsx("span",{className:"truncate text-text-secondary",title:m,children:m})]}),o.jsx(GT,{}),o.jsx(HT,{workdir:t}),o.jsx(UT,{sessionId:y==null?void 0:y.id}),x&&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",x]}),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(Ep,{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(FT,{isOpen:d,onClose:()=>f(!1),versionInfo:null})]})}function WT({children:e,criteriaSidebarOpen:t=!0,onCriteriaSidebarToggle:n,messages:s}){const a=De(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(hv,{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(hv,{messages:s,workdir:a==null?void 0:a.workdir})})]})]})}function qT(e,t){return t||e>85?"bg-accent-error":e>60?"bg-accent-warning":"bg-accent-success"}function h1({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 ${qT(e,t)}`,style:{width:`${Math.min(e,100)}%`}})})}function KT({dangerZone:e,size:t="md"}){return e?o.jsx("span",{className:"text-accent-error animate-pulse text-[10px] font-medium",children:"Low!"}):null}function fv(e,t){return t||e>85?"text-accent-error":e>60?"text-accent-warning":"text-text-muted"}function YT(){const e=De(v=>v.contextState),t=De(v=>v.currentSession),n=De(v=>v.compactContext),[s,a]=L.useState(!1),[l,u]=L.useState(!1),[c,d]=L.useState(!1),f=L.useRef(!1);if(L.useEffect(()=>{e!=null&&e.dynamicContextChanged&&!f.current&&u(!1),f.current=(e==null?void 0:e.dynamicContextChanged)??!1},[e==null?void 0:e.dynamicContextChanged]),!e||!t)return null;const{currentTokens:p,maxTokens:m,compactionCount:x,dangerZone:y,dynamicContextChanged:w}=e,C=Math.round(p/m*100),b=t.isRunning,S=()=>{Ut.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:fv(C,y),children:[ku(p)," / ",ku(m)]}),o.jsxs("span",{className:fv(C,y),children:["(",C,"%)"]}),o.jsx(h1,{percent:C,dangerZone:y}),o.jsx(KT,{dangerZone:y}),x>0&&o.jsxs("span",{className:"text-[10px] text-text-muted bg-bg-tertiary px-1 py-0.5 rounded",children:[x,"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(LS,{})}),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:()=>{b||n(),a(!1)},disabled:b,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:b?"Cannot compact while running":"Compact context",children:o.jsx("span",{className:y?"text-accent-error":"",children:"Compact"})}),w&&o.jsx("button",{onClick:()=>{a(!1),d(!0)},disabled:b,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:b?"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(qa,{})})]})}),o.jsxs(jt,{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:b,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 XT({stats:e,onClose:t}){var n;return o.jsx(jt,{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(eu,{label:"Total Time",value:`${e.totalTime.toFixed(1)}s`}),o.jsx(eu,{label:"Prefill",value:e.prefillTokens>=1e3?`${(e.prefillTokens/1e3).toFixed(1)}k`:String(e.prefillTokens)}),o.jsx(eu,{label:"Generated",value:e.generationTokens>=1e3?`${(e.generationTokens/1e3).toFixed(1)}k`:String(e.generationTokens)}),o.jsx(eu,{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(tu,{label:"temp",value:s.temperature.toFixed(2)}),s.topP!==void 0&&o.jsx(tu,{label:"topP",value:s.topP.toFixed(2)}),s.topK!==void 0&&o.jsx(tu,{label:"topK",value:String(s.topK)}),s.maxTokens!==void 0&&o.jsx(tu,{label:"maxTok",value:String(s.maxTokens)})]})]})]},a))]})]})})}function eu({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 tu({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 QT(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const JT=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,ZT=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,eA={};function mv(e,t){return(eA.jsx?ZT:JT).test(e)}const tA=/[ \t\n\f\r]/g;function nA(e){return typeof e=="object"?e.type==="text"?pv(e.value):!1:pv(e)}function pv(e){return e.replace(tA,"")===""}let Al=class{constructor(t,n,s){this.normal=n,this.property=t,s&&(this.space=s)}};Al.prototype.normal={};Al.prototype.property={};Al.prototype.space=void 0;function f1(e,t){const n={},s={};for(const a of e)Object.assign(n,a.property),Object.assign(s,a.normal);return new Al(n,s,t)}function Vm(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 rA=0;const Je=Oi(),Jt=Oi(),Gm=Oi(),Le=Oi(),Tt=Oi(),Ba=Oi(),Gn=Oi();function Oi(){return 2**++rA}const Wm=Object.freeze(Object.defineProperty({__proto__:null,boolean:Je,booleanish:Jt,commaOrSpaceSeparated:Gn,commaSeparated:Ba,number:Le,overloadedBoolean:Gm,spaceSeparated:Tt},Symbol.toStringTag,{value:"Module"})),Jf=Object.keys(Wm);let Op=class extends In{constructor(t,n,s,a){let l=-1;if(super(t,n),gv(this,"space",a),typeof s=="number")for(;++l<Jf.length;){const u=Jf[l];gv(this,Jf[l],(s&Wm[u])===Wm[u])}}};Op.prototype.defined=!0;function gv(e,t,n){n&&(e[t]=n)}function Ya(e){const t={},n={};for(const[s,a]of Object.entries(e.properties)){const l=new Op(s,e.transform(e.attributes||{},s),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(s)&&(l.mustUseProperty=!0),t[s]=l,n[Vm(s)]=s,n[Vm(l.attribute)]=s}return new Al(t,n,e.space)}const m1=Ya({properties:{ariaActiveDescendant:null,ariaAtomic:Jt,ariaAutoComplete:null,ariaBusy:Jt,ariaChecked:Jt,ariaColCount:Le,ariaColIndex:Le,ariaColSpan:Le,ariaControls:Tt,ariaCurrent:null,ariaDescribedBy:Tt,ariaDetails:null,ariaDisabled:Jt,ariaDropEffect:Tt,ariaErrorMessage:null,ariaExpanded:Jt,ariaFlowTo:Tt,ariaGrabbed:Jt,ariaHasPopup:null,ariaHidden:Jt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Tt,ariaLevel:Le,ariaLive:null,ariaModal:Jt,ariaMultiLine:Jt,ariaMultiSelectable:Jt,ariaOrientation:null,ariaOwns:Tt,ariaPlaceholder:null,ariaPosInSet:Le,ariaPressed:Jt,ariaReadOnly:Jt,ariaRelevant:null,ariaRequired:Jt,ariaRoleDescription:Tt,ariaRowCount:Le,ariaRowIndex:Le,ariaRowSpan:Le,ariaSelected:Jt,ariaSetSize:Le,ariaSort:null,ariaValueMax:Le,ariaValueMin:Le,ariaValueNow:Le,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function p1(e,t){return t in e?e[t]:t}function g1(e,t){return p1(e,t.toLowerCase())}const sA=Ya({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Ba,acceptCharset:Tt,accessKey:Tt,action:null,allow:null,allowFullScreen:Je,allowPaymentRequest:Je,allowUserMedia:Je,alt:null,as:null,async:Je,autoCapitalize:null,autoComplete:Tt,autoFocus:Je,autoPlay:Je,blocking:Tt,capture:null,charSet:null,checked:Je,cite:null,className:Tt,cols:Le,colSpan:null,content:null,contentEditable:Jt,controls:Je,controlsList:Tt,coords:Le|Ba,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Je,defer:Je,dir:null,dirName:null,disabled:Je,download:Gm,draggable:Jt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Je,formTarget:null,headers:Tt,height:Le,hidden:Gm,high:Le,href:null,hrefLang:null,htmlFor:Tt,httpEquiv:Tt,id:null,imageSizes:null,imageSrcSet:null,inert:Je,inputMode:null,integrity:null,is:null,isMap:Je,itemId:null,itemProp:Tt,itemRef:Tt,itemScope:Je,itemType:Tt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Je,low:Le,manifest:null,max:null,maxLength:Le,media:null,method:null,min:null,minLength:Le,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:Le,pattern:null,ping:Tt,placeholder:null,playsInline:Je,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Je,referrerPolicy:null,rel:Tt,required:Je,reversed:Je,rows:Le,rowSpan:Le,sandbox:Tt,scope:null,scoped:Je,seamless:Je,selected:Je,shadowRootClonable:Je,shadowRootDelegatesFocus:Je,shadowRootMode:null,shape:null,size:Le,sizes:null,slot:null,span:Le,spellCheck:Jt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Le,step:null,style:null,tabIndex:Le,target:null,title:null,translate:null,type:null,typeMustMatch:Je,useMap:null,value:Jt,width:Le,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Tt,axis:null,background:null,bgColor:null,border:Le,borderColor:null,bottomMargin:Le,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:Le,leftMargin:Le,link:null,longDesc:null,lowSrc:null,marginHeight:Le,marginWidth:Le,noResize:Je,noHref:Je,noShade:Je,noWrap:Je,object:null,profile:null,prompt:null,rev:null,rightMargin:Le,rules:null,scheme:null,scrolling:Jt,standby:null,summary:null,text:null,topMargin:Le,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Le,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Je,disableRemotePlayback:Je,prefix:null,property:null,results:Le,security:null,unselectable:null},space:"html",transform:g1}),iA=Ya({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:Le,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Le,amplitude:Le,arabicForm:null,ascent:Le,attributeName:null,attributeType:null,azimuth:Le,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Le,by:null,calcMode:null,capHeight:Le,className:Tt,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Le,diffuseConstant:Le,direction:null,display:null,dur:null,divisor:Le,dominantBaseline:null,download:Je,dx:null,dy:null,edgeMode:null,editable:null,elevation:Le,enableBackground:null,end:null,event:null,exponent:Le,externalResourcesRequired:null,fill:null,fillOpacity:Le,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:Ba,g2:Ba,glyphName:Ba,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Le,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Le,horizOriginX:Le,horizOriginY:Le,id:null,ideographic:Le,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Le,k:Le,k1:Le,k2:Le,k3:Le,k4:Le,kernelMatrix:Gn,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Le,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:Le,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:Le,overlineThickness:Le,paintOrder:null,panose1:null,path:null,pathLength:Le,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Tt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Le,pointsAtY:Le,pointsAtZ:Le,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:Le,specularExponent:Le,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Le,strikethroughThickness:Le,string:null,stroke:null,strokeDashArray:Gn,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Le,strokeOpacity:Le,strokeWidth:null,style:null,surfaceScale:Le,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Gn,tabIndex:Le,tableValues:null,target:null,targetX:Le,targetY:Le,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:Le,underlineThickness:Le,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Le,values:null,vAlphabetic:Le,vMathematical:Le,vectorEffect:null,vHanging:Le,vIdeographic:Le,version:null,vertAdvY:Le,vertOriginX:Le,vertOriginY:Le,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Le,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:p1}),x1=Ya({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()}}),y1=Ya({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:g1}),_1=Ya({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),aA={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"},oA=/[A-Z]/g,xv=/-[a-z]/g,lA=/^data[-\w.:]+$/i;function cA(e,t){const n=Vm(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"&&lA.test(t)){if(t.charAt(4)==="-"){const l=t.slice(5).replace(xv,dA);s="data"+l.charAt(0).toUpperCase()+l.slice(1)}else{const l=t.slice(4);if(!xv.test(l)){let u=l.replace(oA,uA);u.charAt(0)!=="-"&&(u="-"+u),t="data"+u}}a=Op}return new a(s,t)}function uA(e){return"-"+e.toLowerCase()}function dA(e){return e.charAt(1).toUpperCase()}const hA=f1([m1,sA,x1,y1,_1],"html"),Ip=f1([m1,iA,x1,y1,_1],"svg");function fA(e){return e.join(" ").trim()}var ka={},Zf,yv;function mA(){if(yv)return Zf;yv=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="/",p="*",m="",x="comment",y="declaration";function w(b,S){if(typeof b!="string")throw new TypeError("First argument must be a string");if(!b)return[];S=S||{};var v=1,_=1;function E(U){var V=U.match(t);V&&(v+=V.length);var z=U.lastIndexOf(d);_=~z?U.length-z:_+U.length}function j(){var U={line:v,column:_};return function(V){return V.position=new T(U),D(),V}}function T(U){this.start=U,this.end={line:v,column:_},this.source=S.source}T.prototype.content=b;function R(U){var V=new Error(S.source+":"+v+":"+_+": "+U);if(V.reason=U,V.filename=S.source,V.line=v,V.column=_,V.source=b,!S.silent)throw V}function A(U){var V=U.exec(b);if(V){var z=V[0];return E(z),b=b.slice(z.length),V}}function D(){A(n)}function $(U){var V;for(U=U||[];V=q();)V!==!1&&U.push(V);return U}function q(){var U=j();if(!(f!=b.charAt(0)||p!=b.charAt(1))){for(var V=2;m!=b.charAt(V)&&(p!=b.charAt(V)||f!=b.charAt(V+1));)++V;if(V+=2,m===b.charAt(V-1))return R("End of comment missing");var z=b.slice(2,V-2);return _+=2,E(z),b=b.slice(V),_+=2,U({type:x,comment:z})}}function G(){var U=j(),V=A(s);if(V){if(q(),!A(a))return R("property missing ':'");var z=A(l),J=U({type:y,property:C(V[0].replace(e,m)),value:z?C(z[0].replace(e,m)):m});return A(u),J}}function I(){var U=[];$(U);for(var V;V=G();)V!==!1&&(U.push(V),$(U));return U}return D(),I()}function C(b){return b?b.replace(c,m):m}return Zf=w,Zf}var _v;function pA(){if(_v)return ka;_v=1;var e=ka&&ka.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(ka,"__esModule",{value:!0}),ka.default=n;const t=e(mA());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:p}=d;c?a(f,p,d):p&&(l=l||{},l[f]=p)}),l}return ka}var Xo={},bv;function gA(){if(bv)return Xo;bv=1,Object.defineProperty(Xo,"__esModule",{value:!0}),Xo.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,s=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,l=function(f){return!f||n.test(f)||e.test(f)},u=function(f,p){return p.toUpperCase()},c=function(f,p){return"".concat(p,"-")},d=function(f,p){return p===void 0&&(p={}),l(f)?f:(f=f.toLowerCase(),p.reactCompat?f=f.replace(a,c):f=f.replace(s,c),f.replace(t,u))};return Xo.camelCase=d,Xo}var Qo,vv;function xA(){if(vv)return Qo;vv=1;var e=Qo&&Qo.__importDefault||function(a){return a&&a.__esModule?a:{default:a}},t=e(pA()),n=gA();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,Qo=s,Qo}var yA=xA();const _A=Gu(yA),b1=v1("end"),Mp=v1("start");function v1(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 bA(e){const t=Mp(e),n=b1(e);if(t&&n)return{start:t,end:n}}function cl(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Sv(e.position):"start"in e||"end"in e?Sv(e):"line"in e||"column"in e?qm(e):""}function qm(e){return wv(e&&e.line)+":"+wv(e&&e.column)}function Sv(e){return qm(e&&e.start)+"-"+qm(e&&e.end)}function wv(e){return e&&typeof e=="number"?e:1}class Sn 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=cl(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}}Sn.prototype.file="";Sn.prototype.name="";Sn.prototype.reason="";Sn.prototype.message="";Sn.prototype.stack="";Sn.prototype.column=void 0;Sn.prototype.line=void 0;Sn.prototype.ancestors=void 0;Sn.prototype.cause=void 0;Sn.prototype.fatal=void 0;Sn.prototype.place=void 0;Sn.prototype.ruleId=void 0;Sn.prototype.source=void 0;const Pp={}.hasOwnProperty,vA=new Map,SA=/[A-Z]/g,wA=new Set(["table","tbody","thead","tfoot","tr"]),CA=new Set(["td","th"]),S1="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function kA(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=DA(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=RA(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"?Ip:hA,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},l=w1(a,e,void 0);return l&&typeof l!="string"?l:a.create(e,a.Fragment,{children:l||void 0},void 0)}function w1(e,t,n){if(t.type==="element")return EA(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return jA(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return TA(e,t,n);if(t.type==="mdxjsEsm")return NA(e,t);if(t.type==="root")return AA(e,t,n);if(t.type==="text")return LA(e,t)}function EA(e,t,n){const s=e.schema;let a=s;t.tagName.toLowerCase()==="svg"&&s.space==="html"&&(a=Ip,e.schema=a),e.ancestors.push(t);const l=k1(e,t.tagName,!1),u=OA(e,t);let c=zp(e,t);return wA.has(t.tagName)&&(c=c.filter(function(d){return typeof d=="string"?!nA(d):!0})),C1(e,u,l,t),Bp(u,c),e.ancestors.pop(),e.schema=s,e.create(t,l,u,n)}function jA(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)}xl(e,t.position)}function NA(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);xl(e,t.position)}function TA(e,t,n){const s=e.schema;let a=s;t.name==="svg"&&s.space==="html"&&(a=Ip,e.schema=a),e.ancestors.push(t);const l=t.name===null?e.Fragment:k1(e,t.name,!0),u=IA(e,t),c=zp(e,t);return C1(e,u,l,t),Bp(u,c),e.ancestors.pop(),e.schema=s,e.create(t,l,u,n)}function AA(e,t,n){const s={};return Bp(s,zp(e,t)),e.create(t,e.Fragment,s,n)}function LA(e,t){return t.value}function C1(e,t,n,s){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=s)}function Bp(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function RA(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 DA(e,t){return n;function n(s,a,l,u){const c=Array.isArray(l.children),d=Mp(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 OA(e,t){const n={};let s,a;for(a in t.properties)if(a!=="children"&&Pp.call(t.properties,a)){const l=MA(e,a,t.properties[a]);if(l){const[u,c]=l;e.tableCellAlignToStyle&&u==="align"&&typeof c=="string"&&CA.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 IA(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 xl(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 xl(e,t.position);else l=s.value===null?!0:s.value;n[a]=l}return n}function zp(e,t){const n=[];let s=-1;const a=e.passKeys?new Map:vA;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=w1(e,l,u);c!==void 0&&n.push(c)}return n}function MA(e,t,n){const s=cA(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=s.commaSeparated?QT(n):fA(n)),s.property==="style"){let a=typeof n=="object"?n:PA(e,String(n));return e.stylePropertyNameCase==="css"&&(a=BA(a)),["style",a]}return[e.elementAttributeNameCase==="react"&&s.space?aA[s.property]||s.property:s.attribute,n]}}function PA(e,t){try{return _A(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const s=n,a=new Sn("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=S1+"#cannot-parse-style-attribute",a}}function k1(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=mv(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=mv(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(s.type==="Literal"){const a=s.value;return Pp.call(e.components,a)?e.components[a]:a}if(e.evaluater)return e.evaluater.evaluateExpression(s);xl(e)}function xl(e,t){const n=new Sn("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=S1+"#cannot-handle-mdx-estrees-without-createevaluater",n}function BA(e){const t={};let n;for(n in e)Pp.call(e,n)&&(t[zA(n)]=e[n]);return t}function zA(e){let t=e.replace(SA,$A);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function $A(e){return"-"+e.toLowerCase()}const em={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"]},HA={};function $p(e,t){const n=HA,s=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,a=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return E1(e,s,a)}function E1(e,t,n){if(UA(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 Cv(e.children,t,n)}return Array.isArray(e)?Cv(e,t,n):""}function Cv(e,t,n){const s=[];let a=-1;for(;++a<e.length;)s[a]=E1(e[a],t,n);return s.join("")}function UA(e){return!!(e&&typeof e=="object")}const kv=document.createElement("i");function Hp(e){const t="&"+e+";";kv.innerHTML=t;const n=kv.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 lr(e,t){return e.length>0?(Kn(e,e.length,0,t),e):t}const Ev={}.hasOwnProperty;function j1(e){const t={};let n=-1;for(;++n<e.length;)FA(t,e[n]);return t}function FA(e,t){let n;for(n in t){const a=(Ev.call(e,n)?e[n]:void 0)||(e[n]={}),l=t[n];let u;if(l)for(u in l){Ev.call(a,u)||(a[u]=[]);const c=l[u];VA(a[u],Array.isArray(c)?c:c?[c]:[])}}}function VA(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 N1(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 kn=Ks(/[A-Za-z]/),vn=Ks(/[\dA-Za-z]/),GA=Ks(/[#-'*+\--9=?A-Z^-~]/);function Nu(e){return e!==null&&(e<32||e===127)}const Km=Ks(/\d/),WA=Ks(/[\dA-Fa-f]/),qA=Ks(/[!-/:-@[-`{-~]/);function Ue(e){return e!==null&&e<-2}function Nt(e){return e!==null&&(e<0||e===32)}function at(e){return e===-2||e===-1||e===32}const rd=Ks(new RegExp("\\p{P}|\\p{S}","u")),Ai=Ks(/\s/);function Ks(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Xa(e){const t=[];let n=-1,s=0,a=0;for(;++n<e.length;){const l=e.charCodeAt(n);let u="";if(l===37&&vn(e.charCodeAt(n+1))&&vn(e.charCodeAt(n+2)))a=2;else if(l<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(l))||(u=String.fromCharCode(l));else if(l>55295&&l<57344){const c=e.charCodeAt(n+1);l<56320&&c>56319&&c<57344?(u=String.fromCharCode(l,c),a=1):u="�"}else u=String.fromCharCode(l);u&&(t.push(e.slice(s,n),encodeURIComponent(u)),s=n+a+1,u=""),a&&(n+=a,a=0)}return t.join("")+e.slice(s)}function ut(e,t,n,s){const a=s?s-1:Number.POSITIVE_INFINITY;let l=0;return u;function u(d){return at(d)?(e.enter(n),c(d)):t(d)}function c(d){return at(d)&&l++<a?(e.consume(d),c):(e.exit(n),t(d))}}const KA={tokenize:YA};function YA(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 Ue(c)?(e.consume(c),e.exit("chunkText"),l):(e.consume(c),u)}}const XA={tokenize:QA},jv={tokenize:JA};function QA(e){const t=this,n=[];let s=0,a,l,u;return c;function c(_){if(s<n.length){const E=n[s];return t.containerState=E[1],e.attempt(E[0].continuation,d,f)(_)}return f(_)}function d(_){if(s++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,a&&v();const E=t.events.length;let j=E,T;for(;j--;)if(t.events[j][0]==="exit"&&t.events[j][1].type==="chunkFlow"){T=t.events[j][1].end;break}S(s);let R=E;for(;R<t.events.length;)t.events[R][1].end={...T},R++;return Kn(t.events,j+1,0,t.events.slice(E)),t.events.length=R,f(_)}return c(_)}function f(_){if(s===n.length){if(!a)return x(_);if(a.currentConstruct&&a.currentConstruct.concrete)return w(_);t.interrupt=!!(a.currentConstruct&&!a._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(jv,p,m)(_)}function p(_){return a&&v(),S(s),x(_)}function m(_){return t.parser.lazy[t.now().line]=s!==n.length,u=t.now().offset,w(_)}function x(_){return t.containerState={},e.attempt(jv,y,w)(_)}function y(_){return s++,n.push([t.currentConstruct,t.containerState]),x(_)}function w(_){if(_===null){a&&v(),S(0),e.consume(_);return}return a=a||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:a,contentType:"flow",previous:l}),C(_)}function C(_){if(_===null){b(e.exit("chunkFlow"),!0),S(0),e.consume(_);return}return Ue(_)?(e.consume(_),b(e.exit("chunkFlow")),s=0,t.interrupt=void 0,c):(e.consume(_),C)}function b(_,E){const j=t.sliceStream(_);if(E&&j.push(null),_.previous=l,l&&(l.next=_),l=_,a.defineSkip(_.start),a.write(j),t.parser.lazy[_.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 R=t.events.length;let A=R,D,$;for(;A--;)if(t.events[A][0]==="exit"&&t.events[A][1].type==="chunkFlow"){if(D){$=t.events[A][1].end;break}D=!0}for(S(s),T=R;T<t.events.length;)t.events[T][1].end={...$},T++;Kn(t.events,A+1,0,t.events.slice(R)),t.events.length=T}}function S(_){let E=n.length;for(;E-- >_;){const j=n[E];t.containerState=j[1],j[0].exit.call(t,e)}n.length=_}function v(){a.write([null]),l=void 0,a=void 0,t.containerState._closeFlow=void 0}}function JA(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 Ha(e){if(e===null||Nt(e)||Ai(e))return 1;if(rd(e))return 2}function sd(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 Ym={name:"attention",resolveAll:ZA,tokenize:eL};function ZA(e,t){let n=-1,s,a,l,u,c,d,f,p;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(s=n;s--;)if(e[s][0]==="exit"&&e[s][1].type==="attentionSequence"&&e[s][1]._open&&t.sliceSerialize(e[s][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[s][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[s][1].end.offset-e[s][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;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 m={...e[s][1].end},x={...e[n][1].start};Nv(m,-d),Nv(x,d),u={type:d>1?"strongSequence":"emphasisSequence",start:m,end:{...e[s][1].end}},c={type:d>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:x},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=lr(f,[["enter",e[s][1],t],["exit",e[s][1],t]])),f=lr(f,[["enter",a,t],["enter",u,t],["exit",u,t],["enter",l,t]]),f=lr(f,sd(t.parser.constructs.insideSpan.null,e.slice(s+1,n),t)),f=lr(f,[["exit",l,t],["enter",c,t],["exit",c,t],["exit",a,t]]),e[n][1].end.offset-e[n][1].start.offset?(p=2,f=lr(f,[["enter",e[n][1],t],["exit",e[n][1],t]])):p=0,Kn(e,s-1,n-s+3,f),n=s+f.length-p-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function eL(e,t){const n=this.parser.constructs.attentionMarkers.null,s=this.previous,a=Ha(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"),p=Ha(d),m=!p||p===2&&a||n.includes(d),x=!a||a===2&&p||n.includes(s);return f._open=!!(l===42?m:m&&(a||!x)),f._close=!!(l===42?x:x&&(p||!m)),t(d)}}function Nv(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const tL={name:"autolink",tokenize:nL};function nL(e,t,n){let s=0;return a;function a(y){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(y),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),l}function l(y){return kn(y)?(e.consume(y),u):y===64?n(y):f(y)}function u(y){return y===43||y===45||y===46||vn(y)?(s=1,c(y)):f(y)}function c(y){return y===58?(e.consume(y),s=0,d):(y===43||y===45||y===46||vn(y))&&s++<32?(e.consume(y),c):(s=0,f(y))}function d(y){return y===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(y),e.exit("autolinkMarker"),e.exit("autolink"),t):y===null||y===32||y===60||Nu(y)?n(y):(e.consume(y),d)}function f(y){return y===64?(e.consume(y),p):GA(y)?(e.consume(y),f):n(y)}function p(y){return vn(y)?m(y):n(y)}function m(y){return y===46?(e.consume(y),s=0,p):y===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(y),e.exit("autolinkMarker"),e.exit("autolink"),t):x(y)}function x(y){if((y===45||vn(y))&&s++<63){const w=y===45?x:m;return e.consume(y),w}return n(y)}}const Ll={partial:!0,tokenize:rL};function rL(e,t,n){return s;function s(l){return at(l)?ut(e,a,"linePrefix")(l):a(l)}function a(l){return l===null||Ue(l)?t(l):n(l)}}const T1={continuation:{tokenize:iL},exit:aL,name:"blockQuote",tokenize:sL};function sL(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 at(u)?(e.enter("blockQuotePrefixWhitespace"),e.consume(u),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(u))}}function iL(e,t,n){const s=this;return a;function a(u){return at(u)?ut(e,l,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(u):l(u)}function l(u){return e.attempt(T1,t,n)(u)}}function aL(e){e.exit("blockQuote")}const A1={name:"characterEscape",tokenize:oL};function oL(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 qA(l)?(e.enter("characterEscapeValue"),e.consume(l),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(l)}}const L1={name:"characterReference",tokenize:lL};function lL(e,t,n){const s=this;let a=0,l,u;return c;function c(m){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(m),e.exit("characterReferenceMarker"),d}function d(m){return m===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(m),e.exit("characterReferenceMarkerNumeric"),f):(e.enter("characterReferenceValue"),l=31,u=vn,p(m))}function f(m){return m===88||m===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(m),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),l=6,u=WA,p):(e.enter("characterReferenceValue"),l=7,u=Km,p(m))}function p(m){if(m===59&&a){const x=e.exit("characterReferenceValue");return u===vn&&!Hp(s.sliceSerialize(x))?n(m):(e.enter("characterReferenceMarker"),e.consume(m),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return u(m)&&a++<l?(e.consume(m),p):n(m)}}const Tv={partial:!0,tokenize:uL},Av={concrete:!0,name:"codeFenced",tokenize:cL};function cL(e,t,n){const s=this,a={partial:!0,tokenize:j};let l=0,u=0,c;return d;function d(T){return f(T)}function f(T){const R=s.events[s.events.length-1];return l=R&&R[1].type==="linePrefix"?R[2].sliceSerialize(R[1],!0).length:0,c=T,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),p(T)}function p(T){return T===c?(u++,e.consume(T),p):u<3?n(T):(e.exit("codeFencedFenceSequence"),at(T)?ut(e,m,"whitespace")(T):m(T))}function m(T){return T===null||Ue(T)?(e.exit("codeFencedFence"),s.interrupt?t(T):e.check(Tv,C,E)(T)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),x(T))}function x(T){return T===null||Ue(T)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),m(T)):at(T)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),ut(e,y,"whitespace")(T)):T===96&&T===c?n(T):(e.consume(T),x)}function y(T){return T===null||Ue(T)?m(T):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),w(T))}function w(T){return T===null||Ue(T)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),m(T)):T===96&&T===c?n(T):(e.consume(T),w)}function C(T){return e.attempt(a,E,b)(T)}function b(T){return e.enter("lineEnding"),e.consume(T),e.exit("lineEnding"),S}function S(T){return l>0&&at(T)?ut(e,v,"linePrefix",l+1)(T):v(T)}function v(T){return T===null||Ue(T)?e.check(Tv,C,E)(T):(e.enter("codeFlowValue"),_(T))}function _(T){return T===null||Ue(T)?(e.exit("codeFlowValue"),v(T)):(e.consume(T),_)}function E(T){return e.exit("codeFenced"),t(T)}function j(T,R,A){let D=0;return $;function $(V){return T.enter("lineEnding"),T.consume(V),T.exit("lineEnding"),q}function q(V){return T.enter("codeFencedFence"),at(V)?ut(T,G,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(V):G(V)}function G(V){return V===c?(T.enter("codeFencedFenceSequence"),I(V)):A(V)}function I(V){return V===c?(D++,T.consume(V),I):D>=u?(T.exit("codeFencedFenceSequence"),at(V)?ut(T,U,"whitespace")(V):U(V)):A(V)}function U(V){return V===null||Ue(V)?(T.exit("codeFencedFence"),R(V)):A(V)}}}function uL(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 tm={name:"codeIndented",tokenize:hL},dL={partial:!0,tokenize:fL};function hL(e,t,n){const s=this;return a;function a(f){return e.enter("codeIndented"),ut(e,l,"linePrefix",5)(f)}function l(f){const p=s.events[s.events.length-1];return p&&p[1].type==="linePrefix"&&p[2].sliceSerialize(p[1],!0).length>=4?u(f):n(f)}function u(f){return f===null?d(f):Ue(f)?e.attempt(dL,u,d)(f):(e.enter("codeFlowValue"),c(f))}function c(f){return f===null||Ue(f)?(e.exit("codeFlowValue"),u(f)):(e.consume(f),c)}function d(f){return e.exit("codeIndented"),t(f)}}function fL(e,t,n){const s=this;return a;function a(u){return s.parser.lazy[s.now().line]?n(u):Ue(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),a):ut(e,l,"linePrefix",5)(u)}function l(u){const c=s.events[s.events.length-1];return c&&c[1].type==="linePrefix"&&c[2].sliceSerialize(c[1],!0).length>=4?t(u):Ue(u)?a(u):n(u)}}const mL={name:"codeText",previous:gL,resolve:pL,tokenize:xL};function pL(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 gL(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function xL(e,t,n){let s=0,a,l;return u;function u(m){return e.enter("codeText"),e.enter("codeTextSequence"),c(m)}function c(m){return m===96?(e.consume(m),s++,c):(e.exit("codeTextSequence"),d(m))}function d(m){return m===null?n(m):m===32?(e.enter("space"),e.consume(m),e.exit("space"),d):m===96?(l=e.enter("codeTextSequence"),a=0,p(m)):Ue(m)?(e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),d):(e.enter("codeTextData"),f(m))}function f(m){return m===null||m===32||m===96||Ue(m)?(e.exit("codeTextData"),d(m)):(e.consume(m),f)}function p(m){return m===96?(e.consume(m),a++,p):a===s?(e.exit("codeTextSequence"),e.exit("codeText"),t(m)):(l.type="codeTextData",f(m))}}class yL{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&&Jo(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),Jo(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Jo(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);Jo(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Jo(this.left,n.reverse())}}}function Jo(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 R1(e){const t={};let n=-1,s,a,l,u,c,d,f;const p=new yL(e);for(;++n<p.length;){for(;n in t;)n=t[n];if(s=p.get(n),n&&s[1].type==="chunkFlow"&&p.get(n-1)[1].type==="listItemPrefix"&&(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,_L(p,n)),n=t[n],f=!0);else if(s[1]._container){for(l=n,a=void 0;l--;)if(u=p.get(l),u[1].type==="lineEnding"||u[1].type==="lineEndingBlank")u[0]==="enter"&&(a&&(p.get(a)[1].type="lineEndingBlank"),u[1].type="lineEnding",a=l);else if(!(u[1].type==="linePrefix"||u[1].type==="listItemIndent"))break;a&&(s[1].end={...p.get(a)[1].start},c=p.slice(a,n),c.unshift(s),p.splice(a,n-a+1,c))}}return Kn(e,0,Number.POSITIVE_INFINITY,p.slice(0)),!f}function _L(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 p,m,x=-1,y=n,w=0,C=0;const b=[C];for(;y;){for(;e.get(++a)[1]!==y;);l.push(a),y._tokenizer||(p=s.sliceStream(y),y.next||p.push(null),m&&u.defineSkip(y.start),y._isInFirstContentOfListItem&&(u._gfmTasklistFirstContentOfListItem=!0),u.write(p),y._isInFirstContentOfListItem&&(u._gfmTasklistFirstContentOfListItem=void 0)),m=y,y=y.next}for(y=n;++x<c.length;)c[x][0]==="exit"&&c[x-1][0]==="enter"&&c[x][1].type===c[x-1][1].type&&c[x][1].start.line!==c[x][1].end.line&&(C=x+1,b.push(C),y._tokenizer=void 0,y.previous=void 0,y=y.next);for(u.events=[],y?(y._tokenizer=void 0,y.previous=void 0):b.pop(),x=b.length;x--;){const S=c.slice(b[x],b[x+1]),v=l.pop();d.push([v,v+S.length-1]),e.splice(v,2,S)}for(d.reverse(),x=-1;++x<d.length;)f[w+d[x][0]]=w+d[x][1],w+=d[x][1]-d[x][0]-1;return f}const bL={resolve:SL,tokenize:wL},vL={partial:!0,tokenize:CL};function SL(e){return R1(e),e}function wL(e,t){let n;return s;function s(c){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),a(c)}function a(c){return c===null?l(c):Ue(c)?e.check(vL,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 CL(e,t,n){const s=this;return a;function a(u){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),ut(e,l,"linePrefix")}function l(u){if(u===null||Ue(u))return n(u);const c=s.events[s.events.length-1];return!s.parser.constructs.disable.null.includes("codeIndented")&&c&&c[1].type==="linePrefix"&&c[2].sliceSerialize(c[1],!0).length>=4?t(u):e.interrupt(s.parser.constructs.flow,n,t)(u)}}function D1(e,t,n,s,a,l,u,c,d){const f=d||Number.POSITIVE_INFINITY;let p=0;return m;function m(S){return S===60?(e.enter(s),e.enter(a),e.enter(l),e.consume(S),e.exit(l),x):S===null||S===32||S===41||Nu(S)?n(S):(e.enter(s),e.enter(u),e.enter(c),e.enter("chunkString",{contentType:"string"}),C(S))}function x(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"}),y(S))}function y(S){return S===62?(e.exit("chunkString"),e.exit(c),x(S)):S===null||S===60||Ue(S)?n(S):(e.consume(S),S===92?w:y)}function w(S){return S===60||S===62||S===92?(e.consume(S),y):y(S)}function C(S){return!p&&(S===null||S===41||Nt(S))?(e.exit("chunkString"),e.exit(c),e.exit(u),e.exit(s),t(S)):p<f&&S===40?(e.consume(S),p++,C):S===41?(e.consume(S),p--,C):S===null||S===32||S===40||Nu(S)?n(S):(e.consume(S),S===92?b:C)}function b(S){return S===40||S===41||S===92?(e.consume(S),C):C(S)}}function O1(e,t,n,s,a,l){const u=this;let c=0,d;return f;function f(y){return e.enter(s),e.enter(a),e.consume(y),e.exit(a),e.enter(l),p}function p(y){return c>999||y===null||y===91||y===93&&!d||y===94&&!c&&"_hiddenFootnoteSupport"in u.parser.constructs?n(y):y===93?(e.exit(l),e.enter(a),e.consume(y),e.exit(a),e.exit(s),t):Ue(y)?(e.enter("lineEnding"),e.consume(y),e.exit("lineEnding"),p):(e.enter("chunkString",{contentType:"string"}),m(y))}function m(y){return y===null||y===91||y===93||Ue(y)||c++>999?(e.exit("chunkString"),p(y)):(e.consume(y),d||(d=!at(y)),y===92?x:m)}function x(y){return y===91||y===92||y===93?(e.consume(y),c++,m):m(y)}}function I1(e,t,n,s,a,l){let u;return c;function c(x){return x===34||x===39||x===40?(e.enter(s),e.enter(a),e.consume(x),e.exit(a),u=x===40?41:x,d):n(x)}function d(x){return x===u?(e.enter(a),e.consume(x),e.exit(a),e.exit(s),t):(e.enter(l),f(x))}function f(x){return x===u?(e.exit(l),d(u)):x===null?n(x):Ue(x)?(e.enter("lineEnding"),e.consume(x),e.exit("lineEnding"),ut(e,f,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),p(x))}function p(x){return x===u||x===null||Ue(x)?(e.exit("chunkString"),f(x)):(e.consume(x),x===92?m:p)}function m(x){return x===u||x===92?(e.consume(x),p):p(x)}}function ul(e,t){let n;return s;function s(a){return Ue(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),n=!0,s):at(a)?ut(e,s,n?"linePrefix":"lineSuffix")(a):t(a)}}const kL={name:"definition",tokenize:jL},EL={partial:!0,tokenize:NL};function jL(e,t,n){const s=this;let a;return l;function l(y){return e.enter("definition"),u(y)}function u(y){return O1.call(s,e,c,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(y)}function c(y){return a=Sr(s.sliceSerialize(s.events[s.events.length-1][1]).slice(1,-1)),y===58?(e.enter("definitionMarker"),e.consume(y),e.exit("definitionMarker"),d):n(y)}function d(y){return Nt(y)?ul(e,f)(y):f(y)}function f(y){return D1(e,p,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(y)}function p(y){return e.attempt(EL,m,m)(y)}function m(y){return at(y)?ut(e,x,"whitespace")(y):x(y)}function x(y){return y===null||Ue(y)?(e.exit("definition"),s.parser.defined.push(a),t(y)):n(y)}}function NL(e,t,n){return s;function s(c){return Nt(c)?ul(e,a)(c):n(c)}function a(c){return I1(e,l,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(c)}function l(c){return at(c)?ut(e,u,"whitespace")(c):u(c)}function u(c){return c===null||Ue(c)?t(c):n(c)}}const TL={name:"hardBreakEscape",tokenize:AL};function AL(e,t,n){return s;function s(l){return e.enter("hardBreakEscape"),e.consume(l),a}function a(l){return Ue(l)?(e.exit("hardBreakEscape"),t(l)):n(l)}}const LL={name:"headingAtx",resolve:RL,tokenize:DL};function RL(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 DL(e,t,n){let s=0;return a;function a(p){return e.enter("atxHeading"),l(p)}function l(p){return e.enter("atxHeadingSequence"),u(p)}function u(p){return p===35&&s++<6?(e.consume(p),u):p===null||Nt(p)?(e.exit("atxHeadingSequence"),c(p)):n(p)}function c(p){return p===35?(e.enter("atxHeadingSequence"),d(p)):p===null||Ue(p)?(e.exit("atxHeading"),t(p)):at(p)?ut(e,c,"whitespace")(p):(e.enter("atxHeadingText"),f(p))}function d(p){return p===35?(e.consume(p),d):(e.exit("atxHeadingSequence"),c(p))}function f(p){return p===null||p===35||Nt(p)?(e.exit("atxHeadingText"),c(p)):(e.consume(p),f)}}const OL=["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"],Lv=["pre","script","style","textarea"],IL={concrete:!0,name:"htmlFlow",resolveTo:BL,tokenize:zL},ML={partial:!0,tokenize:HL},PL={partial:!0,tokenize:$L};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 zL(e,t,n){const s=this;let a,l,u,c,d;return f;function f(P){return p(P)}function p(P){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(P),m}function m(P){return P===33?(e.consume(P),x):P===47?(e.consume(P),l=!0,C):P===63?(e.consume(P),a=3,s.interrupt?t:O):kn(P)?(e.consume(P),u=String.fromCharCode(P),b):n(P)}function x(P){return P===45?(e.consume(P),a=2,y):P===91?(e.consume(P),a=5,c=0,w):kn(P)?(e.consume(P),a=4,s.interrupt?t:O):n(P)}function y(P){return P===45?(e.consume(P),s.interrupt?t:O):n(P)}function w(P){const ee="CDATA[";return P===ee.charCodeAt(c++)?(e.consume(P),c===ee.length?s.interrupt?t:G:w):n(P)}function C(P){return kn(P)?(e.consume(P),u=String.fromCharCode(P),b):n(P)}function b(P){if(P===null||P===47||P===62||Nt(P)){const ee=P===47,X=u.toLowerCase();return!ee&&!l&&Lv.includes(X)?(a=1,s.interrupt?t(P):G(P)):OL.includes(u.toLowerCase())?(a=6,ee?(e.consume(P),S):s.interrupt?t(P):G(P)):(a=7,s.interrupt&&!s.parser.lazy[s.now().line]?n(P):l?v(P):_(P))}return P===45||vn(P)?(e.consume(P),u+=String.fromCharCode(P),b):n(P)}function S(P){return P===62?(e.consume(P),s.interrupt?t:G):n(P)}function v(P){return at(P)?(e.consume(P),v):$(P)}function _(P){return P===47?(e.consume(P),$):P===58||P===95||kn(P)?(e.consume(P),E):at(P)?(e.consume(P),_):$(P)}function E(P){return P===45||P===46||P===58||P===95||vn(P)?(e.consume(P),E):j(P)}function j(P){return P===61?(e.consume(P),T):at(P)?(e.consume(P),j):_(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,R):at(P)?(e.consume(P),T):A(P)}function R(P){return P===d?(e.consume(P),d=null,D):P===null||Ue(P)?n(P):(e.consume(P),R)}function A(P){return P===null||P===34||P===39||P===47||P===60||P===61||P===62||P===96||Nt(P)?j(P):(e.consume(P),A)}function D(P){return P===47||P===62||at(P)?_(P):n(P)}function $(P){return P===62?(e.consume(P),q):n(P)}function q(P){return P===null||Ue(P)?G(P):at(P)?(e.consume(P),q):n(P)}function G(P){return P===45&&a===2?(e.consume(P),z):P===60&&a===1?(e.consume(P),J):P===62&&a===4?(e.consume(P),B):P===63&&a===3?(e.consume(P),O):P===93&&a===5?(e.consume(P),H):Ue(P)&&(a===6||a===7)?(e.exit("htmlFlowData"),e.check(ML,W,I)(P)):P===null||Ue(P)?(e.exit("htmlFlowData"),I(P)):(e.consume(P),G)}function I(P){return e.check(PL,U,W)(P)}function U(P){return e.enter("lineEnding"),e.consume(P),e.exit("lineEnding"),V}function V(P){return P===null||Ue(P)?I(P):(e.enter("htmlFlowData"),G(P))}function z(P){return P===45?(e.consume(P),O):G(P)}function J(P){return P===47?(e.consume(P),u="",Z):G(P)}function Z(P){if(P===62){const ee=u.toLowerCase();return Lv.includes(ee)?(e.consume(P),B):G(P)}return kn(P)&&u.length<8?(e.consume(P),u+=String.fromCharCode(P),Z):G(P)}function H(P){return P===93?(e.consume(P),O):G(P)}function O(P){return P===62?(e.consume(P),B):P===45&&a===2?(e.consume(P),O):G(P)}function B(P){return P===null||Ue(P)?(e.exit("htmlFlowData"),W(P)):(e.consume(P),B)}function W(P){return e.exit("htmlFlow"),t(P)}}function $L(e,t,n){const s=this;return a;function a(u){return Ue(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),l):n(u)}function l(u){return s.parser.lazy[s.now().line]?n(u):t(u)}}function HL(e,t,n){return s;function s(a){return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),e.attempt(Ll,t,n)}}const UL={name:"htmlText",tokenize:FL};function FL(e,t,n){const s=this;let a,l,u;return c;function c(O){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(O),d}function d(O){return O===33?(e.consume(O),f):O===47?(e.consume(O),j):O===63?(e.consume(O),_):kn(O)?(e.consume(O),A):n(O)}function f(O){return O===45?(e.consume(O),p):O===91?(e.consume(O),l=0,w):kn(O)?(e.consume(O),v):n(O)}function p(O){return O===45?(e.consume(O),y):n(O)}function m(O){return O===null?n(O):O===45?(e.consume(O),x):Ue(O)?(u=m,J(O)):(e.consume(O),m)}function x(O){return O===45?(e.consume(O),y):m(O)}function y(O){return O===62?z(O):O===45?x(O):m(O)}function w(O){const B="CDATA[";return O===B.charCodeAt(l++)?(e.consume(O),l===B.length?C:w):n(O)}function C(O){return O===null?n(O):O===93?(e.consume(O),b):Ue(O)?(u=C,J(O)):(e.consume(O),C)}function b(O){return O===93?(e.consume(O),S):C(O)}function S(O){return O===62?z(O):O===93?(e.consume(O),S):C(O)}function v(O){return O===null||O===62?z(O):Ue(O)?(u=v,J(O)):(e.consume(O),v)}function _(O){return O===null?n(O):O===63?(e.consume(O),E):Ue(O)?(u=_,J(O)):(e.consume(O),_)}function E(O){return O===62?z(O):_(O)}function j(O){return kn(O)?(e.consume(O),T):n(O)}function T(O){return O===45||vn(O)?(e.consume(O),T):R(O)}function R(O){return Ue(O)?(u=R,J(O)):at(O)?(e.consume(O),R):z(O)}function A(O){return O===45||vn(O)?(e.consume(O),A):O===47||O===62||Nt(O)?D(O):n(O)}function D(O){return O===47?(e.consume(O),z):O===58||O===95||kn(O)?(e.consume(O),$):Ue(O)?(u=D,J(O)):at(O)?(e.consume(O),D):z(O)}function $(O){return O===45||O===46||O===58||O===95||vn(O)?(e.consume(O),$):q(O)}function q(O){return O===61?(e.consume(O),G):Ue(O)?(u=q,J(O)):at(O)?(e.consume(O),q):D(O)}function G(O){return O===null||O===60||O===61||O===62||O===96?n(O):O===34||O===39?(e.consume(O),a=O,I):Ue(O)?(u=G,J(O)):at(O)?(e.consume(O),G):(e.consume(O),U)}function I(O){return O===a?(e.consume(O),a=void 0,V):O===null?n(O):Ue(O)?(u=I,J(O)):(e.consume(O),I)}function U(O){return O===null||O===34||O===39||O===60||O===61||O===96?n(O):O===47||O===62||Nt(O)?D(O):(e.consume(O),U)}function V(O){return O===47||O===62||Nt(O)?D(O):n(O)}function z(O){return O===62?(e.consume(O),e.exit("htmlTextData"),e.exit("htmlText"),t):n(O)}function J(O){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(O),e.exit("lineEnding"),Z}function Z(O){return at(O)?ut(e,H,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(O):H(O)}function H(O){return e.enter("htmlTextData"),u(O)}}const Up={name:"labelEnd",resolveAll:qL,resolveTo:KL,tokenize:YL},VL={tokenize:XL},GL={tokenize:QL},WL={tokenize:JL};function qL(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 KL(e,t){let n=e.length,s=0,a,l,u,c;for(;n--;)if(a=e[n][1],l){if(a.type==="link"||a.type==="labelLink"&&a._inactive)break;e[n][0]==="enter"&&a.type==="labelLink"&&(a._inactive=!0)}else if(u){if(e[n][0]==="enter"&&(a.type==="labelImage"||a.type==="labelLink")&&!a._balanced&&(l=n,a.type!=="labelLink")){s=2;break}}else a.type==="labelEnd"&&(u=n);const 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}},p={type:"labelText",start:{...e[l+s+2][1].end},end:{...e[u-2][1].start}};return c=[["enter",d,t],["enter",f,t]],c=lr(c,e.slice(l+1,l+s+3)),c=lr(c,[["enter",p,t]]),c=lr(c,sd(t.parser.constructs.insideSpan.null,e.slice(l+s+4,u-3),t)),c=lr(c,[["exit",p,t],e[u-2],e[u-1],["exit",f,t]]),c=lr(c,e.slice(u+1)),c=lr(c,[["exit",d,t]]),Kn(e,l,e.length,c),e}function YL(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(x){return l?l._inactive?m(x):(u=s.parser.defined.includes(Sr(s.sliceSerialize({start:l.end,end:s.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(x),e.exit("labelMarker"),e.exit("labelEnd"),d):n(x)}function d(x){return x===40?e.attempt(VL,p,u?p:m)(x):x===91?e.attempt(GL,p,u?f:m)(x):u?p(x):m(x)}function f(x){return e.attempt(WL,p,m)(x)}function p(x){return t(x)}function m(x){return l._balanced=!0,n(x)}}function XL(e,t,n){return s;function s(m){return e.enter("resource"),e.enter("resourceMarker"),e.consume(m),e.exit("resourceMarker"),a}function a(m){return Nt(m)?ul(e,l)(m):l(m)}function l(m){return m===41?p(m):D1(e,u,c,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(m)}function u(m){return Nt(m)?ul(e,d)(m):p(m)}function c(m){return n(m)}function d(m){return m===34||m===39||m===40?I1(e,f,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(m):p(m)}function f(m){return Nt(m)?ul(e,p)(m):p(m)}function p(m){return m===41?(e.enter("resourceMarker"),e.consume(m),e.exit("resourceMarker"),e.exit("resource"),t):n(m)}}function QL(e,t,n){const s=this;return a;function a(c){return O1.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 JL(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 ZL={name:"labelStartImage",resolveAll:Up.resolveAll,tokenize:eR};function eR(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 tR={name:"labelStartLink",resolveAll:Up.resolveAll,tokenize:nR};function nR(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 nm={name:"lineEnding",tokenize:rR};function rR(e,t){return n;function n(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),ut(e,t,"linePrefix")}}const _u={name:"thematicBreak",tokenize:sR};function sR(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||Ue(f))?(e.exit("thematicBreak"),t(f)):n(f)}function d(f){return f===a?(e.consume(f),s++,d):(e.exit("thematicBreakSequence"),at(f)?ut(e,c,"whitespace")(f):c(f))}}const Dn={continuation:{tokenize:lR},exit:uR,name:"list",tokenize:oR},iR={partial:!0,tokenize:dR},aR={partial:!0,tokenize:cR};function oR(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(y){const w=s.containerState.type||(y===42||y===43||y===45?"listUnordered":"listOrdered");if(w==="listUnordered"?!s.containerState.marker||y===s.containerState.marker:Km(y)){if(s.containerState.type||(s.containerState.type=w,e.enter(w,{_container:!0})),w==="listUnordered")return e.enter("listItemPrefix"),y===42||y===45?e.check(_u,n,f)(y):f(y);if(!s.interrupt||y===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),d(y)}return n(y)}function d(y){return Km(y)&&++u<10?(e.consume(y),d):(!s.interrupt||u<2)&&(s.containerState.marker?y===s.containerState.marker:y===41||y===46)?(e.exit("listItemValue"),f(y)):n(y)}function f(y){return e.enter("listItemMarker"),e.consume(y),e.exit("listItemMarker"),s.containerState.marker=s.containerState.marker||y,e.check(Ll,s.interrupt?n:p,e.attempt(iR,x,m))}function p(y){return s.containerState.initialBlankLine=!0,l++,x(y)}function m(y){return at(y)?(e.enter("listItemPrefixWhitespace"),e.consume(y),e.exit("listItemPrefixWhitespace"),x):n(y)}function x(y){return s.containerState.size=l+s.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(y)}}function lR(e,t,n){const s=this;return s.containerState._closeFlow=void 0,e.check(Ll,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||!at(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(aR,t,u)(c))}function u(c){return s.containerState._closeFlow=!0,s.interrupt=void 0,ut(e,e.attempt(Dn,t,n),"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c)}}function cR(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 uR(e){e.exit(this.containerState.type)}function dR(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!at(l)&&u&&u[1].type==="listItemPrefixWhitespace"?t(l):n(l)}}const Rv={name:"setextUnderline",resolveTo:hR,tokenize:fR};function hR(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 fR(e,t,n){const s=this;let a;return l;function l(f){let p=s.events.length,m;for(;p--;)if(s.events[p][1].type!=="lineEnding"&&s.events[p][1].type!=="linePrefix"&&s.events[p][1].type!=="content"){m=s.events[p][1].type==="paragraph";break}return!s.parser.lazy[s.now().line]&&(s.interrupt||m)?(e.enter("setextHeadingLine"),a=f,u(f)):n(f)}function u(f){return e.enter("setextHeadingLineSequence"),c(f)}function c(f){return f===a?(e.consume(f),c):(e.exit("setextHeadingLineSequence"),at(f)?ut(e,d,"lineSuffix")(f):d(f))}function d(f){return f===null||Ue(f)?(e.exit("setextHeadingLine"),t(f)):n(f)}}const mR={tokenize:pR};function pR(e){const t=this,n=e.attempt(Ll,s,e.attempt(this.parser.constructs.flowInitial,a,ut(e,e.attempt(this.parser.constructs.flow,a,e.attempt(bL,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 gR={resolveAll:P1()},xR=M1("string"),yR=M1("text");function M1(e){return{resolveAll:P1(e==="text"?_R:void 0),tokenize:t};function t(n){const s=this,a=this.parser.constructs[e],l=n.attempt(a,u,c);return u;function u(p){return f(p)?l(p):c(p)}function c(p){if(p===null){n.consume(p);return}return n.enter("data"),n.consume(p),d}function d(p){return f(p)?(n.exit("data"),l(p)):(n.consume(p),d)}function f(p){if(p===null)return!0;const m=a[p];let x=-1;if(m)for(;++x<m.length;){const y=m[x];if(!y.previous||y.previous.call(s,s.previous))return!0}return!1}}}function P1(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 _R(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 bR={42:Dn,43:Dn,45:Dn,48:Dn,49:Dn,50:Dn,51:Dn,52:Dn,53:Dn,54:Dn,55:Dn,56:Dn,57:Dn,62:T1},vR={91:kL},SR={[-2]:tm,[-1]:tm,32:tm},wR={35:LL,42:_u,45:[Rv,_u],60:IL,61:Rv,95:_u,96:Av,126:Av},CR={38:L1,92:A1},kR={[-5]:nm,[-4]:nm,[-3]:nm,33:ZL,38:L1,42:Ym,60:[tL,UL],91:tR,92:[TL,A1],93:Up,95:Ym,96:mL},ER={null:[Ym,gR]},jR={null:[42,95]},NR={null:[]},TR=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:jR,contentInitial:vR,disable:NR,document:bR,flow:wR,flowInitial:SR,insideSpan:ER,string:CR,text:kR},Symbol.toStringTag,{value:"Module"}));function AR(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:R(j),check:R(T),consume:v,enter:_,exit:E,interrupt:R(T,{interrupt:!0})},f={code:null,containerState:{},defineSkip:C,events:[],now:w,parser:e,previous:null,sliceSerialize:x,sliceStream:y,write:m};let p=t.tokenize.call(f,d);return t.resolveAll&&l.push(t),f;function m(q){return u=lr(u,q),b(),u[u.length-1]!==null?[]:(A(t,0),f.events=sd(l,f.events,f),f.events)}function x(q,G){return RR(y(q),G)}function y(q){return LR(u,q)}function w(){const{_bufferIndex:q,_index:G,line:I,column:U,offset:V}=s;return{_bufferIndex:q,_index:G,line:I,column:U,offset:V}}function C(q){a[q.line]=q.column,$()}function b(){let q;for(;s._index<u.length;){const G=u[s._index];if(typeof G=="string")for(q=s._index,s._bufferIndex<0&&(s._bufferIndex=0);s._index===q&&s._bufferIndex<G.length;)S(G.charCodeAt(s._bufferIndex));else S(G)}}function S(q){p=p(q)}function v(q){Ue(q)?(s.line++,s.column=1,s.offset+=q===-3?2:1,$()):q!==-1&&(s.column++,s.offset++),s._bufferIndex<0?s._index++:(s._bufferIndex++,s._bufferIndex===u[s._index].length&&(s._bufferIndex=-1,s._index++)),f.previous=q}function _(q,G){const I=G||{};return I.type=q,I.start=w(),f.events.push(["enter",I,f]),c.push(I),I}function E(q){const G=c.pop();return G.end=w(),f.events.push(["exit",G,f]),G}function j(q,G){A(q,G.from)}function T(q,G){G.restore()}function R(q,G){return I;function I(U,V,z){let J,Z,H,O;return Array.isArray(U)?W(U):"tokenize"in U?W([U]):B(U);function B(ne){return Y;function Y(F){const te=F!==null&&ne[F],se=F!==null&&ne.null,xe=[...Array.isArray(te)?te:te?[te]:[],...Array.isArray(se)?se:se?[se]:[]];return W(xe)(F)}}function W(ne){return J=ne,Z=0,ne.length===0?z:P(ne[Z])}function P(ne){return Y;function Y(F){return O=D(),H=ne,ne.partial||(f.currentConstruct=ne),ne.name&&f.parser.constructs.disable.null.includes(ne.name)?X():ne.tokenize.call(G?Object.assign(Object.create(f),G):f,d,ee,X)(F)}}function ee(ne){return q(H,O),V}function X(ne){return O.restore(),++Z<J.length?P(J[Z]):z}}}function A(q,G){q.resolveAll&&!l.includes(q)&&l.push(q),q.resolve&&Kn(f.events,G,f.events.length-G,q.resolve(f.events.slice(G),f)),q.resolveTo&&(f.events=q.resolveTo(f.events,f))}function D(){const q=w(),G=f.previous,I=f.currentConstruct,U=f.events.length,V=Array.from(c);return{from:U,restore:z};function z(){s=q,f.previous=G,f.currentConstruct=I,f.events.length=U,c=V,$()}}function $(){s.line in a&&s.column<2&&(s.column=a[s.line],s.offset+=a[s.line]-1)}}function LR(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 RR(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 DR(e){const s={constructs:j1([TR,...(e||{}).extensions||[]]),content:a(KA),defined:[],document:a(XA),flow:a(mR),lazy:{},string:a(xR),text:a(yR)};return s;function a(l){return u;function u(c){return AR(s,l,c)}}}function OR(e){for(;!R1(e););return e}const Dv=/[\0\t\n\r]/g;function IR(){let e=1,t="",n=!0,s;return a;function a(l,u,c){const d=[];let f,p,m,x,y;for(l=t+(typeof l=="string"?l.toString():new TextDecoder(u||void 0).decode(l)),m=0,t="",n&&(l.charCodeAt(0)===65279&&m++,n=void 0);m<l.length;){if(Dv.lastIndex=m,f=Dv.exec(l),x=f&&f.index!==void 0?f.index:l.length,y=l.charCodeAt(x),!f){t=l.slice(m);break}if(y===10&&m===x&&s)d.push(-3),s=void 0;else switch(s&&(d.push(-5),s=void 0),m<x&&(d.push(l.slice(m,x)),e+=x-m),y){case 0:{d.push(65533),e++;break}case 9:{for(p=Math.ceil(e/4)*4,d.push(-2);e++<p;)d.push(-1);break}case 10:{d.push(-4),e=1;break}default:s=!0,e=1}m=x+1}return c&&(s&&d.push(-5),t&&d.push(t),d.push(null)),d}}const MR=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function PR(e){return e.replace(MR,BR)}function BR(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const a=n.charCodeAt(1),l=a===120||a===88;return N1(n.slice(l?2:1),l?16:10)}return Hp(n)||e}const B1={}.hasOwnProperty;function zR(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),$R(n)(OR(DR(n).document().write(IR()(e,t,!0))))}function $R(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:l(ve),autolinkProtocol:D,autolinkEmail:D,atxHeading:l(ae),blockQuote:l(se),characterEscape:D,characterReference:D,codeFenced:l(xe),codeFencedFenceInfo:u,codeFencedFenceMeta:u,codeIndented:l(xe,u),codeText:l(le,u),codeTextData:D,data:D,codeFlowValue:D,definition:l(Ee),definitionDestinationString:u,definitionLabelString:u,definitionTitleString:u,emphasis:l(ue),hardBreakEscape:l(de),hardBreakTrailing:l(de),htmlFlow:l(oe,u),htmlFlowData:D,htmlText:l(oe,u),htmlTextData:D,image:l(Ne),label:u,link:l(ve),listItem:l(_e),listItemValue:x,listOrdered:l(re,m),listUnordered:l(re),paragraph:l(He),reference:P,referenceString:u,resourceDestinationString:u,resourceTitleString:u,setextHeading:l(ae),strong:l(et),thematicBreak:l(kt)},exit:{atxHeading:d(),atxHeadingSequence:j,autolink:d(),autolinkEmail:te,autolinkProtocol:F,blockQuote:d(),characterEscapeValue:$,characterReferenceMarkerHexadecimal:X,characterReferenceMarkerNumeric:X,characterReferenceValue:ne,characterReference:Y,codeFenced:d(b),codeFencedFence:C,codeFencedFenceInfo:y,codeFencedFenceMeta:w,codeFlowValue:$,codeIndented:d(S),codeText:d(V),codeTextData:$,data:$,definition:d(),definitionDestinationString:E,definitionLabelString:v,definitionTitleString:_,emphasis:d(),hardBreakEscape:d(G),hardBreakTrailing:d(G),htmlFlow:d(I),htmlFlowData:$,htmlText:d(U),htmlTextData:$,image:d(J),label:H,labelText:Z,lineEnding:q,link:d(z),listItem:d(),listOrdered:d(),listUnordered:d(),paragraph:d(),referenceString:ee,resourceDestinationString:O,resourceTitleString:B,resource:W,setextHeading:d(A),setextHeadingLineSequence:R,setextHeadingText:T,strong:d(),thematicBreak:d()}};z1(t,(e||{}).mdastExtensions||[]);const n={};return s;function s(ye){let Ae={type:"root",children:[]};const Be={stack:[Ae],tokenStack:[],config:t,enter:c,exit:f,buffer:u,resume:p,data:n},Ge=[];let Xe=-1;for(;++Xe<ye.length;)if(ye[Xe][1].type==="listOrdered"||ye[Xe][1].type==="listUnordered")if(ye[Xe][0]==="enter")Ge.push(Xe);else{const Dt=Ge.pop();Xe=a(ye,Dt,Xe)}for(Xe=-1;++Xe<ye.length;){const Dt=t[ye[Xe][0]];B1.call(Dt,ye[Xe][1].type)&&Dt[ye[Xe][1].type].call(Object.assign({sliceSerialize:ye[Xe][2].sliceSerialize},Be),ye[Xe][1])}if(Be.tokenStack.length>0){const Dt=Be.tokenStack[Be.tokenStack.length-1];(Dt[1]||Ov).call(Be,void 0,Dt[0])}for(Ae.position={start:Ms(ye.length>0?ye[0][1].start:{line:1,column:1,offset:0}),end:Ms(ye.length>0?ye[ye.length-2][1].end:{line:1,column:1,offset:0})},Xe=-1;++Xe<t.transforms.length;)Ae=t.transforms[Xe](Ae)||Ae;return Ae}function a(ye,Ae,Be){let Ge=Ae-1,Xe=-1,Dt=!1,nt,Ot,pt,xn;for(;++Ge<=Be;){const xt=ye[Ge];switch(xt[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{xt[0]==="enter"?Xe++:Xe--,xn=void 0;break}case"lineEndingBlank":{xt[0]==="enter"&&(nt&&!xn&&!Xe&&!pt&&(pt=Ge),xn=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:xn=void 0}if(!Xe&&xt[0]==="enter"&&xt[1].type==="listItemPrefix"||Xe===-1&&xt[0]==="exit"&&(xt[1].type==="listUnordered"||xt[1].type==="listOrdered")){if(nt){let hr=Ge;for(Ot=void 0;hr--;){const Pn=ye[hr];if(Pn[1].type==="lineEnding"||Pn[1].type==="lineEndingBlank"){if(Pn[0]==="exit")continue;Ot&&(ye[Ot][1].type="lineEndingBlank",Dt=!0),Pn[1].type="lineEnding",Ot=hr}else if(!(Pn[1].type==="linePrefix"||Pn[1].type==="blockQuotePrefix"||Pn[1].type==="blockQuotePrefixWhitespace"||Pn[1].type==="blockQuoteMarker"||Pn[1].type==="listItemIndent"))break}pt&&(!Ot||pt<Ot)&&(nt._spread=!0),nt.end=Object.assign({},Ot?ye[Ot][1].start:xt[1].end),ye.splice(Ot||Ge,0,["exit",nt,xt[2]]),Ge++,Be++}if(xt[1].type==="listItemPrefix"){const hr={type:"listItem",_spread:!1,start:Object.assign({},xt[1].start),end:void 0};nt=hr,ye.splice(Ge,0,["enter",hr,xt[2]]),Ge++,Be++,pt=void 0,xn=!0}}}return ye[Ae][1]._spread=Dt,Be}function l(ye,Ae){return Be;function Be(Ge){c.call(this,ye(Ge),Ge),Ae&&Ae.call(this,Ge)}}function u(){this.stack.push({type:"fragment",children:[]})}function c(ye,Ae,Be){this.stack[this.stack.length-1].children.push(ye),this.stack.push(ye),this.tokenStack.push([Ae,Be||void 0]),ye.position={start:Ms(Ae.start),end:void 0}}function d(ye){return Ae;function Ae(Be){ye&&ye.call(this,Be),f.call(this,Be)}}function f(ye,Ae){const Be=this.stack.pop(),Ge=this.tokenStack.pop();if(Ge)Ge[0].type!==ye.type&&(Ae?Ae.call(this,ye,Ge[0]):(Ge[1]||Ov).call(this,ye,Ge[0]));else throw new Error("Cannot close `"+ye.type+"` ("+cl({start:ye.start,end:ye.end})+"): it’s not open");Be.position.end=Ms(ye.end)}function p(){return $p(this.stack.pop())}function m(){this.data.expectingFirstListItemValue=!0}function x(ye){if(this.data.expectingFirstListItemValue){const Ae=this.stack[this.stack.length-2];Ae.start=Number.parseInt(this.sliceSerialize(ye),10),this.data.expectingFirstListItemValue=void 0}}function y(){const ye=this.resume(),Ae=this.stack[this.stack.length-1];Ae.lang=ye}function w(){const ye=this.resume(),Ae=this.stack[this.stack.length-1];Ae.meta=ye}function C(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function b(){const ye=this.resume(),Ae=this.stack[this.stack.length-1];Ae.value=ye.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function S(){const ye=this.resume(),Ae=this.stack[this.stack.length-1];Ae.value=ye.replace(/(\r?\n|\r)$/g,"")}function v(ye){const Ae=this.resume(),Be=this.stack[this.stack.length-1];Be.label=Ae,Be.identifier=Sr(this.sliceSerialize(ye)).toLowerCase()}function _(){const ye=this.resume(),Ae=this.stack[this.stack.length-1];Ae.title=ye}function E(){const ye=this.resume(),Ae=this.stack[this.stack.length-1];Ae.url=ye}function j(ye){const Ae=this.stack[this.stack.length-1];if(!Ae.depth){const Be=this.sliceSerialize(ye).length;Ae.depth=Be}}function T(){this.data.setextHeadingSlurpLineEnding=!0}function R(ye){const Ae=this.stack[this.stack.length-1];Ae.depth=this.sliceSerialize(ye).codePointAt(0)===61?1:2}function A(){this.data.setextHeadingSlurpLineEnding=void 0}function D(ye){const Be=this.stack[this.stack.length-1].children;let Ge=Be[Be.length-1];(!Ge||Ge.type!=="text")&&(Ge=rt(),Ge.position={start:Ms(ye.start),end:void 0},Be.push(Ge)),this.stack.push(Ge)}function $(ye){const Ae=this.stack.pop();Ae.value+=this.sliceSerialize(ye),Ae.position.end=Ms(ye.end)}function q(ye){const Ae=this.stack[this.stack.length-1];if(this.data.atHardBreak){const Be=Ae.children[Ae.children.length-1];Be.position.end=Ms(ye.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(Ae.type)&&(D.call(this,ye),$.call(this,ye))}function G(){this.data.atHardBreak=!0}function I(){const ye=this.resume(),Ae=this.stack[this.stack.length-1];Ae.value=ye}function U(){const ye=this.resume(),Ae=this.stack[this.stack.length-1];Ae.value=ye}function V(){const ye=this.resume(),Ae=this.stack[this.stack.length-1];Ae.value=ye}function z(){const ye=this.stack[this.stack.length-1];if(this.data.inReference){const Ae=this.data.referenceType||"shortcut";ye.type+="Reference",ye.referenceType=Ae,delete ye.url,delete ye.title}else delete ye.identifier,delete ye.label;this.data.referenceType=void 0}function J(){const ye=this.stack[this.stack.length-1];if(this.data.inReference){const Ae=this.data.referenceType||"shortcut";ye.type+="Reference",ye.referenceType=Ae,delete ye.url,delete ye.title}else delete ye.identifier,delete ye.label;this.data.referenceType=void 0}function Z(ye){const Ae=this.sliceSerialize(ye),Be=this.stack[this.stack.length-2];Be.label=PR(Ae),Be.identifier=Sr(Ae).toLowerCase()}function H(){const ye=this.stack[this.stack.length-1],Ae=this.resume(),Be=this.stack[this.stack.length-1];if(this.data.inReference=!0,Be.type==="link"){const Ge=ye.children;Be.children=Ge}else Be.alt=Ae}function O(){const ye=this.resume(),Ae=this.stack[this.stack.length-1];Ae.url=ye}function B(){const ye=this.resume(),Ae=this.stack[this.stack.length-1];Ae.title=ye}function W(){this.data.inReference=void 0}function P(){this.data.referenceType="collapsed"}function ee(ye){const Ae=this.resume(),Be=this.stack[this.stack.length-1];Be.label=Ae,Be.identifier=Sr(this.sliceSerialize(ye)).toLowerCase(),this.data.referenceType="full"}function X(ye){this.data.characterReferenceType=ye.type}function ne(ye){const Ae=this.sliceSerialize(ye),Be=this.data.characterReferenceType;let Ge;Be?(Ge=N1(Ae,Be==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Ge=Hp(Ae);const Xe=this.stack[this.stack.length-1];Xe.value+=Ge}function Y(ye){const Ae=this.stack.pop();Ae.position.end=Ms(ye.end)}function F(ye){$.call(this,ye);const Ae=this.stack[this.stack.length-1];Ae.url=this.sliceSerialize(ye)}function te(ye){$.call(this,ye);const Ae=this.stack[this.stack.length-1];Ae.url="mailto:"+this.sliceSerialize(ye)}function se(){return{type:"blockquote",children:[]}}function xe(){return{type:"code",lang:null,meta:null,value:""}}function le(){return{type:"inlineCode",value:""}}function Ee(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function ue(){return{type:"emphasis",children:[]}}function ae(){return{type:"heading",depth:0,children:[]}}function de(){return{type:"break"}}function oe(){return{type:"html",value:""}}function Ne(){return{type:"image",title:null,url:"",alt:null}}function ve(){return{type:"link",title:null,url:"",children:[]}}function re(ye){return{type:"list",ordered:ye.type==="listOrdered",start:null,spread:ye._spread,children:[]}}function _e(ye){return{type:"listItem",spread:ye._spread,checked:null,children:[]}}function He(){return{type:"paragraph",children:[]}}function et(){return{type:"strong",children:[]}}function rt(){return{type:"text",value:""}}function kt(){return{type:"thematicBreak"}}}function Ms(e){return{line:e.line,column:e.column,offset:e.offset}}function z1(e,t){let n=-1;for(;++n<t.length;){const s=t[n];Array.isArray(s)?z1(e,s):HR(e,s)}}function HR(e,t){let n;for(n in t)if(B1.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 Ov(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+cl({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+cl({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+cl({start:t.start,end:t.end})+") is still open")}function UR(e){const t=this;t.parser=n;function n(s){return zR(s,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function FR(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 VR(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
100
|
+
`}]}function GR(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 WR(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function qR(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function KR(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",s=String(t.identifier).toUpperCase(),a=Xa(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 YR(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 XR(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function $1(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 QR(e,t){const n=String(t.identifier).toUpperCase(),s=e.definitionById.get(n);if(!s)return $1(e,t);const a={src:Xa(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 JR(e,t){const n={src:Xa(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 ZR(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 eD(e,t){const n=String(t.identifier).toUpperCase(),s=e.definitionById.get(n);if(!s)return $1(e,t);const a={href:Xa(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 tD(e,t){const n={href:Xa(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 nD(e,t,n){const s=e.all(t),a=n?rD(n):H1(t),l={},u=[];if(typeof t.checked=="boolean"){const p=s[0];let m;p&&p.type==="element"&&p.tagName==="p"?m=p:(m={type:"element",tagName:"p",properties:{},children:[]},s.unshift(m)),m.children.length>0&&m.children.unshift({type:"text",value:" "}),m.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),l.className=["task-list-item"]}let c=-1;for(;++c<s.length;){const p=s[c];(a||c!==0||p.type!=="element"||p.tagName!=="p")&&u.push({type:"text",value:`
|
|
102
|
+
`}),p.type==="element"&&p.tagName==="p"&&!a?u.push(...p.children):u.push(p)}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 rD(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=H1(n[s])}return t}function H1(e){const t=e.spread;return t??e.children.length>1}function sD(e,t){const n={},s=e.all(t);let a=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++a<s.length;){const u=s[a];if(u.type==="element"&&u.tagName==="li"&&u.properties&&Array.isArray(u.properties.className)&&u.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const l={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(s,!0)};return e.patch(t,l),e.applyData(t,l)}function iD(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function aD(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function oD(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function lD(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=Mp(t.children[1]),d=b1(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 cD(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 m=t.children[d],x={},y=u?u[d]:void 0;y&&(x.align=y);let w={type:"element",tagName:l,properties:x,children:[]};m&&(w.children=e.all(m),e.patch(m,w),w=e.applyData(m,w)),f.push(w)}const p={type:"element",tagName:"tr",properties:{},children:e.wrap(f,!0)};return e.patch(t,p),e.applyData(t,p)}function uD(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const Iv=9,Mv=32;function dD(e){const t=String(e),n=/\r?\n|\r/g;let s=n.exec(t),a=0;const l=[];for(;s;)l.push(Pv(t.slice(a,s.index),a>0,!0),s[0]),a=s.index+s[0].length,s=n.exec(t);return l.push(Pv(t.slice(a),a>0,!1)),l.join("")}function Pv(e,t,n){let s=0,a=e.length;if(t){let l=e.codePointAt(s);for(;l===Iv||l===Mv;)s++,l=e.codePointAt(s)}if(n){let l=e.codePointAt(a-1);for(;l===Iv||l===Mv;)a--,l=e.codePointAt(a-1)}return a>s?e.slice(s,a):""}function hD(e,t){const n={type:"text",value:dD(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function fD(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const mD={blockquote:FR,break:VR,code:GR,delete:WR,emphasis:qR,footnoteReference:KR,heading:YR,html:XR,imageReference:QR,image:JR,inlineCode:ZR,linkReference:eD,link:tD,listItem:nD,list:sD,paragraph:iD,root:aD,strong:oD,table:lD,tableCell:uD,tableRow:cD,text:hD,thematicBreak:fD,toml:nu,yaml:nu,definition:nu,footnoteDefinition:nu};function nu(){}const U1=-1,id=0,dl=1,Tu=2,Fp=3,Vp=4,Gp=5,Wp=6,F1=7,V1=8,Bv=typeof self=="object"?self:globalThis,pD=(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 id:case U1:return n(u,a);case dl:{const c=n([],a);for(const d of u)c.push(s(d));return c}case Tu:{const c=n({},a);for(const[d,f]of u)c[s(d)]=s(f);return c}case Fp:return n(new Date(u),a);case Vp:{const{source:c,flags:d}=u;return n(new RegExp(c,d),a)}case Gp:{const c=n(new Map,a);for(const[d,f]of u)c.set(s(d),s(f));return c}case Wp:{const c=n(new Set,a);for(const d of u)c.add(s(d));return c}case F1:{const{name:c,message:d}=u;return n(new Bv[c](d),a)}case V1: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 Bv[l](u),a)};return s},zv=e=>pD(new Map,e)(0),Ea="",{toString:gD}={},{keys:xD}=Object,Zo=e=>{const t=typeof e;if(t!=="object"||!e)return[id,t];const n=gD.call(e).slice(8,-1);switch(n){case"Array":return[dl,Ea];case"Object":return[Tu,Ea];case"Date":return[Fp,Ea];case"RegExp":return[Vp,Ea];case"Map":return[Gp,Ea];case"Set":return[Wp,Ea];case"DataView":return[dl,n]}return n.includes("Array")?[dl,n]:n.includes("Error")?[F1,n]:[Tu,n]},ru=([e,t])=>e===id&&(t==="function"||t==="symbol"),yD=(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]=Zo(u);switch(c){case id:{let p=u;switch(d){case"bigint":c=V1,p=u.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+d);p=null;break;case"undefined":return a([U1],u)}return a([c,p],u)}case dl:{if(d){let x=u;return d==="DataView"?x=new Uint8Array(u.buffer):d==="ArrayBuffer"&&(x=new Uint8Array(u)),a([d,[...x]],u)}const p=[],m=a([c,p],u);for(const x of u)p.push(l(x));return m}case Tu:{if(d)switch(d){case"BigInt":return a([d,u.toString()],u);case"Boolean":case"Number":case"String":return a([d,u.valueOf()],u)}if(t&&"toJSON"in u)return l(u.toJSON());const p=[],m=a([c,p],u);for(const x of xD(u))(e||!ru(Zo(u[x])))&&p.push([l(x),l(u[x])]);return m}case Fp:return a([c,u.toISOString()],u);case Vp:{const{source:p,flags:m}=u;return a([c,{source:p,flags:m}],u)}case Gp:{const p=[],m=a([c,p],u);for(const[x,y]of u)(e||!(ru(Zo(x))||ru(Zo(y))))&&p.push([l(x),l(y)]);return m}case Wp:{const p=[],m=a([c,p],u);for(const x of u)(e||!ru(Zo(x)))&&p.push(l(x));return m}}const{message:f}=u;return a([c,{name:d,message:f}],u)};return l},$v=(e,{json:t,lossy:n}={})=>{const s=[];return yD(!(t||n),!!t,new Map,s)(e),s},Au=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?zv($v(e,t)):structuredClone(e):(e,t)=>zv($v(e,t));function _D(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 bD(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function vD(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||_D,s=e.options.footnoteBackLabel||bD,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 p=e.all(f),m=String(f.identifier).toUpperCase(),x=Xa(m.toLowerCase());let y=0;const w=[],C=e.footnoteCounts.get(m);for(;C!==void 0&&++y<=C;){w.length>0&&w.push({type:"text",value:" "});let v=typeof n=="string"?n:n(d,y);typeof v=="string"&&(v={type:"text",value:v}),w.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+x+(y>1?"-"+y:""),dataFootnoteBackref:"",ariaLabel:typeof s=="string"?s:s(d,y),className:["data-footnote-backref"]},children:Array.isArray(v)?v:[v]})}const b=p[p.length-1];if(b&&b.type==="element"&&b.tagName==="p"){const v=b.children[b.children.length-1];v&&v.type==="text"?v.value+=" ":b.children.push({type:"text",value:" "}),b.children.push(...w)}else p.push(...w);const S={type:"element",tagName:"li",properties:{id:t+"fn-"+x},children:e.wrap(p,!0)};e.patch(f,S),c.push(S)}if(c.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:l,properties:{...Au(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 ad=(function(e){if(e==null)return kD;if(typeof e=="function")return od(e);if(typeof e=="object")return Array.isArray(e)?SD(e):wD(e);if(typeof e=="string")return CD(e);throw new Error("Expected function, string, or object as test")});function SD(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=ad(e[n]);return od(s);function s(...a){let l=-1;for(;++l<t.length;)if(t[l].apply(this,a))return!0;return!1}}function wD(e){const t=e;return od(n);function n(s){const a=s;let l;for(l in e)if(a[l]!==t[l])return!1;return!0}}function CD(e){return od(t);function t(n){return n&&n.type===e}}function od(e){return t;function t(n,s,a){return!!(ED(n)&&e.call(this,n,typeof s=="number"?s:void 0,a||void 0))}}function kD(){return!0}function ED(e){return e!==null&&typeof e=="object"&&"type"in e}const G1=[],jD=!0,Xm=!1,ND="skip";function W1(e,t,n,s){let a;typeof t=="function"&&typeof n!="function"?(s=n,n=t):a=t;const l=ad(a),u=s?-1:1;c(e,void 0,[])();function c(d,f,p){const m=d&&typeof d=="object"?d:{};if(typeof m.type=="string"){const y=typeof m.tagName=="string"?m.tagName:typeof m.name=="string"?m.name:void 0;Object.defineProperty(x,"name",{value:"node ("+(d.type+(y?"<"+y+">":""))+")"})}return x;function x(){let y=G1,w,C,b;if((!t||l(d,f,p[p.length-1]||void 0))&&(y=TD(n(d,p)),y[0]===Xm))return y;if("children"in d&&d.children){const S=d;if(S.children&&y[0]!==ND)for(C=(s?S.children.length:-1)+u,b=p.concat(S);C>-1&&C<S.children.length;){const v=S.children[C];if(w=c(v,C,b)(),w[0]===Xm)return w;C=typeof w[1]=="number"?w[1]:C+u}}return y}}}function TD(e){return Array.isArray(e)?e:typeof e=="number"?[jD,e]:e==null?G1:[e]}function qp(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),W1(e,l,c,a);function c(d,f){const p=f[f.length-1],m=p?p.children.indexOf(d):void 0;return u(d,m,p)}}const Qm={}.hasOwnProperty,AD={};function LD(e,t){const n=t||AD,s=new Map,a=new Map,l=new Map,u={...mD,...n.handlers},c={all:f,applyData:DD,definitionById:s,footnoteById:a,footnoteCounts:l,footnoteOrder:[],handlers:u,one:d,options:n,patch:RD,wrap:ID};return qp(e,function(p){if(p.type==="definition"||p.type==="footnoteDefinition"){const m=p.type==="definition"?s:a,x=String(p.identifier).toUpperCase();m.has(x)||m.set(x,p)}}),c;function d(p,m){const x=p.type,y=c.handlers[x];if(Qm.call(c.handlers,x)&&y)return y(c,p,m);if(c.options.passThrough&&c.options.passThrough.includes(x)){if("children"in p){const{children:C,...b}=p,S=Au(b);return S.children=c.all(p),S}return Au(p)}return(c.options.unknownHandler||OD)(c,p,m)}function f(p){const m=[];if("children"in p){const x=p.children;let y=-1;for(;++y<x.length;){const w=c.one(x[y],p);if(w){if(y&&x[y-1].type==="break"&&(!Array.isArray(w)&&w.type==="text"&&(w.value=Hv(w.value)),!Array.isArray(w)&&w.type==="element")){const C=w.children[0];C&&C.type==="text"&&(C.value=Hv(C.value))}Array.isArray(w)?m.push(...w):m.push(w)}}}return m}}function RD(e,t){e.position&&(t.position=bA(e))}function DD(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,Au(l)),"children"in n&&n.children&&a!==null&&a!==void 0&&(n.children=a)}return n}function OD(e,t){const n=t.data||{},s="value"in t&&!(Qm.call(n,"hProperties")||Qm.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 ID(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 Hv(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function Uv(e,t){const n=LD(e,t),s=n.one(e,void 0),a=vD(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 MD(e,t){return e&&"run"in e?async function(n,s){const a=Uv(n,{file:s,...t});await e.run(a,s)}:function(n,s){return Uv(n,{file:s,...e||t})}}function Fv(e){if(e)throw e}var rm,Vv;function PD(){if(Vv)return rm;Vv=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,s=Object.getOwnPropertyDescriptor,a=function(f){return typeof Array.isArray=="function"?Array.isArray(f):t.call(f)==="[object Array]"},l=function(f){if(!f||t.call(f)!=="[object Object]")return!1;var p=e.call(f,"constructor"),m=f.constructor&&f.constructor.prototype&&e.call(f.constructor.prototype,"isPrototypeOf");if(f.constructor&&!p&&!m)return!1;var x;for(x in f);return typeof x>"u"||e.call(f,x)},u=function(f,p){n&&p.name==="__proto__"?n(f,p.name,{enumerable:!0,configurable:!0,value:p.newValue,writable:!0}):f[p.name]=p.newValue},c=function(f,p){if(p==="__proto__")if(e.call(f,p)){if(s)return s(f,p).value}else return;return f[p]};return rm=function d(){var f,p,m,x,y,w,C=arguments[0],b=1,S=arguments.length,v=!1;for(typeof C=="boolean"&&(v=C,C=arguments[1]||{},b=2),(C==null||typeof C!="object"&&typeof C!="function")&&(C={});b<S;++b)if(f=arguments[b],f!=null)for(p in f)m=c(C,p),x=c(f,p),C!==x&&(v&&x&&(l(x)||(y=a(x)))?(y?(y=!1,w=m&&a(m)?m:[]):w=m&&l(m)?m:{},u(C,{name:p,newValue:d(v,w,x)})):typeof x<"u"&&u(C,{name:p,newValue:x}));return C},rm}var BD=PD();const sm=Gu(BD);function Jm(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 zD(){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 p=e[++l];let m=-1;if(d){u(d);return}for(;++m<a.length;)(f[m]===null||f[m]===void 0)&&(f[m]=a[m]);a=f,p?$D(p,c)(...f):u(null,...f)}}function s(a){if(typeof a!="function")throw new TypeError("Expected `middelware` to be a function, not "+a);return e.push(a),t}}function $D(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 p=f;if(c&&n)throw p;return a(p)}c||(d&&d.then&&typeof d.then=="function"?d.then(l,a):d instanceof Error?a(d):l(d))}function a(u,...c){n||(n=!0,t(u,...c))}function l(u){a(null,u)}}const Rr={basename:HD,dirname:UD,extname:FD,join:VD,sep:"/"};function HD(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Rl(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 UD(e){if(Rl(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 FD(e){Rl(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 VD(...e){let t=-1,n;for(;++t<e.length;)Rl(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":GD(n)}function GD(e){Rl(e);const t=e.codePointAt(0)===47;let n=WD(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function WD(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 Rl(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const qD={cwd:KD};function KD(){return"/"}function Zm(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function YD(e){if(typeof e=="string")e=new URL(e);else if(!Zm(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 XD(e)}function XD(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 im=["history","path","basename","stem","extname","dirname"];class q1{constructor(t){let n;t?Zm(t)?n={path:t}:typeof t=="string"||QD(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":qD.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let s=-1;for(;++s<im.length;){const l=im[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)im.includes(a)||(this[a]=n[a])}get basename(){return typeof this.path=="string"?Rr.basename(this.path):void 0}set basename(t){om(t,"basename"),am(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){Gv(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(am(t,"extname"),Gv(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){Zm(t)&&(t=YD(t)),om(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){om(t,"stem"),am(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 Sn(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 am(e,t){if(e&&e.includes(Rr.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Rr.sep+"`")}function om(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function Gv(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function QD(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const JD=(function(e){const s=this.constructor.prototype,a=s[e],l=function(){return a.apply(l,arguments)};return Object.setPrototypeOf(l,s),l}),ZD={}.hasOwnProperty;class Kp extends JD{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=zD()}copy(){const t=new Kp;let n=-1;for(;++n<this.attachers.length;){const s=this.attachers[n];t.use(...s)}return t.data(sm(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(um("data",this.frozen),this.namespace[t]=n,this):ZD.call(this.namespace,t)&&this.namespace[t]||void 0:t?(um("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=su(t),s=this.parser||this.Parser;return lm("parse",s),s(String(n),n)}process(t,n){const s=this;return this.freeze(),lm("process",this.parser||this.Parser),cm("process",this.compiler||this.Compiler),n?a(void 0,n):new Promise(a);function a(l,u){const c=su(t),d=s.parse(c);s.run(d,c,function(p,m,x){if(p||!m||!x)return f(p);const y=m,w=s.stringify(y,x);n3(w)?x.value=w:x.result=w,f(p,x)});function f(p,m){p||!m?u(p):l?l(m):n(void 0,m)}}}processSync(t){let n=!1,s;return this.freeze(),lm("processSync",this.parser||this.Parser),cm("processSync",this.compiler||this.Compiler),this.process(t,a),qv("processSync","process",n),s;function a(l,u){n=!0,Fv(l),s=u}}run(t,n,s){Wv(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=su(n);a.run(t,d,f);function f(p,m,x){const y=m||t;p?c(p):u?u(y):s(void 0,y,x)}}}runSync(t,n){let s=!1,a;return this.run(t,n,l),qv("runSync","run",s),a;function l(u,c){Fv(u),a=c,s=!0}}stringify(t,n){this.freeze();const s=su(n),a=this.compiler||this.Compiler;return cm("stringify",a),Wv(t),a(t,s)}use(t,...n){const s=this.attachers,a=this.namespace;if(um("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[p,...m]=f;d(p,m)}else u(f);else throw new TypeError("Expected usable value, not `"+f+"`")}function u(f){if(!("plugins"in f)&&!("settings"in f))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");c(f.plugins),f.settings&&(a.settings=sm(!0,a.settings,f.settings))}function c(f){let p=-1;if(f!=null)if(Array.isArray(f))for(;++p<f.length;){const m=f[p];l(m)}else throw new TypeError("Expected a list of plugins, not `"+f+"`")}function d(f,p){let m=-1,x=-1;for(;++m<s.length;)if(s[m][0]===f){x=m;break}if(x===-1)s.push([f,...p]);else if(p.length>0){let[y,...w]=p;const C=s[x][1];Jm(C)&&Jm(y)&&(y=sm(!0,C,y)),s[x]=[f,y,...w]}}}}const e3=new Kp().freeze();function lm(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function cm(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function um(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 Wv(e){if(!Jm(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function qv(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function su(e){return t3(e)?e:new q1(e)}function t3(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function n3(e){return typeof e=="string"||r3(e)}function r3(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const s3="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",Kv=[],Yv={allowDangerousHtml:!0},i3=/^(https?|ircs?|mailto|xmpp)$/i,a3=[{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 o3(e){const t=l3(e),n=c3(e);return u3(t.runSync(t.parse(n),n),e)}function l3(e){const t=e.rehypePlugins||Kv,n=e.remarkPlugins||Kv,s=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Yv}:Yv;return e3().use(UR).use(n).use(MD,s).use(t)}function c3(e){const t=e.children||"",n=new q1;return typeof t=="string"&&(n.value=t),n}function u3(e,t){const n=t.allowedElements,s=t.allowElement,a=t.components,l=t.disallowedElements,u=t.skipHtml,c=t.unwrapDisallowed,d=t.urlTransform||d3;for(const p of a3)Object.hasOwn(t,p.from)&&(""+p.from+(p.to?"use `"+p.to+"` instead":"remove it")+s3+p.id,void 0);return qp(e,f),kA(e,{Fragment:o.Fragment,components:a,ignoreInvalidStyle:!0,jsx:o.jsx,jsxs:o.jsxs,passKeys:!0,passNode:!0});function f(p,m,x){if(p.type==="raw"&&x&&typeof m=="number")return u?x.children.splice(m,1):x.children[m]={type:"text",value:p.value},m;if(p.type==="element"){let y;for(y in em)if(Object.hasOwn(em,y)&&Object.hasOwn(p.properties,y)){const w=p.properties[y],C=em[y];(C===null||C.includes(p.tagName))&&(p.properties[y]=d(String(w||""),y,p))}}if(p.type==="element"){let y=n?!n.includes(p.tagName):l?l.includes(p.tagName):!1;if(!y&&s&&typeof m=="number"&&(y=!s(p,m,x)),y&&x&&typeof m=="number")return c&&p.children?x.children.splice(m,1,...p.children):x.children.splice(m,1),m}}}function d3(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||i3.test(e.slice(0,t))?e:""}function Xv(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 h3(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function f3(e,t,n){const a=ad((n||{}).ignore||[]),l=m3(t);let u=-1;for(;++u<l.length;)W1(e,"text",c);function c(f,p){let m=-1,x;for(;++m<p.length;){const y=p[m],w=x?x.children:void 0;if(a(y,w?w.indexOf(y):void 0,x))return;x=y}if(x)return d(f,p)}function d(f,p){const m=p[p.length-1],x=l[u][0],y=l[u][1];let w=0;const b=m.children.indexOf(f);let S=!1,v=[];x.lastIndex=0;let _=x.exec(f.value);for(;_;){const E=_.index,j={index:_.index,input:_.input,stack:[...p,f]};let T=y(..._,j);if(typeof T=="string"&&(T=T.length>0?{type:"text",value:T}:void 0),T===!1?x.lastIndex=E+1:(w!==E&&v.push({type:"text",value:f.value.slice(w,E)}),Array.isArray(T)?v.push(...T):T&&v.push(T),w=E+_[0].length,S=!0),!x.global)break;_=x.exec(f.value)}return S?(w<f.value.length&&v.push({type:"text",value:f.value.slice(w)}),m.children.splice(b,1,...v)):v=[f],b+v.length}}function m3(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([p3(a[0]),g3(a[1])])}return t}function p3(e){return typeof e=="string"?new RegExp(h3(e),"g"):e}function g3(e){return typeof e=="function"?e:function(){return e}}const dm="phrasing",hm=["autolink","link","image","label"];function x3(){return{transforms:[C3],enter:{literalAutolink:_3,literalAutolinkEmail:fm,literalAutolinkHttp:fm,literalAutolinkWww:fm},exit:{literalAutolink:w3,literalAutolinkEmail:S3,literalAutolinkHttp:b3,literalAutolinkWww:v3}}}function y3(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:dm,notInConstruct:hm},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:dm,notInConstruct:hm},{character:":",before:"[ps]",after:"\\/",inConstruct:dm,notInConstruct:hm}]}}function _3(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function fm(e){this.config.enter.autolinkProtocol.call(this,e)}function b3(e){this.config.exit.autolinkProtocol.call(this,e)}function v3(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 S3(e){this.config.exit.autolinkEmail.call(this,e)}function w3(e){this.exit(e)}function C3(e){f3(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,k3],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),E3]],{ignore:["link","linkReference"]})}function k3(e,t,n,s,a){let l="";if(!K1(a)||(/^w/i.test(t)&&(n=t+n,t="",l="http://"),!j3(n)))return!1;const u=N3(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 E3(e,t,n,s){return!K1(s,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function j3(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 N3(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=Xv(e,"(");let l=Xv(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 K1(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||Ai(n)||rd(n))&&(!t||n!==47)}Y1.peek=P3;function T3(){this.buffer()}function A3(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function L3(){this.buffer()}function R3(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function D3(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 O3(e){this.exit(e)}function I3(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 M3(e){this.exit(e)}function P3(){return"["}function Y1(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:T3,gfmFootnoteCall:A3,gfmFootnoteDefinitionLabelString:L3,gfmFootnoteDefinition:R3},exit:{gfmFootnoteCallString:D3,gfmFootnoteCall:O3,gfmFootnoteDefinitionLabelString:I3,gfmFootnoteDefinition:M3}}}function z3(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:Y1},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"),p=l.enter("label");return d+=c.move(l.safe(l.associationId(s),{before:d,after:"]"})),p(),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?X1:$3))),f(),d}}function $3(e,t,n){return t===0?e:X1(e,t,n)}function X1(e,t,n){return(n?"":" ")+e}const H3=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];Q1.peek=W3;function U3(){return{canContainEols:["delete"],enter:{strikethrough:V3},exit:{strikethrough:G3}}}function F3(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:H3}],handlers:{delete:Q1}}}function V3(e){this.enter({type:"delete",children:[]},e)}function G3(e){this.exit(e)}function Q1(e,t,n,s){const a=n.createTracker(s),l=n.enter("strikethrough");let u=a.move("~~");return u+=n.containerPhrasing(e,{...a.current(),before:u,after:"~"}),u+=a.move("~~"),l(),u}function W3(){return"~"}function q3(e){return e.length}function K3(e,t){const n=t||{},s=(n.align||[]).concat(),a=n.stringLength||q3,l=[],u=[],c=[],d=[];let f=0,p=-1;for(;++p<e.length;){const C=[],b=[];let S=-1;for(e[p].length>f&&(f=e[p].length);++S<e[p].length;){const v=Y3(e[p][S]);if(n.alignDelimiters!==!1){const _=a(v);b[S]=_,(d[S]===void 0||_>d[S])&&(d[S]=_)}C.push(v)}u[p]=C,c[p]=b}let m=-1;if(typeof s=="object"&&"length"in s)for(;++m<f;)l[m]=Qv(s[m]);else{const C=Qv(s);for(;++m<f;)l[m]=C}m=-1;const x=[],y=[];for(;++m<f;){const C=l[m];let b="",S="";C===99?(b=":",S=":"):C===108?b=":":C===114&&(S=":");let v=n.alignDelimiters===!1?1:Math.max(1,d[m]-b.length-S.length);const _=b+"-".repeat(v)+S;n.alignDelimiters!==!1&&(v=b.length+v+S.length,v>d[m]&&(d[m]=v),y[m]=v),x[m]=_}u.splice(1,0,x),c.splice(1,0,y),p=-1;const w=[];for(;++p<u.length;){const C=u[p],b=c[p];m=-1;const S=[];for(;++m<f;){const v=C[m]||"";let _="",E="";if(n.alignDelimiters!==!1){const j=d[m]-(b[m]||0),T=l[m];T===114?_=" ".repeat(j):T===99?j%2?(_=" ".repeat(j/2+.5),E=" ".repeat(j/2-.5)):(_=" ".repeat(j/2),E=_):E=" ".repeat(j)}n.delimiterStart!==!1&&!m&&S.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&v==="")&&(n.delimiterStart!==!1||m)&&S.push(" "),n.alignDelimiters!==!1&&S.push(_),S.push(v),n.alignDelimiters!==!1&&S.push(E),n.padding!==!1&&S.push(" "),(n.delimiterEnd!==!1||m!==f-1)&&S.push("|")}w.push(n.delimiterEnd===!1?S.join("").replace(/ +$/,""):S.join(""))}return w.join(`
|
|
111
|
+
`)}function Y3(e){return e==null?"":String(e)}function Qv(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 X3(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()),Q3);return a(),u}function Q3(e,t,n){return">"+(n?"":" ")+e}function J3(e,t){return Jv(e,t.inConstruct,!0)&&!Jv(e,t.notInConstruct,!1)}function Jv(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 Zv(e,t,n,s){let a=-1;for(;++a<n.unsafe.length;)if(n.unsafe[a].character===`
|
|
112
|
+
`&&J3(n.stack,n.unsafe[a]))return/[ \t]/.test(s.before)?"":" ";return`\\
|
|
113
|
+
`}function Z3(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 e5(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 t5(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 n5(e,t,n,s){const a=t5(n),l=e.value||"",u=a==="`"?"GraveAccent":"Tilde";if(e5(e,n)){const m=n.enter("codeIndented"),x=n.indentLines(l,r5);return m(),x}const c=n.createTracker(s),d=a.repeat(Math.max(Z3(l,a)+1,3)),f=n.enter("codeFenced");let p=c.move(d);if(e.lang){const m=n.enter(`codeFencedLang${u}`);p+=c.move(n.safe(e.lang,{before:p,after:" ",encode:["`"],...c.current()})),m()}if(e.lang&&e.meta){const m=n.enter(`codeFencedMeta${u}`);p+=c.move(" "),p+=c.move(n.safe(e.meta,{before:p,after:`
|
|
114
|
+
`,encode:["`"],...c.current()})),m()}return p+=c.move(`
|
|
115
|
+
`),l&&(p+=c.move(l+`
|
|
116
|
+
`)),p+=c.move(d),f(),p}function r5(e,t,n){return(n?"":" ")+e}function Yp(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 s5(e,t,n,s){const a=Yp(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 i5(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 yl(e){return"&#x"+e.toString(16).toUpperCase()+";"}function Lu(e,t,n){const s=Ha(e),a=Ha(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}}J1.peek=a5;function J1(e,t,n,s){const a=i5(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),p=Lu(s.before.charCodeAt(s.before.length-1),f,a);p.inside&&(d=yl(f)+d.slice(1));const m=d.charCodeAt(d.length-1),x=Lu(s.after.charCodeAt(0),m,a);x.inside&&(d=d.slice(0,-1)+yl(m));const y=u.move(a);return l(),n.attentionEncodeSurroundingInfo={after:x.outside,before:p.outside},c+d+y}function a5(e,t,n){return n.options.emphasis||"*"}function o5(e,t){let n=!1;return qp(e,function(s){if("value"in s&&/\r?\n|\r/.test(s.value)||s.type==="break")return n=!0,Xm}),!!((!e.depth||e.depth<3)&&$p(e)&&(t.options.setext||n))}function l5(e,t,n,s){const a=Math.max(Math.min(6,e.depth||1),1),l=n.createTracker(s);if(o5(e,n)){const p=n.enter("headingSetext"),m=n.enter("phrasing"),x=n.containerPhrasing(e,{...l.current(),before:`
|
|
118
|
+
`,after:`
|
|
119
|
+
`});return m(),p(),x+`
|
|
120
|
+
`+(a===1?"=":"-").repeat(x.length-(Math.max(x.lastIndexOf("\r"),x.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=yl(f.charCodeAt(0))+f.slice(1)),f=f?u+" "+f:u,n.options.closeAtx&&(f+=" "+u),d(),c(),f}Z1.peek=c5;function Z1(e){return e.value||""}function c5(){return"<"}ew.peek=u5;function ew(e,t,n,s){const a=Yp(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 u5(){return"!"}tw.peek=d5;function tw(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 p=n.stack;n.stack=[],u=n.enter("reference");const m=n.safe(n.associationId(e),{before:d,after:"]",...c.current()});return u(),n.stack=p,l(),a==="full"||!f||f!==m?d+=c.move(m+"]"):a==="shortcut"?d=d.slice(0,-1):d+=c.move("]"),d}function d5(){return"!"}nw.peek=h5;function nw(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 h5(){return"`"}function rw(e,t){const n=$p(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))}sw.peek=f5;function sw(e,t,n,s){const a=Yp(n),l=a==='"'?"Quote":"Apostrophe",u=n.createTracker(s);let c,d;if(rw(e,n)){const p=n.stack;n.stack=[],c=n.enter("autolink");let m=u.move("<");return m+=u.move(n.containerPhrasing(e,{before:m,after:">",...u.current()})),m+=u.move(">"),c(),n.stack=p,m}c=n.enter("link"),d=n.enter("label");let 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 f5(e,t,n){return rw(e,n)?"<":"["}iw.peek=m5;function iw(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 p=n.stack;n.stack=[],u=n.enter("reference");const m=n.safe(n.associationId(e),{before:d,after:"]",...c.current()});return u(),n.stack=p,l(),a==="full"||!f||f!==m?d+=c.move(m+"]"):a==="shortcut"?d=d.slice(0,-1):d+=c.move("]"),d}function m5(){return"["}function Xp(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 p5(e){const t=Xp(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 g5(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 aw(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 x5(e,t,n,s){const a=n.enter("list"),l=n.bulletCurrent;let u=e.ordered?g5(n):Xp(n);const c=e.ordered?u==="."?")":".":p5(n);let d=t&&n.bulletLastUsed?u===n.bulletLastUsed:!1;if(!e.ordered){const p=e.children?e.children[0]:void 0;if((u==="*"||u==="-")&&p&&(!p.children||!p.children[0])&&n.stack[n.stack.length-1]==="list"&&n.stack[n.stack.length-2]==="listItem"&&n.stack[n.stack.length-3]==="list"&&n.stack[n.stack.length-4]==="listItem"&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(d=!0),aw(n)===u&&p){let m=-1;for(;++m<e.children.length;){const x=e.children[m];if(x&&x.type==="listItem"&&x.children&&x.children[0]&&x.children[0].type==="thematicBreak"){d=!0;break}}}}d&&(u=c),n.bulletCurrent=u;const f=n.containerFlow(e,s);return n.bulletLastUsed=u,n.bulletCurrent=l,a(),f}function y5(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 _5(e,t,n,s){const a=y5(n);let l=n.bulletCurrent||Xp(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()),p);return d(),f;function p(m,x,y){return x?(y?"":" ".repeat(u))+m:(y?l:l+" ".repeat(u-l.length))+m}}function b5(e,t,n,s){const a=n.enter("paragraph"),l=n.enter("phrasing"),u=n.containerPhrasing(e,s);return l(),a(),u}const v5=ad(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function S5(e,t,n,s){return(e.children.some(function(u){return v5(u)})?n.containerPhrasing:n.containerFlow).call(n,e,s)}function w5(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}ow.peek=C5;function ow(e,t,n,s){const a=w5(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),p=Lu(s.before.charCodeAt(s.before.length-1),f,a);p.inside&&(d=yl(f)+d.slice(1));const m=d.charCodeAt(d.length-1),x=Lu(s.after.charCodeAt(0),m,a);x.inside&&(d=d.slice(0,-1)+yl(m));const y=u.move(a+a);return l(),n.attentionEncodeSurroundingInfo={after:x.outside,before:p.outside},c+d+y}function C5(e,t,n){return n.options.strong||"*"}function k5(e,t,n,s){return n.safe(e.value,s)}function E5(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 j5(e,t,n){const s=(aw(n)+(n.options.ruleSpaces?" ":"")).repeat(E5(n));return n.options.ruleSpaces?s.slice(0,-1):s}const lw={blockquote:X3,break:Zv,code:n5,definition:s5,emphasis:J1,hardBreak:Zv,heading:l5,html:Z1,image:ew,imageReference:tw,inlineCode:nw,link:sw,linkReference:iw,list:x5,listItem:_5,paragraph:b5,root:S5,strong:ow,text:k5,thematicBreak:j5};function N5(){return{enter:{table:T5,tableData:e0,tableHeader:e0,tableRow:L5},exit:{codeText:R5,table:A5,tableData:mm,tableHeader:mm,tableRow:mm}}}function T5(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 A5(e){this.exit(e),this.data.inTable=void 0}function L5(e){this.enter({type:"tableRow",children:[]},e)}function mm(e){this.exit(e)}function e0(e){this.enter({type:"tableCell",children:[]},e)}function R5(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,D5));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function D5(e,t){return t==="|"?t:e}function O5(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:x,table:u,tableCell:d,tableRow:c}};function u(y,w,C,b){return f(p(y,C,b),y.align)}function c(y,w,C,b){const S=m(y,C,b),v=f([S]);return v.slice(0,v.indexOf(`
|
|
124
|
+
`))}function d(y,w,C,b){const S=C.enter("tableCell"),v=C.enter("phrasing"),_=C.containerPhrasing(y,{...b,before:l,after:l});return v(),S(),_}function f(y,w){return K3(y,{align:w,alignDelimiters:s,padding:n,stringLength:a})}function p(y,w,C){const b=y.children;let S=-1;const v=[],_=w.enter("table");for(;++S<b.length;)v[S]=m(b[S],w,C);return _(),v}function m(y,w,C){const b=y.children;let S=-1;const v=[],_=w.enter("tableRow");for(;++S<b.length;)v[S]=d(b[S],y,w,C);return _(),v}function x(y,w,C){let b=lw.inlineCode(y,w,C);return C.stack.includes("tableCell")&&(b=b.replace(/\|/g,"\\$&")),b}}function I5(){return{exit:{taskListCheckValueChecked:t0,taskListCheckValueUnchecked:t0,paragraph:P5}}}function M5(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:B5}}}function t0(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function P5(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=lw.listItem(e,t,n,{...s,...c.current()});return l&&(d=d.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,f)),d;function f(p){return p+u}}function z5(){return[x3(),B3(),U3(),N5(),I5()]}function $5(e){return{extensions:[y3(),z3(e),F3(),O5(e),M5()]}}const H5={tokenize:q5,partial:!0},cw={tokenize:K5,partial:!0},uw={tokenize:Y5,partial:!0},dw={tokenize:X5,partial:!0},U5={tokenize:Q5,partial:!0},hw={name:"wwwAutolink",tokenize:G5,previous:mw},fw={name:"protocolAutolink",tokenize:W5,previous:pw},ds={name:"emailAutolink",tokenize:V5,previous:gw},Pr={};function F5(){return{text:Pr}}let pi=48;for(;pi<123;)Pr[pi]=ds,pi++,pi===58?pi=65:pi===91&&(pi=97);Pr[43]=ds;Pr[45]=ds;Pr[46]=ds;Pr[95]=ds;Pr[72]=[ds,fw];Pr[104]=[ds,fw];Pr[87]=[ds,hw];Pr[119]=[ds,hw];function V5(e,t,n){const s=this;let a,l;return u;function u(m){return!ep(m)||!gw.call(s,s.previous)||Qp(s.events)?n(m):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),c(m))}function c(m){return ep(m)?(e.consume(m),c):m===64?(e.consume(m),d):n(m)}function d(m){return m===46?e.check(U5,p,f)(m):m===45||m===95||vn(m)?(l=!0,e.consume(m),d):p(m)}function f(m){return e.consume(m),a=!0,d}function p(m){return l&&a&&kn(s.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(m)):n(m)}}function G5(e,t,n){const s=this;return a;function a(u){return u!==87&&u!==119||!mw.call(s,s.previous)||Qp(s.events)?n(u):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(H5,e.attempt(cw,e.attempt(uw,l),n),n)(u))}function l(u){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(u)}}function W5(e,t,n){const s=this;let a="",l=!1;return u;function u(m){return(m===72||m===104)&&pw.call(s,s.previous)&&!Qp(s.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),a+=String.fromCodePoint(m),e.consume(m),c):n(m)}function c(m){if(kn(m)&&a.length<5)return a+=String.fromCodePoint(m),e.consume(m),c;if(m===58){const x=a.toLowerCase();if(x==="http"||x==="https")return e.consume(m),d}return n(m)}function d(m){return m===47?(e.consume(m),l?f:(l=!0,d)):n(m)}function f(m){return m===null||Nu(m)||Nt(m)||Ai(m)||rd(m)?n(m):e.attempt(cw,e.attempt(uw,p),n)(m)}function p(m){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(m)}}function q5(e,t,n){let s=0;return a;function a(u){return(u===87||u===119)&&s<3?(s++,e.consume(u),a):u===46&&s===3?(e.consume(u),l):n(u)}function l(u){return u===null?n(u):t(u)}}function K5(e,t,n){let s,a,l;return u;function u(f){return f===46||f===95?e.check(dw,d,c)(f):f===null||Nt(f)||Ai(f)||f!==45&&rd(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 Y5(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(dw,t,l)(u):u===null||Nt(u)||Ai(u)?t(u):(e.consume(u),a)}function l(u){return u===41&&s++,e.consume(u),a}}function X5(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||Nt(c)||Ai(c)?t(c):n(c)}function a(c){return c===null||c===40||c===91||Nt(c)||Ai(c)?t(c):s(c)}function l(c){return kn(c)?u(c):n(c)}function u(c){return c===59?(e.consume(c),s):kn(c)?(e.consume(c),u):n(c)}}function Q5(e,t,n){return s;function s(l){return e.consume(l),a}function a(l){return vn(l)?n(l):t(l)}}function mw(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Nt(e)}function pw(e){return!kn(e)}function gw(e){return!(e===47||ep(e))}function ep(e){return e===43||e===45||e===46||e===95||vn(e)}function Qp(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 J5={tokenize:aO,partial:!0};function Z5(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:rO,continuation:{tokenize:sO},exit:iO}},text:{91:{name:"gfmFootnoteCall",tokenize:nO},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:eO,resolveTo:tO}}}}function eO(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 tO(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 nO(e,t,n){const s=this,a=s.parser.gfmFootnotes||(s.parser.gfmFootnotes=[]);let l=0,u;return c;function c(m){return e.enter("gfmFootnoteCall"),e.enter("gfmFootnoteCallLabelMarker"),e.consume(m),e.exit("gfmFootnoteCallLabelMarker"),d}function d(m){return m!==94?n(m):(e.enter("gfmFootnoteCallMarker"),e.consume(m),e.exit("gfmFootnoteCallMarker"),e.enter("gfmFootnoteCallString"),e.enter("chunkString").contentType="string",f)}function f(m){if(l>999||m===93&&!u||m===null||m===91||Nt(m))return n(m);if(m===93){e.exit("chunkString");const x=e.exit("gfmFootnoteCallString");return a.includes(Sr(s.sliceSerialize(x)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(m),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(m)}return Nt(m)||(u=!0),l++,e.consume(m),m===92?p:f}function p(m){return m===91||m===92||m===93?(e.consume(m),l++,f):f(m)}}function rO(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",p):n(w)}function p(w){if(u>999||w===93&&!c||w===null||w===91||Nt(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"),x}return Nt(w)||(c=!0),u++,e.consume(w),w===92?m:p}function m(w){return w===91||w===92||w===93?(e.consume(w),u++,p):p(w)}function x(w){return w===58?(e.enter("definitionMarker"),e.consume(w),e.exit("definitionMarker"),a.includes(l)||a.push(l),ut(e,y,"gfmFootnoteDefinitionWhitespace")):n(w)}function y(w){return t(w)}}function sO(e,t,n){return e.check(Ll,t,e.attempt(J5,t,n))}function iO(e){e.exit("gfmFootnoteDefinition")}function aO(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 oO(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 p={type:"strikethrough",start:Object.assign({},u[f][1].start),end:Object.assign({},u[d][1].end)},m={type:"strikethroughText",start:Object.assign({},u[f][1].end),end:Object.assign({},u[d][1].start)},x=[["enter",p,c],["enter",u[f][1],c],["exit",u[f][1],c],["enter",m,c]],y=c.parser.constructs.insideSpan.null;y&&Kn(x,x.length,0,sd(y,u.slice(f+1,d),c)),Kn(x,x.length,0,[["exit",m,c],["enter",u[d][1],c],["exit",u[d][1],c],["exit",p,c]]),Kn(u,f-1,d-f+3,x),d=f+x.length-2;break}}for(d=-1;++d<u.length;)u[d][1].type==="strikethroughSequenceTemporary"&&(u[d][1].type="data");return u}function l(u,c,d){const f=this.previous,p=this.events;let m=0;return x;function x(w){return f===126&&p[p.length-1][1].type!=="characterEscape"?d(w):(u.enter("strikethroughSequenceTemporary"),y(w))}function y(w){const C=Ha(f);if(w===126)return m>1?d(w):(u.consume(w),m++,y);if(m<2&&!n)return d(w);const b=u.exit("strikethroughSequenceTemporary"),S=Ha(w);return b._open=!S||S===2&&!!C,b._close=!C||C===2&&!!S,c(w)}}}class lO{constructor(){this.map=[]}add(t,n,s){cO(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 cO(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 uO(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 dO(){return{flow:{null:{name:"table",tokenize:hO,resolveAll:fO}}}}function hO(e,t,n){const s=this;let a=0,l=0,u;return c;function c($){let q=s.events.length-1;for(;q>-1;){const U=s.events[q][1].type;if(U==="lineEnding"||U==="linePrefix")q--;else break}const G=q>-1?s.events[q][1].type:null,I=G==="tableHead"||G==="tableRow"?T:d;return I===T&&s.parser.lazy[s.now().line]?n($):I($)}function d($){return e.enter("tableHead"),e.enter("tableRow"),f($)}function f($){return $===124||(u=!0,l+=1),p($)}function p($){return $===null?n($):Ue($)?l>1?(l=0,s.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume($),e.exit("lineEnding"),y):n($):at($)?ut(e,p,"whitespace")($):(l+=1,u&&(u=!1,a+=1),$===124?(e.enter("tableCellDivider"),e.consume($),e.exit("tableCellDivider"),u=!0,p):(e.enter("data"),m($)))}function m($){return $===null||$===124||Nt($)?(e.exit("data"),p($)):(e.consume($),$===92?x:m)}function x($){return $===92||$===124?(e.consume($),m):m($)}function y($){return s.interrupt=!1,s.parser.lazy[s.now().line]?n($):(e.enter("tableDelimiterRow"),u=!1,at($)?ut(e,w,"linePrefix",s.parser.constructs.disable.null.includes("codeIndented")?void 0:4)($):w($))}function w($){return $===45||$===58?b($):$===124?(u=!0,e.enter("tableCellDivider"),e.consume($),e.exit("tableCellDivider"),C):j($)}function C($){return at($)?ut(e,b,"whitespace")($):b($)}function b($){return $===58?(l+=1,u=!0,e.enter("tableDelimiterMarker"),e.consume($),e.exit("tableDelimiterMarker"),S):$===45?(l+=1,S($)):$===null||Ue($)?E($):j($)}function S($){return $===45?(e.enter("tableDelimiterFiller"),v($)):j($)}function v($){return $===45?(e.consume($),v):$===58?(u=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume($),e.exit("tableDelimiterMarker"),_):(e.exit("tableDelimiterFiller"),_($))}function _($){return at($)?ut(e,E,"whitespace")($):E($)}function E($){return $===124?w($):$===null||Ue($)?!u||a!==l?j($):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t($)):j($)}function j($){return n($)}function T($){return e.enter("tableRow"),R($)}function R($){return $===124?(e.enter("tableCellDivider"),e.consume($),e.exit("tableCellDivider"),R):$===null||Ue($)?(e.exit("tableRow"),t($)):at($)?ut(e,R,"whitespace")($):(e.enter("data"),A($))}function A($){return $===null||$===124||Nt($)?(e.exit("data"),R($)):(e.consume($),$===92?D:A)}function D($){return $===92||$===124?(e.consume($),A):A($)}}function fO(e,t){let n=-1,s=!0,a=0,l=[0,0,0,0],u=[0,0,0,0],c=!1,d=0,f,p,m;const x=new lO;for(;++n<e.length;){const y=e[n],w=y[1];y[0]==="enter"?w.type==="tableHead"?(c=!1,d!==0&&(n0(x,t,d,f,p),p=void 0,d=0),f={type:"table",start:Object.assign({},w.start),end:Object.assign({},w.end)},x.add(n,0,[["enter",f,t]])):w.type==="tableRow"||w.type==="tableDelimiterRow"?(s=!0,m=void 0,l=[0,0,0,0],u=[0,n+1,0,0],c&&(c=!1,p={type:"tableBody",start:Object.assign({},w.start),end:Object.assign({},w.end)},x.add(n,0,[["enter",p,t]])),a=w.type==="tableDelimiterRow"?2:p?3:1):a&&(w.type==="data"||w.type==="tableDelimiterMarker"||w.type==="tableDelimiterFiller")?(s=!1,u[2]===0&&(l[1]!==0&&(u[0]=u[1],m=iu(x,t,l,a,void 0,m),l=[0,0,0,0]),u[2]=n)):w.type==="tableCellDivider"&&(s?s=!1:(l[1]!==0&&(u[0]=u[1],m=iu(x,t,l,a,void 0,m)),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],m=iu(x,t,l,a,n,m)):u[1]!==0&&(m=iu(x,t,u,a,n,m)),a=0):a&&(w.type==="data"||w.type==="tableDelimiterMarker"||w.type==="tableDelimiterFiller")&&(u[3]=n)}for(d!==0&&n0(x,t,d,f,p),x.consume(t.events),n=-1;++n<t.events.length;){const y=t.events[n];y[0]==="enter"&&y[1].type==="table"&&(y[1]._align=uO(t.events,n))}return e}function iu(e,t,n,s,a,l){const u=s===1?"tableHeader":s===2?"tableDelimiter":"tableData",c="tableContent";n[0]!==0&&(l.end=Object.assign({},Oa(t.events,n[0])),e.add(n[0],0,[["exit",l,t]]));const d=Oa(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=Oa(t.events,n[2]),p=Oa(t.events,n[3]),m={type:c,start:Object.assign({},f),end:Object.assign({},p)};if(e.add(n[2],0,[["enter",m,t]]),s!==2){const x=t.events[n[2]],y=t.events[n[3]];if(x[1].end=Object.assign({},y[1].end),x[1].type="chunkText",x[1].contentType="text",n[3]>n[2]+1){const w=n[2]+1,C=n[3]-n[2]-1;e.add(w,C,[])}}e.add(n[3]+1,0,[["exit",m,t]])}return a!==void 0&&(l.end=Object.assign({},Oa(t.events,a)),e.add(a,0,[["exit",l,t]]),l=void 0),l}function n0(e,t,n,s,a){const l=[],u=Oa(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 Oa(e,t){const n=e[t],s=n[0]==="enter"?"start":"end";return n[1][s]}const mO={name:"tasklistCheck",tokenize:gO};function pO(){return{text:{91:mO}}}function gO(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 Nt(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 Ue(d)?t(d):at(d)?e.check({tokenize:xO},t,n)(d):n(d)}}function xO(e,t,n){return ut(e,s,"whitespace");function s(a){return a===null?n(a):t(a)}}function yO(e){return j1([F5(),Z5(),oO(e),dO(),pO()])}const _O={};function bO(e){const t=this,n=e||_O,s=t.data(),a=s.micromarkExtensions||(s.micromarkExtensions=[]),l=s.fromMarkdownExtensions||(s.fromMarkdownExtensions=[]),u=s.toMarkdownExtensions||(s.toMarkdownExtensions=[]);a.push(yO(n)),l.push(z5()),u.push($5(n))}var tp=Object.defineProperty,vO=Object.getOwnPropertyDescriptor,SO=Object.getOwnPropertyNames,wO=Object.prototype.hasOwnProperty,Jp=(e,t)=>{let n={};for(var s in e)tp(n,s,{get:e[s],enumerable:!0});return tp(n,Symbol.toStringTag,{value:"Module"}),n},CO=(e,t,n,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(var a=SO(t),l=0,u=a.length,c;l<u;l++)c=a[l],!wO.call(e,c)&&c!==n&&tp(e,c,{get:(d=>t[d]).bind(null,c),enumerable:!(s=vO(t,c))||s.enumerable});return e},xw=(e,t,n)=>(CO(e,t,"default"),n);const ld=[{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"),[]))}],Zp=Object.fromEntries(ld.map(e=>[e.id,e.import])),eg=Object.fromEntries(ld.flatMap(e=>{var t;return((t=e.aliases)==null?void 0:t.map(n=>[n,e.import]))||[]})),cd={...Zp,...eg},tg=[{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"),[]))}],ng=Object.fromEntries(tg.map(e=>[e.id,e.import]));var rg=class extends Error{constructor(t){super(t),this.name="ShikiError"}};function kO(){return 2147483648}function EO(){return typeof performance<"u"?performance.now():Date.now()}const jO=(e,t)=>e+(t-e%t)%t;async function NO(e){let t,n;const s={};function a(y){n=y,s.HEAPU8=new Uint8Array(y),s.HEAPU32=new Uint32Array(y)}function l(y,w,C){s.HEAPU8.copyWithin(y,w,w+C)}function u(y){try{return t.grow(y-n.byteLength+65535>>>16),a(t.buffer),1}catch{}}function c(y){const w=s.HEAPU8.length;y=y>>>0;const C=kO();if(y>C)return!1;for(let b=1;b<=4;b*=2){let S=w*(1+.2/b);S=Math.min(S,y+100663296);const v=Math.min(C,jO(Math.max(y,S),65536));if(u(v))return!0}return!1}const d=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function f(y,w,C=1024){const b=w+C;let S=w;for(;y[S]&&!(S>=b);)++S;if(S-w>16&&y.buffer&&d)return d.decode(y.subarray(w,S));let v="";for(;w<S;){let _=y[w++];if(!(_&128)){v+=String.fromCharCode(_);continue}const E=y[w++]&63;if((_&224)===192){v+=String.fromCharCode((_&31)<<6|E);continue}const j=y[w++]&63;if((_&240)===224?_=(_&15)<<12|E<<6|j:_=(_&7)<<18|E<<12|j<<6|y[w++]&63,_<65536)v+=String.fromCharCode(_);else{const T=_-65536;v+=String.fromCharCode(55296|T>>10,56320|T&1023)}}return v}function p(y,w){return y?f(s.HEAPU8,y,w):""}const m={emscripten_get_now:EO,emscripten_memcpy_big:l,emscripten_resize_heap:c,fd_write:()=>0};async function x(){const w=await e({env:m,wasi_snapshot_preview1:m});t=w.memory,a(t.buffer),Object.assign(s,w),s.UTF8ToString=p}return await x(),s}var TO=Object.defineProperty,AO=(e,t,n)=>t in e?TO(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,rn=(e,t,n)=>AO(e,typeof t!="symbol"?t+"":t,n);let cn=null;function LO(e){throw new rg(e.UTF8ToString(e.getLastOnigError()))}class ud{constructor(t){rn(this,"utf16Length"),rn(this,"utf8Length"),rn(this,"utf16Value"),rn(this,"utf8Value"),rn(this,"utf16OffsetToUtf8"),rn(this,"utf8OffsetToUtf16");const n=t.length,s=ud._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 p=t.charCodeAt(f);let m=p,x=!1;if(p>=55296&&p<=56319&&f+1<n){const y=t.charCodeAt(f+1);y>=56320&&y<=57343&&(m=(p-55296<<10)+65536|y-56320,x=!0)}a&&(l[f]=d,x&&(l[f+1]=d),m<=127?u[d+0]=f:m<=2047?(u[d+0]=f,u[d+1]=f):m<=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)),m<=127?c[d++]=m:m<=2047?(c[d++]=192|(m&1984)>>>6,c[d++]=128|(m&63)>>>0):m<=65535?(c[d++]=224|(m&61440)>>>12,c[d++]=128|(m&4032)>>>6,c[d++]=128|(m&63)>>>0):(c[d++]=240|(m&1835008)>>>18,c[d++]=128|(m&258048)>>>12,c[d++]=128|(m&4032)>>>6,c[d++]=128|(m&63)>>>0),x&&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 dd=class Ar{constructor(t){if(rn(this,"id",++Ar.LAST_ID),rn(this,"_onigBinding"),rn(this,"content"),rn(this,"utf16Length"),rn(this,"utf8Length"),rn(this,"utf16OffsetToUtf8"),rn(this,"utf8OffsetToUtf16"),rn(this,"ptr"),!cn)throw new rg("Must invoke loadWasm first.");this._onigBinding=cn,this.content=t;const n=new ud(t);this.utf16Length=n.utf16Length,this.utf8Length=n.utf8Length,this.utf16OffsetToUtf8=n.utf16OffsetToUtf8,this.utf8OffsetToUtf16=n.utf8OffsetToUtf16,this.utf8Length<1e4&&!Ar._sharedPtrInUse?(Ar._sharedPtr||(Ar._sharedPtr=cn.omalloc(1e4)),Ar._sharedPtrInUse=!0,cn.HEAPU8.set(n.utf8Value,Ar._sharedPtr),this.ptr=Ar._sharedPtr):this.ptr=n.createString(cn)}convertUtf8OffsetToUtf16(t){return this.utf8OffsetToUtf16?t<0?0:t>this.utf8Length?this.utf16Length:this.utf8OffsetToUtf16[t]:t}convertUtf16OffsetToUtf8(t){return this.utf16OffsetToUtf8?t<0?0:t>this.utf16Length?this.utf8Length:this.utf16OffsetToUtf8[t]:t}dispose(){this.ptr===Ar._sharedPtr?Ar._sharedPtrInUse=!1:this._onigBinding.ofree(this.ptr)}};rn(dd,"LAST_ID",0);rn(dd,"_sharedPtr",0);rn(dd,"_sharedPtrInUse",!1);let yw=dd;class RO{constructor(t){if(rn(this,"_onigBinding"),rn(this,"_ptr"),!cn)throw new rg("Must invoke loadWasm first.");const n=[],s=[];for(let c=0,d=t.length;c<d;c++){const f=new ud(t[c]);n[c]=f.createString(cn),s[c]=f.utf8Length}const a=cn.omalloc(4*t.length);cn.HEAPU32.set(n,a/4);const l=cn.omalloc(4*t.length);cn.HEAPU32.set(s,l/4);const u=cn.createOnigScanner(a,l,t.length);for(let c=0,d=t.length;c<d;c++)cn.ofree(n[c]);cn.ofree(l),cn.ofree(a),u===0&&LO(cn),this._onigBinding=cn,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 yw(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++],p=c[d++],m=[];for(let x=0;x<p;x++){const y=t.convertUtf8OffsetToUtf16(c[d++]),w=t.convertUtf8OffsetToUtf16(c[d++]);m[x]={start:y,end:w,length:w-y}}return{index:f,captureIndices:m}}}function DO(e){return typeof e.instantiator=="function"}function OO(e){return typeof e.default=="function"}function IO(e){return typeof e.data<"u"}function MO(e){return typeof Response<"u"&&e instanceof Response}function PO(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 au;function sg(e){if(au)return au;async function t(){cn=await NO(async n=>{let s=e;return s=await s,typeof s=="function"&&(s=await s(n)),typeof s=="function"&&(s=await s(n)),DO(s)?s=await s.instantiator(n):OO(s)?s=await s.default(n):(IO(s)&&(s=s.data),MO(s)?typeof WebAssembly.instantiateStreaming=="function"?s=await BO(s)(n):s=await zO(s)(n):PO(s)?s=await pm(s)(n):s instanceof WebAssembly.Module?s=await pm(s)(n):"default"in s&&s.default instanceof WebAssembly.Module&&(s=await pm(s.default)(n))),"instance"in s&&(s=s.instance),"exports"in s&&(s=s.exports),s})}return au=t(),au}function pm(e){return t=>WebAssembly.instantiate(e,t)}function BO(e){return t=>WebAssembly.instantiateStreaming(e,t)}function zO(e){return async t=>{const n=await e.arrayBuffer();return WebAssembly.instantiate(n,t)}}let _w;function $O(e){_w=e}function HO(){return _w}async function bw(e){return e&&await sg(e),{createScanner(t){return new RO(t.map(n=>typeof n=="string"?n:n.source))},createString(t){return new yw(t)}}}const UO=Object.freeze(Object.defineProperty({__proto__:null,createOnigurumaEngine:bw,getDefaultWasmLoader:HO,loadWasm:sg,setDefaultWasmLoader:$O},Symbol.toStringTag,{value:"Module"}));var vw=Jp({});xw(vw,UO);var Lt=class extends Error{constructor(e){super(e),this.name="ShikiError"}};function FO(e){return ig(e)}function ig(e){return Array.isArray(e)?VO(e):e instanceof RegExp?e:typeof e=="object"?GO(e):e}function VO(e){let t=[];for(let n=0,s=e.length;n<s;n++)t[n]=ig(e[n]);return t}function GO(e){let t={};for(let n in e)t[n]=ig(e[n]);return t}function Sw(e,...t){return t.forEach(n=>{for(let s in n)e[s]=n[s]}),e}function ww(e){const t=~e.lastIndexOf("/")||~e.lastIndexOf("\\");return t===0?e:~t===e.length-1?ww(e.substring(0,e.length-1)):e.substr(~t+1)}var gm=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,ou=class{static hasCaptures(e){return e===null?!1:(gm.lastIndex=0,gm.test(e))}static replaceCaptures(e,t,n){return e.replace(gm,(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 Cw(e,t){return e<t?-1:e>t?1:0}function kw(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=Cw(e[a],t[a]);if(l!==0)return l}return 0}return n-s}function r0(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 Ew(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var jw=class{constructor(e){be(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}},Ru=class{constructor(e,t,n){be(this,"_cachedMatchRoot",new jw(e=>this._root.match(e)));this._colorMap=e,this._defaults=t,this._root=n}static createFromRawTheme(e,t){return this.createFromParsedTheme(KO(e),t)}static createFromParsedTheme(e,t){return XO(e,t)}getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(e){if(e===null)return this._defaults;const t=e.scopeName,s=this._cachedMatchRoot.get(t).find(a=>WO(e.parent,a.parentScopes));return s?new Nw(s.fontStyle,s.foreground,s.background):null}},xm=class bu{constructor(t,n){this.parent=t,this.scopeName=n}static push(t,n){for(const s of n)t=new bu(t,s);return t}static from(...t){let n=null;for(let s=0;s<t.length;s++)n=new bu(n,t[s]);return n}push(t){return new bu(this,t)}getSegments(){let t=this;const n=[];for(;t;)n.push(t.scopeName),t=t.parent;return n.reverse(),n}toString(){return this.getSegments().join(" ")}extends(t){return this===t?!0:this.parent===null?!1:this.parent.extends(t)}getExtensionIfDefined(t){const n=[];let s=this;for(;s&&s!==t;)n.push(s.scopeName),s=s.parent;return s===t?n.reverse():void 0}};function WO(e,t){if(t.length===0)return!0;for(let n=0;n<t.length;n++){let s=t[n],a=!1;if(s===">"){if(n===t.length-1)return!1;s=t[++n],a=!0}for(;e&&!qO(e.scopeName,s);){if(a)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function qO(e,t){return t===e||e.startsWith(t)&&e[t.length]==="."}var Nw=class{constructor(e,t,n){this.fontStyle=e,this.foregroundId=t,this.backgroundId=n}};function KO(e){if(!e)return[];if(!e.settings||!Array.isArray(e.settings))return[];let t=e.settings,n=[],s=0;for(let a=0,l=t.length;a<l;a++){let u=t[a];if(!u.settings)continue;let c;if(typeof u.scope=="string"){let m=u.scope;m=m.replace(/^[,]+/,""),m=m.replace(/[,]+$/,""),c=m.split(",")}else Array.isArray(u.scope)?c=u.scope:c=[""];let d=-1;if(typeof u.settings.fontStyle=="string"){d=0;let m=u.settings.fontStyle.split(" ");for(let x=0,y=m.length;x<y;x++)switch(m[x]){case"italic":d=d|1;break;case"bold":d=d|2;break;case"underline":d=d|4;break;case"strikethrough":d=d|8;break}}let f=null;typeof u.settings.foreground=="string"&&r0(u.settings.foreground)&&(f=u.settings.foreground);let p=null;typeof u.settings.background=="string"&&r0(u.settings.background)&&(p=u.settings.background);for(let m=0,x=c.length;m<x;m++){let w=c[m].trim().split(" "),C=w[w.length-1],b=null;w.length>1&&(b=w.slice(0,w.length-1),b.reverse()),n[s++]=new YO(C,b,a,d,f,p)}}return n}var YO=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 XO(e,t){e.sort((d,f)=>{let p=Cw(d.scope,f.scope);return p!==0||(p=kw(d.parentScopes,f.parentScopes),p!==0)?p: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 QO(t),u=new Nw(n,l.getId(s),l.getId(a)),c=new ZO(new np(0,null,-1,0,0),[]);for(let d=0,f=e.length;d<f;d++){let p=e[d];c.insert(0,p.scope,p.parentScopes,p.fontStyle,l.getId(p.foreground),l.getId(p.background))}return new Ru(l,u,c)}var QO=class{constructor(e){be(this,"_isFrozen");be(this,"_lastColorId");be(this,"_id2color");be(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)}},JO=Object.freeze([]),np=class Tw{constructor(t,n,s,a,l){be(this,"scopeDepth");be(this,"parentScopes");be(this,"fontStyle");be(this,"foreground");be(this,"background");this.scopeDepth=t,this.parentScopes=n||JO,this.fontStyle=s,this.foreground=a,this.background=l}clone(){return new Tw(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)}},ZO=class rp{constructor(t,n=[],s={}){be(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(rp._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 p;this._children.hasOwnProperty(d)?p=this._children[d]:(p=new rp(this._mainRule.clone(),np.cloneArr(this._rulesWithParentScopes)),this._children[d]=p),p.insert(t+1,f,s,a,l,u)}_doInsertHere(t,n,s,a,l){if(n===null){this._mainRule.acceptOverwrite(t,s,a,l);return}for(let u=0,c=this._rulesWithParentScopes.length;u<c;u++){let d=this._rulesWithParentScopes[u];if(kw(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 np(t,n,s,a,l))}},Ua=class or{static toBinaryStr(t){return t.toString(2).padStart(32,"0")}static print(t){const n=or.getLanguageId(t),s=or.getTokenType(t),a=or.getFontStyle(t),l=or.getForeground(t),u=or.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=or.getLanguageId(t),f=or.getTokenType(t),p=or.containsBalancedBrackets(t)?1:0,m=or.getFontStyle(t),x=or.getForeground(t),y=or.getBackground(t);return n!==0&&(d=n),s!==8&&(f=s),a!==null&&(p=a?1:0),l!==-1&&(m=l),u!==0&&(x=u),c!==0&&(y=c),(d<<0|f<<8|p<<10|m<<11|x<<15|y<<24)>>>0}};function Du(e,t){const n=[],s=e4(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(s0(a)){const d=[];do d.push(a),a=s.next();while(s0(a));return f=>t(d,f)}return null}function u(){const d=[];let f=l();for(;f;)d.push(f),f=l();return p=>d.every(m=>m(p))}function c(){const d=[];let f=u();for(;f&&(d.push(f),a==="|"||a===",");){do a=s.next();while(a==="|"||a===",");f=u()}return p=>d.some(m=>m(p))}}function s0(e){return!!e&&!!e.match(/[\w\.:]+/)}function e4(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 Aw(e){typeof e.dispose=="function"&&e.dispose()}var _l=class{constructor(e){this.scopeName=e}toKey(){return this.scopeName}},t4=class{constructor(e,t){this.scopeName=e,this.ruleName=t}toKey(){return`${this.scopeName}#${this.ruleName}`}},n4=class{constructor(){be(this,"_references",[]);be(this,"_seenReferenceKeys",new Set);be(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))}},r4=class{constructor(e,t){be(this,"seenFullScopeRequests",new Set);be(this,"seenPartialScopeRequests",new Set);be(this,"Q");this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new _l(this.initialScopeName)]}processQueue(){const e=this.Q;this.Q=[];const t=new n4;for(const n of e)s4(n,this.initialScopeName,this.repo,t);for(const n of t.references)if(n instanceof _l){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 s4(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 _l?vu({baseGrammar:l,selfGrammar:a},s):sp(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 _l(c))}function sp(e,t,n){if(t.repository&&t.repository[e]){const s=t.repository[e];Ou([s],t,n)}}function vu(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&Ou(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&Ou(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function Ou(e,t,n){for(const s of e){if(n.visitedRule.has(s))continue;n.visitedRule.add(s);const a=s.repository?Sw({},t.repository,s.repository):t.repository;Array.isArray(s.patterns)&&Ou(s.patterns,{...t,repository:a},n);const l=s.include;if(!l)continue;const u=Lw(l);switch(u.kind){case 0:vu({...t,selfGrammar:t.baseGrammar},n);break;case 1:vu(t,n);break;case 2:sp(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?sp(u.ruleName,d,n):vu(d,n)}else u.kind===4?n.add(new t4(u.scopeName,u.ruleName)):n.add(new _l(u.scopeName));break}}}var i4=class{constructor(){be(this,"kind",0)}},a4=class{constructor(){be(this,"kind",1)}},o4=class{constructor(e){be(this,"kind",2);this.ruleName=e}},l4=class{constructor(e){be(this,"kind",3);this.scopeName=e}},c4=class{constructor(e,t){be(this,"kind",4);this.scopeName=e,this.ruleName=t}};function Lw(e){if(e==="$base")return new i4;if(e==="$self")return new a4;const t=e.indexOf("#");if(t===-1)return new l4(e);if(t===0)return new o4(e.substring(1));{const n=e.substring(0,t),s=e.substring(t+1);return new c4(n,s)}}var u4=/\\(\d+)/,i0=/\\(\d+)/g,d4=-1,Rw=-2;var Dl=class{constructor(e,t,n,s){be(this,"$location");be(this,"id");be(this,"_nameIsCapturing");be(this,"_name");be(this,"_contentNameIsCapturing");be(this,"_contentName");this.$location=e,this.id=t,this._name=n||null,this._nameIsCapturing=ou.hasCaptures(this._name),this._contentName=s||null,this._contentNameIsCapturing=ou.hasCaptures(this._contentName)}get debugName(){const e=this.$location?`${ww(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:ou.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:ou.replaceCaptures(this._contentName,e,t)}},h4=class extends Dl{constructor(t,n,s,a,l){super(t,n,s,a);be(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!")}},f4=class extends Dl{constructor(t,n,s,a,l){super(t,n,s,null);be(this,"_match");be(this,"captures");be(this,"_cachedCompiledPatterns");this._match=new bl(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 vl,this.collectPatterns(t,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},a0=class extends Dl{constructor(t,n,s,a,l){super(t,n,s,a);be(this,"hasMissingPatterns");be(this,"patterns");be(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 vl,this.collectPatterns(t,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},ip=class extends Dl{constructor(t,n,s,a,l,u,c,d,f,p){super(t,n,s,a);be(this,"_begin");be(this,"beginCaptures");be(this,"_end");be(this,"endHasBackReferences");be(this,"endCaptures");be(this,"applyEndPatternLast");be(this,"hasMissingPatterns");be(this,"patterns");be(this,"_cachedCompiledPatterns");this._begin=new bl(l,this.id),this.beginCaptures=u,this._end=new bl(c||"",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=d,this.applyEndPatternLast=f||!1,this.patterns=p.patterns,this.hasMissingPatterns=p.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(t,n){return this._end.resolveBackReferences(t,n)}collectPatterns(t,n){n.push(this._begin)}compile(t,n){return this._getCachedCompiledPatterns(t,n).compile(t)}compileAG(t,n,s,a){return this._getCachedCompiledPatterns(t,n).compileAG(t,s,a)}_getCachedCompiledPatterns(t,n){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new vl;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}},Iu=class extends Dl{constructor(t,n,s,a,l,u,c,d,f){super(t,n,s,a);be(this,"_begin");be(this,"beginCaptures");be(this,"whileCaptures");be(this,"_while");be(this,"whileHasBackReferences");be(this,"hasMissingPatterns");be(this,"patterns");be(this,"_cachedCompiledPatterns");be(this,"_cachedCompiledWhilePatterns");this._begin=new bl(l,this.id),this.beginCaptures=u,this.whileCaptures=d,this._while=new bl(c,Rw),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 vl;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 vl,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,n||""),this._cachedCompiledWhilePatterns}},Dw=class _n{static createCaptureRule(t,n,s,a,l){return t.registerRule(u=>new h4(n,u,s,a,l))}static getCompiledRuleId(t,n,s){return t.id||n.registerRule(a=>{if(t.id=a,t.match)return new f4(t.$vscodeTextmateLocation,t.id,t.name,t.match,_n._compileCaptures(t.captures,n,s));if(typeof t.begin>"u"){t.repository&&(s=Sw({},s,t.repository));let l=t.patterns;return typeof l>"u"&&t.include&&(l=[{include:t.include}]),new a0(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,_n._compilePatterns(l,n,s))}return t.while?new Iu(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,_n._compileCaptures(t.beginCaptures||t.captures,n,s),t.while,_n._compileCaptures(t.whileCaptures||t.captures,n,s),_n._compilePatterns(t.patterns,n,s)):new ip(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,_n._compileCaptures(t.beginCaptures||t.captures,n,s),t.end,_n._compileCaptures(t.endCaptures||t.captures,n,s),t.applyEndPatternLast,_n._compilePatterns(t.patterns,n,s))}),t.id}static _compileCaptures(t,n,s){let a=[];if(t){let l=0;for(const u in t){if(u==="$vscodeTextmateLocation")continue;const c=parseInt(u,10);c>l&&(l=c)}for(let u=0;u<=l;u++)a[u]=null;for(const u in t){if(u==="$vscodeTextmateLocation")continue;const c=parseInt(u,10);let d=0;t[u].patterns&&(d=_n.getCompiledRuleId(t[u],n,s)),a[c]=_n.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=Lw(c.include);switch(f.kind){case 0:case 1:d=_n.getCompiledRuleId(s[c.include],n,s);break;case 2:let p=s[f.ruleName];p&&(d=_n.getCompiledRuleId(p,n,s));break;case 3:case 4:const m=f.scopeName,x=f.kind===4?f.ruleName:null,y=n.getExternalGrammar(m,s);if(y)if(x){let w=y.repository[x];w&&(d=_n.getCompiledRuleId(w,n,y.repository))}else d=_n.getCompiledRuleId(y.repository.$self,n,y.repository);break}}else d=_n.getCompiledRuleId(c,n,s);if(d!==-1){const f=n.getRule(d);let p=!1;if((f instanceof a0||f instanceof ip||f instanceof Iu)&&f.hasMissingPatterns&&f.patterns.length===0&&(p=!0),p)continue;a.push(d)}}return{patterns:a,hasMissingPatterns:(t?t.length:0)!==a.length}}},bl=class Ow{constructor(t,n){be(this,"source");be(this,"ruleId");be(this,"hasAnchor");be(this,"hasBackReferences");be(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=u4.test(this.source):this.hasBackReferences=!1}clone(){return new Ow(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 i0.lastIndex=0,this.source.replace(i0,(a,l)=>Ew(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}},vl=class{constructor(){be(this,"_items");be(this,"_hasAnchors");be(this,"_cached");be(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 o0(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 o0(e,s,this._items.map(a=>a.ruleId))}},o0=class{constructor(e,t,n){be(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}},ym=class{constructor(e,t){this.languageId=e,this.tokenType=t}},ls,m4=(ls=class{constructor(t,n){be(this,"_defaultAttributes");be(this,"_embeddedLanguagesMatcher");be(this,"_getBasicScopeAttributes",new jw(t=>{const n=this._scopeToLanguage(t),s=this._toStandardTokenType(t);return new ym(n,s)}));this._defaultAttributes=new ym(t,8),this._embeddedLanguagesMatcher=new p4(Object.entries(n||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(t){return t===null?ls._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(t)}_scopeToLanguage(t){return this._embeddedLanguagesMatcher.match(t)||0}_toStandardTokenType(t){const n=t.match(ls.STANDARD_TOKEN_TYPE_REGEXP);if(!n)return 8;switch(n[1]){case"comment":return 1;case"string":return 2;case"regex":return 3;case"meta.embedded":return 0}throw new Error("Unexpected match for standard token type!")}},be(ls,"_NULL_SCOPE_METADATA",new ym(0,0)),be(ls,"STANDARD_TOKEN_TYPE_REGEXP",/\b(comment|string|regex|meta\.embedded)\b/),ls),p4=class{constructor(e){be(this,"values");be(this,"scopesRegExp");if(e.length===0)this.values=null,this.scopesRegExp=null;else{this.values=new Map(e);const t=e.map(([n,s])=>Ew(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])}},l0=class{constructor(e,t){this.stack=e,this.stoppedEarly=t}};function Iw(e,t,n,s,a,l,u,c){const d=t.content.length;let f=!1,p=-1;if(u){const y=g4(e,t,n,s,a,l);a=y.stack,s=y.linePos,n=y.isFirstLine,p=y.anchorPosition}const m=Date.now();for(;!f;){if(c!==0&&Date.now()-m>c)return new l0(a,!0);x()}return new l0(a,!1);function x(){const y=x4(e,t,n,s,a,p);if(!y){l.produce(a,d),f=!0;return}const w=y.captureIndices,C=y.matchedRuleId,b=w&&w.length>0?w[0].end>s:!1;if(C===d4){const S=a.getRule(e);l.produce(a,w[0].start),a=a.withContentNameScopesList(a.nameScopesList),ol(e,t,n,a,l,S.endCaptures,w),l.produce(a,w[0].end);const v=a;if(a=a.parent,p=v.getAnchorPos(),!b&&v.getEnterPos()===s){a=v,l.produce(a,d),f=!0;return}}else{const S=e.getRule(C);l.produce(a,w[0].start);const v=a,_=S.getName(t.content,w),E=a.contentNameScopesList.pushAttributed(_,e);if(a=a.push(C,s,p,w[0].end===d,null,E,E),S instanceof ip){const j=S;ol(e,t,n,a,l,j.beginCaptures,w),l.produce(a,w[0].end),p=w[0].end;const T=j.getContentName(t.content,w),R=E.pushAttributed(T,e);if(a=a.withContentNameScopesList(R),j.endHasBackReferences&&(a=a.withEndRule(j.getEndWithResolvedBackReferences(t.content,w))),!b&&v.hasSameRuleAs(a)){a=a.pop(),l.produce(a,d),f=!0;return}}else if(S instanceof Iu){const j=S;ol(e,t,n,a,l,j.beginCaptures,w),l.produce(a,w[0].end),p=w[0].end;const T=j.getContentName(t.content,w),R=E.pushAttributed(T,e);if(a=a.withContentNameScopesList(R),j.whileHasBackReferences&&(a=a.withEndRule(j.getWhileWithResolvedBackReferences(t.content,w))),!b&&v.hasSameRuleAs(a)){a=a.pop(),l.produce(a,d),f=!0;return}}else if(ol(e,t,n,a,l,S.captures,w),l.produce(a,w[0].end),a=a.pop(),!b){a=a.safePop(),l.produce(a,d),f=!0;return}}w[0].end>s&&(s=w[0].end,n=!1)}}function g4(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 Iu&&c.push({rule:f,stack:d})}for(let d=c.pop();d;d=c.pop()){const{ruleScanner:f,findOptions:p}=b4(d.rule,e,d.stack.endRule,n,s===u),m=f.findNextMatchSync(t,s,p);if(m){if(m.ruleId!==Rw){a=d.stack.pop();break}m.captureIndices&&m.captureIndices.length&&(l.produce(d.stack,m.captureIndices[0].start),ol(e,t,n,d.stack,l,d.rule.whileCaptures,m.captureIndices),l.produce(d.stack,m.captureIndices[0].end),u=m.captureIndices[0].end,m.captureIndices[0].end>s&&(s=m.captureIndices[0].end,n=!1))}else{a=d.stack.pop();break}}return{stack:a,linePos:s,anchorPosition:u,isFirstLine:n}}function x4(e,t,n,s,a,l){const u=y4(e,t,n,s,a,l),c=e.getInjections();if(c.length===0)return u;const d=_4(c,e,t,n,s,a,l);if(!d)return u;if(!u)return d;const f=u.captureIndices[0].start,p=d.captureIndices[0].start;return p<f||d.priorityMatch&&p===f?d:u}function y4(e,t,n,s,a,l){const u=a.getRule(e),{ruleScanner:c,findOptions:d}=Mw(u,e,a.endRule,n,s===l),f=c.findNextMatchSync(t,s,d);return f?{captureIndices:f.captureIndices,matchedRuleId:f.ruleId}:null}function _4(e,t,n,s,a,l,u){let c=Number.MAX_VALUE,d=null,f,p=0;const m=l.contentNameScopesList.getScopeNames();for(let x=0,y=e.length;x<y;x++){const w=e[x];if(!w.matcher(m))continue;const C=t.getRule(w.ruleId),{ruleScanner:b,findOptions:S}=Mw(C,t,null,s,a===u),v=b.findNextMatchSync(n,a,S);if(!v)continue;const _=v.captureIndices[0].start;if(!(_>=c)&&(c=_,d=v.captureIndices,f=v.ruleId,p=w.priority,c===a))break}return d?{priorityMatch:p===-1,captureIndices:d,matchedRuleId:f}:null}function Mw(e,t,n,s,a){return{ruleScanner:e.compileAG(t,n,s,a),findOptions:0}}function b4(e,t,n,s,a){return{ruleScanner:e.compileWhileAG(t,n,s,a),findOptions:0}}function ol(e,t,n,s,a,l,u){if(l.length===0)return;const c=t.content,d=Math.min(l.length,u.length),f=[],p=u[0].end;for(let m=0;m<d;m++){const x=l[m];if(x===null)continue;const y=u[m];if(y.length===0)continue;if(y.start>p)break;for(;f.length>0&&f[f.length-1].endPos<=y.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,y.start):a.produce(s,y.start),x.retokenizeCapturedWithRuleId){const C=x.getName(c,u),b=s.contentNameScopesList.pushAttributed(C,e),S=x.getContentName(c,u),v=b.pushAttributed(S,e),_=s.push(x.retokenizeCapturedWithRuleId,y.start,-1,!1,null,b,v),E=e.createOnigString(c.substring(0,y.end));Iw(e,E,n&&y.start===0,y.start,_,a,!1,0),Aw(E);continue}const w=x.getName(c,u);if(w!==null){const b=(f.length>0?f[f.length-1].scopes:s.contentNameScopesList).pushAttributed(w,e);f.push(new v4(b,y.end))}}for(;f.length>0;)a.produceFromScopes(f[f.length-1].scopes,f[f.length-1].endPos),f.pop()}var v4=class{constructor(e,t){be(this,"scopes");be(this,"endPos");this.scopes=e,this.endPos=t}};function S4(e,t,n,s,a,l,u,c){return new C4(e,t,n,s,a,l,u,c)}function c0(e,t,n,s,a){const l=Du(t,Mu),u=Dw.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 Mu(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(w4(t[a],s))return n=a+1,!0;return!1})}function w4(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 C4=class{constructor(e,t,n,s,a,l,u,c){be(this,"_rootId");be(this,"_lastRuleId");be(this,"_ruleId2desc");be(this,"_includedGrammars");be(this,"_grammarRepository");be(this,"_grammar");be(this,"_injections");be(this,"_basicScopeAttributesProvider");be(this,"_tokenTypeMatchers");if(this._rootScopeName=e,this.balancedBracketSelectors=l,this._onigLib=c,this._basicScopeAttributesProvider=new m4(n,s),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=u,this._grammar=u0(t,null),this._injections=null,this._tokenTypeMatchers=[],a)for(const d of Object.keys(a)){const f=Du(d,Mu);for(const p of f)this._tokenTypeMatchers.push({matcher:p.matcher,type:a[d]})}}get themeProvider(){return this._grammarRepository}dispose(){for(const e of this._ruleId2desc)e&&e.dispose()}createOnigScanner(e){return this._onigLib.createOnigScanner(e)}createOnigString(e){return this._onigLib.createOnigString(e)}getMetadataForScope(e){return this._basicScopeAttributesProvider.getBasicScopeAttributes(e)}_collectInjections(){const e={lookup:a=>a===this._rootScopeName?this._grammar:this.getExternalGrammar(a),injections:a=>this._grammarRepository.injections(a)},t=[],n=this._rootScopeName,s=e.lookup(n);if(s){const a=s.injections;if(a)for(let u in a)c0(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&&c0(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]=u0(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=Dw.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let a;if(!t||t===ap.NULL){a=!0;const f=this._basicScopeAttributesProvider.getDefaultAttributes(),p=this.themeProvider.getDefaults(),m=Ua.set(0,f.languageId,f.tokenType,null,p.fontStyle,p.foregroundId,p.backgroundId),x=this.getRule(this._rootId).getName(null,null);let y;x?y=hl.createRootAndLookUpScopeName(x,m,this):y=hl.createRoot("unknown",m),t=new ap(null,this._rootId,-1,-1,!1,null,y,y)}else a=!1,t.reset();e=e+`
|
|
126
|
+
`;const l=this.createOnigString(e),u=l.content.length,c=new E4(n,e,this._tokenTypeMatchers,this.balancedBracketSelectors),d=Iw(this,l,a,0,t,c,!0,s);return Aw(l),{lineLength:u,lineTokens:c,ruleStack:d.stack,stoppedEarly:d.stoppedEarly}}};function u0(e,t){return e=FO(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 hl=class Lr{constructor(t,n,s){this.parent=t,this.scopePath=n,this.tokenAttributes=s}static fromExtension(t,n){let s=t,a=(t==null?void 0:t.scopePath)??null;for(const l of n)a=xm.push(a,l.scopeNames),s=new Lr(s,a,l.encodedTokenAttributes);return s}static createRoot(t,n){return new Lr(null,new xm(null,t),n)}static createRootAndLookUpScopeName(t,n,s){const a=s.getMetadataForScope(t),l=new xm(null,t),u=s.themeProvider.themeMatch(l),c=Lr.mergeAttributes(n,a,u);return new Lr(null,l,c)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(t){return Lr.equals(this,t)}static equals(t,n){do{if(t===n||!t&&!n)return!0;if(!t||!n||t.scopeName!==n.scopeName||t.tokenAttributes!==n.tokenAttributes)return!1;t=t.parent,n=n.parent}while(!0)}static mergeAttributes(t,n,s){let a=-1,l=0,u=0;return s!==null&&(a=s.fontStyle,l=s.foregroundId,u=s.backgroundId),Ua.set(t,n.languageId,n.tokenType,null,a,l,u)}pushAttributed(t,n){if(t===null)return this;if(t.indexOf(" ")===-1)return Lr._pushAttributed(this,t,n);const s=t.split(/ /g);let a=this;for(const l of s)a=Lr._pushAttributed(a,l,n);return a}static _pushAttributed(t,n,s){const a=s.getMetadataForScope(n),l=t.scopePath.push(n),u=s.themeProvider.themeMatch(l),c=Lr.mergeAttributes(t.tokenAttributes,a,u);return new Lr(t,l,c)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(t){var a;const n=[];let s=this;for(;s&&s!==t;)n.push({encodedTokenAttributes:s.tokenAttributes,scopeNames:s.scopePath.getExtensionIfDefined(((a=s.parent)==null?void 0:a.scopePath)??null)}),s=s.parent;return s===t?n.reverse():void 0}},cr,ap=(cr=class{constructor(t,n,s,a,l,u,c,d){be(this,"_stackElementBrand");be(this,"_enterPos");be(this,"_anchorPos");be(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:cr._equals(this,t)}static _equals(t,n){return t===n?!0:this._structuralEquals(t,n)?hl.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(){cr._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(t,n,s,a,l,u,c){return new cr(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 cr(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=hl.fromExtension((t==null?void 0:t.nameScopesList)??null,n.nameScopesList);return new cr(t,n.ruleId,n.enterPos??-1,n.anchorPos??-1,n.beginRuleCapturedEOL,n.endRule,s,hl.fromExtension(s,n.contentNameScopesList))}},be(cr,"NULL",new cr(null,0,0,0,!1,null,null,null)),cr),k4=class{constructor(e,t){be(this,"balancedBracketScopes");be(this,"unbalancedBracketScopes");be(this,"allowAny",!1);this.balancedBracketScopes=e.flatMap(n=>n==="*"?(this.allowAny=!0,[]):Du(n,Mu).map(s=>s.matcher)),this.unbalancedBracketScopes=t.flatMap(n=>Du(n,Mu).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}},E4=class{constructor(e,t,n,s){be(this,"_emitBinaryTokens");be(this,"_lineText");be(this,"_tokens");be(this,"_binaryTokens");be(this,"_lastTokenEndIndex");be(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=Ua.set(a,0,c.type,null,-1,0,0));this.balancedBracketSelectors&&(l=this.balancedBracketSelectors.match(u))}if(l&&(a=Ua.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}},j4=class{constructor(e,t){be(this,"_grammars",new Map);be(this,"_rawGrammars",new Map);be(this,"_injectionGrammars",new Map);be(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,S4(e,l,t,n,s,a,this,this._onigLib))}return this._grammars.get(e)}},N4=class{constructor(t){be(this,"_options");be(this,"_syncRegistry");be(this,"_ensureGrammarCache");this._options=t,this._syncRegistry=new j4(Ru.createFromRawTheme(t.theme,t.colorMap),t.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(t,n){this._syncRegistry.setTheme(Ru.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 k4(s.balancedBracketSelectors||[],s.unbalancedBracketSelectors||[]))}loadGrammar(t){return this._loadGrammar(t,0,null,null,null)}_loadGrammar(t,n,s,a,l){const u=new r4(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)}},op=ap.NULL;function Pu(e,t){const n=typeof e=="string"?{}:{...e.colorReplacements},s=typeof e=="string"?e:e.name;for(const[a,l]of Object.entries((t==null?void 0:t.colorReplacements)||{}))typeof l=="string"?n[a]=l:a===s&&Object.assign(n,l);return n}function Vs(e,t){return e&&((t==null?void 0:t[e==null?void 0:e.toLowerCase()])||e)}function T4(e){return Array.isArray(e)?e:[e]}async function Pw(e){return Promise.resolve(typeof e=="function"?e():e).then(t=>t.default||t)}function hd(e){return!e||["plaintext","txt","text","plain"].includes(e)}function Bw(e){return e==="ansi"||hd(e)}function fd(e){return e==="none"}function zw(e){return fd(e)}const A4=/(\r?\n)/g;function md(e,t=!1){var l;if(e.length===0)return[["",0]];const n=e.split(A4);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 d0={light:"#333333",dark:"#bbbbbb"},h0={light:"#fffffe",dark:"#1e1e1e"},f0="__shiki_resolved";function ag(e){var c,d,f,p,m;if(e!=null&&e[f0])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 x=t.settings?t.settings.find(y=>!y.name&&!y.scope):void 0;(c=x==null?void 0:x.settings)!=null&&c.foreground&&(s=x.settings.foreground),(d=x==null?void 0:x.settings)!=null&&d.background&&(n=x.settings.background),!s&&((f=t==null?void 0:t.colors)!=null&&f["editor.foreground"])&&(s=t.colors["editor.foreground"]),!n&&((p=t==null?void 0:t.colors)!=null&&p["editor.background"])&&(n=t.colors["editor.background"]),s||(s=t.type==="light"?d0.light:d0.dark),n||(n=t.type==="light"?h0.light:h0.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(x){var w;if(l.has(x))return l.get(x);a+=1;const y=`#${a.toString(16).padStart(8,"0").toLowerCase()}`;return(w=t.colorReplacements)!=null&&w[`#${y}`]?u(x):(l.set(x,y),y)}t.settings=t.settings.map(x=>{var b,S;const y=((b=x.settings)==null?void 0:b.foreground)&&!x.settings.foreground.startsWith("#"),w=((S=x.settings)==null?void 0:S.background)&&!x.settings.background.startsWith("#");if(!y&&!w)return x;const C={...x,settings:{...x.settings}};if(y){const v=u(x.settings.foreground);t.colorReplacements[v]=x.settings.foreground,C.settings.foreground=v}if(w){const v=u(x.settings.background);t.colorReplacements[v]=x.settings.background,C.settings.background=v}return C});for(const x of Object.keys(t.colors||{}))if((x==="editor.foreground"||x==="editor.background"||x.startsWith("terminal.ansi"))&&!((m=t.colors[x])!=null&&m.startsWith("#"))){const y=u(t.colors[x]);t.colorReplacements[y]=t.colors[x],t.colors[x]=y}return Object.defineProperty(t,f0,{enumerable:!1,writable:!1,value:!0}),t}async function $w(e){return[...new Set((await Promise.all(e.filter(t=>!Bw(t)).map(async t=>await Pw(t).then(n=>Array.isArray(n)?n:[n])))).flat())]}async function Hw(e){return(await Promise.all(e.map(async t=>zw(t)?null:ag(await Pw(t))))).filter(t=>!!t)}function Uw(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 Lt(`Circular alias \`${[...n].join(" -> ")} -> ${e}\``);n.add(e)}}return e}var L4=class extends N4{constructor(t,n,s,a={}){super(t);be(this,"_resolver");be(this,"_themes");be(this,"_langs");be(this,"_alias");be(this,"_resolvedThemes",new Map);be(this,"_resolvedGrammars",new Map);be(this,"_langMap",new Map);be(this,"_langGraph",new Map);be(this,"_textmateThemeCache",new WeakMap);be(this,"_loadedThemesCache",null);be(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=ag(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=Ru.createFromRawTheme(t),this._textmateThemeCache.set(t,n)),this._syncRegistry.setTheme(n)}getGrammar(t){return t=Uw(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 p;return(p=f.embeddedLangsLazy)==null?void 0:p.includes(t.name)}));this._resolver.addLanguage(t);const s={balancedBracketSelectors:t.balancedBracketSelectors||["*"],unbalancedBracketSelectors:t.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(t.scopeName,t);const a=this.loadGrammarWithConfiguration(t.scopeName,1,s);if(a.name=t.name,this._resolvedGrammars.set(t.name,a),t.aliases&&t.aliases.forEach(f=>{this._alias[f]=t.name}),this._loadedLanguagesCache=null,n.size)for(const f of n)this._resolvedGrammars.delete(f.name),this._loadedLanguagesCache=null,(u=(l=this._syncRegistry)==null?void 0:l._injectionGrammars)==null||u.delete(f.scopeName),(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 Lt(`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))}},R4=class{constructor(e,t){be(this,"_langs",new Map);be(this,"_scopeToLang",new Map);be(this,"_injections",new Map);be(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 el=0;function D4(e){el+=1,e.warnings!==!1&&el>=10&&el%10===0&&console.warn(`[Shiki] ${el} 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 Lt("`engine` option is required for synchronous mode");const n=(e.langs||[]).flat(1),s=(e.themes||[]).flat(1).map(ag),a=new L4(new R4(e.engine,n),s,n,e.langAlias);let l;function u(v){return Uw(v,e.langAlias)}function c(v){b();const _=a.getGrammar(typeof v=="string"?v:v.name);if(!_)throw new Lt(`Language \`${v}\` not found, you may need to load it first`);return _}function d(v){if(v==="none")return{bg:"",fg:"",name:"none",settings:[],type:"dark"};b();const _=a.getTheme(v);if(!_)throw new Lt(`Theme \`${v}\` not found, you may need to load it first`);return _}function f(v){b();const _=d(v);return l!==v&&(a.setTheme(_),l=v),{theme:_,colorMap:a.getColorMap()}}function p(){return b(),a.getLoadedThemes()}function m(){return b(),a.getLoadedLanguages()}function x(...v){b(),a.loadLanguages(v.flat(1))}async function y(...v){return x(await $w(v))}function w(...v){b();for(const _ of v.flat(1))a.loadTheme(_)}async function C(...v){return b(),w(await Hw(v))}function b(){if(t)throw new Lt("Shiki instance has been disposed")}function S(){t||(t=!0,a.dispose(),el-=1)}return{setTheme:f,getTheme:d,getLanguage:c,getLoadedThemes:p,getLoadedLanguages:m,resolveLangAlias:u,loadLanguage:y,loadLanguageSync:x,loadTheme:C,loadThemeSync:w,dispose:S,[Symbol.dispose]:S}}async function O4(e){e.engine||console.warn("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");const[t,n,s]=await Promise.all([Hw(e.themes||[]),$w(e.langs||[]),e.engine]);return D4({...e,themes:t,langs:n,engine:s})}const Fw=new WeakMap;function pd(e,t){Fw.set(e,t)}function Sl(e){return Fw.get(e)}var gd=class Vw{constructor(...t){be(this,"_stacks",{});be(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 Vw(Object.fromEntries(T4(n).map(s=>[s,op])),t)}getInternalStack(t=this.theme){return this._stacks[t]}getScopes(t=this.theme){return I4(this._stacks[t])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function I4(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 M4(e,t){if(!(e instanceof gd))throw new Lt("Invalid grammar state");return e.getInternalStack(t)}const P4=/,/,B4=/ /;function Gw(e,t,n={}){const{theme:s=e.getLoadedThemes()[0]}=n;if(hd(e.resolveLangAlias(n.lang||"text"))||fd(s))return md(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 Lt(`Grammar state language "${n.grammarState.lang}" does not match highlight language "${u.name}"`);if(!n.grammarState.themes.includes(a.name))throw new Lt(`Grammar state themes "${n.grammarState.themes}" do not contain highlight theme "${a.name}"`)}return $4(t,u,a,l,n)}function z4(...e){if(e.length===2)return Sl(e[1]);const[t,n,s={}]=e,{lang:a="text",theme:l=t.getLoadedThemes()[0]}=s;if(hd(a)||fd(l))throw new Lt("Plain language does not have grammar state");if(a==="ansi")throw new Lt("ANSI language does not have grammar state");const{theme:u,colorMap:c}=t.setTheme(l),d=t.getLanguage(a);return new gd(og(n,d,u,c,s).stateStack,d.name,u.name)}function $4(e,t,n,s,a){const l=og(e,t,n,s,a),u=new gd(l.stateStack,t.name,n.name);return pd(l.tokens,u),l.tokens}function og(e,t,n,s,a){const l=Pu(n,a),{tokenizeMaxLineLength:u=0,tokenizeTimeLimit:c=500}=a,d=md(e);let f=a.grammarState?M4(a.grammarState,n.name)??op:a.grammarContextCode!=null?og(a.grammarContextCode,t,n,s,{...a,grammarState:void 0,grammarContextCode:void 0}).stateStack:op,p=[];const m=[];for(let x=0,y=d.length;x<y;x++){const[w,C]=d[x];if(w===""){p=[],m.push([]);continue}if(u>0&&w.length>=u){p=[],m.push([{content:w,offset:C,color:"",fontStyle:0}]);continue}let b,S,v;a.includeExplanation&&(b=t.tokenizeLine(w,f,c),S=b.tokens,v=0);const _=t.tokenizeLine2(w,f,c),E=_.tokens.length/2;for(let j=0;j<E;j++){const T=_.tokens[2*j],R=j+1<E?_.tokens[2*j+2]:w.length;if(T===R)continue;const A=_.tokens[2*j+1],D=Vs(s[Ua.getForeground(A)],l),$=Ua.getFontStyle(A),q={content:w.substring(T,R),offset:C+T,color:D,fontStyle:$};if(a.includeExplanation){const G=[];if(a.includeExplanation!=="scopeName")for(const U of n.settings){let V;switch(typeof U.scope){case"string":V=U.scope.split(P4).map(z=>z.trim());break;case"object":V=U.scope;break;default:continue}G.push({settings:U,selectors:V.map(z=>z.split(B4))})}q.explanation=[];let I=0;for(;T+I<R;){const U=S[v],V=w.substring(U.startIndex,U.endIndex);I+=V.length,q.explanation.push({content:V,scopes:a.includeExplanation==="scopeName"?H4(U.scopes):U4(G,U.scopes)}),v+=1}}p.push(q)}m.push(p),p=[],f=_.ruleStack}return{tokens:m,stateStack:f}}function H4(e){return e.map(t=>({scopeName:t}))}function U4(e,t){const n=[];for(let s=0,a=t.length;s<a;s++){const l=t[s];n[s]={scopeName:l,themeMatches:V4(e,l,t.slice(0,s))}}return n}function m0(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]==="."}function F4(e,t,n){if(!m0(e.at(-1),t))return!1;let s=e.length-2,a=n.length-1;for(;s>=0&&a>=0;)m0(e[s],n[a])&&(s-=1),a-=1;return s===-1}function V4(e,t,n){const s=[];for(const{selectors:a,settings:l}of e)for(const u of a)if(F4(u,t,n)){s.push(l);break}return s}function Ww(e,t,n,s=Gw){const a=Object.entries(n.themes).filter(f=>f[1]).map(f=>({color:f[0],theme:f[1]})),l=a.map(f=>{const p=s(e,t,{...n,theme:f.theme});return{tokens:p,state:Sl(p),theme:typeof f.theme=="string"?f.theme:f.theme.name}}),u=G4(...l.map(f=>f.tokens)),c=u[0].map((f,p)=>f.map((m,x)=>{const y={content:m.content,variants:{},offset:m.offset};return"includeExplanation"in n&&n.includeExplanation&&(y.explanation=m.explanation),u.forEach((w,C)=>{const{content:b,explanation:S,offset:v,..._}=w[p][x];y.variants[a[C].color]=_}),y})),d=l[0].state?new gd(Object.fromEntries(l.map(f=>{var p;return[f.theme,(p=f.state)==null?void 0:p.getInternalStack(f.theme)]})),l[0].state.lang):void 0;return d&&pd(c,d),c}function G4(...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 p=c[f];p.content.length===d?(l[f].push(p),u[f]+=1,c[f]=a[f][u[f]]):(l[f].push({...p,content:p.content.slice(0,d)}),c[f]={...p,content:p.content.slice(d),offset:p.offset+d})}}}return t}const W4=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"];class Ol{constructor(t,n,s){this.normal=n,this.property=t,s&&(this.space=s)}}Ol.prototype.normal={};Ol.prototype.property={};Ol.prototype.space=void 0;function qw(e,t){const n={},s={};for(const a of e)Object.assign(n,a.property),Object.assign(s,a.normal);return new Ol(n,s,t)}function lp(e){return e.toLowerCase()}class Mn{constructor(t,n){this.attribute=n,this.property=t}}Mn.prototype.attribute="";Mn.prototype.booleanish=!1;Mn.prototype.boolean=!1;Mn.prototype.commaOrSpaceSeparated=!1;Mn.prototype.commaSeparated=!1;Mn.prototype.defined=!1;Mn.prototype.mustUseProperty=!1;Mn.prototype.number=!1;Mn.prototype.overloadedBoolean=!1;Mn.prototype.property="";Mn.prototype.spaceSeparated=!1;Mn.prototype.space=void 0;let q4=0;const Ze=Ii(),Zt=Ii(),cp=Ii(),Re=Ii(),At=Ii(),za=Ii(),Wn=Ii();function Ii(){return 2**++q4}const up=Object.freeze(Object.defineProperty({__proto__:null,boolean:Ze,booleanish:Zt,commaOrSpaceSeparated:Wn,commaSeparated:za,number:Re,overloadedBoolean:cp,spaceSeparated:At},Symbol.toStringTag,{value:"Module"})),_m=Object.keys(up);class lg extends Mn{constructor(t,n,s,a){let l=-1;if(super(t,n),p0(this,"space",a),typeof s=="number")for(;++l<_m.length;){const u=_m[l];p0(this,_m[l],(s&up[u])===up[u])}}}lg.prototype.defined=!0;function p0(e,t,n){n&&(e[t]=n)}function Qa(e){const t={},n={};for(const[s,a]of Object.entries(e.properties)){const l=new lg(s,e.transform(e.attributes||{},s),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(s)&&(l.mustUseProperty=!0),t[s]=l,n[lp(s)]=s,n[lp(l.attribute)]=s}return new Ol(t,n,e.space)}const Kw=Qa({properties:{ariaActiveDescendant:null,ariaAtomic:Zt,ariaAutoComplete:null,ariaBusy:Zt,ariaChecked:Zt,ariaColCount:Re,ariaColIndex:Re,ariaColSpan:Re,ariaControls:At,ariaCurrent:null,ariaDescribedBy:At,ariaDetails:null,ariaDisabled:Zt,ariaDropEffect:At,ariaErrorMessage:null,ariaExpanded:Zt,ariaFlowTo:At,ariaGrabbed:Zt,ariaHasPopup:null,ariaHidden:Zt,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:At,ariaLevel:Re,ariaLive:null,ariaModal:Zt,ariaMultiLine:Zt,ariaMultiSelectable:Zt,ariaOrientation:null,ariaOwns:At,ariaPlaceholder:null,ariaPosInSet:Re,ariaPressed:Zt,ariaReadOnly:Zt,ariaRelevant:null,ariaRequired:Zt,ariaRoleDescription:At,ariaRowCount:Re,ariaRowIndex:Re,ariaRowSpan:Re,ariaSelected:Zt,ariaSetSize:Re,ariaSort:null,ariaValueMax:Re,ariaValueMin:Re,ariaValueNow:Re,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function Yw(e,t){return t in e?e[t]:t}function Xw(e,t){return Yw(e,t.toLowerCase())}const K4=Qa({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:za,acceptCharset:At,accessKey:At,action:null,allow:null,allowFullScreen:Ze,allowPaymentRequest:Ze,allowUserMedia:Ze,alt:null,as:null,async:Ze,autoCapitalize:null,autoComplete:At,autoFocus:Ze,autoPlay:Ze,blocking:At,capture:null,charSet:null,checked:Ze,cite:null,className:At,cols:Re,colSpan:null,content:null,contentEditable:Zt,controls:Ze,controlsList:At,coords:Re|za,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Ze,defer:Ze,dir:null,dirName:null,disabled:Ze,download:cp,draggable:Zt,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Ze,formTarget:null,headers:At,height:Re,hidden:cp,high:Re,href:null,hrefLang:null,htmlFor:At,httpEquiv:At,id:null,imageSizes:null,imageSrcSet:null,inert:Ze,inputMode:null,integrity:null,is:null,isMap:Ze,itemId:null,itemProp:At,itemRef:At,itemScope:Ze,itemType:At,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Ze,low:Re,manifest:null,max:null,maxLength:Re,media:null,method:null,min:null,minLength:Re,multiple:Ze,muted:Ze,name:null,nonce:null,noModule:Ze,noValidate:Ze,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Ze,optimum:Re,pattern:null,ping:At,placeholder:null,playsInline:Ze,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Ze,referrerPolicy:null,rel:At,required:Ze,reversed:Ze,rows:Re,rowSpan:Re,sandbox:At,scope:null,scoped:Ze,seamless:Ze,selected:Ze,shadowRootClonable:Ze,shadowRootDelegatesFocus:Ze,shadowRootMode:null,shape:null,size:Re,sizes:null,slot:null,span:Re,spellCheck:Zt,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Re,step:null,style:null,tabIndex:Re,target:null,title:null,translate:null,type:null,typeMustMatch:Ze,useMap:null,value:Zt,width:Re,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:At,axis:null,background:null,bgColor:null,border:Re,borderColor:null,bottomMargin:Re,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Ze,declare:Ze,event:null,face:null,frame:null,frameBorder:null,hSpace:Re,leftMargin:Re,link:null,longDesc:null,lowSrc:null,marginHeight:Re,marginWidth:Re,noResize:Ze,noHref:Ze,noShade:Ze,noWrap:Ze,object:null,profile:null,prompt:null,rev:null,rightMargin:Re,rules:null,scheme:null,scrolling:Zt,standby:null,summary:null,text:null,topMargin:Re,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Re,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Ze,disableRemotePlayback:Ze,prefix:null,property:null,results:Re,security:null,unselectable:null},space:"html",transform:Xw}),Y4=Qa({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:Re,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Re,amplitude:Re,arabicForm:null,ascent:Re,attributeName:null,attributeType:null,azimuth:Re,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Re,by:null,calcMode:null,capHeight:Re,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:Re,diffuseConstant:Re,direction:null,display:null,dur:null,divisor:Re,dominantBaseline:null,download:Ze,dx:null,dy:null,edgeMode:null,editable:null,elevation:Re,enableBackground:null,end:null,event:null,exponent:Re,externalResourcesRequired:null,fill:null,fillOpacity:Re,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:za,g2:za,glyphName:za,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Re,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Re,horizOriginX:Re,horizOriginY:Re,id:null,ideographic:Re,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Re,k:Re,k1:Re,k2:Re,k3:Re,k4:Re,kernelMatrix:Wn,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Re,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:Re,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:Re,overlineThickness:Re,paintOrder:null,panose1:null,path:null,pathLength:Re,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:At,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Re,pointsAtY:Re,pointsAtZ:Re,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:Re,specularExponent:Re,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Re,strikethroughThickness:Re,string:null,stroke:null,strokeDashArray:Wn,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Re,strokeOpacity:Re,strokeWidth:null,style:null,surfaceScale:Re,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Wn,tabIndex:Re,tableValues:null,target:null,targetX:Re,targetY:Re,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:Re,underlineThickness:Re,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Re,values:null,vAlphabetic:Re,vMathematical:Re,vectorEffect:null,vHanging:Re,vIdeographic:Re,version:null,vertAdvY:Re,vertOriginX:Re,vertOriginY:Re,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Re,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Yw}),Qw=Qa({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()}}),Jw=Qa({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Xw}),Zw=Qa({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),X4=/[A-Z]/g,g0=/-[a-z]/g,Q4=/^data[-\w.:]+$/i;function J4(e,t){const n=lp(t);let s=t,a=Mn;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&Q4.test(t)){if(t.charAt(4)==="-"){const l=t.slice(5).replace(g0,eI);s="data"+l.charAt(0).toUpperCase()+l.slice(1)}else{const l=t.slice(4);if(!g0.test(l)){let u=l.replace(X4,Z4);u.charAt(0)!=="-"&&(u="-"+u),t="data"+u}}a=lg}return new a(s,t)}function Z4(e){return"-"+e.toLowerCase()}function eI(e){return e.charAt(1).toUpperCase()}const tI=qw([Kw,K4,Qw,Jw,Zw],"html"),eC=qw([Kw,Y4,Qw,Jw,Zw],"svg"),x0={}.hasOwnProperty;function nI(e,t){const n=t||{};function s(a,...l){let u=s.invalid;const c=s.handlers;if(a&&x0.call(a,e)){const d=String(a[e]);u=x0.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 rI=/["&'<>`]/g,sI=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,iI=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,aI=/[|\\{}()[\]^$+*?.]/g,y0=new WeakMap;function oI(e,t){if(e=e.replace(t.subset?lI(t.subset):rI,s),t.subset||t.escapeOnly)return e;return e.replace(sI,n).replace(iI,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 lI(e){let t=y0.get(e);return t||(t=cI(e),y0.set(e,t)),t}function cI(e){const t=[];let n=-1;for(;++n<e.length;)t.push(e[n].replace(aI,"\\$&"));return new RegExp("(?:"+t.join("|")+")","g")}const uI=/[\dA-Fa-f]/;function dI(e,t,n){const s="&#x"+e.toString(16).toUpperCase();return n&&t&&!uI.test(String.fromCharCode(t))?s:s+";"}const hI=/\d/;function fI(e,t,n){const s="&#"+String(e);return n&&t&&!hI.test(String.fromCharCode(t))?s:s+";"}const mI=["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"],bm={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:"€"},pI=["cent","copy","divide","gt","lt","not","para","times"],tC={}.hasOwnProperty,dp={};let lu;for(lu in bm)tC.call(bm,lu)&&(dp[bm[lu]]=lu);const gI=/[^\dA-Za-z]/;function xI(e,t,n,s){const a=String.fromCharCode(e);if(tC.call(dp,a)){const l=dp[a],u="&"+l;return n&&mI.includes(l)&&!pI.includes(l)&&(!s||t&&t!==61&&gI.test(String.fromCharCode(t)))?u:u+";"}return""}function yI(e,t,n){let s=dI(e,t,n.omitOptionalSemicolons),a;if((n.useNamedReferences||n.useShortestReferences)&&(a=xI(e,t,n.omitOptionalSemicolons,n.attribute)),(n.useShortestReferences||!a)&&n.useShortestReferences){const l=fI(e,t,n.omitOptionalSemicolons);l.length<s.length&&(s=l)}return a&&(!n.useShortestReferences||a.length<s.length)?a:s}function $a(e,t){return oI(e,Object.assign({format:yI},t))}const _I=/^>|^->|<!--|-->|--!>|<!-$/g,bI=[">"],vI=["<",">"];function SI(e,t,n,s){return s.settings.bogusComments?"<?"+$a(e.value,Object.assign({},s.settings.characterReferences,{subset:bI}))+">":"<!--"+e.value.replace(_I,a)+"-->";function a(l){return $a(l,Object.assign({},s.settings.characterReferences,{subset:vI}))}}function wI(e,t,n,s){return"<!"+(s.settings.upperDoctype?"DOCTYPE":"doctype")+(s.settings.tightDoctype?"":" ")+"html>"}function _0(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 CI(e,t){const n=t||{};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}function kI(e){return e.join(" ").trim()}const EI=/[ \t\n\f\r]/g;function cg(e){return typeof e=="object"?e.type==="text"?b0(e.value):!1:b0(e)}function b0(e){return e.replace(EI,"")===""}const an=rC(1),nC=rC(-1),jI=[];function rC(e){return t;function t(n,s,a){const l=n?n.children:jI;let u=(s||0)+e,c=l[u];if(!a)for(;c&&cg(c);)u+=e,c=l[u];return c}}const NI={}.hasOwnProperty;function sC(e){return t;function t(n,s,a){return NI.call(e,n.tagName)&&e[n.tagName](n,s,a)}}const ug=sC({body:AI,caption:vm,colgroup:vm,dd:OI,dt:DI,head:vm,html:TI,li:RI,optgroup:II,option:MI,p:LI,rp:v0,rt:v0,tbody:BI,td:S0,tfoot:zI,th:S0,thead:PI,tr:$I});function vm(e,t,n){const s=an(n,t,!0);return!s||s.type!=="comment"&&!(s.type==="text"&&cg(s.value.charAt(0)))}function TI(e,t,n){const s=an(n,t);return!s||s.type!=="comment"}function AI(e,t,n){const s=an(n,t);return!s||s.type!=="comment"}function LI(e,t,n){const s=an(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 RI(e,t,n){const s=an(n,t);return!s||s.type==="element"&&s.tagName==="li"}function DI(e,t,n){const s=an(n,t);return!!(s&&s.type==="element"&&(s.tagName==="dt"||s.tagName==="dd"))}function OI(e,t,n){const s=an(n,t);return!s||s.type==="element"&&(s.tagName==="dt"||s.tagName==="dd")}function v0(e,t,n){const s=an(n,t);return!s||s.type==="element"&&(s.tagName==="rp"||s.tagName==="rt")}function II(e,t,n){const s=an(n,t);return!s||s.type==="element"&&s.tagName==="optgroup"}function MI(e,t,n){const s=an(n,t);return!s||s.type==="element"&&(s.tagName==="option"||s.tagName==="optgroup")}function PI(e,t,n){const s=an(n,t);return!!(s&&s.type==="element"&&(s.tagName==="tbody"||s.tagName==="tfoot"))}function BI(e,t,n){const s=an(n,t);return!s||s.type==="element"&&(s.tagName==="tbody"||s.tagName==="tfoot")}function zI(e,t,n){return!an(n,t)}function $I(e,t,n){const s=an(n,t);return!s||s.type==="element"&&s.tagName==="tr"}function S0(e,t,n){const s=an(n,t);return!s||s.type==="element"&&(s.tagName==="td"||s.tagName==="th")}const HI=sC({body:VI,colgroup:GI,head:FI,html:UI,tbody:WI});function UI(e){const t=an(e,-1);return!t||t.type!=="comment"}function FI(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 VI(e){const t=an(e,-1,!0);return!t||t.type!=="comment"&&!(t.type==="text"&&cg(t.value.charAt(0)))&&!(t.type==="element"&&(t.tagName==="meta"||t.tagName==="link"||t.tagName==="script"||t.tagName==="style"||t.tagName==="template"))}function GI(e,t,n){const s=nC(n,t),a=an(e,-1,!0);return n&&s&&s.type==="element"&&s.tagName==="colgroup"&&ug(s,n.children.indexOf(s),n)?!1:!!(a&&a.type==="element"&&a.tagName==="col")}function WI(e,t,n){const s=nC(n,t),a=an(e,-1);return n&&s&&s.type==="element"&&(s.tagName==="thead"||s.tagName==="tbody")&&ug(s,n.children.indexOf(s),n)?!1:!!(a&&a.type==="element"&&a.tagName==="tr")}const cu={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 qI(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=eC);const f=KI(s,e.properties),p=s.all(a.space==="html"&&e.tagName==="template"?e.content:e);return s.schema=a,p&&(u=!1),(f||!l||!HI(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(p),!u&&(!l||!ug(e,t,n))&&c.push("</"+e.tagName+">"),c.join("")}function KI(e,t){const n=[];let s=-1,a;if(t){for(a in t)if(t[a]!==null&&t[a]!==void 0){const l=YI(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 YI(e,t,n){const s=J4(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=$a(s.attribute,Object.assign({},e.settings.characterReferences,{subset:cu.name[a][l]}));return n===!0||(n=Array.isArray(n)?(s.commaSeparated?CI:kI)(n,{padLeft:!e.settings.tightCommaSeparatedLists}):String(n),e.settings.collapseEmptyAttributes&&!n)?d:(e.settings.preferUnquoted&&(c=$a(n,Object.assign({},e.settings.characterReferences,{attribute:!0,subset:cu.unquoted[a][l]}))),c!==n&&(e.settings.quoteSmart&&_0(n,u)>_0(n,e.alternative)&&(u=e.alternative),c=u+$a(n,Object.assign({},e.settings.characterReferences,{subset:(u==="'"?cu.single:cu.double)[a][l],attribute:!0}))+u),d+(c&&"="+c))}const XI=["<","&"];function iC(e,t,n,s){return n&&n.type==="element"&&(n.tagName==="script"||n.tagName==="style")?e.value:$a(e.value,Object.assign({},s.settings.characterReferences,{subset:XI}))}function QI(e,t,n,s){return s.settings.allowDangerousHtml?e.value:iC(e,t,n,s)}function JI(e,t,n,s){return s.all(e)}const ZI=nI("type",{invalid:eM,unknown:tM,handlers:{comment:SI,doctype:wI,element:qI,raw:QI,root:JI,text:iC}});function eM(e){throw new Error("Expected node, not `"+e+"`")}function tM(e){const t=e;throw new Error("Cannot compile unknown node `"+t.type+"`")}const nM={},rM={},sM=[];function iM(e,t){const n=t||nM,s=n.quote||'"',a=s==='"'?"'":'"';if(s!=='"'&&s!=="'")throw new Error("Invalid quote `"+s+"`, expected `'` or `\"`");return{one:aM,all:oM,settings:{omitOptionalTags:n.omitOptionalTags||!1,allowParseErrors:n.allowParseErrors||!1,allowDangerousCharacters:n.allowDangerousCharacters||!1,quoteSmart:n.quoteSmart||!1,preferUnquoted:n.preferUnquoted||!1,tightAttributes:n.tightAttributes||!1,upperDoctype:n.upperDoctype||!1,tightDoctype:n.tightDoctype||!1,bogusComments:n.bogusComments||!1,tightCommaSeparatedLists:n.tightCommaSeparatedLists||!1,tightSelfClosing:n.tightSelfClosing||!1,collapseEmptyAttributes:n.collapseEmptyAttributes||!1,allowDangerousHtml:n.allowDangerousHtml||!1,voids:n.voids||W4,characterReferences:n.characterReferences||rM,closeSelfClosing:n.closeSelfClosing||!1,closeEmptyElements:n.closeEmptyElements||!1},schema:n.space==="svg"?eC:tI,quote:s,alternative:a}.one(Array.isArray(e)?{type:"root",children:e}:e,void 0,void 0)}function aM(e,t,n){return ZI(e,t,n,this)}function oM(e){const t=[],n=e&&e.children||sM;let s=-1;for(;++s<n.length;)t[s]=this.one(n[s],s,e);return t.join("")}const w0=/\s+/g;function aC(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(w0)),Array.isArray(e.properties.class)||(e.properties.class=[]);const n=Array.isArray(t)?t:t.split(w0);for(const a of n)a&&!e.properties.class.includes(a)&&e.properties.class.push(a);return e}const lM=/:?lang=["']([^"']+)["']/g,cM=/(?:```|~~~)([\w-]+)/g,uM=/\\begin\{([\w-]+)\}/g,dM=/<script\s+(?:type|lang)=["']([^"']+)["']/gi;function hM(e){const t=md(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 fM(e,t,n){const s=new Set;for(const l of e.matchAll(lM)){const u=l[1].toLowerCase().trim();u&&s.add(u)}for(const l of e.matchAll(cM)){const u=l[1].toLowerCase().trim();u&&s.add(u)}for(const l of e.matchAll(uM)){const u=l[1].toLowerCase().trim();u&&s.add(u)}for(const l of e.matchAll(dM)){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 mM=["color","background-color"];function pM(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 gM(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?pM(a,l):a})):e}function xM(e,t,n,s,a="css-vars"){const l={content:e.content,explanation:e.explanation,offset:e.offset},u=t.map(p=>Bu(e.variants[p])),c=new Set(u.flatMap(p=>Object.keys(p))),d={},f=(p,m)=>{const x=m==="color"?"":m==="background-color"?"-bg":`-${m}`;return n+t[p]+(m==="color"?"":x)};return u.forEach((p,m)=>{for(const x of c){const y=p[x]||"inherit";if(m===0&&s&&mM.includes(x))if(s==="light-dark()"&&u.length>1){const w=t.findIndex(b=>b==="light"),C=t.findIndex(b=>b==="dark");if(w===-1||C===-1)throw new Lt('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');d[x]=`light-dark(${u[w][x]||"inherit"}, ${u[C][x]||"inherit"})`,a==="css-vars"&&(d[f(m,x)]=y)}else d[x]=y;else a==="css-vars"&&(d[f(m,x)]=y)}}),l.htmlStyle=d,l}function Bu(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 hp(e){return typeof e=="string"?e:Object.entries(e).map(([t,n])=>`${t}:${n}`).join(";")}function yM(){const e=new WeakMap;function t(n){if(!e.has(n.meta)){let l=function(c){if(typeof c=="number"){if(c<0||c>n.source.length)throw new Lt(`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 Lt(`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 Lt(`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=hM(n.source),u=(n.options.decorations||[]).map(c=>({...c,start:l(c.start),end:l(c.end)}));_M(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 gM(n,t(this).decorations.flatMap(a=>[a.start.offset,a.end.offset]))},code(n){var p;if(!((p=this.options.decorations)!=null&&p.length))return;const s=t(this),a=[...n.children].filter(m=>m.type==="element"&&m.tagName==="span");if(a.length!==s.converter.lines.length)throw new Lt(`Number of lines in code element (${a.length}) does not match the number of lines in the source (${s.converter.lines.length}). Failed to apply decorations.`);function l(m,x,y,w){const C=a[m];let b="",S=-1,v=-1;if(x===0&&(S=0),y===0&&(v=0),y===Number.POSITIVE_INFINITY&&(v=C.children.length),S===-1||v===-1)for(let E=0;E<C.children.length;E++)b+=oC(C.children[E]),S===-1&&b.length===x&&(S=E+1),v===-1&&b.length===y&&(v=E+1);if(S===-1)throw new Lt(`Failed to find start index for decoration ${JSON.stringify(w.start)}`);if(v===-1)throw new Lt(`Failed to find end index for decoration ${JSON.stringify(w.end)}`);const _=C.children.slice(S,v);if(!w.alwaysWrap&&_.length===C.children.length)c(C,w,"line");else if(!w.alwaysWrap&&_.length===1&&_[0].type==="element")c(_[0],w,"token");else{const E={type:"element",tagName:"span",properties:{},children:_};c(E,w,"wrapper"),C.children.splice(S,_.length,E)}}function u(m,x){a[m]=c(a[m],x,"line")}function c(m,x,y){var b;const w=x.properties||{},C=x.transform||(S=>S);return m.tagName=x.tagName||"span",m.properties={...m.properties,...w,class:m.properties.class},(b=x.properties)!=null&&b.class&&aC(m,x.properties.class),m=C(m,y)||m,m}const d=[],f=s.decorations.sort((m,x)=>x.start.offset-m.start.offset||m.end.offset-x.end.offset);for(const m of f){const{start:x,end:y}=m;if(x.line===y.line)l(x.line,x.character,y.character,m);else if(x.line<y.line){l(x.line,x.character,Number.POSITIVE_INFINITY,m);for(let w=x.line+1;w<y.line;w++)d.unshift(()=>u(w,m));l(y.line,0,y.character,m)}}d.forEach(m=>m())}}}function _M(e){for(let t=0;t<e.length;t++){const n=e[t];if(n.start.offset>n.end.offset)throw new Lt(`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 Lt(`Decorations ${JSON.stringify(n.start)} and ${JSON.stringify(a.start)} intersect.`)}}}}function oC(e){return e.type==="text"?e.value:e.type==="element"?e.children.map(oC).join(""):""}const bM=[yM()];function zu(e){const t=vM(e.transformers||[]);return[...t.pre,...t.normal,...t.post,...bM]}function vM(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 Ci=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],Sm={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function SM(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 C0(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 wM(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)Sm[s]&&t.push({type:"setDecoration",value:Sm[s]});else if(s<=29){const a=Sm[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:Ci[s-30]}});else if(s===38){const a=C0(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:Ci[s-40]}});else if(s===48){const a=C0(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:Ci[s-90+8]}}):s>=100&&s<=107&&t.push({type:"setBackgroundColor",value:{type:"named",name:Ci[s-100+8]}})}return t}function CM(){let e=null,t=null,n=new Set;return{parse(s){const a=[];let l=0;do{const u=SM(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=wM(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 kM={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 EM(e=kM){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<Ci.length;f++)s.push(t(Ci[f]));let c=[0,95,135,175,215,255];for(let f=0;f<6;f++)for(let p=0;p<6;p++)for(let m=0;m<6;m++)s.push(n([c[f],c[p],c[m]]));let 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 jM=/#([0-9a-f]{3,8})/i,NM=/var\((--[\w-]+-ansi-[\w-]+)\)/,TM={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 AM(e,t,n){const s=Pu(e,n),a=md(t),l=EM(Object.fromEntries(Ci.map(c=>{var f;const d=`terminal.ansi${c[0].toUpperCase()}${c.substring(1)}`;return[c,((f=e.colors)==null?void 0:f[d])||TM[c]]}))),u=CM();return a.map(c=>u.parse(c[0]).map(d=>{let f,p;d.decorations.has("reverse")?(f=d.background?l.value(d.background):e.bg,p=d.foreground?l.value(d.foreground):e.fg):(f=d.foreground?l.value(d.foreground):e.fg,p=d.background?l.value(d.background):void 0),f=Vs(f,s),p=Vs(p,s),d.decorations.has("dim")&&(f=LM(f));let m=bn.None;return d.decorations.has("bold")&&(m|=bn.Bold),d.decorations.has("italic")&&(m|=bn.Italic),d.decorations.has("underline")&&(m|=bn.Underline),d.decorations.has("strikethrough")&&(m|=bn.Strikethrough),{content:d.value,offset:c[1],color:f,bgColor:p,fontStyle:m}}))}function LM(e){const t=e.match(jM);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(NM);return n?`var(${n[1]}-dim)`:e}function fp(e,t,n={}){const s=e.resolveLangAlias(n.lang||"text"),{theme:a=e.getLoadedThemes()[0]}=n;if(!hd(s)&&!fd(a)&&s==="ansi"){const{theme:l}=e.setTheme(a);return AM(l,t,n)}return Gw(e,t,n)}function $u(e,t,n){let s,a,l,u,c,d;if("themes"in n){const{defaultColor:f="light",cssVariablePrefix:p="--shiki-",colorsRendering:m="css-vars"}=n,x=Object.entries(n.themes).filter(S=>S[1]).map(S=>({color:S[0],theme:S[1]})).sort((S,v)=>S.color===f?-1:v.color===f?1:0);if(x.length===0)throw new Lt("`themes` option must not be empty");const y=Ww(e,t,n,fp);if(d=Sl(y),f&&f!=="light-dark()"&&!x.some(S=>S.color===f))throw new Lt(`\`themes\` option must contain the defaultColor key \`${f}\``);const w=x.map(S=>e.getTheme(S.theme)),C=x.map(S=>S.color);l=y.map(S=>S.map(v=>xM(v,C,p,f,m))),d&&pd(l,d);const b=x.map(S=>Pu(S.theme,n));a=k0(x,w,b,p,f,"fg",m),s=k0(x,w,b,p,f,"bg",m),u=`shiki-themes ${w.map(S=>S.name).join(" ")}`,c=f?void 0:[a,s].join(";")}else if("theme"in n){const f=Pu(n.theme,n);l=fp(e,t,n);const p=e.getTheme(n.theme);s=Vs(p.bg,f),a=Vs(p.fg,f),u=p.name,d=Sl(l)}else throw new Lt("Invalid options, either `theme` or `themes` must be provided");return{tokens:l,fg:a,bg:s,themeName:u,rootStyle:c,grammarState:d}}function k0(e,t,n,s,a,l,u){return e.map((c,d)=>{const f=Vs(t[d][l],n[d])||"inherit",p=`${s+c.color}${l==="bg"?"-bg":""}:${f}`;if(d===0&&a){if(a==="light-dark()"&&e.length>1){const m=e.findIndex(y=>y.color==="light"),x=e.findIndex(y=>y.color==="dark");if(m===-1||x===-1)throw new Lt('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');return`light-dark(${Vs(t[m][l],n[m])||"inherit"}, ${Vs(t[x][l],n[x])||"inherit"});${p}`}return f}return u==="css-vars"?p:null}).filter(c=>!!c).join(";")}const lC=/^\s+$/,RM=/^(\s*)(.*?)(\s*)$/;function Hu(e,t,n,s={meta:{},options:n,codeToHast:(a,l)=>Hu(e,a,l),codeToTokens:(a,l)=>$u(e,a,l)}){var w,C;let a=t;for(const b of zu(n))a=((w=b.preprocess)==null?void 0:w.call(s,a,n))||a;let{tokens:l,fg:u,bg:c,themeName:d,rootStyle:f,grammarState:p}=$u(e,a,n);const{mergeWhitespaces:m=!0,mergeSameStyleTokens:x=!1}=n;m===!0?l=OM(l):m==="never"&&(l=IM(l)),x&&(l=MM(l));const y={...s,get source(){return a}};for(const b of zu(n))l=((C=b.tokens)==null?void 0:C.call(y,l))||l;return DM(l,{...n,fg:u,bg:c,themeName:d,rootStyle:n.rootStyle===!1?!1:n.rootStyle??f},y,p)}function DM(e,t,n,s=Sl(e)){var C,b,S,v;const a=zu(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[_,E]of Object.entries(t.meta||{}))_.startsWith("_")||(f[_]=E);let p={type:"element",tagName:"pre",properties:f,children:[],data:t.data},m={type:"element",tagName:"code",properties:{},children:l};const x=[],y={...n,structure:c,addClassToHast:aC,get source(){return n.source},get tokens(){return e},get options(){return t},get root(){return u},get pre(){return p},get code(){return m},get lines(){return x}};if(e.forEach((_,E)=>{var R,A;E&&(c==="inline"?u.children.push({type:"element",tagName:"br",properties:{},children:[]}):c==="classic"&&l.push({type:"text",value:`
|
|
135
|
+
`}));let j={type:"element",tagName:"span",properties:{class:"line"},children:[]},T=0;for(const D of _){let $={type:"element",tagName:"span",properties:{...D.htmlAttrs},children:[{type:"text",value:D.content}]};const q=hp(D.htmlStyle||Bu(D));q&&($.properties.style=q);for(const G of a)$=((R=G==null?void 0:G.span)==null?void 0:R.call(y,$,E+1,T,j,D))||$;c==="inline"?u.children.push($):c==="classic"&&j.children.push($),T+=D.content.length}if(c==="classic"){for(const D of a)j=((A=D==null?void 0:D.line)==null?void 0:A.call(y,j,E+1))||j;x.push(j),l.push(j)}else c==="inline"&&x.push(j)}),c==="classic"){for(const _ of a)m=((C=_==null?void 0:_.code)==null?void 0:C.call(y,m))||m;p.children.push(m);for(const _ of a)p=((b=_==null?void 0:_.pre)==null?void 0:b.call(y,p))||p;u.children.push(p)}else if(c==="inline"){const _=[];let E={type:"element",tagName:"span",properties:{class:"line"},children:[]};for(const T of u.children)T.type==="element"&&T.tagName==="br"?(_.push(E),E={type:"element",tagName:"span",properties:{class:"line"},children:[]}):(T.type==="element"||T.type==="text")&&E.children.push(T);_.push(E);let j={type:"element",tagName:"code",properties:{},children:_};for(const T of a)j=((S=T==null?void 0:T.code)==null?void 0:S.call(y,j))||j;u.children=[];for(let T=0;T<j.children.length;T++){T>0&&u.children.push({type:"element",tagName:"br",properties:{},children:[]});const R=j.children[T];R.type==="element"&&u.children.push(...R.children)}}let w=u;for(const _ of a)w=((v=_==null?void 0:_.root)==null?void 0:v.call(y,w))||w;return s&&pd(w,s),w}function OM(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&&lC.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 IM(e){return e.map(t=>t.flatMap(n=>{if(lC.test(n.content))return n;const s=n.content.match(RM);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 MM(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=hp(a.htmlStyle||Bu(a)),u=hp(s.htmlStyle||Bu(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 PM=iM;function BM(e,t,n){var l;const s={meta:{},options:n,codeToHast:(u,c)=>Hu(e,u,c),codeToTokens:(u,c)=>$u(e,u,c)};let a=PM(Hu(e,t,n,s));for(const u of zu(n))a=((l=u.postprocess)==null?void 0:l.call(s,a,n))||a;return a}async function zM(e){const t=await O4(e);return{getLastGrammarState:(...n)=>z4(t,...n),codeToTokensBase:(n,s)=>fp(t,n,s),codeToTokensWithThemes:(n,s)=>Ww(t,n,s),codeToTokens:(n,s)=>$u(t,n,s),codeToHast:(n,s)=>Hu(t,n,s),codeToHtml:(n,s)=>BM(t,n,s),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...t,getInternalContext:()=>t}}function $M(e){const t=e.langs,n=e.themes,s=e.engine;async function a(l){function u(m){var x;if(typeof m=="string"){if(m=((x=l.langAlias)==null?void 0:x[m])||m,Bw(m))return[];const y=t[m];if(!y)throw new Lt(`Language \`${m}\` is not included in this bundle. You may want to load it from external source.`);return y}return m}function c(m){if(zw(m))return"none";if(typeof m=="string"){const x=n[m];if(!x)throw new Lt(`Theme \`${m}\` is not included in this bundle. You may want to load it from external source.`);return x}return m}const d=(l.themes??[]).map(m=>c(m)),f=(l.langs??[]).map(m=>u(m)),p=await zM({engine:l.engine??s(),...l,themes:d,langs:f});return{...p,loadLanguage(...m){return p.loadLanguage(...m.map(u))},loadTheme(...m){return p.loadTheme(...m.map(c))},getBundledLanguages(){return t},getBundledThemes(){return n}}}return a}function HM(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 UM(e,t){const n=HM(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 FM=Jp({bundledLanguages:()=>cd,bundledLanguagesAlias:()=>eg,bundledLanguagesBase:()=>Zp,bundledLanguagesInfo:()=>ld,bundledThemes:()=>ng,bundledThemesInfo:()=>tg,codeToHast:()=>uC,codeToHtml:()=>cC,codeToTokens:()=>dC,codeToTokensBase:()=>hC,codeToTokensWithThemes:()=>fC,createHighlighter:()=>xd,getLastGrammarState:()=>pC,getSingletonHighlighter:()=>mC});const xd=$M({langs:cd,themes:ng,engine:()=>(0,vw.createOnigurumaEngine)(Q(()=>import("./wasm-CG6Dc4jp.js"),[]))}),{codeToHtml:cC,codeToHast:uC,codeToTokens:dC,codeToTokensBase:hC,codeToTokensWithThemes:fC,getSingletonHighlighter:mC,getLastGrammarState:pC}=UM(xd,{guessEmbeddedLanguages:fM}),E0=4294967295;var VM=class{constructor(e,t={}){be(this,"patterns");be(this,"options");be(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:E0,end:E0,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 Ja(e){if([...e].length!==1)throw new Error(`Expected "${e}" to be a single code point`);return e.codePointAt(0)}function GM(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}const dg=new Set(["alnum","alpha","ascii","blank","cntrl","digit","graph","lower","print","punct","space","upper","word","xdigit"]),un=String.raw;function Za(e,t){if(e==null)throw new Error(t??"Value expected");return e}const gC=un`\[\^?`,xC=`c.? | C(?:-.?)?|${un`[pP]\{(?:\^?[-\x20_]*[A-Za-z][-\x20\w]*\})?`}|${un`x[89A-Fa-f]\p{AHex}(?:\\x[89A-Fa-f]\p{AHex})*`}|${un`u(?:\p{AHex}{4})? | x\{[^\}]*\}? | x\p{AHex}{0,2}`}|${un`o\{[^\}]*\}?`}|${un`\d{1,3}`}`,hg=/[?*+][?+]?|\{(?:\d+(?:,\d*)?|,\d+)\}\??/,uu=new RegExp(un`
|
|
136
|
+
\\ (?:
|
|
137
|
+
${xC}
|
|
138
|
+
| [gk]<[^>]*>?
|
|
139
|
+
| [gk]'[^']*'?
|
|
140
|
+
| .
|
|
141
|
+
)
|
|
142
|
+
| \( (?:
|
|
143
|
+
\? (?:
|
|
144
|
+
[:=!>({]
|
|
145
|
+
| <[=!]
|
|
146
|
+
| <[^>]*>
|
|
147
|
+
| '[^']*'
|
|
148
|
+
| ~\|?
|
|
149
|
+
| #(?:[^)\\]|\\.?)*
|
|
150
|
+
| [^:)]*[:)]
|
|
151
|
+
)?
|
|
152
|
+
| \*[^\)]*\)?
|
|
153
|
+
)?
|
|
154
|
+
| (?:${hg.source})+
|
|
155
|
+
| ${gC}
|
|
156
|
+
| .
|
|
157
|
+
`.replace(/\s+/g,""),"gsu"),wm=new RegExp(un`
|
|
158
|
+
\\ (?:
|
|
159
|
+
${xC}
|
|
160
|
+
| .
|
|
161
|
+
)
|
|
162
|
+
| \[:(?:\^?\p{Alpha}+|\^):\]
|
|
163
|
+
| ${gC}
|
|
164
|
+
| &&
|
|
165
|
+
| .
|
|
166
|
+
`.replace(/\s+/g,""),"gsu");function WM(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=dP(n.flags),a=[s.extended],l={captureGroup:n.rules.captureGroup,getCurrentModX(){return a.at(-1)},numOpenGroups:0,popModX(){a.pop()},pushModX(m){a.push(m)},replaceCurrentModX(m){a[a.length-1]=m},singleline:n.rules.singleline};let u=[],c;for(uu.lastIndex=0;c=uu.exec(e);){const m=qM(l,e,c[0],uu.lastIndex);m.tokens?u.push(...m.tokens):m.token&&u.push(m.token),m.lastIndex!==void 0&&(uu.lastIndex=m.lastIndex)}const d=[];let f=0;u.filter(m=>m.type==="GroupOpen").forEach(m=>{m.kind==="capturing"?m.number=++f:m.raw==="("&&d.push(m)}),f||d.forEach((m,x)=>{m.kind="capturing",m.number=x+1});const p=f||d.length;return{tokens:u.map(m=>m.type==="EscapedNumber"?fP(m,p):m).flat(),flags:s}}function qM(e,t,n,s){const[a,l]=n;if(n==="["||n==="[^"){const u=KM(t,n,s);return{tokens:u.tokens,lastIndex:u.lastIndex}}if(a==="\\"){if("AbBGyYzZ".includes(l))return{token:j0(n,n)};if(/^\\g[<']/.test(n)){if(!/^\\g(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:sP(n)}}if(/^\\k[<']/.test(n)){if(!/^\\k(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:_C(n)}}if(l==="K")return{token:bC("keep",n)};if(l==="N"||l==="R")return{token:ki("newline",n,{negate:l==="N"})};if(l==="O")return{token:ki("any",n)};if(l==="X")return{token:ki("text_segment",n)};const u=yC(n,{inCharClass:!1});return Array.isArray(u)?{tokens:u}:{token:u}}if(a==="("){if(l==="*")return{token:lP(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:oP(n,e)};if(e.pushModX(e.getCurrentModX()),e.numOpenGroups++,n==="("&&!e.captureGroup||n==="(?:")return{token:Ia("group",n)};if(n==="(?>")return{token:Ia("atomic",n)};if(n==="(?="||n==="(?!"||n==="(?<="||n==="(?<!")return{token:Ia(n[2]==="<"?"lookbehind":"lookahead",n,{negate:n.endsWith("!")})};if(n==="("&&e.captureGroup||n.startsWith("(?<")&&n.endsWith(">")||n.startsWith("(?'")&&n.endsWith("'"))return{token:Ia("capturing",n,{...n!=="("&&{name:n.slice(3,-1)}})};if(n.startsWith("(?~")){if(n==="(?~|")throw new Error(`Unsupported absence function kind "${n}"`);return{token:Ia("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:tP(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:ki("dot",n)};if(n==="^"||n==="$"){const u=e.singleline?{"^":un`\A`,$:un`\Z`}[n]:n;return{token:j0(u,n)}}return n==="|"?{token:XM(n)}:hg.test(n)?{tokens:mP(n)}:{token:cs(Ja(n),n)}}function KM(e,t,n){const s=[N0(t[1]==="^",t)];let a=1,l;for(wm.lastIndex=n;l=wm.exec(e);){const u=l[0];if(u[0]==="["&&u[1]!==":")a++,s.push(N0(u[1]==="^",u));else if(u==="]"){if(s.at(-1).type==="CharacterClassOpen")s.push(cs(93,u));else if(a--,s.push(QM(u)),!a)break}else{const c=YM(u);Array.isArray(c)?s.push(...c):s.push(c)}}return{tokens:s,lastIndex:wm.lastIndex||e.length}}function YM(e){if(e[0]==="\\")return yC(e,{inCharClass:!0});if(e[0]==="["){const t=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);if(!t||!dg.has(t.groups.name))throw new Error(`Invalid POSIX class "${e}"`);return ki("posix",e,{value:t.groups.name,negate:!!t.groups.negate})}return e==="-"?JM(e):e==="&&"?ZM(e):cs(Ja(e),e)}function yC(e,{inCharClass:t}){const n=e[1];if(n==="c"||n==="C")return aP(e);if("dDhHsSwW".includes(n))return cP(e);if(e.startsWith(un`\o{`))throw new Error(`Incomplete, invalid, or unsupported octal code point "${e}"`);if(/^\\[pP]\{/.test(e)){if(e.length===3)throw new Error(`Incomplete or invalid Unicode property "${e}"`);return uP(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 cs(Ja(u),c)})}catch{throw new Error(`Multibyte code "${e}" incomplete or invalid in Oniguruma`)}if(n==="u"||n==="x")return cs(hP(e),e);if(T0.has(n))return cs(T0.get(n),e);if(/\d/.test(n))return eP(t,e);if(e==="\\")throw new Error(un`Incomplete escape "\"`);if(n==="M")throw new Error(`Unsupported meta "${e}"`);if([...e].length===2)return cs(e.codePointAt(1),e);throw new Error(`Unexpected escape "${e}"`)}function XM(e){return{type:"Alternator",raw:e}}function j0(e,t){return{type:"Assertion",kind:e,raw:t}}function _C(e){return{type:"Backreference",raw:e}}function cs(e,t){return{type:"Character",value:e,raw:t}}function QM(e){return{type:"CharacterClassClose",raw:e}}function JM(e){return{type:"CharacterClassHyphen",raw:e}}function ZM(e){return{type:"CharacterClassIntersector",raw:e}}function N0(e,t){return{type:"CharacterClassOpen",negate:e,raw:t}}function ki(e,t,n={}){return{type:"CharacterSet",kind:e,...n,raw:t}}function bC(e,t,n={}){return e==="keep"?{type:"Directive",kind:e,raw:t}:{type:"Directive",kind:e,flags:Za(n.flags),raw:t}}function eP(e,t){return{type:"EscapedNumber",inCharClass:e,raw:t}}function tP(e){return{type:"GroupClose",raw:e}}function Ia(e,t,n={}){return{type:"GroupOpen",kind:e,...n,raw:t}}function nP(e,t,n,s){return{type:"NamedCallout",kind:e,tag:t,arguments:n,raw:s}}function rP(e,t,n,s){return{type:"Quantifier",kind:e,min:t,max:n,raw:s}}function sP(e){return{type:"Subroutine",raw:e}}const iP=new Set(["COUNT","CMP","ERROR","FAIL","MAX","MISMATCH","SKIP","TOTAL_COUNT"]),T0=new Map([["a",7],["b",8],["e",27],["f",12],["n",10],["r",13],["t",9],["v",11]]);function aP(e){const t=e[1]==="c"?e[2]:e[3];if(!t||!/[A-Za-z]/.test(t))throw new Error(`Unsupported control character "${e}"`);return cs(Ja(t.toUpperCase())-64,e)}function oP(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=L0(n),u=L0(s),c={};if(l&&(c.enable=l),u&&(c.disable=u),e.endsWith(")"))return t.replaceCurrentModX(a),bC("flags",e,{flags:c});if(e.endsWith(":"))return t.pushModX(a),t.numOpenGroups++,Ia("group",e,{...(l||u)&&{flags:c}});throw new Error(`Unexpected flag modifier "${e}"`)}function lP(e){const t=/\(\*(?<name>[A-Za-z_]\w*)?(?:\[(?<tag>(?:[A-Za-z_]\w*)?)\])?(?:\{(?<args>[^}]*)\})?\)/.exec(e);if(!t)throw new Error(`Incomplete or invalid named callout "${e}"`);const{name:n,tag:s,args:a}=t.groups;if(!n)throw new Error(`Invalid named callout "${e}"`);if(s==="")throw new Error(`Named callout tag with empty value not allowed "${e}"`);const l=a?a.split(",").filter(p=>p!=="").map(p=>/^[+-]?\d+$/.test(p)?+p:p):[],[u,c,d]=l,f=iP.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 nP(f,s??null,(a==null?void 0:a.split(","))??null,e)}function A0(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 rP(t,n,s,e)}function cP(e){const t=e[1].toLowerCase();return ki({d:"digit",h:"hex",s:"space",w:"word"}[t],e,{negate:e[1]!==t})}function uP(e){const{p:t,neg:n,value:s}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(e).groups;return ki("property",e,{value:s,negate:t==="P"&&!n||t==="p"&&!!n})}function L0(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 dP(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 hP(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 fP(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[_C(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(un`Octal encoded byte above 177 unsupported "${n}"`)}else f=Ja(d);l.push(cs(f,(c===0?"\\":"")+d))}return l}function mP(e){const t=[],n=new RegExp(hg,"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(A0(a.slice(0,-1)));continue}}}t.push(A0(a))}return t}function vC(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 pP(e){return gP.has(e.type)}const gP=new Set(["AbsenceFunction","Backreference","CapturingGroup","Character","CharacterClass","CharacterSet","Group","Quantifier","Subroutine"]);function SC(e,t={}){const n={flags:"",normalizeUnknownPropertyNames:!1,skipBackrefValidation:!1,skipLookbehindValidation:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t,rules:{captureGroup:!1,singleline:!1,...t.rules}},s=WM(e,{flags:n.flags,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline}}),a=(x,y)=>{const w=s.tokens[l.nextIndex];switch(l.parent=x,l.nextIndex++,w.type){case"Alternator":return Li();case"Assertion":return xP(w);case"Backreference":return yP(w,l);case"Character":return yd(w.value,{useLastValid:!!y.isCheckingRangeEnd});case"CharacterClassHyphen":return _P(w,l,y);case"CharacterClassOpen":return bP(w,l,y);case"CharacterSet":return vP(w,l);case"Directive":return jP(w.kind,{flags:w.flags});case"GroupOpen":return SP(w,l,y);case"NamedCallout":return TP(w.kind,w.tag,w.arguments);case"Quantifier":return wP(w,l);case"Subroutine":return CP(w,l);default:throw new Error(`Unexpected token type "${w.type}"`)}},l={capturingGroups:[],hasNumberedRef:!1,namedGroupsByName:new Map,nextIndex:0,normalizeUnknownPropertyNames:n.normalizeUnknownPropertyNames,parent:null,skipBackrefValidation:n.skipBackrefValidation,skipLookbehindValidation:n.skipLookbehindValidation,skipPropertyNameValidation:n.skipPropertyNameValidation,subroutines:[],tokens:s.tokens,unicodePropertyMap:n.unicodePropertyMap,walk:a},u=LP(NP(s.flags));let c=u.body[0];for(;l.nextIndex<s.tokens.length;){const x=a(c,{});x.type==="Alternative"?(u.body.push(x),c=x):c.body.push(x)}const{capturingGroups:d,hasNumberedRef:f,namedGroupsByName:p,subroutines:m}=l;if(f&&p.size&&!n.rules.captureGroup)throw new Error("Numbered backref/subroutine not allowed when using named capture");for(const{ref:x}of m)if(typeof x=="number"){if(x>d.length)throw new Error("Subroutine uses a group number that's not defined");x&&(d[x-1].isSubroutined=!0)}else if(p.has(x)){if(p.get(x).length>1)throw new Error(un`Subroutine uses a duplicate group name "\g<${x}>"`);p.get(x)[0].isSubroutined=!0}else throw new Error(un`Subroutine uses a group name that's not defined "\g<${x}>"`);return u}function xP({kind:e}){return mp(Za({"^":"line_start",$:"line_end","\\A":"string_start","\\b":"word_boundary","\\B":"word_boundary","\\G":"search_start","\\y":"text_segment_boundary","\\Y":"text_segment_boundary","\\z":"string_end","\\Z":"string_end_newline"}[e],`Unexpected assertion kind "${e}"`),{negate:e===un`\B`||e===un`\Y`})}function yP({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,pp(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 pp(s)}return a(+s)}function _P(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(),EP(u,d);throw new Error("Invalid character class range")}return yd(Ja("-"))}function bP({negate:e},t,n){const{tokens:s,walk:a}=t,l=[Su()],u=s[t.nextIndex];let c=O0(u);for(;c.type!=="CharacterClassClose";){if(c.type==="CharacterClassIntersector")l.push(Su()),t.nextIndex++;else{const f=l.at(-1);f.body.push(a(f,n))}c=O0(s[t.nextIndex],u)}const d=Su({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 vP({kind:e,negate:t,value:n},s){const{normalizeUnknownPropertyNames:a,skipPropertyNameValidation:l,unicodePropertyMap:u}=s;if(e==="property"){const c=_d(n);if(dg.has(c)&&!(u!=null&&u.has(c)))e="posix",n=c;else return Ma(n,{negate:t,normalizeUnknownPropertyNames:a,skipPropertyNameValidation:l,unicodePropertyMap:u})}return e==="posix"?AP(n,{negate:t}):gp(e,{negate:t})}function SP(e,t,n){const{tokens:s,capturingGroups:a,namedGroupsByName:l,skipLookbehindValidation:u,walk:c}=t,d=RP(e),f=d.type==="AbsenceFunction",p=D0(d),m=p&&d.negate;if(d.type==="CapturingGroup"&&(a.push(d),d.name&&GM(l,d.name,[]).push(d)),f&&n.isInAbsenceFunction)throw new Error("Nested absence function not supported by Oniguruma");let x=I0(s[t.nextIndex]);for(;x.type!=="GroupClose";){if(x.type==="Alternator")d.body.push(Li()),t.nextIndex++;else{const y=d.body.at(-1),w=c(y,{...n,isInAbsenceFunction:n.isInAbsenceFunction||f,isInLookbehind:n.isInLookbehind||p,isInNegLookbehind:n.isInNegLookbehind||m});if(y.body.push(w),(p||n.isInLookbehind)&&!u){const C="Lookbehind includes a pattern not allowed by Oniguruma";if(m||n.isInNegLookbehind){if(R0(w)||w.type==="CapturingGroup")throw new Error(C)}else if(R0(w)||D0(w)&&w.negate)throw new Error(C)}}x=I0(s[t.nextIndex])}return t.nextIndex++,d}function wP({kind:e,min:t,max:n},s){const a=s.parent,l=a.body.at(-1);if(!l||!pP(l))throw new Error("Quantifier requires a repeatable token");const u=CC(e,t,n,l);return a.body.pop(),u}function CP({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=kC(a);return s.push(u),u}function kP(e,t){return{type:"AbsenceFunction",kind:e,body:Il(t==null?void 0:t.body)}}function Li(e){return{type:"Alternative",body:EC(e==null?void 0:e.body)}}function mp(e,t){const n={type:"Assertion",kind:e};return(e==="word_boundary"||e==="text_segment_boundary")&&(n.negate=!!(t!=null&&t.negate)),n}function pp(e,t){const n=!!(t!=null&&t.orphan);return{type:"Backreference",ref:e,...n&&{orphan:n}}}function wC(e,t){const n={name:void 0,isSubroutined:!1,...t};if(n.name!==void 0&&!DP(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:Il(t==null?void 0:t.body)}}function yd(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 Su(e){const t={kind:"union",negate:!1,...e};return{type:"CharacterClass",kind:t.kind,negate:t.negate,body:EC(e==null?void 0:e.body)}}function EP(e,t){if(t.value<e.value)throw new Error("Character class range out of order");return{type:"CharacterClassRange",min:e,max:t}}function gp(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 jP(e,t={}){if(e==="keep")return{type:"Directive",kind:e};if(e==="flags")return{type:"Directive",kind:e,flags:Za(t.flags)};throw new Error(`Unexpected directive kind "${e}"`)}function NP(e){return{type:"Flags",...e}}function br(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:Il(e==null?void 0:e.body)}}function wi(e){const t={behind:!1,negate:!1,...e};return{type:"LookaroundAssertion",kind:t.behind?"lookbehind":"lookahead",negate:t.negate,body:Il(e==null?void 0:e.body)}}function TP(e,t,n){return{type:"NamedCallout",kind:e,tag:t,arguments:n}}function AP(e,t){const n=!!(t!=null&&t.negate);if(!dg.has(e))throw new Error(`Invalid POSIX class "${e}"`);return{type:"CharacterSet",kind:"posix",value:e,negate:n}}function CC(e,t,n,s){if(t>n)throw new Error("Invalid reversed quantifier range");return{type:"Quantifier",kind:e,min:t,max:n,body:s}}function LP(e,t){return{type:"Regex",body:Il(t==null?void 0:t.body),flags:e}}function kC(e){return{type:"Subroutine",ref:e}}function Ma(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(_d(e));if(!s){if(n.normalizeUnknownPropertyNames)s=OP(e);else if(n.unicodePropertyMap&&!n.skipPropertyNameValidation)throw new Error(un`Invalid Unicode property "\p{${e}}"`)}return{type:"CharacterSet",kind:"property",value:s??e,negate:n.negate}}function RP({flags:e,kind:t,name:n,negate:s,number:a}){switch(t){case"absence_repeater":return kP("repeater");case"atomic":return br({atomic:!0});case"capturing":return wC(a,{name:n});case"group":return br({flags:e});case"lookahead":case"lookbehind":return wi({behind:t==="lookbehind",negate:s});default:throw new Error(`Unexpected group kind "${t}"`)}}function Il(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 EC(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 R0(e){return e.type==="LookaroundAssertion"&&e.kind==="lookahead"}function D0(e){return e.type==="LookaroundAssertion"&&e.kind==="lookbehind"}function DP(e){return/^[\p{Alpha}\p{Pc}][^)]*$/u.test(e)}function OP(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 _d(e){return e.replace(/[- _]+/g,"").toLowerCase()}function O0(e,t){const n=t;return Za(e,`Unclosed character class${(n==null?void 0:n.type)==="Character"&&n.value===93&&n.raw==="]"?' (started with "]")':""}`)}function I0(e){return Za(e,"Unclosed group")}function fl(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,v;let f=0,p=!1;const m={node:l,parent:u,key:c,container:d,root:e,remove(){du(d).splice(Math.max(0,ja(c)+f),1),f--,p=!0},removeAllNextSiblings(){return du(d).splice(ja(c)+1)},removeAllPrevSiblings(){const _=ja(c)+f;return f-=_,du(d).splice(0,Math.max(0,_))},replaceWith(_,E={}){const j=!!E.traverse;d?d[Math.max(0,ja(c)+f)]=_:Za(u,"Can't replace root node")[c]=_,j&&a(_,u,c,d),p=!0},replaceWithMultiple(_,E={}){const j=!!E.traverse;if(du(d).splice(Math.max(0,ja(c)+f),1,..._),f+=_.length-1,j){let T=0;for(let R=0;R<_.length;R++)T+=a(_[R],u,ja(c)+R+T,d)}p=!0},skip(){p=!0}},{type:x}=l,y=t["*"],w=t[x],C=typeof y=="function"?y:y==null?void 0:y.enter,b=typeof w=="function"?w:w==null?void 0:w.enter;if(C==null||C(m,n),b==null||b(m,n),!p)switch(x){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 "${x}"`)}return(S=w==null?void 0:w.exit)==null||S.call(w,m,n),(v=y==null?void 0:y.exit)==null||v.call(y,m,n),f}return a(e),e}function du(e){if(!Array.isArray(e))throw new Error("Container expected");return e}function ja(e){if(typeof e!="number")throw new Error("Numeric key expected");return e}const IP=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function MP(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function PP(e,t,n,s){return e.slice(0,t)+s+e.slice(t+n.length)}const dr=Object.freeze({DEFAULT:"DEFAULT",CHAR_CLASS:"CHAR_CLASS"});function fg(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:p}}=d;if(!p&&(!s||s===dr.DEFAULT==!u)){n instanceof Function?c+=n(d,{context:u?dr.CHAR_CLASS:dr.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 jC(e,t,n,s){fg(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===dr.DEFAULT==!l))return u;c==="["?l++:c==="]"&&l&&l--,a.lastIndex==u.index&&a.lastIndex++}return null}function hu(e,t,n){return!!BP(e,t,0,n)}function zP(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 M0=new RegExp(String.raw`(?<noncapturingStart>${IP})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,"gsu");function $P(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,p=NaN,m;do{m=!1;let x=0,y=0,w=!1,C;for(M0.lastIndex=Number.isNaN(p)?0:p+l.length;C=M0.exec(e);){const{0:b,index:S,groups:{capturingStart:v,noncapturingStart:_}}=C;if(b==="[")x++;else if(x)b==="]"&&x--;else if(b===a&&!w)p=S,w=!0;else if(w&&_)y++;else if(v)w?y++:(d++,u.push(d+f));else if(b===")"&&w){if(!y){f++;const E=d+f;if(e=`${e.slice(0,p)}${l}${e.slice(p+a.length,S)}))<$$${E}>)${e.slice(S+1)}`,m=!0,c.push(E),MP(n,E),s.size){const j=new Map;s.forEach((T,R)=>{j.set(R>=E?R+1:R,T.map(A=>A>=E?A+1:A))}),s=j}break}y--}}}while(m);return n.push(...c),e=fg(e,String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,({0:x,groups:{backrefNum:y,wrappedBackrefNum:w}})=>{if(y){const C=+y;if(C>u.length-1)throw new Error(`Backref "${x}" greater than number of captures`);return`\\${u[C]}`}return`\\${w}`},dr.DEFAULT),{pattern:e,captureTransfers:s,hiddenCaptures:n}}const NC=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,Cm=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>${NC})(?<qMod>[?+]?)(?<invalidQ>[?*+\{]?)
|
|
181
|
+
| \\?.
|
|
182
|
+
`.replace(/\s+/g,""),"gsu");function HP(e){if(!new RegExp(`${NC}\\+`).test(e))return{pattern:e};const t=[];let n=null,s=null,a="",l=0,u;for(Cm.lastIndex=0;u=Cm.exec(e);){const{0:c,index:d,groups:{qBase:f,qMod:p,invalidQ:m}}=u;if(c==="[")l||(s=d),l++;else if(c==="]")l?l--:s=null;else if(!l)if(p==="+"&&a&&!a.startsWith("(")){if(m)throw new Error(`Invalid quantifier "${c}"`);let x=-1;if(/^\{\d+\}$/.test(f))e=PP(e,d+f.length,p,"");else{if(a===")"||a==="]"){const y=a===")"?n:s;if(y===null)throw new Error(`Invalid unmatched "${a}"`);e=`${e.slice(0,y)}(?>${e.slice(y,d)}${f})${e.slice(d+c.length)}`}else e=`${e.slice(0,d-a.length)}(?>${a}${f})${e.slice(d+c.length)}`;x+=4}Cm.lastIndex+=x}else c[0]==="("?t.push(d):c===")"&&(n=t.length?t.pop():null);a=c}return{pattern:e}}const ur=String.raw,UP=ur`\\g<(?<gRNameOrNum>[^>&]+)&R=(?<gRDepth>[^>]+)>`,xp=ur`\(\?R=(?<rDepth>[^\)]+)\)|${UP}`,bd=ur`\(\?<(?![=!])(?<captureName>[^>]+)>`,TC=ur`${bd}|(?<unnamed>\()(?!\?)`,gi=new RegExp(ur`${bd}|${xp}|\(\?|\\?.`,"gsu"),km="Cannot use multiple overlapping recursions";function FP(e,t){const{hiddenCaptures:n,mode:s}={hiddenCaptures:[],mode:"plugin",...t};let a=(t==null?void 0:t.captureTransfers)??new Map;if(!new RegExp(xp,"su").test(e))return{pattern:e,captureTransfers:a,hiddenCaptures:n};if(s==="plugin"&&hu(e,ur`\(\?\(DEFINE\)`,dr.DEFAULT))throw new Error("DEFINE groups cannot be used with recursion");const l=[],u=hu(e,ur`\\[1-9]`,dr.DEFAULT),c=new Map,d=[];let f=!1,p=0,m=0,x;for(gi.lastIndex=0;x=gi.exec(e);){const{0:y,groups:{captureName:w,rDepth:C,gRNameOrNum:b,gRDepth:S}}=x;if(y==="[")p++;else if(p)y==="]"&&p--;else if(C){if(P0(C),f)throw new Error(km);if(u)throw new Error(`${s==="external"?"Backrefs":"Numbered backrefs"} cannot be used with global recursion`);const v=e.slice(0,x.index),_=e.slice(gi.lastIndex);if(hu(_,xp,dr.DEFAULT))throw new Error(km);const E=+C-1;e=B0(v,_,E,!1,n,l,m),a=$0(a,v,E,l.length,0,m);break}else if(b){P0(S);let v=!1;for(const G of d)if(G.name===b||G.num===+b){if(v=!0,G.hasRecursedWithin)throw new Error(km);break}if(!v)throw new Error(ur`Recursive \g cannot be used outside the referenced group "${s==="external"?b:ur`\g<${b}&R=${S}>`}"`);const _=c.get(b),E=zP(e,_);if(u&&hu(E,ur`${bd}|\((?!\?)`,dr.DEFAULT))throw new Error(`${s==="external"?"Backrefs":"Numbered backrefs"} cannot be used with recursion of capturing groups`);const j=e.slice(_,x.index),T=E.slice(j.length+y.length),R=l.length,A=+S-1,D=B0(j,T,A,!0,n,l,m);a=$0(a,j,A,l.length-R,R,m);const $=e.slice(0,_),q=e.slice(_+E.length);e=`${$}${D}${q}`,gi.lastIndex+=D.length-y.length-j.length-T.length,d.forEach(G=>G.hasRecursedWithin=!0),f=!0}else if(w)m++,c.set(String(m),gi.lastIndex),c.set(w,gi.lastIndex),d.push({num:m,name:w});else if(y[0]==="("){const v=y==="(";v&&(m++,c.set(String(m),gi.lastIndex)),d.push(v?{num:m}:{})}else y===")"&&d.pop()}return n.push(...l),{pattern:e,captureTransfers:a,hiddenCaptures:n}}function P0(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 B0(e,t,n,s,a,l,u){const c=new Set;s&&jC(e+t,bd,({groups:{captureName:f}})=>{c.add(f)},dr.DEFAULT);const d=[n,s?c:null,a,l,u];return`${e}${z0(`(?:${e}`,"forward",...d)}(?:)${z0(`${t})`,"backward",...d)}${t}`}function z0(e,t,n,s,a,l,u){const d=p=>t==="forward"?p+2:n-p+2-1;let f="";for(let p=0;p<n;p++){const m=d(p);f+=fg(e,ur`${TC}|\\k<(?<backref>[^>]+)>`,({0:x,groups:{captureName:y,unnamed:w,backref:C}})=>{if(C&&s&&!s.has(C))return x;const b=`_$${m}`;if(w||y){const S=u+l.length+1;return l.push(S),VP(a,S),w?x:`(?<${y}${b}>`}return ur`\k<${C}${b}>`},dr.DEFAULT)}return f}function VP(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function $0(e,t,n,s,a,l){if(e.size&&s){let u=0;jC(t,TC,()=>u++,dr.DEFAULT);const c=l-u+a,d=new Map;return e.forEach((f,p)=>{const m=(s-u*n)/n,x=u*n,y=p>c+u?p+s:p,w=[];for(const C of f)if(C<=c)w.push(C);else if(C>c+u+m)w.push(C+s);else if(C<=c+u)for(let b=0;b<=n;b++)w.push(C+u*b);else for(let b=0;b<=n;b++)w.push(C+x+m*b);d.set(y,w)}),d}return e}var sn=String.fromCodePoint,Ke=String.raw,wr={},vd=globalThis.RegExp;wr.flagGroups=(()=>{try{new vd("(?i:)")}catch{return!1}return!0})();wr.unicodeSets=(()=>{try{new vd("[[]]","v")}catch{return!1}return!0})();wr.bugFlagVLiteralHyphenIsRange=wr.unicodeSets?(()=>{try{new vd(Ke`[\d\-a]`,"v")}catch{return!0}return!1})():!1;wr.bugNestedClassIgnoresNegation=wr.unicodeSets&&new vd("[[^a]]","v").test("a");function Uu(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 wl(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}function yp(e,t){return H0[e]>=H0[t]}function GP(e,t){if(e==null)throw new Error(t??"Value expected");return e}var H0={ES2025:2025,ES2024:2024,ES2018:2018},WP={auto:"auto",ES2025:"ES2025",ES2024:"ES2024",ES2018:"ES2018"};function AC(e={}){if({}.toString.call(e)!=="[object Object]")throw new Error("Unexpected options");if(e.target!==void 0&&!WP[e.target])throw new Error(`Unexpected target "${e.target}"`);const t={accuracy:"default",avoidSubclass:!1,flags:"",global:!1,hasIndices:!1,lazyCompileLength:1/0,target:"auto",verbose:!1,...e,rules:{allowOrphanBackrefs:!1,asciiWordBoundaries:!1,captureGroup:!1,recursionLimit:20,singleline:!1,...e.rules}};return t.target==="auto"&&(t.target=wr.flagGroups?"ES2025":wr.unicodeSets?"ES2024":"ES2018"),t}var qP="[ -\r ]",KP=new Set([sn(304),sn(305)]),rs=Ke`[\p{L}\p{M}\p{N}\p{Pc}]`;function LC(e){if(KP.has(e))return[e];const t=new Set,n=e.toLowerCase(),s=n.toUpperCase(),a=QP.get(n),l=YP.get(n),u=XP.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 mg=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=>[_d(e),e])),YP=new Map([["s",sn(383)],[sn(383),"s"]]),XP=new Map([[sn(223),sn(7838)],[sn(107),sn(8490)],[sn(229),sn(8491)],[sn(969),sn(8486)]]),QP=new Map([Ps(453),Ps(456),Ps(459),Ps(498),...Em(8072,8079),...Em(8088,8095),...Em(8104,8111),Ps(8124),Ps(8140),Ps(8188)]),JP=new Map([["alnum",Ke`[\p{Alpha}\p{Nd}]`],["alpha",Ke`\p{Alpha}`],["ascii",Ke`\p{ASCII}`],["blank",Ke`[\p{Zs}\t]`],["cntrl",Ke`\p{Cc}`],["digit",Ke`\p{Nd}`],["graph",Ke`[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]`],["lower",Ke`\p{Lower}`],["print",Ke`[[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],["punct",Ke`[\p{P}\p{S}]`],["space",Ke`\p{space}`],["upper",Ke`\p{Upper}`],["word",Ke`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],["xdigit",Ke`\p{AHex}`]]);function ZP(e,t){const n=[];for(let s=e;s<=t;s++)n.push(s);return n}function Ps(e){const t=sn(e);return[t.toLowerCase(),t]}function Em(e,t){return ZP(e,t).map(n=>Ps(n))}var RC=new Set(["Lower","Lowercase","Upper","Uppercase","Ll","Lowercase_Letter","Lt","Titlecase_Letter","Lu","Uppercase_Letter"]);function e6(e,t){const n={accuracy:"default",asciiWordBoundaries:!1,avoidSubclass:!1,bestEffortTarget:"ES2025",...t};DC(e);const s={accuracy:n.accuracy,asciiWordBoundaries:n.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,flagDirectivesByAlt:new Map,jsGroupNameMap:new Map,minTargetEs2024:yp(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};fl(e,t6,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};fl(e,n6,l);const u={groupsByName:l.groupsByName,highestOrphanBackref:0,numCapturesToLeft:0,reffedNodesByReferencer:l.reffedNodesByReferencer};return fl(e,r6,u),e._originMap=l.groupOriginByCopy,e._strategy=s.strategy,e}var t6={AbsenceFunction({node:e,parent:t,replaceWith:n}){const{body:s,kind:a}=e;if(a==="repeater"){const l=br();l.body[0].body.push(wi({negate:!0,body:s}),Ma("Any"));const u=br();u.body[0].body.push(CC("greedy",0,1/0,l)),n(Wt(u,t),{traverse:!0})}else throw new Error('Unsupported absence function "(?~|"')},Alternative:{enter({node:e,parent:t,key:n},{flagDirectivesByAlt:s}){const a=e.body.filter(l=>l.kind==="flags");for(let l=n+1;l<t.body.length;l++){const u=t.body[l];wl(s,u,[]).push(...a)}},exit({node:e},{flagDirectivesByAlt:t}){var n;if((n=t.get(e))!=null&&n.length){const s=IC(t.get(e));if(s){const a=br({flags:s});a.body[0].body=e.body,e.body=[Wt(a,e)]}}}},Assertion({node:e,parent:t,key:n,container:s,root:a,remove:l,replaceWith:u},c){const{kind:d,negate:f}=e,{asciiWordBoundaries:p,avoidSubclass:m,supportedGNodes:x,wordIsAscii:y}=c;if(d==="text_segment_boundary")throw new Error(`Unsupported text segment boundary "\\${f?"Y":"y"}"`);if(d==="line_end")u(Wt(wi({body:[Li({body:[mp("string_end")]}),Li({body:[yd(10)]})]}),t));else if(d==="line_start")u(Wt(ss(Ke`(?<=\A|\n(?!\z))`,{skipLookbehindValidation:!0}),t));else if(d==="search_start")if(x.has(e))a.flags.sticky=!0,l();else{const w=s[n-1];if(w&&c6(w))u(Wt(wi({negate:!0}),t));else{if(m)throw new Error(Ke`Uses "\G" in a way that requires a subclass`);u(Bs(mp("string_start"),t)),c.strategy="clip_search"}}else if(!(d==="string_end"||d==="string_start"))if(d==="string_end_newline")u(Wt(ss(Ke`(?=\n?\z)`),t));else if(d==="word_boundary"){if(!y&&!p){const w=`(?:(?<=${rs})(?!${rs})|(?<!${rs})(?=${rs}))`,C=`(?:(?<=${rs})(?=${rs})|(?<!${rs})(?!${rs}))`;u(Wt(ss(f?C:w),t))}}else throw new Error(`Unexpected assertion kind "${d}"`)},Backreference({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n=="string"&&!Nm(n)&&(n=jm(n,t),e.ref=n)},CapturingGroup({node:e},{jsGroupNameMap:t,subroutineRefMap:n}){let{name:s}=e;s&&!Nm(s)&&(s=jm(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=Su({body:[e]});n(Wt(s,t),{traverse:!0})}},CharacterSet({node:e,parent:t,replaceWith:n},{accuracy:s,minTargetEs2024:a,digitIsAscii:l,spaceIsAscii:u,wordIsAscii:c}){const{kind:d,negate:f,value:p}=e;if(l&&(d==="digit"||p==="digit")){n(Bs(gp("digit",{negate:f}),t));return}if(u&&(d==="space"||p==="space")){n(Wt(Tm(ss(qP),f),t));return}if(c&&(d==="word"||p==="word")){n(Bs(gp("word",{negate:f}),t));return}if(d==="any")n(Bs(Ma("Any"),t));else if(d==="digit")n(Bs(Ma("Nd",{negate:f}),t));else if(d!=="dot")if(d==="text_segment"){if(s==="strict")throw new Error(Ke`Use of "\X" requires non-strict accuracy`);const m="\\p{Emoji}(?:\\p{EMod}|\\uFE0F\\u20E3?|[\\x{E0020}-\\x{E007E}]+\\x{E007F})?",x=Ke`\p{RI}{2}|${m}(?:\u200D${m})*`;n(Wt(ss(Ke`(?>\r\n|${a?Ke`\p{RGI_Emoji}`:x}|\P{M}\p{M}*)`,{skipPropertyNameValidation:!0}),t))}else if(d==="hex")n(Bs(Ma("AHex",{negate:f}),t));else if(d==="newline")n(Wt(ss(f?`[^
|
|
273
|
+
]`:`(?>\r
|
|
274
|
+
?|[
|
|
275
|
+
\v\f
\u2028\u2029])`),t));else if(d==="posix")if(!a&&(p==="graph"||p==="print")){if(s==="strict")throw new Error(`POSIX class "${p}" requires min target ES2024 or non-strict accuracy`);let m={graph:"!-~",print:" -~"}[p];f&&(m=`\0-${sn(m.codePointAt(0)-1)}${sn(m.codePointAt(2)+1)}-`),n(Wt(ss(`[${m}]`),t))}else n(Wt(Tm(ss(JP.get(p)),f),t));else if(d==="property")mg.has(_d(p))||(e.key="sc");else if(d==="space")n(Bs(Ma("space",{negate:f}),t));else if(d==="word")n(Wt(Tm(ss(rs),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=br({flags:d});f.body[0].body=u(),a(Wt(f,t),{traverse:!0})}else if(c==="keep"){const f=n.body[0],m=n.body.length===1&&vC(f,{type:"Group"})&&f.body[0].body.length===1?f.body[0]:n;if(t.parent!==m||m.body.length>1)throw new Error(Ke`Uses "\K" in a way that's unsupported`);const x=wi({behind:!0});x.body[0].body=l(),a(Wt(x,t))}else throw new Error(`Unexpected directive kind "${c}"`)},Flags({node:e,parent:t}){if(e.posixIsAscii)throw new Error('Unsupported flag "P"');if(e.textSegmentMode==="word")throw new Error('Unsupported flag "y{w}"');["digitIsAscii","extended","posixIsAscii","spaceIsAscii","wordIsAscii","textSegmentMode"].forEach(n=>delete e[n]),Object.assign(e,{global:!1,hasIndices:!1,multiline:!1,sticky:e.sticky??!1}),t.options={disable:{x:!0,n:!0},force:{v:!0}}},Group({node:e}){if(!e.flags)return;const{enable:t,disable:n}=e.flags;t!=null&&t.extended&&delete t.extended,n!=null&&n.extended&&delete n.extended,t!=null&&t.dotAll&&(n!=null&&n.dotAll)&&delete t.dotAll,t!=null&&t.ignoreCase&&(n!=null&&n.ignoreCase)&&delete t.ignoreCase,t&&!Object.keys(t).length&&delete e.flags.enable,n&&!Object.keys(n).length&&delete e.flags.disable,!e.flags.enable&&!e.flags.disable&&delete e.flags},LookaroundAssertion({node:e},t){const{kind:n}=e;n==="lookbehind"&&(t.passedLookbehind=!0)},NamedCallout({node:e,parent:t,replaceWith:n}){const{kind:s}=e;if(s==="fail")n(Wt(wi({negate:!0}),t));else throw new Error(`Unsupported named callout "(*${s.toUpperCase()}"`)},Quantifier({node:e}){if(e.body.type==="Quantifier"){const t=br();t.body[0].body.push(e.body),e.body=Wt(t,e)}},Regex:{enter({node:e},{supportedGNodes:t}){const n=[];let s=!1,a=!1;for(const l of e.body)if(l.body.length===1&&l.body[0].kind==="search_start")l.body.pop();else{const u=PC(l.body);u?(s=!0,Array.isArray(u)?n.push(...u):n.push(u)):a=!0}s&&!a&&n.forEach(l=>t.add(l))},exit(e,{accuracy:t,passedLookbehind:n,strategy:s}){if(t==="strict"&&n&&s)throw new Error(Ke`Uses "\G" in a way that requires non-strict accuracy`)}},Subroutine({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n=="string"&&!Nm(n)&&(n=jm(n,t),e.ref=n)}},n6={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 m=Bs(U0(e.number),t);d.set(m,c.get(e.number)),n(m);return}c.set(e.number,e),u.set(e.number,[]),e.name&&wl(u,e.name,[]);const p=u.get(e.name??e.number);for(let m=0;m<p.length;m++){const x=p[m];if(f===x.node||f&&f===x.origin||e===x.origin){p.splice(m,1);break}}if(u.get(e.number).push({node:e,origin:f}),e.name&&u.get(e.name).push({node:e,origin:f}),e.name){const m=wl(l,e.name,new Map);let x=!1;if(f)x=!0;else for(const y of m.values())if(!y.hasDuplicateNameToRemove){x=!0;break}l.get(e.name).set(e,{node:e,hasDuplicateNameToRemove:x})}},exit({node:e},{openRefs:t}){t.get(e.number)===e&&t.delete(e.number)}},Group:{enter({node:e},t){t.prevFlags=t.currentFlags,e.flags&&(t.currentFlags=Uu(t.currentFlags,e.flags))},exit(e,t){t.currentFlags=t.prevFlags}},Subroutine({node:e,parent:t,replaceWith:n},s){const{isRecursive:a,ref:l}=e;if(a){let p=t;for(;(p=p.parent)&&!(p.type==="CapturingGroup"&&(p.name===l||p.number===l)););s.reffedNodesByReferencer.set(e,p);return}const u=s.subroutineRefMap.get(l),c=l===0,d=c?U0(0):OC(u,s.groupOriginByCopy,null);let f=d;if(!c){const p=IC(a6(u,x=>x.type==="Group"&&!!x.flags)),m=p?Uu(s.globalFlags,p):s.globalFlags;s6(m,s.currentFlags)||(f=br({flags:o6(m)}),f.body[0].body.push(d))}n(Wt(f,t),{traverse:!c})}},r6={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=>i6(u,e));if(!l.length)n(Wt(wi({negate:!0}),t));else if(l.length>1){const u=br({atomic:!0,body:l.reverse().map(c=>Li({body:[pp(c.number)]}))});n(Wt(u,t))}else e.ref=l[0].number},CapturingGroup({node:e},t){e.number=++t.numCapturesToLeft,e.name&&t.groupsByName.get(e.name).get(e).hasDuplicateNameToRemove&&delete e.name},Regex:{exit({node:e},t){const n=Math.max(t.highestOrphanBackref-t.numCapturesToLeft,0);for(let s=0;s<n;s++){const a=wC();e.body.at(-1).body.push(a)}}},Subroutine({node:e},t){!e.isRecursive||e.ref===0||(e.ref=t.reffedNodesByReferencer.get(e).number)}};function DC(e){fl(e,{"*"({node:t,parent:n}){t.parent=n}})}function s6(e,t){return e.dotAll===t.dotAll&&e.ignoreCase===t.ignoreCase}function i6(e,t){let n=t;do{if(n.type==="Regex")return!1;if(n.type==="Alternative")continue;if(n===e)return!1;const s=MC(n.parent);for(const a of s){if(a===n)break;if(a===e||BC(a,e))return!0}}while(n=n.parent);throw new Error("Unexpected path")}function OC(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]=OC(u,t,a,n):(l==="type"&&u==="CapturingGroup"&&t.set(a,t.get(e)??e),a[l]=u);return a}function U0(e){const t=kC(e);return t.isRecursive=!0,t}function a6(e,t){const n=[];for(;e=e.parent;)(!t||t(e))&&n.push(e);return n}function jm(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 IC(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 o6({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 MC(e){if(!e)throw new Error("Node expected");const{body:t}=e;return Array.isArray(t)?t:t?[t]:null}function PC(e){const t=e.find(n=>n.kind==="search_start"||u6(n,{negate:!1})||!l6(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=PC(s.body);if(!a)return null;Array.isArray(a)?n.push(...a):n.push(a)}return n}return null}function BC(e,t){const n=MC(e)??[];for(const s of n)if(s===t||BC(s,t))return!0;return!1}function l6({type:e}){return e==="Assertion"||e==="Directive"||e==="LookaroundAssertion"}function c6(e){const t=["Character","CharacterClass","CharacterSet"];return t.includes(e.type)||e.type==="Quantifier"&&e.min&&t.includes(e.body.type)}function u6(e,t){const n={negate:null,...t};return e.type==="LookaroundAssertion"&&(n.negate===null||e.negate===n.negate)&&e.body.length===1&&vC(e.body[0],{type:"Assertion",kind:"search_start"})}function Nm(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function ss(e,t){const s=SC(e,{...t,unicodePropertyMap:mg}).body;return s.length>1||s[0].body.length>1?br({body:s}):s[0].body[0]}function Tm(e,t){return e.negate=t,e}function Bs(e,t){return e.parent=t,e}function Wt(e,t){return DC(e),e.parent=t,e}function d6(e,t){const n=AC(t),s=yp(n.target,"ES2024"),a=yp(n.target,"ES2025"),l=n.rules.recursionLimit;if(!Number.isInteger(l)||l<2||l>20)throw new Error("Invalid recursionLimit; use 2-20");let u=null,c=null;if(!a){const y=[e.flags.ignoreCase];fl(e,h6,{getCurrentModI:()=>y.at(-1),popModI(){y.pop()},pushModI(w){y.push(w)},setHasCasedChar(){y.at(-1)?u=!0:c=!0}})}const d={dotAll:e.flags.dotAll,ignoreCase:!!((e.flags.ignoreCase||u)&&!c)};let f=e;const p={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 m(y){return p.lastNode=f,f=y,GP(f6[y.type],`Unexpected node type "${y.type}"`)(y,p,m)}const x={pattern:e.body.map(m).join("|"),flags:m(e.flags),options:{...e.options}};return s||(delete x.options.force.v,x.options.disable.v=!0,x.options.unicodeSetsPlugin=null),x._captureTransfers=new Map,x._hiddenCaptures=[],p.captureMap.forEach((y,w)=>{y.hidden&&x._hiddenCaptures.push(w),y.transferTo&&wl(x._captureTransfers,y.transferTo,[]).push(w)}),x}var h6={"*":{enter({node:e},t){if(V0(e)){const n=t.getCurrentModI();t.pushModI(e.flags?Uu({ignoreCase:n},e.flags).ignoreCase:n)}},exit({node:e},t){V0(e)&&t.popModI()}},Backreference(e,t){t.setHasCasedChar()},Character({node:e},t){pg(sn(e.value))&&t.setHasCasedChar()},CharacterClassRange({node:e,skip:t},n){t(),zC(e,{firstOnly:!0}).length&&n.setHasCasedChar()},CharacterSet({node:e},t){e.kind==="property"&&RC.has(e.value)&&t.setHasCasedChar()}},f6={Alternative({body:e},t,n){return e.map(n).join("")},Assertion({kind:e,negate:t}){if(e==="string_end")return"$";if(e==="string_start")return"^";if(e==="word_boundary")return t?Ke`\B`:Ke`\b`;throw new Error(`Unexpected assertion kind "${e}"`)},Backreference({ref:e},t){if(typeof e!="number")throw new Error("Unexpected named backref in transformed AST");if(!t.useFlagMods&&t.accuracy==="strict"&&t.currentFlags.ignoreCase&&!t.captureMap.get(e).ignoreCase)throw new Error("Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy");return"\\"+e},CapturingGroup(e,t,n){const{body:s,name:a,number:l}=e,u={ignoreCase:t.currentFlags.ignoreCase},c=t.originMap.get(e);return c&&(u.hidden=!0,l>c.number&&(u.transferTo=c.number)),t.captureMap.set(l,u),`(${a?`?<${a}>`:""}${s.map(n).join("|")})`},Character({value:e},t){const n=sn(e),s=Na(e,{escDigit:t.lastNode.type==="Backreference",inCharClass:t.inCharClass,useFlagV:t.useFlagV});if(s!==n)return s;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&pg(n)){const a=LC(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(G0)&&(u=[yd(45),...u.filter(f=>!G0(f))]);const c=()=>`[${a?"^":""}${u.map(n).join(s==="intersection"?"&&":"")}]`;if(!t.inCharClass){if((!t.useFlagV||wr.bugNestedClassIgnoresNegation)&&!a){const p=u.filter(m=>m.type==="CharacterClass"&&m.kind==="union"&&m.negate);if(p.length){const m=br(),x=m.body[0];return m.parent=l,x.parent=m,u=u.filter(y=>!p.includes(y)),e.body=u,u.length?(e.parent=x,x.body.push(e)):m.body.pop(),p.forEach(y=>{const w=Li({body:[y]});y.parent=w,w.parent=m,m.body.push(w)}),n(m)}}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=Na(n,a),u=Na(s,a),c=new Set;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase){const d=zC(e);y6(d).forEach(p=>{c.add(Array.isArray(p)?`${Na(p[0],a)}-${Na(p[1],a)}`:Na(p,a))})}return`${l}-${u}${[...c].join("")}`},CharacterSet({kind:e,negate:t,value:n,key:s},a){if(e==="dot")return a.currentFlags.dotAll?a.appliedGlobalFlags.dotAll||a.useFlagMods?".":"[^]":Ke`[^\n]`;if(e==="digit")return t?Ke`\D`:Ke`\d`;if(e==="property"){if(a.useAppliedIgnoreCase&&a.currentFlags.ignoreCase&&RC.has(n))throw new Error(`Unicode property "${n}" can't be case-insensitive when other chars have specific case`);return`${t?Ke`\P`:Ke`\p`}{${s?`${s}=`:""}${n}}`}if(e==="word")return t?Ke`\W`:Ke`\w`;throw new Error(`Unexpected character set kind "${e}"`)},Flags(e,t){return(t.appliedGlobalFlags.ignoreCase?"i":"")+(e.dotAll?"s":"")+(e.sticky?"y":"")},Group({atomic:e,body:t,flags:n,parent:s},a,l){const u=a.currentFlags;n&&(a.currentFlags=Uu(u,n));const c=t.map(l).join("|"),d=!a.verbose&&t.length===1&&s.type!=="Quantifier"&&!e&&(!a.useFlagMods||!n)?c:`(?${_6(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)+b6(e)},Subroutine({isRecursive:e,ref:t},n){if(!e)throw new Error("Unexpected non-recursive subroutine in transformed AST");const s=n.recursionLimit;return t===0?`(?R=${s})`:Ke`\g<${t}&R=${s}>`}},m6=new Set(["$","(",")","*","+",".","?","[","\\","]","^","{","|","}"]),p6=new Set(["-","\\","]","^","["]),g6=new Set(["(",")","-","/","[","\\","]","^","{","|","}","!","#","$","%","&","*","+",",",".",":",";","<","=",">","?","@","`","~"]),F0=new Map([[9,Ke`\t`],[10,Ke`\n`],[11,Ke`\v`],[12,Ke`\f`],[13,Ke`\r`],[8232,Ke`\u2028`],[8233,Ke`\u2029`],[65279,Ke`\uFEFF`]]),x6=new RegExp("^\\p{Cased}$","u");function pg(e){return x6.test(e)}function zC(e,t){const n=!!(t!=null&&t.firstOnly),s=e.min.value,a=e.max.value,l=[];if(s<65&&(a===65535||a>=131071)||s===65536&&a>=131071)return l;for(let u=s;u<=a;u++){const c=sn(u);if(!pg(c))continue;const d=LC(c).filter(f=>{const p=f.codePointAt(0);return p<s||p>a});if(d.length&&(l.push(...d),n))break}return l}function Na(e,{escDigit:t,inCharClass:n,useFlagV:s}){if(F0.has(e))return F0.get(e);if(e<32||e>126&&e<160||e>262143||t&&v6(e))return e>255?`\\u{${e.toString(16).toUpperCase()}}`:`\\x${e.toString(16).toUpperCase().padStart(2,"0")}`;const a=n?s?g6:p6:m6,l=sn(e);return(a.has(l)?"\\":"")+l}function y6(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 _6(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 b6({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 V0({type:e}){return e==="CapturingGroup"||e==="Group"||e==="LookaroundAssertion"}function v6(e){return e>47&&e<58}function G0({type:e,value:t}){return e==="Character"&&t===45}var zs,os,Ei,$s,ji,Cl,_p,Gs,S6=(Gs=class extends RegExp{constructor(n,s,a){var t=(...M$)=>(super(...M$),fi(this,Cl),fi(this,zs,new Map),fi(this,os,null),fi(this,Ei),fi(this,$s,null),fi(this,ji,null),be(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,Ei,u.source),u instanceof Gs&&(xr(this,zs,Cn(u,zs)),xr(this,$s,Cn(u,$s)),xr(this,ji,Cn(u,ji)),this.rawOptions=u.rawOptions)}else{const u={hiddenCaptures:[],strategy:null,transfers:[],...a};t(l?"":n,s),xr(this,Ei,n),xr(this,zs,C6(u.hiddenCaptures,u.transfers)),xr(this,ji,u.strategy),this.rawOptions=a??{}}l||xr(this,os,this)}get source(){return Cn(this,Ei)||"(?:)"}exec(n){if(!Cn(this,os)){const{lazyCompile:l,...u}=this.rawOptions;xr(this,os,new Gs(Cn(this,Ei),this.flags,u))}const s=this.global||this.sticky,a=this.lastIndex;if(Cn(this,ji)==="clip_search"&&s&&a){this.lastIndex=0;const l=Of(this,Cl,_p).call(this,n.slice(a));return l&&(w6(l,a,n,this.hasIndices),this.lastIndex+=a),l}return Of(this,Cl,_p).call(this,n)}},zs=new WeakMap,os=new WeakMap,Ei=new WeakMap,$s=new WeakMap,ji=new WeakMap,Cl=new WeakSet,_p=function(n){Cn(this,os).lastIndex=this.lastIndex;const s=db(Gs.prototype,this,"exec").call(Cn(this,os),n);if(this.lastIndex=Cn(this,os).lastIndex,!s||!Cn(this,zs).size)return s;const a=[...s];s.length=1;let l;this.hasIndices&&(l=[...s.indices],s.indices.length=1);const u=[0];for(let c=1;c<a.length;c++){const{hidden:d,transferTo:f}=Cn(this,zs).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 p=u[f];if(!p)throw new Error(`Invalid capture transfer to "${p}"`);if(s[p]=a[c],this.hasIndices&&(s.indices[p]=l[c]),s.groups){Cn(this,$s)||xr(this,$s,k6(this.source));const m=Cn(this,$s).get(f);m&&(s.groups[m]=a[c],this.hasIndices&&(s.indices.groups[m]=l[c]))}}}return s},Gs);function w6(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 C6(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)wl(n,l,{}).transferTo=s;return n}function k6(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 E6(e,t){const n=j6(e,t);return n.options?new S6(n.pattern,n.flags,n.options):new RegExp(n.pattern,n.flags)}function j6(e,t){const n=AC(t),s=SC(e,{flags:n.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline},skipBackrefValidation:n.rules.allowOrphanBackrefs,unicodePropertyMap:mg}),a=e6(s,{accuracy:n.accuracy,asciiWordBoundaries:n.rules.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,bestEffortTarget:n.target}),l=d6(a,n),u=FP(l.pattern,{captureTransfers:l._captureTransfers,hiddenCaptures:l._hiddenCaptures,mode:"external"}),c=HP(u.pattern),d=$P(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 p=d.hiddenCaptures.sort((w,C)=>w-C),m=Array.from(d.captureTransfers),x=a._strategy,y=f.pattern.length>=n.lazyCompileLength;(p.length||m.length||x||y)&&(f.options={...p.length&&{hiddenCaptures:p},...m.length&&{transfers:m},...x&&{strategy:x},...y&&{lazyCompile:y}})}return f}function $C(e,t){return E6(e,{global:!0,hasIndices:!0,lazyCompileLength:3e3,rules:{allowOrphanBackrefs:!0,asciiWordBoundaries:!0,captureGroup:!0,recursionLimit:5,singleline:!0},...t})}function N6(e={}){const t={target:"auto",cache:new Map,...e};return t.regexConstructor||(t.regexConstructor=n=>$C(n,{target:t.target})),{createScanner(n){return new VM(n,t)},createString(n){return{content:n}}}}xw(Jp({bundledLanguages:()=>cd,bundledLanguagesAlias:()=>eg,bundledLanguagesBase:()=>Zp,bundledLanguagesInfo:()=>ld,bundledThemes:()=>ng,bundledThemesInfo:()=>tg,codeToHast:()=>uC,codeToHtml:()=>cC,codeToTokens:()=>dC,codeToTokensBase:()=>hC,codeToTokensWithThemes:()=>fC,createHighlighter:()=>xd,createJavaScriptRegexEngine:()=>N6,createOnigurumaEngine:()=>bw,defaultJavaScriptRegexConstructor:()=>$C,getLastGrammarState:()=>pC,getSingletonHighlighter:()=>mC,loadWasm:()=>sg}),FM);let Am=null;const ml=new Set,fu=new Map,W0=["typescript","javascript","tsx","jsx","python","bash","json","css","html","sql","yaml","markdown","diff","rust","go","java","c","cpp","ruby","toml","scss","graphql","docker","powershell"],T6=["github-dark-default","vitesse-light","monokai","dracula","nord"],A6={dark:"github-dark-default",light:"vitesse-light",monokai:"monokai",dracula:"dracula",nord:"nord"};function L6(){return{name:"line-numbers",line(e,t){e.properties["data-line"]=String(t+1)}}}async function HC(){return Am||(Am=xd({themes:T6,langs:W0}).then(e=>(W0.forEach(t=>ml.add(t)),e))),Am}async function R6(e){if(ml.has(e))return;if(fu.has(e))return fu.get(e);const t=(async()=>{const n=await HC(),s=cd[e];if(s){await n.loadLanguage(s),ml.add(e);return}try{const a=await Q(()=>import(`shiki/langs/${e}.mjs`),[]);a.default&&(await n.loadLanguage(a.default),ml.add(e))}catch(a){console.warn(`Failed to load language ${e}:`,a)}})();fu.set(e,t),await t,fu.delete(e)}const tl=new Map,D6=50;function O6(e,t,n){return`${e}|${t}|${n}`}async function UC(e,t,n="github-dark-default"){t!=="text"&&!ml.has(t)&&await R6(t);const s=O6(e,t,n),a=tl.get(s);if(a)return a;const u=(await HC()).codeToHtml(e,{lang:t,theme:n,transformers:[L6()]});if(tl.size>=D6){const c=tl.keys().next().value;c&&tl.delete(c)}return tl.set(s,u),u}const I6={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 Sd(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?I6[s]??"text":"text"}function FC(){const e=Ht(n=>n.currentPreset);return Ht(n=>n.isCustom)?"github-dark-default":A6[e]??"github-dark-default"}function VC(e=2e3){const[t,n]=L.useState(!1),s=L.useCallback(async a=>{try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(a);else{const l=document.createElement("textarea");l.value=a,l.style.position="fixed",l.style.left="-9999px",document.body.appendChild(l),l.select(),document.execCommand("copy"),document.body.removeChild(l)}n(!0),setTimeout(()=>n(!1),e)}catch(l){console.error("Failed to copy:",l)}},[e]);return{copied:t,copy:s}}const M6=L.memo(function({language:t,codeString:n,showSyntaxHighlighting:s}){const{copied:a,copy:l}=VC(),[u,c]=L.useState(null),d=FC(),f=L.useRef(n);return L.useEffect(()=>{s&&(f.current=n,UC(n,t,d).then(p=>{f.current===n&&c(p)}))},[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:p=>{p.preventDefault(),p.stopPropagation(),l(n)},className:"opacity-0 group-hover:opacity-100 transition-opacity hover:text-text-primary p-0.5",title:"Copy code",children:a?o.jsx(Mr,{}):o.jsx(Cp,{})})]}),s&&u?o.jsx("div",{className:"min-w-0",dangerouslySetInnerHTML:{__html:u}}):o.jsx("div",{className:"overflow-x-auto",children:o.jsx("pre",{className:"my-0 px-4 py-3 overflow-x-auto font-mono text-sm whitespace-pre-wrap break-word",children:o.jsx("code",{className:`language-${t}`,children:n})})})]})});function P6(e,t){const n=e?"text-text-muted":"text-sky-400",s=e?"text-text-secondary":"text-amber-400";return{code({className:a,children:l,...u}){const c=/language-(\w+)/.exec(a||"");if(!c&&!String(l).includes(`
|
|
276
|
+
`)){const m=e?"text-text-muted":"text-accent-secondary";return o.jsx("code",{className:`bg-bg-tertiary px-1 py-0.5 rounded ${m} font-mono text-xs`,...u,children:l})}const f=(c==null?void 0:c[1])||"text",p=String(l).replace(/\n$/,"");return o.jsx(M6,{language:f,codeString:p,showSyntaxHighlighting:t})},p({children:a}){const l=e?"text-text-muted":"text-text-primary";return o.jsx("p",{className:`${l} mb-1.5 last:mb-0 leading-tight break-words`,children:a})},ul({children:a}){return o.jsx("ul",{className:"list-disc list-inside mb-1.5 space-y-0.5",children:a})},ol({children:a}){return o.jsx("ol",{className:"list-decimal list-inside mb-1.5 space-y-0.5",children:a})},li({children:a}){const l=e?"text-text-muted":"text-text-primary";return o.jsx("li",{className:`${l} text-sm list-item`,children:a})},h1({children:a}){return o.jsx("h1",{className:`text-base font-bold mb-1.5 mt-2 first:mt-0 ${n}`,children:a})},h2({children:a}){return o.jsx("h2",{className:`text-sm font-bold mb-1.5 mt-2 first:mt-0 ${n}`,children:a})},h3({children:a}){return o.jsx("h3",{className:`text-sm font-bold mb-1.5 mt-1.5 first:mt-0 ${n}`,children:a})},h4({children:a}){return o.jsx("h4",{className:`text-sm font-bold mb-1.5 mt-1.5 first:mt-0 ${n}`,children:a})},strong({children:a}){return o.jsx("strong",{className:`font-bold ${s}`,children:a})},em({children:a}){return o.jsx("em",{className:e?"italic text-text-secondary":"italic",children:a})},a({href:a,children:l}){return o.jsx("a",{href:a,className:"text-accent-primary hover:underline text-sm",target:"_blank",rel:"noopener noreferrer",children:l})},blockquote({children:a}){const l=e?"text-text-muted":"text-text-secondary";return o.jsx("blockquote",{className:`border-l-2 border-accent-primary pl-2 my-1.5 ${l} italic text-sm`,children:a})},table({children:a}){return o.jsx("div",{className:"overflow-x-auto my-1.5",children:o.jsx("table",{className:"min-w-full border border-border",children:a})})},th({children:a}){return o.jsx("th",{className:"border border-border bg-bg-tertiary px-2 py-1 text-left font-semibold text-sm",children:a})},td({children:a}){return o.jsx("td",{className:"border border-border px-2 py-1 text-sm",children:a})},hr(){return o.jsx("hr",{className:"border-border my-2"})},input({checked:a,...l}){return o.jsx("input",{type:"checkbox",checked:a,disabled:!0,className:"mr-1.5 w-3.5 h-3.5",...l})}}}const us=L.memo(function({content:t,className:n="",muted:s=!1}){const{showSyntaxHighlighting:a}=Ri(),l=L.useMemo(()=>{let c=B6(t);return c=z6(c),c},[t]),u=L.useMemo(()=>P6(s,a),[s,a]);return o.jsx("div",{className:`markdown-content [&_li>p]:inline ${n}`,children:o.jsx(o3,{remarkPlugins:[bO],components:u,children:l})})});function B6(e){let t=e.replace(/^(\s*)•\s/gm,"$1- ");return t=t.replace(/^(\d+)\.\s*\n(?=\S)/gm,"$1. "),t=t.replace(/^\|\s*$/gm,""),t=t.replace(/^\d+\|/gm,""),t}function z6(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 $6=L.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 overflow-x-auto",children:o.jsx(us,{content:t})})]}):o.jsx("div",{className:"text-text-muted text-sm italic bg-secondary rounded p-1.5 feed-item overflow-x-auto",children:o.jsx(us,{content:t,muted:!0})})});function GC({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"})})}function H6({code:e,variant:t}){const n=t==="inline"?"span":t==="block-nowrap"?"div":"pre";return o.jsx(n,{className:"language-",children:o.jsx("code",{className:"language-",children:e})})}const Fa=L.memo(function({code:t,language:n,variant:s,showLineNumbers:a=!1,startLine:l=1}){const{showSyntaxHighlighting:u}=Ri(),[c,d]=L.useState(null),f=FC(),p=L.useRef(t);if(L.useEffect(()=>{u&&(p.current=t,UC(t,n,f).then(x=>{p.current===t&&d(x)}))},[t,n,f,u]),!u||!c)return o.jsx(H6,{code:t,variant:s});if(s==="inline")return o.jsx("span",{dangerouslySetInnerHTML:{__html:c}});const m=a?"":"shiki-plain";return o.jsx("div",{className:m,style:{"--shiki-start":l},dangerouslySetInnerHTML:{__html:c}})});function WC({src:e,alt:t,isOpen:n,onClose:s}){return n?o.jsx(jt,{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 Fu=L.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})})})}),U6=L.memo(function({oldString:t,newString:n,filePath:s}){const a=L.useMemo(()=>Sd(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(Fu,{type:"removed",children:o.jsx(Fa,{code:t,language:a,variant:"block",showLineNumbers:!0})}),u&&o.jsx(Fu,{type:"added",children:o.jsx(Fa,{code:n,language:a,variant:"block",showLineNumbers:!0})})]})}),F6=L.memo(function({content:t,filePath:n}){const s=L.useMemo(()=>Sd(n),[n]);return o.jsx("div",{className:"rounded overflow-hidden border border-border max-h-[45vh] overflow-y-auto",children:o.jsx(Fu,{type:"added",children:o.jsx(Fa,{code:t,language:s,variant:"block",showLineNumbers:!0})})})}),V6=L.memo(function({regions:t,filePath:n}){const s=L.useMemo(()=>Sd(n),[n]);return t.length===0?o.jsx("div",{className:"text-xs text-text-muted italic p-2",children:"No changes"}):o.jsx("div",{className:"space-y-2",children:t.map((a,l)=>o.jsx(W6,{region:a,language:s},l))})});function G6(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 W6=L.memo(function({region:t,language:n}){const s=G6(t);return o.jsx("div",{className:"rounded overflow-hidden border border-border font-mono text-sm",children:s.map((a,l)=>o.jsx(q6,{section:a,language:n},l))})}),q6=L.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(Fa,{code:s,language:n,variant:"block",showLineNumbers:!0,startLine:t.startLine})})})}):o.jsx(Fu,{type:t.type,children:o.jsx(Fa,{code:s,language:n,variant:"block",showLineNumbers:!0,startLine:t.startLine})})});function q0(e){return e.split(`
|
|
281
|
+
`).filter(t=>!t.startsWith(`
|
|
282
|
+
[`)&&!t.startsWith("[")).map(t=>t.replace(/^\d+\|/,"")).join(`
|
|
283
|
+
`)}const K6=L.memo(function({result:t,metadata:n,filePath:s,heightExpanded:a=!1}){const[l,u]=L.useState(!1),c=L.useMemo(()=>Sd(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(WC,{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 p=t;if(c==="markdown"){const C=q0(p);return o.jsx("div",{className:`rounded overflow-hidden border border-border ${a?"":"max-h-[45vh]"} overflow-y-auto p-2`,children:o.jsx(us,{content:C})})}const m=q0(p),x=p.split(`
|
|
284
|
+
`)[0],y=x==null?void 0:x.match(/^(\d+)\|/),w=y?parseInt(y[1],10):1;return o.jsx("div",{className:`rounded overflow-hidden border border-border ${a?"":"max-h-[45vh]"} overflow-y-auto`,children:o.jsx(Fa,{code:m,language:c,variant:"block",showLineNumbers:!0,startLine:w})})}),Y6={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"}},K0=L.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=Y6[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)})})]})}),X6=L.memo(function({command:t,timeout:n,startedAt:s,streamingOutput:a,status:l,result:u,error:c,durationMs:d}){const f=L.useRef(null),[p,m]=L.useState(0);L.useEffect(()=>{f.current&&l==="pending"&&(f.current.scrollTop=f.current.scrollHeight)},[a,l]),L.useEffect(()=>{if(l!=="pending"||!s)return;const C=setInterval(()=>{m(Date.now()-s)},100);return()=>clearInterval(C)},[l,s]);const x=n/1e3,y=l==="pending"?p/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:[y.toFixed(1),"s / ",x,"s"]})]})]}),l==="pending"&&o.jsx("div",{className:"h-1 bg-bg-tertiary rounded overflow-hidden",children:o.jsx("div",{className:"h-full bg-accent-warning transition-all duration-100",style:{width:`${Math.min(100,p/n*100)}%`}})}),(w||l==="pending")&&o.jsx("pre",{ref:f,className:`text-xs bg-bg-primary p-2 rounded max-h-64 overflow-y-auto ${l==="pending"?"border border-accent-warning/30":""}`,style:{overflowX:"hidden",whiteSpace:"normal"},children:l==="pending"&&a?a.map((C,b)=>o.jsx("span",{className:C.stream==="stderr"?"text-accent-warning":"",children:ju(C.content)},b)):ju(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 Q6(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 J6({confirmation:e}){const t=De(m=>m.confirmPath),n=De(m=>m.currentSession),s=De(m=>m.switchDangerLevel),{title:a,description:l}=Q6(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",p=()=>{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(zm,{}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:`text-sm font-medium ${u?"text-red-400":"text-amber-400"}`,children:a}),o.jsx("div",{className:"text-xs text-text-muted",children:l})]})]}),o.jsxs("div",{className:"text-xs text-text-muted mb-2",children:[o.jsx("span",{className:"font-medium",children:e.tool})," wants to access:"]}),o.jsx("div",{className:"bg-bg-primary rounded p-2 mb-3 max-h-24 overflow-y-auto",children:o.jsx("ul",{className:"space-y-0.5",children:e.paths.map((m,x)=>o.jsx("li",{className:`text-xs font-mono ${u?"text-red-300":"text-amber-300"} break-all`,children:m},x))})}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx("button",{onClick:()=>t(e.callId,!1),className:"flex-1 px-3 py-1.5 text-xs font-medium rounded bg-bg-tertiary hover:bg-bg-tertiary/80 text-text-secondary border border-border transition-colors",children:"Deny"}),o.jsx("button",{onClick:()=>t(e.callId,!0,!1),className:"flex-1 px-3 py-1.5 text-xs font-medium rounded bg-accent-primary hover:bg-accent-primary/80 text-text-primary transition-colors",children:"Allow"}),o.jsx("button",{onClick:p,className:`flex-1 px-3 py-1.5 text-xs font-medium rounded transition-colors ${f?"hidden":"bg-red-600 hover:bg-red-700 text-white"}`,title:"Enable dangerous mode and allow this request",children:"Allow Everything"})]})]})}function Z6(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 Y0(e,t,n){return Z6(e,t)}function eB(e){return JSON.stringify(e,null,2)}const tB={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}},nB=L.memo(function({tool:t,args:n,status:s,variant:a="compact",forceCompact:l,result:u,error:c,durationMs:d,diagnostics:f,editContext:p,startedAt:m,streamingOutput:x,metadata:y,callId:w}){var q;const C=t==="edit_file"||t==="write_file",b=t==="run_command",S=t==="read_file",_=l?!1:C||b||t==="return_value",[E,j]=L.useState(_),T=tB[s],R=qt(G=>G.settings[Oe.DISPLAY_SHOW_OPEN_IN_EDITOR])==="true",A=t==="edit_file"?(q=p==null?void 0:p.regions[0])==null?void 0:q.startLine:t==="read_file"?(()=>{const G=u==null?void 0:u.split(`
|
|
285
|
+
`)[0],I=G==null?void 0:G.match(/^(\d+): /);return I?parseInt(I[1],10):void 0})():void 0,D=De(G=>G.pendingPathConfirmations),$=s==="pending"&&w?D.find(G=>G.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(GC,{tool:t}),o.jsx("span",{className:"text-accent-primary font-medium",children:t}),o.jsx("span",{className:"text-text-muted truncate flex-1",children:Y0(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:()=>j(!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:Y0(t,n)}),o.jsx("span",{className:"text-text-muted text-xs",children:E?"▼":"▶"})]}),$&&o.jsx(J6,{confirmation:$}),(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(X6,{command:String(n.command??""),timeout:n.timeout??12e4,startedAt:m,streamingOutput:x,status:s,result:u,error:c,durationMs:d}),t==="edit_file"&&s==="success"&&o.jsxs(o.Fragment,{children:[p&&p.regions.length>0?o.jsx(V6,{regions:p.regions,filePath:String(n.path??"")}):o.jsx(U6,{oldString:String(n.old_string??""),newString:String(n.new_string??""),filePath:String(n.path??"")}),f&&f.length>0&&o.jsx(K0,{diagnostics:f})]}),t==="write_file"&&s==="success"&&o.jsxs(o.Fragment,{children:[o.jsx(F6,{content:String(n.content??""),filePath:String(n.path??"")}),f&&f.length>0&&o.jsx(K0,{diagnostics:f})]}),t==="read_file"&&s==="success"&&o.jsx(K6,{result:u,metadata:y,filePath:String(n.path??""),heightExpanded:E}),t==="return_value"&&(()=>{const G=(x==null?void 0:x.map(U=>U.content).join(""))??"",I=s==="pending"&&G?G:String(n.content??"");return o.jsxs("div",{children:[o.jsx("div",{className:"text-[10px] text-accent-primary font-medium mb-1 uppercase tracking-wide",children:"Sub-Agent Summary"}),o.jsx("div",{className:"text-xs prose prose-invert prose-sm max-w-none",children:o.jsx(us,{content:I})})]})})(),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 break-words",children:eB(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 break-words",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"]}),R&&(t==="read_file"||t==="write_file"||t==="edit_file")&&String((y==null?void 0:y.path)??n.path??"")&&o.jsx("a",{href:`vscode://file/${String((y==null?void 0:y.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 break-words",children:c})]})]})]})}),rB={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"},sB={criteria:"criteria",review_findings:"review findings",todos:"tasks"};function iB(e,t){const n=rB[e];if(!n)return`Preparing ${e}`;if(e==="session_metadata"&&t)try{const a=JSON.parse(t).key;if(a){const l=sB[a]??a;return`${n} ${l}`}}catch{}return n}function aB(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 oB=L.memo(function({name:t,arguments:n}){let a=iB(t,n)+"...";if(t==="run_command"&&n){const l=aB(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(GC,{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})]})})}),lB={pending:{icon:"○",color:"text-text-muted"},in_progress:{icon:"●",color:"text-accent-warning",animate:!0},completed:{icon:"✓",color:"text-accent-success"}},cB=L.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=lB[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 uB({toolCall:e}){var E;const t=De(j=>j.pendingQuestions),n=De(j=>j.answerQuestion),[s,a]=L.useState(""),l=L.useRef(null),u=L.useRef(null),c=t.find(j=>j.callId===e.id),d=e.arguments.question??(c==null?void 0:c.question)??"",f=e.arguments.type??(c==null?void 0:c.type)??"text",p=e.arguments.options??(c==null?void 0:c.options)??void 0,m=e.result!==void 0,x=c!==void 0&&!m,y=((E=e.result)==null?void 0:E.output)??"",w=y==="[user skipped]";L.useEffect(()=>{x&&l.current&&l.current.focus()},[x]),L.useEffect(()=>{x&&u.current&&u.current.scrollIntoView({behavior:"smooth",block:"nearest"})},[x]);const C=L.useCallback(()=>{c&&n(c.callId,s)},[c,s,n]),b=L.useCallback(()=>{c&&n(c.callId,"",!0)},[c,n]),S=L.useCallback(j=>{j.key==="Enter"&&!j.shiftKey&&(j.preventDefault(),C()),j.key==="Escape"&&!j.shiftKey&&(j.preventDefault(),b())},[C,b]),v=L.useCallback(j=>{c&&n(c.callId,j)},[c,n]),_="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}),x&&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:()=>v("yes"),className:`${_} 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:()=>v("no"),className:`${_} 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:b,className:`${_} bg-bg-tertiary hover:bg-bg-tertiary/80 text-text-secondary border border-border`,children:"Skip"})]}):f==="choice"&&p&&p.length>0?o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"flex flex-col gap-1.5",children:p.map(j=>o.jsx("button",{onClick:()=>v(j),className:`${_} text-left w-full bg-bg-tertiary hover:bg-accent-primary/20 text-text-primary border border-border hover:border-accent-primary/50`,children:j},j))}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx("textarea",{ref:l,value:s,onChange:j=>a(j.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:`${_} 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:b,className:`${_} 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:j=>a(j.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:b,className:`${_} 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:`${_} bg-accent-primary/25 hover:bg-accent-primary/40 text-text-primary disabled:opacity-50 disabled:cursor-not-allowed`,children:"Send Answer"})]})]})})}),m&&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: ${y}`})})]})}const X0={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"}},dB=L.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,p;return d.arguments.action==="get"&&((f=d.result)==null?void 0:f.success)&&((p=d.result)==null?void 0:p.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((p,m)=>o.jsxs("div",{className:`flex items-start gap-2 px-2 py-1.5 ${m>0?"border-t border-border":""}`,children:[o.jsx("span",{className:"text-text-muted text-sm leading-tight flex-shrink-0",children:"○"}),o.jsx("div",{className:"flex-1 min-w-0",children:o.jsx(us,{content:`[${p.id}] ${p.description}`})})]},p.id??m))}catch{return t.map((f,p)=>o.jsx(Q0,{tc:f,index:p,criteriaMap:s},f.id??p))}})():t.map((d,f)=>o.jsx(Q0,{tc:d,index:f,criteriaMap:s},d.id??f))})]})});function Q0({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,p=d??(f==null?void 0:f.description)??(u&&c?`[${c}]`:"Criterion updated"),m=a.reason,x=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(td,{status:a.status,className:"text-sm leading-tight flex-shrink-0"}):(()=>{const y=s&&X0[s]?X0[s]:{icon:"○",color:"text-text-muted"};return o.jsx("span",{className:`${y.color} text-sm leading-tight flex-shrink-0`,children:y.icon})})(),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("div",{className:u?"line-through text-text-muted":"",children:o.jsx(us,{content:p})}),m&&o.jsxs("div",{className:`mt-1 text-sm ${x?"text-accent-error":"text-text-muted"}`,children:[o.jsx("span",{className:"text-text-muted",children:"└ "}),'"',m,'"']})]})]})}function hB(e){return e==="criterion"||e==="session_metadata"}function fB(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"&&hB(a.toolCall.name)?n.push(a.toolCall):(s(),t.push(a));return s(),t}function mB(e,t){if(e.segments&&e.segments.length>0)return pB(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 pB(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 gg=L.memo(function({message:t,showStats:n=!0,showThinking:s=!0,showVerboseToolOutput:a=!0}){const l=De(x=>{var y,w;return(w=(y=x.currentSession)==null?void 0:y.metadataEntries)==null?void 0:w.criteria}),u=mt(x=>x.defaults),c=mt(x=>x.userItems),d=[...u,...c],f=mB(t,n),p=s?f:f.filter(x=>x.type!=="thinking"),m=fB(p);return m.length===0?null:o.jsx("div",{className:"feed-item",children:o.jsxs("div",{className:"min-w-0",children:[m.map((x,y)=>{var w;switch(x.type){case"thinking":return o.jsx($6,{content:x.content},y);case"text":return o.jsx("div",{className:"prose prose-sm prose-invert max-w-none",children:o.jsx(us,{content:x.content})},y);case"preparing_tool_call":return o.jsx(oB,{name:x.preparing.name,arguments:x.preparing.arguments},`preparing-${x.preparing.index}`);case"tool_call":{const C=x.toolCall,b=C.result;if(C.name==="ask_user")return o.jsx(uB,{toolCall:C},y);if(C.name==="todo_write"){const _=C.arguments.todos,E=Array.isArray(_)?_:[];return o.jsx(cB,{todos:E},y)}const S=(w=b==null?void 0:b.output)==null?void 0:w.includes("[interrupted by user]"),v=b?S?"interrupted":b.success?"success":"error":"pending";return o.jsx(nB,{tool:C.name,args:C.arguments,status:v,variant:"expandable",forceCompact:!a,result:b==null?void 0:b.output,error:b==null?void 0:b.error,durationMs:b==null?void 0:b.durationMs,diagnostics:b==null?void 0:b.diagnostics,editContext:b==null?void 0:b.editContext,startedAt:C.startedAt,streamingOutput:C.streamingOutput,metadata:b==null?void 0:b.metadata,callId:C.id},y)}case"criteria_group":return o.jsx(dB,{toolCalls:x.toolCalls,criteria:l},y);case"stats":{const C=x.stats;if(!C||"error"in C)return null;const b=C.model.split("/").pop()??C.model,S=gl(d,C.mode),v=E=>E>=1e3?`${(E/1e3).toFixed(1)}k`:E.toString(),_=E=>E>=1e3?`${(E/1e3).toFixed(1)}k`:E.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:b}),o.jsx("span",{className:"text-text-muted",children:"·"}),o.jsx("span",{style:{color:S},children:C.mode}),o.jsx("span",{className:"text-text-muted",children:"·"}),o.jsxs("span",{children:[C.totalTime.toFixed(1),"s"]}),C.toolTime>0&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"text-text-muted",children:"·"}),o.jsxs("span",{children:[C.toolTime.toFixed(1),"s tools"]})]}),o.jsx("span",{className:"text-text-muted",children:"·"}),o.jsxs("span",{children:[v(C.prefillTokens)," @ ",_(C.prefillSpeed)," pp"]}),o.jsx("span",{className:"text-text-muted",children:"·"}),o.jsxs("span",{children:[v(C.generationTokens)," @ ",_(C.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 E=new CustomEvent("open-turn-stats",{detail:{stats:C}});window.dispatchEvent(E)},children:o.jsx(AS,{className:"w-3 h-3"})}),o.jsx("span",{className:"flex-1 h-px bg-border"})]},y)}}}),t.partial&&o.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-accent-warning mt-1",children:[o.jsx(zm,{}),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(zm,{}),o.jsx("span",{children:"Response was truncated — the model ran out of output tokens."})]})]})})});function Vu(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 gB(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 xB(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}const yB=L.memo(function({data:t}){var u;const n=Ct(c=>c.defaults),s=Ct(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",{"data-testid":"task-completed-card",className:"feed-item rounded p-3 border",style:{borderColor:Vu(l,.3),backgroundColor:Vu(l,.08)},children:[o.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[o.jsx(Jj,{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(nl,{label:"Iterations",value:String(t.iterations)}),o.jsx(nl,{label:"Total time",value:gB(t.totalTimeSeconds)}),o.jsx(nl,{label:"Tool calls",value:String(t.totalToolCalls)}),o.jsx(nl,{label:"Tokens",value:xB(t.totalTokensGenerated)}),o.jsx(nl,{label:"Speed",value:t.avgGenerationSpeed>0?`${t.avgGenerationSpeed} tok/s`:"-"})]})]})});function nl({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 _B=L.memo(function({data:t}){var u;const n=Ct(c=>c.defaults),s=Ct(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:Vu(l,.3),backgroundColor:Vu(l,.08)},children:[o.jsx(Kj,{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 bB({attachments:e,messageId:t}){const[n,s]=L.useState(null),a=De(p=>p.visionFallbackByMessage),l=De(p=>p.messages),u=L.useMemo(()=>{const p=l.findIndex(m=>m.id===t);if(p===-1)return null;for(let m=p+1;m<l.length;m++){const x=l[m];if(x&&x.role==="assistant")return x.id}return null},[l,t]),c=p=>{s(p)},d=()=>{s(null)},f=p=>{const m=`${t}-${p}`;if(a[m])return a[m];if(u){const x=`${u}-${p}`;return a[x]}return null};return e.length===0?null:o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"mt-3 flex flex-wrap gap-3",children:e.map(p=>{const m=f(p.id);return o.jsxs("div",{className:"relative inline-block",children:[o.jsxs("button",{onClick:()=>c(p.data),className:"group relative inline-block",title:(m==null?void 0:m.type)==="done"&&m.description||p.description||p.filename,disabled:(m==null?void 0:m.type)==="start",children:[o.jsx("img",{src:p.data,alt:(m==null?void 0:m.type)==="done"&&m.description||p.description||p.filename,className:"max-w-[256px] max-h-[256px] object-contain rounded-lg border border-border hover:border-accent-primary transition-colors cursor-pointer"}),(m==null?void 0:m.type)==="start"&&o.jsx("div",{className:"absolute inset-0 bg-black/60 flex items-center justify-center rounded-lg",children:o.jsx("span",{className:"text-xs text-text-primary animate-pulse",children:"Describing image..."})})]}),(m==null?void 0:m.type)==="done"&&m.description&&o.jsxs("div",{className:"mt-2 p-2 bg-bg-tertiary rounded text-xs text-text-secondary max-w-[256px]",children:[m.description.slice(0,200),m.description.length>200?"...":""]})]},p.id)})}),n&&o.jsx(WC,{src:n,alt:"Attached image",isOpen:!0,onClose:d})]})}function vB({content:e,align:t="right",messageId:n,sessionId:s}){const[a,l]=L.useState(!1),[u,c]=L.useState(!1),[d,f]=L.useState("left"),p=L.useRef(null),m=L.useRef(null),x=De(S=>S.loadSession),y=t==="right",w=()=>{if(!m.current)return"left";const S=m.current.getBoundingClientRect(),v=window.innerWidth-S.right,_=S.left,E=160,j=v>=E,T=_>=E;return T&&j||T?"left":j?"right":_>=v?"left":"right"};L.useEffect(()=>{const S=v=>{p.current&&!p.current.contains(v.target)&&l(!1)};return a&&document.addEventListener("mousedown",S),()=>document.removeEventListener("mousedown",S)},[a]);const 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)}},b=async()=>{!s||!n||(l(!1),await M2(s,n),x(s))};return o.jsx(o.Fragment,{children:o.jsxs("div",{className:`flex items-start gap-1.5 ${y?"":"order-first"}`,children:[u&&o.jsx(Mr,{className:"w-4 h-4 text-accent-success"}),o.jsxs("div",{ref:p,className:"relative",children:[o.jsx("button",{ref:m,onClick:()=>{a||f(w()),l(!a)},className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary",title:"Message options",children:o.jsx(kp,{})}),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(Cp,{className:"w-4 h-4"}),"Copy"]}),s&&n&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"border-t border-border my-1"}),o.jsxs("button",{onClick:b,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(Ep,{className:"w-4 h-4"}),"Replay"]})]})]})]})]})})}function SB({message:e}){const[t,n]=L.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 overflow-x-auto",style:{borderLeft:`3px solid ${a}`},children:o.jsx("pre",{className:"whitespace-pre-wrap break-words font-mono text-xs",children:e.content})})}),o.jsx(jt,{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 break-words bg-bg-tertiary rounded p-4 h-full min-h-96 overflow-auto font-mono",children:e.content})})]})})]})}function wB({message:e,messageId: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(vB,{content:e.content,align:"right",messageId: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 break-words 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(bB,{attachments:e.attachments,messageId:e.id})]})]})}const qC=L.memo(function({message:t,isLastAssistantMessage:n=!1,messageId: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(gg,{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 break-words 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(_B,{data:f})}catch{}if(t.messageKind==="task-completed")try{const f=JSON.parse(t.content);return o.jsx(yB,{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 break-words text-sm text-amber-200 italic",children:t.content})]})}):l?o.jsx(wB,{message:t,messageId:s,sessionId:a}):o.jsx("div",{className:"flex justify-start feed-item",children:o.jsx("div",{className:"max-w-[75%] rounded p-2 bg-bg-tertiary text-text-primary",children:o.jsx(us,{content:t.content})})})}),CB={verifier:"Verification",code_reviewer:"Code Review",test_generator:"Test Generation",debugger:"Debug"};function kB(e){return{backgroundColor:`${e}20`,color:e,borderColor:`${e}4d`}}function J0(e,t){return t||e>85?"text-accent-error":e>60?"text-accent-warning":"text-text-muted"}function EB({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:J0(l,a),children:[ku(t),"/",ku(n)]}),o.jsxs("span",{className:J0(l,a),children:["(",l,"%)"]}),o.jsx(h1,{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 jB=L.memo(function({messages:t,subAgentType:n,subAgentId:s,isStreaming:a}){const l=L.useRef(null),u=L.useRef(null),[c,d]=L.useState(!1),f=mt(R=>R.defaults),p=mt(R=>R.userItems),m=[...f,...p],x=De(R=>R.subAgentContextStates[s]),{showThinking:y,showVerboseToolOutput:w}=Ri(),{isAutoScrollActive:C,setAutoScroll:b}=nd(u,null);L.useEffect(()=>{a||b(!0)},[a]);const S=L.useCallback(()=>{const R=!c;d(R),R&&setTimeout(()=>{var A;(A=l.current)==null||A.scrollIntoView({block:"start",behavior:"smooth"})},220)},[c]),v=m.find(R=>R.id===n),_=(v==null?void 0:v.name)??CB[n]??n,E=gl(m,n),j=kB(E),T=t.filter(R=>R.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:j,children:[o.jsx("span",{className:"text-xs font-medium",children:_}),o.jsx("div",{className:"absolute left-1/2 -translate-x-1/2",children:x&&o.jsx(EB,{contextState:x})}),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:()=>b(!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(R=>R.role==="assistant"?o.jsx(gg,{message:R,showStats:!0,showThinking:y,showVerboseToolOutput:w},R.id):o.jsx(qC,{message:R,isLastAssistantMessage:!1},R.id))})]})});function mu(e){var t;return e.type==="context-divider"?`ctx-${e.windowSequence}`:e.type==="subagent"?((t=e.messages[0])==null?void 0:t.id)??e.subAgentId:e.message.id}const KC=L.memo(function({displayItems:t,highlightedMessageId:n=null,sessionId:s,showThinking:a=!0,showVerboseToolOutput:l=!0,showStats:u=!0,showAgentDefinitions:c=!0,showWorkflowBars:d=!0}){return o.jsx(o.Fragment,{children:t.map((f,p)=>{if(f.type==="context-divider")return o.jsxs("div",{"data-item-index":p,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"})]},mu(f));if(f.type==="subagent"){const w=f.messages.some(C=>C.isStreaming);return o.jsx("div",{"data-item-index":p,className:"px-2 md:px-4",children:o.jsx(jB,{messages:f.messages,subAgentType:f.subAgentType,subAgentId:f.subAgentId,isStreaming:w})},mu(f))}const m=f.message;if(m.role==="assistant")return o.jsx("div",{"data-item-index":p,className:"px-2 md:px-4",children:o.jsx(gg,{message:m,showStats:u,showThinking:a,showVerboseToolOutput:l})},mu(f));const x=!c&&m.messageKind==="auto-prompt",y=!d&&(m.messageKind==="workflow-started"||m.messageKind==="task-completed");return x||y?null:o.jsx("div",{"data-item-index":p,className:"px-2 md:px-4",children:o.jsx("div",{"data-message-id":m.id,className:n===m.id?"rounded animate-highlight-fade":void 0,children:o.jsx(qC,{message:m,messageId:m.id,sessionId:s??void 0,isLastAssistantMessage:!1})})},mu(f))})})});function YC(e,t,n=!0){L.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 NB=[],TB=L.memo(function({displayItems:t,scrollContainerRef:n,highlightedMessageId:s,onLaunchWorkflow:a,hiddenCount:l=0}){const u=De(U=>{var V,z;return((z=(V=U.currentSession)==null?void 0:V.metadataEntries)==null?void 0:z.criteria)??NB}),c=De(U=>{var V;return(V=U.currentSession)==null?void 0:V.id}),d=De(U=>{var V;return(V=U.currentSession)==null?void 0:V.mode}),f=De(U=>{var V;return(V=U.currentSession)==null?void 0:V.phase}),p=De(U=>U.error),m=De(U=>U.clearError),x=Yu(),{showThinking:y,showVerboseToolOutput:w,showStats:C,showAgentDefinitions:b,showWorkflowBars:S}=Ri(),v=Ct(U=>U.defaults),_=Ct(U=>U.userItems),E=[...v,..._],j=d==="planner",T=u.length>0,R=f==="done",A=t.some(U=>U.type==="message"&&U.message.role==="assistant"),D=j&&T&&!x&&A&&!R,$=De(U=>{var V;return(V=U.currentSession)==null?void 0:V.projectId}),[q,G]=L.useState(!1),I=()=>{if(!$||!c)return;G(!1),window.open(`/p/${$}/s/${c}/readonly`,"_blank")||G(!0)};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.jsxs("div",{className:"pt-4",children:[l>0&&o.jsxs("div",{className:"px-2 md:px-4 pb-2 space-y-1",children:[o.jsxs("button",{onClick:I,className:"w-full text-sm text-text-muted hover:text-text-primary bg-bg-tertiary/50 hover:bg-bg-tertiary border border-border rounded px-3 py-2 transition-colors text-center",children:[l," older item",l!==1?"s":""," hidden — View full history"]}),q&&o.jsxs("p",{className:"text-xs text-text-muted text-center",children:["Popup blocked."," ",o.jsx("a",{href:$&&c?`/p/${$}/s/${c}/readonly`:"#",target:"_blank",rel:"noopener noreferrer",className:"underline hover:text-text-primary",children:"Open manually"})]})]}),o.jsx(KC,{displayItems:t,highlightedMessageId:s,sessionId:c,showThinking:y,showVerboseToolOutput:w,showStats:C,showAgentDefinitions:b,showWorkflowBars:S})]}),o.jsxs("div",{className:"px-2 md:px-4 pb-4",children:[p&&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:p.code}),o.jsx("div",{className:"text-red-300 text-xs mt-0.5",children:p.message})]}),o.jsx(Tl,{onClick:m,className:"text-red-400 hover:text-red-300 p-0.5",size:"sm"})]})}),D&&o.jsx("div",{className:"flex justify-center gap-2 feed-item flex-wrap",children:E.map(U=>{const V=U.color??"#3b82f6",z=parseInt(V.slice(1,3),16),J=parseInt(V.slice(3,5),16),Z=parseInt(V.slice(5,7),16),H=`rgba(${z},${J},${Z},0.12)`,O=`rgba(${z},${J},${Z},0.22)`,B=`rgba(${z},${J},${Z},0.25)`;return o.jsx(AB,{workflowName:U.name,color:V,bg:H,bgHover:O,border:B,subGroups:U.subGroups,onLaunch:W=>a(U.id,W)},U.id)})})]})]})});function AB({workflowName:e,color:t,bg:n,bgHover:s,border:a,subGroups:l,onLaunch:u}){const[c,d]=L.useState(!1),f=L.useRef(null);return YC(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:p=>{p.currentTarget.style.backgroundColor=s},onMouseLeave:p=>{p.currentTarget.style.backgroundColor=n},children:["▶ ",e]}),l&&l.length>0&&o.jsxs("div",{ref:f,className:"relative",children:[o.jsx("button",{onClick:()=>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:p=>{p.currentTarget.style.backgroundColor=s},onMouseLeave:p=>{p.currentTarget.style.backgroundColor=n},children:"⋮"}),c&&o.jsxs("div",{className:"absolute top-full right-0 mt-1 w-40 bg-bg-secondary border border-border rounded-lg shadow-xl z-50 overflow-hidden",children:[o.jsx("button",{onClick:()=>{u(),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(p=>o.jsx("button",{onClick:()=>{u(p),d(!1)},className:"w-full text-left px-3 py-2 text-sm text-text-primary hover:bg-bg-tertiary transition-colors",children:p},p))]})]})]})}function LB(){const e=De(s=>s.connectionStatus),t=De(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(eN,{}),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=Xn((e,t)=>({defaults:[],userItems:[],projectItems:[],loading:!1,fetchCommands:async()=>{await c1("/api/commands",e,!0)},fetchCommand:async n=>{try{const s=await Te(`/api/commands/${n}`);return s.ok?await s.json():null}catch{return null}},fetchDefaultContent:async n=>{try{const s=await Te(`/api/commands/defaults/${n}`);return s.ok?await s.json():null}catch{return null}},createCommand:async(n,s)=>{const a=await Ws("POST","/api/commands",{...n,destination:s});return a.success&&await t().fetchCommands(),a},updateCommand:async(n,s)=>{const a=await Ws("PUT",`/api/commands/${n}`,s);return a.success&&await t().fetchCommands(),a},deleteCommand:async n=>{try{const s=await Te(`/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)=>Ku(`/api/commands/${n}/duplicate`,()=>t().fetchCommands(),s)}));function RB(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function DB({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(wu,{})})}function XC({isOpen:e,onClose:t,initialEditId:n}){const s=en(re=>re.defaults),a=en(re=>re.userItems),l=en(re=>re.projectItems),u=en(re=>re.loading),c=en(re=>re.fetchCommands),d=en(re=>re.fetchCommand),f=en(re=>re.fetchDefaultContent),p=en(re=>re.createCommand),m=en(re=>re.updateCommand),x=en(re=>re.deleteCommand),[y,w]=L.useState(null),[C,b]=L.useState(null),{view:S,editingId:v,formError:_,saving:E,formData:j,setView:T,setEditingId:R,setFormError:A,setFormData:D,setSaving:$}=VS(),{requestDelete:q,clearConfirm:G,isConfirming:I}=Qu(),U=L.useRef(!1),V=mt(re=>re.defaults),z=mt(re=>re.userItems),J=mt(re=>re.fetchAgents),H=[...V,...z].filter(re=>!re.subagent),O=L.useRef(c),B=L.useRef(J),W=L.useRef(d),P=L.useRef(f),ee=L.useRef(n),X=L.useRef(T),ne=L.useRef(R),Y=L.useRef(A),F=L.useRef(G);L.useEffect(()=>{O.current=c,B.current=J,W.current=d,P.current=f,ee.current=n,X.current=T,ne.current=R,Y.current=A,F.current=G}),L.useEffect(()=>{if(e)if(O.current(),B.current(),U.current||(F.current(),U.current=!0),ee.current){const re=s.some(_e=>_e.id===ee.current);X.current("edit"),ne.current(ee.current),Y.current(""),re?P.current(ee.current).then(_e=>{_e&&D({name:_e.metadata.name+" (copy)",id:`${ee.current}-copy-${Date.now()}`,prompt:_e.prompt,agentMode:_e.metadata.agentMode??"",isDefault:!0,destination:"user"})}):W.current(ee.current).then(_e=>{_e&&D({name:_e.metadata.name,id:_e.metadata.id,prompt:_e.prompt,agentMode:_e.metadata.agentMode??"",isDefault:!1,destination:"user"})})}else X.current("list"),ne.current(null);else U.current=!1},[e]);const te=async re=>{w(re);const _e=await f(re);b((_e==null?void 0:_e.prompt)??null)},se=async re=>{if(s.some(He=>He.id===re)){const He=await f(re);He&&(R(null),D({name:`${He.metadata.name} (copy)`,id:`${re}-copy-${Date.now()}`,prompt:He.prompt,agentMode:He.metadata.agentMode??"",isDefault:!0,destination:"user"}),A(""),T("edit"))}else{const He=await d(re);He&&(R(null),D({name:`${He.metadata.name} (copy)`,id:`${re}-copy-${Date.now()}`,prompt:He.prompt,agentMode:He.metadata.agentMode??"",isDefault:!1,destination:"user"}),A(""),T("edit"))}},xe=()=>{D({name:"",id:"",prompt:"",agentMode:"",isDefault:!1,destination:"user"}),R(null),T("edit")},le=async re=>{const _e=await d(re);_e&&(R(re),D({name:_e.metadata.name,id:_e.metadata.id,prompt:_e.prompt,agentMode:_e.metadata.agentMode??"",isDefault:!1,destination:"user"}),A(""),T("edit"))},Ee=async re=>{await x(re),G()},ue=async()=>{const re=v??j.id;if(!re||!j.name||!j.prompt){A("Name and message are required.");return}$(!0),A("");const _e={metadata:{id:re,name:j.name,...j.agentMode?{agentMode:j.agentMode}:{}},prompt:j.prompt},He=v?await m(v,_e):await p(_e,j.destination);if($(!1),!He.success){A(He.error??"Failed to save command.");return}n?t():T("list")},ae=()=>{n?t():(T("list"),w(null),b(null))},de=re=>{D(_e=>({..._e,name:re})),(!v||j.isDefault)&&D(_e=>({..._e,id:RB(re)}))},oe=()=>{w(null),b(null),T("list")},Ne=()=>{y&&(w(null),T("edit"),R(y),f(y).then(re=>{re&&D({name:`${re.metadata.name} (copy)`,id:`${y}-copy-${Date.now()}`,prompt:re.prompt,agentMode:re.metadata.agentMode??"",isDefault:!0,destination:"user"})}))};if(y){const re=s.find(_e=>_e.id===y);return o.jsx(jt,{isOpen:e,onClose:oe,title:`Default: ${(re==null?void 0:re.name)??y}`,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:y})]}),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:re==null?void 0:re.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:(re==null?void 0:re.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(Ve,{variant:"secondary",onClick:oe,children:"Close"}),o.jsx(Ve,{variant:"primary",onClick:Ne,children:"Duplicate & Customize"})]})]})})}if(S==="edit")return o.jsx(jt,{isOpen:e,onClose:ae,title:v?"Edit Command":"New Command",size:"xl",children:o.jsxs("div",{className:"flex flex-col h-full",children:[_&&o.jsx(Ju,{message:_}),o.jsxs("div",{className:"space-y-3 mb-3",children:[o.jsx(FS,{name:j.name,id:j.id,nameLabel:"Name",idLabel:"ID",namePlaceholder:"My Command",idPlaceholder:"my-command",readOnlyId:!!v&&!j.isDefault,onNameChange:de,onIdChange:re=>D(_e=>({..._e,id:re}))}),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:j.agentMode,onChange:re=>D(_e=>({..._e,agentMode:re.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(re=>o.jsx("option",{value:re.id,children:re.name},re.id))]})]}),!v&&o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("label",{className:"text-xs text-text-secondary",children:"Save to:"}),o.jsxs("select",{value:j.destination,onChange:re=>D(_e=>({..._e,destination:re.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:j.prompt,onChange:re=>D(_e=>({..._e,prompt:re.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(Ve,{variant:"secondary",onClick:ae,children:"Cancel"}),o.jsx(Ve,{variant:"primary",onClick:ue,disabled:E||!j.name||!j.prompt,children:E?"Saving...":"Save"})]})]})});const ve=re=>re.map(_e=>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:_e.name})})}),o.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[o.jsx(Fs,{onClick:()=>le(_e.id)}),o.jsx(Cu,{onClick:()=>se(_e.id)}),I(_e.id,"delete")?o.jsx(Tp,{onConfirm:()=>Ee(_e.id),onCancel:G}):o.jsx(Ap,{onClick:()=>q(_e.id)})]})]},_e.id));return o.jsxs(jt,{isOpen:e,onClose:t,title:"Commands",size:"lg",children:[o.jsx(US,{description:"Commands are pre-defined messages you can send with a single click.",onNew:xe}),o.jsxs(Lp,{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(re=>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:re.name})}),o.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[o.jsx(DB,{onClick:()=>te(re.id)}),o.jsx(Cu,{onClick:()=>se(re.id)})]})]},re.id))})]}),a.length>0&&o.jsx(HS,{children:ve(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:ve(l)})]})]})]})}const xi=150,is=54,pu=80,yr=30,Ta=70,Z0=100,yi=50,gu=50,eS=4,QC={step_result:"Result",metadata_all_match:"Metadata match",metadata_all_in:"Metadata in",always:"otherwise"},JC=[{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)"}],OB=[{value:"agent",label:"Agent"},{value:"sub_agent",label:"Sub-Agent"},{value:"shell",label:"Shell"}];function xg(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 IB(e,t,n,s){const a=gu+yi+xi+Z0+xi+yi+gu,l=a/2,u=gu+yi+xi/2,c=gu+yi+xi+Z0+xi/2,d=[],f=[],p=new Map,m=e.filter(V=>V.type==="agent"||V.type==="shell"),x=e.filter(V=>V.type==="sub_agent"),y=x.length>0,w=y?u:l,C=m.length>0?c:l,b=yi+yr/2;d.push({id:"$start",type:"terminal",label:"Start",cx:w,cy:b,w:pu,h:yr}),p.set("$start",{cx:w,cy:b,w:pu,h:yr});const S=V=>{d.push({id:"$done",type:"terminal",label:"Done",cx:w,cy:V,w:pu,h:yr}),p.set("$done",{cx:w,cy:V,w:pu,h:yr})};if(e.length===0){const V=b+yr/2+Ta*2+yr/2;return S(V),{nodes:d,edges:f,width:a,height:V+yr/2+yi,posMap:p}}const v=b+yr/2+Ta,_=(V,z)=>{V.forEach((J,Z)=>{const H=v+Z*(is+Ta)+is/2,{name:O,color:B}=xg(J,s);d.push({id:J.id,type:"step",label:O,color:B,cx:z,cy:H,w:xi,h:is}),p.set(J.id,{cx:z,cy:H,w:xi,h:is})})};_(m,w),_(x,C);const E=m.length>0?v+(m.length-1)*(is+Ta)+is/2:b,j=y?v+(x.length-1)*(is+Ta)+is/2:b,T=Math.max(E,j)+is/2+Ta+yr/2;S(T);const R=[];t&&p.has(t)&&R.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,J)=>{var P;if(!z.goto||!p.has(z.goto))return;const Z=p.get(V.id),H=p.get(z.goto),O=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(","))??"?"}]`:QC[z.when.type]??z.when.type,B=V.id===z.goto;let W;B?W="back":H.cy>Z.cy+1?W="down":H.cy<Z.cy-1?W="back":W="same",R.push({from:V.id,to:z.goto,label:O,edgeKey:`${V.id}:${J}`,direction:W,backEdgeIndex:W==="back"?A++:0})});const D=new Map,$=new Map,q=new Map,G=new Map;for(const V of R)V.direction==="down"&&(D.set(V.from,(D.get(V.from)??0)+1),$.set(V.to,($.get(V.to)??0)+1));const I=new Map,U=new Map;for(const V of R){if(V.direction!=="same")continue;const z=[V.from,V.to].sort().join("|");I.set(z,(I.get(z)??0)+1)}for(const V of R){if(V.direction==="back"||V.direction==="same"){let W=0;if(V.direction==="same"){const P=[V.from,V.to].sort().join("|");W=U.get(P)??0,U.set(P,W+1)}f.push({...V,fromPort:0,toPort:0,sameEdgeIndex:W});continue}const z=D.get(V.from)??1,J=$.get(V.to)??1,Z=q.get(V.from)??0,H=G.get(V.to)??0;q.set(V.from,Z+1),G.set(V.to,H+1);const O=z===1?0:-.6+1.2*Z/(z-1),B=J===1?0:-.6+1.2*H/(J-1);f.push({...V,fromPort:O,toPort:B,sameEdgeIndex:0})}return{nodes:d,edges:f,width:a,height:T+yr/2+yi,posMap:p}}function MB({steps:e,entryStep:t,selectedNodeId:n,selectedEdgeKey:s,startConditionLabel:a,agentTypes:l,isReadOnly:u,onSelectNode:c,onSelectEdge:d,onRemoveStep:f,onCreateTransition:p,onReconnectTo:m,onReconnectFrom:x,onDeleteTransition:y}){const w=L.useRef(null),C=L.useRef(!1),[b,S]=L.useState(null),[v,_]=L.useState(null),[E,j]=L.useState(null),{nodes:T,edges:R,width:A,height:D,posMap:$}=L.useMemo(()=>IB(e,t,a,l),[e,t,a,l]),q=L.useCallback(X=>{var se;const ne=w.current;if(!ne)return{x:0,y:0};const Y=ne.createSVGPoint();Y.x=X.clientX,Y.y=X.clientY;const F=(se=ne.getScreenCTM())==null?void 0:se.inverse();if(!F)return{x:0,y:0};const te=Y.matrixTransform(F);return{x:te.x,y:te.y}},[]),G=L.useCallback(X=>!X||!v||X==="$start"?!1:v.type==="reconnect-from"?X!=="$done":!0,[v]),I=L.useCallback((X,ne)=>{if(u)return;X.stopPropagation(),X.preventDefault();const Y=q(X);_({type:"new",fromNodeId:ne,mouseX:Y.x,mouseY:Y.y})},[q,u]),U=L.useCallback((X,ne)=>{if(u)return;X.stopPropagation(),X.preventDefault();const Y=q(X);_({type:"reconnect-to",fromNodeId:ne.from,edgeKey:ne.edgeKey,mouseX:Y.x,mouseY:Y.y})},[q,u]),V=L.useCallback((X,ne)=>{if(u)return;X.stopPropagation(),X.preventDefault();const Y=q(X);_({type:"reconnect-from",fromNodeId:ne.from,fixedTargetId:ne.to,edgeKey:ne.edgeKey,mouseX:Y.x,mouseY:Y.y})},[q,u]),z=L.useCallback(X=>{if(!v)return;const ne=q(X);_(Y=>Y?{...Y,mouseX:ne.x,mouseY:ne.y}:null)},[v,q]),J=L.useCallback(()=>{v&&(C.current=!0,E&&G(E)&&(v.type==="new"?p(v.fromNodeId,E):v.type==="reconnect-to"?m(v.edgeKey,E):v.type==="reconnect-from"&&x(v.edgeKey,E)),_(null),j(null))},[v,E,G,p,m,x]),Z=L.useCallback(()=>{if(C.current){C.current=!1;return}c(null),d(null)},[c,d]);L.useEffect(()=>{if(u)return;const X=ne=>{ne.target instanceof HTMLInputElement||ne.target instanceof HTMLTextAreaElement||ne.target instanceof HTMLSelectElement||(ne.key==="Delete"||ne.key==="Backspace")&&s&&s!=="start"&&(ne.preventDefault(),y(s),d(null))};return document.addEventListener("keydown",X),()=>document.removeEventListener("keydown",X)},[u,s,y,d]);const H=X=>{const ne=$.get(X.from),Y=$.get(X.to);if(!ne||!Y)return null;let F,te,se,xe="middle",le,Ee;if(X.direction==="down"){const ue=ne.cx+X.fromPort*(ne.w/2-10),ae=ne.cy+ne.h/2,de=Y.cx+X.toPort*(Y.w/2-10),oe=Y.cy-Y.h/2,Ne=oe-ae,ve=de-ue;F=`M ${ue} ${ae} C ${ue} ${ae+Ne*.4}, ${de-ve*.2} ${oe-Ne*.1}, ${de} ${oe}`,te=ue+(de-ue)*.5,se=ae+Ne*.6,le={x:ue,y:ae},Ee={x:de,y:oe}}else if(X.direction==="back"){const ue=X.from===X.to,ae=ne.cx>=A/2,de=X.backEdgeIndex*16,oe=ae?A-20-de:20+de;if(ue){const Ne=ne.cx>=A/2,ve=30+X.backEdgeIndex*14,re=ne.cy-ne.h/2,_e=Ne?ne.cx+ne.w/2:ne.cx-ne.w/2,He=Ne?_e+ve:_e-ve,et=ne.cx+(Ne?ne.w/4:-ne.w/4),rt=re-20-X.backEdgeIndex*10;F=`M ${_e} ${ne.cy} C ${He} ${ne.cy}, ${He} ${rt}, ${et} ${re}`,te=He+10,se=rt+4,xe="middle",le={x:_e,y:ne.cy},Ee={x:et,y:re}}else{const Ne=ae?ne.cx+ne.w/2:ne.cx-ne.w/2,ve=Y.cx+(ae?Y.w/4:-Y.w/4),re=Math.min(ne.cy,Y.cy)-Y.h/2-18-X.backEdgeIndex*14;F=`M ${Ne} ${ne.cy} L ${oe} ${ne.cy} L ${oe} ${re} L ${ve} ${re} L ${ve} ${Y.cy-Y.h/2}`,te=oe,se=(ne.cy+re)/2,xe=ae?"start":"end",le={x:Ne,y:ne.cy},Ee={x:ve,y:Y.cy-Y.h/2}}}else{const ue=Y.cx>ne.cx,ae=X.sameEdgeIndex===0?-12:12,de=ue?ne.cx+ne.w/2:ne.cx-ne.w/2,oe=ue?Y.cx-Y.w/2:Y.cx+Y.w/2,Ne=ne.cy+ae,ve=Y.cy+ae,re=(de+oe)/2;F=`M ${de} ${Ne} C ${re} ${Ne}, ${re} ${ve}, ${oe} ${ve}`,te=re,se=(Ne+ve)/2-6,le={x:de,y:Ne},Ee={x:oe,y:ve}}return{path:F,labelX:te,labelY:se,labelAnchor:xe,fromPt:le,toPt:Ee}},O=(X,ne)=>{const Y=H(X);if(!Y)return null;const{path:F,labelX:te,labelY:se,labelAnchor:xe}=Y,le=s===X.edgeKey,Ee=X.label&&X.label!=="otherwise";return o.jsxs("g",{children:[o.jsx("path",{d:F,fill:"none",stroke:"transparent",strokeWidth:14,className:"cursor-pointer",onClick:ue=>{ue.stopPropagation(),u||d(le?null:X.edgeKey)}}),o.jsx("path",{d:F,fill:"none",stroke:le?"#58a6ff":"#484f58",strokeWidth:le?2.2:1.2,markerEnd:le?"url(#arrow-selected)":"url(#arrow)",pointerEvents:"none"}),Ee&&o.jsx("text",{x:te+(xe==="start"?5:xe==="end"?-5:0),y:se+3,textAnchor:xe,className:"text-[8px]",fill:le?"#79c0ff":"#8b949e",style:{paintOrder:"stroke",stroke:"#0d1117",strokeWidth:3,strokeLinejoin:"round"},pointerEvents:"none",children:X.label})]},ne)},B=()=>{if(!s||v)return null;const X=R.find(se=>se.edgeKey===s);if(!X)return null;const ne=H(X);if(!ne)return null;const{fromPt:Y,toPt:F}=ne,te=6;return o.jsxs(o.Fragment,{children:[X.edgeKey!=="start"&&o.jsx("circle",{cx:Y.x,cy:Y.y,r:te,fill:"#58a6ff",fillOpacity:.25,stroke:"#58a6ff",strokeWidth:2,strokeOpacity:.8,className:"cursor-grab",onMouseDown:se=>V(se,X)}),o.jsx("circle",{cx:F.x,cy:F.y,r:te,fill:"#58a6ff",fillOpacity:.25,stroke:"#58a6ff",strokeWidth:2,strokeOpacity:.8,className:"cursor-grab",onMouseDown:se=>U(se,X)})]})},W=()=>{if(!v)return null;let X,ne,Y,F;if(v.type==="reconnect-from"){const xe=$.get(v.fixedTargetId);if(!xe)return null;X=v.mouseX,ne=v.mouseY,Y=xe.cx,F=xe.cy-xe.h/2}else{const xe=$.get(v.fromNodeId);if(!xe)return null;X=xe.cx,ne=xe.cy+xe.h/2,Y=v.mouseX,F=v.mouseY}const te=F-ne,se=Math.abs(te)>10?`M ${X} ${ne} C ${X} ${ne+te*.4}, ${Y} ${F-te*.4}, ${Y} ${F}`:`M ${X} ${ne} L ${Y} ${F}`;return o.jsx("path",{d:se,fill:"none",stroke:"#58a6ff",strokeWidth:2,strokeDasharray:"6 3",strokeOpacity:.7,pointerEvents:"none"})},P=X=>{const ne=X.cy+X.h/2,Y=(v==null?void 0:v.fromNodeId)===X.id;return o.jsx("circle",{cx:X.cx,cy:ne,r:eS,fill:Y?"#58a6ff":"#1c2128",stroke:Y?"#58a6ff":"#484f58",strokeWidth:1.5,strokeOpacity:Y?1:.5,className:"cursor-crosshair",onMouseDown:F=>I(F,X.id)})},ee=X=>{const ne=X.cy-X.h/2,Y=v&&E===X.id&&G(X.id);return o.jsx("circle",{cx:X.cx,cy:ne,r:eS,fill:Y?"#3fb950":"#1c2128",stroke:Y?"#3fb950":"#484f58",strokeWidth:1.5,strokeOpacity:Y?1:.5})};return o.jsxs("svg",{ref:w,viewBox:`0 0 ${A} ${D}`,className:"block w-full",preserveAspectRatio:"xMidYMin meet",onMouseMove:z,onMouseUp:J,onClick:Z,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"})})]}),R.map((X,ne)=>O(X,ne)),T.map(X=>{const ne=n===X.id,Y=X.cx-X.w/2,F=X.cy-X.h/2,te=b===X.id,se=v&&E===X.id&&G(X.id);if(X.type==="terminal"){const le=X.id==="$start",Ee=le?"#58a6ff":"#3fb950",ue=le,ae=!le;return o.jsxs("g",{onClick:de=>{de.stopPropagation(),le&&!u&&d("start")},className:le&&!u?"cursor-pointer":void 0,children:[se&&o.jsx("rect",{x:Y-3,y:F-3,width:X.w+6,height:X.h+6,rx:X.h/2+3,fill:"none",stroke:"#3fb950",strokeOpacity:.6,strokeWidth:2}),le&&s==="start"&&o.jsx("rect",{x:Y-3,y:F-3,width:X.w+6,height:X.h+6,rx:X.h/2+3,fill:"none",stroke:"#58a6ff",strokeOpacity:.5,strokeWidth:2}),o.jsx("rect",{x:Y,y:F,width:X.w,height:X.h,rx:X.h/2,fill:Ee,fillOpacity:.08,stroke:Ee,strokeOpacity:.4,strokeWidth:1.5}),o.jsx("text",{x:X.cx,y:X.cy+4,textAnchor:"middle",fill:Ee,className:"text-[10px] font-medium",pointerEvents:"none",children:X.label}),ue&&P(X),ae&&ee(X)]},X.id)}const xe=X.color??"#6b7280";return o.jsxs("g",{onClick:le=>{le.stopPropagation(),u||c(ne?null:X.id)},onMouseEnter:()=>S(X.id),onMouseLeave:()=>S(null),className:u?void 0:"cursor-pointer",children:[se&&o.jsx("rect",{x:Y-3,y:F-3,width:X.w+6,height:X.h+6,rx:12,fill:"none",stroke:"#3fb950",strokeOpacity:.6,strokeWidth:2}),ne&&o.jsx("rect",{x:Y-3,y:F-3,width:X.w+6,height:X.h+6,rx:12,fill:"none",stroke:"#58a6ff",strokeOpacity:.5,strokeWidth:2}),o.jsx("rect",{x:Y,y:F,width:X.w,height:X.h,rx:10,fill:xe,fillOpacity:.08,stroke:xe,strokeOpacity:.6,strokeWidth:ne?2:1.5}),o.jsx("text",{x:X.cx,y:X.cy+4,textAnchor:"middle",fill:"#c9d1d9",className:"text-[11px] font-medium",pointerEvents:"none",children:X.label}),!u&&P(X),!u&&ee(X),te&&!v&&!u&&o.jsxs("g",{onClick:le=>{le.stopPropagation(),f(X.id)},className:"cursor-pointer",children:[o.jsx("circle",{cx:Y+X.w-2,cy:F+2,r:8,fill:"#0d1117",fillOpacity:.9,stroke:"#f85149",strokeOpacity:.5,strokeWidth:1}),o.jsx("line",{x1:Y+X.w-5,y1:F-1,x2:Y+X.w+1,y2:F+5,stroke:"#f85149",strokeWidth:1.5,strokeLinecap:"round"}),o.jsx("line",{x1:Y+X.w+1,y1:F-1,x2:Y+X.w-5,y2:F+5,stroke:"#f85149",strokeWidth:1.5,strokeLinecap:"round"})]})]},X.id)}),v&&T.map(X=>G(X.id)?o.jsx("rect",{x:X.cx-X.w/2-8,y:X.cy-X.h/2-8,width:X.w+16,height:X.h+16,fill:"transparent",rx:12,onMouseEnter:()=>j(X.id),onMouseLeave:()=>j(null),onMouseUp:ne=>{ne.stopPropagation(),J()}},`drop-${X.id}`):null),W(),B()]})}const xu="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",rl="block text-[11px] text-text-secondary mb-0.5";function PB({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:rl,children:"Name"}),o.jsx("input",{value:e,onChange:p=>u(p.target.value),placeholder:"Workflow name",className:`${xu} ${l?"opacity-50":""}`,readOnly:l})]}),o.jsxs("div",{className:"min-w-[100px]",children:[o.jsx("label",{className:rl,children:"ID"}),o.jsx("input",{value:t,readOnly:!0,className:`${xu} font-mono opacity-50`})]}),o.jsxs("div",{className:"flex-1 min-w-[140px]",children:[o.jsx("label",{className:rl,children:"Description"}),o.jsx("input",{value:n,onChange:p=>!l&&c(p.target.value),readOnly:l,placeholder:"What does this workflow do?",className:`${xu} ${l?"opacity-50":""}`})]}),o.jsxs("div",{className:"w-20",children:[o.jsx("label",{className:rl,children:"Max Iter."}),o.jsx("input",{type:"number",value:s,onChange:p=>!l&&d(Number(p.target.value)),readOnly:l,className:`${xu} font-mono ${l?"opacity-50":""}`})]}),o.jsxs("div",{children:[o.jsx("label",{className:rl,children:"Color"}),o.jsx("input",{type:"color",value:a,onChange:p=>!l&&f(p.target.value),disabled:l,className:`w-8 h-8 rounded border border-border bg-transparent ${l?"opacity-50":"cursor-pointer"}`})]})]})}function BB({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 tS({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(BB,{name:s.name,id:s.id,color:s.color??"#3b82f6",description:s.description,actions:n(s)},s.id))})]})}const Aa="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",Lm="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",as="block text-[11px] text-text-secondary mb-0.5";function Rm({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 zB({step:e,isEntry:t,agentTypes:n,transitionCount:s,templateVariables:a,onUpdate:l,onRemove:u,onSetEntry:c}){const{color:d,name:f}=xg(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:as,children:"Type"}),o.jsx("select",{value:e.type,onChange:p=>{const m=p.target.value,x=m==="sub_agent"?"verification":"build";if(m==="agent"){const y=n.find(w=>!w.subagent);l({...e,type:m,phase:x,agentId:(y==null?void 0:y.id)??"builder",name:(y==null?void 0:y.name)??"Agent"})}else if(m==="sub_agent"){const y=n.find(w=>w.subagent);l({...e,type:m,phase:x,subAgentType:(y==null?void 0:y.id)??"",name:(y==null?void 0:y.name)??"Sub-Agent"})}else l({...e,type:m,phase:x,name:"Shell"})},className:Lm,children:OB.map(p=>o.jsx("option",{value:p.value,children:p.label},p.value))})]}),e.type==="agent"&&o.jsxs("div",{children:[o.jsx("label",{className:as,children:"Agent Type"}),o.jsx("select",{value:e.agentId??"builder",onChange:p=>{const m=n.find(x=>x.id===p.target.value);l({...e,agentId:p.target.value,name:(m==null?void 0:m.name)??p.target.value})},className:Lm,children:n.filter(p=>!p.subagent).map(p=>o.jsx("option",{value:p.id,children:p.name},p.id))})]}),e.type==="sub_agent"&&o.jsxs("div",{children:[o.jsx("label",{className:as,children:"Sub-Agent Type"}),o.jsxs("select",{value:e.subAgentType??"",onChange:p=>{const m=n.find(x=>x.id===p.target.value);l({...e,subAgentType:p.target.value,name:(m==null?void 0:m.name)??p.target.value})},className:Lm,children:[o.jsx("option",{value:"",children:"— select —"}),n.filter(p=>p.subagent).map(p=>o.jsx("option",{value:p.id,children:p.name},p.id))]})]}),(e.type==="agent"||e.type==="sub_agent")&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx("label",{className:as,children:"Prompt"}),o.jsx("textarea",{value:e.prompt??"",onChange:p=>l({...e,prompt:p.target.value||void 0}),rows:6,className:`${Aa} resize-y text-xs`,placeholder:"Injected on first entry..."}),o.jsx(Rm,{variables:a,onInsert:p=>l({...e,prompt:(e.prompt??"")+`{{${p}}}`})})]}),o.jsxs("div",{children:[o.jsx("label",{className:as,children:"Nudge Prompt"}),o.jsx("textarea",{value:e.nudgePrompt??"",onChange:p=>l({...e,nudgePrompt:p.target.value||void 0}),rows:6,className:`${Aa} resize-y text-xs`,placeholder:"Injected on re-entry..."}),o.jsx(Rm,{variables:a,onInsert:p=>l({...e,nudgePrompt:(e.nudgePrompt??"")+`{{${p}}}`})})]})]}),e.type==="shell"&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx("label",{className:as,children:"Command"}),o.jsx("textarea",{value:e.command??"",onChange:p=>l({...e,command:p.target.value}),rows:3,className:`${Aa} font-mono text-xs resize-y`,placeholder:"cd {{workdir}} && npm run lint"}),o.jsx(Rm,{variables:a,onInsert:p=>l({...e,command:(e.command??"")+`{{${p}}}`})})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[o.jsxs("div",{children:[o.jsx("label",{className:as,children:"Timeout (ms)"}),o.jsx("input",{type:"number",value:e.timeout??6e4,onChange:p=>l({...e,timeout:Number(p.target.value)}),className:`${Aa} font-mono text-xs`})]}),o.jsxs("div",{children:[o.jsx("label",{className:as,children:"Success Codes"}),o.jsx("input",{value:(e.successExitCodes??[0]).join(", "),onChange:p=>l({...e,successExitCodes:p.target.value.split(",").map(m=>Number(m.trim())).filter(m=>!isNaN(m))}),className:`${Aa} font-mono text-xs`})]})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:as,children:"Sub-group"}),o.jsx("input",{value:e.subGroup??"",onChange:p=>l({...e,subGroup:p.target.value||void 0}),placeholder:"e.g. build, verify, review",className:Aa})]}),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 La="w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary",nS="w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary",_i="block text-[11px] text-text-secondary mb-0.5";function $B({fromLabel:e,toLabel:t,condition:n,subGroup:s,fromStep:a,agentTypes:l,transitionIndex:u,totalTransitions:c,onUpdateCondition:d,onUpdateSubGroup:f,onDelete:p,onMoveUp:m,onMoveDown:x}){var C;const y=a&&(a.type==="sub_agent"||a.type==="agent")?l.find(b=>b.id===(a.type==="sub_agent"?a.subAgentType:a.agentId)):void 0,w=(y==null?void 0:y.results)&&y.results.length>0;return o.jsxs("div",{className:"space-y-3 text-sm",children:[o.jsxs("div",{className:"flex items-center justify-between",children:[o.jsxs("div",{className:"flex items-center gap-1.5",children:[o.jsxs("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold bg-blue-500/15 text-blue-300",children:["#",u+1]}),c>1&&o.jsxs("div",{className:"flex items-center gap-0.5",children:[o.jsx("button",{onClick:m,disabled:u===0,className:"p-0.5 rounded text-text-muted hover:text-text-primary disabled:opacity-20 disabled:cursor-not-allowed",title:"Move up (higher priority)",children:o.jsx(On,{className:"w-3 h-3",rotate:180})}),o.jsx("button",{onClick:x,disabled:u===c-1,className:"p-0.5 rounded text-text-muted hover:text-text-primary disabled:opacity-20 disabled:cursor-not-allowed",title:"Move down (lower priority)",children:o.jsx(On,{className:"w-3 h-3"})})]})]}),o.jsx("button",{onClick:p,className:"p-1 rounded text-text-muted hover:text-accent-error text-xs",children:"Delete"})]}),o.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-text-secondary",children:[o.jsx("span",{className:"font-medium text-text-primary",children:e}),o.jsx(TS,{}),o.jsx("span",{className:"font-medium text-text-primary",children:t})]}),o.jsxs("div",{children:[o.jsx("label",{className:_i,children:"Condition"}),o.jsx("select",{value:n.type,onChange:b=>{d(b.target.value==="step_result"?{type:"step_result",result:"success"}:{type:b.target.value})},className:nS,children:JC.map(b=>o.jsx("option",{value:b.value,children:b.label},b.value))})]}),n.type==="step_result"&&o.jsxs("div",{children:[o.jsx("label",{className:_i,children:"Result"}),w?o.jsx("select",{value:n.result??y.results[0],onChange:b=>{d({type:"step_result",result:b.target.value})},className:nS,children:y.results.map(b=>o.jsx("option",{value:b,children:b},b))}):o.jsx("input",{type:"text",value:n.result??"success",onChange:b=>d({type:"step_result",result:b.target.value}),placeholder:"e.g. success, passed, failed",className:La})]}),(n.type==="metadata_all_match"||n.type==="metadata_all_in")&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx("label",{className:_i,children:"Metadata Key"}),o.jsx("input",{type:"text",value:n.key??"",onChange:b=>d({...n,key:b.target.value}),placeholder:"e.g. criteria, todos, review_findings",className:La})]}),o.jsxs("div",{children:[o.jsx("label",{className:_i,children:"Field"}),o.jsx("input",{type:"text",value:n.field??"",onChange:b=>d({...n,field:b.target.value}),placeholder:"e.g. status",className:La})]}),n.type==="metadata_all_match"?o.jsxs("div",{children:[o.jsx("label",{className:_i,children:"Value"}),o.jsx("input",{type:"text",value:n.value??"",onChange:b=>d({...n,value:b.target.value}),placeholder:"e.g. passed, resolved",className:La})]}):o.jsxs("div",{children:[o.jsx("label",{className:_i,children:"Values (comma-separated)"}),o.jsx("input",{type:"text",value:((C=n.values)==null?void 0:C.join(", "))??"",onChange:b=>d({...n,values:b.target.value.split(",").map(S=>S.trim()).filter(Boolean)}),placeholder:"e.g. resolved, dismissed",className:La})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:_i,children:"Sub-group"}),o.jsx("input",{type:"text",value:s??"",onChange:b=>f(b.target.value||void 0),placeholder:"e.g. build, verify",className:La})]}),o.jsx("p",{className:"text-text-muted text-[10px]",children:"Drag handles to reconnect. Order determines evaluation priority. Press Delete to remove."})]})}function HB(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function UB(e){let t=1;for(;e.some(n=>n.id===`s${t}`);)t++;return`s${t}`}const sl="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",rS="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",Ra="block text-[11px] text-text-secondary mb-0.5",sS=[];function ZC({isOpen:e,onClose:t,initialEditId:n}){var $i,hs;const s=Ct(we=>we.defaults),a=Ct(we=>we.userItems),l=Ct(we=>we.loading),u=Ct(we=>we.templateVariables),c=Ct(we=>we.fetchWorkflows),d=Ct(we=>we.fetchWorkflow),f=Ct(we=>we.fetchDefaultContent),p=Ct(we=>we.fetchTemplateVariables),m=Ct(we=>we.createWorkflow),x=Ct(we=>we.updateWorkflow),y=Ct(we=>we.deleteWorkflow),{requestDelete:w,clearConfirm:C,isConfirming:b}=Qu(),[S,v]=L.useState("list"),[_,E]=L.useState(null),[j,T]=L.useState(!1),[R,A]=L.useState(null),[D,$]=L.useState(null),[q,G]=L.useState(""),[I,U]=L.useState(""),[V,z]=L.useState(""),[J,Z]=L.useState("1.0.0"),[H,O]=L.useState("#3b82f6"),[B,W]=L.useState(""),[P,ee]=L.useState(50),[X,ne]=L.useState(sS),[Y,F]=L.useState({type:"always"}),[te,se]=L.useState(""),[xe,le]=L.useState(!1),Ee=mt(we=>we.defaults),ue=mt(we=>we.userItems),ae=mt(we=>we.projectItems),de=L.useMemo(()=>[...Ee,...ue,...ae],[Ee,ue,ae]),oe=mt(we=>we.fetchAgents),[Ne]=L.useState(null);L.useEffect(()=>{e&&(c(),p(),oe(),A(null),$(null),n?s.some(ke=>ke.id===n)?f(n).then(ke=>{ke&&ve({...ke,metadata:{...ke.metadata,name:ke.metadata.name+" (copy)",id:`${n}-copy-${Date.now()}`}},{editingId:null,isReadOnly:!1})}):d(n).then(ke=>{ke&&ve(ke,{editingId:n,isReadOnly:!1})}):(v("list"),E(null),T(!1)))},[e,c,d,f,p,n]);const ve=(we,ke)=>{G(we.metadata.name),U(we.metadata.id),z(we.metadata.description),Z(we.metadata.version),O(we.metadata.color??"#3b82f6"),W(we.entryStep),ee(we.settings.maxIterations),ne(we.steps),F(we.startCondition??{type:"always"}),se(""),(ke==null?void 0:ke.editingId)!==void 0&&E(ke.editingId),(ke==null?void 0:ke.isReadOnly)!==void 0&&T(ke.isReadOnly),(ke==null?void 0:ke.selectedNodeKey)!==void 0&&A(null),(ke==null?void 0:ke.selectedEdgeKey)!==void 0&&$(null),v("edit")},re=async we=>{const ke=await d(we);ke&&ve(ke,{editingId:we,isReadOnly:!1,selectedNodeKey:null,selectedEdgeKey:null})},_e=async()=>{var tt;const we=_??I;if(!we||!q)return se("Name is required."),!1;if(X.length===0)return se("Add at least one step."),!1;let ke=B;if(!ke||!X.some(qe=>qe.id===ke)){if(ke=((tt=X.find(qe=>qe.id))==null?void 0:tt.id)??"",!ke)return se("All steps need an ID."),!1;W(ke)}le(!0),se("");const Ie={metadata:{id:we,name:q,description:V,version:J||"1.0.0",color:H},entryStep:ke,settings:{maxIterations:P},steps:X,startCondition:Y},$e=_?await x(_,Ie):await m(Ie);return le(!1),$e.success?(_||E(we),!0):(se($e.error??"Failed to save."),!1)},He=async()=>{await _e()},et=async()=>{await _e()&&(n?t():v("list"))},rt=()=>{n?t():v("list")},kt=we=>{G(we),_||U(HB(we))},ye=async we=>s.some(Ie=>Ie.id===we)?await f(we):await d(we),Ae=async we=>{const ke=await ye(we);ke&&ve(ke,{editingId:we,isReadOnly:!0})},Be=async we=>{const ke=await ye(we);ke&&ve({...ke,metadata:{...ke.metadata,name:ke.metadata.name+" (copy)",id:`${we}-copy-${Date.now()}`}},{editingId:null,isReadOnly:!1})},Ge=()=>{E(null),G(""),U(""),z(""),Z("1.0.0"),O("#3b82f6"),W(""),ee(50),ne(structuredClone(sS)),F({type:"always"}),se(""),A(null),$(null),T(!1),v("edit")},Xe=async we=>{await y(we),C()},Dt=L.useCallback(we=>{A(we),$(null)},[]),nt=L.useCallback(we=>{$(we),A(null)},[]),Ot=R!==null?Number(R):-1,pt=Ot>=0?X[Ot]??null:null,xn=L.useCallback(we=>{ne(ke=>ke.map((Ie,$e)=>$e===Ot?we:Ie))},[Ot]),xt=Y.type==="step_result"?`${Y.result}`:Y.type==="metadata_all_match"?`${Y.key??"?"}=${Y.value??"?"}`:Y.type==="metadata_all_in"?`${Y.key??"?"} in [${(($i=Y.values)==null?void 0:$i.join(","))??"?"}]`:QC[Y.type]??Y.type,hr=()=>{const we=X.length,ke=UB(X),Ie=de.find($e=>!$e.subagent);ne([...X,{id:ke,name:(Ie==null?void 0:Ie.name)??"Agent",type:"agent",phase:"build",agentId:(Ie==null?void 0:Ie.id)??"builder",transitions:[]}]),B||W(ke),Dt(String(we))},Pn=L.useCallback((we,ke)=>{we==="$start"?(W(ke),nt("start")):ne(Ie=>{const $e=Ie.find(qe=>qe.id===we),tt=$e?$e.transitions.length:0;return nt(`${we}:${tt}`),Ie.map(qe=>qe.id===we?{...qe,transitions:[...qe.transitions,{when:{type:"always"},goto:ke}]}:qe)})},[nt]),Mi=we=>{if(we==="start")return null;const ke=we.lastIndexOf(":"),Ie=we.slice(0,ke),$e=parseInt(we.slice(ke+1));return{stepId:Ie,transIdx:$e}},fr=L.useCallback((we,ke)=>{const Ie=Mi(we);Ie&&ne($e=>$e.map(tt=>tt.id===Ie.stepId?{...tt,transitions:tt.transitions.map((qe,dt)=>dt===Ie.transIdx?ke(qe):qe)}:tt))},[]),Pi=L.useCallback((we,ke)=>{if(we==="start"){W(ke);return}fr(we,Ie=>({...Ie,goto:ke}))},[fr]),Bi=L.useCallback((we,ke)=>{const Ie=Mi(we);Ie&&(ne($e=>{const tt=$e.find(dt=>dt.id===Ie.stepId);if(!tt)return $e;const qe=tt.transitions[Ie.transIdx];return qe?$e.map(dt=>dt.id===Ie.stepId?{...dt,transitions:dt.transitions.filter((dn,Pt)=>Pt!==Ie.transIdx)}:dt.id===ke?{...dt,transitions:[...dt.transitions,qe]}:dt):$e}),$(null))},[]),Cr=L.useCallback(we=>{if(we==="start"){W(""),$(null);return}const ke=Mi(we);ke&&(ne(Ie=>Ie.map($e=>$e.id===ke.stepId?{...$e,transitions:$e.transitions.filter((tt,qe)=>qe!==ke.transIdx)}:$e)),$(null))},[]),zi=L.useCallback((we,ke)=>{if(we==="start"){F(ke);return}fr(we,Ie=>({...Ie,when:ke}))},[fr]),Ys=L.useCallback((we,ke)=>{we!=="start"&&fr(we,Ie=>({...Ie,subGroup:ke||void 0}))},[fr]),eo=we=>xg(we,de).name,Ml=()=>{if(!D)return null;if(D==="start"){const dn=X.find(Pt=>Pt.id===B);return{type:"start",fromLabel:"Start",toLabel:dn?eo(dn):"(none)",condition:Y}}const we=D.lastIndexOf(":"),ke=D.slice(0,we),Ie=parseInt(D.slice(we+1)),$e=X.find(dn=>dn.id===ke);if(!$e)return null;const tt=$e.transitions[Ie];if(!tt)return null;const qe=X.find(dn=>dn.id===tt.goto),dt=tt.goto==="$done"?"Done":qe?eo(qe):tt.goto;return{type:"step",fromLabel:eo($e),toLabel:dt,condition:tt.when,subGroup:tt.subGroup}};if(S==="edit"){const we=Ml();return o.jsxs(jt,{isOpen:e,onClose:rt,title:j?q:_?"Edit Workflow":"New Workflow",size:"full",children:[te&&o.jsx("div",{className:"text-accent-error text-sm px-3 py-2 bg-accent-error/10 rounded mb-3",children:te}),o.jsx(PB,{formName:q,formId:I,formDescription:V,formMaxIterations:P,formColor:H,isReadOnly:j,onNameChange:kt,onDescriptionChange:z,onMaxIterationsChange:ee,onColorChange:O}),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"}),!j&&o.jsx("button",{onClick:hr,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(MB,{steps:X,entryStep:B,selectedNodeId:(pt==null?void 0:pt.id)??null,selectedEdgeKey:D,startConditionLabel:xt,agentTypes:de,isReadOnly:j,onSelectNode:ke=>{if(ke===null){Dt(null);return}const Ie=X.findIndex($e=>$e.id===ke);Dt(Ie>=0?String(Ie):null)},onSelectEdge:nt,onRemoveStep:ke=>{var $e;const Ie=X.findIndex(tt=>tt.id===ke);if(ne(tt=>tt.filter(qe=>qe.id!==ke)),Ot===Ie&&Dt(null),B===ke){const tt=X.filter(qe=>qe.id!==ke);W((($e=tt[0])==null?void 0:$e.id)??"")}},onCreateTransition:Pn,onReconnectTo:Pi,onReconnectFrom:Bi,onDeleteTransition:Cr}),X.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:hr,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:j&&(we||pt)?o.jsx("p",{className:"text-text-muted text-xs text-center py-8",children:'View only — click "Duplicate & Customize" to edit.'}):we?we.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"})}),B&&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(TS,{}),o.jsx("span",{className:"text-text-primary font-medium",children:we.toLabel})]}),o.jsxs("div",{children:[o.jsx("label",{className:Ra,children:"Activation Condition"}),o.jsx("select",{value:Y.type,onChange:ke=>F(ke.target.value==="step_result"?{type:"step_result",result:"success"}:ke.target.value==="metadata_all_match"?{type:"metadata_all_match",key:"",field:"",value:""}:ke.target.value==="metadata_all_in"?{type:"metadata_all_in",key:"",field:"",values:[]}:{type:ke.target.value}),className:rS,children:JC.map(ke=>o.jsx("option",{value:ke.value,children:ke.label},ke.value))})]}),Y.type==="step_result"&&o.jsxs("div",{children:[o.jsx("label",{className:Ra,children:"Result"}),B&&(()=>{const ke=X.find(qe=>qe.id===B),Ie=ke&&(ke.type==="sub_agent"||ke.type==="agent")?de.find(qe=>qe.id===(ke.type==="sub_agent"?ke.subAgentType:ke.agentId)):void 0,$e=(Ie==null?void 0:Ie.results)&&Ie.results.length>0,tt=(Ie==null?void 0:Ie.results)??[];return $e?o.jsx("select",{value:Y.result??tt[0],onChange:qe=>F({type:"step_result",result:qe.target.value}),className:rS,children:tt.map(qe=>o.jsx("option",{value:qe,children:qe},qe))}):o.jsx("input",{type:"text",value:Y.result??"success",onChange:qe=>F({type:"step_result",result:qe.target.value}),placeholder:"e.g. success, passed, failed",className:sl})})()]}),(Y.type==="metadata_all_match"||Y.type==="metadata_all_in")&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{children:[o.jsx("label",{className:Ra,children:"Metadata Key"}),o.jsx("input",{type:"text",value:Y.key??"",onChange:ke=>F({...Y,key:ke.target.value}),placeholder:"e.g. criteria, todos, review_findings",className:sl})]}),o.jsxs("div",{children:[o.jsx("label",{className:Ra,children:"Field"}),o.jsx("input",{type:"text",value:Y.field??"",onChange:ke=>F({...Y,field:ke.target.value}),placeholder:"e.g. status",className:sl})]}),Y.type==="metadata_all_match"?o.jsxs("div",{children:[o.jsx("label",{className:Ra,children:"Value"}),o.jsx("input",{type:"text",value:Y.value??"",onChange:ke=>F({...Y,value:ke.target.value}),placeholder:"e.g. passed, resolved",className:sl})]}):o.jsxs("div",{children:[o.jsx("label",{className:Ra,children:"Values (comma-separated)"}),o.jsx("input",{type:"text",value:((hs=Y.values)==null?void 0:hs.join(", "))??"",onChange:ke=>F({...Y,values:ke.target.value.split(",").map(Ie=>Ie.trim()).filter(Boolean)}),placeholder:"e.g. resolved, dismissed",className:sl})]})]}),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 ke=Mi(D),Ie=ke==null?void 0:ke.stepId,$e=(ke==null?void 0:ke.transIdx)??0,tt=Ie?X.find(dt=>dt.id===Ie):void 0,qe=(tt==null?void 0:tt.transitions.length)??0;return o.jsx($B,{fromLabel:we.fromLabel,toLabel:we.toLabel,condition:we.condition,subGroup:"subGroup"in we?we.subGroup:void 0,fromStep:we.type==="step"?X.find(dt=>dt.id===we.fromLabel):void 0,agentTypes:de,transitionIndex:$e,totalTransitions:qe,onUpdateCondition:dt=>zi(D,dt),onUpdateSubGroup:dt=>Ys(D,dt),onDelete:()=>Cr(D),onMoveUp:()=>{ne(dt=>{const dn=dt.find(yt=>yt.id===Ie);if(!dn||$e===0)return dt;const Pt=[...dn.transitions];return[Pt[$e-1],Pt[$e]]=[Pt[$e],Pt[$e-1]],dt.map(yt=>yt.id===Ie?{...yt,transitions:Pt}:yt)}),$(`${Ie}:${$e-1}`)},onMoveDown:()=>{ne(dt=>{const dn=dt.find(yt=>yt.id===Ie);if(!dn||$e===dn.transitions.length-1)return dt;const Pt=[...dn.transitions];return[Pt[$e],Pt[$e+1]]=[Pt[$e+1],Pt[$e]],dt.map(yt=>yt.id===Ie?{...yt,transitions:Pt}:yt)}),$(`${Ie}:${$e+1}`)}})})():pt?o.jsx(zB,{step:pt,isEntry:pt.id===B,agentTypes:de,transitionCount:pt.transitions.length,templateVariables:u,onUpdate:xn,onRemove:()=>{var ke;if(pt&&(ne(X.filter((Ie,$e)=>$e!==Ot)),Dt(null),B===pt.id)){const Ie=X.filter(($e,tt)=>tt!==Ot);W(((ke=Ie[0])==null?void 0:ke.id)??"")}},onSetEntry:()=>W(pt.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(Ve,{variant:"secondary",onClick:rt,children:"Close"}),j?o.jsx(Ve,{variant:"primary",onClick:()=>{G(q+" (copy)"),U(`${_}-copy-${Date.now()}`),E(null),T(!1)},children:"Duplicate & Customize"}):o.jsxs(o.Fragment,{children:[o.jsx(Ve,{variant:"primary",onClick:He,children:"Save"}),o.jsx(Ve,{variant:"primary",onClick:et,children:"Save & Close"})]})]})]})}return o.jsx(jt,{isOpen:e,onClose:t,title:"Workflows",size:"lg",children:o.jsx($S,{description:"Workflows define multi-step agentic processes with branching transitions.",onNew:Ge,loading:l,hasItems:s.length>0||a.length>0,children:o.jsxs("div",{className:"space-y-4",children:[o.jsx(tS,{title:"Built-in",items:s,renderActions:we=>o.jsx(o.Fragment,{children:o.jsx(Fs,{onClick:()=>Be(we.id),children:o.jsx(wu,{})})})}),o.jsx(tS,{title:"Custom",items:a,renderActions:we=>o.jsxs(o.Fragment,{children:[o.jsx(Fs,{onClick:()=>Ae(we.id),children:o.jsx(wu,{})}),o.jsx(Fs,{onClick:()=>re(we.id),children:o.jsx("span",{className:"text-[10px]",children:"Edit"})}),o.jsx(Cu,{onClick:()=>Be(we.id)}),b(we.id,"delete")?o.jsx(Tp,{onConfirm:()=>Xe(we.id),onCancel:C}):o.jsx(Ap,{onClick:()=>w(we.id)})]})})]})})})}function FB(e){const t=e.match(/^\/p\/([^/]+)/);return t==null?void 0:t[1]}function VB({isOpen:e,onClose:t,onCloseComplete:n,onSelectCommand:s,onSelectWorkflow:a,onCloseCompleteAction:l,textareaContent:u,onSearchMessages:c,onToggleAutoScroll:d,isAutoScrollActive:f}){const[,p]=Yn(),m=en(P=>P.fetchCommands),x=Ct(P=>P.fetchWorkflows),y=mt(P=>P.fetchAgents),w=en(P=>P.defaults),C=en(P=>P.userItems),b=en(P=>P.projectItems),S=Ct(P=>P.defaults),v=Ct(P=>P.userItems),_=Ct(P=>P.projectItems),E=mt(P=>P.defaults),j=mt(P=>P.userItems),T=mt(P=>P.projectItems),R=De(P=>{var ee;return(ee=P.currentSession)==null?void 0:ee.mode}),A=De(P=>{var ee;return((ee=P.currentSession)==null?void 0:ee.dangerLevel)??"normal"}),D=De(P=>P.switchMode),$=De(P=>P.switchDangerLevel),q=De(P=>{var ee;return(ee=P.currentSession)==null?void 0:ee.projectId}),G=L.useRef(void 0),[I,U]=L.useState(""),[V,z]=L.useState(0),J=L.useRef(null),Z=L.useRef(!1);L.useEffect(()=>{e&&(Z.current=!0)},[e]),L.useEffect(()=>{if(e){m(),x(),y(),U(""),z(0);const P=setTimeout(()=>{var ee;return(ee=J.current)==null?void 0:ee.focus()},50);return()=>clearTimeout(P)}},[e,m,x,y]),L.useEffect(()=>{var P;!e&&Z.current&&(n==null||n(),(P=G.current)==null||P.call(G),G.current=void 0)},[e,n]);const O=[{id:"create-session",name:"New Session",prefix:"Action > Create",action:()=>{const P=q??FB(window.location.pathname);P&&p(`/p/${P}/new`)}},{id:"navigate-session",name:"Another Session",prefix:"Action > Navigate to",action:()=>{G.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)}},...Or(Or(E,j),T).filter(P=>!P.subagent&&P.id!==R).map(P=>({id:P.id,name:P.name,prefix:"Agent > Switch to",action:()=>D(P.id)})),...Or(Or(w,C),b).map(P=>({id:P.id,name:P.name,prefix:"Command > Launch",action:()=>s(P.id,u)})),...Or(Or(S,v),_).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:()=>$(P)}))].filter(P=>Pa(`${P.prefix} ${P.name}`,I)),B=O.length-1,W=P=>{i1(P,B,z,()=>{var ee;(ee=O[V])==null||ee.action(),t()},t)};return e?Ka.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:J,type:"text",value:I,onChange:P=>{U(P.target.value),z(0)},onKeyDown:W,placeholder:"Search...",className:"flex-1 bg-transparent text-sm focus:outline-none placeholder:text-text-muted"}),o.jsx(Np,{onClick:t,className:"shrink-0","aria-label":"Close"})]}),o.jsx("div",{className:"overflow-y-auto max-h-[60vh] p-2",children:O.length===0?o.jsx("div",{className:"px-3 py-4 text-center text-text-muted text-sm",children:w.length+C.length+S.length+v.length>0?"No matches":"No agents, commands, or workflows yet"}):O.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}const ek="openfox-message-search-filters",GB=[{key:"user",label:"User prompts"},{key:"thinking",label:"Thinking"},{key:"response",label:"Responses"}];function WB(){try{const e=localStorage.getItem(ek);if(e){const t=JSON.parse(e);return new Set(t)}}catch{}return new Set(["user","thinking","response"])}function qB(e){localStorage.setItem(ek,JSON.stringify([...e]))}function KB(e){var n,s;if(e.type!=="message")return null;const t=e.message;if(t.role==="user")return"user";if(t.role==="assistant"){if((n=t.content)!=null&&n.trim())return"response";if((s=t.thinkingContent)!=null&&s.trim())return"thinking"}return null}function YB(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 XB(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 QB(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 JB(e){var n,s;if(e.type!=="message")return o.jsx(Gb,{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(nN,{className:"w-3.5 h-3.5"}):o.jsx(Gb,{className:"w-3.5 h-3.5"}):o.jsx(tN,{className:"w-3.5 h-3.5"})}function iS(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}`:""}function ZB({isOpen:e,onClose:t,displayItems:n,onNavigate:s}){const[a,l]=L.useState(""),[u,c]=L.useState(0),[d,f]=L.useState(WB),p=L.useRef(null),m=L.useRef(null),x=L.useRef(null),y=j=>{f(T=>{const R=new Set(T);return R.has(j)?R.delete(j):R.add(j),qB(R),R})},w=L.useMemo(()=>n.filter(j=>{var T,R;return!(j.type==="context-divider"||j.type==="message"&&(j.message.messageKind==="auto-prompt"||j.message.role==="assistant"&&!((T=j.message.content)!=null&&T.trim())&&!((R=j.message.thinkingContent)!=null&&R.trim())))}),[n]),C=L.useMemo(()=>w.filter(j=>{const T=KB(j);return!(T&&!d.has(T))}),[w,d]),b=L.useMemo(()=>a?w.filter(j=>{const T=iS(j);return Pa(T,a)}):C,[C,a]),S=b.length-1;L.useEffect(()=>{if(e){l(""),c(0);const j=setTimeout(()=>{var T;return(T=p.current)==null?void 0:T.focus()},50);return()=>clearTimeout(j)}},[e]),L.useEffect(()=>{e&&m.current&&(m.current.scrollTop=m.current.scrollHeight)},[e]),L.useEffect(()=>{x.current&&x.current.scrollIntoView({block:"nearest",behavior:"smooth"})},[u]);const v=j=>{i1(j,S,c,()=>{const T=b[u];if(T){const R=n.indexOf(T);R>=0&&s(R),t()}},t)},_=j=>{const T=n.indexOf(j);T>=0&&s(T),t()},E=j=>n.indexOf(j);return e?Ka.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(pl,{}),o.jsx("input",{ref:p,type:"text",value:a,onChange:j=>{l(j.target.value),c(0)},onKeyDown:v,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(qa,{className:"w-4 h-4"})})]}),o.jsx("div",{className:"flex gap-1.5 px-4 py-2 border-b border-border",children:GB.map(j=>{const T=d.has(j.key);return o.jsx("button",{type:"button",onClick:()=>y(j.key),className:`px-2 py-0.5 rounded text-xs font-medium transition-colors ${T?"bg-accent-primary/20 text-accent-primary border border-accent-primary/40":"bg-bg-tertiary text-text-muted border border-border hover:text-text-secondary"}`,children:j.label},j.key)})}),o.jsx("div",{ref:m,className:"overflow-y-auto max-h-[60vh] p-2",children:b.length===0?o.jsx("div",{className:"px-3 py-4 text-center text-text-muted text-sm",children:C.length>0?"No matches":"No messages yet"}):b.map((j,T)=>{const R=E(j),A=JB(j),D=iS(j),$=QB(j),q=XB(j),G=j.type==="message"&&j.message.role==="user";return o.jsx("button",{ref:T===u?x:null,type:"button",onClick:()=>_(j),className:`w-full text-left px-3 py-2 rounded text-sm transition-colors ${T===u?"bg-accent-primary/20 text-text-primary":G?"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:A}),o.jsx("span",{className:`truncate flex-1 ${$}`,children:D})]}),q&&o.jsx("span",{className:"text-text-muted text-xs shrink-0",children:YB(q)})]})},`${R}-${j.type}`)})})]})]}),document.body):null}function e8({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(Tl,{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.description||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 t8({history:e,selectedIndex:t,onSelect:n,onEscape:s,onNavigate:a}){const l=L.useRef(null),u=L.useRef(null);L.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,p)=>o.jsxs("div",{ref:p===t?u:null,role:"listitem",onClick:()=>d(f.content),className:`
|
|
295
|
+
p-2 rounded cursor-pointer transition-colors
|
|
296
|
+
${p===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 n8(){const e=Tj(),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 r8={maxWidth:1920,maxHeight:1920,quality:.85,maxSizeBytes:1048576};async function s8(e,t={}){const n={...r8,...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=d8(a),u=`data:${e.type};base64,${l}`,c=await tk(u);return{dataUrl:u,mimeType:e.type,size:e.size,width:c.width,height:c.height}}return await i8(e,n)}async function i8(e,t){const n=await o8(e),s=await tk(n),{width:a,height:l}=a8(s.width,s.height,t.maxWidth,t.maxHeight),u=l8();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 m=0;m<10&&(f=u.toDataURL(e.type.startsWith("image/gif")?"image/png":e.type,d),!(aS(f)<=t.maxSizeBytes||d<=.3));m++)d-=.1;const p=aS(f);return{dataUrl:f,mimeType:e.type.startsWith("image/gif")?"image/png":e.type,size:p,width:a,height:l}}function a8(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 o8(e){return new Promise((t,n)=>{const s=u8(),a=new s;a.onload=()=>t(a.result),a.onerror=()=>n(new Error("Failed to read file")),a.readAsDataURL(e)})}function tk(e){return new Promise((t,n)=>{const s=c8(),a=new s;a.onload=()=>t(a),a.onerror=()=>n(new Error("Failed to load image")),a.src=e})}function l8(){var t;const e=yg();if(!((t=e.document)!=null&&t.createElement))throw new Error("Image compression requires browser canvas APIs");return e.document.createElement("canvas")}function c8(){const e=yg();if(!e.Image)throw new Error("Image compression requires browser image APIs");return e.Image}function u8(){const e=yg();if(!e.FileReader)throw new Error("Image compression requires browser file APIs");return e.FileReader}function yg(){return globalThis}function d8(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 aS(e){const n=e.split(",")[1];return n?Math.round(n.length*3/4):0}function h8(e){return["image/png","image/jpeg","image/gif"].includes(e.type)}function f8(e,t=50*1024*1024){return e.size>t?{valid:!1,error:`Image file is too large (${oS(e.size)}). Maximum size is ${oS(t)}.`}:{valid:!0}}function oS(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}async function Dm(e,t,n,s={}){const{maxSizeBytes:a=50*1024*1024,filename:l}=s;if(!h8(e)){n(`Unsupported file type: ${e.type}. Only PNG, JPG, and GIF are supported.`);return}const u=f8(e,a);if(!u.valid){n(u.error??"Image file is too large");return}try{const c=await s8(e,{maxWidth:1920,maxHeight:1920,quality:.85,maxSizeBytes:1048576}),d={id:bS(),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 nk(e){const t=De(l=>l.sendMessage),n=De(l=>l.launchWorkflow),s=L.useCallback((l,u,c)=>{e(!0),t(l,u,c)},[e,t]),a=L.useCallback((l,u,c,d)=>{e(!0),n(l,u,c,d)},[e,n]);return{sendMessage:s,launchWorkflow:a}}function m8({children:e}){return Ka.createPortal(e,document.body)}function p8(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 g8({onSendCommand:e,onSelectWorkflow:t,onSelectWorkflowWithSubGroup:n,onOpenCommandsManager:s,onOpenWorkflowsManager:a,onAttach:l,textareaContent:u,attachments:c}){const[d,f]=L.useState(!1),[p,m]=L.useState("commands"),[x,y]=L.useState(""),[w,C]=L.useState(0),[b,S]=L.useState(null),[v,_]=L.useState(null),E=L.useRef(null),j=L.useRef(null),T=en(ee=>ee.defaults),R=en(ee=>ee.userItems),A=en(ee=>ee.projectItems),D=en(ee=>ee.fetchCommands),$=Ct(ee=>ee.defaults),q=Ct(ee=>ee.userItems),G=Ct(ee=>ee.projectItems),I=Ct(ee=>ee.fetchWorkflows),U=Or(Or(T,R),A),V=Or(Or($,q),G);L.useEffect(()=>{d&&(p==="commands"?D():p==="workflows"&&I())},[d,p,D,I]),L.useEffect(()=>{d&&(y(""),C(0),requestAnimationFrame(()=>{var ee;return(ee=E.current)==null?void 0:ee.focus()}))},[d,p]),L.useEffect(()=>{if(!d)return;const ee=X=>{var ne;(ne=j.current)!=null&&ne.contains(X.target)||f(!1)};return document.addEventListener("mousedown",ee),()=>document.removeEventListener("mousedown",ee)},[d]);const z=ee=>{switch(ee.key){case"ArrowDown":ee.preventDefault(),C(X=>{const Y=(p==="commands"?U:V).filter(F=>{const te=x.toLowerCase();return!te||F.name.toLowerCase().includes(te)});return Math.min(X+1,Y.length-1)});break;case"ArrowUp":ee.preventDefault(),C(X=>Math.max(X-1,0));break;case"Enter":ee.preventDefault();break;case"Escape":ee.preventDefault(),f(!1);break}},J=ee=>{y(ee),C(0)},Z=U.filter(ee=>!x||ee.name.toLowerCase().includes(x.toLowerCase())),H=V.filter(ee=>!x||ee.name.toLowerCase().includes(x.toLowerCase())),O=async ee=>{const X=await en.getState().fetchCommand(ee);X&&e(X.prompt,X.metadata.agentMode,u,c),f(!1)},B=ee=>{t(ee),f(!1)},W=(ee,X)=>{X.stopPropagation(),f(!1),S(ee)},P=(ee,X)=>{X.stopPropagation(),f(!1),_(ee)};return o.jsxs("div",{ref:j,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(LS,{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:()=>{m("commands"),y(""),C(0)},className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${p==="commands"?"text-accent-primary border-b-2 border-accent-primary":"text-text-muted hover:text-text-primary"}`,children:"Commands"}),o.jsx("button",{type:"button",onClick:()=>{m("workflows"),y(""),C(0)},className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${p==="workflows"?"text-accent-primary border-b-2 border-accent-primary":"text-text-muted hover:text-text-primary"}`,children:"Workflows"}),o.jsx("button",{type:"button",onClick:()=>m("attach"),className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${p==="attach"?"text-accent-primary border-b-2 border-accent-primary":"text-text-muted hover:text-text-primary"}`,children:"Attach"})]}),p!=="attach"&&o.jsx("div",{className:"p-2 border-b border-border",children:o.jsx("input",{ref:E,value:x,onChange:ee=>J(ee.target.value),onKeyDown:z,placeholder:p==="commands"?"Search commands...":"Search workflows...",className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary"})}),o.jsx("div",{className:"overflow-y-auto max-h-64 p-1",children:p==="commands"?Z.length===0?o.jsx("div",{className:"px-3 py-2 text-text-muted text-sm",children:U.length===0?"No commands yet":"No matches"}):Z.map((ee,X)=>o.jsxs("div",{className:`flex items-center gap-1 px-3 py-2 rounded transition-colors group ${X===w?"bg-accent-primary/20":"hover:bg-bg-tertiary"}`,children:[o.jsx("button",{type:"button",onClick:()=>O(ee.id),className:"flex-1 text-left",children:o.jsx("div",{className:"text-sm text-text-primary font-medium",children:ee.name})}),o.jsx(Fs,{className:"opacity-0 group-hover:opacity-100",onClick:ne=>W(ee.id,ne)})]},ee.id)):p==="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,X)=>{const ne=p8(ee),Y=ee.color??"#3b82f6";return o.jsxs("div",{className:`flex items-center gap-2 px-3 py-2 rounded transition-colors group ${X===w?"bg-accent-primary/20":"hover:bg-bg-tertiary"}`,children:[o.jsxs("button",{type:"button",onClick:()=>B(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}),ne!==null&&o.jsx("span",{className:"w-1.5 h-1.5 rounded-full flex-shrink-0",style:{backgroundColor:ne?"#22c55e":"#6b7280"},title:ne?"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(x8,{subGroups:ee.subGroups,onSelect:F=>{f(!1),n(ee.id,F)}}),o.jsx(Fs,{className:"opacity-0 group-hover:opacity-100",onClick:F=>P(ee.id,F)})]})]},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(Bj,{className:"w-4 h-4"}),o.jsx("span",{className:"text-sm font-medium",children:"Attach image"})]}),o.jsx("span",{className:"text-xs text-text-muted",children:"or drag & drop into chat"})]})}),p!=="attach"&&o.jsx("div",{className:"border-t border-border p-1",children:o.jsx("button",{type:"button",onClick:()=>{f(!1),p==="commands"?s():a()},className:"w-full text-left px-3 py-1.5 rounded text-sm text-text-muted hover:text-text-primary hover:bg-bg-tertiary transition-colors",children:p==="commands"?"Manage Commands...":"Manage Workflows..."})})]}),o.jsx(XC,{isOpen:!!b,onClose:()=>S(null),initialEditId:b}),o.jsx(ZC,{isOpen:!!v,onClose:()=>_(null),initialEditId:v})]})}function x8({subGroups:e,onSelect:t}){const[n,s]=L.useState(!1),[a,l]=L.useState({top:0,right:0}),u=L.useRef(null),c=L.useRef(null);YC(c,()=>s(!1),n);const d=f=>{if(f.stopPropagation(),!n&&u.current){const p=u.current.getBoundingClientRect();l({top:p.bottom+4,right:window.innerWidth-p.right})}s(!n)};return o.jsxs(o.Fragment,{children:[o.jsx("button",{ref:u,type:"button",onClick:d,className:"p-1 rounded text-text-muted hover:text-text-primary transition-colors",title:"Sub-groups",children:"⋮"}),n&&o.jsx(m8,{children:o.jsx("div",{ref:c,onMouseDown:f=>f.stopPropagation(),className:"fixed w-40 bg-bg-secondary border border-border rounded-lg shadow-xl z-[100] overflow-hidden",style:{top:a.top,right:a.right},children:e.map(f=>o.jsx("button",{type:"button",onClick:p=>{p.stopPropagation(),t(f)},className:"w-full text-left px-3 py-2 text-sm text-text-primary hover:bg-bg-tertiary transition-colors",children:f},f))})})]})}function y8({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(Tl,{onClick:()=>t(n.queueId),size:"sm"})]},n.queueId))})}function _8({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(qS,{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 lS({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=p=>o.jsx(_8,{agent:p,isBuiltIn:s,isConfirmingDelete:!1,alwaysAllowedNames:a,onView:()=>l(p.id),onEdit:s?void 0:()=>c==null?void 0:c(p.id),onDuplicate:()=>u(p.id),onDelete:s?void 0:()=>d==null?void 0:d(p.id)},p.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 b8(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 Om(e){const t=[];for(const[n,s]of e)s.size===0?t.push(n):t.push(`${n}:${[...s].join(",")}`);return t}function v8({formName:e,formId:t,formDescription:n,formSubagent:s,formTools:a,formColor:l,formPrompt:u,formError:c,saving:d,isReadOnly:f,availableTools:p,onNameChange:m,onIdChange:x,onDescriptionChange:y,onSubagentChange:w,onToolsChange:C,onColorChange:b,onPromptChange:S,onSave:v,onCancel:_,onDuplicate:E}){const j=b8(a),T=p.filter(D=>!(s&&D.topLevelOnly)),R=(D,$)=>{const q=new Map(j),G=q.get(D)||new Set,I=new Set(G);I.has($)?I.delete($):I.add($),I.size===0?q.set(D,new Set):q.set(D,I),C(Om(q))},A=D=>{const $=new Map(j);$.has(D)?$.delete(D):$.set(D,new Set),C(Om($))};return o.jsxs("div",{className:"flex flex-col h-full",children:[o.jsxs("div",{className:"space-y-3",children:[c&&o.jsx(Ju,{message:c}),o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsx(vr,{label:"Name",value:e,onChange:m,placeholder:"My Agent",readOnly:f}),o.jsx(vr,{label:"ID",value:t,onChange:x,readOnly:!0,placeholder:"my_agent",hint:"(read-only)",mono:!0})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[o.jsx(vr,{label:"Description",value:n,onChange:y,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:D=>!f&&b(D.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(D=>{const $=j.has(D.name),q=D.actions.length>0,G=j.get(D.name)||new Set;return q?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:D.name}),o.jsx("span",{className:"text-[10px]",children:"*"})]},D.name):o.jsx(Nl,{trigger:o.jsxs("button",{className:`px-1.5 py-0.5 rounded text-xs font-mono transition-colors flex items-center gap-1 ${$?"bg-accent-primary/25 text-accent-primary":"bg-bg-primary text-text-muted"}`,children:[o.jsx("span",{children:D.name}),q&&o.jsx("span",{className:`text-[10px] ${$&&G.size>0?"text-accent-primary":"text-text-muted"}`,children:"*"})]}),minWidth:"160px",items:[...D.actions.map(I=>({label:o.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",htmlFor:`${D.name}-${I}`,children:[o.jsx("input",{type:"checkbox",id:`${D.name}-${I}`,checked:G.has(I),onChange:()=>R(D.name,I),disabled:f,className:"w-3 h-3 rounded accent-accent-primary"}),o.jsx("span",{children:I})]}),closeOnClick:!1})),{label:$?"Deselect all":"Select all",closeOnClick:!1,onClick:()=>{if($)A(D.name);else{const I=new Map(j);I.set(D.name,new Set(D.actions)),C(Om(I))}}}]},D.name):o.jsx("button",{onClick:()=>!f&&A(D.name),className:`px-1.5 py-0.5 rounded text-xs font-mono transition-colors flex items-center gap-1 ${$?"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:D.name})},D.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:D=>!f&&S(D.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(fN,{onCancel:_,onSave:v,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 S8(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_|_$/g,"")}function w8({isOpen:e,onClose:t,initialEditId:n}){const s=mt(ve=>ve.defaults),a=mt(ve=>ve.userItems),l=mt(ve=>ve.loading),u=mt(ve=>ve.fetchAgents),c=mt(ve=>ve.fetchAgent),d=mt(ve=>ve.fetchDefaultContent),f=mt(ve=>ve.createAgent),p=mt(ve=>ve.updateAgent),m=mt(ve=>ve.deleteAgent),[x,y]=L.useState("list"),[w,C]=L.useState(null),[b,S]=L.useState(!1),[v,_]=L.useState(""),[E,j]=L.useState(""),[T,R]=L.useState(""),[A,D]=L.useState(!0),[$,q]=L.useState([]),[G,I]=L.useState("#6b7280"),[U,V]=L.useState(""),[z,J]=L.useState(""),[Z,H]=L.useState(!1),[O,B]=L.useState([]),[W,P]=L.useState(new Set),ee=ve=>{_(ve.metadata.name),j(ve.metadata.id),R(ve.metadata.description),D(ve.metadata.subagent),q(ve.metadata.allowedTools),I(ve.metadata.color??"#6b7280"),V(ve.prompt),J("")},X=(ve,re,_e)=>{_(ve.metadata.name+" (copy)"),j(`${re}-copy-${Date.now()}`),R(ve.metadata.description),D(ve.metadata.subagent),q(ve.metadata.allowedTools),I(ve.metadata.color??"#6b7280"),V(ve.prompt),J(""),C(null),S(!1),y("edit")},ne=(ve,re)=>{ee(ve),C(re),S(!0),y("edit")};L.useEffect(()=>{e&&(u(),Te("/api/tools").then(ve=>ve.json()).then(ve=>{const re=ve.tools||[];P(new Set(re.filter(_e=>_e.alwaysAllowed).map(_e=>_e.name))),B(re.filter(_e=>!_e.alwaysAllowed))}).catch(()=>{B([]),P(new Set)}),n?s.some(re=>re.id===n)?d(n).then(re=>{re&&X(re,n)}):c(n).then(re=>{re&&(ee(re),C(n),S(!1),y("edit"))}):(y("list"),C(null),S(!1)))},[e,u,c,d,n]);const Y=async ve=>{if(s.some(_e=>_e.id===ve)){const _e=await d(ve);if(!_e)return;ne(_e,ve)}else{const _e=await c(ve);if(!_e)return;ne(_e,ve)}},F=async ve=>{const re=await d(ve);re&&X(re,ve)},te=()=>{C(null),_(""),j(""),R(""),D(!0),q(["read_file"]),I("#6b7280"),V(""),J(""),S(!1),y("edit")},se=async ve=>{const re=await c(ve);re&&(ee(re),C(ve),S(!1),y("edit"))},xe=async ve=>{await m(ve)},le=async()=>{const ve=w??E;if(!ve||!v||!U){J("Name and prompt are required.");return}H(!0),J("");const re={metadata:{id:ve,name:v,description:T,subagent:A,allowedTools:$.filter(He=>!W.has(He)),color:G},prompt:U},_e=w?await p(w,re):await f(re);if(H(!1),!_e.success){J(_e.error??"Failed to save agent.");return}n?t():y("list")},Ee=()=>{n?t():(y("list"),S(!1))},ue=ve=>{_(ve),w||j(S8(ve))},ae=s.filter(ve=>ve.subagent),de=s.filter(ve=>!ve.subagent),oe=a.filter(ve=>ve.subagent),Ne=a.filter(ve=>!ve.subagent);return x==="edit"?o.jsx(jt,{isOpen:e,onClose:Ee,title:b?`${v}`:w?"Edit Agent":"New Agent",size:"xl",children:o.jsx(v8,{formName:v,formId:E,formDescription:T,formSubagent:A,formTools:$,formColor:G,formPrompt:U,formError:z,saving:Z,isReadOnly:b,availableTools:O,onNameChange:ue,onIdChange:j,onDescriptionChange:R,onSubagentChange:ve=>{D(ve),ve&&q(re=>re.filter(_e=>{var He;return!((He=O.find(et=>et.name===_e))!=null&&He.topLevelOnly)}))},onToolsChange:q,onColorChange:I,onPromptChange:V,onSave:le,onCancel:Ee,onDuplicate:()=>{_(v+" (copy)"),j(`${w}-copy-${Date.now()}`),C(null),S(!1)}})}):o.jsx(jt,{isOpen:e,onClose:t,title:"Agents",size:"lg",children:o.jsx($S,{description:"Agents define behavior, tools, and prompts for top-level modes and sub-agents.",onNew:te,loading:l,hasItems:s.length>0||a.length>0,children:o.jsxs("div",{className:"space-y-4",children:[s.length>0&&o.jsx(lS,{title:"Built-in",agents:de,subagents:ae,isBuiltIn:!0,alwaysAllowedNames:W,onView:Y,onDuplicate:F}),a.length>0&&o.jsx(lS,{title:"Custom",agents:Ne,subagents:oe,isBuiltIn:!1,alwaysAllowedNames:W,onView:Y,onDuplicate:F,onEdit:se,onDelete:xe})]})})})}function C8(){const e=De(v=>{var _;return(_=v.currentSession)==null?void 0:_.mode}),t=De(v=>v.switchMode),n=mt(v=>v.defaults),s=mt(v=>v.userItems),a=mt(v=>v.fetchAgents),l=[...n,...s],[u,c]=L.useState(!1),[d,f]=L.useState(!1),[p,m]=L.useState(null),x=L.useRef(null);L.useEffect(()=>{a()},[a]),L.useEffect(()=>{function v(_){x.current&&!x.current.contains(_.target)&&c(!1)}return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[]);const y=jp();if(!e)return null;const w=l.filter(v=>!v.subagent),C=w.find(v=>v.id===e),b=(C==null?void 0:C.name)??e,S=gl(l,e);return o.jsxs("div",{className:"relative",ref:x,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:b}),o.jsx(On,{className:`w-3 h-3 text-text-muted transition-transform ${u?"rotate-180":""}`})]}),u&&w.length>0&&o.jsxs("div",{className:"absolute bottom-full left-0 mb-1 w-56 bg-bg-secondary border border-border rounded-lg shadow-lg overflow-hidden z-50",children:[w.map((v,_)=>{const E=v.id===e,j=gl(l,v.id),T=y.agentSwitching[_],R=T?MS(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(v.id),c(!1)},className:"flex-1 text-left flex items-center gap-2 min-w-0",children:[o.jsx("span",{className:"font-medium truncate",style:{color:j},children:v.name}),E&&o.jsx(Mr,{className:"w-3.5 h-3.5 text-text-muted shrink-0"})]}),R&&o.jsx("span",{className:"shrink-0 px-1.5 py-0.5 text-[10px] bg-bg-tertiary text-text-muted rounded",children:R})]},v.id)}),o.jsx("div",{className:"border-t border-border p-1",children:o.jsx("button",{type:"button",onClick:()=>{c(!1),f(!0)},className:"w-full text-left px-3 py-1.5 rounded text-sm text-text-muted hover:text-text-primary hover:bg-bg-tertiary transition-colors",children:"Manage Agents..."})})]}),o.jsx(w8,{isOpen:d,onClose:()=>{f(!1),m(null)},initialEditId:p})]})}function k8(){const e=De(s=>s.currentSession),t=De(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 cS({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 E8=[8080,11434,8e3,1234];function j8({model:e,modelConfigs:t,autoConfigState:n,testResults:s,onUpdateConfig:a,onRunAutoConfig:l,onTestParams:u,onShowRaw:c}){var d,f,p,m,x,y,w,C,b,S,v,_,E,j,T,R,A,D,$,q,G,I,U,V,z,J,Z,H,O,B,W,P,ee,X,ne,Y,F,te,se,xe,le;return o.jsxs("div",{className:"px-4 pb-4 border-t border-border pt-3 space-y-3",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("button",{onClick:()=>l(e.id),disabled:n.progress[e.id]==="probing",className:"px-4 py-2 bg-accent-primary text-text-primary rounded-lg text-sm font-medium hover:bg-accent-primary/90 disabled:opacity-50 transition-colors",children:n.progress[e.id]==="probing"?"Probing...":"Auto-config"}),n.progress[e.id]==="done"&&o.jsx("span",{className:"text-sm text-accent-success font-medium",children:"Configured ✓"}),n.progress[e.id]==="error"&&o.jsx("span",{className:"text-sm text-red-500 font-medium",children:"Failed ✗"})]}),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:((d=t[e.id])==null?void 0:d.contextWindow)??e.contextWindow,onChange:Ee=>a(e.id,{contextWindow:parseInt(Ee.target.value)||e.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:((f=t[e.id])==null?void 0:f.supportsVision)??!1,onChange:Ee=>a(e.id,{supportsVision:Ee.target.checked}),className:"accent-accent-primary"})," ","Supports vision"]})]}),o.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("button",{onClick:()=>u(e.id,"thinking"),disabled:(p=s[e.id+"-thinking"])==null?void 0:p.loading,className:"px-3 py-1.5 bg-bg-tertiary border border-border rounded text-xs font-medium hover:bg-bg-secondary disabled:opacity-50 transition-colors",children:(m=s[e.id+"-thinking"])!=null&&m.loading?"Testing...":"Test thinking"}),((x=s[e.id+"-thinking"])==null?void 0:x.result)&&o.jsx("span",{className:"text-xs text-accent-success",children:"OK"}),((y=s[e.id+"-thinking"])==null?void 0:y.error)&&o.jsx("span",{className:"text-xs text-red-500",title:(w=s[e.id+"-thinking"])==null?void 0:w.error,children:"Fail"}),((C=s[e.id+"-thinking"])==null?void 0:C.result)&&o.jsx("button",{onClick:()=>c(s[e.id+"-thinking"].result),className:"text-xs text-accent-primary hover:underline",children:"raw"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("button",{onClick:()=>u(e.id,"non-thinking"),disabled:(b=s[e.id+"-non-thinking"])==null?void 0:b.loading,className:"px-3 py-1.5 bg-bg-tertiary border border-border rounded text-xs font-medium hover:bg-bg-secondary disabled:opacity-50 transition-colors",children:(S=s[e.id+"-non-thinking"])!=null&&S.loading?"Testing...":"Test non-thinking"}),((v=s[e.id+"-non-thinking"])==null?void 0:v.result)&&o.jsx("span",{className:"text-xs text-accent-success",children:"OK"}),((_=s[e.id+"-non-thinking"])==null?void 0:_.error)&&o.jsx("span",{className:"text-xs text-red-500",title:(E=s[e.id+"-non-thinking"])==null?void 0:E.error,children:"Fail"}),((j=s[e.id+"-non-thinking"])==null?void 0:j.result)&&o.jsx("button",{onClick:()=>c(s[e.id+"-non-thinking"].result),className:"text-xs text-accent-primary hover:underline",children:"raw"})]})]}),o.jsxs("details",{className:"group",children:[o.jsxs("summary",{className:"text-xs text-text-muted cursor-pointer hover:text-text-secondary list-none flex items-center gap-1 select-none",children:[o.jsx(On,{className:"w-3 h-3 transition-transform group-open:rotate-180"}),"Advanced: thinking & non-thinking params"]}),o.jsxs("div",{className:"mt-3 space-y-2",children:[o.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:((T=t[e.id])==null?void 0:T.thinkingEnabled)??!1,onChange:Ee=>a(e.id,{thinkingEnabled:Ee.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"})]}),((R=t[e.id])==null?void 0:R.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:((A=t[e.id])==null?void 0:A.thinkingLevel)??"",onChange:Ee=>a(e.id,{thinkingLevel:Ee.target.value}),className:"w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-xs text-text-primary"})]}),o.jsx(cS,{value:(D=t[e.id])==null?void 0:D.thinkingQueryParams,onChange:Ee=>a(e.id,{thinkingQueryParams:Ee})})]}),o.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:(($=t[e.id])==null?void 0:$.nonThinkingEnabled)??!1,onChange:Ee=>a(e.id,{nonThinkingEnabled:Ee.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"})]}),((q=t[e.id])==null?void 0:q.nonThinkingEnabled)&&o.jsx("div",{className:"ml-6 space-y-2 pl-3 border-l-2 border-accent-warning/30",children:o.jsx(cS,{value:(G=t[e.id])==null?void 0:G.nonThinkingQueryParams,onChange:Ee=>a(e.id,{nonThinkingQueryParams:Ee})})})]}),o.jsxs("div",{className:"border-t border-border pt-3 mt-3",children:[o.jsx("p",{className:"text-xs text-text-muted mb-2",children:"Sampling parameters"}),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:((I=t[e.id])==null?void 0:I.temperature)??"",onChange:Ee=>a(e.id,{temperature:Ee.target.value?parseFloat(Ee.target.value):void 0}),placeholder:((V=(U=t[e.id])==null?void 0:U.defaultTemperature)==null?void 0:V.toString())??"Using default",className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary"}),((z=t[e.id])==null?void 0:z.defaultTemperature)!==void 0&&o.jsxs("p",{className:"text-xs text-text-muted mt-0.5",children:["default: ",(J=t[e.id])==null?void 0:J.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:((Z=t[e.id])==null?void 0:Z.topP)??"",onChange:Ee=>a(e.id,{topP:Ee.target.value?parseFloat(Ee.target.value):void 0}),placeholder:((O=(H=t[e.id])==null?void 0:H.defaultTopP)==null?void 0:O.toString())??"Using default",className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary"}),((B=t[e.id])==null?void 0:B.defaultTopP)!==void 0&&o.jsxs("p",{className:"text-xs text-text-muted mt-0.5",children:["default: ",(W=t[e.id])==null?void 0:W.defaultTopP]})]})]}),o.jsxs("div",{className:"grid grid-cols-2 gap-2 mt-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:((P=t[e.id])==null?void 0:P.topK)??"",onChange:Ee=>a(e.id,{topK:Ee.target.value?parseInt(Ee.target.value):void 0}),placeholder:((X=(ee=t[e.id])==null?void 0:ee.defaultTopK)==null?void 0:X.toString())??"Using default",className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary"}),((ne=t[e.id])==null?void 0:ne.defaultTopK)!==void 0&&o.jsxs("p",{className:"text-xs text-text-muted mt-0.5",children:["default: ",(Y=t[e.id])==null?void 0:Y.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:((F=t[e.id])==null?void 0:F.maxTokens)??"",onChange:Ee=>a(e.id,{maxTokens:Ee.target.value?parseInt(Ee.target.value):void 0}),placeholder:((se=(te=t[e.id])==null?void 0:te.defaultMaxTokens)==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"}),((xe=t[e.id])==null?void 0:xe.defaultMaxTokens)!==void 0&&o.jsxs("p",{className:"text-xs text-text-muted mt-0.5",children:["default: ",(le=t[e.id])==null?void 0:le.defaultMaxTokens]})]})]})]})]})]})}function rk({isOpen:e,onClose:t,onSave:n,initialStep:s=1,editProvider:a,editModelId:l}){const[u,c]=L.useState(s),[d,f]=L.useState(""),[p,m]=L.useState(""),[x,y]=L.useState("unknown"),[w,C]=L.useState(""),[b,S]=L.useState(!1),[v,_]=L.useState(!1),[E,j]=L.useState(null),[T,R]=L.useState([]),[A,D]=L.useState(null),[$,q]=L.useState(!1),[G,I]=L.useState(""),[U,V]=L.useState({}),[z,J]=L.useState({loading:!1,progress:{}}),[Z,H]=L.useState({}),[O,B]=L.useState(null),[W,P]=L.useState(new Set),[ee,X]=L.useState(""),ne=L.useRef(null);L.useEffect(()=>{u===1&&e&&requestAnimationFrame(()=>{var ue;return(ue=ne.current)==null?void 0:ue.focus()})},[u,e]);function Y(ue,ae){V(de=>({...de,[ue]:{...de[ue],...ae}}))}function F(ue){if(!ue.trim())return T;const ae=ue.toLowerCase().split(/\s+/).filter(Boolean);return T.filter(de=>ae.every(oe=>de.id.toLowerCase().includes(oe)))}L.useEffect(()=>{var ue,ae;if(e)if(c(s),f((a==null?void 0:a.name)??""),m((a==null?void 0:a.url)??""),y((a==null?void 0:a.backend)??"unknown"),C((a==null?void 0:a.apiKey)??""),S((a==null?void 0:a.isLocal)??!1),j(null),I((a==null?void 0:a.thinkingField)??""),H({}),B(null),(ue=a==null?void 0:a.models)!=null&&ue.length){const de={},oe=new Set;for(const Ne of a.models)de[Ne.id]={contextWindow:Ne.contextWindow,supportsVision:Ne.supportsVision,thinkingEnabled:Ne.thinkingEnabled,thinkingLevel:Ne.thinkingLevel,nonThinkingEnabled:Ne.nonThinkingEnabled,thinkingQueryParams:Ne.thinkingQueryParams,nonThinkingQueryParams:Ne.nonThinkingQueryParams,defaultTemperature:Ne.defaultTemperature,defaultTopP:Ne.defaultTopP,defaultTopK:Ne.defaultTopK,defaultMaxTokens:Ne.defaultMaxTokens},Ne.selected&&oe.add(Ne.id);if(oe.size===0)for(const Ne of a.models)oe.add(Ne.id);P(oe),V(de),R(a.models.map(Ne=>({id:Ne.id,contextWindow:Ne.contextWindow}))),D(l??((ae=a.models[0])==null?void 0:ae.id)??null)}else R([]),V({}),D(null),P(new Set)},[e,s,a==null?void 0:a.id,l]),L.useEffect(()=>{u===2&&p&&T.length===0&&!v&&!E&&te(p)},[u]);async function te(ue){var ae,de;_(!0),j(null),R([]);try{const oe=new URLSearchParams({url:ue});w&&oe.set("apiKey",w),x&&oe.set("backend",x);const Ne=await Te(`/api/providers/models?${oe.toString()}`);if(Ne.ok){const ve=await Ne.json();if((ae=ve.models)!=null&&ae.length){R(ve.models),D(((de=ve.models[0])==null?void 0:de.id)??null);const re={};for(const _e of ve.models)re[_e.id]={contextWindow:_e.contextWindow,thinkingEnabled:!0,thinkingLevel:void 0,defaultTemperature:_e.defaultTemperature,defaultTopP:_e.defaultTopP,defaultTopK:_e.defaultTopK,defaultMaxTokens:_e.defaultMaxTokens};V(re),ve.models.length===1&&(P(new Set([ve.models[0].id])),D(ve.models[0].id),se(ve.models[0].id))}}else{const ve=await Ne.json();j(ve.error??`Failed to fetch models from ${ue}`)}}catch(oe){j(`Failed to fetch models from ${ue}: ${oe instanceof Error?oe.message:"Unknown error"}`)}_(!1)}async function se(ue){J(ae=>({loading:!0,progress:{...ae.progress,[ue]:"probing"}}));try{const ae=await Te("/api/providers/auto-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:p,apiKey:w||void 0,backend:x||"unknown",models:[{id:ue}]})});if(!ae.ok){const oe=await ae.json();throw new Error(oe.error??"Auto-config failed")}const de=await ae.json();for(const oe of de.models){const Ne={};oe.contextSource!=="default"&&(Ne.contextWindow=oe.contextWindow,Ne.supportsVision=oe.supportsVision),oe.thinkingConfig&&(Ne.thinkingEnabled=!0,Ne.thinkingQueryParams=JSON.stringify(oe.thinkingConfig)),oe.nonThinkingConfig&&(Ne.nonThinkingEnabled=!0,Ne.nonThinkingQueryParams=JSON.stringify(oe.nonThinkingConfig)),Y(oe.id,Ne),J(ve=>({...ve,progress:{...ve.progress,[oe.id]:"done"}}))}}catch(ae){console.error("Auto-config error:",ae),J(de=>({...de,progress:{...de.progress,[ue]:"error"}}))}finally{J(ae=>({...ae,loading:!1}))}}async function xe(ue,ae){const de=ue+"-"+ae;H(oe=>({...oe,[de]:{loading:!0}}));try{const oe=U[ue],Ne=await Te("/api/providers/test-params",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:p,model:ue,apiKey:w||void 0,backend:x||"unknown",thinkingField:G||void 0,mode:ae,modelConfig:{temperature:oe==null?void 0:oe.temperature,topP:oe==null?void 0:oe.topP,topK:oe==null?void 0:oe.topK,maxTokens:oe==null?void 0:oe.maxTokens,supportsVision:oe==null?void 0:oe.supportsVision,thinkingEnabled:oe==null?void 0:oe.thinkingEnabled,thinkingLevel:oe==null?void 0:oe.thinkingLevel,nonThinkingEnabled:oe==null?void 0:oe.nonThinkingEnabled,thinkingQueryParams:oe==null?void 0:oe.thinkingQueryParams,nonThinkingQueryParams:oe==null?void 0:oe.nonThinkingQueryParams}})}),ve=await Ne.json();Ne.ok?H(re=>({...re,[de]:{loading:!1,result:JSON.stringify(ve,null,2),message:ve.message}})):H(re=>({...re,[de]:{loading:!1,error:ve.error??"Test failed"}}))}catch(oe){H(Ne=>({...Ne,[de]:{loading:!1,error:oe instanceof Error?oe.message:"Request failed"}}))}}function le(){R([]),V({}),J({loading:!1,progress:{}}),H({}),B(null),P(new Set),X("")}function Ee(){const ue=d||"Provider",ae=(a==null?void 0:a.id)??`temp-${Date.now()}`;n({id:ae,name:ue,url:p,backend:x||"unknown",apiKey:w||void 0,isLocal:b||void 0,thinkingField:G||void 0,models:T.map(de=>{var oe,Ne,ve,re,_e,He,et,rt,kt,ye,Ae;return{id:de.id,contextWindow:((oe=U[de.id])==null?void 0:oe.contextWindow)??de.contextWindow,selected:W.has(de.id)||void 0,supportsVision:(Ne=U[de.id])==null?void 0:Ne.supportsVision,thinkingEnabled:(ve=U[de.id])==null?void 0:ve.thinkingEnabled,thinkingLevel:(re=U[de.id])==null?void 0:re.thinkingLevel,nonThinkingEnabled:(_e=U[de.id])==null?void 0:_e.nonThinkingEnabled,thinkingQueryParams:(He=U[de.id])==null?void 0:He.thinkingQueryParams,nonThinkingQueryParams:(et=U[de.id])==null?void 0:et.nonThinkingQueryParams,temperature:(rt=U[de.id])==null?void 0:rt.temperature,topP:(kt=U[de.id])==null?void 0:kt.topP,topK:(ye=U[de.id])==null?void 0:ye.topK,maxTokens:(Ae=U[de.id])==null?void 0:Ae.maxTokens}})}),t()}return e?o.jsxs("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",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].map(ue=>o.jsx("div",{className:`h-1 flex-1 rounded-full transition-colors ${ue<u?"bg-accent-success":ue===u?"bg-accent-primary":"bg-border"}`},ue))}),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:"Inference engine"}),o.jsxs("div",{className:"grid grid-cols-5 gap-2",children:[o.jsx("button",{type:"button",onClick:()=>{y("unknown"),S(!1),j(null)},className:`p-2 rounded border text-center text-sm transition-colors ${x==="unknown"?"border-accent-primary bg-accent-primary/10 text-accent-primary":"border-border hover:border-text-muted text-text-secondary"}`,children:"Other"},"other"),E8.map(ue=>{const ae={8e3:"vllm",11434:"ollama",8080:"llamacpp",1234:"lmstudio"},de={8e3:"vLLM",11434:"Ollama",8080:"llama.cpp",1234:"LM Studio"};return o.jsx("button",{type:"button",onClick:()=>{f(oe=>oe||(de[ue]??"")),m(oe=>oe||`http://localhost:${ue}`),y(ae[ue]??""),S(!0),j(null)},className:`p-2 rounded border text-center text-sm transition-colors ${x===ae[ue]?"border-accent-primary bg-accent-primary/10 text-accent-primary":"border-border hover:border-text-muted text-text-secondary"}`,children:de[ue]??`localhost:${ue}`},ue)})]})]}),o.jsxs("div",{children:[o.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Provider URL"}),o.jsx("input",{ref:ne,type:"text",value:p,"data-testid":"provider-modal-url",onChange:ue=>{m(ue.target.value),j(null),R([]),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:ue=>f(ue.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:ue=>C(ue.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:b,onChange:ue=>S(ue.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:[v&&o.jsxs("div",{className:"flex items-center gap-2 text-sm text-text-muted",children:[o.jsx("span",{className:"w-4 h-4 border-2 border-accent-primary border-t-transparent rounded-full animate-spin"}),"Fetching models..."]}),E&&o.jsxs("div",{className:"p-3 rounded-lg text-sm bg-red-500/10 text-red-500 border border-red-500/20",children:[o.jsx("p",{children:E}),o.jsxs("p",{className:"text-xs text-text-muted mt-1",children:["URL: ",p]}),o.jsxs("div",{className:"flex gap-2 mt-2",children:[o.jsx("button",{onClick:()=>te(p),className:"text-xs text-accent-primary hover:underline",children:"Retry"}),o.jsx("button",{onClick:()=>{le(),c(1)},className:"text-xs text-accent-primary hover:underline",children:"Edit URL"})]})]}),T.length>0&&x&&o.jsxs(o.Fragment,{children:[W.size>0&&o.jsxs("div",{className:"mb-4",children:[o.jsxs("h4",{className:"text-sm font-medium text-text-primary mb-1",children:["Selected Models (",W.size,")"]}),o.jsx("p",{className:"text-xs text-text-muted mb-2",children:"Only selected models will appear in the model selector."}),o.jsx("div",{className:"space-y-2",children:T.filter(ue=>W.has(ue.id)).map(ue=>{var ae;return o.jsxs("div",{className:"bg-bg-primary border border-border rounded-lg overflow-hidden",children:[o.jsxs("div",{onClick:()=>D(A===ue.id?null:ue.id),className:"w-full flex items-center justify-between px-4 py-3 hover:bg-bg-tertiary transition-colors cursor-pointer",children:[o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("span",{className:"text-sm font-medium text-text-primary",children:ue.id.split("/").pop()}),o.jsxs("span",{className:"text-xs text-text-muted bg-bg-tertiary px-2 py-0.5 rounded",children:[(((ae=U[ue.id])==null?void 0:ae.contextWindow)??ue.contextWindow).toLocaleString()," ctx"]})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[z.progress[ue.id]==="probing"?o.jsx("span",{className:"w-3 h-3 border-2 border-accent-primary border-t-transparent rounded-full animate-spin"}):z.progress[ue.id]==="done"?o.jsx("span",{className:"text-xs text-accent-success font-medium",children:"Configured ✓"}):z.progress[ue.id]==="error"?o.jsx("span",{className:"text-xs text-red-500 font-medium",children:"Failed ✗"}):o.jsx("button",{onClick:de=>{de.stopPropagation(),se(ue.id)},className:"text-xs text-accent-primary hover:underline",children:"Auto-config"}),T.length>1&&o.jsx("button",{onClick:de=>{de.stopPropagation();const oe=new Set(W);oe.delete(ue.id),P(oe),A===ue.id&&D(null)},className:"text-xs text-red-500 hover:text-red-400 px-2 py-1 rounded hover:bg-red-500/10",children:"Remove"}),o.jsx(On,{className:`w-4 h-4 text-text-muted transition-transform ${A===ue.id?"rotate-180":""}`})]})]}),A===ue.id&&o.jsx(j8,{model:ue,modelConfigs:U,autoConfigState:z,testResults:Z,onUpdateConfig:Y,onRunAutoConfig:se,onTestParams:xe,onShowRaw:B})]},ue.id)})})]}),T.length>1&&o.jsxs("div",{children:[o.jsx("h4",{className:"text-sm font-medium text-text-primary mb-1",children:"Available Models"}),W.size===0&&o.jsx("p",{className:"text-xs text-text-muted mb-2",children:"This provider has many models available. Select the ones you want to use below."}),o.jsxs("div",{className:"relative mb-2",children:[o.jsx("input",{type:"text",value:ee,onChange:ue=>X(ue.target.value),placeholder:"Search models...",className:"w-full px-4 py-2 bg-bg-primary border border-border rounded-lg text-sm text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"}),ee&&o.jsx("button",{onClick:()=>X(""),className:"absolute right-3 top-1/2 -translate-y-1/2 text-text-muted hover:text-text-primary text-sm",children:"×"})]}),o.jsxs("div",{className:"flex items-center justify-between mb-2",children:[o.jsxs("p",{className:"text-xs text-text-muted",children:["Showing ",F(ee).length," of ",T.length," models"]}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx("button",{onClick:()=>{const ue=new Set(W),ae=F(ee);for(const de of ae)ue.add(de.id);P(ue);for(const de of ae)z.progress[de.id]!=="probing"&&z.progress[de.id]!=="done"&&se(de.id)},className:"text-xs text-accent-primary hover:underline",children:"Select all"}),o.jsx("button",{onClick:()=>{const ue=new Set(W),ae=F(ee);for(const de of ae)ue.delete(de.id);P(ue)},className:"text-xs text-text-muted hover:text-text-secondary",children:"Deselect all"})]})]}),o.jsxs("div",{className:"space-y-1 max-h-48 overflow-y-auto border border-border rounded-lg bg-bg-primary",children:[F(ee).map(ue=>{var de;const ae=W.has(ue.id);return o.jsxs("div",{role:"checkbox","aria-checked":ae,tabIndex:0,className:`flex items-center gap-3 px-4 py-2 hover:bg-bg-tertiary transition-colors cursor-pointer ${ae?"bg-accent-primary/5":""}`,onClick:()=>{if(ae){const oe=new Set(W);oe.delete(ue.id),P(oe)}else{const oe=new Set(W);oe.add(ue.id),P(oe),se(ue.id)}},onKeyDown:oe=>{(oe.key==="Enter"||oe.key===" ")&&(oe.preventDefault(),oe.currentTarget.click())},children:[o.jsx("input",{type:"checkbox",checked:ae,onChange:()=>{},className:"w-4 h-4 rounded border-border accent-accent-primary pointer-events-none"}),o.jsx("span",{className:"text-sm text-text-primary flex-1 truncate",children:ue.id.split("/").pop()}),o.jsxs("span",{className:"text-xs text-text-muted flex-shrink-0",children:[(((de=U[ue.id])==null?void 0:de.contextWindow)??ue.contextWindow).toLocaleString()," ctx"]}),z.progress[ue.id]==="probing"&&o.jsx("span",{className:"w-3 h-3 border-2 border-accent-primary border-t-transparent rounded-full animate-spin flex-shrink-0"}),z.progress[ue.id]==="done"&&o.jsx("span",{className:"text-xs text-accent-success flex-shrink-0",children:"✓"}),z.progress[ue.id]==="error"&&o.jsx("span",{className:"text-xs text-red-500 flex-shrink-0",children:"✗"})]},ue.id)}),F(ee).length===0&&o.jsxs("div",{className:"px-4 py-6 text-center text-sm text-text-muted",children:["No models match “",ee,"”"]})]})]})]})]}),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:()=>{u===2&&le(),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===1?o.jsx("button",{onClick:()=>c(2),disabled:!p,"data-testid":"provider-modal-next",className:"px-5 py-2 bg-accent-primary text-text-primary rounded-lg text-sm font-medium hover:bg-accent-primary/90 disabled:opacity-50 transition-colors",children:"Next — Test & Configure"}):o.jsx("button",{onClick:Ee,disabled:z.loading,"data-testid":"provider-modal-save",className:"px-5 py-2 bg-accent-primary text-text-primary rounded-lg text-sm font-medium hover:bg-accent-primary/90 disabled:opacity-50 transition-colors",children:z.loading?"Configuring...":"Save Provider"})]})]})]}),$&&o.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[60]",onClick:ue=>{ue.target===ue.currentTarget&&q(!1)},children:o.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl w-[480px] shadow-2xl",children:[o.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border",children:[o.jsx("h3",{className:"text-base font-semibold text-text-primary",children:"Provider-Level Defaults"}),o.jsx("button",{onClick:()=>q(!1),className:"text-text-muted hover:text-text-primary text-xl leading-none p-1",children:"×"})]}),o.jsxs("div",{className:"px-6 py-4 space-y-4",children:[o.jsx("p",{className:"text-xs text-text-muted",children:"These apply to all models unless overridden per-model."}),o.jsxs("div",{children:[o.jsx("label",{className:"text-xs text-text-secondary block mb-1",children:"Non-thinking mode params"}),o.jsx("input",{type:"text",defaultValue:'{"chat_template_kwargs":{"enable_thinking":false}}',readOnly:!0,className:"w-full px-3 py-2 bg-bg-primary border border-border rounded text-sm text-text-secondary font-mono"})]}),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:G,onChange:ue=>I(ue.target.value),placeholder:"Leave blank for auto-detect",className:"w-full px-3 py-2 bg-bg-primary border border-border rounded text-sm text-text-primary font-mono"}),o.jsx("p",{className:"text-xs text-text-muted mt-1",children:"Field name the backend uses for reasoning/thinking content (e.g. reasoning, reasoning_content, thinking)."})]})]}),o.jsx("div",{className:"flex justify-end px-6 py-4 border-t border-border",children:o.jsx("button",{onClick:()=>q(!1),className:"px-5 py-2 bg-accent-primary text-text-primary rounded-lg text-sm font-medium hover:bg-accent-primary/90 transition-colors",children:"Done"})})]})}),O&&o.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[60]",onClick:ue=>{ue.target===ue.currentTarget&&B(null)},children:o.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl w-[640px] max-h-[80vh] shadow-2xl flex flex-col",children:[o.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border shrink-0",children:[o.jsx("h3",{className:"text-base font-semibold text-text-primary",children:"Raw Response"}),o.jsx("button",{onClick:()=>B(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 break-all",children:O})]})})]}):null}function N8(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(0)}K`:`${e}`}function T8(){var ue;const[,e]=Yn(),t=De(ae=>ae.currentSession),n=De(ae=>ae.setSessionProvider),[s,a]=L.useState(!1),[l,u]=L.useState([]),[c,d]=L.useState(null),f=L.useRef(null),[p,m]=L.useState(null),[x,y]=L.useState(!1),w=L.useRef(new Set),C=nn(ae=>ae.providers),b=nn(ae=>ae.activeProviderId),S=nn(ae=>ae.defaultModelSelection),v=nn(ae=>ae.activating),_=nn(ae=>ae.activateProvider),E=nn(ae=>ae.refreshModel),j=nn(ae=>ae.refreshProviderModels),T=nn(ae=>ae.setDefaultModel),R=(t==null?void 0:t.providerId)??null,A=(t==null?void 0:t.providerModel)??null,D=(S==null?void 0:S.split("/")[0])??null,$=(S==null?void 0:S.split("/").slice(1).join("/"))??null,q=R??D,G=A??$,I=G?((ue=G.split("/").pop())==null?void 0:ue.replace(/-/g," "))??G:"No model",V=!!(t&&A)&&A!==$,[z,J]=L.useState(!1);L.useEffect(()=>{function ae(de){f.current&&!f.current.contains(de.target)&&(a(!1),u([]),w.current=new Set)}return document.addEventListener("mousedown",ae),()=>document.removeEventListener("mousedown",ae)},[]),L.useEffect(()=>{if(s){const ae=C.map(de=>de.id);u(ae),ae.forEach(de=>{w.current.has(de)||(w.current.add(de),W(de))})}},[s,C]);const Z=C.find(ae=>ae.id===q),H=(Z==null?void 0:Z.status)==="disconnected",O=(ae,de)=>t?t.providerId===ae&&t.providerModel===de:!1,B=(ae,de)=>S?S===`${ae}/${de}`:!1,W=async ae=>{d(ae);try{await j(ae)}catch{}finally{d(null)}},P=ae=>{l.includes(ae.id)?u(l.filter(de=>de!==ae.id)):(u([...l,ae.id]),W(ae.id))},ee=async ae=>{if(ae.id===b){P(ae);return}t?(n(ae.id,void 0),a(!1),u([])):await _(ae.id)&&(a(!1),u([]))},X=ae=>{P(ae)},ne=async(ae,de)=>{ae.stopPropagation(),w.current.delete(de),await W(de)},Y=(ae,de)=>{m({providerId:ae,model:de}),y(!0)},F=p?C.find(ae=>ae.id===p.providerId):void 0,te=()=>{m(null),y(!1)},se=async ae=>{try{if(!(await Te(`/api/providers/${ae.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:ae.name,url:ae.url,backend:ae.backend,apiKey:ae.apiKey,isLocal:ae.isLocal,thinkingField:ae.thinkingField,models:ae.models})})).ok)throw new Error("Failed to update provider");await nn.getState().fetchConfig()}catch{}m(null),y(!1)},xe=async(ae,de)=>{if(t){De.setState(Ne=>({currentSession:Ne.currentSession?{...Ne.currentSession,providerId:ae,providerModel:de}:null})),n(ae,de),u([]),a(!1);return}await _(ae)&&(u([]),a(!1))},le=async(ae,de,oe)=>{ae.stopPropagation(),J(!0);try{await T(de,oe)}catch{}finally{J(!1)}};function Ee(ae){return ae.models.some(oe=>oe.selected)?ae.models.filter(oe=>oe.selected):ae.models}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:H?"LLM server is offline. Click to retry.":I??"Click to refresh model",children:[H?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:I}),o.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded-full ${Z!=null&&Z.isLocal?"text-accent-success bg-accent-success/10":"text-accent-warning bg-accent-warning/10"}`,children:Z!=null&&Z.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:[H?o.jsx("span",{className:"text-sm text-accent-error animate-pulse",children:"offline"}):o.jsxs(o.Fragment,{children:[o.jsx("span",{className:`text-sm ${V?"text-accent-primary italic":"text-accent-primary"}`,children:I}),V&&o.jsx("span",{className:"text-xs text-text-muted ml-0.5",title:"Session-scoped model (different from default)",children:"•"}),o.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded-full ${Z!=null&&Z.isLocal?"text-accent-success bg-accent-success/10":"text-accent-warning bg-accent-warning/10"}`,children:Z!=null&&Z.isLocal?"local":"api"})]}),o.jsx(On,{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(ae=>{var de;return o.jsxs("div",{children:[o.jsxs("div",{className:`px-3 py-2 flex items-center justify-between ${ae.id===q?"bg-bg-tertiary":"hover:bg-bg-tertiary"} ${v?"opacity-50 cursor-wait":"cursor-pointer"}`,children:[o.jsxs("div",{onClick:()=>!v&&ee(ae),className:"flex flex-col min-w-0 flex-1 cursor-pointer",children:[o.jsx("span",{className:`text-sm font-medium truncate ${ae.id===q?"text-accent-primary":"text-text-primary"}`,children:ae.name}),o.jsx("span",{className:"text-xs text-text-muted truncate",children:ae.backend!=="unknown"&&vS(ae.backend)})]}),o.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[ae.id===q?o.jsx("span",{className:"text-accent-success",title:"Active provider",children:o.jsx(Mr,{className:"w-4 h-4"})}):o.jsx("span",{className:"w-4"}),o.jsx("button",{type:"button",onClick:oe=>{oe.stopPropagation(),ne(oe,ae.id)},className:"p-0.5 hover:bg-bg-tertiary rounded transition-colors",title:"Refresh models",children:o.jsx(Ep,{className:`w-4 h-4 ${c===ae.id?"animate-spin":""} ${ae.id===b?"text-accent-primary":"text-text-muted"}`})}),o.jsx("button",{type:"button",onClick:oe=>{oe.stopPropagation(),X(ae)},className:"p-0.5 hover:bg-bg-tertiary rounded transition-colors",title:"Show models",children:o.jsx(On,{className:`w-4 h-4 transition-transform ${l.includes(ae.id)?"rotate-180":""} ${ae.id===b?"text-accent-primary":"text-text-muted"}`})})]})]}),l.includes(ae.id)&&o.jsx("div",{className:"bg-bg-primary border-t border-border max-h-40 overflow-y-auto",children:c===ae.id?o.jsx("div",{className:"px-4 py-2 text-xs text-text-muted",children:"Loading models..."}):(de=ae.models)!=null&&de.length?Ee(ae).map(oe=>{var re;const Ne=O(ae.id,oe.id),ve=B(ae.id,oe.id);return o.jsxs("div",{className:`flex items-center px-4 py-1.5 text-sm hover:bg-bg-tertiary transition-colors group ${c==="activating"?"opacity-50 cursor-wait":""} ${Ne?"text-accent-primary":"text-text-secondary"}`,children:[o.jsx("button",{type:"button",onClick:()=>xe(ae.id,oe.id),disabled:c==="activating",className:"flex-1 truncate text-left",children:((re=oe.id.split("/").pop())==null?void 0:re.replace(/-/g," "))??oe.id}),o.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0 ml-2",children:[o.jsx("span",{className:"text-xs text-text-muted",children:N8(oe.contextWindow)}),t&&o.jsx("button",{type:"button",onClick:_e=>le(_e,ae.id,oe.id),disabled:z,className:"p-0.5 hover:bg-bg-tertiary rounded transition-colors disabled:opacity-40",title:ve?"Default model":"Set as default model",children:ve?o.jsx(RS,{className:"w-3.5 h-3.5 text-accent-warning"}):o.jsx(DS,{className:"w-3.5 h-3.5 text-text-muted hover:text-accent-warning"})}),o.jsx("button",{type:"button",onClick:_e=>{_e.stopPropagation(),Y(ae.id,oe)},className:"opacity-0 group-hover:opacity-100 p-0.5 hover:bg-bg-tertiary rounded transition-opacity",title:"Edit model context",children:o.jsx(Uj,{className:"w-3 h-3 text-text-muted"})}),Ne&&o.jsx("span",{className:"text-accent-success flex-shrink-0",title:"Session model",children:o.jsx(Mr,{className:"w-3.5 h-3.5"})})]})]},oe.id)}):o.jsx("div",{className:"px-4 py-2 text-xs text-text-muted",children:"No models available"})})]},ae.id)})}),o.jsx("div",{className:"border-t border-border px-3 py-2",children:o.jsx("button",{onClick:()=>e("/onboarding"),className:"text-xs text-accent-primary hover:underline",children:"Manage providers"})})]}),p&&x&&o.jsx(rk,{isOpen:!0,onClose:te,onSave:se,initialStep:2,editProvider:{id:p.providerId,name:(F==null?void 0:F.name)??"",url:(F==null?void 0:F.url)??"",backend:(F==null?void 0:F.backend)??"unknown",apiKey:F==null?void 0:F.apiKey,isLocal:F==null?void 0:F.isLocal,thinkingField:F==null?void 0:F.thinkingField,models:F==null?void 0:F.models},editModelId:p.model.id})]})}function A8(e,t){const n=e.slice(0,t),s=n.lastIndexOf("@");if(s===-1)return null;const a=n.slice(s+1);return a.includes(" ")||a.includes(`
|
|
298
|
+
`)||a.includes(" ")?null:{query:a,startIndex:s}}const L8=L.forwardRef(function({text:t,cursorPos:n,workdir:s,onSelect:a},l){const u=A8(t,n),[c,d]=L.useState([]),[f,p]=L.useState(!1),[m,x]=L.useState(0),y=L.useRef(null),w=L.useRef([]),C=L.useRef(0),b=L.useRef([]);L.useEffect(()=>{C.current=m},[m]),L.useEffect(()=>{b.current=c},[c]),L.useEffect(()=>{if(!u){d([]);return}const _=setTimeout(()=>{S(u.query)},150);return()=>clearTimeout(_)},[u==null?void 0:u.query,s]);const S=async _=>{p(!0);try{const E=new URLSearchParams({q:_});s&&E.set("workdir",s);const T=await(await Te(`/api/files?${E.toString()}`)).json();d(T),x(0),C.current=0}catch(E){console.error("File search failed:",E),d([])}finally{p(!1)}},v=L.useCallback(_=>{if(!u)return!1;switch(_.key){case"ArrowDown":return _.preventDefault(),x(E=>{var T;const j=Math.min(E+1,b.current.length-1);return w.current[j]&&((T=w.current[j])==null||T.scrollIntoView({block:"nearest"})),j}),C.current=Math.min(C.current+1,b.current.length-1),!0;case"ArrowUp":return _.preventDefault(),x(E=>{var T;const j=Math.max(E-1,0);return w.current[j]&&((T=w.current[j])==null||T.scrollIntoView({block:"nearest"})),j}),C.current=Math.max(C.current-1,0),!0;case"Enter":case"Tab":{const E=b.current;return E[C.current]?(_.preventDefault(),a(E[C.current],u.startIndex),!0):!1}case"Escape":return _.preventDefault(),d([]),!0}return!1},[u,a]);return L.useImperativeHandle(l,()=>({handleKeyDown:v}),[v]),L.useEffect(()=>{if(!u)return;const _=E=>{y.current&&!y.current.contains(E.target)&&d([])};return document.addEventListener("mousedown",_),()=>document.removeEventListener("mousedown",_)},[u]),u?f?o.jsx("div",{className:"absolute bottom-full left-0 right-0 mb-2 z-50",children:o.jsx("div",{className:"bg-bg-secondary border border-border rounded-lg shadow-lg",children:o.jsx("div",{className:"p-4 text-center",children:o.jsx(Di,{size:"sm"})})})}):c.length===0?null:o.jsx("div",{ref:y,className:"absolute bottom-full left-0 right-0 mb-2 z-50",children:o.jsx("div",{className:"bg-bg-secondary border border-border rounded-lg shadow-lg max-h-64 overflow-y-auto",children:o.jsx("ul",{className:"py-1",children:c.map((_,E)=>o.jsxs("li",{ref:j=>{w.current[E]=j},className:`px-3 py-2 cursor-pointer flex items-center gap-2 text-sm ${E===m?"bg-accent-primary/20 text-text-primary":"text-text-muted hover:bg-bg-tertiary"}`,onClick:()=>{u&&a(_,u.startIndex)},children:[_.type==="directory"?o.jsx(El,{className:"w-4 h-4 shrink-0"}):o.jsx("span",{className:"w-4 h-4 shrink-0"}),o.jsx("span",{className:"truncate",children:_.path})]},_.path))})})}):null});function R8({input:e,setInput:t,attachments:n,setAttachments:s,dragOver:a,setDragOver:l,errorMessage:u,setErrorMessage:c,scrollContainerRef:d,sessionId:f,sessionMode:p,showHistory:m,history:x,selectedIndex:y,openHistory:w,closeHistory:C,navigateUp:b,navigateDown:S,selectCurrent:v,isAutoScrollActive:_,setAutoScroll:E,onOpenMessageSearch:j,onOpenCommandsModal:T,onOpenWorkflowsModal:R,onSelectWorkflow:A,onSelectWorkflowWithSubGroup:D,clearInput:$}){const q=L.useRef(null),G=L.useRef(null),I=L.useRef(0),U=L.useRef(0),V=L.useRef(null),z=Yu(),J=De(re=>re.stopGeneration),Z=De(re=>re.cancelQueued),H=De(re=>re.queuedMessages),O=De(re=>re.restoredInput),B=De(re=>re.clearRestoredInput),W=De(re=>{var _e;return(_e=re.currentSession)==null?void 0:_e.workdir}),P=De(re=>re.currentSession),ee=L.useRef(!1),{sendMessage:X}=nk(E);L.useEffect(()=>{var re;O!==null&&(t(O),B(),(re=q.current)==null||re.focus())},[O,t,B]);const ne=L.useCallback(()=>{const re=q.current;if(!re)return;const _e=e.length>=I.current;I.current=e.length,_e||(re.style.height="auto"),re.style.height=`${Math.min(200,re.scrollHeight)}px`},[e]);L.useEffect(()=>{if(!f)return;const re=`openfox:draft:${f}`,_e=localStorage.getItem(re);_e!==null&&t(_e)},[f,t]),L.useEffect(()=>{var re;(re=q.current)==null||re.focus(),ne()},[f,ne]),L.useEffect(()=>{if(!f)return;const re=`openfox:draft:${f}`,_e=setTimeout(()=>{e?localStorage.setItem(re,e):localStorage.removeItem(re)},500);return()=>clearTimeout(_e)},[f,e]),L.useEffect(()=>{ne()},[e,ne]),L.useEffect(()=>{const re=q.current;if(!re)return;const _e=async He=>{var rt;if(document.activeElement!==re)return;const et=(rt=He.clipboardData)==null?void 0:rt.items;if(et){for(const kt of Array.from(et))if(kt.type.startsWith("image/")){He.preventDefault();const ye=kt.getAsFile();if(!ye)continue;await Dm(ye,Ae=>s([...n,Ae]),c,{filename:"pasted-image"})}}};return re.addEventListener("paste",_e),()=>re.removeEventListener("paste",_e)},[n,s,c]);const Y=re=>{re.preventDefault(),!(!e.trim()&&n.length===0)&&(X(e,n.length>0?n:void 0),$())},F=re=>{var _e;if(!((_e=V.current)!=null&&_e.handleKeyDown(re))){if(m)switch(re.key){case"Enter":{re.preventDefault();const He=v();He&&(t(He),C());return}case"Escape":re.preventDefault(),C(),z&&J();return;case"ArrowUp":re.preventDefault(),b();return;case"ArrowDown":re.preventDefault(),S();return}if(re.key==="ArrowUp"&&e.trim()===""&&!m){re.preventDefault(),w();return}re.key==="Enter"&&!re.shiftKey&&(re.preventDefault(),Y(re))}},te=L.useCallback(async re=>{const _e=re.target.files;if(!(!_e||_e.length===0)){c(null);for(const He of Array.from(_e))await Dm(He,et=>s([...n,et]),c);G.current&&(G.current.value="")}},[n,s,c]),se=L.useCallback(re=>{re.preventDefault(),re.stopPropagation(),l(!0)},[l]),xe=L.useCallback(re=>{re.preventDefault(),re.stopPropagation(),l(!1)},[l]),le=L.useCallback(async re=>{re.preventDefault(),re.stopPropagation(),l(!1),c(null);const _e=re.dataTransfer.files;if(!(!_e||_e.length===0))for(const He of Array.from(_e))await Dm(He,et=>s([...n,et]),c)},[n,s,l,c]),Ee=L.useCallback(re=>{s(n.filter(_e=>_e.id!==re))},[n,s]),ue=L.useCallback(()=>{var re;(re=G.current)==null||re.click()},[]),ae=()=>{var re;!e.trim()&&n.length===0||((re=d.current)==null||re.scrollTo({top:d.current.scrollHeight,behavior:"smooth"}),X(e,n),$())},de=L.useCallback((re,_e)=>{const et=re.type==="directory"?"/":" ",rt=e.slice(0,_e),kt=e.slice(U.current),ye=`${rt}@${re.path}${et}${kt}`;t(ye);const Ae=_e+re.path.length+2;U.current=Ae,q.current&&(q.current.selectionStart=Ae,q.current.selectionEnd=Ae,q.current.focus())},[e,t]),oe=L.useCallback(re=>{const _e=re.target.value;t(_e),m&&C(),U.current=re.target.selectionStart,!ee.current&&f&&_e&&P&&P.messages.length===0&&(ee.current=!0,Te(`/api/sessions/${f}/warmup`,{method:"POST"}).catch(()=>{}))},[t,m,C,f,P]),Ne=L.useCallback(re=>{U.current=re.target.selectionStart},[]),ve=L.useCallback(re=>{U.current=re.currentTarget.selectionStart},[]);return o.jsxs("form",{onSubmit:Y,className:"relative p-2 md:p-4 bg-secondary",children:[z&&o.jsx("div",{className:"absolute -top-8 left-2 md:left-4 z-10",children:o.jsx(n8,{})}),o.jsxs("div",{className:`absolute -top-8 right-2 md:right-4 z-10 flex items-center gap-2 border${_?" border-transparent":" rounded backdrop-blur-xl saturate-150 border-border"}`,children:[o.jsx(Dp,{isActive:_,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:j,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(pl,{}),"Browse history"]})]}),o.jsx("input",{ref:G,type:"file",accept:".png,.jpg,.jpeg,.gif",onChange:te,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(re=>o.jsx(e8,{attachment:re,onRemove:Ee},re.id))}),m&&o.jsx(t8,{history:x,selectedIndex:y,onSelect:re=>{t(re),C()},onEscape:C,onNavigate:re=>{re==="up"?b():S()}}),o.jsx(y8,{messages:H,onCancel:Z}),o.jsxs("div",{className:`flex items-end gap-3 p-3 rounded transition-colors ${a?"bg-accent-primary/10":"bg-primary"}`,onDragOver:se,onDragLeave:xe,onDrop:le,children:[o.jsxs("div",{className:"relative flex-1 min-w-0",children:[o.jsx("textarea",{id:YS,ref:q,value:e,onChange:oe,onKeyDown:F,onSelect:Ne,onKeyUp:ve,placeholder:"What would you like to build?","data-testid":"chat-input-textarea",className:"w-full bg-transparent text-sm placeholder:text-text-muted resize-none overflow-y-auto focus:outline-none",style:{minHeight:"24px",maxHeight:"200px"},spellCheck:!1}),o.jsx(L8,{ref:V,text:e,cursorPos:U.current,workdir:W,onSelect:de})]}),o.jsxs("div",{className:"flex items-center self-center gap-1.5",children:[z&&o.jsxs("button",{type:"button",onClick:()=>J(),"data-testid":"chat-stop-button",className:"flex items-center gap-1 px-4 py-1.5 rounded bg-accent-error/20 text-sm text-accent-error font-medium hover:bg-accent-error/30 transition-colors whitespace-nowrap",children:[o.jsx(OS,{}),"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(g8,{onSendCommand:(re,_e,He,et)=>{var kt;_e&&p!==_e&&De.getState().switchMode(_e);const rt=He&&He.trim()?`${He.trim()}
|
|
299
|
+
|
|
300
|
+
${re}`:re;(kt=d.current)==null||kt.scrollTo({top:d.current.scrollHeight,behavior:"smooth"}),X(rt,et!=null&&et.length?et:void 0,{messageKind:"command",isSystemGenerated:!0}),$()},onSelectWorkflow:A,onSelectWorkflowWithSubGroup:D,onOpenCommandsManager:T,onOpenWorkflowsManager:R,onAttach:ue,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(C8,{}),o.jsx(k8,{})]}),o.jsx(T8,{})]})]})}function D8(e){return(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()==="f"&&document.querySelector("[data-global-settings]")===null}function sk(e,t=[]){const n=[];let s=null,a,l=1;const u=new Map,c=new Map;for(const f of t)f.type==="message"?u.set(f.message.id,f):f.type==="subagent"&&c.set(f.subAgentId,f);const d=()=>{if(!s)return;const f=s,p=c.get(f.subAgentId);p&&p.type==="subagent"&&p.messages.length===f.messages.length&&p.messages.every((x,y)=>x===f.messages[y])?n.push(p):n.push({type:"subagent",subAgentId:f.subAgentId,subAgentType:f.subAgentType,messages:f.messages}),s=null};for(const f of e)if(f.role!=="tool")if(f.contextWindowId&&a&&f.contextWindowId!==a&&(d(),l++,n.push({type:"context-divider",windowSequence:l})),a=f.contextWindowId,f.subAgentId&&f.subAgentType)s&&s.subAgentId===f.subAgentId?s.messages.push(f):(d(),s={subAgentId:f.subAgentId,subAgentType:f.subAgentType,messages:[f]});else{d();const p=u.get(f.id);p&&p.type==="message"&&p.message===f?n.push(p):n.push({type:"message",message:f})}return d(),n}function O8(e){const{year:t,month:n,day:s}=e1(e);return`${t}/${n}/${s} ${ed(e)}`}function I8(e,t){return e.length<=t?e:e.substring(0,t)+"..."}const M8=10,P8=150;function B8(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 z8(e){return[...e].sort((s,a)=>new Date(a.timestamp).getTime()-new Date(s.timestamp).getTime()).slice(0,M8).reverse().map(s=>({id:s.id,content:s.content,timestamp:s.timestamp,formattedTimestamp:O8(s.timestamp),trimmedContent:I8(s.content,P8),sessionId:s.sessionId,sessionName:s.sessionName}))}function $8(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(...B8(l));return z8(s)}function H8(e,t=[],n=null){const[s,a]=L.useState(0),[l,u]=L.useState(!1),c=L.useMemo(()=>$8(e,t,n),[e,t,n]),d=L.useCallback(()=>{c.length>0&&(a(c.length-1),u(!0))},[c.length]),f=L.useCallback(()=>{u(!1),a(0)},[]),p=L.useCallback(()=>{a(y=>c.length===0?y:y===0?c.length-1:y-1)},[c.length]),m=L.useCallback(()=>{a(y=>c.length===0?y:y===c.length-1?0:y+1)},[c.length]),x=L.useCallback(()=>{if(c.length===0||!l)return null;const y=c[s];return(y==null?void 0:y.content)??null},[c,s,l]);return{history:c,selectedIndex:s,showHistory:l,openHistory:d,closeHistory:f,navigateUp:p,navigateDown:m,selectCurrent:x}}L.memo(function({item:t}){const[n,s]=L.useState(!1);return t.type==="start"?o.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-amber-500/10 border border-amber-500/30 rounded text-amber-300 text-sm",children:[o.jsx("span",{className:"animate-pulse",children:"●"}),o.jsx("span",{children:"Delegating image to fallback vision model..."}),t.filename&&o.jsxs("span",{className:"text-amber-400/70",children:["(",t.filename,")"]})]}):o.jsxs("div",{className:"flex items-start gap-2 px-3 py-2 bg-accent-success/10 border border-accent-success/30 rounded",children:[o.jsx("span",{className:"text-accent-success",children:"✓"}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:"flex items-center justify-between gap-2",children:[o.jsx("span",{className:"text-accent-success text-sm",children:"Image description done"}),o.jsx("button",{type:"button",onClick:()=>s(!n),className:"text-xs text-accent-primary hover:text-accent-primary/80 transition-colors",children:n?"Hide":"Show"})]}),n&&t.description&&o.jsx("div",{className:"mt-2 text-xs prose prose-invert prose-sm max-w-none",children:o.jsx(us,{content:t.description})})]})]})});function U8({criteriaSidebarOpen:e,onCriteriaSidebarToggle:t}={}){const n=e??!0,[s,a]=L.useState(""),[l,u]=L.useState([]),[c,d]=L.useState(!1),[f,p]=L.useState(null),[m,x]=L.useState(!1),[y,w]=L.useState(!1),[C,b]=L.useState(!1),[S,v]=L.useState(!1),[_,E]=L.useState(null),j=L.useRef(null),T=De(de=>de.currentSession),R=De(de=>de.messages),A=De(de=>de.sessions),D=Yu(),$=De(de=>de.stopGeneration),q=mt(de=>de.defaults),G=mt(de=>de.userItems),I=[...q,...G].filter(de=>!de.subagent),{history:U,selectedIndex:V,showHistory:z,openHistory:J,closeHistory:Z,navigateUp:H,navigateDown:O,selectCurrent:B}=H8(R,A,T==null?void 0:T.id);L.useEffect(()=>{const de=oe=>{E(oe.detail.stats)};return window.addEventListener("open-turn-stats",de),()=>window.removeEventListener("open-turn-stats",de)},[]),L.useEffect(()=>{Ct.getState().fetchWorkflows()},[]),L.useEffect(()=>{const de=oe=>{D8(oe)&&(oe.preventDefault(),v(!0))};return window.addEventListener("keydown",de),()=>window.removeEventListener("keydown",de)},[]);const{maxVisibleItems:W}=Ri(),P=L.useRef([]),{displayItems:ee,hiddenCount:X}=L.useMemo(()=>{const de=sk(R,P.current);return P.current=de,W>0&&de.length>W?{displayItems:de.slice(-W),hiddenCount:de.length-W}:{displayItems:de,hiddenCount:0}},[R,W]),{isAutoScrollActive:ne,setAutoScroll:Y}=nd(j,T),{sendMessage:F,launchWorkflow:te}=nk(Y),se=L.useCallback((de,oe)=>{te(void 0,void 0,de,oe)},[te]),xe=L.useCallback(de=>{var Ne;Y(!1);const oe=document.querySelector(`[data-item-index="${de}"]`);oe&&(oe.scrollIntoView({behavior:"smooth",block:"start"}),(Ne=oe.closest('[data-testid="chat-scroll-container"]'))==null||Ne.scrollBy(0,-80))},[Y]);L.useEffect(()=>{const de=oe=>{const Ne=C||m||y||S||_;oe.key==="Escape"&&D&&!Ne&&$(),oe.key==="ScrollLock"&&Y(!ne)};return window.addEventListener("keydown",de),()=>window.removeEventListener("keydown",de)},[D,$,ne,C,m,y,S,_]);const le=jp();zS(le.quickAction,()=>{b(!0)}),oN(le.agentSwitching,I,de=>{De.getState().switchMode(de)});const Ee=de=>{const oe=s.trim()?s:void 0,Ne=l.length>0?l:void 0;te(oe,Ne,de),ae()},ue=(de,oe)=>{const Ne=s.trim()?s:void 0,ve=l.length>0?l:void 0;te(Ne,ve,de,oe),ae()},ae=()=>{a(""),u([]),T!=null&&T.id&&localStorage.removeItem(`openfox:draft:${T.id}`)};return o.jsxs(o.Fragment,{children:[o.jsxs(WT,{criteriaSidebarOpen:n,onCriteriaSidebarToggle:t,messages:R,children:[o.jsx(YT,{}),_&&o.jsx(XT,{stats:_,onClose:()=>E(null)}),o.jsx(LB,{}),o.jsx(TB,{displayItems:ee,scrollContainerRef:j,highlightedMessageId:null,onLaunchWorkflow:se,hiddenCount:X}),o.jsx(R8,{input:s,setInput:a,attachments:l,setAttachments:u,dragOver:c,setDragOver:d,errorMessage:f,setErrorMessage:p,scrollContainerRef:j,sessionId:T==null?void 0:T.id,sessionMode:T==null?void 0:T.mode,showHistory:z,history:U,selectedIndex:V,openHistory:J,closeHistory:Z,navigateUp:H,navigateDown:O,selectCurrent:B,isAutoScrollActive:ne,setAutoScroll:Y,onOpenMessageSearch:()=>v(!0),onOpenCommandsModal:()=>x(!0),onOpenWorkflowsModal:()=>w(!0),onSelectWorkflow:Ee,onSelectWorkflowWithSubGroup:ue,clearInput:ae}),o.jsx(XC,{isOpen:m,onClose:()=>x(!1)}),o.jsx(ZC,{isOpen:y,onClose:()=>w(!1)}),o.jsx(VB,{isOpen:C,onClose:()=>b(!1),onSearchMessages:()=>v(!0),isAutoScrollActive:ne,onToggleAutoScroll:Y,textareaContent:s,onCloseComplete:Um,onCloseCompleteAction:()=>window.dispatchEvent(new CustomEvent("open-session-dropdown")),onSelectCommand:async(de,oe)=>{const Ne=await en.getState().fetchCommand(de);if(Ne){const ve=oe!=null&&oe.trim()?`${oe.trim()}
|
|
301
|
+
|
|
302
|
+
${Ne.prompt}`:Ne.prompt;Ne.metadata.agentMode&&De.getState().switchMode(Ne.metadata.agentMode),F(ve,l!=null&&l.length?l:void 0,{messageKind:"command",isSystemGenerated:!0}),ae()}},onSelectWorkflow:de=>{const oe=s.trim()||void 0,Ne=l.length>0?l:void 0;te(oe,Ne,de),ae()}})]}),S&&o.jsx(ZB,{isOpen:S,onClose:()=>{v(!1),Um()},displayItems:ee,onNavigate:xe})]})}function F8(){var S;const[,e]=Ga("/p/:projectId/s/:sessionId/readonly"),t=e==null?void 0:e.sessionId,[n,s]=L.useState(null),[a,l]=L.useState([]),[u,c]=L.useState(!0),[d,f]=L.useState(null),p=async()=>{if(t){c(!0),f(null);try{const v=await Te(`/api/sessions/${t}`);if(!v.ok){f(`Failed to load session (${v.status})`),c(!1);return}const _=await v.json();s(_.session??null),l(_.messages??[])}catch(v){f(v instanceof Error?v.message:"Unknown error")}finally{c(!1)}}};L.useEffect(()=>{qt.getState().getSettings([...bp])},[]),L.useEffect(()=>{p()},[t]);const{showThinking:m,showVerboseToolOutput:x,showStats:y,showAgentDefinitions:w,showWorkflowBars:C}=Ri(),b=L.useMemo(()=>sk(a),[a]);return u?o.jsx("div",{className:"h-screen flex items-center justify-center bg-primary",children:o.jsx(Di,{})}):d?o.jsx("div",{className:"h-screen flex items-center justify-center bg-primary",children:o.jsxs("div",{className:"text-center space-y-4",children:[o.jsx("div",{className:"text-red-400 text-sm",children:d}),o.jsx("button",{onClick:p,className:"px-3 py-1.5 text-sm bg-bg-tertiary text-text-primary border border-border rounded hover:bg-bg-tertiary/80 transition-colors",children:"Retry"})]})}):o.jsxs("div",{className:"h-screen print:h-auto flex flex-col bg-primary",children:[o.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border bg-secondary shrink-0 print:hidden",children:[o.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[o.jsxs("h1",{className:"text-sm font-medium text-text-primary truncate",children:[((S=n==null?void 0:n.metadata)==null?void 0:S.title)??"Session"," — Read-only view"]}),o.jsxs("span",{className:"text-xs text-text-muted whitespace-nowrap",children:[a.length," messages"]})]}),o.jsx("div",{className:"flex items-center gap-2",children:o.jsx("button",{onClick:p,disabled:u,className:"px-3 py-1 text-xs bg-bg-tertiary text-text-primary border border-border rounded hover:bg-bg-tertiary/80 transition-colors disabled:opacity-50",children:u?"Refreshing...":"Refresh"})})]}),o.jsxs("div",{className:"flex-1 overflow-y-auto print:overflow-visible",children:[o.jsx("div",{className:"pt-4",children:o.jsx(KC,{displayItems:b,showThinking:m,showVerboseToolOutput:x,showStats:y,showAgentDefinitions:w,showWorkflowBars:C})}),o.jsx("div",{className:"h-8"})]})]})}function uS({isOpen:e,isRetry:t,onSubmit:n,onCancel:s}){const[a,l]=L.useState(""),u=L.useRef(null);L.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(jt,{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(Ni,{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(Ve,{type:"button",variant:"secondary",onClick:s,children:"Cancel"}),o.jsx(Ve,{type:"submit",disabled:!a.trim(),children:t?"Try Again":"Connect"})]})]})})}function V8({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 G8({onNext:e}){const[t,n]=L.useState([]),[s,a]=L.useState([]),[l,u]=L.useState(!1),[c,d]=L.useState(null),[f,p]=L.useState(null),[m,x]=L.useState(null);L.useEffect(()=>{y()},[]);async function y(){try{const j=await Te("/api/providers");if(j.ok){const R=(await j.json()).providers.map(A=>({id:A.id,name:A.name,url:A.url,backend:A.backend,model:null,apiKey:A.apiKey,isLocal:A.isLocal,thinkingField:A.thinkingField,models:A.models}));n(R),a(R)}}catch{}}async function w(j){const T=j.id.startsWith("temp-"),R={name:j.name,url:j.url,backend:j.backend,apiKey:j.apiKey,isLocal:j.isLocal,thinkingField:j.thinkingField,models:j.models};try{if(T){const A=await Te("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(R)});if(A.ok){const D=await A.json(),$={...j,id:D.provider.id,model:null};a(q=>[...q,$]),n(q=>[...q,$])}}else await Te(`/api/providers/${j.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(R)}),a(A=>A.map(D=>D.id===j.id?{...D,...j,model:null}:D)),n(A=>A.map(D=>D.id===j.id?{...D,...j,model:null}:D))}catch{if(T){const A={...j,model:null};a(D=>[...D,A])}}}function C(){d(null),u(!0)}function b(j){d(j),u(!0)}function S(){u(!1),d(null)}function v(j){p(j),t.some(R=>R.id===j)?Te(`/api/providers/${j}`,{method:"DELETE"}).then(()=>{a(s.filter(R=>R.id!==j)),n(t.filter(R=>R.id!==j)),p(null)}).catch(()=>p(null)):(a(s.filter(R=>R.id!==j)),p(null))}function _(){const j=s.filter(T=>!T.id.startsWith("temp-"));e({providers:j})}const E=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(j=>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:vS(j.backend)}),o.jsx("span",{className:"text-text-primary font-medium",children:j.name}),o.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded-full ${j.isLocal?"text-accent-success bg-accent-success/10":"text-accent-warning bg-accent-warning/10"}`,children:j.isLocal?"local":"api"})]}),o.jsx("p",{className:"text-text-muted text-sm mt-1",children:j.url}),j.model&&o.jsxs("p",{className:"text-text-secondary text-xs mt-0.5",children:["Model: ",j.model]})]}),o.jsx("div",{className:"flex items-center gap-1",children:m===j.id?o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("button",{onClick:()=>v(j.id),disabled:f===j.id,className:"px-2 py-1 text-xs text-red-500 hover:text-red-400 bg-red-500/10 rounded transition-colors disabled:opacity-50",children:f===j.id?"Deleting...":"Confirm"}),o.jsx("button",{onClick:()=>x(null),className:"px-2 py-1 text-xs text-text-muted hover:text-text-secondary transition-colors",children:"Cancel"})]}):o.jsxs(o.Fragment,{children:[o.jsx("button",{onClick:()=>b(j),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:()=>x(j.id),className:"p-2 text-text-muted hover:text-red-500 transition-colors",title:"Remove provider",children:o.jsx(Wa,{})})]})})]},j.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:C,"data-testid":"onboarding-add-provider-button",className:"w-full flex items-center justify-center gap-2 px-4 py-3 bg-bg-secondary border border-dashed border-border rounded-lg text-text-secondary hover:text-text-primary hover:border-text-muted transition-colors",children:[o.jsx(qs,{className:"w-4 h-4"}),"Add Provider"]}),o.jsx("button",{onClick:_,disabled:!E,"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(rk,{isOpen:l,onClose:S,onSave:w,initialStep:1,editProvider:c??void 0})]})}function W8({onNext:e}){const[t,n]=L.useState(""),[s,a]=L.useState(!1);return L.useEffect(()=>{Te("/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(Zu,{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 q8({onNext:e}){const[t,n]=L.useState(!1),[s,a]=L.useState("http://localhost:11434"),[l,u]=L.useState("qwen3.5:0.8b"),[c,d]=L.useState("ollama"),{copied:f,copy:p}=VC();L.useEffect(()=>{Te("/api/config").then(x=>x.json()).then(x=>{x.visionFallback&&(n(x.visionFallback.enabled),a(x.visionFallback.url),u(x.visionFallback.model),x.visionFallback.backend&&d(x.visionFallback.backend))}).catch(()=>{})},[]);function m(x){if(x){e({});return}e({visionFallback:{enabled:t,url:s,model:l,timeout:120,backend:c}})}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:"You need a server with a vision model. Choose your backend type below."}),o.jsx("p",{className:"text-text-secondary text-sm mb-2",children:"For Ollama:"}),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:()=>p("ollama pull qwen3.5:0.8b"),className:"text-text-muted hover:text-text-primary transition-colors",title:"Copy",children:f?o.jsx(Mr,{className:"w-4 h-4 text-accent-primary"}):o.jsx(Hj,{className:"w-4 h-4"})})]}),o.jsxs("p",{className:"text-text-secondary text-sm mt-3",children:["For OpenAI-compatible servers (vLLM, sglang, llama.cpp): use the ",o.jsx("strong",{children:"OpenAI"})," backend type."]})]}),o.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:t,onChange:x=>n(x.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:"Backend type"}),o.jsxs("select",{value:c,onChange:x=>d(x.target.value),className:"w-full px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary focus:outline-none focus:border-accent-primary",children:[o.jsx("option",{value:"ollama",children:"Ollama"}),o.jsx("option",{value:"openai",children:"OpenAI-compatible (vLLM, sglang, llama.cpp)"})]})]}),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:x=>a(x.target.value),placeholder:c==="ollama"?"http://localhost:11434":"http://localhost:8000/v1",className:"w-full px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"})]}),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:x=>u(x.target.value),placeholder:c==="ollama"?"qwen3.5:0.8b":"qwen3.5-27b",className:"w-full px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"})]})]}),o.jsxs("div",{className:"flex items-center justify-between pt-4",children:[o.jsx("button",{onClick:()=>m(!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:()=>m(!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 K8({onComplete:e}){const[t,n]=L.useState(1),[s,a]=L.useState(!1),[l,u]=L.useState({});async function c(m){u(x=>({...x,providers:m.providers})),n(2)}async function d(m){u(x=>({...x,...m})),n(3)}async function f(m){a(!0);try{if(!(await Te("/api/init/config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workdir:l.workdir,visionFallback:m.visionFallback})})).ok)throw new Error("Failed to save config");e()}catch(x){console.error("Failed to save onboarding data:",x),a(!1)}}const p=m=>{n(m)};return o.jsxs("div",{className:"w-full max-w-xl mx-auto px-6 py-16 relative",children:[o.jsx(Tl,{onClick:e,className:"absolute top-4 right-4 p-2",variant:"modal",size:"xl"}),o.jsx(V8,{currentStep:t,totalSteps:3,labels:["LLM Providers","Projects Folder","Vision"],onStepClick:p}),o.jsx("div",{className:"max-w-xl mx-auto",children:s?o.jsxs("div",{className:"text-center",children:[o.jsx(qs,{className:"w-6 h-6"}),o.jsx("p",{className:"mt-4 text-text-secondary",children:"Saving your settings..."})]}):o.jsxs(o.Fragment,{children:[t===1&&o.jsx(G8,{onNext:c}),t===2&&o.jsx(W8,{onNext:d}),t===3&&o.jsx(q8,{onNext:f})]})})]})}const Im="openfox_updated_to",Mm="update_pending";function Y8(){const[e,t]=L.useState(!1),n=localStorage.getItem(Im),s=localStorage.getItem(Mm);L.useEffect(()=>{if(!n||!s)return;const l=setTimeout(()=>{localStorage.removeItem(Im),localStorage.removeItem(Mm),t(!0)},8e3);return()=>clearTimeout(l)},[n,s]);const a=()=>{localStorage.removeItem(Im),localStorage.removeItem(Mm),t(!0)};return e||s!=="true"||!n?null:o.jsxs("div",{className:"fixed bottom-20 left-1/2 -translate-x-1/2 z-[100] flex items-center gap-3 px-4 py-2.5 bg-bg-secondary border border-border rounded-lg shadow-xl animate-slide-down",role:"status","aria-live":"polite",children:[o.jsx("div",{className:"flex items-center justify-center w-5 h-5 rounded-full bg-accent-primary/20",children:o.jsx(Mr,{className:"w-3 h-3 text-accent-primary"})}),o.jsxs("div",{className:"flex flex-col",children:[o.jsx("span",{className:"text-sm font-medium text-text-primary",children:"OpenFox updated successfully"}),o.jsxs("span",{className:"text-xs text-text-muted",children:["Now running ",n]})]}),o.jsx("button",{onClick:a,className:"ml-2 p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors","aria-label":"Dismiss",children:o.jsx(IS,{className:"w-3.5 h-3.5"})})]})}typeof window<"u"&&(Ht.getState().loadUserPresets(),Ht.getState().applySavedTheme());function _g(){return typeof window>"u"?!1:localStorage.getItem("openfox_token")!==null}function ik(){return o.jsx("div",{className:"flex-1 flex items-center justify-center",children:o.jsx(Di,{})})}function X8({sidebarOpen:e,onSidebarToggle:t}){const[,n]=Ga("/p/:projectId"),s=n==null?void 0:n.projectId,a=De(d=>d.connectionStatus),l=Rt(d=>d.currentProject),u=_g();return Ij({canLoad:a==="connected"||u,projectId:s,currentProjectId:l==null?void 0:l.id}),!l||l.id!==s?o.jsx(ik,{}):o.jsxs(o.Fragment,{children:[o.jsx(n1,{projectId:s,isOpen:e,onClose:t}),o.jsx("div",{className:"flex-1 min-w-0 bg-primary",children:o.jsx(aT,{})})]})}function Q8({sidebarOpen:e,onSidebarToggle:t,rightSidebarOpen:n,onRightSidebarToggle:s}){const[,a]=Ga("/p/:projectId/s/:sessionId"),l=a==null?void 0:a.projectId,u=a==null?void 0:a.sessionId,[,c]=Yn(),d=De(C=>C.connectionStatus),f=De(C=>C.currentSession),p=De(C=>C.error),m=De(C=>C.clearError),x=Rt(C=>C.currentProject),y=_g();return Mj({canLoad:d==="connected"||y,projectId:l,sessionId:u,currentProjectId:x==null?void 0:x.id,currentSessionId:f==null?void 0:f.id}),L.useEffect(()=>{(p==null?void 0:p.code)==="NOT_FOUND"&&l&&(m(),c(`/p/${l}`))},[p,l,m,c]),!x||x.id!==l?o.jsx(ik,{}):o.jsxs(o.Fragment,{children:[o.jsx(n1,{projectId:l,isOpen:e,onClose:t}),o.jsx("div",{className:"flex-1 min-w-0 bg-primary",children:o.jsx(U8,{criteriaSidebarOpen:n,onCriteriaSidebarToggle:s})})]})}function J8(){const e=nn(n=>n.fetchConfig);function t(){e(),window.history.back()}return o.jsx("div",{className:"flex-1 overflow-y-auto",children:o.jsx(K8,{onComplete:t})})}function Z8(){const{connectionStatus:e}=Aj(),t=nn(Z=>Z.fetchConfig),n=nn(Z=>Z.refreshProviderModels),s=nn(Z=>Z.providers),a=nn(Z=>Z.activeProviderId),[,l]=Yn(),u=_g(),[c,d]=L.useState(!1);L.useEffect(()=>{(e==="connected"||u)&&t().then(()=>{d(!0),qt.getState().getSettings([...bp,Oe.DISPLAY_THEME,Oe.DISPLAY_USER_PRESETS,Oe.KEYBINDINGS])})},[e,u,t]),L.useEffect(()=>{c&&a&&n(a).then(()=>{const Z=nn.getState().defaultModelSelection;(Z?Z.split("/")[0]:null)!==a&&t()})},[c,a,n,t]);const f=qt(Z=>Z.settings);L.useEffect(()=>{c&&s.length===0&&l("/onboarding")},[c,s.length]),L.useEffect(()=>{const{applyPreset:Z,applyTokens:H,setFollowSystemTheme:O,initSystemThemeListener:B}=Ht.getState(),W=f[Oe.DISPLAY_THEME],P=f[Oe.DISPLAY_USER_PRESETS],ee=f[Oe.DISPLAY_FOLLOW_SYSTEM_THEME];if(P&&localStorage.setItem("openfox:userPresets",P),W){localStorage.setItem("openfox:theme",W);try{const ne=JSON.parse(W);ne.preset&&ne.tokens?(Z(ne.preset),Ht.setState({basePreset:ne.preset}),H(ne.tokens)):ne.preset?Z(ne.preset):ne.tokens&&H(ne.tokens)}catch{Z("dark")}}else Z("system");ee!==void 0&&Ht.getState().followSystemTheme!==(ee==="true")&&O(ee==="true");const X=B();return()=>X()},[f[Oe.DISPLAY_THEME],f[Oe.DISPLAY_USER_PRESETS]]);const p=()=>{const Z=localStorage.getItem("openfox:leftSidebar");return Z!==null?Z==="true":!0},m=()=>{const Z=localStorage.getItem("openfox:rightSidebar");return Z!==null?Z==="true":!0},[x,y]=L.useState(p),[w,C]=L.useState(m),[b,S]=L.useState(!1),[v,_]=L.useState(!1),[E,j]=L.useState(!1),T=P2();L.useEffect(()=>{const Z=()=>{j(window.innerWidth<768)};return Z(),window.addEventListener("resize",Z),()=>window.removeEventListener("resize",Z)},[]);const[R]=Yn(),A=/^\/p\/[^/]+$/.test(R),D=E?b:A?!0:x,$=E?v:w,q=()=>{E?S(!b):y(!x)},G=()=>{E?_(!v):C(!w)};L.useEffect(()=>{E||localStorage.setItem("openfox:leftSidebar",String(x))},[x,E]),L.useEffect(()=>{E||localStorage.setItem("openfox:rightSidebar",String(w))},[w,E]),L.useEffect(()=>{(e==="connected"||u)&&t()},[e,t,u]);const I=De(Z=>Z.showPasswordModal),U=De(Z=>Z.passwordModalRetry),V=De(Z=>Z.submitPassword),z=De(Z=>Z.cancelPassword),[J]=Ga("/p/:projectId/s/:sessionId/readonly");return!J&&e!=="connected"&&!I&&!u?o.jsxs(o.Fragment,{children:[o.jsx(uS,{isOpen:!0,isRetry:U,onSubmit:V,onCancel:z}),o.jsx("div",{className:"h-screen flex items-center justify-center",children:o.jsx(pN,{text:"Connecting to server..."})})]}):J?o.jsx(F8,{}):o.jsxs(o.Fragment,{children:[o.jsx(uS,{isOpen:I,isRetry:U,onSubmit:V,onCancel:z}),o.jsxs("div",{className:"flex flex-col",style:{height:E?`calc(${T.offsetTop}px + ${T.height}px)`:"100vh"},children:[o.jsx(nT,{}),o.jsx(XN,{onMenuClick:q,onCriteriaToggle:G}),o.jsx("div",{className:"flex-1 flex overflow-hidden",children:o.jsxs(ij,{children:[o.jsx(qo,{path:"/onboarding",children:o.jsx(J8,{})}),o.jsx(qo,{path:"/p/:projectId/s/:sessionId",children:o.jsx(Q8,{sidebarOpen:D,onSidebarToggle:q,rightSidebarOpen:$,onRightSidebarToggle:G})}),o.jsx(qo,{path:"/p/:projectId/new",children:o.jsx(iT,{})}),o.jsx(qo,{path:"/p/:projectId",children:o.jsx(X8,{sidebarOpen:D,onSidebarToggle:q})}),o.jsx(qo,{path:"/",children:o.jsx(sT,{})})]})})]}),o.jsx(Y8,{})]})}R2.createRoot(document.getElementById("root")).render(o.jsx(Hs.StrictMode,{children:o.jsx(Z8,{})}));
|