openfox 2.0.112 → 2.0.113

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.md +1 -0
  3. package/dist/CHANGELOG.md +27 -0
  4. package/dist/{chat-handler-BYXZIIV3.js → chat-handler-PEK5JDHO.js} +24 -24
  5. package/dist/{chunk-3UILDGOO.js → chunk-3R43CMLS.js} +8 -8
  6. package/dist/{chunk-ERYUSG5C.js → chunk-43M7QZMX.js} +2 -2
  7. package/dist/{chunk-SYJMUIRC.js → chunk-4NMGX5F2.js} +2 -2
  8. package/dist/{chunk-RAKPI4OE.js → chunk-5VYSKVZT.js} +28 -25
  9. package/dist/{chunk-FFPCVN5M.js → chunk-6UPBZ2ZR.js} +4 -4
  10. package/dist/{chunk-C5NQF2K4.js → chunk-AZFZE36I.js} +15 -6
  11. package/dist/chunk-B2PHPBFU.js +7 -0
  12. package/dist/{chunk-P45RJGOT.js → chunk-BKCW3JLL.js} +1 -1
  13. package/dist/{chunk-N4RTAGFY.js → chunk-BNFGDTEU.js} +2 -2
  14. package/dist/{chunk-JNHKKUGJ.js → chunk-BYSUSSSC.js} +2 -2
  15. package/dist/{chunk-NB2D6I64.js → chunk-CP44U7BT.js} +5 -5
  16. package/dist/{chunk-SVJFMZ2Q.js → chunk-EC5T5A6O.js} +11 -4
  17. package/dist/{chunk-RKMP74BB.js → chunk-EMI3YYLP.js} +3 -3
  18. package/dist/{chunk-BOSKQI62.js → chunk-FF2EKUQO.js} +4 -4
  19. package/dist/{chunk-XCK5IBO4.js → chunk-HGOTZWON.js} +41 -19
  20. package/dist/{chunk-XWNCKIPO.js → chunk-HKD4IMOE.js} +2 -2
  21. package/dist/{chunk-C372UH7N.js → chunk-KSXCOHHW.js} +18 -20
  22. package/dist/{chunk-Z56SEG4Z.js → chunk-O2YSYW2F.js} +6 -6
  23. package/dist/{chunk-UAF2FOI5.js → chunk-ONONXV3N.js} +7 -7
  24. package/dist/{chunk-LCQ5AN6Y.js → chunk-PWXBIUEY.js} +5 -1
  25. package/dist/{chunk-33Q7LCVD.js → chunk-R2MTWC7C.js} +2 -2
  26. package/dist/{chunk-JDT63SSP.js → chunk-SNLLOXCM.js} +3 -3
  27. package/dist/{chunk-FSYRANYR.js → chunk-TCGWZBTS.js} +3 -4
  28. package/dist/{chunk-IYTDCPEQ.js → chunk-TEQEDOWI.js} +206 -143
  29. package/dist/{chunk-PCC4DBPF.js → chunk-V4664YKR.js} +2 -2
  30. package/dist/{chunk-FR5LUTLQ.js → chunk-VGRVPYZ5.js} +10 -6
  31. package/dist/{chunk-RT2A2RRL.js → chunk-WWTYWLDM.js} +2 -2
  32. package/dist/{chunk-6FPGJR7O.js → chunk-XQR76MQ5.js} +2 -2
  33. package/dist/{chunk-RISQXU32.js → chunk-Y64PEWKP.js} +2 -2
  34. package/dist/{chunk-QGXLZZBS.js → chunk-YB6WYVNY.js} +2 -2
  35. package/dist/{chunk-SDGNV45R.js → chunk-YGPPFVLJ.js} +10 -10
  36. package/dist/cli/dev.js +1 -1
  37. package/dist/cli/index.js +1 -1
  38. package/dist/{client-QNQTX5EA.js → client-3LJGD6KY.js} +5 -5
  39. package/dist/{compactor-X2KZ3XFU.js → compactor-ZBNKANHV.js} +10 -10
  40. package/dist/{config-TW5FHQEM.js → config-EAB3V4QK.js} +2 -2
  41. package/dist/{dynamic-context-ZRQO2FJN.js → dynamic-context-F2XTQJR5.js} +9 -9
  42. package/dist/{events-Y6XXQYFG.js → events-224IO5NJ.js} +7 -7
  43. package/dist/{folding-Z4GNWRC3.js → folding-YTTTVS56.js} +5 -5
  44. package/dist/http-client-YC3UA5OZ.js +11 -0
  45. package/dist/{inspect-proxy-N42Z5TOG.js → inspect-proxy-B7LGGTM7.js} +4 -4
  46. package/dist/{manager-HCMDFEQH.js → manager-4QGXI6WZ.js} +5 -5
  47. package/dist/{model-overrides-O3ZYKFP7.js → model-overrides-OY2YKUNV.js} +4 -4
  48. package/dist/{orchestrator-P5EUMC7E.js → orchestrator-JKBY7B3P.js} +23 -23
  49. package/dist/package.json +5 -4
  50. package/dist/{path-security-525YLND3.js → path-security-PFMZY7IA.js} +11 -11
  51. package/dist/{platform-MEQUWG6U.js → platform-QNGCKX4L.js} +4 -4
  52. package/dist/{processor-UN4H4V7F.js → processor-NYPJ5PFA.js} +23 -23
  53. package/dist/{project-creator-BVA55HY6.js → project-creator-AWP2JUFS.js} +3 -3
  54. package/dist/{projects-PQXME5S4.js → projects-C4353IQK.js} +3 -3
  55. package/dist/{protocol-D6MISQyz.d.ts → protocol-CBT1d98i.d.ts} +3 -1
  56. package/dist/{protocol-FTHAR2YL.js → protocol-LZZ7C4VQ.js} +3 -3
  57. package/dist/provider/index.d.ts +4 -4
  58. package/dist/{provider-3R4X62LW.js → provider-PIRPN2CC.js} +8 -8
  59. package/dist/{provider-manager-W5N4XRE5.js → provider-manager-GNEPR6UN.js} +6 -6
  60. package/dist/{registry-74KPZ5NV.js → registry-VCKDSVKA.js} +4 -4
  61. package/dist/{serve-WHFUNQ6Z.js → serve-6DRHQLCG.js} +31 -31
  62. package/dist/server/index.d.ts +7 -4
  63. package/dist/server/index.js +30 -30
  64. package/dist/server-HUHFJW7U.js +48 -0
  65. package/dist/{session-overrides-XH6I3COP.js → session-overrides-RNKV35MU.js} +6 -6
  66. package/dist/{sessions-D772YTWL.js → sessions-D5CEPQGU.js} +7 -5
  67. package/dist/{settings-KO6DSJLD.js → settings-BNRNX6IW.js} +3 -3
  68. package/dist/shared/index.d.ts +3 -3
  69. package/dist/shared/index.js +1 -1
  70. package/dist/skill-defaults/workflows/SKILL.md +499 -0
  71. package/dist/{tools-HTUTYMKI.js → tools-2B363F7L.js} +21 -21
  72. package/dist/{types-BMEOlLT0.d.ts → types-BAxh20ZL.d.ts} +8 -1
  73. package/dist/{types-D0TgGL3t.d.ts → types-cVfqOj6M.d.ts} +1 -1
  74. package/dist/{update-BRUFGGTW.js → update-IQMRYN7J.js} +2 -2
  75. package/dist/web/assets/{index-nS1p0g8O.css → index-CjWC6EQ4.css} +1 -1
  76. package/dist/web/assets/index-DBUtUSHK.js +323 -0
  77. package/dist/web/index.html +2 -2
  78. package/dist/web/sw.js +1 -1
  79. package/dist/workflow-defaults/default.workflow.json +41 -3
  80. package/dist/{workspace-YDUQZ3HC.js → workspace-YUNHV4WS.js} +4 -4
  81. package/package.json +5 -4
  82. package/dist/chunk-P5AA7OYJ.js +0 -7
  83. package/dist/http-client-2GDKHZIG.js +0 -11
  84. package/dist/server-7MOOJR2N.js +0 -48
  85. package/dist/web/assets/index-Dukvfqm-.js +0 -323
@@ -0,0 +1,323 @@
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 qL=Object.defineProperty;var KL=Object.getPrototypeOf;var YL=Reflect.get;var TS=e=>{throw TypeError(e)};var XL=(e,t,n)=>t in e?qL(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Ae=(e,t,n)=>XL(e,typeof t!="symbol"?t+"":t,n),Jp=(e,t,n)=>t.has(e)||TS("Cannot "+n);var nr=(e,t,n)=>(Jp(e,t,"read from private field"),n?n.call(e):t.get(e)),ba=(e,t,n)=>t.has(e)?TS("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),ns=(e,t,n,r)=>(Jp(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),Zp=(e,t,n)=>(Jp(e,t,"access private method"),n);var AS=(e,t,n)=>YL(KL(e),n,t);function QL(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const a in r)if(a!=="default"&&!(a in e)){const l=Object.getOwnPropertyDescriptor(r,a);l&&Object.defineProperty(e,a,l.get?l:{enumerable:!0,get:()=>r[a]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const a of document.querySelectorAll('link[rel="modulepreload"]'))r(a);new MutationObserver(a=>{for(const l of a)if(l.type==="childList")for(const u of l.addedNodes)u.tagName==="LINK"&&u.rel==="modulepreload"&&r(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 r(a){if(a.ep)return;a.ep=!0;const l=n(a);fetch(a.href,l)}})();function nf(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var eg={exports:{}},hc={};/**
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 LS;function JL(){if(LS)return hc;LS=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(r,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:r,key:u,ref:a!==void 0?a:null,props:l}}return hc.Fragment=t,hc.jsx=n,hc.jsxs=n,hc}var RS;function ZL(){return RS||(RS=1,eg.exports=JL()),eg.exports}var s=ZL(),tg={exports:{}},xt={};/**
11
+ * @license React
12
+ * react.production.js
13
+ *
14
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
15
+ *
16
+ * This source code is licensed under the MIT license found in the
17
+ * LICENSE file in the root directory of this source tree.
18
+ */var DS;function eR(){if(DS)return xt;DS=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),l=Symbol.for("react.consumer"),u=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),m=Symbol.for("react.activity"),g=Symbol.iterator;function y(D){return D===null||typeof D!="object"?null:(D=g&&D[g]||D["@@iterator"],typeof D=="function"?D:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,_={};function S(D,q,$){this.props=D,this.context=q,this.refs=_,this.updater=$||w}S.prototype.isReactComponent={},S.prototype.setState=function(D,q){if(typeof D!="object"&&typeof D!="function"&&D!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,D,q,"setState")},S.prototype.forceUpdate=function(D){this.updater.enqueueForceUpdate(this,D,"forceUpdate")};function b(){}b.prototype=S.prototype;function v(D,q,$){this.props=D,this.context=q,this.refs=_,this.updater=$||w}var k=v.prototype=new b;k.constructor=v,C(k,S.prototype),k.isPureReactComponent=!0;var T=Array.isArray;function N(){}var R={H:null,A:null,T:null,S:null},A=Object.prototype.hasOwnProperty;function O(D,q,$){var J=$.ref;return{$$typeof:e,type:D,key:q,ref:J!==void 0?J:null,props:$}}function P(D,q){return O(D.type,q,D.props)}function V(D){return typeof D=="object"&&D!==null&&D.$$typeof===e}function z(D){var q={"=":"=0",":":"=2"};return"$"+D.replace(/[=:]/g,function($){return q[$]})}var W=/\/+/g;function M(D,q){return typeof D=="object"&&D!==null&&D.key!=null?z(""+D.key):q.toString(36)}function U(D){switch(D.status){case"fulfilled":return D.value;case"rejected":throw D.reason;default:switch(typeof D.status=="string"?D.then(N,N):(D.status="pending",D.then(function(q){D.status==="pending"&&(D.status="fulfilled",D.value=q)},function(q){D.status==="pending"&&(D.status="rejected",D.reason=q)})),D.status){case"fulfilled":return D.value;case"rejected":throw D.reason}}throw D}function F(D,q,$,J,Y){var Z=typeof D;(Z==="undefined"||Z==="boolean")&&(D=null);var K=!1;if(D===null)K=!0;else switch(Z){case"bigint":case"string":case"number":K=!0;break;case"object":switch(D.$$typeof){case e:case t:K=!0;break;case p:return K=D._init,F(K(D._payload),q,$,J,Y)}}if(K)return Y=Y(D),K=J===""?"."+M(D,0):J,T(Y)?($="",K!=null&&($=K.replace(W,"$&/")+"/"),F(Y,q,$,"",function(se){return se})):Y!=null&&(V(Y)&&(Y=P(Y,$+(Y.key==null||D&&D.key===Y.key?"":(""+Y.key).replace(W,"$&/")+"/")+K)),q.push(Y)),1;K=0;var B=J===""?".":J+":";if(T(D))for(var ne=0;ne<D.length;ne++)J=D[ne],Z=B+M(J,ne),K+=F(J,q,$,Z,Y);else if(ne=y(D),typeof ne=="function")for(D=ne.call(D),ne=0;!(J=D.next()).done;)J=J.value,Z=B+M(J,ne++),K+=F(J,q,$,Z,Y);else if(Z==="object"){if(typeof D.then=="function")return F(U(D),q,$,J,Y);throw q=String(D),Error("Objects are not valid as a React child (found: "+(q==="[object Object]"?"object with keys {"+Object.keys(D).join(", ")+"}":q)+"). If you meant to render a collection of children, use an array instead.")}return K}function Q(D,q,$){if(D==null)return D;var J=[],Y=0;return F(D,J,"","",function(Z){return q.call($,Z,Y++)}),J}function X(D){if(D._status===-1){var q=D._result;q=q(),q.then(function($){(D._status===0||D._status===-1)&&(D._status=1,D._result=$)},function($){(D._status===0||D._status===-1)&&(D._status=2,D._result=$)}),D._status===-1&&(D._status=0,D._result=q)}if(D._status===1)return D._result.default;throw D._result}var H=typeof reportError=="function"?reportError:function(D){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var q=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof D=="object"&&D!==null&&typeof D.message=="string"?String(D.message):String(D),error:D});if(!window.dispatchEvent(q))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",D);return}console.error(D)},I={map:Q,forEach:function(D,q,$){Q(D,function(){q.apply(this,arguments)},$)},count:function(D){var q=0;return Q(D,function(){q++}),q},toArray:function(D){return Q(D,function(q){return q})||[]},only:function(D){if(!V(D))throw Error("React.Children.only expected to receive a single React element child.");return D}};return xt.Activity=m,xt.Children=I,xt.Component=S,xt.Fragment=n,xt.Profiler=a,xt.PureComponent=v,xt.StrictMode=r,xt.Suspense=d,xt.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=R,xt.__COMPILER_RUNTIME={__proto__:null,c:function(D){return R.H.useMemoCache(D)}},xt.cache=function(D){return function(){return D.apply(null,arguments)}},xt.cacheSignal=function(){return null},xt.cloneElement=function(D,q,$){if(D==null)throw Error("The argument must be a React element, but you passed "+D+".");var J=C({},D.props),Y=D.key;if(q!=null)for(Z in q.key!==void 0&&(Y=""+q.key),q)!A.call(q,Z)||Z==="key"||Z==="__self"||Z==="__source"||Z==="ref"&&q.ref===void 0||(J[Z]=q[Z]);var Z=arguments.length-2;if(Z===1)J.children=$;else if(1<Z){for(var K=Array(Z),B=0;B<Z;B++)K[B]=arguments[B+2];J.children=K}return O(D.type,Y,J)},xt.createContext=function(D){return D={$$typeof:u,_currentValue:D,_currentValue2:D,_threadCount:0,Provider:null,Consumer:null},D.Provider=D,D.Consumer={$$typeof:l,_context:D},D},xt.createElement=function(D,q,$){var J,Y={},Z=null;if(q!=null)for(J in q.key!==void 0&&(Z=""+q.key),q)A.call(q,J)&&J!=="key"&&J!=="__self"&&J!=="__source"&&(Y[J]=q[J]);var K=arguments.length-2;if(K===1)Y.children=$;else if(1<K){for(var B=Array(K),ne=0;ne<K;ne++)B[ne]=arguments[ne+2];Y.children=B}if(D&&D.defaultProps)for(J in K=D.defaultProps,K)Y[J]===void 0&&(Y[J]=K[J]);return O(D,Z,Y)},xt.createRef=function(){return{current:null}},xt.forwardRef=function(D){return{$$typeof:c,render:D}},xt.isValidElement=V,xt.lazy=function(D){return{$$typeof:p,_payload:{_status:-1,_result:D},_init:X}},xt.memo=function(D,q){return{$$typeof:h,type:D,compare:q===void 0?null:q}},xt.startTransition=function(D){var q=R.T,$={};R.T=$;try{var J=D(),Y=R.S;Y!==null&&Y($,J),typeof J=="object"&&J!==null&&typeof J.then=="function"&&J.then(N,H)}catch(Z){H(Z)}finally{q!==null&&$.types!==null&&(q.types=$.types),R.T=q}},xt.unstable_useCacheRefresh=function(){return R.H.useCacheRefresh()},xt.use=function(D){return R.H.use(D)},xt.useActionState=function(D,q,$){return R.H.useActionState(D,q,$)},xt.useCallback=function(D,q){return R.H.useCallback(D,q)},xt.useContext=function(D){return R.H.useContext(D)},xt.useDebugValue=function(){},xt.useDeferredValue=function(D,q){return R.H.useDeferredValue(D,q)},xt.useEffect=function(D,q){return R.H.useEffect(D,q)},xt.useEffectEvent=function(D){return R.H.useEffectEvent(D)},xt.useId=function(){return R.H.useId()},xt.useImperativeHandle=function(D,q,$){return R.H.useImperativeHandle(D,q,$)},xt.useInsertionEffect=function(D,q){return R.H.useInsertionEffect(D,q)},xt.useLayoutEffect=function(D,q){return R.H.useLayoutEffect(D,q)},xt.useMemo=function(D,q){return R.H.useMemo(D,q)},xt.useOptimistic=function(D,q){return R.H.useOptimistic(D,q)},xt.useReducer=function(D,q,$){return R.H.useReducer(D,q,$)},xt.useRef=function(D){return R.H.useRef(D)},xt.useState=function(D){return R.H.useState(D)},xt.useSyncExternalStore=function(D,q,$){return R.H.useSyncExternalStore(D,q,$)},xt.useTransition=function(){return R.H.useTransition()},xt.version="19.2.8",xt}var OS;function rf(){return OS||(OS=1,tg.exports=eR()),tg.exports}var E=rf();const os=nf(E),tR=QL({__proto__:null,default:os},[E]);var ng={exports:{}},fc={},rg={exports:{}},sg={};/**
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 IS;function nR(){return IS||(IS=1,(function(e){function t(F,Q){var X=F.length;F.push(Q);e:for(;0<X;){var H=X-1>>>1,I=F[H];if(0<a(I,Q))F[H]=Q,F[X]=I,X=H;else break e}}function n(F){return F.length===0?null:F[0]}function r(F){if(F.length===0)return null;var Q=F[0],X=F.pop();if(X!==Q){F[0]=X;e:for(var H=0,I=F.length,D=I>>>1;H<D;){var q=2*(H+1)-1,$=F[q],J=q+1,Y=F[J];if(0>a($,X))J<I&&0>a(Y,$)?(F[H]=Y,F[J]=X,H=J):(F[H]=$,F[q]=X,H=q);else if(J<I&&0>a(Y,X))F[H]=Y,F[J]=X,H=J;else break e}}return Q}function a(F,Q){var X=F.sortIndex-Q.sortIndex;return X!==0?X:F.id-Q.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=[],h=[],p=1,m=null,g=3,y=!1,w=!1,C=!1,_=!1,S=typeof setTimeout=="function"?setTimeout:null,b=typeof clearTimeout=="function"?clearTimeout:null,v=typeof setImmediate<"u"?setImmediate:null;function k(F){for(var Q=n(h);Q!==null;){if(Q.callback===null)r(h);else if(Q.startTime<=F)r(h),Q.sortIndex=Q.expirationTime,t(d,Q);else break;Q=n(h)}}function T(F){if(C=!1,k(F),!w)if(n(d)!==null)w=!0,N||(N=!0,z());else{var Q=n(h);Q!==null&&U(T,Q.startTime-F)}}var N=!1,R=-1,A=5,O=-1;function P(){return _?!0:!(e.unstable_now()-O<A)}function V(){if(_=!1,N){var F=e.unstable_now();O=F;var Q=!0;try{e:{w=!1,C&&(C=!1,b(R),R=-1),y=!0;var X=g;try{t:{for(k(F),m=n(d);m!==null&&!(m.expirationTime>F&&P());){var H=m.callback;if(typeof H=="function"){m.callback=null,g=m.priorityLevel;var I=H(m.expirationTime<=F);if(F=e.unstable_now(),typeof I=="function"){m.callback=I,k(F),Q=!0;break t}m===n(d)&&r(d),k(F)}else r(d);m=n(d)}if(m!==null)Q=!0;else{var D=n(h);D!==null&&U(T,D.startTime-F),Q=!1}}break e}finally{m=null,g=X,y=!1}Q=void 0}}finally{Q?z():N=!1}}}var z;if(typeof v=="function")z=function(){v(V)};else if(typeof MessageChannel<"u"){var W=new MessageChannel,M=W.port2;W.port1.onmessage=V,z=function(){M.postMessage(null)}}else z=function(){S(V,0)};function U(F,Q){R=S(function(){F(e.unstable_now())},Q)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(F){F.callback=null},e.unstable_forceFrameRate=function(F){0>F||125<F?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):A=0<F?Math.floor(1e3/F):5},e.unstable_getCurrentPriorityLevel=function(){return g},e.unstable_next=function(F){switch(g){case 1:case 2:case 3:var Q=3;break;default:Q=g}var X=g;g=Q;try{return F()}finally{g=X}},e.unstable_requestPaint=function(){_=!0},e.unstable_runWithPriority=function(F,Q){switch(F){case 1:case 2:case 3:case 4:case 5:break;default:F=3}var X=g;g=F;try{return Q()}finally{g=X}},e.unstable_scheduleCallback=function(F,Q,X){var H=e.unstable_now();switch(typeof X=="object"&&X!==null?(X=X.delay,X=typeof X=="number"&&0<X?H+X:H):X=H,F){case 1:var I=-1;break;case 2:I=250;break;case 5:I=1073741823;break;case 4:I=1e4;break;default:I=5e3}return I=X+I,F={id:p++,callback:Q,priorityLevel:F,startTime:X,expirationTime:I,sortIndex:-1},X>H?(F.sortIndex=X,t(h,F),n(d)===null&&F===n(h)&&(C?(b(R),R=-1):C=!0,U(T,X-H))):(F.sortIndex=I,t(d,F),w||y||(w=!0,N||(N=!0,z()))),F},e.unstable_shouldYield=P,e.unstable_wrapCallback=function(F){var Q=g;return function(){var X=g;g=Q;try{return F.apply(this,arguments)}finally{g=X}}}})(sg)),sg}var MS;function rR(){return MS||(MS=1,rg.exports=nR()),rg.exports}var ig={exports:{}},qn={};/**
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 PS;function sR(){if(PS)return qn;PS=1;var e=rf();function t(d){var h="https://react.dev/errors/"+d;if(1<arguments.length){h+="?args[]="+encodeURIComponent(arguments[1]);for(var p=2;p<arguments.length;p++)h+="&args[]="+encodeURIComponent(arguments[p])}return"Minified React error #"+d+"; visit "+h+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var r={d:{f:n,r:function(){throw Error(t(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},a=Symbol.for("react.portal");function l(d,h,p){var m=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:m==null?null:""+m,children:d,containerInfo:h,implementation:p}}var u=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function c(d,h){if(d==="font")return"";if(typeof h=="string")return h==="use-credentials"?h:""}return qn.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=r,qn.createPortal=function(d,h){var p=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!h||h.nodeType!==1&&h.nodeType!==9&&h.nodeType!==11)throw Error(t(299));return l(d,h,null,p)},qn.flushSync=function(d){var h=u.T,p=r.p;try{if(u.T=null,r.p=2,d)return d()}finally{u.T=h,r.p=p,r.d.f()}},qn.preconnect=function(d,h){typeof d=="string"&&(h?(h=h.crossOrigin,h=typeof h=="string"?h==="use-credentials"?h:"":void 0):h=null,r.d.C(d,h))},qn.prefetchDNS=function(d){typeof d=="string"&&r.d.D(d)},qn.preinit=function(d,h){if(typeof d=="string"&&h&&typeof h.as=="string"){var p=h.as,m=c(p,h.crossOrigin),g=typeof h.integrity=="string"?h.integrity:void 0,y=typeof h.fetchPriority=="string"?h.fetchPriority:void 0;p==="style"?r.d.S(d,typeof h.precedence=="string"?h.precedence:void 0,{crossOrigin:m,integrity:g,fetchPriority:y}):p==="script"&&r.d.X(d,{crossOrigin:m,integrity:g,fetchPriority:y,nonce:typeof h.nonce=="string"?h.nonce:void 0})}},qn.preinitModule=function(d,h){if(typeof d=="string")if(typeof h=="object"&&h!==null){if(h.as==null||h.as==="script"){var p=c(h.as,h.crossOrigin);r.d.M(d,{crossOrigin:p,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0})}}else h==null&&r.d.M(d)},qn.preload=function(d,h){if(typeof d=="string"&&typeof h=="object"&&h!==null&&typeof h.as=="string"){var p=h.as,m=c(p,h.crossOrigin);r.d.L(d,p,{crossOrigin:m,integrity:typeof h.integrity=="string"?h.integrity:void 0,nonce:typeof h.nonce=="string"?h.nonce:void 0,type:typeof h.type=="string"?h.type:void 0,fetchPriority:typeof h.fetchPriority=="string"?h.fetchPriority:void 0,referrerPolicy:typeof h.referrerPolicy=="string"?h.referrerPolicy:void 0,imageSrcSet:typeof h.imageSrcSet=="string"?h.imageSrcSet:void 0,imageSizes:typeof h.imageSizes=="string"?h.imageSizes:void 0,media:typeof h.media=="string"?h.media:void 0})}},qn.preloadModule=function(d,h){if(typeof d=="string")if(h){var p=c(h.as,h.crossOrigin);r.d.m(d,{as:typeof h.as=="string"&&h.as!=="script"?h.as:void 0,crossOrigin:p,integrity:typeof h.integrity=="string"?h.integrity:void 0})}else r.d.m(d)},qn.requestFormReset=function(d){r.d.r(d)},qn.unstable_batchedUpdates=function(d,h){return d(h)},qn.useFormState=function(d,h,p){return u.H.useFormState(d,h,p)},qn.useFormStatus=function(){return u.H.useHostTransitionStatus()},qn.version="19.2.8",qn}var BS;function fk(){if(BS)return ig.exports;BS=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(),ig.exports=sR(),ig.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 $S;function iR(){if($S)return fc;$S=1;var e=rR(),t=rf(),n=fk();function r(i){var o="https://react.dev/errors/"+i;if(1<arguments.length){o+="?args[]="+encodeURIComponent(arguments[1]);for(var f=2;f<arguments.length;f++)o+="&args[]="+encodeURIComponent(arguments[f])}return"Minified React error #"+i+"; visit "+o+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function a(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11)}function l(i){var o=i,f=i;if(i.alternate)for(;o.return;)o=o.return;else{i=o;do o=i,(o.flags&4098)!==0&&(f=o.return),i=o.return;while(i)}return o.tag===3?f:null}function u(i){if(i.tag===13){var o=i.memoizedState;if(o===null&&(i=i.alternate,i!==null&&(o=i.memoizedState)),o!==null)return o.dehydrated}return null}function c(i){if(i.tag===31){var o=i.memoizedState;if(o===null&&(i=i.alternate,i!==null&&(o=i.memoizedState)),o!==null)return o.dehydrated}return null}function d(i){if(l(i)!==i)throw Error(r(188))}function h(i){var o=i.alternate;if(!o){if(o=l(i),o===null)throw Error(r(188));return o!==i?null:i}for(var f=i,x=o;;){var j=f.return;if(j===null)break;var L=j.alternate;if(L===null){if(x=j.return,x!==null){f=x;continue}break}if(j.child===L.child){for(L=j.child;L;){if(L===f)return d(j),i;if(L===x)return d(j),o;L=L.sibling}throw Error(r(188))}if(f.return!==x.return)f=j,x=L;else{for(var G=!1,ee=j.child;ee;){if(ee===f){G=!0,f=j,x=L;break}if(ee===x){G=!0,x=j,f=L;break}ee=ee.sibling}if(!G){for(ee=L.child;ee;){if(ee===f){G=!0,f=L,x=j;break}if(ee===x){G=!0,x=L,f=j;break}ee=ee.sibling}if(!G)throw Error(r(189))}}if(f.alternate!==x)throw Error(r(190))}if(f.tag!==3)throw Error(r(188));return f.stateNode.current===f?i:o}function p(i){var o=i.tag;if(o===5||o===26||o===27||o===6)return i;for(i=i.child;i!==null;){if(o=p(i),o!==null)return o;i=i.sibling}return null}var m=Object.assign,g=Symbol.for("react.element"),y=Symbol.for("react.transitional.element"),w=Symbol.for("react.portal"),C=Symbol.for("react.fragment"),_=Symbol.for("react.strict_mode"),S=Symbol.for("react.profiler"),b=Symbol.for("react.consumer"),v=Symbol.for("react.context"),k=Symbol.for("react.forward_ref"),T=Symbol.for("react.suspense"),N=Symbol.for("react.suspense_list"),R=Symbol.for("react.memo"),A=Symbol.for("react.lazy"),O=Symbol.for("react.activity"),P=Symbol.for("react.memo_cache_sentinel"),V=Symbol.iterator;function z(i){return i===null||typeof i!="object"?null:(i=V&&i[V]||i["@@iterator"],typeof i=="function"?i:null)}var W=Symbol.for("react.client.reference");function M(i){if(i==null)return null;if(typeof i=="function")return i.$$typeof===W?null:i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case C:return"Fragment";case S:return"Profiler";case _:return"StrictMode";case T:return"Suspense";case N:return"SuspenseList";case O:return"Activity"}if(typeof i=="object")switch(i.$$typeof){case w:return"Portal";case v:return i.displayName||"Context";case b:return(i._context.displayName||"Context")+".Consumer";case k:var o=i.render;return i=i.displayName,i||(i=o.displayName||o.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case R:return o=i.displayName||null,o!==null?o:M(i.type)||"Memo";case A:o=i._payload,i=i._init;try{return M(i(o))}catch{}}return null}var U=Array.isArray,F=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Q=n.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,X={pending:!1,data:null,method:null,action:null},H=[],I=-1;function D(i){return{current:i}}function q(i){0>I||(i.current=H[I],H[I]=null,I--)}function $(i,o){I++,H[I]=i.current,i.current=o}var J=D(null),Y=D(null),Z=D(null),K=D(null);function B(i,o){switch($(Z,o),$(Y,i),$(J,null),o.nodeType){case 9:case 11:i=(i=o.documentElement)&&(i=i.namespaceURI)?J0(i):0;break;default:if(i=o.tagName,o=o.namespaceURI)o=J0(o),i=Z0(o,i);else switch(i){case"svg":i=1;break;case"math":i=2;break;default:i=0}}q(J),$(J,i)}function ne(){q(J),q(Y),q(Z)}function se(i){i.memoizedState!==null&&$(K,i);var o=J.current,f=Z0(o,i.type);o!==f&&($(Y,i),$(J,f))}function re(i){Y.current===i&&(q(J),q(Y)),K.current===i&&(q(K),lc._currentValue=X)}var oe,ve;function Se(i){if(oe===void 0)try{throw Error()}catch(f){var o=f.stack.trim().match(/\n( *(at )?)/);oe=o&&o[1]||"",ve=-1<f.stack.indexOf(`
43
+ at`)?" (<anonymous>)":-1<f.stack.indexOf("@")?"@unknown:0:0":""}return`
44
+ `+oe+i+ve}var $e=!1;function ze(i,o){if(!i||$e)return"";$e=!0;var f=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var x={DetermineComponentFrameRoot:function(){try{if(o){var Be=function(){throw Error()};if(Object.defineProperty(Be.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Be,[])}catch(Ee){var _e=Ee}Reflect.construct(i,[],Be)}else{try{Be.call()}catch(Ee){_e=Ee}i.call(Be.prototype)}}else{try{throw Error()}catch(Ee){_e=Ee}(Be=i())&&typeof Be.catch=="function"&&Be.catch(function(){})}}catch(Ee){if(Ee&&_e&&typeof Ee.stack=="string")return[Ee.stack,_e.stack]}return[null,null]}};x.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var j=Object.getOwnPropertyDescriptor(x.DetermineComponentFrameRoot,"name");j&&j.configurable&&Object.defineProperty(x.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var L=x.DetermineComponentFrameRoot(),G=L[0],ee=L[1];if(G&&ee){var le=G.split(`
45
+ `),xe=ee.split(`
46
+ `);for(j=x=0;x<le.length&&!le[x].includes("DetermineComponentFrameRoot");)x++;for(;j<xe.length&&!xe[j].includes("DetermineComponentFrameRoot");)j++;if(x===le.length||j===xe.length)for(x=le.length-1,j=xe.length-1;1<=x&&0<=j&&le[x]!==xe[j];)j--;for(;1<=x&&0<=j;x--,j--)if(le[x]!==xe[j]){if(x!==1||j!==1)do if(x--,j--,0>j||le[x]!==xe[j]){var Re=`
47
+ `+le[x].replace(" at new "," at ");return i.displayName&&Re.includes("<anonymous>")&&(Re=Re.replace("<anonymous>",i.displayName)),Re}while(1<=x&&0<=j);break}}}finally{$e=!1,Error.prepareStackTrace=f}return(f=i?i.displayName||i.name:"")?Se(f):""}function ke(i,o){switch(i.tag){case 26:case 27:case 5:return Se(i.type);case 16:return Se("Lazy");case 13:return i.child!==o&&o!==null?Se("Suspense Fallback"):Se("Suspense");case 19:return Se("SuspenseList");case 0:case 15:return ze(i.type,!1);case 11:return ze(i.type.render,!1);case 1:return ze(i.type,!0);case 31:return Se("Activity");default:return""}}function Ge(i){try{var o="",f=null;do o+=ke(i,f),f=i,i=i.return;while(i);return o}catch(x){return`
48
+ Error generating stack: `+x.message+`
49
+ `+x.stack}}var Je=Object.prototype.hasOwnProperty,Ce=e.unstable_scheduleCallback,me=e.unstable_cancelCallback,We=e.unstable_shouldYield,he=e.unstable_requestPaint,Ve=e.unstable_now,He=e.unstable_getCurrentPriorityLevel,ie=e.unstable_ImmediatePriority,ye=e.unstable_UserBlockingPriority,Le=e.unstable_NormalPriority,ue=e.unstable_LowPriority,de=e.unstable_IdlePriority,Fe=e.log,Ue=e.unstable_setDisableYieldValue,Qe=null,rt=null;function pe(i){if(typeof Fe=="function"&&Ue(i),rt&&typeof rt.setStrictMode=="function")try{rt.setStrictMode(Qe,i)}catch{}}var Ie=Math.clz32?Math.clz32:$t,it=Math.log,ut=Math.LN2;function $t(i){return i>>>=0,i===0?32:31-(it(i)/ut|0)|0}var Ut=256,At=262144,Mn=4194304;function _n(i){var o=i&42;if(o!==0)return o;switch(i&-i){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return i&261888;case 262144:case 524288:case 1048576:case 2097152:return i&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return i&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return i}}function dn(i,o,f){var x=i.pendingLanes;if(x===0)return 0;var j=0,L=i.suspendedLanes,G=i.pingedLanes;i=i.warmLanes;var ee=x&134217727;return ee!==0?(x=ee&~L,x!==0?j=_n(x):(G&=ee,G!==0?j=_n(G):f||(f=ee&~i,f!==0&&(j=_n(f))))):(ee=x&~L,ee!==0?j=_n(ee):G!==0?j=_n(G):f||(f=x&~i,f!==0&&(j=_n(f)))),j===0?0:o!==0&&o!==j&&(o&L)===0&&(L=j&-j,f=o&-o,L>=f||L===32&&(f&4194048)!==0)?o:j}function An(i,o){return(i.pendingLanes&~(i.suspendedLanes&~i.pingedLanes)&o)===0}function Sn(i,o){switch(i){case 1:case 2:case 4:case 8:case 64:return o+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 o+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 cn(){var i=Mn;return Mn<<=1,(Mn&62914560)===0&&(Mn=4194304),i}function er(i){for(var o=[],f=0;31>f;f++)o.push(i);return o}function be(i,o){i.pendingLanes|=o,o!==268435456&&(i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0)}function et(i,o,f,x,j,L){var G=i.pendingLanes;i.pendingLanes=f,i.suspendedLanes=0,i.pingedLanes=0,i.warmLanes=0,i.expiredLanes&=f,i.entangledLanes&=f,i.errorRecoveryDisabledLanes&=f,i.shellSuspendCounter=0;var ee=i.entanglements,le=i.expirationTimes,xe=i.hiddenUpdates;for(f=G&~f;0<f;){var Re=31-Ie(f),Be=1<<Re;ee[Re]=0,le[Re]=-1;var _e=xe[Re];if(_e!==null)for(xe[Re]=null,Re=0;Re<_e.length;Re++){var Ee=_e[Re];Ee!==null&&(Ee.lane&=-536870913)}f&=~Be}x!==0&&Ye(i,x,0),L!==0&&j===0&&i.tag!==0&&(i.suspendedLanes|=L&~(G&~o))}function Ye(i,o,f){i.pendingLanes|=o,i.suspendedLanes&=~o;var x=31-Ie(o);i.entangledLanes|=o,i.entanglements[x]=i.entanglements[x]|1073741824|f&261930}function ae(i,o){var f=i.entangledLanes|=o;for(i=i.entanglements;f;){var x=31-Ie(f),j=1<<x;j&o|i[x]&o&&(i[x]|=o),f&=~j}}function Me(i,o){var f=o&-o;return f=(f&42)!==0?1:Ze(f),(f&(i.suspendedLanes|o))!==0?0:f}function Ze(i){switch(i){case 2:i=1;break;case 8:i=4;break;case 32:i=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:i=128;break;case 268435456:i=134217728;break;default:i=0}return i}function Rt(i){return i&=-i,2<i?8<i?(i&134217727)!==0?32:268435456:8:2}function nn(){var i=Q.p;return i!==0?i:(i=window.event,i===void 0?32:SS(i.type))}function Ne(i,o){var f=Q.p;try{return Q.p=i,o()}finally{Q.p=f}}var Te=Math.random().toString(36).slice(2),Pe="__reactFiber$"+Te,Xe="__reactProps$"+Te,tt="__reactContainer$"+Te,mt="__reactEvents$"+Te,_t="__reactListeners$"+Te,Ln="__reactHandles$"+Te,mn="__reactResources$"+Te,wn="__reactMarker$"+Te;function Ja(i){delete i[Pe],delete i[Xe],delete i[mt],delete i[_t],delete i[Ln]}function Za(i){var o=i[Pe];if(o)return o;for(var f=i.parentNode;f;){if(o=f[tt]||f[Pe]){if(f=o.alternate,o.child!==null||f!==null&&f.child!==null)for(i=aS(i);i!==null;){if(f=i[Pe])return f;i=aS(i)}return o}i=f,f=i.parentNode}return null}function eo(i){if(i=i[Pe]||i[tt]){var o=i.tag;if(o===5||o===6||o===13||o===31||o===26||o===27||o===3)return i}return null}function Cl(i){var o=i.tag;if(o===5||o===26||o===27||o===6)return i.stateNode;throw Error(r(33))}function to(i){var o=i[mn];return o||(o=i[mn]={hoistableStyles:new Map,hoistableScripts:new Map}),o}function Pn(i){i[wn]=!0}var zb=new Set,Hb={};function na(i,o){no(i,o),no(i+"Capture",o)}function no(i,o){for(Hb[i]=o,i=0;i<o.length;i++)zb.add(o[i])}var BT=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]*$"),Fb={},Ub={};function $T(i){return Je.call(Ub,i)?!0:Je.call(Fb,i)?!1:BT.test(i)?Ub[i]=!0:(Fb[i]=!0,!1)}function wu(i,o,f){if($T(o))if(f===null)i.removeAttribute(o);else{switch(typeof f){case"undefined":case"function":case"symbol":i.removeAttribute(o);return;case"boolean":var x=o.toLowerCase().slice(0,5);if(x!=="data-"&&x!=="aria-"){i.removeAttribute(o);return}}i.setAttribute(o,""+f)}}function Cu(i,o,f){if(f===null)i.removeAttribute(o);else{switch(typeof f){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(o);return}i.setAttribute(o,""+f)}}function Ds(i,o,f,x){if(x===null)i.removeAttribute(f);else{switch(typeof x){case"undefined":case"function":case"symbol":case"boolean":i.removeAttribute(f);return}i.setAttributeNS(o,f,""+x)}}function Or(i){switch(typeof i){case"bigint":case"boolean":case"number":case"string":case"undefined":return i;case"object":return i;default:return""}}function Vb(i){var o=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(o==="checkbox"||o==="radio")}function zT(i,o,f){var x=Object.getOwnPropertyDescriptor(i.constructor.prototype,o);if(!i.hasOwnProperty(o)&&typeof x<"u"&&typeof x.get=="function"&&typeof x.set=="function"){var j=x.get,L=x.set;return Object.defineProperty(i,o,{configurable:!0,get:function(){return j.call(this)},set:function(G){f=""+G,L.call(this,G)}}),Object.defineProperty(i,o,{enumerable:x.enumerable}),{getValue:function(){return f},setValue:function(G){f=""+G},stopTracking:function(){i._valueTracker=null,delete i[o]}}}}function Wf(i){if(!i._valueTracker){var o=Vb(i)?"checked":"value";i._valueTracker=zT(i,o,""+i[o])}}function Wb(i){if(!i)return!1;var o=i._valueTracker;if(!o)return!0;var f=o.getValue(),x="";return i&&(x=Vb(i)?i.checked?"true":"false":i.value),i=x,i!==f?(o.setValue(i),!0):!1}function ku(i){if(i=i||(typeof document<"u"?document:void 0),typeof i>"u")return null;try{return i.activeElement||i.body}catch{return i.body}}var HT=/[\n"\\]/g;function Ir(i){return i.replace(HT,function(o){return"\\"+o.charCodeAt(0).toString(16)+" "})}function Gf(i,o,f,x,j,L,G,ee){i.name="",G!=null&&typeof G!="function"&&typeof G!="symbol"&&typeof G!="boolean"?i.type=G:i.removeAttribute("type"),o!=null?G==="number"?(o===0&&i.value===""||i.value!=o)&&(i.value=""+Or(o)):i.value!==""+Or(o)&&(i.value=""+Or(o)):G!=="submit"&&G!=="reset"||i.removeAttribute("value"),o!=null?qf(i,G,Or(o)):f!=null?qf(i,G,Or(f)):x!=null&&i.removeAttribute("value"),j==null&&L!=null&&(i.defaultChecked=!!L),j!=null&&(i.checked=j&&typeof j!="function"&&typeof j!="symbol"),ee!=null&&typeof ee!="function"&&typeof ee!="symbol"&&typeof ee!="boolean"?i.name=""+Or(ee):i.removeAttribute("name")}function Gb(i,o,f,x,j,L,G,ee){if(L!=null&&typeof L!="function"&&typeof L!="symbol"&&typeof L!="boolean"&&(i.type=L),o!=null||f!=null){if(!(L!=="submit"&&L!=="reset"||o!=null)){Wf(i);return}f=f!=null?""+Or(f):"",o=o!=null?""+Or(o):f,ee||o===i.value||(i.value=o),i.defaultValue=o}x=x??j,x=typeof x!="function"&&typeof x!="symbol"&&!!x,i.checked=ee?i.checked:!!x,i.defaultChecked=!!x,G!=null&&typeof G!="function"&&typeof G!="symbol"&&typeof G!="boolean"&&(i.name=G),Wf(i)}function qf(i,o,f){o==="number"&&ku(i.ownerDocument)===i||i.defaultValue===""+f||(i.defaultValue=""+f)}function ro(i,o,f,x){if(i=i.options,o){o={};for(var j=0;j<f.length;j++)o["$"+f[j]]=!0;for(f=0;f<i.length;f++)j=o.hasOwnProperty("$"+i[f].value),i[f].selected!==j&&(i[f].selected=j),j&&x&&(i[f].defaultSelected=!0)}else{for(f=""+Or(f),o=null,j=0;j<i.length;j++){if(i[j].value===f){i[j].selected=!0,x&&(i[j].defaultSelected=!0);return}o!==null||i[j].disabled||(o=i[j])}o!==null&&(o.selected=!0)}}function qb(i,o,f){if(o!=null&&(o=""+Or(o),o!==i.value&&(i.value=o),f==null)){i.defaultValue!==o&&(i.defaultValue=o);return}i.defaultValue=f!=null?""+Or(f):""}function Kb(i,o,f,x){if(o==null){if(x!=null){if(f!=null)throw Error(r(92));if(U(x)){if(1<x.length)throw Error(r(93));x=x[0]}f=x}f==null&&(f=""),o=f}f=Or(o),i.defaultValue=f,x=i.textContent,x===f&&x!==""&&x!==null&&(i.value=x),Wf(i)}function so(i,o){if(o){var f=i.firstChild;if(f&&f===i.lastChild&&f.nodeType===3){f.nodeValue=o;return}}i.textContent=o}var FT=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 Yb(i,o,f){var x=o.indexOf("--")===0;f==null||typeof f=="boolean"||f===""?x?i.setProperty(o,""):o==="float"?i.cssFloat="":i[o]="":x?i.setProperty(o,f):typeof f!="number"||f===0||FT.has(o)?o==="float"?i.cssFloat=f:i[o]=(""+f).trim():i[o]=f+"px"}function Xb(i,o,f){if(o!=null&&typeof o!="object")throw Error(r(62));if(i=i.style,f!=null){for(var x in f)!f.hasOwnProperty(x)||o!=null&&o.hasOwnProperty(x)||(x.indexOf("--")===0?i.setProperty(x,""):x==="float"?i.cssFloat="":i[x]="");for(var j in o)x=o[j],o.hasOwnProperty(j)&&f[j]!==x&&Yb(i,j,x)}else for(var L in o)o.hasOwnProperty(L)&&Yb(i,L,o[L])}function Kf(i){if(i.indexOf("-")===-1)return!1;switch(i){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var UT=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"]]),VT=/^[\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 Eu(i){return VT.test(""+i)?"javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')":i}function Os(){}var Yf=null;function Xf(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var io=null,ao=null;function Qb(i){var o=eo(i);if(o&&(i=o.stateNode)){var f=i[Xe]||null;e:switch(i=o.stateNode,o.type){case"input":if(Gf(i,f.value,f.defaultValue,f.defaultValue,f.checked,f.defaultChecked,f.type,f.name),o=f.name,f.type==="radio"&&o!=null){for(f=i;f.parentNode;)f=f.parentNode;for(f=f.querySelectorAll('input[name="'+Ir(""+o)+'"][type="radio"]'),o=0;o<f.length;o++){var x=f[o];if(x!==i&&x.form===i.form){var j=x[Xe]||null;if(!j)throw Error(r(90));Gf(x,j.value,j.defaultValue,j.defaultValue,j.checked,j.defaultChecked,j.type,j.name)}}for(o=0;o<f.length;o++)x=f[o],x.form===i.form&&Wb(x)}break e;case"textarea":qb(i,f.value,f.defaultValue);break e;case"select":o=f.value,o!=null&&ro(i,!!f.multiple,o,!1)}}}var Qf=!1;function Jb(i,o,f){if(Qf)return i(o,f);Qf=!0;try{var x=i(o);return x}finally{if(Qf=!1,(io!==null||ao!==null)&&(fd(),io&&(o=io,i=ao,ao=io=null,Qb(o),i)))for(o=0;o<i.length;o++)Qb(i[o])}}function kl(i,o){var f=i.stateNode;if(f===null)return null;var x=f[Xe]||null;if(x===null)return null;f=x[o];e:switch(o){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(x=!x.disabled)||(i=i.type,x=!(i==="button"||i==="input"||i==="select"||i==="textarea")),i=!x;break e;default:i=!1}if(i)return null;if(f&&typeof f!="function")throw Error(r(231,o,typeof f));return f}var Is=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Jf=!1;if(Is)try{var El={};Object.defineProperty(El,"passive",{get:function(){Jf=!0}}),window.addEventListener("test",El,El),window.removeEventListener("test",El,El)}catch{Jf=!1}var hi=null,Zf=null,ju=null;function Zb(){if(ju)return ju;var i,o=Zf,f=o.length,x,j="value"in hi?hi.value:hi.textContent,L=j.length;for(i=0;i<f&&o[i]===j[i];i++);var G=f-i;for(x=1;x<=G&&o[f-x]===j[L-x];x++);return ju=j.slice(i,1<x?1-x:void 0)}function Nu(i){var o=i.keyCode;return"charCode"in i?(i=i.charCode,i===0&&o===13&&(i=13)):i=o,i===10&&(i=13),32<=i||i===13?i:0}function Tu(){return!0}function ev(){return!1}function ar(i){function o(f,x,j,L,G){this._reactName=f,this._targetInst=j,this.type=x,this.nativeEvent=L,this.target=G,this.currentTarget=null;for(var ee in i)i.hasOwnProperty(ee)&&(f=i[ee],this[ee]=f?f(L):L[ee]);return this.isDefaultPrevented=(L.defaultPrevented!=null?L.defaultPrevented:L.returnValue===!1)?Tu:ev,this.isPropagationStopped=ev,this}return m(o.prototype,{preventDefault:function(){this.defaultPrevented=!0;var f=this.nativeEvent;f&&(f.preventDefault?f.preventDefault():typeof f.returnValue!="unknown"&&(f.returnValue=!1),this.isDefaultPrevented=Tu)},stopPropagation:function(){var f=this.nativeEvent;f&&(f.stopPropagation?f.stopPropagation():typeof f.cancelBubble!="unknown"&&(f.cancelBubble=!0),this.isPropagationStopped=Tu)},persist:function(){},isPersistent:Tu}),o}var ra={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Au=ar(ra),jl=m({},ra,{view:0,detail:0}),WT=ar(jl),em,tm,Nl,Lu=m({},jl,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:rm,button:0,buttons:0,relatedTarget:function(i){return i.relatedTarget===void 0?i.fromElement===i.srcElement?i.toElement:i.fromElement:i.relatedTarget},movementX:function(i){return"movementX"in i?i.movementX:(i!==Nl&&(Nl&&i.type==="mousemove"?(em=i.screenX-Nl.screenX,tm=i.screenY-Nl.screenY):tm=em=0,Nl=i),em)},movementY:function(i){return"movementY"in i?i.movementY:tm}}),tv=ar(Lu),GT=m({},Lu,{dataTransfer:0}),qT=ar(GT),KT=m({},jl,{relatedTarget:0}),nm=ar(KT),YT=m({},ra,{animationName:0,elapsedTime:0,pseudoElement:0}),XT=ar(YT),QT=m({},ra,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),JT=ar(QT),ZT=m({},ra,{data:0}),nv=ar(ZT),eA={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},tA={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"},nA={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function rA(i){var o=this.nativeEvent;return o.getModifierState?o.getModifierState(i):(i=nA[i])?!!o[i]:!1}function rm(){return rA}var sA=m({},jl,{key:function(i){if(i.key){var o=eA[i.key]||i.key;if(o!=="Unidentified")return o}return i.type==="keypress"?(i=Nu(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?tA[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:rm,charCode:function(i){return i.type==="keypress"?Nu(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?Nu(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),iA=ar(sA),aA=m({},Lu,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),rv=ar(aA),oA=m({},jl,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:rm}),lA=ar(oA),cA=m({},ra,{propertyName:0,elapsedTime:0,pseudoElement:0}),uA=ar(cA),dA=m({},Lu,{deltaX:function(i){return"deltaX"in i?i.deltaX:"wheelDeltaX"in i?-i.wheelDeltaX:0},deltaY:function(i){return"deltaY"in i?i.deltaY:"wheelDeltaY"in i?-i.wheelDeltaY:"wheelDelta"in i?-i.wheelDelta:0},deltaZ:0,deltaMode:0}),hA=ar(dA),fA=m({},ra,{newState:0,oldState:0}),mA=ar(fA),pA=[9,13,27,32],sm=Is&&"CompositionEvent"in window,Tl=null;Is&&"documentMode"in document&&(Tl=document.documentMode);var gA=Is&&"TextEvent"in window&&!Tl,sv=Is&&(!sm||Tl&&8<Tl&&11>=Tl),iv=" ",av=!1;function ov(i,o){switch(i){case"keyup":return pA.indexOf(o.keyCode)!==-1;case"keydown":return o.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function lv(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var oo=!1;function xA(i,o){switch(i){case"compositionend":return lv(o);case"keypress":return o.which!==32?null:(av=!0,iv);case"textInput":return i=o.data,i===iv&&av?null:i;default:return null}}function yA(i,o){if(oo)return i==="compositionend"||!sm&&ov(i,o)?(i=Zb(),ju=Zf=hi=null,oo=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(o.ctrlKey||o.altKey||o.metaKey)||o.ctrlKey&&o.altKey){if(o.char&&1<o.char.length)return o.char;if(o.which)return String.fromCharCode(o.which)}return null;case"compositionend":return sv&&o.locale!=="ko"?null:o.data;default:return null}}var bA={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 cv(i){var o=i&&i.nodeName&&i.nodeName.toLowerCase();return o==="input"?!!bA[i.type]:o==="textarea"}function uv(i,o,f,x){io?ao?ao.push(x):ao=[x]:io=x,o=vd(o,"onChange"),0<o.length&&(f=new Au("onChange","change",null,f,x),i.push({event:f,listeners:o}))}var Al=null,Ll=null;function vA(i){G0(i,0)}function Ru(i){var o=Cl(i);if(Wb(o))return i}function dv(i,o){if(i==="change")return o}var hv=!1;if(Is){var im;if(Is){var am="oninput"in document;if(!am){var fv=document.createElement("div");fv.setAttribute("oninput","return;"),am=typeof fv.oninput=="function"}im=am}else im=!1;hv=im&&(!document.documentMode||9<document.documentMode)}function mv(){Al&&(Al.detachEvent("onpropertychange",pv),Ll=Al=null)}function pv(i){if(i.propertyName==="value"&&Ru(Ll)){var o=[];uv(o,Ll,i,Xf(i)),Jb(vA,o)}}function _A(i,o,f){i==="focusin"?(mv(),Al=o,Ll=f,Al.attachEvent("onpropertychange",pv)):i==="focusout"&&mv()}function SA(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return Ru(Ll)}function wA(i,o){if(i==="click")return Ru(o)}function CA(i,o){if(i==="input"||i==="change")return Ru(o)}function kA(i,o){return i===o&&(i!==0||1/i===1/o)||i!==i&&o!==o}var vr=typeof Object.is=="function"?Object.is:kA;function Rl(i,o){if(vr(i,o))return!0;if(typeof i!="object"||i===null||typeof o!="object"||o===null)return!1;var f=Object.keys(i),x=Object.keys(o);if(f.length!==x.length)return!1;for(x=0;x<f.length;x++){var j=f[x];if(!Je.call(o,j)||!vr(i[j],o[j]))return!1}return!0}function gv(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function xv(i,o){var f=gv(i);i=0;for(var x;f;){if(f.nodeType===3){if(x=i+f.textContent.length,i<=o&&x>=o)return{node:f,offset:o-i};i=x}e:{for(;f;){if(f.nextSibling){f=f.nextSibling;break e}f=f.parentNode}f=void 0}f=gv(f)}}function yv(i,o){return i&&o?i===o?!0:i&&i.nodeType===3?!1:o&&o.nodeType===3?yv(i,o.parentNode):"contains"in i?i.contains(o):i.compareDocumentPosition?!!(i.compareDocumentPosition(o)&16):!1:!1}function bv(i){i=i!=null&&i.ownerDocument!=null&&i.ownerDocument.defaultView!=null?i.ownerDocument.defaultView:window;for(var o=ku(i.document);o instanceof i.HTMLIFrameElement;){try{var f=typeof o.contentWindow.location.href=="string"}catch{f=!1}if(f)i=o.contentWindow;else break;o=ku(i.document)}return o}function om(i){var o=i&&i.nodeName&&i.nodeName.toLowerCase();return o&&(o==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||o==="textarea"||i.contentEditable==="true")}var EA=Is&&"documentMode"in document&&11>=document.documentMode,lo=null,lm=null,Dl=null,cm=!1;function vv(i,o,f){var x=f.window===f?f.document:f.nodeType===9?f:f.ownerDocument;cm||lo==null||lo!==ku(x)||(x=lo,"selectionStart"in x&&om(x)?x={start:x.selectionStart,end:x.selectionEnd}:(x=(x.ownerDocument&&x.ownerDocument.defaultView||window).getSelection(),x={anchorNode:x.anchorNode,anchorOffset:x.anchorOffset,focusNode:x.focusNode,focusOffset:x.focusOffset}),Dl&&Rl(Dl,x)||(Dl=x,x=vd(lm,"onSelect"),0<x.length&&(o=new Au("onSelect","select",null,o,f),i.push({event:o,listeners:x}),o.target=lo)))}function sa(i,o){var f={};return f[i.toLowerCase()]=o.toLowerCase(),f["Webkit"+i]="webkit"+o,f["Moz"+i]="moz"+o,f}var co={animationend:sa("Animation","AnimationEnd"),animationiteration:sa("Animation","AnimationIteration"),animationstart:sa("Animation","AnimationStart"),transitionrun:sa("Transition","TransitionRun"),transitionstart:sa("Transition","TransitionStart"),transitioncancel:sa("Transition","TransitionCancel"),transitionend:sa("Transition","TransitionEnd")},um={},_v={};Is&&(_v=document.createElement("div").style,"AnimationEvent"in window||(delete co.animationend.animation,delete co.animationiteration.animation,delete co.animationstart.animation),"TransitionEvent"in window||delete co.transitionend.transition);function ia(i){if(um[i])return um[i];if(!co[i])return i;var o=co[i],f;for(f in o)if(o.hasOwnProperty(f)&&f in _v)return um[i]=o[f];return i}var Sv=ia("animationend"),wv=ia("animationiteration"),Cv=ia("animationstart"),jA=ia("transitionrun"),NA=ia("transitionstart"),TA=ia("transitioncancel"),kv=ia("transitionend"),Ev=new Map,dm="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(" ");dm.push("scrollEnd");function Zr(i,o){Ev.set(i,o),na(o,[i])}var Du=typeof reportError=="function"?reportError:function(i){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var o=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof i=="object"&&i!==null&&typeof i.message=="string"?String(i.message):String(i),error:i});if(!window.dispatchEvent(o))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",i);return}console.error(i)},Mr=[],uo=0,hm=0;function Ou(){for(var i=uo,o=hm=uo=0;o<i;){var f=Mr[o];Mr[o++]=null;var x=Mr[o];Mr[o++]=null;var j=Mr[o];Mr[o++]=null;var L=Mr[o];if(Mr[o++]=null,x!==null&&j!==null){var G=x.pending;G===null?j.next=j:(j.next=G.next,G.next=j),x.pending=j}L!==0&&jv(f,j,L)}}function Iu(i,o,f,x){Mr[uo++]=i,Mr[uo++]=o,Mr[uo++]=f,Mr[uo++]=x,hm|=x,i.lanes|=x,i=i.alternate,i!==null&&(i.lanes|=x)}function fm(i,o,f,x){return Iu(i,o,f,x),Mu(i)}function aa(i,o){return Iu(i,null,null,o),Mu(i)}function jv(i,o,f){i.lanes|=f;var x=i.alternate;x!==null&&(x.lanes|=f);for(var j=!1,L=i.return;L!==null;)L.childLanes|=f,x=L.alternate,x!==null&&(x.childLanes|=f),L.tag===22&&(i=L.stateNode,i===null||i._visibility&1||(j=!0)),i=L,L=L.return;return i.tag===3?(L=i.stateNode,j&&o!==null&&(j=31-Ie(f),i=L.hiddenUpdates,x=i[j],x===null?i[j]=[o]:x.push(o),o.lane=f|536870912),L):null}function Mu(i){if(50<tc)throw tc=0,Sp=null,Error(r(185));for(var o=i.return;o!==null;)i=o,o=i.return;return i.tag===3?i.stateNode:null}var ho={};function AA(i,o,f,x){this.tag=i,this.key=f,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=o,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=x,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function _r(i,o,f,x){return new AA(i,o,f,x)}function mm(i){return i=i.prototype,!(!i||!i.isReactComponent)}function Ms(i,o){var f=i.alternate;return f===null?(f=_r(i.tag,o,i.key,i.mode),f.elementType=i.elementType,f.type=i.type,f.stateNode=i.stateNode,f.alternate=i,i.alternate=f):(f.pendingProps=o,f.type=i.type,f.flags=0,f.subtreeFlags=0,f.deletions=null),f.flags=i.flags&65011712,f.childLanes=i.childLanes,f.lanes=i.lanes,f.child=i.child,f.memoizedProps=i.memoizedProps,f.memoizedState=i.memoizedState,f.updateQueue=i.updateQueue,o=i.dependencies,f.dependencies=o===null?null:{lanes:o.lanes,firstContext:o.firstContext},f.sibling=i.sibling,f.index=i.index,f.ref=i.ref,f.refCleanup=i.refCleanup,f}function Nv(i,o){i.flags&=65011714;var f=i.alternate;return f===null?(i.childLanes=0,i.lanes=o,i.child=null,i.subtreeFlags=0,i.memoizedProps=null,i.memoizedState=null,i.updateQueue=null,i.dependencies=null,i.stateNode=null):(i.childLanes=f.childLanes,i.lanes=f.lanes,i.child=f.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=f.memoizedProps,i.memoizedState=f.memoizedState,i.updateQueue=f.updateQueue,i.type=f.type,o=f.dependencies,i.dependencies=o===null?null:{lanes:o.lanes,firstContext:o.firstContext}),i}function Pu(i,o,f,x,j,L){var G=0;if(x=i,typeof i=="function")mm(i)&&(G=1);else if(typeof i=="string")G=IL(i,f,J.current)?26:i==="html"||i==="head"||i==="body"?27:5;else e:switch(i){case O:return i=_r(31,f,o,j),i.elementType=O,i.lanes=L,i;case C:return oa(f.children,j,L,o);case _:G=8,j|=24;break;case S:return i=_r(12,f,o,j|2),i.elementType=S,i.lanes=L,i;case T:return i=_r(13,f,o,j),i.elementType=T,i.lanes=L,i;case N:return i=_r(19,f,o,j),i.elementType=N,i.lanes=L,i;default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case v:G=10;break e;case b:G=9;break e;case k:G=11;break e;case R:G=14;break e;case A:G=16,x=null;break e}G=29,f=Error(r(130,i===null?"null":typeof i,"")),x=null}return o=_r(G,f,o,j),o.elementType=i,o.type=x,o.lanes=L,o}function oa(i,o,f,x){return i=_r(7,i,x,o),i.lanes=f,i}function pm(i,o,f){return i=_r(6,i,null,o),i.lanes=f,i}function Tv(i){var o=_r(18,null,null,0);return o.stateNode=i,o}function gm(i,o,f){return o=_r(4,i.children!==null?i.children:[],i.key,o),o.lanes=f,o.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},o}var Av=new WeakMap;function Pr(i,o){if(typeof i=="object"&&i!==null){var f=Av.get(i);return f!==void 0?f:(o={value:i,source:o,stack:Ge(o)},Av.set(i,o),o)}return{value:i,source:o,stack:Ge(o)}}var fo=[],mo=0,Bu=null,Ol=0,Br=[],$r=0,fi=null,ms=1,ps="";function Ps(i,o){fo[mo++]=Ol,fo[mo++]=Bu,Bu=i,Ol=o}function Lv(i,o,f){Br[$r++]=ms,Br[$r++]=ps,Br[$r++]=fi,fi=i;var x=ms;i=ps;var j=32-Ie(x)-1;x&=~(1<<j),f+=1;var L=32-Ie(o)+j;if(30<L){var G=j-j%5;L=(x&(1<<G)-1).toString(32),x>>=G,j-=G,ms=1<<32-Ie(o)+j|f<<j|x,ps=L+i}else ms=1<<L|f<<j|x,ps=i}function xm(i){i.return!==null&&(Ps(i,1),Lv(i,1,0))}function ym(i){for(;i===Bu;)Bu=fo[--mo],fo[mo]=null,Ol=fo[--mo],fo[mo]=null;for(;i===fi;)fi=Br[--$r],Br[$r]=null,ps=Br[--$r],Br[$r]=null,ms=Br[--$r],Br[$r]=null}function Rv(i,o){Br[$r++]=ms,Br[$r++]=ps,Br[$r++]=fi,ms=o.id,ps=o.overflow,fi=i}var Fn=null,rn=null,Nt=!1,mi=null,zr=!1,bm=Error(r(519));function pi(i){var o=Error(r(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?"text":"HTML",""));throw Il(Pr(o,i)),bm}function Dv(i){var o=i.stateNode,f=i.type,x=i.memoizedProps;switch(o[Pe]=i,o[Xe]=x,f){case"dialog":wt("cancel",o),wt("close",o);break;case"iframe":case"object":case"embed":wt("load",o);break;case"video":case"audio":for(f=0;f<rc.length;f++)wt(rc[f],o);break;case"source":wt("error",o);break;case"img":case"image":case"link":wt("error",o),wt("load",o);break;case"details":wt("toggle",o);break;case"input":wt("invalid",o),Gb(o,x.value,x.defaultValue,x.checked,x.defaultChecked,x.type,x.name,!0);break;case"select":wt("invalid",o);break;case"textarea":wt("invalid",o),Kb(o,x.value,x.defaultValue,x.children)}f=x.children,typeof f!="string"&&typeof f!="number"&&typeof f!="bigint"||o.textContent===""+f||x.suppressHydrationWarning===!0||X0(o.textContent,f)?(x.popover!=null&&(wt("beforetoggle",o),wt("toggle",o)),x.onScroll!=null&&wt("scroll",o),x.onScrollEnd!=null&&wt("scrollend",o),x.onClick!=null&&(o.onclick=Os),o=!0):o=!1,o||pi(i,!0)}function Ov(i){for(Fn=i.return;Fn;)switch(Fn.tag){case 5:case 31:case 13:zr=!1;return;case 27:case 3:zr=!0;return;default:Fn=Fn.return}}function po(i){if(i!==Fn)return!1;if(!Nt)return Ov(i),Nt=!0,!1;var o=i.tag,f;if((f=o!==3&&o!==27)&&((f=o===5)&&(f=i.type,f=!(f!=="form"&&f!=="button")||Pp(i.type,i.memoizedProps)),f=!f),f&&rn&&pi(i),Ov(i),o===13){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(317));rn=iS(i)}else if(o===31){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(317));rn=iS(i)}else o===27?(o=rn,Ti(i.type)?(i=Fp,Fp=null,rn=i):rn=o):rn=Fn?Fr(i.stateNode.nextSibling):null;return!0}function la(){rn=Fn=null,Nt=!1}function vm(){var i=mi;return i!==null&&(ur===null?ur=i:ur.push.apply(ur,i),mi=null),i}function Il(i){mi===null?mi=[i]:mi.push(i)}var _m=D(null),ca=null,Bs=null;function gi(i,o,f){$(_m,o._currentValue),o._currentValue=f}function $s(i){i._currentValue=_m.current,q(_m)}function Sm(i,o,f){for(;i!==null;){var x=i.alternate;if((i.childLanes&o)!==o?(i.childLanes|=o,x!==null&&(x.childLanes|=o)):x!==null&&(x.childLanes&o)!==o&&(x.childLanes|=o),i===f)break;i=i.return}}function wm(i,o,f,x){var j=i.child;for(j!==null&&(j.return=i);j!==null;){var L=j.dependencies;if(L!==null){var G=j.child;L=L.firstContext;e:for(;L!==null;){var ee=L;L=j;for(var le=0;le<o.length;le++)if(ee.context===o[le]){L.lanes|=f,ee=L.alternate,ee!==null&&(ee.lanes|=f),Sm(L.return,f,i),x||(G=null);break e}L=ee.next}}else if(j.tag===18){if(G=j.return,G===null)throw Error(r(341));G.lanes|=f,L=G.alternate,L!==null&&(L.lanes|=f),Sm(G,f,i),G=null}else G=j.child;if(G!==null)G.return=j;else for(G=j;G!==null;){if(G===i){G=null;break}if(j=G.sibling,j!==null){j.return=G.return,G=j;break}G=G.return}j=G}}function go(i,o,f,x){i=null;for(var j=o,L=!1;j!==null;){if(!L){if((j.flags&524288)!==0)L=!0;else if((j.flags&262144)!==0)break}if(j.tag===10){var G=j.alternate;if(G===null)throw Error(r(387));if(G=G.memoizedProps,G!==null){var ee=j.type;vr(j.pendingProps.value,G.value)||(i!==null?i.push(ee):i=[ee])}}else if(j===K.current){if(G=j.alternate,G===null)throw Error(r(387));G.memoizedState.memoizedState!==j.memoizedState.memoizedState&&(i!==null?i.push(lc):i=[lc])}j=j.return}i!==null&&wm(o,i,f,x),o.flags|=262144}function $u(i){for(i=i.firstContext;i!==null;){if(!vr(i.context._currentValue,i.memoizedValue))return!0;i=i.next}return!1}function ua(i){ca=i,Bs=null,i=i.dependencies,i!==null&&(i.firstContext=null)}function Un(i){return Iv(ca,i)}function zu(i,o){return ca===null&&ua(i),Iv(i,o)}function Iv(i,o){var f=o._currentValue;if(o={context:o,memoizedValue:f,next:null},Bs===null){if(i===null)throw Error(r(308));Bs=o,i.dependencies={lanes:0,firstContext:o},i.flags|=524288}else Bs=Bs.next=o;return f}var LA=typeof AbortController<"u"?AbortController:function(){var i=[],o=this.signal={aborted:!1,addEventListener:function(f,x){i.push(x)}};this.abort=function(){o.aborted=!0,i.forEach(function(f){return f()})}},RA=e.unstable_scheduleCallback,DA=e.unstable_NormalPriority,Cn={$$typeof:v,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function Cm(){return{controller:new LA,data:new Map,refCount:0}}function Ml(i){i.refCount--,i.refCount===0&&RA(DA,function(){i.controller.abort()})}var Pl=null,km=0,xo=0,yo=null;function OA(i,o){if(Pl===null){var f=Pl=[];km=0,xo=Np(),yo={status:"pending",value:void 0,then:function(x){f.push(x)}}}return km++,o.then(Mv,Mv),o}function Mv(){if(--km===0&&Pl!==null){yo!==null&&(yo.status="fulfilled");var i=Pl;Pl=null,xo=0,yo=null;for(var o=0;o<i.length;o++)(0,i[o])()}}function IA(i,o){var f=[],x={status:"pending",value:null,reason:null,then:function(j){f.push(j)}};return i.then(function(){x.status="fulfilled",x.value=o;for(var j=0;j<f.length;j++)(0,f[j])(o)},function(j){for(x.status="rejected",x.reason=j,j=0;j<f.length;j++)(0,f[j])(void 0)}),x}var Pv=F.S;F.S=function(i,o){v0=Ve(),typeof o=="object"&&o!==null&&typeof o.then=="function"&&OA(i,o),Pv!==null&&Pv(i,o)};var da=D(null);function Em(){var i=da.current;return i!==null?i:Yt.pooledCache}function Hu(i,o){o===null?$(da,da.current):$(da,o.pool)}function Bv(){var i=Em();return i===null?null:{parent:Cn._currentValue,pool:i}}var bo=Error(r(460)),jm=Error(r(474)),Fu=Error(r(542)),Uu={then:function(){}};function $v(i){return i=i.status,i==="fulfilled"||i==="rejected"}function zv(i,o,f){switch(f=i[f],f===void 0?i.push(o):f!==o&&(o.then(Os,Os),o=f),o.status){case"fulfilled":return o.value;case"rejected":throw i=o.reason,Fv(i),i;default:if(typeof o.status=="string")o.then(Os,Os);else{if(i=Yt,i!==null&&100<i.shellSuspendCounter)throw Error(r(482));i=o,i.status="pending",i.then(function(x){if(o.status==="pending"){var j=o;j.status="fulfilled",j.value=x}},function(x){if(o.status==="pending"){var j=o;j.status="rejected",j.reason=x}})}switch(o.status){case"fulfilled":return o.value;case"rejected":throw i=o.reason,Fv(i),i}throw fa=o,bo}}function ha(i){try{var o=i._init;return o(i._payload)}catch(f){throw f!==null&&typeof f=="object"&&typeof f.then=="function"?(fa=f,bo):f}}var fa=null;function Hv(){if(fa===null)throw Error(r(459));var i=fa;return fa=null,i}function Fv(i){if(i===bo||i===Fu)throw Error(r(483))}var vo=null,Bl=0;function Vu(i){var o=Bl;return Bl+=1,vo===null&&(vo=[]),zv(vo,i,o)}function $l(i,o){o=o.props.ref,i.ref=o!==void 0?o:null}function Wu(i,o){throw o.$$typeof===g?Error(r(525)):(i=Object.prototype.toString.call(o),Error(r(31,i==="[object Object]"?"object with keys {"+Object.keys(o).join(", ")+"}":i)))}function Uv(i){function o(fe,ce){if(i){var ge=fe.deletions;ge===null?(fe.deletions=[ce],fe.flags|=16):ge.push(ce)}}function f(fe,ce){if(!i)return null;for(;ce!==null;)o(fe,ce),ce=ce.sibling;return null}function x(fe){for(var ce=new Map;fe!==null;)fe.key!==null?ce.set(fe.key,fe):ce.set(fe.index,fe),fe=fe.sibling;return ce}function j(fe,ce){return fe=Ms(fe,ce),fe.index=0,fe.sibling=null,fe}function L(fe,ce,ge){return fe.index=ge,i?(ge=fe.alternate,ge!==null?(ge=ge.index,ge<ce?(fe.flags|=67108866,ce):ge):(fe.flags|=67108866,ce)):(fe.flags|=1048576,ce)}function G(fe){return i&&fe.alternate===null&&(fe.flags|=67108866),fe}function ee(fe,ce,ge,Oe){return ce===null||ce.tag!==6?(ce=pm(ge,fe.mode,Oe),ce.return=fe,ce):(ce=j(ce,ge),ce.return=fe,ce)}function le(fe,ce,ge,Oe){var at=ge.type;return at===C?Re(fe,ce,ge.props.children,Oe,ge.key):ce!==null&&(ce.elementType===at||typeof at=="object"&&at!==null&&at.$$typeof===A&&ha(at)===ce.type)?(ce=j(ce,ge.props),$l(ce,ge),ce.return=fe,ce):(ce=Pu(ge.type,ge.key,ge.props,null,fe.mode,Oe),$l(ce,ge),ce.return=fe,ce)}function xe(fe,ce,ge,Oe){return ce===null||ce.tag!==4||ce.stateNode.containerInfo!==ge.containerInfo||ce.stateNode.implementation!==ge.implementation?(ce=gm(ge,fe.mode,Oe),ce.return=fe,ce):(ce=j(ce,ge.children||[]),ce.return=fe,ce)}function Re(fe,ce,ge,Oe,at){return ce===null||ce.tag!==7?(ce=oa(ge,fe.mode,Oe,at),ce.return=fe,ce):(ce=j(ce,ge),ce.return=fe,ce)}function Be(fe,ce,ge){if(typeof ce=="string"&&ce!==""||typeof ce=="number"||typeof ce=="bigint")return ce=pm(""+ce,fe.mode,ge),ce.return=fe,ce;if(typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case y:return ge=Pu(ce.type,ce.key,ce.props,null,fe.mode,ge),$l(ge,ce),ge.return=fe,ge;case w:return ce=gm(ce,fe.mode,ge),ce.return=fe,ce;case A:return ce=ha(ce),Be(fe,ce,ge)}if(U(ce)||z(ce))return ce=oa(ce,fe.mode,ge,null),ce.return=fe,ce;if(typeof ce.then=="function")return Be(fe,Vu(ce),ge);if(ce.$$typeof===v)return Be(fe,zu(fe,ce),ge);Wu(fe,ce)}return null}function _e(fe,ce,ge,Oe){var at=ce!==null?ce.key:null;if(typeof ge=="string"&&ge!==""||typeof ge=="number"||typeof ge=="bigint")return at!==null?null:ee(fe,ce,""+ge,Oe);if(typeof ge=="object"&&ge!==null){switch(ge.$$typeof){case y:return ge.key===at?le(fe,ce,ge,Oe):null;case w:return ge.key===at?xe(fe,ce,ge,Oe):null;case A:return ge=ha(ge),_e(fe,ce,ge,Oe)}if(U(ge)||z(ge))return at!==null?null:Re(fe,ce,ge,Oe,null);if(typeof ge.then=="function")return _e(fe,ce,Vu(ge),Oe);if(ge.$$typeof===v)return _e(fe,ce,zu(fe,ge),Oe);Wu(fe,ge)}return null}function Ee(fe,ce,ge,Oe,at){if(typeof Oe=="string"&&Oe!==""||typeof Oe=="number"||typeof Oe=="bigint")return fe=fe.get(ge)||null,ee(ce,fe,""+Oe,at);if(typeof Oe=="object"&&Oe!==null){switch(Oe.$$typeof){case y:return fe=fe.get(Oe.key===null?ge:Oe.key)||null,le(ce,fe,Oe,at);case w:return fe=fe.get(Oe.key===null?ge:Oe.key)||null,xe(ce,fe,Oe,at);case A:return Oe=ha(Oe),Ee(fe,ce,ge,Oe,at)}if(U(Oe)||z(Oe))return fe=fe.get(ge)||null,Re(ce,fe,Oe,at,null);if(typeof Oe.then=="function")return Ee(fe,ce,ge,Vu(Oe),at);if(Oe.$$typeof===v)return Ee(fe,ce,ge,zu(ce,Oe),at);Wu(ce,Oe)}return null}function nt(fe,ce,ge,Oe){for(var at=null,Dt=null,st=ce,vt=ce=0,Et=null;st!==null&&vt<ge.length;vt++){st.index>vt?(Et=st,st=null):Et=st.sibling;var Ot=_e(fe,st,ge[vt],Oe);if(Ot===null){st===null&&(st=Et);break}i&&st&&Ot.alternate===null&&o(fe,st),ce=L(Ot,ce,vt),Dt===null?at=Ot:Dt.sibling=Ot,Dt=Ot,st=Et}if(vt===ge.length)return f(fe,st),Nt&&Ps(fe,vt),at;if(st===null){for(;vt<ge.length;vt++)st=Be(fe,ge[vt],Oe),st!==null&&(ce=L(st,ce,vt),Dt===null?at=st:Dt.sibling=st,Dt=st);return Nt&&Ps(fe,vt),at}for(st=x(st);vt<ge.length;vt++)Et=Ee(st,fe,vt,ge[vt],Oe),Et!==null&&(i&&Et.alternate!==null&&st.delete(Et.key===null?vt:Et.key),ce=L(Et,ce,vt),Dt===null?at=Et:Dt.sibling=Et,Dt=Et);return i&&st.forEach(function(Oi){return o(fe,Oi)}),Nt&&Ps(fe,vt),at}function lt(fe,ce,ge,Oe){if(ge==null)throw Error(r(151));for(var at=null,Dt=null,st=ce,vt=ce=0,Et=null,Ot=ge.next();st!==null&&!Ot.done;vt++,Ot=ge.next()){st.index>vt?(Et=st,st=null):Et=st.sibling;var Oi=_e(fe,st,Ot.value,Oe);if(Oi===null){st===null&&(st=Et);break}i&&st&&Oi.alternate===null&&o(fe,st),ce=L(Oi,ce,vt),Dt===null?at=Oi:Dt.sibling=Oi,Dt=Oi,st=Et}if(Ot.done)return f(fe,st),Nt&&Ps(fe,vt),at;if(st===null){for(;!Ot.done;vt++,Ot=ge.next())Ot=Be(fe,Ot.value,Oe),Ot!==null&&(ce=L(Ot,ce,vt),Dt===null?at=Ot:Dt.sibling=Ot,Dt=Ot);return Nt&&Ps(fe,vt),at}for(st=x(st);!Ot.done;vt++,Ot=ge.next())Ot=Ee(st,fe,vt,Ot.value,Oe),Ot!==null&&(i&&Ot.alternate!==null&&st.delete(Ot.key===null?vt:Ot.key),ce=L(Ot,ce,vt),Dt===null?at=Ot:Dt.sibling=Ot,Dt=Ot);return i&&st.forEach(function(GL){return o(fe,GL)}),Nt&&Ps(fe,vt),at}function Gt(fe,ce,ge,Oe){if(typeof ge=="object"&&ge!==null&&ge.type===C&&ge.key===null&&(ge=ge.props.children),typeof ge=="object"&&ge!==null){switch(ge.$$typeof){case y:e:{for(var at=ge.key;ce!==null;){if(ce.key===at){if(at=ge.type,at===C){if(ce.tag===7){f(fe,ce.sibling),Oe=j(ce,ge.props.children),Oe.return=fe,fe=Oe;break e}}else if(ce.elementType===at||typeof at=="object"&&at!==null&&at.$$typeof===A&&ha(at)===ce.type){f(fe,ce.sibling),Oe=j(ce,ge.props),$l(Oe,ge),Oe.return=fe,fe=Oe;break e}f(fe,ce);break}else o(fe,ce);ce=ce.sibling}ge.type===C?(Oe=oa(ge.props.children,fe.mode,Oe,ge.key),Oe.return=fe,fe=Oe):(Oe=Pu(ge.type,ge.key,ge.props,null,fe.mode,Oe),$l(Oe,ge),Oe.return=fe,fe=Oe)}return G(fe);case w:e:{for(at=ge.key;ce!==null;){if(ce.key===at)if(ce.tag===4&&ce.stateNode.containerInfo===ge.containerInfo&&ce.stateNode.implementation===ge.implementation){f(fe,ce.sibling),Oe=j(ce,ge.children||[]),Oe.return=fe,fe=Oe;break e}else{f(fe,ce);break}else o(fe,ce);ce=ce.sibling}Oe=gm(ge,fe.mode,Oe),Oe.return=fe,fe=Oe}return G(fe);case A:return ge=ha(ge),Gt(fe,ce,ge,Oe)}if(U(ge))return nt(fe,ce,ge,Oe);if(z(ge)){if(at=z(ge),typeof at!="function")throw Error(r(150));return ge=at.call(ge),lt(fe,ce,ge,Oe)}if(typeof ge.then=="function")return Gt(fe,ce,Vu(ge),Oe);if(ge.$$typeof===v)return Gt(fe,ce,zu(fe,ge),Oe);Wu(fe,ge)}return typeof ge=="string"&&ge!==""||typeof ge=="number"||typeof ge=="bigint"?(ge=""+ge,ce!==null&&ce.tag===6?(f(fe,ce.sibling),Oe=j(ce,ge),Oe.return=fe,fe=Oe):(f(fe,ce),Oe=pm(ge,fe.mode,Oe),Oe.return=fe,fe=Oe),G(fe)):f(fe,ce)}return function(fe,ce,ge,Oe){try{Bl=0;var at=Gt(fe,ce,ge,Oe);return vo=null,at}catch(st){if(st===bo||st===Fu)throw st;var Dt=_r(29,st,null,fe.mode);return Dt.lanes=Oe,Dt.return=fe,Dt}finally{}}}var ma=Uv(!0),Vv=Uv(!1),xi=!1;function Nm(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Tm(i,o){i=i.updateQueue,o.updateQueue===i&&(o.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,callbacks:null})}function yi(i){return{lane:i,tag:0,payload:null,callback:null,next:null}}function bi(i,o,f){var x=i.updateQueue;if(x===null)return null;if(x=x.shared,(Mt&2)!==0){var j=x.pending;return j===null?o.next=o:(o.next=j.next,j.next=o),x.pending=o,o=Mu(i),jv(i,null,f),o}return Iu(i,x,o,f),Mu(i)}function zl(i,o,f){if(o=o.updateQueue,o!==null&&(o=o.shared,(f&4194048)!==0)){var x=o.lanes;x&=i.pendingLanes,f|=x,o.lanes=f,ae(i,f)}}function Am(i,o){var f=i.updateQueue,x=i.alternate;if(x!==null&&(x=x.updateQueue,f===x)){var j=null,L=null;if(f=f.firstBaseUpdate,f!==null){do{var G={lane:f.lane,tag:f.tag,payload:f.payload,callback:null,next:null};L===null?j=L=G:L=L.next=G,f=f.next}while(f!==null);L===null?j=L=o:L=L.next=o}else j=L=o;f={baseState:x.baseState,firstBaseUpdate:j,lastBaseUpdate:L,shared:x.shared,callbacks:x.callbacks},i.updateQueue=f;return}i=f.lastBaseUpdate,i===null?f.firstBaseUpdate=o:i.next=o,f.lastBaseUpdate=o}var Lm=!1;function Hl(){if(Lm){var i=yo;if(i!==null)throw i}}function Fl(i,o,f,x){Lm=!1;var j=i.updateQueue;xi=!1;var L=j.firstBaseUpdate,G=j.lastBaseUpdate,ee=j.shared.pending;if(ee!==null){j.shared.pending=null;var le=ee,xe=le.next;le.next=null,G===null?L=xe:G.next=xe,G=le;var Re=i.alternate;Re!==null&&(Re=Re.updateQueue,ee=Re.lastBaseUpdate,ee!==G&&(ee===null?Re.firstBaseUpdate=xe:ee.next=xe,Re.lastBaseUpdate=le))}if(L!==null){var Be=j.baseState;G=0,Re=xe=le=null,ee=L;do{var _e=ee.lane&-536870913,Ee=_e!==ee.lane;if(Ee?(kt&_e)===_e:(x&_e)===_e){_e!==0&&_e===xo&&(Lm=!0),Re!==null&&(Re=Re.next={lane:0,tag:ee.tag,payload:ee.payload,callback:null,next:null});e:{var nt=i,lt=ee;_e=o;var Gt=f;switch(lt.tag){case 1:if(nt=lt.payload,typeof nt=="function"){Be=nt.call(Gt,Be,_e);break e}Be=nt;break e;case 3:nt.flags=nt.flags&-65537|128;case 0:if(nt=lt.payload,_e=typeof nt=="function"?nt.call(Gt,Be,_e):nt,_e==null)break e;Be=m({},Be,_e);break e;case 2:xi=!0}}_e=ee.callback,_e!==null&&(i.flags|=64,Ee&&(i.flags|=8192),Ee=j.callbacks,Ee===null?j.callbacks=[_e]:Ee.push(_e))}else Ee={lane:_e,tag:ee.tag,payload:ee.payload,callback:ee.callback,next:null},Re===null?(xe=Re=Ee,le=Be):Re=Re.next=Ee,G|=_e;if(ee=ee.next,ee===null){if(ee=j.shared.pending,ee===null)break;Ee=ee,ee=Ee.next,Ee.next=null,j.lastBaseUpdate=Ee,j.shared.pending=null}}while(!0);Re===null&&(le=Be),j.baseState=le,j.firstBaseUpdate=xe,j.lastBaseUpdate=Re,L===null&&(j.shared.lanes=0),Ci|=G,i.lanes=G,i.memoizedState=Be}}function Wv(i,o){if(typeof i!="function")throw Error(r(191,i));i.call(o)}function Gv(i,o){var f=i.callbacks;if(f!==null)for(i.callbacks=null,i=0;i<f.length;i++)Wv(f[i],o)}var _o=D(null),Gu=D(0);function qv(i,o){i=Ks,$(Gu,i),$(_o,o),Ks=i|o.baseLanes}function Rm(){$(Gu,Ks),$(_o,_o.current)}function Dm(){Ks=Gu.current,q(_o),q(Gu)}var Sr=D(null),Hr=null;function vi(i){var o=i.alternate;$(pn,pn.current&1),$(Sr,i),Hr===null&&(o===null||_o.current!==null||o.memoizedState!==null)&&(Hr=i)}function Om(i){$(pn,pn.current),$(Sr,i),Hr===null&&(Hr=i)}function Kv(i){i.tag===22?($(pn,pn.current),$(Sr,i),Hr===null&&(Hr=i)):_i()}function _i(){$(pn,pn.current),$(Sr,Sr.current)}function wr(i){q(Sr),Hr===i&&(Hr=null),q(pn)}var pn=D(0);function qu(i){for(var o=i;o!==null;){if(o.tag===13){var f=o.memoizedState;if(f!==null&&(f=f.dehydrated,f===null||zp(f)||Hp(f)))return o}else if(o.tag===19&&(o.memoizedProps.revealOrder==="forwards"||o.memoizedProps.revealOrder==="backwards"||o.memoizedProps.revealOrder==="unstable_legacy-backwards"||o.memoizedProps.revealOrder==="together")){if((o.flags&128)!==0)return o}else if(o.child!==null){o.child.return=o,o=o.child;continue}if(o===i)break;for(;o.sibling===null;){if(o.return===null||o.return===i)return null;o=o.return}o.sibling.return=o.return,o=o.sibling}return null}var zs=0,bt=null,Vt=null,kn=null,Ku=!1,So=!1,pa=!1,Yu=0,Ul=0,wo=null,MA=0;function hn(){throw Error(r(321))}function Im(i,o){if(o===null)return!1;for(var f=0;f<o.length&&f<i.length;f++)if(!vr(i[f],o[f]))return!1;return!0}function Mm(i,o,f,x,j,L){return zs=L,bt=o,o.memoizedState=null,o.updateQueue=null,o.lanes=0,F.H=i===null||i.memoizedState===null?L_:Qm,pa=!1,L=f(x,j),pa=!1,So&&(L=Xv(o,f,x,j)),Yv(i),L}function Yv(i){F.H=Gl;var o=Vt!==null&&Vt.next!==null;if(zs=0,kn=Vt=bt=null,Ku=!1,Ul=0,wo=null,o)throw Error(r(300));i===null||En||(i=i.dependencies,i!==null&&$u(i)&&(En=!0))}function Xv(i,o,f,x){bt=i;var j=0;do{if(So&&(wo=null),Ul=0,So=!1,25<=j)throw Error(r(301));if(j+=1,kn=Vt=null,i.updateQueue!=null){var L=i.updateQueue;L.lastEffect=null,L.events=null,L.stores=null,L.memoCache!=null&&(L.memoCache.index=0)}F.H=R_,L=o(f,x)}while(So);return L}function PA(){var i=F.H,o=i.useState()[0];return o=typeof o.then=="function"?Vl(o):o,i=i.useState()[0],(Vt!==null?Vt.memoizedState:null)!==i&&(bt.flags|=1024),o}function Pm(){var i=Yu!==0;return Yu=0,i}function Bm(i,o,f){o.updateQueue=i.updateQueue,o.flags&=-2053,i.lanes&=~f}function $m(i){if(Ku){for(i=i.memoizedState;i!==null;){var o=i.queue;o!==null&&(o.pending=null),i=i.next}Ku=!1}zs=0,kn=Vt=bt=null,So=!1,Ul=Yu=0,wo=null}function tr(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return kn===null?bt.memoizedState=kn=i:kn=kn.next=i,kn}function gn(){if(Vt===null){var i=bt.alternate;i=i!==null?i.memoizedState:null}else i=Vt.next;var o=kn===null?bt.memoizedState:kn.next;if(o!==null)kn=o,Vt=i;else{if(i===null)throw bt.alternate===null?Error(r(467)):Error(r(310));Vt=i,i={memoizedState:Vt.memoizedState,baseState:Vt.baseState,baseQueue:Vt.baseQueue,queue:Vt.queue,next:null},kn===null?bt.memoizedState=kn=i:kn=kn.next=i}return kn}function Xu(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function Vl(i){var o=Ul;return Ul+=1,wo===null&&(wo=[]),i=zv(wo,i,o),o=bt,(kn===null?o.memoizedState:kn.next)===null&&(o=o.alternate,F.H=o===null||o.memoizedState===null?L_:Qm),i}function Qu(i){if(i!==null&&typeof i=="object"){if(typeof i.then=="function")return Vl(i);if(i.$$typeof===v)return Un(i)}throw Error(r(438,String(i)))}function zm(i){var o=null,f=bt.updateQueue;if(f!==null&&(o=f.memoCache),o==null){var x=bt.alternate;x!==null&&(x=x.updateQueue,x!==null&&(x=x.memoCache,x!=null&&(o={data:x.data.map(function(j){return j.slice()}),index:0})))}if(o==null&&(o={data:[],index:0}),f===null&&(f=Xu(),bt.updateQueue=f),f.memoCache=o,f=o.data[o.index],f===void 0)for(f=o.data[o.index]=Array(i),x=0;x<i;x++)f[x]=P;return o.index++,f}function Hs(i,o){return typeof o=="function"?o(i):o}function Ju(i){var o=gn();return Hm(o,Vt,i)}function Hm(i,o,f){var x=i.queue;if(x===null)throw Error(r(311));x.lastRenderedReducer=f;var j=i.baseQueue,L=x.pending;if(L!==null){if(j!==null){var G=j.next;j.next=L.next,L.next=G}o.baseQueue=j=L,x.pending=null}if(L=i.baseState,j===null)i.memoizedState=L;else{o=j.next;var ee=G=null,le=null,xe=o,Re=!1;do{var Be=xe.lane&-536870913;if(Be!==xe.lane?(kt&Be)===Be:(zs&Be)===Be){var _e=xe.revertLane;if(_e===0)le!==null&&(le=le.next={lane:0,revertLane:0,gesture:null,action:xe.action,hasEagerState:xe.hasEagerState,eagerState:xe.eagerState,next:null}),Be===xo&&(Re=!0);else if((zs&_e)===_e){xe=xe.next,_e===xo&&(Re=!0);continue}else Be={lane:0,revertLane:xe.revertLane,gesture:null,action:xe.action,hasEagerState:xe.hasEagerState,eagerState:xe.eagerState,next:null},le===null?(ee=le=Be,G=L):le=le.next=Be,bt.lanes|=_e,Ci|=_e;Be=xe.action,pa&&f(L,Be),L=xe.hasEagerState?xe.eagerState:f(L,Be)}else _e={lane:Be,revertLane:xe.revertLane,gesture:xe.gesture,action:xe.action,hasEagerState:xe.hasEagerState,eagerState:xe.eagerState,next:null},le===null?(ee=le=_e,G=L):le=le.next=_e,bt.lanes|=Be,Ci|=Be;xe=xe.next}while(xe!==null&&xe!==o);if(le===null?G=L:le.next=ee,!vr(L,i.memoizedState)&&(En=!0,Re&&(f=yo,f!==null)))throw f;i.memoizedState=L,i.baseState=G,i.baseQueue=le,x.lastRenderedState=L}return j===null&&(x.lanes=0),[i.memoizedState,x.dispatch]}function Fm(i){var o=gn(),f=o.queue;if(f===null)throw Error(r(311));f.lastRenderedReducer=i;var x=f.dispatch,j=f.pending,L=o.memoizedState;if(j!==null){f.pending=null;var G=j=j.next;do L=i(L,G.action),G=G.next;while(G!==j);vr(L,o.memoizedState)||(En=!0),o.memoizedState=L,o.baseQueue===null&&(o.baseState=L),f.lastRenderedState=L}return[L,x]}function Qv(i,o,f){var x=bt,j=gn(),L=Nt;if(L){if(f===void 0)throw Error(r(407));f=f()}else f=o();var G=!vr((Vt||j).memoizedState,f);if(G&&(j.memoizedState=f,En=!0),j=j.queue,Wm(e_.bind(null,x,j,i),[i]),j.getSnapshot!==o||G||kn!==null&&kn.memoizedState.tag&1){if(x.flags|=2048,Co(9,{destroy:void 0},Zv.bind(null,x,j,f,o),null),Yt===null)throw Error(r(349));L||(zs&127)!==0||Jv(x,o,f)}return f}function Jv(i,o,f){i.flags|=16384,i={getSnapshot:o,value:f},o=bt.updateQueue,o===null?(o=Xu(),bt.updateQueue=o,o.stores=[i]):(f=o.stores,f===null?o.stores=[i]:f.push(i))}function Zv(i,o,f,x){o.value=f,o.getSnapshot=x,t_(o)&&n_(i)}function e_(i,o,f){return f(function(){t_(o)&&n_(i)})}function t_(i){var o=i.getSnapshot;i=i.value;try{var f=o();return!vr(i,f)}catch{return!0}}function n_(i){var o=aa(i,2);o!==null&&dr(o,i,2)}function Um(i){var o=tr();if(typeof i=="function"){var f=i;if(i=f(),pa){pe(!0);try{f()}finally{pe(!1)}}}return o.memoizedState=o.baseState=i,o.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:Hs,lastRenderedState:i},o}function r_(i,o,f,x){return i.baseState=f,Hm(i,Vt,typeof x=="function"?x:Hs)}function BA(i,o,f,x,j){if(td(i))throw Error(r(485));if(i=o.action,i!==null){var L={payload:j,action:i,next:null,isTransition:!0,status:"pending",value:null,reason:null,listeners:[],then:function(G){L.listeners.push(G)}};F.T!==null?f(!0):L.isTransition=!1,x(L),f=o.pending,f===null?(L.next=o.pending=L,s_(o,L)):(L.next=f.next,o.pending=f.next=L)}}function s_(i,o){var f=o.action,x=o.payload,j=i.state;if(o.isTransition){var L=F.T,G={};F.T=G;try{var ee=f(j,x),le=F.S;le!==null&&le(G,ee),i_(i,o,ee)}catch(xe){Vm(i,o,xe)}finally{L!==null&&G.types!==null&&(L.types=G.types),F.T=L}}else try{L=f(j,x),i_(i,o,L)}catch(xe){Vm(i,o,xe)}}function i_(i,o,f){f!==null&&typeof f=="object"&&typeof f.then=="function"?f.then(function(x){a_(i,o,x)},function(x){return Vm(i,o,x)}):a_(i,o,f)}function a_(i,o,f){o.status="fulfilled",o.value=f,o_(o),i.state=f,o=i.pending,o!==null&&(f=o.next,f===o?i.pending=null:(f=f.next,o.next=f,s_(i,f)))}function Vm(i,o,f){var x=i.pending;if(i.pending=null,x!==null){x=x.next;do o.status="rejected",o.reason=f,o_(o),o=o.next;while(o!==x)}i.action=null}function o_(i){i=i.listeners;for(var o=0;o<i.length;o++)(0,i[o])()}function l_(i,o){return o}function c_(i,o){if(Nt){var f=Yt.formState;if(f!==null){e:{var x=bt;if(Nt){if(rn){t:{for(var j=rn,L=zr;j.nodeType!==8;){if(!L){j=null;break t}if(j=Fr(j.nextSibling),j===null){j=null;break t}}L=j.data,j=L==="F!"||L==="F"?j:null}if(j){rn=Fr(j.nextSibling),x=j.data==="F!";break e}}pi(x)}x=!1}x&&(o=f[0])}}return f=tr(),f.memoizedState=f.baseState=o,x={pending:null,lanes:0,dispatch:null,lastRenderedReducer:l_,lastRenderedState:o},f.queue=x,f=N_.bind(null,bt,x),x.dispatch=f,x=Um(!1),L=Xm.bind(null,bt,!1,x.queue),x=tr(),j={state:o,dispatch:null,action:i,pending:null},x.queue=j,f=BA.bind(null,bt,j,L,f),j.dispatch=f,x.memoizedState=i,[o,f,!1]}function u_(i){var o=gn();return d_(o,Vt,i)}function d_(i,o,f){if(o=Hm(i,o,l_)[0],i=Ju(Hs)[0],typeof o=="object"&&o!==null&&typeof o.then=="function")try{var x=Vl(o)}catch(G){throw G===bo?Fu:G}else x=o;o=gn();var j=o.queue,L=j.dispatch;return f!==o.memoizedState&&(bt.flags|=2048,Co(9,{destroy:void 0},$A.bind(null,j,f),null)),[x,L,i]}function $A(i,o){i.action=o}function h_(i){var o=gn(),f=Vt;if(f!==null)return d_(o,f,i);gn(),o=o.memoizedState,f=gn();var x=f.queue.dispatch;return f.memoizedState=i,[o,x,!1]}function Co(i,o,f,x){return i={tag:i,create:f,deps:x,inst:o,next:null},o=bt.updateQueue,o===null&&(o=Xu(),bt.updateQueue=o),f=o.lastEffect,f===null?o.lastEffect=i.next=i:(x=f.next,f.next=i,i.next=x,o.lastEffect=i),i}function f_(){return gn().memoizedState}function Zu(i,o,f,x){var j=tr();bt.flags|=i,j.memoizedState=Co(1|o,{destroy:void 0},f,x===void 0?null:x)}function ed(i,o,f,x){var j=gn();x=x===void 0?null:x;var L=j.memoizedState.inst;Vt!==null&&x!==null&&Im(x,Vt.memoizedState.deps)?j.memoizedState=Co(o,L,f,x):(bt.flags|=i,j.memoizedState=Co(1|o,L,f,x))}function m_(i,o){Zu(8390656,8,i,o)}function Wm(i,o){ed(2048,8,i,o)}function zA(i){bt.flags|=4;var o=bt.updateQueue;if(o===null)o=Xu(),bt.updateQueue=o,o.events=[i];else{var f=o.events;f===null?o.events=[i]:f.push(i)}}function p_(i){var o=gn().memoizedState;return zA({ref:o,nextImpl:i}),function(){if((Mt&2)!==0)throw Error(r(440));return o.impl.apply(void 0,arguments)}}function g_(i,o){return ed(4,2,i,o)}function x_(i,o){return ed(4,4,i,o)}function y_(i,o){if(typeof o=="function"){i=i();var f=o(i);return function(){typeof f=="function"?f():o(null)}}if(o!=null)return i=i(),o.current=i,function(){o.current=null}}function b_(i,o,f){f=f!=null?f.concat([i]):null,ed(4,4,y_.bind(null,o,i),f)}function Gm(){}function v_(i,o){var f=gn();o=o===void 0?null:o;var x=f.memoizedState;return o!==null&&Im(o,x[1])?x[0]:(f.memoizedState=[i,o],i)}function __(i,o){var f=gn();o=o===void 0?null:o;var x=f.memoizedState;if(o!==null&&Im(o,x[1]))return x[0];if(x=i(),pa){pe(!0);try{i()}finally{pe(!1)}}return f.memoizedState=[x,o],x}function qm(i,o,f){return f===void 0||(zs&1073741824)!==0&&(kt&261930)===0?i.memoizedState=o:(i.memoizedState=f,i=S0(),bt.lanes|=i,Ci|=i,f)}function S_(i,o,f,x){return vr(f,o)?f:_o.current!==null?(i=qm(i,f,x),vr(i,o)||(En=!0),i):(zs&42)===0||(zs&1073741824)!==0&&(kt&261930)===0?(En=!0,i.memoizedState=f):(i=S0(),bt.lanes|=i,Ci|=i,o)}function w_(i,o,f,x,j){var L=Q.p;Q.p=L!==0&&8>L?L:8;var G=F.T,ee={};F.T=ee,Xm(i,!1,o,f);try{var le=j(),xe=F.S;if(xe!==null&&xe(ee,le),le!==null&&typeof le=="object"&&typeof le.then=="function"){var Re=IA(le,x);Wl(i,o,Re,Er(i))}else Wl(i,o,x,Er(i))}catch(Be){Wl(i,o,{then:function(){},status:"rejected",reason:Be},Er())}finally{Q.p=L,G!==null&&ee.types!==null&&(G.types=ee.types),F.T=G}}function HA(){}function Km(i,o,f,x){if(i.tag!==5)throw Error(r(476));var j=C_(i).queue;w_(i,j,o,X,f===null?HA:function(){return k_(i),f(x)})}function C_(i){var o=i.memoizedState;if(o!==null)return o;o={memoizedState:X,baseState:X,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Hs,lastRenderedState:X},next:null};var f={};return o.next={memoizedState:f,baseState:f,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Hs,lastRenderedState:f},next:null},i.memoizedState=o,i=i.alternate,i!==null&&(i.memoizedState=o),o}function k_(i){var o=C_(i);o.next===null&&(o=i.alternate.memoizedState),Wl(i,o.next.queue,{},Er())}function Ym(){return Un(lc)}function E_(){return gn().memoizedState}function j_(){return gn().memoizedState}function FA(i){for(var o=i.return;o!==null;){switch(o.tag){case 24:case 3:var f=Er();i=yi(f);var x=bi(o,i,f);x!==null&&(dr(x,o,f),zl(x,o,f)),o={cache:Cm()},i.payload=o;return}o=o.return}}function UA(i,o,f){var x=Er();f={lane:x,revertLane:0,gesture:null,action:f,hasEagerState:!1,eagerState:null,next:null},td(i)?T_(o,f):(f=fm(i,o,f,x),f!==null&&(dr(f,i,x),A_(f,o,x)))}function N_(i,o,f){var x=Er();Wl(i,o,f,x)}function Wl(i,o,f,x){var j={lane:x,revertLane:0,gesture:null,action:f,hasEagerState:!1,eagerState:null,next:null};if(td(i))T_(o,j);else{var L=i.alternate;if(i.lanes===0&&(L===null||L.lanes===0)&&(L=o.lastRenderedReducer,L!==null))try{var G=o.lastRenderedState,ee=L(G,f);if(j.hasEagerState=!0,j.eagerState=ee,vr(ee,G))return Iu(i,o,j,0),Yt===null&&Ou(),!1}catch{}finally{}if(f=fm(i,o,j,x),f!==null)return dr(f,i,x),A_(f,o,x),!0}return!1}function Xm(i,o,f,x){if(x={lane:2,revertLane:Np(),gesture:null,action:x,hasEagerState:!1,eagerState:null,next:null},td(i)){if(o)throw Error(r(479))}else o=fm(i,f,x,2),o!==null&&dr(o,i,2)}function td(i){var o=i.alternate;return i===bt||o!==null&&o===bt}function T_(i,o){So=Ku=!0;var f=i.pending;f===null?o.next=o:(o.next=f.next,f.next=o),i.pending=o}function A_(i,o,f){if((f&4194048)!==0){var x=o.lanes;x&=i.pendingLanes,f|=x,o.lanes=f,ae(i,f)}}var Gl={readContext:Un,use:Qu,useCallback:hn,useContext:hn,useEffect:hn,useImperativeHandle:hn,useLayoutEffect:hn,useInsertionEffect:hn,useMemo:hn,useReducer:hn,useRef:hn,useState:hn,useDebugValue:hn,useDeferredValue:hn,useTransition:hn,useSyncExternalStore:hn,useId:hn,useHostTransitionStatus:hn,useFormState:hn,useActionState:hn,useOptimistic:hn,useMemoCache:hn,useCacheRefresh:hn};Gl.useEffectEvent=hn;var L_={readContext:Un,use:Qu,useCallback:function(i,o){return tr().memoizedState=[i,o===void 0?null:o],i},useContext:Un,useEffect:m_,useImperativeHandle:function(i,o,f){f=f!=null?f.concat([i]):null,Zu(4194308,4,y_.bind(null,o,i),f)},useLayoutEffect:function(i,o){return Zu(4194308,4,i,o)},useInsertionEffect:function(i,o){Zu(4,2,i,o)},useMemo:function(i,o){var f=tr();o=o===void 0?null:o;var x=i();if(pa){pe(!0);try{i()}finally{pe(!1)}}return f.memoizedState=[x,o],x},useReducer:function(i,o,f){var x=tr();if(f!==void 0){var j=f(o);if(pa){pe(!0);try{f(o)}finally{pe(!1)}}}else j=o;return x.memoizedState=x.baseState=j,i={pending:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:j},x.queue=i,i=i.dispatch=UA.bind(null,bt,i),[x.memoizedState,i]},useRef:function(i){var o=tr();return i={current:i},o.memoizedState=i},useState:function(i){i=Um(i);var o=i.queue,f=N_.bind(null,bt,o);return o.dispatch=f,[i.memoizedState,f]},useDebugValue:Gm,useDeferredValue:function(i,o){var f=tr();return qm(f,i,o)},useTransition:function(){var i=Um(!1);return i=w_.bind(null,bt,i.queue,!0,!1),tr().memoizedState=i,[!1,i]},useSyncExternalStore:function(i,o,f){var x=bt,j=tr();if(Nt){if(f===void 0)throw Error(r(407));f=f()}else{if(f=o(),Yt===null)throw Error(r(349));(kt&127)!==0||Jv(x,o,f)}j.memoizedState=f;var L={value:f,getSnapshot:o};return j.queue=L,m_(e_.bind(null,x,L,i),[i]),x.flags|=2048,Co(9,{destroy:void 0},Zv.bind(null,x,L,f,o),null),f},useId:function(){var i=tr(),o=Yt.identifierPrefix;if(Nt){var f=ps,x=ms;f=(x&~(1<<32-Ie(x)-1)).toString(32)+f,o="_"+o+"R_"+f,f=Yu++,0<f&&(o+="H"+f.toString(32)),o+="_"}else f=MA++,o="_"+o+"r_"+f.toString(32)+"_";return i.memoizedState=o},useHostTransitionStatus:Ym,useFormState:c_,useActionState:c_,useOptimistic:function(i){var o=tr();o.memoizedState=o.baseState=i;var f={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return o.queue=f,o=Xm.bind(null,bt,!0,f),f.dispatch=o,[i,o]},useMemoCache:zm,useCacheRefresh:function(){return tr().memoizedState=FA.bind(null,bt)},useEffectEvent:function(i){var o=tr(),f={impl:i};return o.memoizedState=f,function(){if((Mt&2)!==0)throw Error(r(440));return f.impl.apply(void 0,arguments)}}},Qm={readContext:Un,use:Qu,useCallback:v_,useContext:Un,useEffect:Wm,useImperativeHandle:b_,useInsertionEffect:g_,useLayoutEffect:x_,useMemo:__,useReducer:Ju,useRef:f_,useState:function(){return Ju(Hs)},useDebugValue:Gm,useDeferredValue:function(i,o){var f=gn();return S_(f,Vt.memoizedState,i,o)},useTransition:function(){var i=Ju(Hs)[0],o=gn().memoizedState;return[typeof i=="boolean"?i:Vl(i),o]},useSyncExternalStore:Qv,useId:E_,useHostTransitionStatus:Ym,useFormState:u_,useActionState:u_,useOptimistic:function(i,o){var f=gn();return r_(f,Vt,i,o)},useMemoCache:zm,useCacheRefresh:j_};Qm.useEffectEvent=p_;var R_={readContext:Un,use:Qu,useCallback:v_,useContext:Un,useEffect:Wm,useImperativeHandle:b_,useInsertionEffect:g_,useLayoutEffect:x_,useMemo:__,useReducer:Fm,useRef:f_,useState:function(){return Fm(Hs)},useDebugValue:Gm,useDeferredValue:function(i,o){var f=gn();return Vt===null?qm(f,i,o):S_(f,Vt.memoizedState,i,o)},useTransition:function(){var i=Fm(Hs)[0],o=gn().memoizedState;return[typeof i=="boolean"?i:Vl(i),o]},useSyncExternalStore:Qv,useId:E_,useHostTransitionStatus:Ym,useFormState:h_,useActionState:h_,useOptimistic:function(i,o){var f=gn();return Vt!==null?r_(f,Vt,i,o):(f.baseState=i,[i,f.queue.dispatch])},useMemoCache:zm,useCacheRefresh:j_};R_.useEffectEvent=p_;function Jm(i,o,f,x){o=i.memoizedState,f=f(x,o),f=f==null?o:m({},o,f),i.memoizedState=f,i.lanes===0&&(i.updateQueue.baseState=f)}var Zm={enqueueSetState:function(i,o,f){i=i._reactInternals;var x=Er(),j=yi(x);j.payload=o,f!=null&&(j.callback=f),o=bi(i,j,x),o!==null&&(dr(o,i,x),zl(o,i,x))},enqueueReplaceState:function(i,o,f){i=i._reactInternals;var x=Er(),j=yi(x);j.tag=1,j.payload=o,f!=null&&(j.callback=f),o=bi(i,j,x),o!==null&&(dr(o,i,x),zl(o,i,x))},enqueueForceUpdate:function(i,o){i=i._reactInternals;var f=Er(),x=yi(f);x.tag=2,o!=null&&(x.callback=o),o=bi(i,x,f),o!==null&&(dr(o,i,f),zl(o,i,f))}};function D_(i,o,f,x,j,L,G){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(x,L,G):o.prototype&&o.prototype.isPureReactComponent?!Rl(f,x)||!Rl(j,L):!0}function O_(i,o,f,x){i=o.state,typeof o.componentWillReceiveProps=="function"&&o.componentWillReceiveProps(f,x),typeof o.UNSAFE_componentWillReceiveProps=="function"&&o.UNSAFE_componentWillReceiveProps(f,x),o.state!==i&&Zm.enqueueReplaceState(o,o.state,null)}function ga(i,o){var f=o;if("ref"in o){f={};for(var x in o)x!=="ref"&&(f[x]=o[x])}if(i=i.defaultProps){f===o&&(f=m({},f));for(var j in i)f[j]===void 0&&(f[j]=i[j])}return f}function I_(i){Du(i)}function M_(i){console.error(i)}function P_(i){Du(i)}function nd(i,o){try{var f=i.onUncaughtError;f(o.value,{componentStack:o.stack})}catch(x){setTimeout(function(){throw x})}}function B_(i,o,f){try{var x=i.onCaughtError;x(f.value,{componentStack:f.stack,errorBoundary:o.tag===1?o.stateNode:null})}catch(j){setTimeout(function(){throw j})}}function ep(i,o,f){return f=yi(f),f.tag=3,f.payload={element:null},f.callback=function(){nd(i,o)},f}function $_(i){return i=yi(i),i.tag=3,i}function z_(i,o,f,x){var j=f.type.getDerivedStateFromError;if(typeof j=="function"){var L=x.value;i.payload=function(){return j(L)},i.callback=function(){B_(o,f,x)}}var G=f.stateNode;G!==null&&typeof G.componentDidCatch=="function"&&(i.callback=function(){B_(o,f,x),typeof j!="function"&&(ki===null?ki=new Set([this]):ki.add(this));var ee=x.stack;this.componentDidCatch(x.value,{componentStack:ee!==null?ee:""})})}function VA(i,o,f,x,j){if(f.flags|=32768,x!==null&&typeof x=="object"&&typeof x.then=="function"){if(o=f.alternate,o!==null&&go(o,f,j,!0),f=Sr.current,f!==null){switch(f.tag){case 31:case 13:return Hr===null?md():f.alternate===null&&fn===0&&(fn=3),f.flags&=-257,f.flags|=65536,f.lanes=j,x===Uu?f.flags|=16384:(o=f.updateQueue,o===null?f.updateQueue=new Set([x]):o.add(x),kp(i,x,j)),!1;case 22:return f.flags|=65536,x===Uu?f.flags|=16384:(o=f.updateQueue,o===null?(o={transitions:null,markerInstances:null,retryQueue:new Set([x])},f.updateQueue=o):(f=o.retryQueue,f===null?o.retryQueue=new Set([x]):f.add(x)),kp(i,x,j)),!1}throw Error(r(435,f.tag))}return kp(i,x,j),md(),!1}if(Nt)return o=Sr.current,o!==null?((o.flags&65536)===0&&(o.flags|=256),o.flags|=65536,o.lanes=j,x!==bm&&(i=Error(r(422),{cause:x}),Il(Pr(i,f)))):(x!==bm&&(o=Error(r(423),{cause:x}),Il(Pr(o,f))),i=i.current.alternate,i.flags|=65536,j&=-j,i.lanes|=j,x=Pr(x,f),j=ep(i.stateNode,x,j),Am(i,j),fn!==4&&(fn=2)),!1;var L=Error(r(520),{cause:x});if(L=Pr(L,f),ec===null?ec=[L]:ec.push(L),fn!==4&&(fn=2),o===null)return!0;x=Pr(x,f),f=o;do{switch(f.tag){case 3:return f.flags|=65536,i=j&-j,f.lanes|=i,i=ep(f.stateNode,x,i),Am(f,i),!1;case 1:if(o=f.type,L=f.stateNode,(f.flags&128)===0&&(typeof o.getDerivedStateFromError=="function"||L!==null&&typeof L.componentDidCatch=="function"&&(ki===null||!ki.has(L))))return f.flags|=65536,j&=-j,f.lanes|=j,j=$_(j),z_(j,i,f,x),Am(f,j),!1}f=f.return}while(f!==null);return!1}var tp=Error(r(461)),En=!1;function Vn(i,o,f,x){o.child=i===null?Vv(o,null,f,x):ma(o,i.child,f,x)}function H_(i,o,f,x,j){f=f.render;var L=o.ref;if("ref"in x){var G={};for(var ee in x)ee!=="ref"&&(G[ee]=x[ee])}else G=x;return ua(o),x=Mm(i,o,f,G,L,j),ee=Pm(),i!==null&&!En?(Bm(i,o,j),Fs(i,o,j)):(Nt&&ee&&xm(o),o.flags|=1,Vn(i,o,x,j),o.child)}function F_(i,o,f,x,j){if(i===null){var L=f.type;return typeof L=="function"&&!mm(L)&&L.defaultProps===void 0&&f.compare===null?(o.tag=15,o.type=L,U_(i,o,L,x,j)):(i=Pu(f.type,null,x,o,o.mode,j),i.ref=o.ref,i.return=o,o.child=i)}if(L=i.child,!cp(i,j)){var G=L.memoizedProps;if(f=f.compare,f=f!==null?f:Rl,f(G,x)&&i.ref===o.ref)return Fs(i,o,j)}return o.flags|=1,i=Ms(L,x),i.ref=o.ref,i.return=o,o.child=i}function U_(i,o,f,x,j){if(i!==null){var L=i.memoizedProps;if(Rl(L,x)&&i.ref===o.ref)if(En=!1,o.pendingProps=x=L,cp(i,j))(i.flags&131072)!==0&&(En=!0);else return o.lanes=i.lanes,Fs(i,o,j)}return np(i,o,f,x,j)}function V_(i,o,f,x){var j=x.children,L=i!==null?i.memoizedState:null;if(i===null&&o.stateNode===null&&(o.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),x.mode==="hidden"){if((o.flags&128)!==0){if(L=L!==null?L.baseLanes|f:f,i!==null){for(x=o.child=i.child,j=0;x!==null;)j=j|x.lanes|x.childLanes,x=x.sibling;x=j&~L}else x=0,o.child=null;return W_(i,o,L,f,x)}if((f&536870912)!==0)o.memoizedState={baseLanes:0,cachePool:null},i!==null&&Hu(o,L!==null?L.cachePool:null),L!==null?qv(o,L):Rm(),Kv(o);else return x=o.lanes=536870912,W_(i,o,L!==null?L.baseLanes|f:f,f,x)}else L!==null?(Hu(o,L.cachePool),qv(o,L),_i(),o.memoizedState=null):(i!==null&&Hu(o,null),Rm(),_i());return Vn(i,o,j,f),o.child}function ql(i,o){return i!==null&&i.tag===22||o.stateNode!==null||(o.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),o.sibling}function W_(i,o,f,x,j){var L=Em();return L=L===null?null:{parent:Cn._currentValue,pool:L},o.memoizedState={baseLanes:f,cachePool:L},i!==null&&Hu(o,null),Rm(),Kv(o),i!==null&&go(i,o,x,!0),o.childLanes=j,null}function rd(i,o){return o=id({mode:o.mode,children:o.children},i.mode),o.ref=i.ref,i.child=o,o.return=i,o}function G_(i,o,f){return ma(o,i.child,null,f),i=rd(o,o.pendingProps),i.flags|=2,wr(o),o.memoizedState=null,i}function WA(i,o,f){var x=o.pendingProps,j=(o.flags&128)!==0;if(o.flags&=-129,i===null){if(Nt){if(x.mode==="hidden")return i=rd(o,x),o.lanes=536870912,ql(null,i);if(Om(o),(i=rn)?(i=sS(i,zr),i=i!==null&&i.data==="&"?i:null,i!==null&&(o.memoizedState={dehydrated:i,treeContext:fi!==null?{id:ms,overflow:ps}:null,retryLane:536870912,hydrationErrors:null},f=Tv(i),f.return=o,o.child=f,Fn=o,rn=null)):i=null,i===null)throw pi(o);return o.lanes=536870912,null}return rd(o,x)}var L=i.memoizedState;if(L!==null){var G=L.dehydrated;if(Om(o),j)if(o.flags&256)o.flags&=-257,o=G_(i,o,f);else if(o.memoizedState!==null)o.child=i.child,o.flags|=128,o=null;else throw Error(r(558));else if(En||go(i,o,f,!1),j=(f&i.childLanes)!==0,En||j){if(x=Yt,x!==null&&(G=Me(x,f),G!==0&&G!==L.retryLane))throw L.retryLane=G,aa(i,G),dr(x,i,G),tp;md(),o=G_(i,o,f)}else i=L.treeContext,rn=Fr(G.nextSibling),Fn=o,Nt=!0,mi=null,zr=!1,i!==null&&Rv(o,i),o=rd(o,x),o.flags|=4096;return o}return i=Ms(i.child,{mode:x.mode,children:x.children}),i.ref=o.ref,o.child=i,i.return=o,i}function sd(i,o){var f=o.ref;if(f===null)i!==null&&i.ref!==null&&(o.flags|=4194816);else{if(typeof f!="function"&&typeof f!="object")throw Error(r(284));(i===null||i.ref!==f)&&(o.flags|=4194816)}}function np(i,o,f,x,j){return ua(o),f=Mm(i,o,f,x,void 0,j),x=Pm(),i!==null&&!En?(Bm(i,o,j),Fs(i,o,j)):(Nt&&x&&xm(o),o.flags|=1,Vn(i,o,f,j),o.child)}function q_(i,o,f,x,j,L){return ua(o),o.updateQueue=null,f=Xv(o,x,f,j),Yv(i),x=Pm(),i!==null&&!En?(Bm(i,o,L),Fs(i,o,L)):(Nt&&x&&xm(o),o.flags|=1,Vn(i,o,f,L),o.child)}function K_(i,o,f,x,j){if(ua(o),o.stateNode===null){var L=ho,G=f.contextType;typeof G=="object"&&G!==null&&(L=Un(G)),L=new f(x,L),o.memoizedState=L.state!==null&&L.state!==void 0?L.state:null,L.updater=Zm,o.stateNode=L,L._reactInternals=o,L=o.stateNode,L.props=x,L.state=o.memoizedState,L.refs={},Nm(o),G=f.contextType,L.context=typeof G=="object"&&G!==null?Un(G):ho,L.state=o.memoizedState,G=f.getDerivedStateFromProps,typeof G=="function"&&(Jm(o,f,G,x),L.state=o.memoizedState),typeof f.getDerivedStateFromProps=="function"||typeof L.getSnapshotBeforeUpdate=="function"||typeof L.UNSAFE_componentWillMount!="function"&&typeof L.componentWillMount!="function"||(G=L.state,typeof L.componentWillMount=="function"&&L.componentWillMount(),typeof L.UNSAFE_componentWillMount=="function"&&L.UNSAFE_componentWillMount(),G!==L.state&&Zm.enqueueReplaceState(L,L.state,null),Fl(o,x,L,j),Hl(),L.state=o.memoizedState),typeof L.componentDidMount=="function"&&(o.flags|=4194308),x=!0}else if(i===null){L=o.stateNode;var ee=o.memoizedProps,le=ga(f,ee);L.props=le;var xe=L.context,Re=f.contextType;G=ho,typeof Re=="object"&&Re!==null&&(G=Un(Re));var Be=f.getDerivedStateFromProps;Re=typeof Be=="function"||typeof L.getSnapshotBeforeUpdate=="function",ee=o.pendingProps!==ee,Re||typeof L.UNSAFE_componentWillReceiveProps!="function"&&typeof L.componentWillReceiveProps!="function"||(ee||xe!==G)&&O_(o,L,x,G),xi=!1;var _e=o.memoizedState;L.state=_e,Fl(o,x,L,j),Hl(),xe=o.memoizedState,ee||_e!==xe||xi?(typeof Be=="function"&&(Jm(o,f,Be,x),xe=o.memoizedState),(le=xi||D_(o,f,le,x,_e,xe,G))?(Re||typeof L.UNSAFE_componentWillMount!="function"&&typeof L.componentWillMount!="function"||(typeof L.componentWillMount=="function"&&L.componentWillMount(),typeof L.UNSAFE_componentWillMount=="function"&&L.UNSAFE_componentWillMount()),typeof L.componentDidMount=="function"&&(o.flags|=4194308)):(typeof L.componentDidMount=="function"&&(o.flags|=4194308),o.memoizedProps=x,o.memoizedState=xe),L.props=x,L.state=xe,L.context=G,x=le):(typeof L.componentDidMount=="function"&&(o.flags|=4194308),x=!1)}else{L=o.stateNode,Tm(i,o),G=o.memoizedProps,Re=ga(f,G),L.props=Re,Be=o.pendingProps,_e=L.context,xe=f.contextType,le=ho,typeof xe=="object"&&xe!==null&&(le=Un(xe)),ee=f.getDerivedStateFromProps,(xe=typeof ee=="function"||typeof L.getSnapshotBeforeUpdate=="function")||typeof L.UNSAFE_componentWillReceiveProps!="function"&&typeof L.componentWillReceiveProps!="function"||(G!==Be||_e!==le)&&O_(o,L,x,le),xi=!1,_e=o.memoizedState,L.state=_e,Fl(o,x,L,j),Hl();var Ee=o.memoizedState;G!==Be||_e!==Ee||xi||i!==null&&i.dependencies!==null&&$u(i.dependencies)?(typeof ee=="function"&&(Jm(o,f,ee,x),Ee=o.memoizedState),(Re=xi||D_(o,f,Re,x,_e,Ee,le)||i!==null&&i.dependencies!==null&&$u(i.dependencies))?(xe||typeof L.UNSAFE_componentWillUpdate!="function"&&typeof L.componentWillUpdate!="function"||(typeof L.componentWillUpdate=="function"&&L.componentWillUpdate(x,Ee,le),typeof L.UNSAFE_componentWillUpdate=="function"&&L.UNSAFE_componentWillUpdate(x,Ee,le)),typeof L.componentDidUpdate=="function"&&(o.flags|=4),typeof L.getSnapshotBeforeUpdate=="function"&&(o.flags|=1024)):(typeof L.componentDidUpdate!="function"||G===i.memoizedProps&&_e===i.memoizedState||(o.flags|=4),typeof L.getSnapshotBeforeUpdate!="function"||G===i.memoizedProps&&_e===i.memoizedState||(o.flags|=1024),o.memoizedProps=x,o.memoizedState=Ee),L.props=x,L.state=Ee,L.context=le,x=Re):(typeof L.componentDidUpdate!="function"||G===i.memoizedProps&&_e===i.memoizedState||(o.flags|=4),typeof L.getSnapshotBeforeUpdate!="function"||G===i.memoizedProps&&_e===i.memoizedState||(o.flags|=1024),x=!1)}return L=x,sd(i,o),x=(o.flags&128)!==0,L||x?(L=o.stateNode,f=x&&typeof f.getDerivedStateFromError!="function"?null:L.render(),o.flags|=1,i!==null&&x?(o.child=ma(o,i.child,null,j),o.child=ma(o,null,f,j)):Vn(i,o,f,j),o.memoizedState=L.state,i=o.child):i=Fs(i,o,j),i}function Y_(i,o,f,x){return la(),o.flags|=256,Vn(i,o,f,x),o.child}var rp={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function sp(i){return{baseLanes:i,cachePool:Bv()}}function ip(i,o,f){return i=i!==null?i.childLanes&~f:0,o&&(i|=kr),i}function X_(i,o,f){var x=o.pendingProps,j=!1,L=(o.flags&128)!==0,G;if((G=L)||(G=i!==null&&i.memoizedState===null?!1:(pn.current&2)!==0),G&&(j=!0,o.flags&=-129),G=(o.flags&32)!==0,o.flags&=-33,i===null){if(Nt){if(j?vi(o):_i(),(i=rn)?(i=sS(i,zr),i=i!==null&&i.data!=="&"?i:null,i!==null&&(o.memoizedState={dehydrated:i,treeContext:fi!==null?{id:ms,overflow:ps}:null,retryLane:536870912,hydrationErrors:null},f=Tv(i),f.return=o,o.child=f,Fn=o,rn=null)):i=null,i===null)throw pi(o);return Hp(i)?o.lanes=32:o.lanes=536870912,null}var ee=x.children;return x=x.fallback,j?(_i(),j=o.mode,ee=id({mode:"hidden",children:ee},j),x=oa(x,j,f,null),ee.return=o,x.return=o,ee.sibling=x,o.child=ee,x=o.child,x.memoizedState=sp(f),x.childLanes=ip(i,G,f),o.memoizedState=rp,ql(null,x)):(vi(o),ap(o,ee))}var le=i.memoizedState;if(le!==null&&(ee=le.dehydrated,ee!==null)){if(L)o.flags&256?(vi(o),o.flags&=-257,o=op(i,o,f)):o.memoizedState!==null?(_i(),o.child=i.child,o.flags|=128,o=null):(_i(),ee=x.fallback,j=o.mode,x=id({mode:"visible",children:x.children},j),ee=oa(ee,j,f,null),ee.flags|=2,x.return=o,ee.return=o,x.sibling=ee,o.child=x,ma(o,i.child,null,f),x=o.child,x.memoizedState=sp(f),x.childLanes=ip(i,G,f),o.memoizedState=rp,o=ql(null,x));else if(vi(o),Hp(ee)){if(G=ee.nextSibling&&ee.nextSibling.dataset,G)var xe=G.dgst;G=xe,x=Error(r(419)),x.stack="",x.digest=G,Il({value:x,source:null,stack:null}),o=op(i,o,f)}else if(En||go(i,o,f,!1),G=(f&i.childLanes)!==0,En||G){if(G=Yt,G!==null&&(x=Me(G,f),x!==0&&x!==le.retryLane))throw le.retryLane=x,aa(i,x),dr(G,i,x),tp;zp(ee)||md(),o=op(i,o,f)}else zp(ee)?(o.flags|=192,o.child=i.child,o=null):(i=le.treeContext,rn=Fr(ee.nextSibling),Fn=o,Nt=!0,mi=null,zr=!1,i!==null&&Rv(o,i),o=ap(o,x.children),o.flags|=4096);return o}return j?(_i(),ee=x.fallback,j=o.mode,le=i.child,xe=le.sibling,x=Ms(le,{mode:"hidden",children:x.children}),x.subtreeFlags=le.subtreeFlags&65011712,xe!==null?ee=Ms(xe,ee):(ee=oa(ee,j,f,null),ee.flags|=2),ee.return=o,x.return=o,x.sibling=ee,o.child=x,ql(null,x),x=o.child,ee=i.child.memoizedState,ee===null?ee=sp(f):(j=ee.cachePool,j!==null?(le=Cn._currentValue,j=j.parent!==le?{parent:le,pool:le}:j):j=Bv(),ee={baseLanes:ee.baseLanes|f,cachePool:j}),x.memoizedState=ee,x.childLanes=ip(i,G,f),o.memoizedState=rp,ql(i.child,x)):(vi(o),f=i.child,i=f.sibling,f=Ms(f,{mode:"visible",children:x.children}),f.return=o,f.sibling=null,i!==null&&(G=o.deletions,G===null?(o.deletions=[i],o.flags|=16):G.push(i)),o.child=f,o.memoizedState=null,f)}function ap(i,o){return o=id({mode:"visible",children:o},i.mode),o.return=i,i.child=o}function id(i,o){return i=_r(22,i,null,o),i.lanes=0,i}function op(i,o,f){return ma(o,i.child,null,f),i=ap(o,o.pendingProps.children),i.flags|=2,o.memoizedState=null,i}function Q_(i,o,f){i.lanes|=o;var x=i.alternate;x!==null&&(x.lanes|=o),Sm(i.return,o,f)}function lp(i,o,f,x,j,L){var G=i.memoizedState;G===null?i.memoizedState={isBackwards:o,rendering:null,renderingStartTime:0,last:x,tail:f,tailMode:j,treeForkCount:L}:(G.isBackwards=o,G.rendering=null,G.renderingStartTime=0,G.last=x,G.tail=f,G.tailMode=j,G.treeForkCount=L)}function J_(i,o,f){var x=o.pendingProps,j=x.revealOrder,L=x.tail;x=x.children;var G=pn.current,ee=(G&2)!==0;if(ee?(G=G&1|2,o.flags|=128):G&=1,$(pn,G),Vn(i,o,x,f),x=Nt?Ol:0,!ee&&i!==null&&(i.flags&128)!==0)e:for(i=o.child;i!==null;){if(i.tag===13)i.memoizedState!==null&&Q_(i,f,o);else if(i.tag===19)Q_(i,f,o);else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===o)break e;for(;i.sibling===null;){if(i.return===null||i.return===o)break e;i=i.return}i.sibling.return=i.return,i=i.sibling}switch(j){case"forwards":for(f=o.child,j=null;f!==null;)i=f.alternate,i!==null&&qu(i)===null&&(j=f),f=f.sibling;f=j,f===null?(j=o.child,o.child=null):(j=f.sibling,f.sibling=null),lp(o,!1,j,f,L,x);break;case"backwards":case"unstable_legacy-backwards":for(f=null,j=o.child,o.child=null;j!==null;){if(i=j.alternate,i!==null&&qu(i)===null){o.child=j;break}i=j.sibling,j.sibling=f,f=j,j=i}lp(o,!0,f,null,L,x);break;case"together":lp(o,!1,null,null,void 0,x);break;default:o.memoizedState=null}return o.child}function Fs(i,o,f){if(i!==null&&(o.dependencies=i.dependencies),Ci|=o.lanes,(f&o.childLanes)===0)if(i!==null){if(go(i,o,f,!1),(f&o.childLanes)===0)return null}else return null;if(i!==null&&o.child!==i.child)throw Error(r(153));if(o.child!==null){for(i=o.child,f=Ms(i,i.pendingProps),o.child=f,f.return=o;i.sibling!==null;)i=i.sibling,f=f.sibling=Ms(i,i.pendingProps),f.return=o;f.sibling=null}return o.child}function cp(i,o){return(i.lanes&o)!==0?!0:(i=i.dependencies,!!(i!==null&&$u(i)))}function GA(i,o,f){switch(o.tag){case 3:B(o,o.stateNode.containerInfo),gi(o,Cn,i.memoizedState.cache),la();break;case 27:case 5:se(o);break;case 4:B(o,o.stateNode.containerInfo);break;case 10:gi(o,o.type,o.memoizedProps.value);break;case 31:if(o.memoizedState!==null)return o.flags|=128,Om(o),null;break;case 13:var x=o.memoizedState;if(x!==null)return x.dehydrated!==null?(vi(o),o.flags|=128,null):(f&o.child.childLanes)!==0?X_(i,o,f):(vi(o),i=Fs(i,o,f),i!==null?i.sibling:null);vi(o);break;case 19:var j=(i.flags&128)!==0;if(x=(f&o.childLanes)!==0,x||(go(i,o,f,!1),x=(f&o.childLanes)!==0),j){if(x)return J_(i,o,f);o.flags|=128}if(j=o.memoizedState,j!==null&&(j.rendering=null,j.tail=null,j.lastEffect=null),$(pn,pn.current),x)break;return null;case 22:return o.lanes=0,V_(i,o,f,o.pendingProps);case 24:gi(o,Cn,i.memoizedState.cache)}return Fs(i,o,f)}function Z_(i,o,f){if(i!==null)if(i.memoizedProps!==o.pendingProps)En=!0;else{if(!cp(i,f)&&(o.flags&128)===0)return En=!1,GA(i,o,f);En=(i.flags&131072)!==0}else En=!1,Nt&&(o.flags&1048576)!==0&&Lv(o,Ol,o.index);switch(o.lanes=0,o.tag){case 16:e:{var x=o.pendingProps;if(i=ha(o.elementType),o.type=i,typeof i=="function")mm(i)?(x=ga(i,x),o.tag=1,o=K_(null,o,i,x,f)):(o.tag=0,o=np(null,o,i,x,f));else{if(i!=null){var j=i.$$typeof;if(j===k){o.tag=11,o=H_(null,o,i,x,f);break e}else if(j===R){o.tag=14,o=F_(null,o,i,x,f);break e}}throw o=M(i)||i,Error(r(306,o,""))}}return o;case 0:return np(i,o,o.type,o.pendingProps,f);case 1:return x=o.type,j=ga(x,o.pendingProps),K_(i,o,x,j,f);case 3:e:{if(B(o,o.stateNode.containerInfo),i===null)throw Error(r(387));x=o.pendingProps;var L=o.memoizedState;j=L.element,Tm(i,o),Fl(o,x,null,f);var G=o.memoizedState;if(x=G.cache,gi(o,Cn,x),x!==L.cache&&wm(o,[Cn],f,!0),Hl(),x=G.element,L.isDehydrated)if(L={element:x,isDehydrated:!1,cache:G.cache},o.updateQueue.baseState=L,o.memoizedState=L,o.flags&256){o=Y_(i,o,x,f);break e}else if(x!==j){j=Pr(Error(r(424)),o),Il(j),o=Y_(i,o,x,f);break e}else{switch(i=o.stateNode.containerInfo,i.nodeType){case 9:i=i.body;break;default:i=i.nodeName==="HTML"?i.ownerDocument.body:i}for(rn=Fr(i.firstChild),Fn=o,Nt=!0,mi=null,zr=!0,f=Vv(o,null,x,f),o.child=f;f;)f.flags=f.flags&-3|4096,f=f.sibling}else{if(la(),x===j){o=Fs(i,o,f);break e}Vn(i,o,x,f)}o=o.child}return o;case 26:return sd(i,o),i===null?(f=uS(o.type,null,o.pendingProps,null))?o.memoizedState=f:Nt||(f=o.type,i=o.pendingProps,x=_d(Z.current).createElement(f),x[Pe]=o,x[Xe]=i,Wn(x,f,i),Pn(x),o.stateNode=x):o.memoizedState=uS(o.type,i.memoizedProps,o.pendingProps,i.memoizedState),null;case 27:return se(o),i===null&&Nt&&(x=o.stateNode=oS(o.type,o.pendingProps,Z.current),Fn=o,zr=!0,j=rn,Ti(o.type)?(Fp=j,rn=Fr(x.firstChild)):rn=j),Vn(i,o,o.pendingProps.children,f),sd(i,o),i===null&&(o.flags|=4194304),o.child;case 5:return i===null&&Nt&&((j=x=rn)&&(x=SL(x,o.type,o.pendingProps,zr),x!==null?(o.stateNode=x,Fn=o,rn=Fr(x.firstChild),zr=!1,j=!0):j=!1),j||pi(o)),se(o),j=o.type,L=o.pendingProps,G=i!==null?i.memoizedProps:null,x=L.children,Pp(j,L)?x=null:G!==null&&Pp(j,G)&&(o.flags|=32),o.memoizedState!==null&&(j=Mm(i,o,PA,null,null,f),lc._currentValue=j),sd(i,o),Vn(i,o,x,f),o.child;case 6:return i===null&&Nt&&((i=f=rn)&&(f=wL(f,o.pendingProps,zr),f!==null?(o.stateNode=f,Fn=o,rn=null,i=!0):i=!1),i||pi(o)),null;case 13:return X_(i,o,f);case 4:return B(o,o.stateNode.containerInfo),x=o.pendingProps,i===null?o.child=ma(o,null,x,f):Vn(i,o,x,f),o.child;case 11:return H_(i,o,o.type,o.pendingProps,f);case 7:return Vn(i,o,o.pendingProps,f),o.child;case 8:return Vn(i,o,o.pendingProps.children,f),o.child;case 12:return Vn(i,o,o.pendingProps.children,f),o.child;case 10:return x=o.pendingProps,gi(o,o.type,x.value),Vn(i,o,x.children,f),o.child;case 9:return j=o.type._context,x=o.pendingProps.children,ua(o),j=Un(j),x=x(j),o.flags|=1,Vn(i,o,x,f),o.child;case 14:return F_(i,o,o.type,o.pendingProps,f);case 15:return U_(i,o,o.type,o.pendingProps,f);case 19:return J_(i,o,f);case 31:return WA(i,o,f);case 22:return V_(i,o,f,o.pendingProps);case 24:return ua(o),x=Un(Cn),i===null?(j=Em(),j===null&&(j=Yt,L=Cm(),j.pooledCache=L,L.refCount++,L!==null&&(j.pooledCacheLanes|=f),j=L),o.memoizedState={parent:x,cache:j},Nm(o),gi(o,Cn,j)):((i.lanes&f)!==0&&(Tm(i,o),Fl(o,null,null,f),Hl()),j=i.memoizedState,L=o.memoizedState,j.parent!==x?(j={parent:x,cache:x},o.memoizedState=j,o.lanes===0&&(o.memoizedState=o.updateQueue.baseState=j),gi(o,Cn,x)):(x=L.cache,gi(o,Cn,x),x!==j.cache&&wm(o,[Cn],f,!0))),Vn(i,o,o.pendingProps.children,f),o.child;case 29:throw o.pendingProps}throw Error(r(156,o.tag))}function Us(i){i.flags|=4}function up(i,o,f,x,j){if((o=(i.mode&32)!==0)&&(o=!1),o){if(i.flags|=16777216,(j&335544128)===j)if(i.stateNode.complete)i.flags|=8192;else if(E0())i.flags|=8192;else throw fa=Uu,jm}else i.flags&=-16777217}function e0(i,o){if(o.type!=="stylesheet"||(o.state.loading&4)!==0)i.flags&=-16777217;else if(i.flags|=16777216,!pS(o))if(E0())i.flags|=8192;else throw fa=Uu,jm}function ad(i,o){o!==null&&(i.flags|=4),i.flags&16384&&(o=i.tag!==22?cn():536870912,i.lanes|=o,No|=o)}function Kl(i,o){if(!Nt)switch(i.tailMode){case"hidden":o=i.tail;for(var f=null;o!==null;)o.alternate!==null&&(f=o),o=o.sibling;f===null?i.tail=null:f.sibling=null;break;case"collapsed":f=i.tail;for(var x=null;f!==null;)f.alternate!==null&&(x=f),f=f.sibling;x===null?o||i.tail===null?i.tail=null:i.tail.sibling=null:x.sibling=null}}function sn(i){var o=i.alternate!==null&&i.alternate.child===i.child,f=0,x=0;if(o)for(var j=i.child;j!==null;)f|=j.lanes|j.childLanes,x|=j.subtreeFlags&65011712,x|=j.flags&65011712,j.return=i,j=j.sibling;else for(j=i.child;j!==null;)f|=j.lanes|j.childLanes,x|=j.subtreeFlags,x|=j.flags,j.return=i,j=j.sibling;return i.subtreeFlags|=x,i.childLanes=f,o}function qA(i,o,f){var x=o.pendingProps;switch(ym(o),o.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return sn(o),null;case 1:return sn(o),null;case 3:return f=o.stateNode,x=null,i!==null&&(x=i.memoizedState.cache),o.memoizedState.cache!==x&&(o.flags|=2048),$s(Cn),ne(),f.pendingContext&&(f.context=f.pendingContext,f.pendingContext=null),(i===null||i.child===null)&&(po(o)?Us(o):i===null||i.memoizedState.isDehydrated&&(o.flags&256)===0||(o.flags|=1024,vm())),sn(o),null;case 26:var j=o.type,L=o.memoizedState;return i===null?(Us(o),L!==null?(sn(o),e0(o,L)):(sn(o),up(o,j,null,x,f))):L?L!==i.memoizedState?(Us(o),sn(o),e0(o,L)):(sn(o),o.flags&=-16777217):(i=i.memoizedProps,i!==x&&Us(o),sn(o),up(o,j,i,x,f)),null;case 27:if(re(o),f=Z.current,j=o.type,i!==null&&o.stateNode!=null)i.memoizedProps!==x&&Us(o);else{if(!x){if(o.stateNode===null)throw Error(r(166));return sn(o),null}i=J.current,po(o)?Dv(o):(i=oS(j,x,f),o.stateNode=i,Us(o))}return sn(o),null;case 5:if(re(o),j=o.type,i!==null&&o.stateNode!=null)i.memoizedProps!==x&&Us(o);else{if(!x){if(o.stateNode===null)throw Error(r(166));return sn(o),null}if(L=J.current,po(o))Dv(o);else{var G=_d(Z.current);switch(L){case 1:L=G.createElementNS("http://www.w3.org/2000/svg",j);break;case 2:L=G.createElementNS("http://www.w3.org/1998/Math/MathML",j);break;default:switch(j){case"svg":L=G.createElementNS("http://www.w3.org/2000/svg",j);break;case"math":L=G.createElementNS("http://www.w3.org/1998/Math/MathML",j);break;case"script":L=G.createElement("div"),L.innerHTML="<script><\/script>",L=L.removeChild(L.firstChild);break;case"select":L=typeof x.is=="string"?G.createElement("select",{is:x.is}):G.createElement("select"),x.multiple?L.multiple=!0:x.size&&(L.size=x.size);break;default:L=typeof x.is=="string"?G.createElement(j,{is:x.is}):G.createElement(j)}}L[Pe]=o,L[Xe]=x;e:for(G=o.child;G!==null;){if(G.tag===5||G.tag===6)L.appendChild(G.stateNode);else if(G.tag!==4&&G.tag!==27&&G.child!==null){G.child.return=G,G=G.child;continue}if(G===o)break e;for(;G.sibling===null;){if(G.return===null||G.return===o)break e;G=G.return}G.sibling.return=G.return,G=G.sibling}o.stateNode=L;e:switch(Wn(L,j,x),j){case"button":case"input":case"select":case"textarea":x=!!x.autoFocus;break e;case"img":x=!0;break e;default:x=!1}x&&Us(o)}}return sn(o),up(o,o.type,i===null?null:i.memoizedProps,o.pendingProps,f),null;case 6:if(i&&o.stateNode!=null)i.memoizedProps!==x&&Us(o);else{if(typeof x!="string"&&o.stateNode===null)throw Error(r(166));if(i=Z.current,po(o)){if(i=o.stateNode,f=o.memoizedProps,x=null,j=Fn,j!==null)switch(j.tag){case 27:case 5:x=j.memoizedProps}i[Pe]=o,i=!!(i.nodeValue===f||x!==null&&x.suppressHydrationWarning===!0||X0(i.nodeValue,f)),i||pi(o,!0)}else i=_d(i).createTextNode(x),i[Pe]=o,o.stateNode=i}return sn(o),null;case 31:if(f=o.memoizedState,i===null||i.memoizedState!==null){if(x=po(o),f!==null){if(i===null){if(!x)throw Error(r(318));if(i=o.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(r(557));i[Pe]=o}else la(),(o.flags&128)===0&&(o.memoizedState=null),o.flags|=4;sn(o),i=!1}else f=vm(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=f),i=!0;if(!i)return o.flags&256?(wr(o),o):(wr(o),null);if((o.flags&128)!==0)throw Error(r(558))}return sn(o),null;case 13:if(x=o.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(j=po(o),x!==null&&x.dehydrated!==null){if(i===null){if(!j)throw Error(r(318));if(j=o.memoizedState,j=j!==null?j.dehydrated:null,!j)throw Error(r(317));j[Pe]=o}else la(),(o.flags&128)===0&&(o.memoizedState=null),o.flags|=4;sn(o),j=!1}else j=vm(),i!==null&&i.memoizedState!==null&&(i.memoizedState.hydrationErrors=j),j=!0;if(!j)return o.flags&256?(wr(o),o):(wr(o),null)}return wr(o),(o.flags&128)!==0?(o.lanes=f,o):(f=x!==null,i=i!==null&&i.memoizedState!==null,f&&(x=o.child,j=null,x.alternate!==null&&x.alternate.memoizedState!==null&&x.alternate.memoizedState.cachePool!==null&&(j=x.alternate.memoizedState.cachePool.pool),L=null,x.memoizedState!==null&&x.memoizedState.cachePool!==null&&(L=x.memoizedState.cachePool.pool),L!==j&&(x.flags|=2048)),f!==i&&f&&(o.child.flags|=8192),ad(o,o.updateQueue),sn(o),null);case 4:return ne(),i===null&&Rp(o.stateNode.containerInfo),sn(o),null;case 10:return $s(o.type),sn(o),null;case 19:if(q(pn),x=o.memoizedState,x===null)return sn(o),null;if(j=(o.flags&128)!==0,L=x.rendering,L===null)if(j)Kl(x,!1);else{if(fn!==0||i!==null&&(i.flags&128)!==0)for(i=o.child;i!==null;){if(L=qu(i),L!==null){for(o.flags|=128,Kl(x,!1),i=L.updateQueue,o.updateQueue=i,ad(o,i),o.subtreeFlags=0,i=f,f=o.child;f!==null;)Nv(f,i),f=f.sibling;return $(pn,pn.current&1|2),Nt&&Ps(o,x.treeForkCount),o.child}i=i.sibling}x.tail!==null&&Ve()>dd&&(o.flags|=128,j=!0,Kl(x,!1),o.lanes=4194304)}else{if(!j)if(i=qu(L),i!==null){if(o.flags|=128,j=!0,i=i.updateQueue,o.updateQueue=i,ad(o,i),Kl(x,!0),x.tail===null&&x.tailMode==="hidden"&&!L.alternate&&!Nt)return sn(o),null}else 2*Ve()-x.renderingStartTime>dd&&f!==536870912&&(o.flags|=128,j=!0,Kl(x,!1),o.lanes=4194304);x.isBackwards?(L.sibling=o.child,o.child=L):(i=x.last,i!==null?i.sibling=L:o.child=L,x.last=L)}return x.tail!==null?(i=x.tail,x.rendering=i,x.tail=i.sibling,x.renderingStartTime=Ve(),i.sibling=null,f=pn.current,$(pn,j?f&1|2:f&1),Nt&&Ps(o,x.treeForkCount),i):(sn(o),null);case 22:case 23:return wr(o),Dm(),x=o.memoizedState!==null,i!==null?i.memoizedState!==null!==x&&(o.flags|=8192):x&&(o.flags|=8192),x?(f&536870912)!==0&&(o.flags&128)===0&&(sn(o),o.subtreeFlags&6&&(o.flags|=8192)):sn(o),f=o.updateQueue,f!==null&&ad(o,f.retryQueue),f=null,i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(f=i.memoizedState.cachePool.pool),x=null,o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(x=o.memoizedState.cachePool.pool),x!==f&&(o.flags|=2048),i!==null&&q(da),null;case 24:return f=null,i!==null&&(f=i.memoizedState.cache),o.memoizedState.cache!==f&&(o.flags|=2048),$s(Cn),sn(o),null;case 25:return null;case 30:return null}throw Error(r(156,o.tag))}function KA(i,o){switch(ym(o),o.tag){case 1:return i=o.flags,i&65536?(o.flags=i&-65537|128,o):null;case 3:return $s(Cn),ne(),i=o.flags,(i&65536)!==0&&(i&128)===0?(o.flags=i&-65537|128,o):null;case 26:case 27:case 5:return re(o),null;case 31:if(o.memoizedState!==null){if(wr(o),o.alternate===null)throw Error(r(340));la()}return i=o.flags,i&65536?(o.flags=i&-65537|128,o):null;case 13:if(wr(o),i=o.memoizedState,i!==null&&i.dehydrated!==null){if(o.alternate===null)throw Error(r(340));la()}return i=o.flags,i&65536?(o.flags=i&-65537|128,o):null;case 19:return q(pn),null;case 4:return ne(),null;case 10:return $s(o.type),null;case 22:case 23:return wr(o),Dm(),i!==null&&q(da),i=o.flags,i&65536?(o.flags=i&-65537|128,o):null;case 24:return $s(Cn),null;case 25:return null;default:return null}}function t0(i,o){switch(ym(o),o.tag){case 3:$s(Cn),ne();break;case 26:case 27:case 5:re(o);break;case 4:ne();break;case 31:o.memoizedState!==null&&wr(o);break;case 13:wr(o);break;case 19:q(pn);break;case 10:$s(o.type);break;case 22:case 23:wr(o),Dm(),i!==null&&q(da);break;case 24:$s(Cn)}}function Yl(i,o){try{var f=o.updateQueue,x=f!==null?f.lastEffect:null;if(x!==null){var j=x.next;f=j;do{if((f.tag&i)===i){x=void 0;var L=f.create,G=f.inst;x=L(),G.destroy=x}f=f.next}while(f!==j)}}catch(ee){Ht(o,o.return,ee)}}function Si(i,o,f){try{var x=o.updateQueue,j=x!==null?x.lastEffect:null;if(j!==null){var L=j.next;x=L;do{if((x.tag&i)===i){var G=x.inst,ee=G.destroy;if(ee!==void 0){G.destroy=void 0,j=o;var le=f,xe=ee;try{xe()}catch(Re){Ht(j,le,Re)}}}x=x.next}while(x!==L)}}catch(Re){Ht(o,o.return,Re)}}function n0(i){var o=i.updateQueue;if(o!==null){var f=i.stateNode;try{Gv(o,f)}catch(x){Ht(i,i.return,x)}}}function r0(i,o,f){f.props=ga(i.type,i.memoizedProps),f.state=i.memoizedState;try{f.componentWillUnmount()}catch(x){Ht(i,o,x)}}function Xl(i,o){try{var f=i.ref;if(f!==null){switch(i.tag){case 26:case 27:case 5:var x=i.stateNode;break;case 30:x=i.stateNode;break;default:x=i.stateNode}typeof f=="function"?i.refCleanup=f(x):f.current=x}}catch(j){Ht(i,o,j)}}function gs(i,o){var f=i.ref,x=i.refCleanup;if(f!==null)if(typeof x=="function")try{x()}catch(j){Ht(i,o,j)}finally{i.refCleanup=null,i=i.alternate,i!=null&&(i.refCleanup=null)}else if(typeof f=="function")try{f(null)}catch(j){Ht(i,o,j)}else f.current=null}function s0(i){var o=i.type,f=i.memoizedProps,x=i.stateNode;try{e:switch(o){case"button":case"input":case"select":case"textarea":f.autoFocus&&x.focus();break e;case"img":f.src?x.src=f.src:f.srcSet&&(x.srcset=f.srcSet)}}catch(j){Ht(i,i.return,j)}}function dp(i,o,f){try{var x=i.stateNode;gL(x,i.type,f,o),x[Xe]=o}catch(j){Ht(i,i.return,j)}}function i0(i){return i.tag===5||i.tag===3||i.tag===26||i.tag===27&&Ti(i.type)||i.tag===4}function hp(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||i0(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.tag===27&&Ti(i.type)||i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function fp(i,o,f){var x=i.tag;if(x===5||x===6)i=i.stateNode,o?(f.nodeType===9?f.body:f.nodeName==="HTML"?f.ownerDocument.body:f).insertBefore(i,o):(o=f.nodeType===9?f.body:f.nodeName==="HTML"?f.ownerDocument.body:f,o.appendChild(i),f=f._reactRootContainer,f!=null||o.onclick!==null||(o.onclick=Os));else if(x!==4&&(x===27&&Ti(i.type)&&(f=i.stateNode,o=null),i=i.child,i!==null))for(fp(i,o,f),i=i.sibling;i!==null;)fp(i,o,f),i=i.sibling}function od(i,o,f){var x=i.tag;if(x===5||x===6)i=i.stateNode,o?f.insertBefore(i,o):f.appendChild(i);else if(x!==4&&(x===27&&Ti(i.type)&&(f=i.stateNode),i=i.child,i!==null))for(od(i,o,f),i=i.sibling;i!==null;)od(i,o,f),i=i.sibling}function a0(i){var o=i.stateNode,f=i.memoizedProps;try{for(var x=i.type,j=o.attributes;j.length;)o.removeAttributeNode(j[0]);Wn(o,x,f),o[Pe]=i,o[Xe]=f}catch(L){Ht(i,i.return,L)}}var Vs=!1,jn=!1,mp=!1,o0=typeof WeakSet=="function"?WeakSet:Set,Bn=null;function YA(i,o){if(i=i.containerInfo,Ip=Nd,i=bv(i),om(i)){if("selectionStart"in i)var f={start:i.selectionStart,end:i.selectionEnd};else e:{f=(f=i.ownerDocument)&&f.defaultView||window;var x=f.getSelection&&f.getSelection();if(x&&x.rangeCount!==0){f=x.anchorNode;var j=x.anchorOffset,L=x.focusNode;x=x.focusOffset;try{f.nodeType,L.nodeType}catch{f=null;break e}var G=0,ee=-1,le=-1,xe=0,Re=0,Be=i,_e=null;t:for(;;){for(var Ee;Be!==f||j!==0&&Be.nodeType!==3||(ee=G+j),Be!==L||x!==0&&Be.nodeType!==3||(le=G+x),Be.nodeType===3&&(G+=Be.nodeValue.length),(Ee=Be.firstChild)!==null;)_e=Be,Be=Ee;for(;;){if(Be===i)break t;if(_e===f&&++xe===j&&(ee=G),_e===L&&++Re===x&&(le=G),(Ee=Be.nextSibling)!==null)break;Be=_e,_e=Be.parentNode}Be=Ee}f=ee===-1||le===-1?null:{start:ee,end:le}}else f=null}f=f||{start:0,end:0}}else f=null;for(Mp={focusedElem:i,selectionRange:f},Nd=!1,Bn=o;Bn!==null;)if(o=Bn,i=o.child,(o.subtreeFlags&1028)!==0&&i!==null)i.return=o,Bn=i;else for(;Bn!==null;){switch(o=Bn,L=o.alternate,i=o.flags,o.tag){case 0:if((i&4)!==0&&(i=o.updateQueue,i=i!==null?i.events:null,i!==null))for(f=0;f<i.length;f++)j=i[f],j.ref.impl=j.nextImpl;break;case 11:case 15:break;case 1:if((i&1024)!==0&&L!==null){i=void 0,f=o,j=L.memoizedProps,L=L.memoizedState,x=f.stateNode;try{var nt=ga(f.type,j);i=x.getSnapshotBeforeUpdate(nt,L),x.__reactInternalSnapshotBeforeUpdate=i}catch(lt){Ht(f,f.return,lt)}}break;case 3:if((i&1024)!==0){if(i=o.stateNode.containerInfo,f=i.nodeType,f===9)$p(i);else if(f===1)switch(i.nodeName){case"HEAD":case"HTML":case"BODY":$p(i);break;default:i.textContent=""}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;default:if((i&1024)!==0)throw Error(r(163))}if(i=o.sibling,i!==null){i.return=o.return,Bn=i;break}Bn=o.return}}function l0(i,o,f){var x=f.flags;switch(f.tag){case 0:case 11:case 15:Gs(i,f),x&4&&Yl(5,f);break;case 1:if(Gs(i,f),x&4)if(i=f.stateNode,o===null)try{i.componentDidMount()}catch(G){Ht(f,f.return,G)}else{var j=ga(f.type,o.memoizedProps);o=o.memoizedState;try{i.componentDidUpdate(j,o,i.__reactInternalSnapshotBeforeUpdate)}catch(G){Ht(f,f.return,G)}}x&64&&n0(f),x&512&&Xl(f,f.return);break;case 3:if(Gs(i,f),x&64&&(i=f.updateQueue,i!==null)){if(o=null,f.child!==null)switch(f.child.tag){case 27:case 5:o=f.child.stateNode;break;case 1:o=f.child.stateNode}try{Gv(i,o)}catch(G){Ht(f,f.return,G)}}break;case 27:o===null&&x&4&&a0(f);case 26:case 5:Gs(i,f),o===null&&x&4&&s0(f),x&512&&Xl(f,f.return);break;case 12:Gs(i,f);break;case 31:Gs(i,f),x&4&&d0(i,f);break;case 13:Gs(i,f),x&4&&h0(i,f),x&64&&(i=f.memoizedState,i!==null&&(i=i.dehydrated,i!==null&&(f=sL.bind(null,f),CL(i,f))));break;case 22:if(x=f.memoizedState!==null||Vs,!x){o=o!==null&&o.memoizedState!==null||jn,j=Vs;var L=jn;Vs=x,(jn=o)&&!L?qs(i,f,(f.subtreeFlags&8772)!==0):Gs(i,f),Vs=j,jn=L}break;case 30:break;default:Gs(i,f)}}function c0(i){var o=i.alternate;o!==null&&(i.alternate=null,c0(o)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(o=i.stateNode,o!==null&&Ja(o)),i.stateNode=null,i.return=null,i.dependencies=null,i.memoizedProps=null,i.memoizedState=null,i.pendingProps=null,i.stateNode=null,i.updateQueue=null}var on=null,or=!1;function Ws(i,o,f){for(f=f.child;f!==null;)u0(i,o,f),f=f.sibling}function u0(i,o,f){if(rt&&typeof rt.onCommitFiberUnmount=="function")try{rt.onCommitFiberUnmount(Qe,f)}catch{}switch(f.tag){case 26:jn||gs(f,o),Ws(i,o,f),f.memoizedState?f.memoizedState.count--:f.stateNode&&(f=f.stateNode,f.parentNode.removeChild(f));break;case 27:jn||gs(f,o);var x=on,j=or;Ti(f.type)&&(on=f.stateNode,or=!1),Ws(i,o,f),ic(f.stateNode),on=x,or=j;break;case 5:jn||gs(f,o);case 6:if(x=on,j=or,on=null,Ws(i,o,f),on=x,or=j,on!==null)if(or)try{(on.nodeType===9?on.body:on.nodeName==="HTML"?on.ownerDocument.body:on).removeChild(f.stateNode)}catch(L){Ht(f,o,L)}else try{on.removeChild(f.stateNode)}catch(L){Ht(f,o,L)}break;case 18:on!==null&&(or?(i=on,nS(i.nodeType===9?i.body:i.nodeName==="HTML"?i.ownerDocument.body:i,f.stateNode),Mo(i)):nS(on,f.stateNode));break;case 4:x=on,j=or,on=f.stateNode.containerInfo,or=!0,Ws(i,o,f),on=x,or=j;break;case 0:case 11:case 14:case 15:Si(2,f,o),jn||Si(4,f,o),Ws(i,o,f);break;case 1:jn||(gs(f,o),x=f.stateNode,typeof x.componentWillUnmount=="function"&&r0(f,o,x)),Ws(i,o,f);break;case 21:Ws(i,o,f);break;case 22:jn=(x=jn)||f.memoizedState!==null,Ws(i,o,f),jn=x;break;default:Ws(i,o,f)}}function d0(i,o){if(o.memoizedState===null&&(i=o.alternate,i!==null&&(i=i.memoizedState,i!==null))){i=i.dehydrated;try{Mo(i)}catch(f){Ht(o,o.return,f)}}}function h0(i,o){if(o.memoizedState===null&&(i=o.alternate,i!==null&&(i=i.memoizedState,i!==null&&(i=i.dehydrated,i!==null))))try{Mo(i)}catch(f){Ht(o,o.return,f)}}function XA(i){switch(i.tag){case 31:case 13:case 19:var o=i.stateNode;return o===null&&(o=i.stateNode=new o0),o;case 22:return i=i.stateNode,o=i._retryCache,o===null&&(o=i._retryCache=new o0),o;default:throw Error(r(435,i.tag))}}function ld(i,o){var f=XA(i);o.forEach(function(x){if(!f.has(x)){f.add(x);var j=iL.bind(null,i,x);x.then(j,j)}})}function lr(i,o){var f=o.deletions;if(f!==null)for(var x=0;x<f.length;x++){var j=f[x],L=i,G=o,ee=G;e:for(;ee!==null;){switch(ee.tag){case 27:if(Ti(ee.type)){on=ee.stateNode,or=!1;break e}break;case 5:on=ee.stateNode,or=!1;break e;case 3:case 4:on=ee.stateNode.containerInfo,or=!0;break e}ee=ee.return}if(on===null)throw Error(r(160));u0(L,G,j),on=null,or=!1,L=j.alternate,L!==null&&(L.return=null),j.return=null}if(o.subtreeFlags&13886)for(o=o.child;o!==null;)f0(o,i),o=o.sibling}var es=null;function f0(i,o){var f=i.alternate,x=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:lr(o,i),cr(i),x&4&&(Si(3,i,i.return),Yl(3,i),Si(5,i,i.return));break;case 1:lr(o,i),cr(i),x&512&&(jn||f===null||gs(f,f.return)),x&64&&Vs&&(i=i.updateQueue,i!==null&&(x=i.callbacks,x!==null&&(f=i.shared.hiddenCallbacks,i.shared.hiddenCallbacks=f===null?x:f.concat(x))));break;case 26:var j=es;if(lr(o,i),cr(i),x&512&&(jn||f===null||gs(f,f.return)),x&4){var L=f!==null?f.memoizedState:null;if(x=i.memoizedState,f===null)if(x===null)if(i.stateNode===null){e:{x=i.type,f=i.memoizedProps,j=j.ownerDocument||j;t:switch(x){case"title":L=j.getElementsByTagName("title")[0],(!L||L[wn]||L[Pe]||L.namespaceURI==="http://www.w3.org/2000/svg"||L.hasAttribute("itemprop"))&&(L=j.createElement(x),j.head.insertBefore(L,j.querySelector("head > title"))),Wn(L,x,f),L[Pe]=i,Pn(L),x=L;break e;case"link":var G=fS("link","href",j).get(x+(f.href||""));if(G){for(var ee=0;ee<G.length;ee++)if(L=G[ee],L.getAttribute("href")===(f.href==null||f.href===""?null:f.href)&&L.getAttribute("rel")===(f.rel==null?null:f.rel)&&L.getAttribute("title")===(f.title==null?null:f.title)&&L.getAttribute("crossorigin")===(f.crossOrigin==null?null:f.crossOrigin)){G.splice(ee,1);break t}}L=j.createElement(x),Wn(L,x,f),j.head.appendChild(L);break;case"meta":if(G=fS("meta","content",j).get(x+(f.content||""))){for(ee=0;ee<G.length;ee++)if(L=G[ee],L.getAttribute("content")===(f.content==null?null:""+f.content)&&L.getAttribute("name")===(f.name==null?null:f.name)&&L.getAttribute("property")===(f.property==null?null:f.property)&&L.getAttribute("http-equiv")===(f.httpEquiv==null?null:f.httpEquiv)&&L.getAttribute("charset")===(f.charSet==null?null:f.charSet)){G.splice(ee,1);break t}}L=j.createElement(x),Wn(L,x,f),j.head.appendChild(L);break;default:throw Error(r(468,x))}L[Pe]=i,Pn(L),x=L}i.stateNode=x}else mS(j,i.type,i.stateNode);else i.stateNode=hS(j,x,i.memoizedProps);else L!==x?(L===null?f.stateNode!==null&&(f=f.stateNode,f.parentNode.removeChild(f)):L.count--,x===null?mS(j,i.type,i.stateNode):hS(j,x,i.memoizedProps)):x===null&&i.stateNode!==null&&dp(i,i.memoizedProps,f.memoizedProps)}break;case 27:lr(o,i),cr(i),x&512&&(jn||f===null||gs(f,f.return)),f!==null&&x&4&&dp(i,i.memoizedProps,f.memoizedProps);break;case 5:if(lr(o,i),cr(i),x&512&&(jn||f===null||gs(f,f.return)),i.flags&32){j=i.stateNode;try{so(j,"")}catch(nt){Ht(i,i.return,nt)}}x&4&&i.stateNode!=null&&(j=i.memoizedProps,dp(i,j,f!==null?f.memoizedProps:j)),x&1024&&(mp=!0);break;case 6:if(lr(o,i),cr(i),x&4){if(i.stateNode===null)throw Error(r(162));x=i.memoizedProps,f=i.stateNode;try{f.nodeValue=x}catch(nt){Ht(i,i.return,nt)}}break;case 3:if(Cd=null,j=es,es=Sd(o.containerInfo),lr(o,i),es=j,cr(i),x&4&&f!==null&&f.memoizedState.isDehydrated)try{Mo(o.containerInfo)}catch(nt){Ht(i,i.return,nt)}mp&&(mp=!1,m0(i));break;case 4:x=es,es=Sd(i.stateNode.containerInfo),lr(o,i),cr(i),es=x;break;case 12:lr(o,i),cr(i);break;case 31:lr(o,i),cr(i),x&4&&(x=i.updateQueue,x!==null&&(i.updateQueue=null,ld(i,x)));break;case 13:lr(o,i),cr(i),i.child.flags&8192&&i.memoizedState!==null!=(f!==null&&f.memoizedState!==null)&&(ud=Ve()),x&4&&(x=i.updateQueue,x!==null&&(i.updateQueue=null,ld(i,x)));break;case 22:j=i.memoizedState!==null;var le=f!==null&&f.memoizedState!==null,xe=Vs,Re=jn;if(Vs=xe||j,jn=Re||le,lr(o,i),jn=Re,Vs=xe,cr(i),x&8192)e:for(o=i.stateNode,o._visibility=j?o._visibility&-2:o._visibility|1,j&&(f===null||le||Vs||jn||xa(i)),f=null,o=i;;){if(o.tag===5||o.tag===26){if(f===null){le=f=o;try{if(L=le.stateNode,j)G=L.style,typeof G.setProperty=="function"?G.setProperty("display","none","important"):G.display="none";else{ee=le.stateNode;var Be=le.memoizedProps.style,_e=Be!=null&&Be.hasOwnProperty("display")?Be.display:null;ee.style.display=_e==null||typeof _e=="boolean"?"":(""+_e).trim()}}catch(nt){Ht(le,le.return,nt)}}}else if(o.tag===6){if(f===null){le=o;try{le.stateNode.nodeValue=j?"":le.memoizedProps}catch(nt){Ht(le,le.return,nt)}}}else if(o.tag===18){if(f===null){le=o;try{var Ee=le.stateNode;j?rS(Ee,!0):rS(le.stateNode,!1)}catch(nt){Ht(le,le.return,nt)}}}else if((o.tag!==22&&o.tag!==23||o.memoizedState===null||o===i)&&o.child!==null){o.child.return=o,o=o.child;continue}if(o===i)break e;for(;o.sibling===null;){if(o.return===null||o.return===i)break e;f===o&&(f=null),o=o.return}f===o&&(f=null),o.sibling.return=o.return,o=o.sibling}x&4&&(x=i.updateQueue,x!==null&&(f=x.retryQueue,f!==null&&(x.retryQueue=null,ld(i,f))));break;case 19:lr(o,i),cr(i),x&4&&(x=i.updateQueue,x!==null&&(i.updateQueue=null,ld(i,x)));break;case 30:break;case 21:break;default:lr(o,i),cr(i)}}function cr(i){var o=i.flags;if(o&2){try{for(var f,x=i.return;x!==null;){if(i0(x)){f=x;break}x=x.return}if(f==null)throw Error(r(160));switch(f.tag){case 27:var j=f.stateNode,L=hp(i);od(i,L,j);break;case 5:var G=f.stateNode;f.flags&32&&(so(G,""),f.flags&=-33);var ee=hp(i);od(i,ee,G);break;case 3:case 4:var le=f.stateNode.containerInfo,xe=hp(i);fp(i,xe,le);break;default:throw Error(r(161))}}catch(Re){Ht(i,i.return,Re)}i.flags&=-3}o&4096&&(i.flags&=-4097)}function m0(i){if(i.subtreeFlags&1024)for(i=i.child;i!==null;){var o=i;m0(o),o.tag===5&&o.flags&1024&&o.stateNode.reset(),i=i.sibling}}function Gs(i,o){if(o.subtreeFlags&8772)for(o=o.child;o!==null;)l0(i,o.alternate,o),o=o.sibling}function xa(i){for(i=i.child;i!==null;){var o=i;switch(o.tag){case 0:case 11:case 14:case 15:Si(4,o,o.return),xa(o);break;case 1:gs(o,o.return);var f=o.stateNode;typeof f.componentWillUnmount=="function"&&r0(o,o.return,f),xa(o);break;case 27:ic(o.stateNode);case 26:case 5:gs(o,o.return),xa(o);break;case 22:o.memoizedState===null&&xa(o);break;case 30:xa(o);break;default:xa(o)}i=i.sibling}}function qs(i,o,f){for(f=f&&(o.subtreeFlags&8772)!==0,o=o.child;o!==null;){var x=o.alternate,j=i,L=o,G=L.flags;switch(L.tag){case 0:case 11:case 15:qs(j,L,f),Yl(4,L);break;case 1:if(qs(j,L,f),x=L,j=x.stateNode,typeof j.componentDidMount=="function")try{j.componentDidMount()}catch(xe){Ht(x,x.return,xe)}if(x=L,j=x.updateQueue,j!==null){var ee=x.stateNode;try{var le=j.shared.hiddenCallbacks;if(le!==null)for(j.shared.hiddenCallbacks=null,j=0;j<le.length;j++)Wv(le[j],ee)}catch(xe){Ht(x,x.return,xe)}}f&&G&64&&n0(L),Xl(L,L.return);break;case 27:a0(L);case 26:case 5:qs(j,L,f),f&&x===null&&G&4&&s0(L),Xl(L,L.return);break;case 12:qs(j,L,f);break;case 31:qs(j,L,f),f&&G&4&&d0(j,L);break;case 13:qs(j,L,f),f&&G&4&&h0(j,L);break;case 22:L.memoizedState===null&&qs(j,L,f),Xl(L,L.return);break;case 30:break;default:qs(j,L,f)}o=o.sibling}}function pp(i,o){var f=null;i!==null&&i.memoizedState!==null&&i.memoizedState.cachePool!==null&&(f=i.memoizedState.cachePool.pool),i=null,o.memoizedState!==null&&o.memoizedState.cachePool!==null&&(i=o.memoizedState.cachePool.pool),i!==f&&(i!=null&&i.refCount++,f!=null&&Ml(f))}function gp(i,o){i=null,o.alternate!==null&&(i=o.alternate.memoizedState.cache),o=o.memoizedState.cache,o!==i&&(o.refCount++,i!=null&&Ml(i))}function ts(i,o,f,x){if(o.subtreeFlags&10256)for(o=o.child;o!==null;)p0(i,o,f,x),o=o.sibling}function p0(i,o,f,x){var j=o.flags;switch(o.tag){case 0:case 11:case 15:ts(i,o,f,x),j&2048&&Yl(9,o);break;case 1:ts(i,o,f,x);break;case 3:ts(i,o,f,x),j&2048&&(i=null,o.alternate!==null&&(i=o.alternate.memoizedState.cache),o=o.memoizedState.cache,o!==i&&(o.refCount++,i!=null&&Ml(i)));break;case 12:if(j&2048){ts(i,o,f,x),i=o.stateNode;try{var L=o.memoizedProps,G=L.id,ee=L.onPostCommit;typeof ee=="function"&&ee(G,o.alternate===null?"mount":"update",i.passiveEffectDuration,-0)}catch(le){Ht(o,o.return,le)}}else ts(i,o,f,x);break;case 31:ts(i,o,f,x);break;case 13:ts(i,o,f,x);break;case 23:break;case 22:L=o.stateNode,G=o.alternate,o.memoizedState!==null?L._visibility&2?ts(i,o,f,x):Ql(i,o):L._visibility&2?ts(i,o,f,x):(L._visibility|=2,ko(i,o,f,x,(o.subtreeFlags&10256)!==0||!1)),j&2048&&pp(G,o);break;case 24:ts(i,o,f,x),j&2048&&gp(o.alternate,o);break;default:ts(i,o,f,x)}}function ko(i,o,f,x,j){for(j=j&&((o.subtreeFlags&10256)!==0||!1),o=o.child;o!==null;){var L=i,G=o,ee=f,le=x,xe=G.flags;switch(G.tag){case 0:case 11:case 15:ko(L,G,ee,le,j),Yl(8,G);break;case 23:break;case 22:var Re=G.stateNode;G.memoizedState!==null?Re._visibility&2?ko(L,G,ee,le,j):Ql(L,G):(Re._visibility|=2,ko(L,G,ee,le,j)),j&&xe&2048&&pp(G.alternate,G);break;case 24:ko(L,G,ee,le,j),j&&xe&2048&&gp(G.alternate,G);break;default:ko(L,G,ee,le,j)}o=o.sibling}}function Ql(i,o){if(o.subtreeFlags&10256)for(o=o.child;o!==null;){var f=i,x=o,j=x.flags;switch(x.tag){case 22:Ql(f,x),j&2048&&pp(x.alternate,x);break;case 24:Ql(f,x),j&2048&&gp(x.alternate,x);break;default:Ql(f,x)}o=o.sibling}}var Jl=8192;function Eo(i,o,f){if(i.subtreeFlags&Jl)for(i=i.child;i!==null;)g0(i,o,f),i=i.sibling}function g0(i,o,f){switch(i.tag){case 26:Eo(i,o,f),i.flags&Jl&&i.memoizedState!==null&&ML(f,es,i.memoizedState,i.memoizedProps);break;case 5:Eo(i,o,f);break;case 3:case 4:var x=es;es=Sd(i.stateNode.containerInfo),Eo(i,o,f),es=x;break;case 22:i.memoizedState===null&&(x=i.alternate,x!==null&&x.memoizedState!==null?(x=Jl,Jl=16777216,Eo(i,o,f),Jl=x):Eo(i,o,f));break;default:Eo(i,o,f)}}function x0(i){var o=i.alternate;if(o!==null&&(i=o.child,i!==null)){o.child=null;do o=i.sibling,i.sibling=null,i=o;while(i!==null)}}function Zl(i){var o=i.deletions;if((i.flags&16)!==0){if(o!==null)for(var f=0;f<o.length;f++){var x=o[f];Bn=x,b0(x,i)}x0(i)}if(i.subtreeFlags&10256)for(i=i.child;i!==null;)y0(i),i=i.sibling}function y0(i){switch(i.tag){case 0:case 11:case 15:Zl(i),i.flags&2048&&Si(9,i,i.return);break;case 3:Zl(i);break;case 12:Zl(i);break;case 22:var o=i.stateNode;i.memoizedState!==null&&o._visibility&2&&(i.return===null||i.return.tag!==13)?(o._visibility&=-3,cd(i)):Zl(i);break;default:Zl(i)}}function cd(i){var o=i.deletions;if((i.flags&16)!==0){if(o!==null)for(var f=0;f<o.length;f++){var x=o[f];Bn=x,b0(x,i)}x0(i)}for(i=i.child;i!==null;){switch(o=i,o.tag){case 0:case 11:case 15:Si(8,o,o.return),cd(o);break;case 22:f=o.stateNode,f._visibility&2&&(f._visibility&=-3,cd(o));break;default:cd(o)}i=i.sibling}}function b0(i,o){for(;Bn!==null;){var f=Bn;switch(f.tag){case 0:case 11:case 15:Si(8,f,o);break;case 23:case 22:if(f.memoizedState!==null&&f.memoizedState.cachePool!==null){var x=f.memoizedState.cachePool.pool;x!=null&&x.refCount++}break;case 24:Ml(f.memoizedState.cache)}if(x=f.child,x!==null)x.return=f,Bn=x;else e:for(f=i;Bn!==null;){x=Bn;var j=x.sibling,L=x.return;if(c0(x),x===f){Bn=null;break e}if(j!==null){j.return=L,Bn=j;break e}Bn=L}}}var QA={getCacheForType:function(i){var o=Un(Cn),f=o.data.get(i);return f===void 0&&(f=i(),o.data.set(i,f)),f},cacheSignal:function(){return Un(Cn).controller.signal}},JA=typeof WeakMap=="function"?WeakMap:Map,Mt=0,Yt=null,St=null,kt=0,zt=0,Cr=null,wi=!1,jo=!1,xp=!1,Ks=0,fn=0,Ci=0,ya=0,yp=0,kr=0,No=0,ec=null,ur=null,bp=!1,ud=0,v0=0,dd=1/0,hd=null,ki=null,Rn=0,Ei=null,To=null,Ys=0,vp=0,_p=null,_0=null,tc=0,Sp=null;function Er(){return(Mt&2)!==0&&kt!==0?kt&-kt:F.T!==null?Np():nn()}function S0(){if(kr===0)if((kt&536870912)===0||Nt){var i=At;At<<=1,(At&3932160)===0&&(At=262144),kr=i}else kr=536870912;return i=Sr.current,i!==null&&(i.flags|=32),kr}function dr(i,o,f){(i===Yt&&(zt===2||zt===9)||i.cancelPendingCommit!==null)&&(Ao(i,0),ji(i,kt,kr,!1)),be(i,f),((Mt&2)===0||i!==Yt)&&(i===Yt&&((Mt&2)===0&&(ya|=f),fn===4&&ji(i,kt,kr,!1)),xs(i))}function w0(i,o,f){if((Mt&6)!==0)throw Error(r(327));var x=!f&&(o&127)===0&&(o&i.expiredLanes)===0||An(i,o),j=x?tL(i,o):Cp(i,o,!0),L=x;do{if(j===0){jo&&!x&&ji(i,o,0,!1);break}else{if(f=i.current.alternate,L&&!ZA(f)){j=Cp(i,o,!1),L=!1;continue}if(j===2){if(L=o,i.errorRecoveryDisabledLanes&L)var G=0;else G=i.pendingLanes&-536870913,G=G!==0?G:G&536870912?536870912:0;if(G!==0){o=G;e:{var ee=i;j=ec;var le=ee.current.memoizedState.isDehydrated;if(le&&(Ao(ee,G).flags|=256),G=Cp(ee,G,!1),G!==2){if(xp&&!le){ee.errorRecoveryDisabledLanes|=L,ya|=L,j=4;break e}L=ur,ur=j,L!==null&&(ur===null?ur=L:ur.push.apply(ur,L))}j=G}if(L=!1,j!==2)continue}}if(j===1){Ao(i,0),ji(i,o,0,!0);break}e:{switch(x=i,L=j,L){case 0:case 1:throw Error(r(345));case 4:if((o&4194048)!==o)break;case 6:ji(x,o,kr,!wi);break e;case 2:ur=null;break;case 3:case 5:break;default:throw Error(r(329))}if((o&62914560)===o&&(j=ud+300-Ve(),10<j)){if(ji(x,o,kr,!wi),dn(x,0,!0)!==0)break e;Ys=o,x.timeoutHandle=eS(C0.bind(null,x,f,ur,hd,bp,o,kr,ya,No,wi,L,"Throttled",-0,0),j);break e}C0(x,f,ur,hd,bp,o,kr,ya,No,wi,L,null,-0,0)}}break}while(!0);xs(i)}function C0(i,o,f,x,j,L,G,ee,le,xe,Re,Be,_e,Ee){if(i.timeoutHandle=-1,Be=o.subtreeFlags,Be&8192||(Be&16785408)===16785408){Be={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:Os},g0(o,L,Be);var nt=(L&62914560)===L?ud-Ve():(L&4194048)===L?v0-Ve():0;if(nt=PL(Be,nt),nt!==null){Ys=L,i.cancelPendingCommit=nt(R0.bind(null,i,o,L,f,x,j,G,ee,le,Re,Be,null,_e,Ee)),ji(i,L,G,!xe);return}}R0(i,o,L,f,x,j,G,ee,le)}function ZA(i){for(var o=i;;){var f=o.tag;if((f===0||f===11||f===15)&&o.flags&16384&&(f=o.updateQueue,f!==null&&(f=f.stores,f!==null)))for(var x=0;x<f.length;x++){var j=f[x],L=j.getSnapshot;j=j.value;try{if(!vr(L(),j))return!1}catch{return!1}}if(f=o.child,o.subtreeFlags&16384&&f!==null)f.return=o,o=f;else{if(o===i)break;for(;o.sibling===null;){if(o.return===null||o.return===i)return!0;o=o.return}o.sibling.return=o.return,o=o.sibling}}return!0}function ji(i,o,f,x){o&=~yp,o&=~ya,i.suspendedLanes|=o,i.pingedLanes&=~o,x&&(i.warmLanes|=o),x=i.expirationTimes;for(var j=o;0<j;){var L=31-Ie(j),G=1<<L;x[L]=-1,j&=~G}f!==0&&Ye(i,f,o)}function fd(){return(Mt&6)===0?(nc(0),!1):!0}function wp(){if(St!==null){if(zt===0)var i=St.return;else i=St,Bs=ca=null,$m(i),vo=null,Bl=0,i=St;for(;i!==null;)t0(i.alternate,i),i=i.return;St=null}}function Ao(i,o){var f=i.timeoutHandle;f!==-1&&(i.timeoutHandle=-1,bL(f)),f=i.cancelPendingCommit,f!==null&&(i.cancelPendingCommit=null,f()),Ys=0,wp(),Yt=i,St=f=Ms(i.current,null),kt=o,zt=0,Cr=null,wi=!1,jo=An(i,o),xp=!1,No=kr=yp=ya=Ci=fn=0,ur=ec=null,bp=!1,(o&8)!==0&&(o|=o&32);var x=i.entangledLanes;if(x!==0)for(i=i.entanglements,x&=o;0<x;){var j=31-Ie(x),L=1<<j;o|=i[j],x&=~L}return Ks=o,Ou(),f}function k0(i,o){bt=null,F.H=Gl,o===bo||o===Fu?(o=Hv(),zt=3):o===jm?(o=Hv(),zt=4):zt=o===tp?8:o!==null&&typeof o=="object"&&typeof o.then=="function"?6:1,Cr=o,St===null&&(fn=1,nd(i,Pr(o,i.current)))}function E0(){var i=Sr.current;return i===null?!0:(kt&4194048)===kt?Hr===null:(kt&62914560)===kt||(kt&536870912)!==0?i===Hr:!1}function j0(){var i=F.H;return F.H=Gl,i===null?Gl:i}function N0(){var i=F.A;return F.A=QA,i}function md(){fn=4,wi||(kt&4194048)!==kt&&Sr.current!==null||(jo=!0),(Ci&134217727)===0&&(ya&134217727)===0||Yt===null||ji(Yt,kt,kr,!1)}function Cp(i,o,f){var x=Mt;Mt|=2;var j=j0(),L=N0();(Yt!==i||kt!==o)&&(hd=null,Ao(i,o)),o=!1;var G=fn;e:do try{if(zt!==0&&St!==null){var ee=St,le=Cr;switch(zt){case 8:wp(),G=6;break e;case 3:case 2:case 9:case 6:Sr.current===null&&(o=!0);var xe=zt;if(zt=0,Cr=null,Lo(i,ee,le,xe),f&&jo){G=0;break e}break;default:xe=zt,zt=0,Cr=null,Lo(i,ee,le,xe)}}eL(),G=fn;break}catch(Re){k0(i,Re)}while(!0);return o&&i.shellSuspendCounter++,Bs=ca=null,Mt=x,F.H=j,F.A=L,St===null&&(Yt=null,kt=0,Ou()),G}function eL(){for(;St!==null;)T0(St)}function tL(i,o){var f=Mt;Mt|=2;var x=j0(),j=N0();Yt!==i||kt!==o?(hd=null,dd=Ve()+500,Ao(i,o)):jo=An(i,o);e:do try{if(zt!==0&&St!==null){o=St;var L=Cr;t:switch(zt){case 1:zt=0,Cr=null,Lo(i,o,L,1);break;case 2:case 9:if($v(L)){zt=0,Cr=null,A0(o);break}o=function(){zt!==2&&zt!==9||Yt!==i||(zt=7),xs(i)},L.then(o,o);break e;case 3:zt=7;break e;case 4:zt=5;break e;case 7:$v(L)?(zt=0,Cr=null,A0(o)):(zt=0,Cr=null,Lo(i,o,L,7));break;case 5:var G=null;switch(St.tag){case 26:G=St.memoizedState;case 5:case 27:var ee=St;if(G?pS(G):ee.stateNode.complete){zt=0,Cr=null;var le=ee.sibling;if(le!==null)St=le;else{var xe=ee.return;xe!==null?(St=xe,pd(xe)):St=null}break t}}zt=0,Cr=null,Lo(i,o,L,5);break;case 6:zt=0,Cr=null,Lo(i,o,L,6);break;case 8:wp(),fn=6;break e;default:throw Error(r(462))}}nL();break}catch(Re){k0(i,Re)}while(!0);return Bs=ca=null,F.H=x,F.A=j,Mt=f,St!==null?0:(Yt=null,kt=0,Ou(),fn)}function nL(){for(;St!==null&&!We();)T0(St)}function T0(i){var o=Z_(i.alternate,i,Ks);i.memoizedProps=i.pendingProps,o===null?pd(i):St=o}function A0(i){var o=i,f=o.alternate;switch(o.tag){case 15:case 0:o=q_(f,o,o.pendingProps,o.type,void 0,kt);break;case 11:o=q_(f,o,o.pendingProps,o.type.render,o.ref,kt);break;case 5:$m(o);default:t0(f,o),o=St=Nv(o,Ks),o=Z_(f,o,Ks)}i.memoizedProps=i.pendingProps,o===null?pd(i):St=o}function Lo(i,o,f,x){Bs=ca=null,$m(o),vo=null,Bl=0;var j=o.return;try{if(VA(i,j,o,f,kt)){fn=1,nd(i,Pr(f,i.current)),St=null;return}}catch(L){if(j!==null)throw St=j,L;fn=1,nd(i,Pr(f,i.current)),St=null;return}o.flags&32768?(Nt||x===1?i=!0:jo||(kt&536870912)!==0?i=!1:(wi=i=!0,(x===2||x===9||x===3||x===6)&&(x=Sr.current,x!==null&&x.tag===13&&(x.flags|=16384))),L0(o,i)):pd(o)}function pd(i){var o=i;do{if((o.flags&32768)!==0){L0(o,wi);return}i=o.return;var f=qA(o.alternate,o,Ks);if(f!==null){St=f;return}if(o=o.sibling,o!==null){St=o;return}St=o=i}while(o!==null);fn===0&&(fn=5)}function L0(i,o){do{var f=KA(i.alternate,i);if(f!==null){f.flags&=32767,St=f;return}if(f=i.return,f!==null&&(f.flags|=32768,f.subtreeFlags=0,f.deletions=null),!o&&(i=i.sibling,i!==null)){St=i;return}St=i=f}while(i!==null);fn=6,St=null}function R0(i,o,f,x,j,L,G,ee,le){i.cancelPendingCommit=null;do gd();while(Rn!==0);if((Mt&6)!==0)throw Error(r(327));if(o!==null){if(o===i.current)throw Error(r(177));if(L=o.lanes|o.childLanes,L|=hm,et(i,f,L,G,ee,le),i===Yt&&(St=Yt=null,kt=0),To=o,Ei=i,Ys=f,vp=L,_p=j,_0=x,(o.subtreeFlags&10256)!==0||(o.flags&10256)!==0?(i.callbackNode=null,i.callbackPriority=0,aL(Le,function(){return P0(),null})):(i.callbackNode=null,i.callbackPriority=0),x=(o.flags&13878)!==0,(o.subtreeFlags&13878)!==0||x){x=F.T,F.T=null,j=Q.p,Q.p=2,G=Mt,Mt|=4;try{YA(i,o,f)}finally{Mt=G,Q.p=j,F.T=x}}Rn=1,D0(),O0(),I0()}}function D0(){if(Rn===1){Rn=0;var i=Ei,o=To,f=(o.flags&13878)!==0;if((o.subtreeFlags&13878)!==0||f){f=F.T,F.T=null;var x=Q.p;Q.p=2;var j=Mt;Mt|=4;try{f0(o,i);var L=Mp,G=bv(i.containerInfo),ee=L.focusedElem,le=L.selectionRange;if(G!==ee&&ee&&ee.ownerDocument&&yv(ee.ownerDocument.documentElement,ee)){if(le!==null&&om(ee)){var xe=le.start,Re=le.end;if(Re===void 0&&(Re=xe),"selectionStart"in ee)ee.selectionStart=xe,ee.selectionEnd=Math.min(Re,ee.value.length);else{var Be=ee.ownerDocument||document,_e=Be&&Be.defaultView||window;if(_e.getSelection){var Ee=_e.getSelection(),nt=ee.textContent.length,lt=Math.min(le.start,nt),Gt=le.end===void 0?lt:Math.min(le.end,nt);!Ee.extend&&lt>Gt&&(G=Gt,Gt=lt,lt=G);var fe=xv(ee,lt),ce=xv(ee,Gt);if(fe&&ce&&(Ee.rangeCount!==1||Ee.anchorNode!==fe.node||Ee.anchorOffset!==fe.offset||Ee.focusNode!==ce.node||Ee.focusOffset!==ce.offset)){var ge=Be.createRange();ge.setStart(fe.node,fe.offset),Ee.removeAllRanges(),lt>Gt?(Ee.addRange(ge),Ee.extend(ce.node,ce.offset)):(ge.setEnd(ce.node,ce.offset),Ee.addRange(ge))}}}}for(Be=[],Ee=ee;Ee=Ee.parentNode;)Ee.nodeType===1&&Be.push({element:Ee,left:Ee.scrollLeft,top:Ee.scrollTop});for(typeof ee.focus=="function"&&ee.focus(),ee=0;ee<Be.length;ee++){var Oe=Be[ee];Oe.element.scrollLeft=Oe.left,Oe.element.scrollTop=Oe.top}}Nd=!!Ip,Mp=Ip=null}finally{Mt=j,Q.p=x,F.T=f}}i.current=o,Rn=2}}function O0(){if(Rn===2){Rn=0;var i=Ei,o=To,f=(o.flags&8772)!==0;if((o.subtreeFlags&8772)!==0||f){f=F.T,F.T=null;var x=Q.p;Q.p=2;var j=Mt;Mt|=4;try{l0(i,o.alternate,o)}finally{Mt=j,Q.p=x,F.T=f}}Rn=3}}function I0(){if(Rn===4||Rn===3){Rn=0,he();var i=Ei,o=To,f=Ys,x=_0;(o.subtreeFlags&10256)!==0||(o.flags&10256)!==0?Rn=5:(Rn=0,To=Ei=null,M0(i,i.pendingLanes));var j=i.pendingLanes;if(j===0&&(ki=null),Rt(f),o=o.stateNode,rt&&typeof rt.onCommitFiberRoot=="function")try{rt.onCommitFiberRoot(Qe,o,void 0,(o.current.flags&128)===128)}catch{}if(x!==null){o=F.T,j=Q.p,Q.p=2,F.T=null;try{for(var L=i.onRecoverableError,G=0;G<x.length;G++){var ee=x[G];L(ee.value,{componentStack:ee.stack})}}finally{F.T=o,Q.p=j}}(Ys&3)!==0&&gd(),xs(i),j=i.pendingLanes,(f&261930)!==0&&(j&42)!==0?i===Sp?tc++:(tc=0,Sp=i):tc=0,nc(0)}}function M0(i,o){(i.pooledCacheLanes&=o)===0&&(o=i.pooledCache,o!=null&&(i.pooledCache=null,Ml(o)))}function gd(){return D0(),O0(),I0(),P0()}function P0(){if(Rn!==5)return!1;var i=Ei,o=vp;vp=0;var f=Rt(Ys),x=F.T,j=Q.p;try{Q.p=32>f?32:f,F.T=null,f=_p,_p=null;var L=Ei,G=Ys;if(Rn=0,To=Ei=null,Ys=0,(Mt&6)!==0)throw Error(r(331));var ee=Mt;if(Mt|=4,y0(L.current),p0(L,L.current,G,f),Mt=ee,nc(0,!1),rt&&typeof rt.onPostCommitFiberRoot=="function")try{rt.onPostCommitFiberRoot(Qe,L)}catch{}return!0}finally{Q.p=j,F.T=x,M0(i,o)}}function B0(i,o,f){o=Pr(f,o),o=ep(i.stateNode,o,2),i=bi(i,o,2),i!==null&&(be(i,2),xs(i))}function Ht(i,o,f){if(i.tag===3)B0(i,i,f);else for(;o!==null;){if(o.tag===3){B0(o,i,f);break}else if(o.tag===1){var x=o.stateNode;if(typeof o.type.getDerivedStateFromError=="function"||typeof x.componentDidCatch=="function"&&(ki===null||!ki.has(x))){i=Pr(f,i),f=$_(2),x=bi(o,f,2),x!==null&&(z_(f,x,o,i),be(x,2),xs(x));break}}o=o.return}}function kp(i,o,f){var x=i.pingCache;if(x===null){x=i.pingCache=new JA;var j=new Set;x.set(o,j)}else j=x.get(o),j===void 0&&(j=new Set,x.set(o,j));j.has(f)||(xp=!0,j.add(f),i=rL.bind(null,i,o,f),o.then(i,i))}function rL(i,o,f){var x=i.pingCache;x!==null&&x.delete(o),i.pingedLanes|=i.suspendedLanes&f,i.warmLanes&=~f,Yt===i&&(kt&f)===f&&(fn===4||fn===3&&(kt&62914560)===kt&&300>Ve()-ud?(Mt&2)===0&&Ao(i,0):yp|=f,No===kt&&(No=0)),xs(i)}function $0(i,o){o===0&&(o=cn()),i=aa(i,o),i!==null&&(be(i,o),xs(i))}function sL(i){var o=i.memoizedState,f=0;o!==null&&(f=o.retryLane),$0(i,f)}function iL(i,o){var f=0;switch(i.tag){case 31:case 13:var x=i.stateNode,j=i.memoizedState;j!==null&&(f=j.retryLane);break;case 19:x=i.stateNode;break;case 22:x=i.stateNode._retryCache;break;default:throw Error(r(314))}x!==null&&x.delete(o),$0(i,f)}function aL(i,o){return Ce(i,o)}var xd=null,Ro=null,Ep=!1,yd=!1,jp=!1,Ni=0;function xs(i){i!==Ro&&i.next===null&&(Ro===null?xd=Ro=i:Ro=Ro.next=i),yd=!0,Ep||(Ep=!0,lL())}function nc(i,o){if(!jp&&yd){jp=!0;do for(var f=!1,x=xd;x!==null;){if(i!==0){var j=x.pendingLanes;if(j===0)var L=0;else{var G=x.suspendedLanes,ee=x.pingedLanes;L=(1<<31-Ie(42|i)+1)-1,L&=j&~(G&~ee),L=L&201326741?L&201326741|1:L?L|2:0}L!==0&&(f=!0,U0(x,L))}else L=kt,L=dn(x,x===Yt?L:0,x.cancelPendingCommit!==null||x.timeoutHandle!==-1),(L&3)===0||An(x,L)||(f=!0,U0(x,L));x=x.next}while(f);jp=!1}}function oL(){z0()}function z0(){yd=Ep=!1;var i=0;Ni!==0&&yL()&&(i=Ni);for(var o=Ve(),f=null,x=xd;x!==null;){var j=x.next,L=H0(x,o);L===0?(x.next=null,f===null?xd=j:f.next=j,j===null&&(Ro=f)):(f=x,(i!==0||(L&3)!==0)&&(yd=!0)),x=j}Rn!==0&&Rn!==5||nc(i),Ni!==0&&(Ni=0)}function H0(i,o){for(var f=i.suspendedLanes,x=i.pingedLanes,j=i.expirationTimes,L=i.pendingLanes&-62914561;0<L;){var G=31-Ie(L),ee=1<<G,le=j[G];le===-1?((ee&f)===0||(ee&x)!==0)&&(j[G]=Sn(ee,o)):le<=o&&(i.expiredLanes|=ee),L&=~ee}if(o=Yt,f=kt,f=dn(i,i===o?f:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),x=i.callbackNode,f===0||i===o&&(zt===2||zt===9)||i.cancelPendingCommit!==null)return x!==null&&x!==null&&me(x),i.callbackNode=null,i.callbackPriority=0;if((f&3)===0||An(i,f)){if(o=f&-f,o===i.callbackPriority)return o;switch(x!==null&&me(x),Rt(f)){case 2:case 8:f=ye;break;case 32:f=Le;break;case 268435456:f=de;break;default:f=Le}return x=F0.bind(null,i),f=Ce(f,x),i.callbackPriority=o,i.callbackNode=f,o}return x!==null&&x!==null&&me(x),i.callbackPriority=2,i.callbackNode=null,2}function F0(i,o){if(Rn!==0&&Rn!==5)return i.callbackNode=null,i.callbackPriority=0,null;var f=i.callbackNode;if(gd()&&i.callbackNode!==f)return null;var x=kt;return x=dn(i,i===Yt?x:0,i.cancelPendingCommit!==null||i.timeoutHandle!==-1),x===0?null:(w0(i,x,o),H0(i,Ve()),i.callbackNode!=null&&i.callbackNode===f?F0.bind(null,i):null)}function U0(i,o){if(gd())return null;w0(i,o,!0)}function lL(){vL(function(){(Mt&6)!==0?Ce(ie,oL):z0()})}function Np(){if(Ni===0){var i=xo;i===0&&(i=Ut,Ut<<=1,(Ut&261888)===0&&(Ut=256)),Ni=i}return Ni}function V0(i){return i==null||typeof i=="symbol"||typeof i=="boolean"?null:typeof i=="function"?i:Eu(""+i)}function W0(i,o){var f=o.ownerDocument.createElement("input");return f.name=o.name,f.value=o.value,i.id&&f.setAttribute("form",i.id),o.parentNode.insertBefore(f,o),i=new FormData(i),f.parentNode.removeChild(f),i}function cL(i,o,f,x,j){if(o==="submit"&&f&&f.stateNode===j){var L=V0((j[Xe]||null).action),G=x.submitter;G&&(o=(o=G[Xe]||null)?V0(o.formAction):G.getAttribute("formAction"),o!==null&&(L=o,G=null));var ee=new Au("action","action",null,x,j);i.push({event:ee,listeners:[{instance:null,listener:function(){if(x.defaultPrevented){if(Ni!==0){var le=G?W0(j,G):new FormData(j);Km(f,{pending:!0,data:le,method:j.method,action:L},null,le)}}else typeof L=="function"&&(ee.preventDefault(),le=G?W0(j,G):new FormData(j),Km(f,{pending:!0,data:le,method:j.method,action:L},L,le))},currentTarget:j}]})}}for(var Tp=0;Tp<dm.length;Tp++){var Ap=dm[Tp],uL=Ap.toLowerCase(),dL=Ap[0].toUpperCase()+Ap.slice(1);Zr(uL,"on"+dL)}Zr(Sv,"onAnimationEnd"),Zr(wv,"onAnimationIteration"),Zr(Cv,"onAnimationStart"),Zr("dblclick","onDoubleClick"),Zr("focusin","onFocus"),Zr("focusout","onBlur"),Zr(jA,"onTransitionRun"),Zr(NA,"onTransitionStart"),Zr(TA,"onTransitionCancel"),Zr(kv,"onTransitionEnd"),no("onMouseEnter",["mouseout","mouseover"]),no("onMouseLeave",["mouseout","mouseover"]),no("onPointerEnter",["pointerout","pointerover"]),no("onPointerLeave",["pointerout","pointerover"]),na("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),na("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),na("onBeforeInput",["compositionend","keypress","textInput","paste"]),na("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),na("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),na("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var rc="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(" "),hL=new Set("beforetoggle cancel close invalid load scroll scrollend toggle".split(" ").concat(rc));function G0(i,o){o=(o&4)!==0;for(var f=0;f<i.length;f++){var x=i[f],j=x.event;x=x.listeners;e:{var L=void 0;if(o)for(var G=x.length-1;0<=G;G--){var ee=x[G],le=ee.instance,xe=ee.currentTarget;if(ee=ee.listener,le!==L&&j.isPropagationStopped())break e;L=ee,j.currentTarget=xe;try{L(j)}catch(Re){Du(Re)}j.currentTarget=null,L=le}else for(G=0;G<x.length;G++){if(ee=x[G],le=ee.instance,xe=ee.currentTarget,ee=ee.listener,le!==L&&j.isPropagationStopped())break e;L=ee,j.currentTarget=xe;try{L(j)}catch(Re){Du(Re)}j.currentTarget=null,L=le}}}}function wt(i,o){var f=o[mt];f===void 0&&(f=o[mt]=new Set);var x=i+"__bubble";f.has(x)||(q0(o,i,2,!1),f.add(x))}function Lp(i,o,f){var x=0;o&&(x|=4),q0(f,i,x,o)}var bd="_reactListening"+Math.random().toString(36).slice(2);function Rp(i){if(!i[bd]){i[bd]=!0,zb.forEach(function(f){f!=="selectionchange"&&(hL.has(f)||Lp(f,!1,i),Lp(f,!0,i))});var o=i.nodeType===9?i:i.ownerDocument;o===null||o[bd]||(o[bd]=!0,Lp("selectionchange",!1,o))}}function q0(i,o,f,x){switch(SS(o)){case 2:var j=zL;break;case 8:j=HL;break;default:j=qp}f=j.bind(null,o,f,i),j=void 0,!Jf||o!=="touchstart"&&o!=="touchmove"&&o!=="wheel"||(j=!0),x?j!==void 0?i.addEventListener(o,f,{capture:!0,passive:j}):i.addEventListener(o,f,!0):j!==void 0?i.addEventListener(o,f,{passive:j}):i.addEventListener(o,f,!1)}function Dp(i,o,f,x,j){var L=x;if((o&1)===0&&(o&2)===0&&x!==null)e:for(;;){if(x===null)return;var G=x.tag;if(G===3||G===4){var ee=x.stateNode.containerInfo;if(ee===j)break;if(G===4)for(G=x.return;G!==null;){var le=G.tag;if((le===3||le===4)&&G.stateNode.containerInfo===j)return;G=G.return}for(;ee!==null;){if(G=Za(ee),G===null)return;if(le=G.tag,le===5||le===6||le===26||le===27){x=L=G;continue e}ee=ee.parentNode}}x=x.return}Jb(function(){var xe=L,Re=Xf(f),Be=[];e:{var _e=Ev.get(i);if(_e!==void 0){var Ee=Au,nt=i;switch(i){case"keypress":if(Nu(f)===0)break e;case"keydown":case"keyup":Ee=iA;break;case"focusin":nt="focus",Ee=nm;break;case"focusout":nt="blur",Ee=nm;break;case"beforeblur":case"afterblur":Ee=nm;break;case"click":if(f.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Ee=tv;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Ee=qT;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Ee=lA;break;case Sv:case wv:case Cv:Ee=XT;break;case kv:Ee=uA;break;case"scroll":case"scrollend":Ee=WT;break;case"wheel":Ee=hA;break;case"copy":case"cut":case"paste":Ee=JT;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Ee=rv;break;case"toggle":case"beforetoggle":Ee=mA}var lt=(o&4)!==0,Gt=!lt&&(i==="scroll"||i==="scrollend"),fe=lt?_e!==null?_e+"Capture":null:_e;lt=[];for(var ce=xe,ge;ce!==null;){var Oe=ce;if(ge=Oe.stateNode,Oe=Oe.tag,Oe!==5&&Oe!==26&&Oe!==27||ge===null||fe===null||(Oe=kl(ce,fe),Oe!=null&&lt.push(sc(ce,Oe,ge))),Gt)break;ce=ce.return}0<lt.length&&(_e=new Ee(_e,nt,null,f,Re),Be.push({event:_e,listeners:lt}))}}if((o&7)===0){e:{if(_e=i==="mouseover"||i==="pointerover",Ee=i==="mouseout"||i==="pointerout",_e&&f!==Yf&&(nt=f.relatedTarget||f.fromElement)&&(Za(nt)||nt[tt]))break e;if((Ee||_e)&&(_e=Re.window===Re?Re:(_e=Re.ownerDocument)?_e.defaultView||_e.parentWindow:window,Ee?(nt=f.relatedTarget||f.toElement,Ee=xe,nt=nt?Za(nt):null,nt!==null&&(Gt=l(nt),lt=nt.tag,nt!==Gt||lt!==5&&lt!==27&&lt!==6)&&(nt=null)):(Ee=null,nt=xe),Ee!==nt)){if(lt=tv,Oe="onMouseLeave",fe="onMouseEnter",ce="mouse",(i==="pointerout"||i==="pointerover")&&(lt=rv,Oe="onPointerLeave",fe="onPointerEnter",ce="pointer"),Gt=Ee==null?_e:Cl(Ee),ge=nt==null?_e:Cl(nt),_e=new lt(Oe,ce+"leave",Ee,f,Re),_e.target=Gt,_e.relatedTarget=ge,Oe=null,Za(Re)===xe&&(lt=new lt(fe,ce+"enter",nt,f,Re),lt.target=ge,lt.relatedTarget=Gt,Oe=lt),Gt=Oe,Ee&&nt)t:{for(lt=fL,fe=Ee,ce=nt,ge=0,Oe=fe;Oe;Oe=lt(Oe))ge++;Oe=0;for(var at=ce;at;at=lt(at))Oe++;for(;0<ge-Oe;)fe=lt(fe),ge--;for(;0<Oe-ge;)ce=lt(ce),Oe--;for(;ge--;){if(fe===ce||ce!==null&&fe===ce.alternate){lt=fe;break t}fe=lt(fe),ce=lt(ce)}lt=null}else lt=null;Ee!==null&&K0(Be,_e,Ee,lt,!1),nt!==null&&Gt!==null&&K0(Be,Gt,nt,lt,!0)}}e:{if(_e=xe?Cl(xe):window,Ee=_e.nodeName&&_e.nodeName.toLowerCase(),Ee==="select"||Ee==="input"&&_e.type==="file")var Dt=dv;else if(cv(_e))if(hv)Dt=CA;else{Dt=SA;var st=_A}else Ee=_e.nodeName,!Ee||Ee.toLowerCase()!=="input"||_e.type!=="checkbox"&&_e.type!=="radio"?xe&&Kf(xe.elementType)&&(Dt=dv):Dt=wA;if(Dt&&(Dt=Dt(i,xe))){uv(Be,Dt,f,Re);break e}st&&st(i,_e,xe),i==="focusout"&&xe&&_e.type==="number"&&xe.memoizedProps.value!=null&&qf(_e,"number",_e.value)}switch(st=xe?Cl(xe):window,i){case"focusin":(cv(st)||st.contentEditable==="true")&&(lo=st,lm=xe,Dl=null);break;case"focusout":Dl=lm=lo=null;break;case"mousedown":cm=!0;break;case"contextmenu":case"mouseup":case"dragend":cm=!1,vv(Be,f,Re);break;case"selectionchange":if(EA)break;case"keydown":case"keyup":vv(Be,f,Re)}var vt;if(sm)e:{switch(i){case"compositionstart":var Et="onCompositionStart";break e;case"compositionend":Et="onCompositionEnd";break e;case"compositionupdate":Et="onCompositionUpdate";break e}Et=void 0}else oo?ov(i,f)&&(Et="onCompositionEnd"):i==="keydown"&&f.keyCode===229&&(Et="onCompositionStart");Et&&(sv&&f.locale!=="ko"&&(oo||Et!=="onCompositionStart"?Et==="onCompositionEnd"&&oo&&(vt=Zb()):(hi=Re,Zf="value"in hi?hi.value:hi.textContent,oo=!0)),st=vd(xe,Et),0<st.length&&(Et=new nv(Et,i,null,f,Re),Be.push({event:Et,listeners:st}),vt?Et.data=vt:(vt=lv(f),vt!==null&&(Et.data=vt)))),(vt=gA?xA(i,f):yA(i,f))&&(Et=vd(xe,"onBeforeInput"),0<Et.length&&(st=new nv("onBeforeInput","beforeinput",null,f,Re),Be.push({event:st,listeners:Et}),st.data=vt)),cL(Be,i,xe,f,Re)}G0(Be,o)})}function sc(i,o,f){return{instance:i,listener:o,currentTarget:f}}function vd(i,o){for(var f=o+"Capture",x=[];i!==null;){var j=i,L=j.stateNode;if(j=j.tag,j!==5&&j!==26&&j!==27||L===null||(j=kl(i,f),j!=null&&x.unshift(sc(i,j,L)),j=kl(i,o),j!=null&&x.push(sc(i,j,L))),i.tag===3)return x;i=i.return}return[]}function fL(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5&&i.tag!==27);return i||null}function K0(i,o,f,x,j){for(var L=o._reactName,G=[];f!==null&&f!==x;){var ee=f,le=ee.alternate,xe=ee.stateNode;if(ee=ee.tag,le!==null&&le===x)break;ee!==5&&ee!==26&&ee!==27||xe===null||(le=xe,j?(xe=kl(f,L),xe!=null&&G.unshift(sc(f,xe,le))):j||(xe=kl(f,L),xe!=null&&G.push(sc(f,xe,le)))),f=f.return}G.length!==0&&i.push({event:o,listeners:G})}var mL=/\r\n?/g,pL=/\u0000|\uFFFD/g;function Y0(i){return(typeof i=="string"?i:""+i).replace(mL,`
50
+ `).replace(pL,"")}function X0(i,o){return o=Y0(o),Y0(i)===o}function Wt(i,o,f,x,j,L){switch(f){case"children":typeof x=="string"?o==="body"||o==="textarea"&&x===""||so(i,x):(typeof x=="number"||typeof x=="bigint")&&o!=="body"&&so(i,""+x);break;case"className":Cu(i,"class",x);break;case"tabIndex":Cu(i,"tabindex",x);break;case"dir":case"role":case"viewBox":case"width":case"height":Cu(i,f,x);break;case"style":Xb(i,x,L);break;case"data":if(o!=="object"){Cu(i,"data",x);break}case"src":case"href":if(x===""&&(o!=="a"||f!=="href")){i.removeAttribute(f);break}if(x==null||typeof x=="function"||typeof x=="symbol"||typeof x=="boolean"){i.removeAttribute(f);break}x=Eu(""+x),i.setAttribute(f,x);break;case"action":case"formAction":if(typeof x=="function"){i.setAttribute(f,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof L=="function"&&(f==="formAction"?(o!=="input"&&Wt(i,o,"name",j.name,j,null),Wt(i,o,"formEncType",j.formEncType,j,null),Wt(i,o,"formMethod",j.formMethod,j,null),Wt(i,o,"formTarget",j.formTarget,j,null)):(Wt(i,o,"encType",j.encType,j,null),Wt(i,o,"method",j.method,j,null),Wt(i,o,"target",j.target,j,null)));if(x==null||typeof x=="symbol"||typeof x=="boolean"){i.removeAttribute(f);break}x=Eu(""+x),i.setAttribute(f,x);break;case"onClick":x!=null&&(i.onclick=Os);break;case"onScroll":x!=null&&wt("scroll",i);break;case"onScrollEnd":x!=null&&wt("scrollend",i);break;case"dangerouslySetInnerHTML":if(x!=null){if(typeof x!="object"||!("__html"in x))throw Error(r(61));if(f=x.__html,f!=null){if(j.children!=null)throw Error(r(60));i.innerHTML=f}}break;case"multiple":i.multiple=x&&typeof x!="function"&&typeof x!="symbol";break;case"muted":i.muted=x&&typeof x!="function"&&typeof x!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(x==null||typeof x=="function"||typeof x=="boolean"||typeof x=="symbol"){i.removeAttribute("xlink:href");break}f=Eu(""+x),i.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",f);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":x!=null&&typeof x!="function"&&typeof x!="symbol"?i.setAttribute(f,""+x):i.removeAttribute(f);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":x&&typeof x!="function"&&typeof x!="symbol"?i.setAttribute(f,""):i.removeAttribute(f);break;case"capture":case"download":x===!0?i.setAttribute(f,""):x!==!1&&x!=null&&typeof x!="function"&&typeof x!="symbol"?i.setAttribute(f,x):i.removeAttribute(f);break;case"cols":case"rows":case"size":case"span":x!=null&&typeof x!="function"&&typeof x!="symbol"&&!isNaN(x)&&1<=x?i.setAttribute(f,x):i.removeAttribute(f);break;case"rowSpan":case"start":x==null||typeof x=="function"||typeof x=="symbol"||isNaN(x)?i.removeAttribute(f):i.setAttribute(f,x);break;case"popover":wt("beforetoggle",i),wt("toggle",i),wu(i,"popover",x);break;case"xlinkActuate":Ds(i,"http://www.w3.org/1999/xlink","xlink:actuate",x);break;case"xlinkArcrole":Ds(i,"http://www.w3.org/1999/xlink","xlink:arcrole",x);break;case"xlinkRole":Ds(i,"http://www.w3.org/1999/xlink","xlink:role",x);break;case"xlinkShow":Ds(i,"http://www.w3.org/1999/xlink","xlink:show",x);break;case"xlinkTitle":Ds(i,"http://www.w3.org/1999/xlink","xlink:title",x);break;case"xlinkType":Ds(i,"http://www.w3.org/1999/xlink","xlink:type",x);break;case"xmlBase":Ds(i,"http://www.w3.org/XML/1998/namespace","xml:base",x);break;case"xmlLang":Ds(i,"http://www.w3.org/XML/1998/namespace","xml:lang",x);break;case"xmlSpace":Ds(i,"http://www.w3.org/XML/1998/namespace","xml:space",x);break;case"is":wu(i,"is",x);break;case"innerText":case"textContent":break;default:(!(2<f.length)||f[0]!=="o"&&f[0]!=="O"||f[1]!=="n"&&f[1]!=="N")&&(f=UT.get(f)||f,wu(i,f,x))}}function Op(i,o,f,x,j,L){switch(f){case"style":Xb(i,x,L);break;case"dangerouslySetInnerHTML":if(x!=null){if(typeof x!="object"||!("__html"in x))throw Error(r(61));if(f=x.__html,f!=null){if(j.children!=null)throw Error(r(60));i.innerHTML=f}}break;case"children":typeof x=="string"?so(i,x):(typeof x=="number"||typeof x=="bigint")&&so(i,""+x);break;case"onScroll":x!=null&&wt("scroll",i);break;case"onScrollEnd":x!=null&&wt("scrollend",i);break;case"onClick":x!=null&&(i.onclick=Os);break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":break;case"innerText":case"textContent":break;default:if(!Hb.hasOwnProperty(f))e:{if(f[0]==="o"&&f[1]==="n"&&(j=f.endsWith("Capture"),o=f.slice(2,j?f.length-7:void 0),L=i[Xe]||null,L=L!=null?L[f]:null,typeof L=="function"&&i.removeEventListener(o,L,j),typeof x=="function")){typeof L!="function"&&L!==null&&(f in i?i[f]=null:i.hasAttribute(f)&&i.removeAttribute(f)),i.addEventListener(o,x,j);break e}f in i?i[f]=x:x===!0?i.setAttribute(f,""):wu(i,f,x)}}}function Wn(i,o,f){switch(o){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":wt("error",i),wt("load",i);var x=!1,j=!1,L;for(L in f)if(f.hasOwnProperty(L)){var G=f[L];if(G!=null)switch(L){case"src":x=!0;break;case"srcSet":j=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,o));default:Wt(i,o,L,G,f,null)}}j&&Wt(i,o,"srcSet",f.srcSet,f,null),x&&Wt(i,o,"src",f.src,f,null);return;case"input":wt("invalid",i);var ee=L=G=j=null,le=null,xe=null;for(x in f)if(f.hasOwnProperty(x)){var Re=f[x];if(Re!=null)switch(x){case"name":j=Re;break;case"type":G=Re;break;case"checked":le=Re;break;case"defaultChecked":xe=Re;break;case"value":L=Re;break;case"defaultValue":ee=Re;break;case"children":case"dangerouslySetInnerHTML":if(Re!=null)throw Error(r(137,o));break;default:Wt(i,o,x,Re,f,null)}}Gb(i,L,ee,le,xe,G,j,!1);return;case"select":wt("invalid",i),x=G=L=null;for(j in f)if(f.hasOwnProperty(j)&&(ee=f[j],ee!=null))switch(j){case"value":L=ee;break;case"defaultValue":G=ee;break;case"multiple":x=ee;default:Wt(i,o,j,ee,f,null)}o=L,f=G,i.multiple=!!x,o!=null?ro(i,!!x,o,!1):f!=null&&ro(i,!!x,f,!0);return;case"textarea":wt("invalid",i),L=j=x=null;for(G in f)if(f.hasOwnProperty(G)&&(ee=f[G],ee!=null))switch(G){case"value":x=ee;break;case"defaultValue":j=ee;break;case"children":L=ee;break;case"dangerouslySetInnerHTML":if(ee!=null)throw Error(r(91));break;default:Wt(i,o,G,ee,f,null)}Kb(i,x,j,L);return;case"option":for(le in f)if(f.hasOwnProperty(le)&&(x=f[le],x!=null))switch(le){case"selected":i.selected=x&&typeof x!="function"&&typeof x!="symbol";break;default:Wt(i,o,le,x,f,null)}return;case"dialog":wt("beforetoggle",i),wt("toggle",i),wt("cancel",i),wt("close",i);break;case"iframe":case"object":wt("load",i);break;case"video":case"audio":for(x=0;x<rc.length;x++)wt(rc[x],i);break;case"image":wt("error",i),wt("load",i);break;case"details":wt("toggle",i);break;case"embed":case"source":case"link":wt("error",i),wt("load",i);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(xe in f)if(f.hasOwnProperty(xe)&&(x=f[xe],x!=null))switch(xe){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,o));default:Wt(i,o,xe,x,f,null)}return;default:if(Kf(o)){for(Re in f)f.hasOwnProperty(Re)&&(x=f[Re],x!==void 0&&Op(i,o,Re,x,f,void 0));return}}for(ee in f)f.hasOwnProperty(ee)&&(x=f[ee],x!=null&&Wt(i,o,ee,x,f,null))}function gL(i,o,f,x){switch(o){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var j=null,L=null,G=null,ee=null,le=null,xe=null,Re=null;for(Ee in f){var Be=f[Ee];if(f.hasOwnProperty(Ee)&&Be!=null)switch(Ee){case"checked":break;case"value":break;case"defaultValue":le=Be;default:x.hasOwnProperty(Ee)||Wt(i,o,Ee,null,x,Be)}}for(var _e in x){var Ee=x[_e];if(Be=f[_e],x.hasOwnProperty(_e)&&(Ee!=null||Be!=null))switch(_e){case"type":L=Ee;break;case"name":j=Ee;break;case"checked":xe=Ee;break;case"defaultChecked":Re=Ee;break;case"value":G=Ee;break;case"defaultValue":ee=Ee;break;case"children":case"dangerouslySetInnerHTML":if(Ee!=null)throw Error(r(137,o));break;default:Ee!==Be&&Wt(i,o,_e,Ee,x,Be)}}Gf(i,G,ee,le,xe,Re,L,j);return;case"select":Ee=G=ee=_e=null;for(L in f)if(le=f[L],f.hasOwnProperty(L)&&le!=null)switch(L){case"value":break;case"multiple":Ee=le;default:x.hasOwnProperty(L)||Wt(i,o,L,null,x,le)}for(j in x)if(L=x[j],le=f[j],x.hasOwnProperty(j)&&(L!=null||le!=null))switch(j){case"value":_e=L;break;case"defaultValue":ee=L;break;case"multiple":G=L;default:L!==le&&Wt(i,o,j,L,x,le)}o=ee,f=G,x=Ee,_e!=null?ro(i,!!f,_e,!1):!!x!=!!f&&(o!=null?ro(i,!!f,o,!0):ro(i,!!f,f?[]:"",!1));return;case"textarea":Ee=_e=null;for(ee in f)if(j=f[ee],f.hasOwnProperty(ee)&&j!=null&&!x.hasOwnProperty(ee))switch(ee){case"value":break;case"children":break;default:Wt(i,o,ee,null,x,j)}for(G in x)if(j=x[G],L=f[G],x.hasOwnProperty(G)&&(j!=null||L!=null))switch(G){case"value":_e=j;break;case"defaultValue":Ee=j;break;case"children":break;case"dangerouslySetInnerHTML":if(j!=null)throw Error(r(91));break;default:j!==L&&Wt(i,o,G,j,x,L)}qb(i,_e,Ee);return;case"option":for(var nt in f)if(_e=f[nt],f.hasOwnProperty(nt)&&_e!=null&&!x.hasOwnProperty(nt))switch(nt){case"selected":i.selected=!1;break;default:Wt(i,o,nt,null,x,_e)}for(le in x)if(_e=x[le],Ee=f[le],x.hasOwnProperty(le)&&_e!==Ee&&(_e!=null||Ee!=null))switch(le){case"selected":i.selected=_e&&typeof _e!="function"&&typeof _e!="symbol";break;default:Wt(i,o,le,_e,x,Ee)}return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var lt in f)_e=f[lt],f.hasOwnProperty(lt)&&_e!=null&&!x.hasOwnProperty(lt)&&Wt(i,o,lt,null,x,_e);for(xe in x)if(_e=x[xe],Ee=f[xe],x.hasOwnProperty(xe)&&_e!==Ee&&(_e!=null||Ee!=null))switch(xe){case"children":case"dangerouslySetInnerHTML":if(_e!=null)throw Error(r(137,o));break;default:Wt(i,o,xe,_e,x,Ee)}return;default:if(Kf(o)){for(var Gt in f)_e=f[Gt],f.hasOwnProperty(Gt)&&_e!==void 0&&!x.hasOwnProperty(Gt)&&Op(i,o,Gt,void 0,x,_e);for(Re in x)_e=x[Re],Ee=f[Re],!x.hasOwnProperty(Re)||_e===Ee||_e===void 0&&Ee===void 0||Op(i,o,Re,_e,x,Ee);return}}for(var fe in f)_e=f[fe],f.hasOwnProperty(fe)&&_e!=null&&!x.hasOwnProperty(fe)&&Wt(i,o,fe,null,x,_e);for(Be in x)_e=x[Be],Ee=f[Be],!x.hasOwnProperty(Be)||_e===Ee||_e==null&&Ee==null||Wt(i,o,Be,_e,x,Ee)}function Q0(i){switch(i){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function xL(){if(typeof performance.getEntriesByType=="function"){for(var i=0,o=0,f=performance.getEntriesByType("resource"),x=0;x<f.length;x++){var j=f[x],L=j.transferSize,G=j.initiatorType,ee=j.duration;if(L&&ee&&Q0(G)){for(G=0,ee=j.responseEnd,x+=1;x<f.length;x++){var le=f[x],xe=le.startTime;if(xe>ee)break;var Re=le.transferSize,Be=le.initiatorType;Re&&Q0(Be)&&(le=le.responseEnd,G+=Re*(le<ee?1:(ee-xe)/(le-xe)))}if(--x,o+=8*(L+G)/(j.duration/1e3),i++,10<i)break}}if(0<i)return o/i/1e6}return navigator.connection&&(i=navigator.connection.downlink,typeof i=="number")?i:5}var Ip=null,Mp=null;function _d(i){return i.nodeType===9?i:i.ownerDocument}function J0(i){switch(i){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function Z0(i,o){if(i===0)switch(o){case"svg":return 1;case"math":return 2;default:return 0}return i===1&&o==="foreignObject"?0:i}function Pp(i,o){return i==="textarea"||i==="noscript"||typeof o.children=="string"||typeof o.children=="number"||typeof o.children=="bigint"||typeof o.dangerouslySetInnerHTML=="object"&&o.dangerouslySetInnerHTML!==null&&o.dangerouslySetInnerHTML.__html!=null}var Bp=null;function yL(){var i=window.event;return i&&i.type==="popstate"?i===Bp?!1:(Bp=i,!0):(Bp=null,!1)}var eS=typeof setTimeout=="function"?setTimeout:void 0,bL=typeof clearTimeout=="function"?clearTimeout:void 0,tS=typeof Promise=="function"?Promise:void 0,vL=typeof queueMicrotask=="function"?queueMicrotask:typeof tS<"u"?function(i){return tS.resolve(null).then(i).catch(_L)}:eS;function _L(i){setTimeout(function(){throw i})}function Ti(i){return i==="head"}function nS(i,o){var f=o,x=0;do{var j=f.nextSibling;if(i.removeChild(f),j&&j.nodeType===8)if(f=j.data,f==="/$"||f==="/&"){if(x===0){i.removeChild(j),Mo(o);return}x--}else if(f==="$"||f==="$?"||f==="$~"||f==="$!"||f==="&")x++;else if(f==="html")ic(i.ownerDocument.documentElement);else if(f==="head"){f=i.ownerDocument.head,ic(f);for(var L=f.firstChild;L;){var G=L.nextSibling,ee=L.nodeName;L[wn]||ee==="SCRIPT"||ee==="STYLE"||ee==="LINK"&&L.rel.toLowerCase()==="stylesheet"||f.removeChild(L),L=G}}else f==="body"&&ic(i.ownerDocument.body);f=j}while(f);Mo(o)}function rS(i,o){var f=i;i=0;do{var x=f.nextSibling;if(f.nodeType===1?o?(f._stashedDisplay=f.style.display,f.style.display="none"):(f.style.display=f._stashedDisplay||"",f.getAttribute("style")===""&&f.removeAttribute("style")):f.nodeType===3&&(o?(f._stashedText=f.nodeValue,f.nodeValue=""):f.nodeValue=f._stashedText||""),x&&x.nodeType===8)if(f=x.data,f==="/$"){if(i===0)break;i--}else f!=="$"&&f!=="$?"&&f!=="$~"&&f!=="$!"||i++;f=x}while(f)}function $p(i){var o=i.firstChild;for(o&&o.nodeType===10&&(o=o.nextSibling);o;){var f=o;switch(o=o.nextSibling,f.nodeName){case"HTML":case"HEAD":case"BODY":$p(f),Ja(f);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(f.rel.toLowerCase()==="stylesheet")continue}i.removeChild(f)}}function SL(i,o,f,x){for(;i.nodeType===1;){var j=f;if(i.nodeName.toLowerCase()!==o.toLowerCase()){if(!x&&(i.nodeName!=="INPUT"||i.type!=="hidden"))break}else if(x){if(!i[wn])switch(o){case"meta":if(!i.hasAttribute("itemprop"))break;return i;case"link":if(L=i.getAttribute("rel"),L==="stylesheet"&&i.hasAttribute("data-precedence"))break;if(L!==j.rel||i.getAttribute("href")!==(j.href==null||j.href===""?null:j.href)||i.getAttribute("crossorigin")!==(j.crossOrigin==null?null:j.crossOrigin)||i.getAttribute("title")!==(j.title==null?null:j.title))break;return i;case"style":if(i.hasAttribute("data-precedence"))break;return i;case"script":if(L=i.getAttribute("src"),(L!==(j.src==null?null:j.src)||i.getAttribute("type")!==(j.type==null?null:j.type)||i.getAttribute("crossorigin")!==(j.crossOrigin==null?null:j.crossOrigin))&&L&&i.hasAttribute("async")&&!i.hasAttribute("itemprop"))break;return i;default:return i}}else if(o==="input"&&i.type==="hidden"){var L=j.name==null?null:""+j.name;if(j.type==="hidden"&&i.getAttribute("name")===L)return i}else return i;if(i=Fr(i.nextSibling),i===null)break}return null}function wL(i,o,f){if(o==="")return null;for(;i.nodeType!==3;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!f||(i=Fr(i.nextSibling),i===null))return null;return i}function sS(i,o){for(;i.nodeType!==8;)if((i.nodeType!==1||i.nodeName!=="INPUT"||i.type!=="hidden")&&!o||(i=Fr(i.nextSibling),i===null))return null;return i}function zp(i){return i.data==="$?"||i.data==="$~"}function Hp(i){return i.data==="$!"||i.data==="$?"&&i.ownerDocument.readyState!=="loading"}function CL(i,o){var f=i.ownerDocument;if(i.data==="$~")i._reactRetry=o;else if(i.data!=="$?"||f.readyState!=="loading")o();else{var x=function(){o(),f.removeEventListener("DOMContentLoaded",x)};f.addEventListener("DOMContentLoaded",x),i._reactRetry=x}}function Fr(i){for(;i!=null;i=i.nextSibling){var o=i.nodeType;if(o===1||o===3)break;if(o===8){if(o=i.data,o==="$"||o==="$!"||o==="$?"||o==="$~"||o==="&"||o==="F!"||o==="F")break;if(o==="/$"||o==="/&")return null}}return i}var Fp=null;function iS(i){i=i.nextSibling;for(var o=0;i;){if(i.nodeType===8){var f=i.data;if(f==="/$"||f==="/&"){if(o===0)return Fr(i.nextSibling);o--}else f!=="$"&&f!=="$!"&&f!=="$?"&&f!=="$~"&&f!=="&"||o++}i=i.nextSibling}return null}function aS(i){i=i.previousSibling;for(var o=0;i;){if(i.nodeType===8){var f=i.data;if(f==="$"||f==="$!"||f==="$?"||f==="$~"||f==="&"){if(o===0)return i;o--}else f!=="/$"&&f!=="/&"||o++}i=i.previousSibling}return null}function oS(i,o,f){switch(o=_d(f),i){case"html":if(i=o.documentElement,!i)throw Error(r(452));return i;case"head":if(i=o.head,!i)throw Error(r(453));return i;case"body":if(i=o.body,!i)throw Error(r(454));return i;default:throw Error(r(451))}}function ic(i){for(var o=i.attributes;o.length;)i.removeAttributeNode(o[0]);Ja(i)}var Ur=new Map,lS=new Set;function Sd(i){return typeof i.getRootNode=="function"?i.getRootNode():i.nodeType===9?i:i.ownerDocument}var Xs=Q.d;Q.d={f:kL,r:EL,D:jL,C:NL,L:TL,m:AL,X:RL,S:LL,M:DL};function kL(){var i=Xs.f(),o=fd();return i||o}function EL(i){var o=eo(i);o!==null&&o.tag===5&&o.type==="form"?k_(o):Xs.r(i)}var Do=typeof document>"u"?null:document;function cS(i,o,f){var x=Do;if(x&&typeof o=="string"&&o){var j=Ir(o);j='link[rel="'+i+'"][href="'+j+'"]',typeof f=="string"&&(j+='[crossorigin="'+f+'"]'),lS.has(j)||(lS.add(j),i={rel:i,crossOrigin:f,href:o},x.querySelector(j)===null&&(o=x.createElement("link"),Wn(o,"link",i),Pn(o),x.head.appendChild(o)))}}function jL(i){Xs.D(i),cS("dns-prefetch",i,null)}function NL(i,o){Xs.C(i,o),cS("preconnect",i,o)}function TL(i,o,f){Xs.L(i,o,f);var x=Do;if(x&&i&&o){var j='link[rel="preload"][as="'+Ir(o)+'"]';o==="image"&&f&&f.imageSrcSet?(j+='[imagesrcset="'+Ir(f.imageSrcSet)+'"]',typeof f.imageSizes=="string"&&(j+='[imagesizes="'+Ir(f.imageSizes)+'"]')):j+='[href="'+Ir(i)+'"]';var L=j;switch(o){case"style":L=Oo(i);break;case"script":L=Io(i)}Ur.has(L)||(i=m({rel:"preload",href:o==="image"&&f&&f.imageSrcSet?void 0:i,as:o},f),Ur.set(L,i),x.querySelector(j)!==null||o==="style"&&x.querySelector(ac(L))||o==="script"&&x.querySelector(oc(L))||(o=x.createElement("link"),Wn(o,"link",i),Pn(o),x.head.appendChild(o)))}}function AL(i,o){Xs.m(i,o);var f=Do;if(f&&i){var x=o&&typeof o.as=="string"?o.as:"script",j='link[rel="modulepreload"][as="'+Ir(x)+'"][href="'+Ir(i)+'"]',L=j;switch(x){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":L=Io(i)}if(!Ur.has(L)&&(i=m({rel:"modulepreload",href:i},o),Ur.set(L,i),f.querySelector(j)===null)){switch(x){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(f.querySelector(oc(L)))return}x=f.createElement("link"),Wn(x,"link",i),Pn(x),f.head.appendChild(x)}}}function LL(i,o,f){Xs.S(i,o,f);var x=Do;if(x&&i){var j=to(x).hoistableStyles,L=Oo(i);o=o||"default";var G=j.get(L);if(!G){var ee={loading:0,preload:null};if(G=x.querySelector(ac(L)))ee.loading=5;else{i=m({rel:"stylesheet",href:i,"data-precedence":o},f),(f=Ur.get(L))&&Up(i,f);var le=G=x.createElement("link");Pn(le),Wn(le,"link",i),le._p=new Promise(function(xe,Re){le.onload=xe,le.onerror=Re}),le.addEventListener("load",function(){ee.loading|=1}),le.addEventListener("error",function(){ee.loading|=2}),ee.loading|=4,wd(G,o,x)}G={type:"stylesheet",instance:G,count:1,state:ee},j.set(L,G)}}}function RL(i,o){Xs.X(i,o);var f=Do;if(f&&i){var x=to(f).hoistableScripts,j=Io(i),L=x.get(j);L||(L=f.querySelector(oc(j)),L||(i=m({src:i,async:!0},o),(o=Ur.get(j))&&Vp(i,o),L=f.createElement("script"),Pn(L),Wn(L,"link",i),f.head.appendChild(L)),L={type:"script",instance:L,count:1,state:null},x.set(j,L))}}function DL(i,o){Xs.M(i,o);var f=Do;if(f&&i){var x=to(f).hoistableScripts,j=Io(i),L=x.get(j);L||(L=f.querySelector(oc(j)),L||(i=m({src:i,async:!0,type:"module"},o),(o=Ur.get(j))&&Vp(i,o),L=f.createElement("script"),Pn(L),Wn(L,"link",i),f.head.appendChild(L)),L={type:"script",instance:L,count:1,state:null},x.set(j,L))}}function uS(i,o,f,x){var j=(j=Z.current)?Sd(j):null;if(!j)throw Error(r(446));switch(i){case"meta":case"title":return null;case"style":return typeof f.precedence=="string"&&typeof f.href=="string"?(o=Oo(f.href),f=to(j).hoistableStyles,x=f.get(o),x||(x={type:"style",instance:null,count:0,state:null},f.set(o,x)),x):{type:"void",instance:null,count:0,state:null};case"link":if(f.rel==="stylesheet"&&typeof f.href=="string"&&typeof f.precedence=="string"){i=Oo(f.href);var L=to(j).hoistableStyles,G=L.get(i);if(G||(j=j.ownerDocument||j,G={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},L.set(i,G),(L=j.querySelector(ac(i)))&&!L._p&&(G.instance=L,G.state.loading=5),Ur.has(i)||(f={rel:"preload",as:"style",href:f.href,crossOrigin:f.crossOrigin,integrity:f.integrity,media:f.media,hrefLang:f.hrefLang,referrerPolicy:f.referrerPolicy},Ur.set(i,f),L||OL(j,i,f,G.state))),o&&x===null)throw Error(r(528,""));return G}if(o&&x!==null)throw Error(r(529,""));return null;case"script":return o=f.async,f=f.src,typeof f=="string"&&o&&typeof o!="function"&&typeof o!="symbol"?(o=Io(f),f=to(j).hoistableScripts,x=f.get(o),x||(x={type:"script",instance:null,count:0,state:null},f.set(o,x)),x):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,i))}}function Oo(i){return'href="'+Ir(i)+'"'}function ac(i){return'link[rel="stylesheet"]['+i+"]"}function dS(i){return m({},i,{"data-precedence":i.precedence,precedence:null})}function OL(i,o,f,x){i.querySelector('link[rel="preload"][as="style"]['+o+"]")?x.loading=1:(o=i.createElement("link"),x.preload=o,o.addEventListener("load",function(){return x.loading|=1}),o.addEventListener("error",function(){return x.loading|=2}),Wn(o,"link",f),Pn(o),i.head.appendChild(o))}function Io(i){return'[src="'+Ir(i)+'"]'}function oc(i){return"script[async]"+i}function hS(i,o,f){if(o.count++,o.instance===null)switch(o.type){case"style":var x=i.querySelector('style[data-href~="'+Ir(f.href)+'"]');if(x)return o.instance=x,Pn(x),x;var j=m({},f,{"data-href":f.href,"data-precedence":f.precedence,href:null,precedence:null});return x=(i.ownerDocument||i).createElement("style"),Pn(x),Wn(x,"style",j),wd(x,f.precedence,i),o.instance=x;case"stylesheet":j=Oo(f.href);var L=i.querySelector(ac(j));if(L)return o.state.loading|=4,o.instance=L,Pn(L),L;x=dS(f),(j=Ur.get(j))&&Up(x,j),L=(i.ownerDocument||i).createElement("link"),Pn(L);var G=L;return G._p=new Promise(function(ee,le){G.onload=ee,G.onerror=le}),Wn(L,"link",x),o.state.loading|=4,wd(L,f.precedence,i),o.instance=L;case"script":return L=Io(f.src),(j=i.querySelector(oc(L)))?(o.instance=j,Pn(j),j):(x=f,(j=Ur.get(L))&&(x=m({},f),Vp(x,j)),i=i.ownerDocument||i,j=i.createElement("script"),Pn(j),Wn(j,"link",x),i.head.appendChild(j),o.instance=j);case"void":return null;default:throw Error(r(443,o.type))}else o.type==="stylesheet"&&(o.state.loading&4)===0&&(x=o.instance,o.state.loading|=4,wd(x,f.precedence,i));return o.instance}function wd(i,o,f){for(var x=f.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),j=x.length?x[x.length-1]:null,L=j,G=0;G<x.length;G++){var ee=x[G];if(ee.dataset.precedence===o)L=ee;else if(L!==j)break}L?L.parentNode.insertBefore(i,L.nextSibling):(o=f.nodeType===9?f.head:f,o.insertBefore(i,o.firstChild))}function Up(i,o){i.crossOrigin==null&&(i.crossOrigin=o.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=o.referrerPolicy),i.title==null&&(i.title=o.title)}function Vp(i,o){i.crossOrigin==null&&(i.crossOrigin=o.crossOrigin),i.referrerPolicy==null&&(i.referrerPolicy=o.referrerPolicy),i.integrity==null&&(i.integrity=o.integrity)}var Cd=null;function fS(i,o,f){if(Cd===null){var x=new Map,j=Cd=new Map;j.set(f,x)}else j=Cd,x=j.get(f),x||(x=new Map,j.set(f,x));if(x.has(i))return x;for(x.set(i,null),f=f.getElementsByTagName(i),j=0;j<f.length;j++){var L=f[j];if(!(L[wn]||L[Pe]||i==="link"&&L.getAttribute("rel")==="stylesheet")&&L.namespaceURI!=="http://www.w3.org/2000/svg"){var G=L.getAttribute(o)||"";G=i+G;var ee=x.get(G);ee?ee.push(L):x.set(G,[L])}}return x}function mS(i,o,f){i=i.ownerDocument||i,i.head.insertBefore(f,o==="title"?i.querySelector("head > title"):null)}function IL(i,o,f){if(f===1||o.itemProp!=null)return!1;switch(i){case"meta":case"title":return!0;case"style":if(typeof o.precedence!="string"||typeof o.href!="string"||o.href==="")break;return!0;case"link":if(typeof o.rel!="string"||typeof o.href!="string"||o.href===""||o.onLoad||o.onError)break;switch(o.rel){case"stylesheet":return i=o.disabled,typeof o.precedence=="string"&&i==null;default:return!0}case"script":if(o.async&&typeof o.async!="function"&&typeof o.async!="symbol"&&!o.onLoad&&!o.onError&&o.src&&typeof o.src=="string")return!0}return!1}function pS(i){return!(i.type==="stylesheet"&&(i.state.loading&3)===0)}function ML(i,o,f,x){if(f.type==="stylesheet"&&(typeof x.media!="string"||matchMedia(x.media).matches!==!1)&&(f.state.loading&4)===0){if(f.instance===null){var j=Oo(x.href),L=o.querySelector(ac(j));if(L){o=L._p,o!==null&&typeof o=="object"&&typeof o.then=="function"&&(i.count++,i=kd.bind(i),o.then(i,i)),f.state.loading|=4,f.instance=L,Pn(L);return}L=o.ownerDocument||o,x=dS(x),(j=Ur.get(j))&&Up(x,j),L=L.createElement("link"),Pn(L);var G=L;G._p=new Promise(function(ee,le){G.onload=ee,G.onerror=le}),Wn(L,"link",x),f.instance=L}i.stylesheets===null&&(i.stylesheets=new Map),i.stylesheets.set(f,o),(o=f.state.preload)&&(f.state.loading&3)===0&&(i.count++,f=kd.bind(i),o.addEventListener("load",f),o.addEventListener("error",f))}}var Wp=0;function PL(i,o){return i.stylesheets&&i.count===0&&jd(i,i.stylesheets),0<i.count||0<i.imgCount?function(f){var x=setTimeout(function(){if(i.stylesheets&&jd(i,i.stylesheets),i.unsuspend){var L=i.unsuspend;i.unsuspend=null,L()}},6e4+o);0<i.imgBytes&&Wp===0&&(Wp=62500*xL());var j=setTimeout(function(){if(i.waitingForImages=!1,i.count===0&&(i.stylesheets&&jd(i,i.stylesheets),i.unsuspend)){var L=i.unsuspend;i.unsuspend=null,L()}},(i.imgBytes>Wp?50:800)+o);return i.unsuspend=f,function(){i.unsuspend=null,clearTimeout(x),clearTimeout(j)}}:null}function kd(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)jd(this,this.stylesheets);else if(this.unsuspend){var i=this.unsuspend;this.unsuspend=null,i()}}}var Ed=null;function jd(i,o){i.stylesheets=null,i.unsuspend!==null&&(i.count++,Ed=new Map,o.forEach(BL,i),Ed=null,kd.call(i))}function BL(i,o){if(!(o.state.loading&4)){var f=Ed.get(i);if(f)var x=f.get(null);else{f=new Map,Ed.set(i,f);for(var j=i.querySelectorAll("link[data-precedence],style[data-precedence]"),L=0;L<j.length;L++){var G=j[L];(G.nodeName==="LINK"||G.getAttribute("media")!=="not all")&&(f.set(G.dataset.precedence,G),x=G)}x&&f.set(null,x)}j=o.instance,G=j.getAttribute("data-precedence"),L=f.get(G)||x,L===x&&f.set(null,j),f.set(G,j),this.count++,x=kd.bind(this),j.addEventListener("load",x),j.addEventListener("error",x),L?L.parentNode.insertBefore(j,L.nextSibling):(i=i.nodeType===9?i.head:i,i.insertBefore(j,i.firstChild)),o.state.loading|=4}}var lc={$$typeof:v,Provider:null,Consumer:null,_currentValue:X,_currentValue2:X,_threadCount:0};function $L(i,o,f,x,j,L,G,ee,le){this.tag=1,this.containerInfo=i,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=er(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=er(0),this.hiddenUpdates=er(null),this.identifierPrefix=x,this.onUncaughtError=j,this.onCaughtError=L,this.onRecoverableError=G,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=le,this.incompleteTransitions=new Map}function gS(i,o,f,x,j,L,G,ee,le,xe,Re,Be){return i=new $L(i,o,f,G,le,xe,Re,Be,ee),o=1,L===!0&&(o|=24),L=_r(3,null,null,o),i.current=L,L.stateNode=i,o=Cm(),o.refCount++,i.pooledCache=o,o.refCount++,L.memoizedState={element:x,isDehydrated:f,cache:o},Nm(L),i}function xS(i){return i?(i=ho,i):ho}function yS(i,o,f,x,j,L){j=xS(j),x.context===null?x.context=j:x.pendingContext=j,x=yi(o),x.payload={element:f},L=L===void 0?null:L,L!==null&&(x.callback=L),f=bi(i,x,o),f!==null&&(dr(f,i,o),zl(f,i,o))}function bS(i,o){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var f=i.retryLane;i.retryLane=f!==0&&f<o?f:o}}function Gp(i,o){bS(i,o),(i=i.alternate)&&bS(i,o)}function vS(i){if(i.tag===13||i.tag===31){var o=aa(i,67108864);o!==null&&dr(o,i,67108864),Gp(i,67108864)}}function _S(i){if(i.tag===13||i.tag===31){var o=Er();o=Ze(o);var f=aa(i,o);f!==null&&dr(f,i,o),Gp(i,o)}}var Nd=!0;function zL(i,o,f,x){var j=F.T;F.T=null;var L=Q.p;try{Q.p=2,qp(i,o,f,x)}finally{Q.p=L,F.T=j}}function HL(i,o,f,x){var j=F.T;F.T=null;var L=Q.p;try{Q.p=8,qp(i,o,f,x)}finally{Q.p=L,F.T=j}}function qp(i,o,f,x){if(Nd){var j=Kp(x);if(j===null)Dp(i,o,x,Td,f),wS(i,x);else if(UL(j,i,o,f,x))x.stopPropagation();else if(wS(i,x),o&4&&-1<FL.indexOf(i)){for(;j!==null;){var L=eo(j);if(L!==null)switch(L.tag){case 3:if(L=L.stateNode,L.current.memoizedState.isDehydrated){var G=_n(L.pendingLanes);if(G!==0){var ee=L;for(ee.pendingLanes|=2,ee.entangledLanes|=2;G;){var le=1<<31-Ie(G);ee.entanglements[1]|=le,G&=~le}xs(L),(Mt&6)===0&&(dd=Ve()+500,nc(0))}}break;case 31:case 13:ee=aa(L,2),ee!==null&&dr(ee,L,2),fd(),Gp(L,2)}if(L=Kp(x),L===null&&Dp(i,o,x,Td,f),L===j)break;j=L}j!==null&&x.stopPropagation()}else Dp(i,o,x,null,f)}}function Kp(i){return i=Xf(i),Yp(i)}var Td=null;function Yp(i){if(Td=null,i=Za(i),i!==null){var o=l(i);if(o===null)i=null;else{var f=o.tag;if(f===13){if(i=u(o),i!==null)return i;i=null}else if(f===31){if(i=c(o),i!==null)return i;i=null}else if(f===3){if(o.stateNode.current.memoizedState.isDehydrated)return o.tag===3?o.stateNode.containerInfo:null;i=null}else o!==i&&(i=null)}}return Td=i,null}function SS(i){switch(i){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(He()){case ie:return 2;case ye:return 8;case Le:case ue:return 32;case de:return 268435456;default:return 32}default:return 32}}var Xp=!1,Ai=null,Li=null,Ri=null,cc=new Map,uc=new Map,Di=[],FL="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 wS(i,o){switch(i){case"focusin":case"focusout":Ai=null;break;case"dragenter":case"dragleave":Li=null;break;case"mouseover":case"mouseout":Ri=null;break;case"pointerover":case"pointerout":cc.delete(o.pointerId);break;case"gotpointercapture":case"lostpointercapture":uc.delete(o.pointerId)}}function dc(i,o,f,x,j,L){return i===null||i.nativeEvent!==L?(i={blockedOn:o,domEventName:f,eventSystemFlags:x,nativeEvent:L,targetContainers:[j]},o!==null&&(o=eo(o),o!==null&&vS(o)),i):(i.eventSystemFlags|=x,o=i.targetContainers,j!==null&&o.indexOf(j)===-1&&o.push(j),i)}function UL(i,o,f,x,j){switch(o){case"focusin":return Ai=dc(Ai,i,o,f,x,j),!0;case"dragenter":return Li=dc(Li,i,o,f,x,j),!0;case"mouseover":return Ri=dc(Ri,i,o,f,x,j),!0;case"pointerover":var L=j.pointerId;return cc.set(L,dc(cc.get(L)||null,i,o,f,x,j)),!0;case"gotpointercapture":return L=j.pointerId,uc.set(L,dc(uc.get(L)||null,i,o,f,x,j)),!0}return!1}function CS(i){var o=Za(i.target);if(o!==null){var f=l(o);if(f!==null){if(o=f.tag,o===13){if(o=u(f),o!==null){i.blockedOn=o,Ne(i.priority,function(){_S(f)});return}}else if(o===31){if(o=c(f),o!==null){i.blockedOn=o,Ne(i.priority,function(){_S(f)});return}}else if(o===3&&f.stateNode.current.memoizedState.isDehydrated){i.blockedOn=f.tag===3?f.stateNode.containerInfo:null;return}}}i.blockedOn=null}function Ad(i){if(i.blockedOn!==null)return!1;for(var o=i.targetContainers;0<o.length;){var f=Kp(i.nativeEvent);if(f===null){f=i.nativeEvent;var x=new f.constructor(f.type,f);Yf=x,f.target.dispatchEvent(x),Yf=null}else return o=eo(f),o!==null&&vS(o),i.blockedOn=f,!1;o.shift()}return!0}function kS(i,o,f){Ad(i)&&f.delete(o)}function VL(){Xp=!1,Ai!==null&&Ad(Ai)&&(Ai=null),Li!==null&&Ad(Li)&&(Li=null),Ri!==null&&Ad(Ri)&&(Ri=null),cc.forEach(kS),uc.forEach(kS)}function Ld(i,o){i.blockedOn===o&&(i.blockedOn=null,Xp||(Xp=!0,e.unstable_scheduleCallback(e.unstable_NormalPriority,VL)))}var Rd=null;function ES(i){Rd!==i&&(Rd=i,e.unstable_scheduleCallback(e.unstable_NormalPriority,function(){Rd===i&&(Rd=null);for(var o=0;o<i.length;o+=3){var f=i[o],x=i[o+1],j=i[o+2];if(typeof x!="function"){if(Yp(x||f)===null)continue;break}var L=eo(f);L!==null&&(i.splice(o,3),o-=3,Km(L,{pending:!0,data:j,method:f.method,action:x},x,j))}}))}function Mo(i){function o(le){return Ld(le,i)}Ai!==null&&Ld(Ai,i),Li!==null&&Ld(Li,i),Ri!==null&&Ld(Ri,i),cc.forEach(o),uc.forEach(o);for(var f=0;f<Di.length;f++){var x=Di[f];x.blockedOn===i&&(x.blockedOn=null)}for(;0<Di.length&&(f=Di[0],f.blockedOn===null);)CS(f),f.blockedOn===null&&Di.shift();if(f=(i.ownerDocument||i).$$reactFormReplay,f!=null)for(x=0;x<f.length;x+=3){var j=f[x],L=f[x+1],G=j[Xe]||null;if(typeof L=="function")G||ES(f);else if(G){var ee=null;if(L&&L.hasAttribute("formAction")){if(j=L,G=L[Xe]||null)ee=G.formAction;else if(Yp(j)!==null)continue}else ee=G.action;typeof ee=="function"?f[x+1]=ee:(f.splice(x,3),x-=3),ES(f)}}}function jS(){function i(L){L.canIntercept&&L.info==="react-transition"&&L.intercept({handler:function(){return new Promise(function(G){return j=G})},focusReset:"manual",scroll:"manual"})}function o(){j!==null&&(j(),j=null),x||setTimeout(f,20)}function f(){if(!x&&!navigation.transition){var L=navigation.currentEntry;L&&L.url!=null&&navigation.navigate(L.url,{state:L.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var x=!1,j=null;return navigation.addEventListener("navigate",i),navigation.addEventListener("navigatesuccess",o),navigation.addEventListener("navigateerror",o),setTimeout(f,100),function(){x=!0,navigation.removeEventListener("navigate",i),navigation.removeEventListener("navigatesuccess",o),navigation.removeEventListener("navigateerror",o),j!==null&&(j(),j=null)}}}function Qp(i){this._internalRoot=i}Dd.prototype.render=Qp.prototype.render=function(i){var o=this._internalRoot;if(o===null)throw Error(r(409));var f=o.current,x=Er();yS(f,x,i,o,null,null)},Dd.prototype.unmount=Qp.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var o=i.containerInfo;yS(i.current,2,null,i,null,null),fd(),o[tt]=null}};function Dd(i){this._internalRoot=i}Dd.prototype.unstable_scheduleHydration=function(i){if(i){var o=nn();i={blockedOn:null,target:i,priority:o};for(var f=0;f<Di.length&&o!==0&&o<Di[f].priority;f++);Di.splice(f,0,i),f===0&&CS(i)}};var NS=t.version;if(NS!=="19.2.8")throw Error(r(527,NS,"19.2.8"));Q.findDOMNode=function(i){var o=i._reactInternals;if(o===void 0)throw typeof i.render=="function"?Error(r(188)):(i=Object.keys(i).join(","),Error(r(268,i)));return i=h(o),i=i!==null?p(i):null,i=i===null?null:i.stateNode,i};var WL={bundleType:0,version:"19.2.8",rendererPackageName:"react-dom",currentDispatcherRef:F,reconcilerVersion:"19.2.8"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Od=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Od.isDisabled&&Od.supportsFiber)try{Qe=Od.inject(WL),rt=Od}catch{}}return fc.createRoot=function(i,o){if(!a(i))throw Error(r(299));var f=!1,x="",j=I_,L=M_,G=P_;return o!=null&&(o.unstable_strictMode===!0&&(f=!0),o.identifierPrefix!==void 0&&(x=o.identifierPrefix),o.onUncaughtError!==void 0&&(j=o.onUncaughtError),o.onCaughtError!==void 0&&(L=o.onCaughtError),o.onRecoverableError!==void 0&&(G=o.onRecoverableError)),o=gS(i,1,!1,null,null,f,x,null,j,L,G,jS),i[tt]=o.current,Rp(i),new Qp(o)},fc.hydrateRoot=function(i,o,f){if(!a(i))throw Error(r(299));var x=!1,j="",L=I_,G=M_,ee=P_,le=null;return f!=null&&(f.unstable_strictMode===!0&&(x=!0),f.identifierPrefix!==void 0&&(j=f.identifierPrefix),f.onUncaughtError!==void 0&&(L=f.onUncaughtError),f.onCaughtError!==void 0&&(G=f.onCaughtError),f.onRecoverableError!==void 0&&(ee=f.onRecoverableError),f.formState!==void 0&&(le=f.formState)),o=gS(i,1,!0,o,f??null,x,j,le,L,G,ee,jS),o.context=xS(null),f=o.current,x=Er(),x=Ze(x),j=yi(x),j.callback=null,bi(f,j,x),f=x,o.current.lanes=f,be(o,f),xs(o),i[tt]=o.current,Rp(i),new Dd(o)},fc.version="19.2.8",fc}var zS;function aR(){if(zS)return ng.exports;zS=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(),ng.exports=iR(),ng.exports}var oR=aR();const lR=nf(oR);function cR(e,t){if(e instanceof RegExp)return{keys:!1,pattern:e};var n,r,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===":"?(r=a.indexOf("?",1),l=a.indexOf(".",1),u.push(a.substring(1,~r?r:~l?l:a.length)),c+=~r&&!~l?"(?:/([^/]+?))?":"/([^/]+?)",~l&&(c+=(~r?"?":"")+"\\"+a.substring(l))):c+="/"+a;return{keys:u,pattern:new RegExp("^"+c+(t?"(?=$|/)":"/?$"),"i")}}var ag={exports:{}},og={};/**
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 HS;function uR(){if(HS)return og;HS=1;var e=rf();function t(m,g){return m===g&&(m!==0||1/m===1/g)||m!==m&&g!==g}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,a=e.useEffect,l=e.useLayoutEffect,u=e.useDebugValue;function c(m,g){var y=g(),w=r({inst:{value:y,getSnapshot:g}}),C=w[0].inst,_=w[1];return l(function(){C.value=y,C.getSnapshot=g,d(C)&&_({inst:C})},[m,y,g]),a(function(){return d(C)&&_({inst:C}),m(function(){d(C)&&_({inst:C})})},[m]),u(y),y}function d(m){var g=m.getSnapshot;m=m.value;try{var y=g();return!n(m,y)}catch{return!0}}function h(m,g){return g()}var p=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h:c;return og.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:p,og}var FS;function dR(){return FS||(FS=1,ag.exports=uR()),ag.exports}var hR=dR();const fR=tR.useInsertionEffect,mR=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",pR=mR?E.useLayoutEffect:E.useEffect,gR=fR||pR,mk=e=>{const t=E.useRef([e,(...n)=>t[0](...n)]).current;return gR(()=>{t[0]=e}),t[1]},xR="popstate",my="pushState",py="replaceState",yR="hashchange",US=[xR,my,py,yR],bR=e=>{for(const t of US)addEventListener(t,e);return()=>{for(const t of US)removeEventListener(t,e)}},pk=(e,t)=>hR.useSyncExternalStore(bR,e,t),VS=()=>location.search,vR=({ssrSearch:e}={})=>pk(VS,e!=null?()=>e:VS),WS=()=>location.pathname,_R=({ssrPath:e}={})=>pk(WS,e!=null?()=>e:WS),SR=(e,{replace:t=!1,state:n=null}={})=>history[t?py:my](n,"",e),wR=(e={})=>[_R(e),SR],GS=Symbol.for("wouter_v3");if(typeof history<"u"&&typeof window[GS]>"u"){for(const e of[my,py]){const t=history[e];history[e]=function(){const n=t.apply(this,arguments),r=new Event(e);return r.arguments=arguments,dispatchEvent(r),n}}Object.defineProperty(window,GS,{value:!0})}const CR=(e,t)=>t.toLowerCase().indexOf(e.toLowerCase())?"~"+t:t.slice(e.length)||"/",gk=(e="")=>e==="/"?"":e,kR=(e,t)=>e[0]==="~"?e.slice(1):gk(t)+e,ER=(e="",t)=>CR(qS(gk(e)),qS(t)),qS=e=>{try{return decodeURI(e)}catch{return e}},xk={hook:wR,searchHook:vR,parser:cR,base:"",ssrPath:void 0,ssrSearch:void 0,ssrContext:void 0,hrefs:e=>e,aroundNav:(e,t,n)=>e(t,n)},yk=E.createContext(xk),fl=()=>E.useContext(yk),bk={},vk=E.createContext(bk),jR=()=>E.useContext(vk),sf=e=>{const[t,n]=e.hook(e);return[ER(e.base,t),mk((r,a)=>e.aroundNav(n,kR(r,e.base),a))]},Gn=()=>sf(fl()),gy=(e,t,n,r)=>{const{pattern:a,keys:l}=t instanceof RegExp?{keys:!1,pattern:t}:e(t||"*",r),u=a.exec(n)||[],[c,...d]=u;return c!==void 0?[!0,(()=>{const h=l!==!1?Object.fromEntries(l.map((m,g)=>[m,d[g]])):u.groups;let p={...d};return h&&Object.assign(p,h),p})(),...r?[c]:[]]:[!1,null]},ml=e=>gy(fl().parser,e,Gn()[0]),_k=({children:e,...t})=>{var p,m,g;const n=fl(),r=t.hook?xk:n;let a=r;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??((g=t.hook)==null?void 0:g.searchHook);let c=E.useRef({}),d=c.current,h=d;for(let y in r){const w=y==="base"?r[y]+(t[y]??""):t[y]??r[y];d===h&&w!==h[y]&&(c.current=h={...h}),h[y]=w,(w!==r[y]||w!==a[y])&&(a=h)}return E.createElement(yk.Provider,{value:a,children:e})},KS=({children:e,component:t},n)=>t?E.createElement(t,{params:n}):typeof e=="function"?e(n):e,NR=e=>{let t=E.useRef(bk);const n=t.current;return t.current=Object.keys(e).length!==Object.keys(n).length||Object.entries(e).some(([r,a])=>a!==n[r])?e:n},mc=({path:e,nest:t,match:n,...r})=>{const a=fl(),[l]=sf(a),[u,c,d]=n??gy(a.parser,e,l,t),h=NR({...jR(),...c});if(!u)return null;const p=d?E.createElement(_k,{base:d},KS(r,h)):KS(r,h);return E.createElement(vk.Provider,{value:h,children:p})},xr=E.forwardRef((e,t)=>{const n=fl(),[r,a]=sf(n),{to:l="",href:u=l,onClick:c,asChild:d,children:h,className:p,replace:m,state:g,transition:y,...w}=e,C=mk(S=>{S.ctrlKey||S.metaKey||S.altKey||S.shiftKey||S.button!==0||(c==null||c(S),S.defaultPrevented||(S.preventDefault(),a(u,e)))}),_=n.hrefs(u[0]==="~"?u.slice(1):n.base+u,n);return d&&E.isValidElement(h)?E.cloneElement(h,{onClick:C,href:_}):E.createElement("a",{...w,onClick:C,href:_,className:p!=null&&p.call?p(r===u):p,children:h,ref:t})}),Sk=e=>Array.isArray(e)?e.flatMap(t=>Sk(t&&t.type===E.Fragment?t.props.children:t)):[e],TR=({children:e,location:t})=>{const n=fl(),[r]=sf(n);for(const a of Sk(e)){let l=0;if(E.isValidElement(a)&&(l=gy(n.parser,a.props.path,t||r,a.props.nest))[0])return E.cloneElement(a,{match:l})}return null};/*!
59
+ * OverlayScrollbars
60
+ * Version: 2.16.0
61
+ *
62
+ * Copyright (c) Rene Haas | KingSora.
63
+ * https://github.com/KingSora
64
+ *
65
+ * Released under the MIT license.
66
+ */const Tr=(e,t)=>{const{o:n,i:r,u:a}=e;let l=n,u;const c=(p,m)=>{const g=l,y=p,w=m||(r?!r(g,y):g!==y);return(w||a)&&(l=y,u=g),[l,w,u]};return[t?p=>c(t(l,u),p):c,p=>[l,!!p,u]]},AR=typeof window<"u"&&typeof HTMLElement<"u"&&!!window.document,gr=AR?window:{},wk=Math.max,LR=Math.min,px=Math.round,Hi=Math.abs,YS=Math.sign,Ck=gr.cancelAnimationFrame,xy=gr.requestAnimationFrame,yy=gr.setTimeout,kk=gr.clearTimeout,af=e=>typeof gr[e]<"u"?gr[e]:void 0,RR=af("MutationObserver"),XS=af("IntersectionObserver"),Ko=af("ResizeObserver"),Lc=af("ScrollTimeline"),by=e=>e===void 0,of=e=>e===null,Vi=e=>typeof e=="number",pl=e=>typeof e=="string",lf=e=>typeof e=="boolean",fs=e=>typeof e=="function",Jr=e=>Array.isArray(e),wh=e=>typeof e=="object"&&!Jr(e)&&!of(e),vy=e=>{const t=!!e&&e.length,n=Vi(t)&&t>-1&&t%1==0;return Jr(e)||!fs(e)&&n?t>0&&wh(e)?t-1 in e:!0:!1},Vc=e=>!!e&&e.constructor===Object,Ch=e=>e instanceof HTMLElement,cf=e=>e instanceof Element;function Kt(e,t){if(vy(e))for(let n=0;n<e.length&&t(e[n],n,e)!==!1;n++);else e&&Kt(Object.keys(e),(n=>t(e[n],n,e)));return e}const Ek=(e,t)=>e.indexOf(t)>=0,al=(e,t)=>e.concat(t),un=(e,t,n)=>(!pl(t)&&vy(t)?Array.prototype.push.apply(e,t):e.push(t),e),Qi=e=>Array.from(e||[]),_y=e=>Jr(e)?e:!pl(e)&&vy(e)?Qi(e):[e],kh=e=>!!e&&!e.length,Eh=e=>Qi(new Set(e)),Lr=(e,t,n)=>{Kt(e,a=>a?a.apply(void 0,t||[]):!0),n||(e.length=0)},jk="paddingTop",Nk="paddingRight",Tk="paddingLeft",Ak="paddingBottom",Lk="marginLeft",Rk="marginRight",Dk="marginBottom",Sy="overflowX",wy="overflowY",uf="width",df="height",si="visible",ss="hidden",$a="scroll",DR=e=>{const t=String(e||"");return t?t[0].toUpperCase()+t.slice(1):""},hf=(e,t,n,r)=>{if(e&&t){let a=!0;return Kt(n,(l=>{const u=e[l],c=t[l];u!==c&&(a=!1)})),a}return!1},Ok=(e,t)=>hf(e,t,["w","h"]),hh=(e,t)=>hf(e,t,["x","y"]),OR=(e,t)=>hf(e,t,["t","r","b","l"]),ht=(e,...t)=>e.bind(0,...t),Yo=e=>{let t;const n=e?yy:xy,r=e?kk:Ck;return[a=>{r(t),t=n((()=>a()),fs(e)?e():e)},()=>r(t)]},QS=e=>{const t=fs(e)?e():e;if(Vi(t)){const n=t?yy:xy,r=t?kk:Ck;return a=>{const l=n((()=>a()),t);return()=>{r(l)}}}return t&&t._},Ik=(e,t)=>{const{p:n,v:r,S:a,m:l}=t||{};let u,c,d,h;const p=function(C){c&&c(),u&&u(),h=c=u=d=void 0,e.apply(this,C)},m=w=>l&&d?l(d,w):w,g=()=>{c&&d&&p(m(d)||d)},y=function(){const C=Qi(arguments),_=QS(n);if(_){const S=typeof a=="function"?a():a,b=QS(r),k=m(C)||C,T=p.bind(0,k);c&&c(),S&&!h?(T(),h=!0,c=_((()=>h=void 0))):(c=_(T),b&&!u&&(u=b(g))),d=k}else p(C)};return y.O=g,y},Mk=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),mr=e=>e?Object.keys(e):[],It=(e,t,n,r,a,l,u)=>{const c=[t,n,r,a,l,u];return(typeof e!="object"||of(e))&&!fs(e)&&(e={}),Kt(c,(d=>{Kt(d,((h,p)=>{const m=d[p];if(e===m)return!0;const g=Jr(m);if(m&&Vc(m)){const y=e[p];let w=y;g&&!Jr(y)?w=[]:!g&&!Vc(y)&&(w={}),e[p]=It(w,m)}else e[p]=g?m.slice():m}))})),e},Pk=(e,t)=>Kt(It({},e),((n,r,a)=>{n===void 0?delete a[r]:n&&Vc(n)&&(a[r]=Pk(n))})),Cy=e=>!mr(e).length,Wc=()=>{},Bk=(e,t,n)=>wk(e,LR(t,n)),za=e=>Eh((Jr(e)?e:(e||"").split(" ")).filter((t=>t))),ky=(e,t)=>e&&e.getAttribute(t),JS=(e,t)=>e&&e.hasAttribute(t),ti=(e,t,n)=>{Kt(za(t),(r=>{e&&e.setAttribute(r,String(n||""))}))},vs=(e,t)=>{Kt(za(t),(n=>e&&e.removeAttribute(n)))},ff=(e,t)=>{const n=za(ky(e,t)),r=ht(ti,e,t),a=(l,u)=>{const c=new Set(n);return Kt(za(l),(d=>{c[u](d)})),Qi(c).join(" ")};return{C:l=>r(a(l,"delete")),$:l=>r(a(l,"add")),H:l=>{const u=za(l);return u.reduce(((c,d)=>c&&n.includes(d)),u.length>0)}}},$k=(e,t,n)=>(ff(e,t).C(n),ht(Ey,e,t,n)),Ey=(e,t,n)=>(ff(e,t).$(n),ht($k,e,t,n)),jh=(e,t,n,r)=>(r?Ey:$k)(e,t,n),jy=(e,t,n)=>ff(e,t).H(n),zk=e=>ff(e,"class"),Hk=(e,t)=>{zk(e).C(t)},Ny=(e,t)=>(zk(e).$(t),ht(Hk,e,t)),Fk=(e,t)=>{const n=t?cf(t)&&t:document;return n?Qi(n.querySelectorAll(e)):[]},IR=(e,t)=>{const n=t?cf(t)&&t:document;return n&&n.querySelector(e)},gx=(e,t)=>cf(e)&&e.matches(t),Uk=e=>gx(e,"body"),xx=e=>e?Qi(e.childNodes):[],Gc=e=>e&&e.parentElement,Xo=(e,t)=>cf(e)&&e.closest(t),yx=e=>document.activeElement,MR=(e,t,n)=>{const r=Xo(e,t),a=e&&IR(n,r),l=Xo(a,t)===r;return r&&a?r===e||a===e||l&&Xo(Xo(e,n),t)!==r:!1},ol=e=>{Kt(_y(e),(t=>{const n=Gc(t);t&&n&&n.removeChild(t)}))},pr=(e,t)=>ht(ol,e&&t&&Kt(_y(t),(n=>{n&&e.appendChild(n)})));let Vk;const PR=()=>Vk,BR=e=>{Vk=e},Zo=e=>{const t=document.createElement("div");return ti(t,"class",e),t},Wk=e=>{const t=Zo(),n=PR(),r=e.trim();return t.innerHTML=n?n.createHTML(r):r,Kt(xx(t),(a=>ol(a)))},ZS=(e,t)=>e.getPropertyValue(t)||e[t]||"",Gk=e=>{const t=e||0;return isFinite(t)?t:0},Id=e=>Gk(parseFloat(e||"")),bx=e=>Math.round(e*1e4)/1e4,qk=e=>`${bx(Gk(e))}px`;function qc(e,t){e&&t&&Kt(t,((n,r)=>{try{const a=e.style,l=of(n)||lf(n)?"":Vi(n)?qk(n):n;r.indexOf("--")===0?a.setProperty(r,l):a[r]=l}catch{}}))}function js(e,t,n){const r=pl(t);let a=r?"":{};if(e){const l=gr.getComputedStyle(e,n)||e.style;a=r?ZS(l,t):Qi(t).reduce(((u,c)=>(u[c]=ZS(l,c),u)),a)}return a}const e1=(e,t,n)=>{const r=t?`${t}-`:"",a=n?`-${n}`:"",l=`${r}top${a}`,u=`${r}right${a}`,c=`${r}bottom${a}`,d=`${r}left${a}`,h=js(e,[l,u,c,d]);return{t:Id(h[l]),r:Id(h[u]),b:Id(h[c]),l:Id(h[d])}},lg=(e,t)=>`translate${wh(e)?`(${e.x},${e.y})`:`${t?"X":"Y"}(${e})`}`,$R=e=>!!(e.offsetWidth||e.offsetHeight||e.getClientRects().length),zR={w:0,h:0},mf=(e,t)=>t?{w:t[`${e}Width`],h:t[`${e}Height`]}:zR,HR=e=>mf("inner",e||gr),el=ht(mf,"offset"),Kk=ht(mf,"client"),Nh=ht(mf,"scroll"),Ty=e=>{const t=parseFloat(js(e,uf))||0,n=parseFloat(js(e,df))||0;return{w:t-px(t),h:n-px(n)}},cg=e=>e.getBoundingClientRect(),FR=e=>!!e&&$R(e),vx=e=>!!(e&&(e[df]||e[uf])),Yk=(e,t)=>{const n=vx(e);return!vx(t)&&n},t1=(e,t,n,r)=>{Kt(za(t),(a=>{e&&e.removeEventListener(a,n,r)}))},an=(e,t,n,r)=>{var a;const l=(a=r&&r.D)!=null?a:!0,u=r&&r.I||!1,c=r&&r.A||!1,d={passive:l,capture:u};return ht(Lr,za(t).map((h=>{const p=c?m=>{t1(e,h,p,u),n&&n(m)}:n;return e&&e.addEventListener(h,p,d),ht(t1,e,h,p,u)})))},Xk=e=>e.stopPropagation(),_x=e=>e.preventDefault(),Qk=e=>Xk(e)||_x(e),ks=(e,t)=>{const{x:n,y:r}=Vi(t)?{x:t,y:t}:t||{};Vi(n)&&(e.scrollLeft=n),Vi(r)&&(e.scrollTop=r)},Ar=e=>({x:e.scrollLeft,y:e.scrollTop}),Jk=()=>({T:{x:0,y:0},k:{x:0,y:0}}),UR=(e,t)=>{const{T:n,k:r}=e,{w:a,h:l}=t,u=(m,g,y)=>{let w=YS(m)*y,C=YS(g)*y;if(w===C){const _=Hi(m),S=Hi(g);C=_>S?0:C,w=_<S?0:w}return w=w===C?0:w,[w+0,C+0]},[c,d]=u(n.x,r.x,a),[h,p]=u(n.y,r.y,l);return{T:{x:c,y:h},k:{x:d,y:p}}},ug=({T:e,k:t})=>{const n=(r,a)=>r===0&&r<=a;return{x:n(e.x,t.x),y:n(e.y,t.y)}},n1=({T:e,k:t},n)=>{const r=(a,l,u)=>Bk(0,1,(a-u)/(a-l)||0);return{x:r(e.x,t.x,n.x),y:r(e.y,t.y,n.y)}},Sx=e=>{e&&e.focus&&e.focus({preventScroll:!0,focusVisible:!1})},r1=(e,t)=>{Kt(_y(t),e)},wx=e=>{const t=new Map,n=(l,u)=>{if(l){const c=t.get(l);r1((d=>{c&&c[d?"delete":"clear"](d)}),u)}else t.forEach((c=>{c.clear()})),t.clear()},r=(l,u)=>{if(pl(l)){const h=t.get(l)||new Set;return t.set(l,h),r1((p=>{fs(p)&&h.add(p)}),u),ht(n,l,u)}lf(u)&&u&&n();const c=mr(l),d=[];return Kt(c,(h=>{const p=l[h];p&&un(d,r(h,p))})),ht(Lr,d)},a=(l,u)=>{Kt(Qi(t.get(l)),(c=>{u&&!kh(u)?c.apply(0,u):c()}))};return r(e||{}),[r,n,a]},Zk={},eE={},VR=e=>{Kt(e,(t=>Kt(t,((n,r)=>{Zk[r]=t[r]}))))},tE=(e,t,n)=>mr(e).map((r=>{const{static:a,instance:l}=e[r],[u,c,d]=n||[],h=n?l:a;if(h){const p=n?h(u,c,t):h(t);return(d||eE)[r]=p}})),WR=(e,t)=>e[t],gl=e=>WR(eE,e),GR="__osOptionsValidationPlugin",xl="data-overlayscrollbars",fh="os-environment",Md=`${fh}-scrollbar-hidden`,dg=`${xl}-initialize`,mh="noClipping",s1=`${xl}-body`,Wi=xl,qR="host",ni=`${xl}-viewport`,KR=Sy,YR=wy,XR="arrange",nE="measuring",QR="scrolling",rE="scrollbarHidden",JR="noContent",Cx=`${xl}-padding`,i1=`${xl}-content`,Ay="os-size-observer",ZR=`${Ay}-appear`,eD=`${Ay}-listener`,tD="os-trinsic-observer",nD="os-theme-none",Dr="os-scrollbar",rD=`${Dr}-rtl`,sD=`${Dr}-horizontal`,iD=`${Dr}-vertical`,sE=`${Dr}-track`,Ly=`${Dr}-handle`,aD=`${Dr}-visible`,oD=`${Dr}-cornerless`,a1=`${Dr}-interaction`,o1=`${Dr}-unusable`,kx=`${Dr}-auto-hide`,lD=`${kx}-hidden`,l1=`${Dr}-wheel`,cD=`${sE}-interactive`,uD=`${Ly}-interactive`,dD="__osSizeObserverPlugin",hD=(e,t)=>{const{M:n}=t,[r,a]=e("showNativeOverlaidScrollbars");return[r&&n.x&&n.y,a]},Qo=e=>e.indexOf(si)===0,fD=e=>e.replace(`${si}-`,""),Ex=(e,t)=>{if(e==="auto")return t?$a:ss;const n=e||ss;return[ss,$a,si].includes(n)?n:ss},mD=(e,t)=>{const{overflowX:n,overflowY:r}=js(e,[Sy,wy]);return{x:Ex(n,t.x),y:Ex(r,t.y)}},Ry="__osScrollbarsHidingPlugin",pD="__osClickScrollPlugin",c1=e=>JSON.stringify(e,((t,n)=>{if(fs(n))throw 0;return n})),u1=(e,t)=>e?`${t}`.split(".").reduce(((n,r)=>n&&Mk(n,r)?n[r]:void 0),e):void 0,gD=[0,33],iE=[33,99],aE=[222,666,!0],xD={paddingAbsolute:!1,showNativeOverlaidScrollbars:!1,update:{elementEvents:[["img","load"]],debounce:{mutation:gD,resize:null,event:iE,env:aE},attributes:null,ignoreMutation:null,flowDirectionStyles:null},overflow:{x:"scroll",y:"scroll"},scrollbars:{theme:"os-theme-dark",visibility:"auto",autoHide:"never",autoHideDelay:1300,autoHideSuspend:!1,dragScroll:!0,clickScroll:!1,pointers:["mouse","touch","pen"]}},oE=(e,t)=>{const n={},r=al(mr(t),mr(e));return Kt(r,(a=>{const l=e[a],u=t[a];if(wh(l)&&wh(u))It(n[a]={},oE(l,u)),Cy(n[a])&&delete n[a];else if(Mk(t,a)&&u!==l){let c=!0;if(Jr(l)||Jr(u))try{c1(l)===c1(u)&&(c=!1)}catch{}c&&(n[a]=u)}})),n},hg=(e,t,n)=>r=>[u1(e,r),n||u1(t,r)!==void 0];let lE;const yD=()=>lE,bD=e=>{lE=e};let fg;const vD=()=>{const e=(k,T,N)=>{pr(document.body,k),pr(document.body,k);const R=Kk(k),A=el(k),O=Ty(T);return N&&ol(k),{x:A.h-R.h+O.h,y:A.w-R.w+O.w}},t=k=>{let T=!1;const N=Ny(k,Md);try{T=js(k,"scrollbar-width")==="none"||js(k,"display","::-webkit-scrollbar")==="none"}catch{}return N(),T},n=`.${fh}{scroll-behavior:auto!important;position:fixed;opacity:0;visibility:hidden;overflow:scroll;height:200px;width:200px;z-index:-1}.${fh} div{width:200%;height:200%;margin:10px 0}.${Md}{scrollbar-width:none!important}.${Md}::-webkit-scrollbar,.${Md}::-webkit-scrollbar-corner{appearance:none!important;display:none!important;width:0!important;height:0!important}`,a=Wk(`<div class="${fh}"><div></div><style>${n}</style></div>`)[0],l=a.firstChild,u=a.lastChild,c=yD();c&&(u.nonce=c);const[d,,h]=wx(),[p,m]=Tr({o:e(a,l),i:hh},ht(e,a,l,!0)),[g]=m(),y=t(a),w={x:g.x===0,y:g.y===0},C={elements:{host:null,padding:!y,viewport:k=>y&&Uk(k)&&k,content:!1},scrollbars:{slot:!0},cancel:{nativeScrollbarsOverlaid:!1,body:null}},_=It({},xD),S=ht(It,{},_),b=ht(It,{},C),v={U:g,M:w,P:y,J:!!Lc,G:ht(d,"r"),K:b,Z:k=>It(C,k)&&b(),tt:S,nt:k=>It(_,k)&&S(),ot:It({},C),st:It({},_)};if(vs(a,"style"),ol(a),an(gr,"resize",(()=>{h("r",[])})),fs(gr.matchMedia)&&!y&&(!w.x||!w.y)){const k=T=>{const N=gr.matchMedia(`(resolution: ${gr.devicePixelRatio}dppx)`);an(N,"change",(()=>{T(),k(T)}),{A:!0})};k((()=>{const[T,N]=p();It(v.U,T),h("r",[N])}))}return v},Ts=()=>(fg||(fg=vD()),fg),_D=(e,t,n)=>{let r=!1;const a=n?new WeakMap:!1,l=()=>{r=!0},u=c=>{if(a&&n){const d=n.map((h=>{const[p,m]=h||[];return[m&&p?(c||Fk)(p,e):[],m]}));Kt(d,(h=>Kt(h[0],(p=>{const m=h[1],g=a.get(p)||[];if(e.contains(p)&&m){const w=an(p,m,(C=>{r?(w(),a.delete(p)):t(C)}));a.set(p,un(g,w))}else Lr(g),a.delete(p)}))))}};return u(),[l,u]},d1=(e,t,n,r)=>{let a=!1;const{et:l,ct:u,rt:c,it:d,lt:h,ut:p}=r||{},[m,g]=_D(e,(()=>a&&n(!0)),c),y=l||[],w=u||[],C=al(y,w),_=(b,v)=>{if(!kh(v)){const k=h||Wc,T=p||Wc,N=[],R=[];let A=!1,O=!1;if(Kt(v,(P=>{const{attributeName:V,target:z,type:W,oldValue:M,addedNodes:U,removedNodes:F}=P,Q=W==="attributes",X=W==="childList",H=e===z,I=Q&&V,D=I&&ky(z,V||""),q=pl(D)?D:null,$=I&&M!==q,J=Ek(w,V)&&$;if(t&&(X||!H)){const Y=Q&&$,Z=Y&&d&&gx(z,d),B=(Z?!k(z,V,M,q):!Q||Y)&&!T(P,!!Z,e,r);Kt(U,(ne=>un(N,ne))),Kt(F,(ne=>un(N,ne))),O=O||B}!t&&H&&$&&!k(z,V,M,q)&&(un(R,V),A=A||J)})),g((P=>Eh(N).reduce(((V,z)=>(un(V,Fk(P,z)),gx(z,P)?un(V,z):V)),[]))),t)return!b&&O&&n(!1),[!1];if(!kh(R)||A){const P=[Eh(R),A];return b||n.apply(0,P),P}}},S=new RR(ht(_,!1));return[()=>(S.observe(e,{attributes:!0,attributeOldValue:!0,attributeFilter:C,subtree:t,childList:t,characterData:t}),a=!0,()=>{a&&(m(),S.disconnect(),a=!1)}),()=>{if(a)return _(!0,S.takeRecords())}]};let va=null;const cE=(e,t,n)=>{const{ft:r}=n||{},a=gl(dD),[l]=Tr({o:!1,u:!0});return()=>{const u=[],d=Wk(`<div class="${Ay}"><div class="${eD}"></div></div>`)[0],h=d.firstChild,p=m=>{const g=Jr(m)&&!kh(m);let y=!1,w=!1;if(g){const C=m[0],[_,,S]=l(C.contentRect),b=vx(_);w=Yk(_,S),y=!w&&!b}else w=m===!0;y||t({_t:!0,ft:w})};if(Ko){if(!lf(va)){const w=new Ko(Wc);w.observe(e,{get box(){va=!0}}),va=va||!1,w.disconnect()}const m=Ik(p,{p:0,v:0}),g=w=>m(w),y=new Ko(g);if(y.observe(va?e:h),un(u,[()=>{y.disconnect()},!va&&pr(e,d)]),va){const w=new Ko(g);w.observe(e,{box:"border-box"}),un(u,(()=>w.disconnect()))}}else if(a){const[m,g]=a(h,p,r);un(u,al([Ny(d,ZR),an(d,"animationstart",m),pr(e,d)],g))}else return Wc;return ht(Lr,u)}},SD=(e,t)=>{let n;const r=d=>d.h===0||d.isIntersecting||d.intersectionRatio>0,a=Zo(tD),[l]=Tr({o:!1}),u=(d,h)=>{if(d){const p=l(r(d)),[,m]=p;return m&&!h&&t(p)&&[p]}},c=(d,h)=>u(h.pop(),d);return[()=>{const d=[];if(XS)n=new XS(ht(c,!1),{root:e}),n.observe(a),un(d,(()=>{n.disconnect()}));else{const h=()=>{const p=el(a);u(p)};un(d,cE(a,h)()),h()}return ht(Lr,un(d,pr(e,a)))},()=>n&&c(!0,n.takeRecords())]},wD=(e,t,n,r)=>{let a,l,u,c,d,h,p,m;const g=`[${Wi}]`,y=`[${ni}]`,w=["id","class","style","open","wrap","cols","rows"],{dt:C,vt:_,L:S,gt:b,ht:v,V:k,bt:T,yt:N,wt:R,St:A}=e,O=K=>js(K,"direction")==="rtl",P=()=>{let K,B,ne;const se=Ik(r,{p:()=>K,v:()=>B,S:()=>ne,m(oe,ve){const[Se]=oe,[$e]=ve;return[al(mr(Se),mr($e)).reduce(((ze,ke)=>(ze[ke]=Se[ke]||$e[ke],ze)),{})]}}),re=(oe,ve)=>{if(Jr(ve)){const[Se,$e,ze]=ve;K=Se,B=$e,ne=ze}else Vi(ve)?(K=ve,B=!1,ne=!1):(K=!1,B=!1,ne=!1);se(oe)};return re.O=se.O,re},V={Ot:!1,B:O(C)},z=Ts(),W=gl(Ry),[M]=Tr({i:Ok,o:{w:0,h:0}},(()=>{const K=W&&W.R(e,t,V,z,n).Y,ne=!(T&&k)&&jy(_,Wi,mh),se=!k&&N(XR),re=se&&Ar(b),oe=re&&A(),ve=R(nE,ne),Se=se&&K&&K(),$e=Nh(S),ze=Ty(S);return Se&&Se(),ks(b,re),oe&&oe(),ne&&ve(),{w:$e.w+ze.w,h:$e.h+ze.h}})),U=P(),F=K=>{const B=O(C);It(K,{Ct:m!==B}),It(V,{B}),m=B},Q=(K,B)=>{const[ne,se]=K,re={$t:se};return It(V,{Ot:ne}),B||r(re),re},X=({_t:K,ft:B})=>{const ne=B?r:U,se={_t:K||B,ft:B};F(se),ne(se,l)},H=(K,B)=>{const[,ne]=M(),se={xt:ne};return F(se),ne&&!B&&U(se,K?u:a),se},I=(K,B,ne)=>{const se={Ht:B};return F(se),B&&!ne&&U(se,a),se},[D,q]=v?SD(_,Q):[],$=!k&&cE(_,X,{ft:!0}),[J,Y]=d1(_,!1,I,{ct:w,et:w}),Z=k&&Ko&&new Ko((K=>{const B=K[K.length-1].contentRect;X({_t:!0,ft:Yk(B,p)}),p=B}));return[()=>{Z&&Z.observe(_);const K=$&&$(),B=D&&D(),ne=J(),se=z.G((re=>{const[,oe]=M();U({Et:re,xt:oe,_t:T},c)}));return()=>{Z&&Z.disconnect(),K&&K(),B&&B(),h&&h(),ne(),se()}},({Dt:K,zt:B,It:ne})=>{const se={},[re]=K("update.ignoreMutation"),[oe,ve]=K("update.attributes"),[Se,$e]=K("update.elementEvents"),[ze,ke]=K("update.debounce"),Ge=$e||ve,Je=B||ne,Ce=me=>fs(re)&&!!re(me);if(Ge){d&&d(),h&&h();const[me,We]=d1(v||S,!0,H,{et:al(w,oe||[]),rt:Se,it:g,ut:(he,Ve)=>{const{target:He,attributeName:ie}=he;return(!Ve&&ie&&!k?MR(He,g,y):!1)||!!Xo(He,`.${Dr}`)||Ce(he)}});h=me(),d=We}if(ke&&(U.O(),Jr(ze)||Vi(ze)?(a=ze,l=!1,u=iE,c=aE):Vc(ze)?(a=ze.mutation,l=ze.resize,u=ze.event,c=ze.env):(a=!1,l=!1,u=!1,c=!1)),Je){const me=Y(),We=q&&q(),he=d&&d();me&&It(se,I(me[0],me[1],Je)),We&&It(se,Q(We[0],Je)),he&&It(se,H(he[0],Je))}return F(se),se},V]},uE=(e,t)=>fs(t)?t.apply(0,e):t,CD=(e,t,n,r)=>{const a=by(r)?n:r;return uE(e,a)||t.apply(0,e)},dE=(e,t,n,r)=>{const a=by(r)?n:r,l=uE(e,a);return!!l&&(Ch(l)?l:t.apply(0,e))},kD=(e,t)=>{const{nativeScrollbarsOverlaid:n,body:r}=t||{},{M:a,P:l,K:u}=Ts(),{nativeScrollbarsOverlaid:c,body:d}=u().cancel,h=n??c,p=by(r)?d:r,m=(a.x||a.y)&&h,g=e&&(of(p)?!l:p);return!!m||!!g},ED=(e,t,n,r)=>{const a="--os-viewport-percent",l="--os-scroll-percent",u="--os-scroll-direction",{K:c}=Ts(),{scrollbars:d}=c(),{slot:h}=d,{dt:p,vt:m,L:g,At:y,gt:w,bt:C,V:_}=t,{scrollbars:S}=y?{}:e,{slot:b}=S||{},v=[],k=[],T=[],N=dE([p,m,g],(()=>_&&C?p:m),h,b),R=D=>{if(Lc){let q=null,$=[];const J=new Lc({source:w,axis:D}),Y=()=>{q&&q.cancel(),q=null};return{Mt:K=>{const{Tt:B}=n,ne=ug(B)[D],se=D==="x",re=[lg(0,se),lg(`calc(-100% + 100cq${se?"w":"h"})`,se)],oe=ne?re:re.reverse();return $[0]===oe[0]&&$[1]===oe[1]||($=oe,Y(),q=K.kt.animate({clear:["left"],transform:oe},{timeline:J})),Y}}}},A={x:R("x"),y:R("y")},O=()=>{const{Rt:D,Vt:q}=n,$=(J,Y)=>Bk(0,1,J/(J+Y)||0);return{x:$(q.x,D.x),y:$(q.y,D.y)}},P=(D,q,$)=>{const J=$?Ny:Hk;Kt(D,(Y=>{J(Y.Lt,q)}))},V=(D,q)=>{Kt(D,($=>{const[J,Y]=q($);qc(J,Y)}))},z=(D,q,$)=>{const J=lf($),Y=J?$:!0,Z=J?!$:!0;Y&&P(k,D,q),Z&&P(T,D,q)},W=()=>{const D=O(),q=$=>J=>[J.Lt,{[a]:bx($)+""}];V(k,q(D.x)),V(T,q(D.y))},M=()=>{if(!Lc){const{Tt:D}=n,q=n1(D,Ar(w)),$=J=>Y=>[Y.Lt,{[l]:bx(J)+""}];V(k,$(q.x)),V(T,$(q.y))}},U=()=>{const{Tt:D}=n,q=ug(D),$=J=>Y=>[Y.Lt,{[u]:J?"0":"1"}];V(k,$(q.x)),V(T,$(q.y)),Lc&&(k.forEach(A.x.Mt),T.forEach(A.y.Mt))},F=()=>{if(_&&!C){const{Rt:D,Tt:q}=n,$=ug(q),J=n1(q,Ar(w)),Y=Z=>{const{Lt:K}=Z,B=Gc(K)===g&&K,ne=(se,re,oe)=>{const ve=re*se;return qk(oe?ve:-ve)};return[B,B&&{transform:lg({x:ne(J.x,D.x,$.x),y:ne(J.y,D.y,$.y)})}]};V(k,Y),V(T,Y)}},Q=D=>{const q=D?"x":"y",J=Zo(`${Dr} ${D?sD:iD}`),Y=Zo(sE),Z=Zo(Ly),K={Lt:J,Pt:Y,kt:Z},B=A[q];return un(D?k:T,K),un(v,[pr(J,Y),pr(Y,Z),ht(ol,J),B&&B.Mt(K),r(K,z,D)]),K},X=ht(Q,!0),H=ht(Q,!1),I=()=>(pr(N,k[0].Lt),pr(N,T[0].Lt),ht(Lr,v));return X(),H(),[{Ut:W,Nt:M,qt:U,Bt:F,Ft:z,jt:{Xt:k,Yt:X,Wt:ht(V,k)},Jt:{Xt:T,Yt:H,Wt:ht(V,T)}},I]},jD=(e,t,n,r,a)=>(l,u,c)=>{const{vt:d,L:h,V:p,gt:m,Gt:g,St:y}=t,{Lt:w,Pt:C,kt:_}=l,[S,b]=Yo(333),[v,k]=Yo(444),T=A=>{fs(m.scrollBy)&&m.scrollBy({behavior:"smooth",left:A.x,top:A.y})},N=()=>{const A="pointerup pointercancel lostpointercapture",O=`client${c?"X":"Y"}`,P=c?uf:df,V=c?"left":"top",z=c?"w":"h",W=c?"x":"y",M=[];return an(C,"pointerdown",r((U=>{const F=Xo(U.target,`.${Ly}`)===_,Q=F?_:C,X=e.scrollbars,H=X[F?"dragScroll":"clickScroll"],{button:I,isPrimary:D,pointerType:q}=U,{pointers:$}=X;if(I===0&&D&&H&&($||[]).includes(q)){Lr(M),k();const Y=!F&&(U.shiftKey||H==="instant"),Z=ht(cg,_),K=ht(cg,C),B=(He,ie)=>(He||Z())[V]-(ie||K())[V],ne=px(cg(m)[P])/el(m)[z]||1,se=Ar(m)[W],re=He=>{ks(m,{[W]:se+He})},oe=He=>{const{Rt:ie}=n,ye=el(C)[z]-el(_)[z],Le=1/ne*He/ye;re(Le*ie[W])},ve=U[O],Se=Z(),$e=K(),ze=Se[P],ke=B(Se,$e)+ze/2,Je=ve-$e[V]-ke,Ce=F?0:Je,me=He=>{Lr(Ve),Q.releasePointerCapture(He.pointerId)},We=F||Y,he=y(),Ve=[an(g,A,me),an(g,"selectstart",(He=>_x(He)),{D:!1}),an(C,A,me),We&&an(C,"pointermove",(He=>oe(Ce+He[O]-ve))),We&&(()=>{const He=Ar(m);he();const ie=Ar(m),ye={x:ie.x-He.x,y:ie.y-He.y};(Hi(ye.x)>3||Hi(ye.y)>3)&&(y(),ks(m,He),T(ye),v(he))})];if(Q.setPointerCapture(U.pointerId),Y)oe(Je);else if(!F){const He=gl(pD);if(He){const{Vt:ie}=n,ye=He(re,oe,ht(B),Je,ie[W],H,!!c,(Le=>{Le?he():un(Ve,he)}));un(Ve,ye),un(M,ht(ye,!0))}}}})))};let R=!0;return ht(Lr,[an(_,"pointermove pointerleave",r(a)),an(w,"pointerenter",r((()=>{u(a1,!0)}))),an(w,"pointerleave pointercancel",r((()=>{u(a1,!1)}))),an(w,"wheel",r((A=>{const{deltaX:O,deltaY:P,deltaMode:V}=A;R&&V===0&&Gc(w)===d&&T({x:O,y:P}),R=!1,u(l1,!0),S((()=>{R=!0,u(l1)})),_x(A)})),{D:!1,I:!0}),!p&&an(w,"mousedown",r((()=>{const A=yx();(JS(A,ni)||JS(A,Wi)||A===document.body)&&yy(ht(Sx,h),25)}))),an(w,"pointerdown",(()=>{const A=an(g,"click",(P=>{O(),Qk(P)}),{A:!0,I:!0,D:!1}),O=an(g,"pointerup pointercancel",(()=>{O(),setTimeout(A,150)}),{I:!0,D:!0})}),{I:!0,D:!0}),N(),b,k])},ND=(e,t,n,r,a,l,u)=>{let c,d,h,p,m,g=Wc,y=0;const w=["mouse","pen"],C=Z=>K=>{n.Kt||Z(K)},_=Z=>w.includes(Z.pointerType),[S,b]=Yo(),[v,k]=Yo(100),[T,N]=Yo(50),[R,A]=Yo((()=>y)),[O,P]=ED(e,l,a,jD(t,l,a,C,(Z=>_(Z)&&I()))),{vt:V,Qt:z,bt:W}=l,{Ft:M,Ut:U,Nt:F,qt:Q,Bt:X}=O,H=(Z,K)=>{A();const B=ne=>{n.Kt||M(lD,ne)};if(Z)B();else{const ne=h?!c:!0;y>0&&!K?R(ht(B,ne)):B(ne)}},I=()=>{(h?!c:!p)&&(H(!0),v((()=>{H(!1)})))},D=Z=>{_(Z)&&(c=!0,!n.Kt&&h&&H(!0))},q=Z=>{_(Z)&&(c=!1,!n.Kt&&h&&H(!1))},$=Z=>{M(kx,Z,!0),M(kx,Z,!1)},J=[A,k,N,b,()=>g(),an(V,"pointerover",D,{A:!0}),an(V,"pointerenter",D),an(V,"pointerleave",q),an(V,"pointermove",C((Z=>{_(Z)&&d&&I()}))),an(z,"scroll",C((Z=>{S((()=>{F(),I()})),u(Z),X()})))],Y=gl(Ry);return[()=>ht(Lr,un(J,P())),({Dt:Z,It:K,Zt:B,tn:ne})=>{const{nn:se,sn:re,en:oe,cn:ve}=ne||{},{Ct:Se,ft:$e}=B||{},{B:ze}=r,{M:ke,P:Ge}=Ts(),{rn:Je,j:Ce}=a,[me,We]=Z("showNativeOverlaidScrollbars"),[he,Ve]=Z("scrollbars.theme"),[He,ie]=Z("scrollbars.visibility"),[ye,Le]=Z("scrollbars.autoHide"),[ue,de]=Z("scrollbars.autoHideSuspend"),[Fe]=Z("scrollbars.autoHideDelay"),[Ue,Qe]=Z("scrollbars.dragScroll"),[rt,pe]=Z("scrollbars.clickScroll"),[Ie,it]=Z("overflow"),ut=$e&&!K,$t=se||re||ve||Se||K,Ut=oe||ie||it,At=me&&ke.x&&ke.y,Mn=!Ge&&!Y,_n=At||Mn,dn=(An,Sn,cn)=>{const er=An.includes($a)&&(He===si||He==="auto"&&Sn===$a);return M(aD,er,cn),er};if(y=Fe,(We||Mn)&&M(nD,_n),Ve&&(M(m),M(he,!0),m=he),(de||ut)&&($(!ue),ut&&ue&&(Ce.x||Ce.y?(g(),T((()=>{g=an(z,$a,C(ht($,!0)),{A:!0})}))):$(!0))),Le&&(d=ye==="move",h=ye==="leave",p=ye==="never",H(p,!0)),Qe&&M(uD,Ue),pe&&M(cD,!!rt),Ut){const An=dn(Ie.x,Je.x,!0),Sn=dn(Ie.y,Je.y,!1);M(oD,!(An&&Sn))}$t&&(F(),U(),X(),ve&&Q(),M(o1,!Ce.x,!0),M(o1,!Ce.y,!1),M(rD,ze&&!W))},{},O]},TD=e=>{const t=Ts(),{K:n,P:r}=t,{elements:a}=n(),{padding:l,viewport:u,content:c}=a,d=Ch(e),h=d?{}:e,{elements:p}=h,{padding:m,viewport:g,content:y}=p||{},w=d?e:h.target,C=Uk(w),_=w.ownerDocument,S=_.documentElement,b=()=>_.defaultView||gr,v=ht(CD,[w]),k=ht(dE,[w]),T=ht(Zo,""),N=ht(v,T,u),R=ht(k,T,c),A=Se=>{const $e=el(Se),ze=Nh(Se),ke=js(Se,Sy),Ge=js(Se,wy);return ze.w-$e.w>0&&!Qo(ke)||ze.h-$e.h>0&&!Qo(Ge)},O=N(g),P=O===w,V=P&&C,z=!P&&R(y),W=!P&&O===z,M=V?S:O,U=V?M:w,F=!P&&k(T,l,m),Q=!W&&z,X=[Q,M,F,U].map((Se=>Ch(Se)&&!Gc(Se)&&Se)),H=Se=>Se&&Ek(X,Se),I=!H(M)&&A(M)?M:w,D=V?S:M,$={dt:w,vt:U,L:M,ln:F,ht:Q,gt:D,Qt:V?_:M,an:C?S:I,Gt:_,bt:C,At:d,V:P,un:b,yt:Se=>jy(M,ni,Se),wt:(Se,$e)=>jh(M,ni,Se,$e),St:()=>jh(D,ni,QR,!0)},{dt:J,vt:Y,ln:Z,L:K,ht:B}=$,ne=[()=>{vs(Y,[Wi,dg]),vs(J,dg),C&&vs(S,[dg,Wi])}];let se=xx([B,K,Z,Y,J].find((Se=>Se&&!H(Se))));const re=V?J:B||K,oe=ht(Lr,ne);return[$,()=>{const Se=b(),$e=yx(),ze=me=>{pr(Gc(me),xx(me)),ol(me)},ke=me=>an(me,"focusin focusout focus blur",Qk,{I:!0,D:!1}),Ge="tabindex",Je=ky(K,Ge),Ce=ke($e);return ti(Y,Wi,P?"":qR),ti(Z,Cx,""),ti(K,ni,""),ti(B,i1,""),P||(ti(K,Ge,Je||"-1"),C&&ti(S,s1,"")),pr(re,se),pr(Y,Z),pr(Z||Y,!P&&K),pr(K,B),un(ne,[Ce,()=>{const me=yx(),We=H(K),he=We&&me===K?J:me,Ve=ke(he);vs(Z,Cx),vs(B,i1),vs(K,ni),C&&vs(S,s1),Je?ti(K,Ge,Je):vs(K,Ge),H(B)&&ze(B),We&&ze(K),H(Z)&&ze(Z),Sx(he),Ve()}]),r&&!P&&(Ey(K,ni,rE),un(ne,ht(vs,K,ni))),Sx(!P&&C&&$e===J&&Se.top===Se?K:$e),Ce(),se=0,oe},oe]},AD=({ht:e})=>({Zt:t,fn:n,It:r})=>{const{$t:a}=t||{},{Ot:l}=n;e&&(a||r)&&qc(e,{[df]:l&&"100%"})},LD=({vt:e,ln:t,L:n,V:r},a)=>{const[l,u]=Tr({i:OR,o:e1()},ht(e1,e,"padding",""));return({Dt:c,Zt:d,fn:h,It:p})=>{let[m,g]=u(p);const{P:y}=Ts(),{_t:w,xt:C,Ct:_}=d||{},{B:S}=h,[b,v]=c("paddingAbsolute");(w||g||(p||C))&&([m,g]=l(p));const T=!r&&(v||_||g);if(T){const N=!b||!t&&!y,R=m.r+m.l,A=m.t+m.b,O={[Rk]:N&&!S?-R:0,[Dk]:N?-A:0,[Lk]:N&&S?-R:0,top:N?-m.t:0,right:N?S?-m.r:"auto":0,left:N?S?"auto":-m.l:0,[uf]:N&&`calc(100% + ${R}px)`},P={[jk]:N?m.t:0,[Nk]:N?m.r:0,[Ak]:N?m.b:0,[Tk]:N?m.l:0};qc(t||n,O),qc(n,P),It(a,{ln:m,_n:!N,F:t?P:It({},O,P)})}return{dn:T}}},RD=(e,t)=>{const n=Ts(),{vt:r,ln:a,L:l,V:u,Qt:c,gt:d,bt:h,wt:p,un:m}=e,{P:g}=n,y=h&&u,w=ht(wk,0),C={display:()=>!1,direction:J=>J!=="ltr",flexDirection:J=>J.endsWith("-reverse"),writingMode:J=>J!=="horizontal-tb"},_=mr(C),S={i:Ok,o:{w:0,h:0}},b={i:hh,o:{}},v=J=>{p(nE,!y&&J)},k=()=>js(l,_),T=(J,Y)=>{const Z=!mr(J).length,K=Y?!0:_.some((Ge=>{const Je=J[Ge];return pl(Je)&&C[Ge](Je)}));if(Z||!K||!FR(l))return{T:{x:0,y:0},k:{x:1,y:1}};v(!0);const B=Ar(d),ne=an(c,$a,(Ge=>{const Je=Ar(d);Ge.isTrusted&&Je.x===B.x&&Je.y===B.y&&Xk(Ge)}),{I:!0,A:!0}),se=p(JR,!0);ks(d,{x:0,y:0}),se();const re=Ar(d),oe=Nh(d);ks(d,{x:oe.w,y:oe.h});const ve=Ar(d),Se={x:ve.x-re.x,y:ve.y-re.y};ks(d,{x:-oe.w,y:-oe.h});const $e=Ar(d),ze={x:$e.x-re.x,y:$e.y-re.y},ke={x:Hi(Se.x)>=Hi(ze.x)?ve.x:$e.x,y:Hi(Se.y)>=Hi(ze.y)?ve.y:$e.y};return ks(d,B),xy((()=>ne())),{T:re,k:ke}},N=(J,Y)=>{const Z=gr.devicePixelRatio%1!==0?1:0,K={w:w(J.w-Y.w),h:w(J.h-Y.h)};return{w:K.w>Z?K.w:0,h:K.h>Z?K.h:0}},R=(J,Y)=>{const Z=(K,B,ne,se)=>{const re=K===si?ss:fD(K),oe=Qo(K),ve=Qo(ne);return!B&&!se?ss:oe&&ve?si:oe?B&&se?re:B?si:ss:B?re:ve&&se?si:ss};return{x:Z(Y.x,J.x,Y.y,J.y),y:Z(Y.y,J.y,Y.x,J.x)}},A=J=>{const Y=K=>[si,ss,$a].map((B=>$(Ex(B),K))),Z=Y(!0).concat(Y()).join(" ");p(Z),p(mr(J).map((K=>$(J[K],K==="x"))).join(" "),!0)},[O,P]=Tr(S,ht(Ty,l)),[V,z]=Tr(S,ht(Nh,l)),[W,M]=Tr(S),[U]=Tr(b),[F,Q]=Tr(S),[X]=Tr(b),[H]=Tr({i:(J,Y)=>hf(J,Y,Eh(al(mr(J),mr(Y)))),o:{}}),[I,D]=Tr({i:(J,Y)=>hh(J.T,Y.T)&&hh(J.k,Y.k),o:Jk()}),q=gl(Ry),$=(J,Y)=>`${Y?KR:YR}${DR(J)}`;return({Dt:J,Zt:Y,fn:Z,It:K},{dn:B})=>{const{_t:ne,Ht:se,xt:re,Ct:oe,ft:ve,Et:Se}=Y||{},$e=q&&q.R(e,t,Z,n,J),{X:ze,Y:ke,W:Ge}=$e||{},[Je,Ce]=hD(J,n),[me,We]=J("overflow"),he=Qo(me.x),Ve=Qo(me.y),He=ne||B||re||oe||Se||Ce;let ie=P(K),ye=z(K),Le=M(K),ue=Q(K);if(Ce&&g&&p(rE,!Je),He){jy(r,Wi,mh)&&v(!0);const et=ke&&ke(),[Ye]=ie=O(K),[ae]=ye=V(K),Me=Kk(l),Ze=y&&HR(m()),Rt={w:w(ae.w+Ye.w),h:w(ae.h+Ye.h)},nn={w:w((Ze?Ze.w:Me.w+w(Me.w-ae.w))+Ye.w),h:w((Ze?Ze.h:Me.h+w(Me.h-ae.h))+Ye.h)};et&&et(),ue=F(nn),Le=W(N(Rt,nn),K)}const[de,Fe]=ue,[Ue,Qe]=Le,[rt,pe]=ye,[Ie,it]=ie,[ut]=U({x:Ue.w>0,y:Ue.h>0}),$t=he&&Ve&&(ut.x||ut.y)||he&&ut.x&&!ut.y||Ve&&ut.y&&!ut.x,Ut=B||oe||Se||it||pe||Fe||Qe||We||Ce||He||se&&y,[At]=J("update.flowDirectionStyles"),[Mn,_n]=H(At?At(l)||{}:k(),K),dn=oe||ve||_n||K,[An,Sn]=dn?I(T(Mn,!!At),K):D();let cn=R(ut,me);v(!1),Ut&&(A(cn),cn=mD(l,ut),Ge&&ze&&(ze(cn,rt,Ie),qc(l,Ge(cn))));const[er,be]=X(cn);return jh(r,Wi,mh,$t),jh(a,Cx,mh,$t),It(t,{rn:er,Vt:{x:de.w,y:de.h},Rt:{x:Ue.w,y:Ue.h},j:ut,Tt:UR(An,Ue)}),{en:be,nn:Fe,sn:Qe,cn:Sn||Qe}}},DD=e=>{const[t,n,r]=TD(e),a={ln:{t:0,r:0,b:0,l:0},_n:!1,F:{[Rk]:0,[Dk]:0,[Lk]:0,[jk]:0,[Nk]:0,[Ak]:0,[Tk]:0},Vt:{x:0,y:0},Rt:{x:0,y:0},rn:{x:ss,y:ss},j:{x:!1,y:!1},Tt:Jk()},{dt:l,gt:u,V:c,St:d}=t,{P:h,M:p}=Ts(),m=!h&&(p.x||p.y),g=[AD(t),LD(t,a),RD(t,a)];return[n,y=>{const w={},_=m&&Ar(u),S=_&&d();return Kt(g,(b=>{It(w,b(y,w)||{})})),ks(u,_),S&&S(),c||ks(l,0),w},a,t,r]},OD=(e,t,n,r)=>{let a=!1;const l={Kt:!1,pn:!1},u=hg(t,{}),[c,d,h,p,m]=DD(e),[g,y,w]=wD(p,h,u,(k=>{v({},k)})),[C,_,,S]=ND(e,t,l,w,h,p,r),b=k=>mr(k).some((T=>!!k[T])),v=(k,T)=>{const{Kt:N,pn:R}=l;if(R||N&&a)return!1;const{vn:A,It:O,zt:P}=k,V=A||{},z=!!O||!a,W={Dt:hg(t,V,z),vn:V,It:z},M=T||y(It({},W,{zt:P})),U=d(It({},W,{fn:w,Zt:M}));_(It({},W,{Zt:M,tn:U}));const F=b(M),Q=b(U),X=F||Q||!Cy(V)||z;return a=!0,X&&n(k,{Zt:M,tn:U}),X};return[()=>{const{an:k,gt:T,St:N}=p,R=Ar(k),A=[g(),c(),C(),()=>{l.pn=!0}],O=N();return ks(T,R),O(),ht(Lr,A)},v,k=>{const T=l.Kt;l.Kt=k,!k&&T!==k&&v({It:!0,zt:!0})},()=>{_({Dt:hg(t,{},!1),vn:{},It:!1})},()=>({gn:l,hn:w,bn:h}),{yn:p,wn:S},m]},Dy=new WeakMap,ID=(e,t)=>{Dy.set(e,t)},MD=e=>{Dy.delete(e)},hE=e=>Dy.get(e),ls=(e,t,n)=>{const{tt:r}=Ts(),a=Ch(e),l=a?e:e.target,u=hE(l);if(t&&!u){const c=[],d={},h=z=>{const W=Pk(z),M=gl(GR);return M?M(W,!0):W},p=It({},r(),h(t)),[m,g,y]=wx(),[w,C,_]=wx(n),S=(z,W)=>{_(z,W),y(z,W)},[b,v,k,T,N,R,A]=OD(e,p,(({vn:z,It:W},{Zt:M,tn:U})=>{const{_t:F,Ct:Q,$t:X,xt:H,Ht:I,ft:D}=M,{nn:q,sn:$,en:J,cn:Y}=U;S("updated",[V,{updateHints:{sizeChanged:!!F,directionChanged:!!Q,heightIntrinsicChanged:!!X,overflowEdgeChanged:!!q,overflowAmountChanged:!!$,overflowStyleChanged:!!J,scrollCoordinatesChanged:!!Y,contentMutation:!!H,hostMutation:!!I,appear:!!D},changedOptions:z||{},force:!!W}])}),(z=>S("scroll",[V,z]))),O=z=>{const{gn:W}=N(),{pn:M}=W;M||(MD(l),Lr(c),S("destroyed",[V,z]),g(),C())},V={options(z,W){if(z){const M=W?r():{},U=oE(p,It(M,h(z)));Cy(U)||(It(p,U),v({vn:U}))}return It({},p)},on:w,off:(z,W)=>{z&&W&&C(z,W)},state(){const{gn:z,hn:W,bn:M}=N(),{pn:U,Kt:F}=z,{B:Q}=W,{Vt:X,Rt:H,rn:I,j:D,ln:q,_n:$,Tt:J}=M;return It({},{overflowEdge:X,overflowAmount:H,overflowStyle:I,hasOverflow:D,scrollCoordinates:{start:J.T,end:J.k},padding:q,paddingAbsolute:$,directionRTL:Q,sleeping:F,destroyed:U})},elements(){const{dt:z,vt:W,ln:M,L:U,ht:F,gt:Q,Qt:X}=R.yn,{jt:H,Jt:I}=R.wn,D=$=>{const{kt:J,Pt:Y,Lt:Z}=$;return{scrollbar:Z,track:Y,handle:J}},q=$=>{const{Xt:J,Yt:Y}=$,Z=D(J[0]);return It({},Z,{clone:()=>{const K=D(Y());return T(),K}})};return It({},{target:z,host:W,padding:M||U,viewport:U,content:F||U,scrollOffsetElement:Q,scrollEventElement:X,scrollbarHorizontal:q(H),scrollbarVertical:q(I)})},update:z=>v({It:z,zt:!0}),destroy:ht(O,!1),sleep:k,plugin:z=>d[mr(z)[0]]};return un(c,[A]),ID(l,V),tE(Zk,ls,[V,m,d]),kD(R.yn.bt,!a&&e.cancel)?(O(!0),V):(un(c,b()),S("initialized",[V]),V.update(),V)}return u};ls.plugin=e=>{const t=Jr(e),n=t?e:[e],r=n.map((a=>tE(a,ls)[0]));return VR(n),t?r:r[0]};ls.valid=e=>{const t=e&&e.elements,n=fs(t)&&t();return Vc(n)&&!!hE(n.target)};ls.env=()=>{const{U:e,M:t,P:n,J:r,ot:a,st:l,K:u,Z:c,tt:d,nt:h}=Ts();return It({},{scrollbarsSize:e,scrollbarsOverlaid:t,scrollbarsHiding:n,scrollTimeline:r,staticDefaultInitialization:a,staticDefaultOptions:l,getDefaultInitialization:u,setDefaultInitialization:c,getDefaultOptions:d,setDefaultOptions:h})};ls.nonce=bD;ls.trustedTypePolicy=BR;const PD=()=>{if(typeof window>"u"){const h=()=>{};return[h,h]}let e,t;const n=window,r=typeof n.requestIdleCallback=="function",a=n.requestAnimationFrame,l=n.cancelAnimationFrame,u=r?n.requestIdleCallback:a,c=r?n.cancelIdleCallback:l,d=()=>{c(e),l(t)};return[(h,p)=>{d(),e=u(r?()=>{d(),t=a(h)}:h,typeof p=="object"?p:{timeout:2233})},d]},BD=e=>{const{options:t,events:n,defer:r}=e||{},[a,l]=E.useMemo(PD,[]),u=E.useRef(null),c=E.useRef(r),d=E.useRef(t),h=E.useRef(n);return E.useEffect(()=>{c.current=r},[r]),E.useEffect(()=>{const{current:p}=u;d.current=t,ls.valid(p)&&p.options(t||{},!0)},[t]),E.useEffect(()=>{const{current:p}=u;h.current=n,ls.valid(p)&&p.on(n||{},!0)},[n]),E.useEffect(()=>()=>{var p;l(),(p=u.current)==null||p.destroy()},[]),E.useMemo(()=>[p=>{const m=u.current;if(ls.valid(m))return;const g=c.current,y=d.current||{},w=h.current||{},C=()=>u.current=ls(p,y,w);g?a(C,g):C()},()=>u.current],[])},$D=(e,t)=>{const{element:n="div",options:r,events:a,defer:l,children:u,...c}=e,d=n,h=E.useRef(null),p=E.useRef(null),[m,g]=BD({options:r,events:a,defer:l});return E.useEffect(()=>{const{current:y}=h,{current:w}=p;if(!y)return;const C=y;return m(n==="body"?{target:C,cancel:{body:null}}:{target:C,elements:{viewport:w,content:w}}),()=>{var _;return(_=g())==null?void 0:_.destroy()}},[m,n]),E.useImperativeHandle(t,()=>({osInstance:g,getElement:()=>h.current}),[]),os.createElement(d,{"data-overlayscrollbars-initialize":"",ref:h,...c},n==="body"?u:os.createElement("div",{"data-overlayscrollbars-contents":"",ref:p},u))},zD=E.forwardRef($D),ct=E.forwardRef(({options:e,horizontal:t,both:n,onScrollbarGesture:r,...a},l)=>{const u=t||n,c=E.useRef(r);c.current=r;const d=E.useRef(null),h=E.useMemo(()=>({initialized:m=>{var b;(b=d.current)==null||b.call(d);const g=m.elements().scrollbarVertical,y=()=>{const v=g.handle.getBoundingClientRect(),k=g.track.getBoundingClientRect();return v.height===0||k.height===0?null:Math.max(0,k.bottom-v.bottom)};let w=null;const C=()=>{var v;(v=c.current)==null||v.call(c,"up",y()),w==null||w()},_=v=>{var k;if(v.buttons===0){C();return}(k=c.current)==null||k.call(c,"move",y())},S=()=>{var v;(v=c.current)==null||v.call(c,"down",y()),w==null||w(),window.addEventListener("pointermove",_),window.addEventListener("pointerup",C),window.addEventListener("pointercancel",C),w=()=>{window.removeEventListener("pointermove",_),window.removeEventListener("pointerup",C),window.removeEventListener("pointercancel",C),w=null}};g.track.addEventListener("pointerdown",S),d.current=()=>{g.track.removeEventListener("pointerdown",S),w==null||w()}}}),[]);return E.useEffect(()=>()=>{var p;return(p=d.current)==null?void 0:p.call(d)},[]),s.jsx(zD,{ref:l,events:h,options:{overflow:{x:u?"scroll":"hidden",y:n?"scroll":t?"hidden":"scroll"},scrollbars:{autoHide:u?"leave":"move",autoHideDelay:u?1500:600,clickScroll:"instant"},update:{elementEvents:[[":scope","mouseenter"]]},...e},...a})});ct.displayName="ScrollArea";const h1=e=>{let t;const n=new Set,r=(h,p)=>{const m=typeof h=="function"?h(t):h;if(!Object.is(m,t)){const g=t;t=p??(typeof m!="object"||m===null)?m:Object.assign({},t,m),n.forEach(y=>y(t,g))}},a=()=>t,c={setState:r,getState:a,getInitialState:()=>d,subscribe:h=>(n.add(h),()=>n.delete(h))},d=t=e(r,a,c);return c},HD=(e=>e?h1(e):h1),FD=e=>e;function UD(e,t=FD){const n=os.useSyncExternalStore(e.subscribe,os.useCallback(()=>t(e.getState()),[e,t]),os.useCallback(()=>t(e.getInitialState()),[e,t]));return os.useDebugValue(n),n}const f1=e=>{const t=HD(e),n=r=>UD(t,r);return Object.assign(n,t),n},Jn=(e=>e?f1(e):f1);function VD(){if(typeof document>"u")return"";const e=Array.from(document.scripts).find(a=>{const l=new URL(a.src,window.location.href).pathname;return l.includes("/assets/")||l.endsWith("/src/main.tsx")});if(!e)return"";const t=new URL(e.src,window.location.href).pathname,n=t.includes("/assets/")?"/assets/":"/src/",r=t.indexOf(n);return r>0?t.slice(0,r):""}const fE=VD();function hs(e){return e.startsWith("/")?`${fE}${e}`||"/":e}async function we(e,t={}){const n=localStorage.getItem("openfox_token"),r={...t.headers instanceof Headers?Object.fromEntries(t.headers.entries()):t.headers,...n?{"x-session-token":n}:{}};return fetch(hs(e),{...t,headers:r})}async function m1(e,t,n,r){try{return(await we(`/api/sessions/${e}/replay`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messageId:t,...n!==void 0?{content:n}:{},...r!==void 0?{attachments:r}:{}})})).ok}catch{return!1}}async function mE(e,t,n){try{const r=await we(`/api/sessions/${e}/fork`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messageId:t,...n!==void 0?{title:n}:{}})});return r.ok?await r.json():null}catch{return null}}const je={GLOBAL_INSTRUCTIONS:"global_instructions",NOTIFICATION_SETTINGS:"notification_settings",DISPLAY_SHOW_THINKING:"display.showThinking",DISPLAY_SHOW_VERBOSE_TOOL_OUTPUT:"display.showVerboseToolOutput",DISPLAY_SHOW_STATS:"display.showStats",DISPLAY_SHOW_AGENT_DEFINITIONS:"display.showAgentDefinitions",DISPLAY_SHOW_WORKFLOW_BARS:"display.showWorkflowBars",DISPLAY_SHOW_SYNTAX_HIGHLIGHTING:"display.showSyntaxHighlighting",DISPLAY_THEME:"display.theme",DISPLAY_USER_PRESETS:"display.userPresets",DISPLAY_FOLLOW_SYSTEM_THEME:"display.followSystemTheme",DISPLAY_SYSTEM_THEME_PREFS:"display.systemThemePrefs",DISPLAY_SHOW_OPEN_IN_EDITOR:"display.showOpenInEditorLinks",DISPLAY_SHOW_CHANGELOG_ON_UPDATE:"display.showChangelogOnUpdate",DISPLAY_MAX_VISIBLE_ITEMS:"display.maxVisibleItems",DISPLAY_CUSTOM_CSS:"display.customCss",DISPLAY_TERMINAL_FONT:"display.terminalFont",DISPLAY_USE_NATIVE_SCROLLBARS:"display.useNativeScrollbars",DISPLAY_USE_NATIVE_SCROLLBARS_CODE_BLOCKS:"display.useNativeScrollbarsCodeBlocks",DISPLAY_COLLAPSE_LARGE_TOOL_CALLS:"display.collapseLargeToolCalls",DISPLAY_DEFER_CODE_HIGHLIGHT_WHILE_STREAMING:"display.deferCodeHighlightWhileStreaming",DISPLAY_FEED_VIRTUALIZATION:"display.feedVirtualization",LLM_DYNAMIC_SYSTEM_PROMPT:"llm.dynamicSystemPrompt",CACHE_WARMING:"cache.warming",KEYBINDINGS:"keybindings",RETRY_PATTERNS:"agent.retryPatterns",SKILLS_DIRECTORIES:"skills.directories",SEARCH_ENGINE:"search.engine",SEARCH_TAVILY_API_KEY:"search.tavilyApiKey",SEARCH_SEARXNG_URL:"search.searxngUrl",SEARCH_SEARXNG_API_KEY:"search.searxngApiKey",TOOLS_USE_RTK:"tools.useRtk",TOOLS_SHELL:"tools.shell",CONFIRM_ON_WORKSPACE_ACTIONS:"tools.confirmOnWorkspaceActions",FEATURES_PER_SESSION_MCP:"features.perSessionMcp",PROXY_URL:"network.proxyUrl",DEFAULT_AGENT:"agent.defaultAgent"};function Pd(e,t){return n=>({loading:{...n.loading,[e]:t}})}function p1(e,t){return n=>({settings:{...n.settings,[e]:t},loading:{...n.loading,[e]:!1}})}const Oy=[je.DISPLAY_SHOW_THINKING,je.DISPLAY_SHOW_VERBOSE_TOOL_OUTPUT,je.DISPLAY_SHOW_STATS,je.DISPLAY_SHOW_AGENT_DEFINITIONS,je.DISPLAY_SHOW_WORKFLOW_BARS,je.DISPLAY_SHOW_SYNTAX_HIGHLIGHTING,je.DISPLAY_FOLLOW_SYSTEM_THEME,je.DISPLAY_SHOW_OPEN_IN_EDITOR,je.DISPLAY_SHOW_CHANGELOG_ON_UPDATE,je.DISPLAY_MAX_VISIBLE_ITEMS,je.DISPLAY_TERMINAL_FONT,je.DISPLAY_USE_NATIVE_SCROLLBARS,je.DISPLAY_USE_NATIVE_SCROLLBARS_CODE_BLOCKS,je.DISPLAY_COLLAPSE_LARGE_TOOL_CALLS,je.DISPLAY_DEFER_CODE_HIGHLIGHT_WHILE_STREAMING,je.DISPLAY_FEED_VIRTUALIZATION];function As(){return{showThinking:Lt(e=>e.settings[je.DISPLAY_SHOW_THINKING]??"true")==="true",showVerboseToolOutput:Lt(e=>e.settings[je.DISPLAY_SHOW_VERBOSE_TOOL_OUTPUT]??"true")==="true",showStats:Lt(e=>e.settings[je.DISPLAY_SHOW_STATS]??"true")==="true",showAgentDefinitions:Lt(e=>e.settings[je.DISPLAY_SHOW_AGENT_DEFINITIONS]??"true")==="true",showWorkflowBars:Lt(e=>e.settings[je.DISPLAY_SHOW_WORKFLOW_BARS]??"true")==="true",showSyntaxHighlighting:Lt(e=>e.settings[je.DISPLAY_SHOW_SYNTAX_HIGHLIGHTING]??"true")==="true",maxVisibleItems:Number(Lt(e=>e.settings[je.DISPLAY_MAX_VISIBLE_ITEMS]??"300")),useNativeScrollbars:Lt(e=>e.settings[je.DISPLAY_USE_NATIVE_SCROLLBARS]??"false")==="true",useNativeScrollbarsCodeBlocks:Lt(e=>e.settings[je.DISPLAY_USE_NATIVE_SCROLLBARS_CODE_BLOCKS]??"false")==="true",collapseLargeToolCalls:Lt(e=>e.settings[je.DISPLAY_COLLAPSE_LARGE_TOOL_CALLS]??"false")==="true",deferCodeHighlightWhileStreaming:Lt(e=>e.settings[je.DISPLAY_DEFER_CODE_HIGHLIGHT_WHILE_STREAMING]??"false")==="true",feedVirtualization:Lt(e=>e.settings[je.DISPLAY_FEED_VIRTUALIZATION]??"false")==="true"}}const Lt=Jn(e=>({settings:{},loading:{},getSetting:async t=>{e(Pd(t,!0));try{const r=await(await we(`/api/settings/${t}`)).json();return e(p1(t,r.value??"")),r.value}catch{return e(Pd(t,!1)),null}},getSettings:async t=>{if(t.length!==0)try{const r=await(await we(`/api/settings?keys=${encodeURIComponent(t.join(","))}`)).json();e({settings:r,loading:Object.fromEntries(t.map(a=>[a,!1]))})}catch{e({loading:Object.fromEntries(t.map(n=>[n,!1]))})}},setSetting:async(t,n)=>{e(Pd(t,!0));try{const a=await(await we(`/api/settings/${t}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({value:n})})).json();e(p1(t,a.value??""))}catch{e(Pd(t,!1))}}})),pc=Object.freeze(Object.defineProperty({__proto__:null,DISPLAY_SETTINGS_KEYS:Oy,SETTINGS_KEYS:je,useDisplaySettings:As,useSettingsStore:Lt},Symbol.toStringTag,{value:"Module"}));function WD(){const[e,t]=E.useState({offsetTop:0,height:window.innerHeight,keyboardVisible:!1}),n=E.useRef(window.innerHeight);return E.useEffect(()=>{const r=window.visualViewport;if(!r)return;const a=()=>{const l=r.offsetTop,u=r.height,c=n.current-u>100;t({offsetTop:l,height:u,keyboardVisible:c})};return a(),r.addEventListener("resize",a),r.addEventListener("scroll",a),()=>{r.removeEventListener("resize",a),r.removeEventListener("scroll",a)}},[]),e}const g1=1e4,ll=new Map;function GD(){const e=Date.now();for(const[t,n]of ll)n.expiresAt<e&&ll.delete(t)}function qD(e){if(ll.has(e))return;const t=localStorage.getItem("openfox_token"),n=fetch(hs(`/api/sessions/${e}`),{headers:t?{"x-session-token":t}:void 0}).then(async r=>r.ok?{ok:!0,data:await r.json()}:{ok:!1}).catch(()=>({ok:!1}));ll.set(e,{promise:n,expiresAt:Date.now()+g1}),setTimeout(GD,g1)}function KD(e){const t=ll.get(e);if(t&&(ll.delete(e),!(t.expiresAt<Date.now())))return t.promise}function YD(e){return typeof e=="object"&&e!==null&&"type"in e&&"payload"in e}function ph(){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 XD{constructor(t){Ae(this,"ws",null);Ae(this,"handlers",new Set);Ae(this,"statusHandler",null);Ae(this,"baseUrl");Ae(this,"isReconnecting",!1);Ae(this,"connectingPromise",null);Ae(this,"lastCloseCode",0);Ae(this,"reconnectAttempts",0);Ae(this,"manualReconnectScheduled",!1);Ae(this,"pwaRecoveryAttempted",!1);this.baseUrl=t}getUrl(){const t=localStorage.getItem("openfox_token");if(t){const n=this.baseUrl.includes("?")?"&":"?";return`${this.baseUrl}${n}token=${encodeURIComponent(t)}`}return this.baseUrl}setToken(t){localStorage.setItem("openfox_token",t)}clearToken(){localStorage.removeItem("openfox_token")}hasToken(){return!!localStorage.getItem("openfox_token")}getLastCloseCode(){return this.lastCloseCode}onStatusChange(t){this.statusHandler=t}connect(){var t,n,r;return((t=this.ws)==null?void 0:t.readyState)===WebSocket.OPEN?Promise.resolve():(this.lastCloseCode=0,this.isReconnecting=!1,this.connectingPromise&&((n=this.ws)==null?void 0:n.readyState)===WebSocket.CONNECTING?this.connectingPromise:(this.lastCloseCode=0,this.isReconnecting=!1,this.connectingPromise&&((r=this.ws)==null?void 0:r.readyState)===WebSocket.CONNECTING?(console.warn("[WS CLIENT] Connection already in progress, returning existing promise"),this.connectingPromise):(this.connectingPromise=new Promise((a,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 h,p,m;clearTimeout(c),this.lastCloseCode=d.code,((h=this.ws)==null?void 0:h.readyState)===WebSocket.CONNECTING?(this.connectingPromise=null,(p=this.statusHandler)==null||p.call(this,"disconnected"),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 h=JSON.parse(d.data);YD(h)&&this.handlers.forEach(p=>p(h))}catch(h){console.error("Failed to parse WebSocket message:",h)}}}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(r=>r.unregister())),window.location.reload())}attemptReconnect(){var r;if(this.lastCloseCode===4e3&&this.hasToken()){console.warn("[WS] Auth failure or initial failure with token - not auto-reconnecting, awaiting user action");return}if(this.isReconnecting||this.manualReconnectScheduled)return;this.isReconnecting=!0,(r=this.statusHandler)==null||r.call(this,"reconnecting");const n=Math.min(1e3*Math.pow(2,this.reconnectAttempts||0),3e4);this.reconnectAttempts=(this.reconnectAttempts||0)+1,setTimeout(()=>{this.isReconnecting=!1,this.manualReconnectScheduled=!1,this.connect().catch(()=>{this.reconnectAttempts>=3&&this.recoverPwaStuckConnection()})},n)}reconnect(){this.manualReconnectScheduled=!0,this.isReconnecting=!1,this.lastCloseCode=0,this.connectingPromise=null,this.connect().catch(()=>{this.recoverPwaStuckConnection()})}disconnect(){this.isReconnecting=!1,this.reconnectAttempts=0,this.ws&&(this.ws.close(),this.ws=null)}resetReconnectAttempts(){this.reconnectAttempts=0}send(t,n){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)throw new Error("WebSocket not connected");const r=ph(),a={id:r,type:t,payload:n};return this.ws.send(JSON.stringify(a)),r}subscribe(t){return this.handlers.add(t),()=>this.handlers.delete(t)}get isConnected(){var t;return((t=this.ws)==null?void 0:t.readyState)===WebSocket.OPEN}}const QD=window.location.protocol==="https:"?"wss:":"ws:";let jx=window.location.port;jx||(jx=window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"?"10469":window.location.protocol==="https:"?"443":"80");const JD=`${QD}//${window.location.hostname}:${jx}${hs("/ws")}`,Pt=new XD(JD),ZD=3e4;function pE(e){switch(e){case"vllm":return"vLLM";case"sglang":return"SGLang";case"ollama":return"Ollama";case"llamacpp":return"llama.cpp";case"lmstudio":return"LM Studio";case"openai":return"OpenAI";case"anthropic":return"Anthropic";case"opencode-go":return"OpenCode Go";case"unknown":return"Other"}}let gc=null;const Zt=Jn((e,t)=>({version:null,model:null,maxContext:2e5,llmUrl:null,llmStatus:"unknown",backend:"unknown",providers:[],activeProviderId:null,defaultModelSelection:null,platform:null,workdir:null,loading:!1,activating:!1,error:null,autoRefreshInterval:null,fetchConfig:async()=>gc||(e({loading:!0,error:null}),gc=(async()=>{try{const n=await we("/api/config");if(!n.ok)throw new Error("Failed to fetch config");const r=await n.json(),a=r.platform&&typeof r.platform=="object"?{isWSL:!!r.platform.isWSL,wslDistro:String(r.platform.wslDistro??"")}:null;e({version:r.version,model:r.model,maxContext:r.maxContext,llmUrl:r.llmUrl,llmStatus:r.llmStatus,backend:r.backend,providers:r.providers??[],activeProviderId:r.activeProviderId??null,defaultModelSelection:r.defaultModelSelection??null,platform:a,workdir:r.workdir??null,loading:!1})}catch(n){e({error:n instanceof Error?n.message:"Unknown error",loading:!1})}finally{gc=null}})(),gc),refreshModel:async()=>{try{const n=await we("/api/model/refresh",{method:"POST"});if(!n.ok)throw new Error("Failed to refresh model");const r=await n.json();e({model:r.model,llmStatus:r.llmStatus,backend:r.backend})}catch(n){console.error("Failed to refresh model:",n)}},activateProvider:async n=>{const{activeProviderId:r,providers:a}=t();if(n===r)return!0;e({activating:!0,error:null});try{const l=await we(`/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,r)=>{const{providers:a}=t();try{const l=await we("/api/default-model",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerId:n,model:r})});if(!l.ok)return!1;const u=await l.json();return e({activeProviderId:n,model:r,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 r=await we(`/api/providers/${n}/refresh`,{method:"POST"});if(!r.ok){const u=await r.json();throw new Error(u.error??"Failed to refresh models")}const a=await r.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(r){return e({error:r instanceof Error?r.message:"Failed to refresh models",activating:!1}),!1}},startAutoRefresh:()=>{const{autoRefreshInterval:n,refreshModel:r}=t();if(n)return;const a=setInterval(()=>{r()},ZD);e({autoRefreshInterval:a})},stopAutoRefresh:()=>{const{autoRefreshInterval:n}=t();n&&(clearInterval(n),e({autoRefreshInterval:null}))},getActiveProvider:()=>{const{providers:n,activeProviderId:r}=t();return n.find(a=>a.id===r)},getModelContext:n=>{const{providers:r,activeProviderId:a}=t(),l=r.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}})),tn=Jn((e,t)=>({projects:[],currentProject:null,loading:!1,listProjects:async()=>{e({loading:!0});try{const r=await(await we("/api/projects")).json();e({projects:r.projects??[],loading:!1})}catch(n){console.error("Failed to load projects:",n),e({loading:!1})}},createProject:async(n,r)=>{try{const a=await we("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:n,workdir:r})});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 r=await we(`/api/projects/${n}`);if(!r.ok)return null;const a=await r.json();return e({currentProject:a.project}),t().projects.length===0&&await t().listProjects(),a.project}catch{return null}},updateProject:async(n,r)=>{var a;try{const l=await we(`/api/projects/${n}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});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 r;try{return(await we(`/api/projects/${n}`,{method:"DELETE"})).ok?(await t().listProjects(),((r=t().currentProject)==null?void 0:r.id)===n&&e({currentProject:null}),!0):!1}catch{return!1}},toggleStar:async(n,r)=>{var a;try{const l=await we(`/api/projects/${n}/star`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isStarred:r})});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})}})),Yi=async(e,t,n)=>{try{const r=await we(t,{method:e,headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});return r.ok?{success:!0}:{success:!1,error:(await r.json()).error}}catch{return{success:!1,error:"Network error"}}},pf=async(e,t,n)=>{try{const r=await we(e,{method:"POST",body:n?JSON.stringify({destination:n}):void 0,headers:n?{"Content-Type":"application/json"}:void 0}),a=await r.json();return r.ok?(await t(),{success:!0}):{success:!1,error:a.error??"Failed to duplicate"}}catch{return{success:!1,error:"Network error"}}};function gE(e){let t=null;function n(){t===null&&(t=requestAnimationFrame(()=>{t=null,e()}))}return n}let Bd=[];const Pc=Jn()((e,t)=>{function n(){if(Bd.length===0)return;const a=Bd;Bd=[],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 r=gE(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 we(`/api/sessions/${l}/background-process/${a}/stop`,{method:"POST"})).ok&&t().removeProcess(a)}catch{}},appendLog:(a,l,u)=>{Bd.push({processId:a,stream:l,content:u}),r()},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,command:d,cwd:h,pid:p,status:m}=l;e(g=>({processes:[...g.processes,{id:u,sessionId:"",name:c,command:d,cwd:h,pid:p,status:m,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(h=>h.id===u?{...h,status:"exited",exitCode:c}:h)}));break}case"backgroundProcess.removed":{const u=l.processId;t().removeProcess(u);break}}}}}),Rc={messageId:null,deltaContent:"",thinkingContent:"",toolOutput:[]};let Ha=null,ai=null,tl=null,Iy=0;const x1=16;function e3(e){Ha=e}function Dc(){return Rc}function t3(){ai!==null&&(tl==="raf"?cancelAnimationFrame(ai):clearTimeout(ai),ai=null,tl=null)}function mg(){ai=null,tl=null,Iy=Date.now(),Ha==null||Ha()}function pg(){if(ai!==null)return;const e=Date.now()-Iy;e>=x1?typeof document<"u"&&document.hidden?(ai=setTimeout(mg,0),tl="timeout"):(ai=requestAnimationFrame(mg),tl="raf"):(ai=setTimeout(mg,x1-e),tl="timeout")}function Da(){t3(),Ha==null||Ha(),Rc.messageId=null,Rc.deltaContent="",Rc.thinkingContent="",Rc.toolOutput=[],Iy=0}let $d=[];const Yn=Jn()((e,t)=>{function n(){if($d.length===0)return;const a=$d;$d=[],e(l=>({logs:[...l.logs,...a]}))}const r=gE(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 we(`/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 we(`/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 we(`/api/dev-server/logs?workdir=${encodeURIComponent(a)}`)).json()).logs.map(d=>({stream:d.stream,content:d.content,...d.type?{type:d.type}:{}}));e({logs:c})}catch{}},clearLogs:async()=>{const a=t().workdir;if(a)try{await we(`/api/dev-server/clear-logs?workdir=${encodeURIComponent(a)}`,{method:"POST"}),e({logs:[]})}catch{}},insertMarker:async()=>{const a=t().workdir;if(a)try{await we(`/api/dev-server/insert-marker?workdir=${encodeURIComponent(a)}`,{method:"POST"}),t().fetchLogs()}catch{}},start:async()=>{const a=t().workdir;if(a)try{const u=await(await we(`/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 we(`/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 we(`/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 we(`/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;$d.push({stream:u.stream,content:u.content}),r();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,...u.url!==void 0?{url:u.url}:{},...u.inspectProxyPort!==void 0?{inspectProxyPort:u.inspectProxyPort}:{}}:{state:u.state,url:u.url??null,hotReload:!1,config:null,errorMessage:u.errorMessage,inspectProxyPort:u.inspectProxyPort??null}}));break}}}}}),n3=[{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"}],r3=[{url:"/sounds/notification.mp3",label:"Notification"},{url:"/sounds/waiting-for-user.mp3",label:"Waiting for User"},{url:"/sounds/achievement.mp3",label:"Achievement"},{url:"/sounds/intervention.mp3",label:"Intervention"},{url:"/sounds/typing.mp3",label:"Typing"}],xE={complete:"/sounds/notification.mp3",waiting_for_user:"/sounds/waiting-for-user.mp3",phase_done:"/sounds/achievement.mp3",phase_blocked:"/sounds/intervention.mp3",new_message:"/sounds/typing.mp3"},Fi={soundEnabled:!0,browserNotification:!1,customSoundUrl:null},yE={soundEnabled:!1,browserNotification:!1,customSoundUrl:null},Nx={soundEnabled:!0,browserNotificationEnabled:!1,events:{complete:{...Fi},waiting_for_user:{...Fi},phase_done:{...Fi},phase_blocked:{...Fi},new_message:{...yE}},agentOverrides:{}};function bE(e,t,n){var l;const r=e.events[t];if(!n)return r;const a=(l=e.agentOverrides[n])==null?void 0:l[t];return a?{soundEnabled:a.soundEnabled??r.soundEnabled,browserNotification:a.browserNotification??r.browserNotification,customSoundUrl:a.customSoundUrl!==void 0?a.customSoundUrl:r.customSoundUrl}:r}const La=Jn((e,t)=>({settings:Nx,loaded:!1,load:()=>{Lt.getState().getSetting(je.NOTIFICATION_SETTINGS);const r=Lt.subscribe(l=>{const u=l.settings[je.NOTIFICATION_SETTINGS];if(u!==void 0)try{const c=JSON.parse(u);e({settings:y1(c),loaded:!0})}catch{e({loaded:!0})}}),a=Lt.getState().settings[je.NOTIFICATION_SETTINGS];if(a)try{const l=JSON.parse(a);e({settings:y1(l),loaded:!0})}catch{e({loaded:!0})}return r},update:n=>{e({settings:n}),gg(n)},updateEvent:(n,r)=>{const a=t().settings,l={...a,events:{...a.events,[n]:{...a.events[n],...r}}};e({settings:l}),gg(l)},updateAgentOverride:(n,r,a)=>{var d;const l=t().settings,u={...l.agentOverrides};if(a===null){if(u[n]){const h={...u[n]};delete h[r],Object.keys(h).length===0?delete u[n]:u[n]=h}}else u[n]={...u[n],[r]:{...((d=u[n])==null?void 0:d[r])??{},...a}};const c={...l,agentOverrides:u};e({settings:c}),gg(c)}}));function gg(e){Lt.getState().setSetting(je.NOTIFICATION_SETTINGS,JSON.stringify(e))}function y1(e){var t,n,r,a,l;return{soundEnabled:e.soundEnabled??Nx.soundEnabled,browserNotificationEnabled:e.browserNotificationEnabled??Nx.browserNotificationEnabled,events:{complete:{...Fi,...(t=e.events)==null?void 0:t.complete},waiting_for_user:{...Fi,...(n=e.events)==null?void 0:n.waiting_for_user},phase_done:{...Fi,...(r=e.events)==null?void 0:r.phase_done},phase_blocked:{...Fi,...(a=e.events)==null?void 0:a.phase_blocked},new_message:{...yE,...(l=e.events)==null?void 0:l.new_message}},agentOverrides:e.agentOverrides??{}}}const b1=new Map;function s3(e){let t=b1.get(e);return t||(t=new Audio(hs(e)),t.volume=.5,b1.set(e,t)),t}let vE=typeof Notification<"u"?Notification.permission:"denied";function i3(){return typeof Notification>"u"?Promise.resolve("denied"):Notification.requestPermission().then(e=>(vE=e,e))}const a3={complete:"Task Complete",waiting_for_user:"Waiting for Input",phase_done:"Phase Complete",phase_blocked:"Phase Blocked",new_message:"New Message"},o3={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 l3(e){typeof Notification>"u"||vE==="granted"&&(document.hasFocus()||new Notification(a3[e],{body:o3[e],icon:hs("/fox.svg"),tag:`openfox-${e}`}))}function cu(e,t){const{settings:n}=La.getState(),r=bE(n,e,t);if(n.soundEnabled&&r.soundEnabled){const a=r.customSoundUrl??xE[e],l=s3(a);l.currentTime=0,l.play().catch(()=>{})}n.browserNotificationEnabled&&r.browserNotification&&l3(e)}const c3=e=>cu("complete",e),u3=e=>cu("phase_done",e),d3=e=>cu("phase_blocked",e),xg=e=>cu("waiting_for_user",e),h3=e=>cu("new_message",e),v1=new Map;function Vo(e,t){var l;const n=t===((l=e.currentSession)==null?void 0:l.id)?e.currentSession:null,r=e.sessions.find(u=>u.id===t),a=(n==null?void 0:n.mode)??(r==null?void 0:r.mode);return a==="planner"?"planner":a==="builder"?"build":"planner"}function f3(e,t){if(e.type==="chat.done"){const n=e.payload,r=Vo(t,e.sessionId),a=n.agentType??r;n.reason==="complete"&&c3(a),n.reason==="waiting_for_user"&&xg(a);return}if(e.type==="chat.path_confirmation"){const n=Vo(t,e.sessionId);xg(n);return}if(e.type==="session.confirmation_pending"){const n=Vo(t,e.sessionId);xg(n);return}if(e.type==="task.completed"){const n=Vo(t,e.sessionId);u3(n);return}if(e.type==="phase.changed"&&e.sessionId){const n=e.payload,r=v1.get(e.sessionId)??null;if(v1.set(e.sessionId,n.phase),r===n.phase)return;const a=Vo(t,e.sessionId);n.phase==="blocked"&&d3(a)}}const Kc=Jn(e=>({servers:[],setServers:t=>e({servers:t}),fetchServers:async()=>{try{const t=await we("/api/mcp/servers");if(!t.ok)return;const r=((await t.json()).servers??[]).sort((a,l)=>a.name.localeCompare(l.name));e({servers:r})}catch{}}})),yg=new Set;function xn(e,t){return t!==null&&e.sessionId===t}function m3(e,t,n){return e.id!==void 0||xn(e,t)||n===!0&&e.sessionId!==void 0}function p3(e,t){return e.includes(t)?e:[...e,t]}function _1(e,t){return e.filter(n=>n!==t)}function g3(e,t){const n=e.find(l=>l.id===t.id),r=t.messageCount??0,a=n?{...n,projectId:t.projectId,workdir:t.workdir,workspace:t.workspace,branch:t.branch,mode:t.mode,phase:t.phase,isRunning:t.isRunning&&n.isRunning!==!1,messageCount:r,criteriaCount:t.criteria.length,criteriaCompleted:t.criteria.filter(l=>l.status.type==="passed").length}:{id:t.id,projectId:t.projectId,workdir:t.workdir,workspace:t.workspace,branch:t.branch,mode:t.mode,phase:t.phase,isRunning:t.isRunning,isFavorite:!1,createdAt:"",updatedAt:"",criteriaCount:t.criteria.length,criteriaCompleted:t.criteria.filter(l=>l.status.type==="passed").length,messageCount:r};return n?e.map(l=>l.id===t.id?a:l):[a,...e]}function bg(e,t){const n=e.findIndex(r=>r.callId===t.callId);if(n>=0){const r=[...e];return r[n]=t,r}return[...e,t]}function x3(e,t,n){return e.map(r=>{const a=(n==null?void 0:n.id)===r.id?n:null,l=t.find(u=>u.id===r.id);return{...r,title:r.title??(l==null?void 0:l.title),mode:(a==null?void 0:a.mode)??(l==null?void 0:l.mode)??r.mode,phase:(a==null?void 0:a.phase)??(l==null?void 0:l.phase)??r.phase,isRunning:r.isRunning&&(l==null?void 0:l.isRunning)!==!1,messageCount:r.messageCount,recentUserPrompts:r.recentUserPrompts}})}function S1(e,t,n,r){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(h=>h.id===a?r(h):h)})),!u){const d=n().currentSession;if(d){const h=r(d);t(()=>({currentSession:h}))}}}function w1(e,t,n){var c,d,h,p,m,g,y,w,C,_,S,b,v,k,T,N,R,A,O,P,V,z,W;const r=n();f3(e,r);const a=((c=r.currentSession)==null?void 0:c.id)??null,l=()=>{const M=e.sessionId;!M||M===a||t(U=>({unreadSessionIds:p3(U.unreadSessionIds,M)}))},u=(M,U,F)=>({messages:M.messages.map(Q=>Q.id===U?F(Q):Q)});switch(e.type){case"session.state":{const M=e.payload;if(!m3(e,a,r.pendingSessionCreate))break;Da();const U=n().pendingSessionCreate===!0,F=M.pendingConfirmations??[],Q=M.session.id,X={...n().crossSessionConfirmations};delete X[Q],t({currentSession:M.session,sessions:g3(n().sessions,M.session),unreadSessionIds:_1(n().unreadSessionIds,Q),messages:M.messages,hiddenCount:M.hiddenCount??0,currentTodos:[],pendingPathConfirmations:F,crossSessionConfirmations:X,sessionsWithPendingConfirmations:Object.keys(X),pendingQuestions:M.pendingQuestions??[],activeWorkflowExecution:M.activeWorkflowExecution??null,...U?{pendingSessionCreate:M.session.id}:{}});break}case"session.list":{const M=e.payload;t(U=>({sessions:x3(M.sessions,U.sessions,U.currentSession)}));break}case"session.created":{const M=e.payload;t(U=>({sessions:U.sessions.some(F=>F.id===M.session.id)?U.sessions.map(F=>F.id===M.session.id?{...F,...M.session}:F):[M.session,...U.sessions],searchSessions:null}));break}case"session.deleted":{const M=e.payload;t(U=>({unreadSessionIds:_1(U.unreadSessionIds,M.sessionId),searchSessions:null})),n().listSessions();break}case"session.deletedAll":{t({searchSessions:null}),n().listSessions();break}case"session.running":{const M=e.payload;S1(e,t,n,U=>({...U,isRunning:M.isRunning})),M.isRunning||t({abortInProgress:!1,queuedMessages:[]}),M.isRunning&&t({restoredInput:null});break}case"chat.message":{if(!xn(e,((d=n().currentSession)==null?void 0:d.id)??null)){l();break}const M=e.payload;t(U=>{if(U.messages.some(Q=>Q.id===M.message.id))return U;const F=M.message.role==="user";return{messages:[...U.messages,M.message],sessions:U.sessions.map(Q=>Q.id===e.sessionId&&F?{...Q,messageCount:Q.messageCount+1}:Q)}});break}case"chat.message_updated":{if(!xn(e,((h=n().currentSession)==null?void 0:h.id)??null)){l();break}const M=e.payload,U=n().messages.find(Q=>Q.id===M.messageId);M.updates.isStreaming===!1&&(U==null?void 0:U.isStreaming)===!0&&Da(),t(Q=>({messages:Q.messages.map(X=>X.id===M.messageId?{...X,...M.updates}:X)}));break}case"chat.delta":{if(!xn(e,((p=n().currentSession)==null?void 0:p.id)??null)){l();break}const M=e.payload;if(!yg.has(M.messageId)){yg.add(M.messageId);const F=M.subAgentType?"sub-agent":Vo(n(),e.sessionId);h3(F)}const U=Dc();U.messageId=M.messageId,U.deltaContent+=M.content,pg();break}case"chat.thinking":{if(!xn(e,((m=n().currentSession)==null?void 0:m.id)??null)){l();break}const M=e.payload,U=Dc();U.messageId=M.messageId,U.thinkingContent+=M.content,pg();break}case"chat.tool_preparing":{if(!xn(e,((g=n().currentSession)==null?void 0:g.id)??null)){l();break}const M=e.payload;t(U=>{var D;const F=U.messages.find(q=>q.id===M.messageId);if(!F)return{};if((D=F.toolCalls)==null?void 0:D.find((q,$)=>$===M.index))return{};const X=F.preparingToolCalls??[],H=X.findIndex(q=>q.index===M.index);let I;return H>=0?I=X.map((q,$)=>$===H?{...q,arguments:M.arguments}:q):I=[...X,{index:M.index,name:M.name,...M.arguments?{arguments:M.arguments}:{}}],{messages:U.messages.map(q=>q.id===M.messageId?{...q,preparingToolCalls:I}:q)}});break}case"chat.tool_call":{if(!xn(e,((y=n().currentSession)==null?void 0:y.id)??null)){l();break}const M=e.payload,U=F=>{var D;const Q=(F.toolCalls??[]).length,X=(D=F.preparingToolCalls)==null?void 0:D.filter(q=>q.index!==Q),H=Dc(),I=H.toolOutput.filter(q=>q.callId===M.callId);return I.length>0&&(H.toolOutput=H.toolOutput.filter(q=>q.callId!==M.callId)),{...F,toolCalls:[...F.toolCalls??[],{id:M.callId,name:M.tool,arguments:M.args,startedAt:Date.now(),...I.length>0?{streamingOutput:I.map(q=>({stream:q.stream,content:q.content,timestamp:Date.now()}))}:{}}],...X&&X.length>0?{preparingToolCalls:X}:{preparingToolCalls:void 0}}};t(F=>u(F,M.messageId,U));break}case"chat.tool_output":{if(!xn(e,((w=n().currentSession)==null?void 0:w.id)??null)){l();break}const M=e.payload,U=Dc();U.messageId=M.messageId,U.toolOutput.push({messageId:M.messageId,callId:M.callId,stream:M.stream,content:M.output}),pg();break}case"chat.tool_result":{if(!xn(e,((C=n().currentSession)==null?void 0:C.id)??null)){l();break}const M=e.payload,U=F=>{var X;const Q=(X=F.toolCalls)==null?void 0:X.map(H=>H.id===M.callId?{...H,result:M.result}:H);return{...F,toolCalls:Q}};t(F=>u(F,M.messageId,U));break}case"chat.vision_fallback":{if(!xn(e,((_=n().currentSession)==null?void 0:_.id)??null)){l();break}const M=e.payload;t(U=>{const F=`${M.messageId}-${M.attachmentId}`,Q={...U.visionFallbackByMessage};return Q[F]={type:M.type,attachmentId:M.attachmentId,filename:M.filename,description:M.description},{visionFallbackByMessage:Q}});break}case"chat.todo":{if(!xn(e,((S=n().currentSession)==null?void 0:S.id)??null)){l();break}const M=e.payload;t({currentTodos:M.todos});break}case"chat.progress":{if(!xn(e,((b=n().currentSession)==null?void 0:b.id)??null)){l();break}const M=e.payload;console.warn("Progress:",M.message,M.phase);break}case"chat.format_retry":{if(!xn(e,((v=n().currentSession)==null?void 0:v.id)??null)){l();break}const M=e.payload;console.warn("Format retry:",M.attempt,"/",M.maxAttempts);break}case"chat.done":{if(!xn(e,((k=n().currentSession)==null?void 0:k.id)??null)){l();break}Da(),yg.delete(e.payload.messageId);const M=e.payload,U=M.stats;t(F=>({messages:F.messages.map(Q=>Q.id===M.messageId?{...Q,isStreaming:!1,stats:U??Q.stats,completeReason:M.reason,preparingToolCalls:void 0}:Q),visionFallbackByMessage:{}}));break}case"chat.error":{if(!xn(e,((T=n().currentSession)==null?void 0:T.id)??null)){l();break}Da();const M=e.payload;console.error("Chat error:",M.error,"recoverable:",M.recoverable),t(U=>({error:{code:"CHAT_ERROR",message:M.error},...M.recoverable?{}:{messages:U.messages}}));break}case"chat.path_confirmation":{const M=e.sessionId,U=M===(((N=n().currentSession)==null?void 0:N.id)??null),F=e.payload,Q={callId:F.callId,tool:F.tool,paths:F.paths,workdir:F.workdir,reason:F.reason};if(!U){l(),M&&t(X=>({crossSessionConfirmations:{...X.crossSessionConfirmations,[M]:bg(X.crossSessionConfirmations[M]??[],Q)},sessionsWithPendingConfirmations:X.sessionsWithPendingConfirmations.includes(M)?X.sessionsWithPendingConfirmations:[...X.sessionsWithPendingConfirmations,M]}));break}t(X=>({pendingPathConfirmations:bg(X.pendingPathConfirmations,Q)}));break}case"session.confirmation_pending":{const M=e.sessionId,U=e.payload,F={callId:U.callId,tool:U.tool,paths:U.paths,workdir:U.workdir,reason:U.reason};M&&t(Q=>({crossSessionConfirmations:{...Q.crossSessionConfirmations,[M]:bg(Q.crossSessionConfirmations[M]??[],F)},sessionsWithPendingConfirmations:Q.sessionsWithPendingConfirmations.includes(M)?Q.sessionsWithPendingConfirmations:[...Q.sessionsWithPendingConfirmations,M]}));break}case"session.confirmation_resolved":{const M=e.sessionId,U=e.payload;M&&t(F=>{const X=(F.crossSessionConfirmations[M]??[]).filter(I=>I.callId!==U.callId),H={...F.crossSessionConfirmations};return X.length===0?delete H[M]:H[M]=X,{crossSessionConfirmations:H,sessionsWithPendingConfirmations:Object.keys(H)}});break}case"chat.ask_user":{if(!xn(e,((R=n().currentSession)==null?void 0:R.id)??null)){l();return}const M=e.payload,U={callId:M.callId,question:M.question,type:M.type??"text",options:M.options??void 0};t(F=>({pendingQuestions:[...F.pendingQuestions.filter(Q=>Q.callId!==M.callId),U]}));break}case"mode.changed":{if(!xn(e,((A=n().currentSession)==null?void 0:A.id)??null)){l();break}const M=e.payload;t(U=>({currentSession:U.currentSession?{...U.currentSession,mode:M.mode}:null}));break}case"phase.changed":{const M=e.payload;S1(e,t,n,U=>({...U,phase:M.phase}));break}case"workflow.execution_changed":{if(!xn(e,((O=n().currentSession)==null?void 0:O.id)??null)){l();break}const M=e.payload,U={...M.currentStepId?{currentStepId:M.currentStepId}:{},...M.currentStepName?{currentStepName:M.currentStepName}:{},...M.pendingChoices?{pendingChoices:M.pendingChoices}:{}};t(F=>{const Q=F.activeWorkflowExecution;return Q?{activeWorkflowExecution:{...Q,status:M.status,...U}}:{activeWorkflowExecution:{id:M.executionId,sessionId:e.sessionId??"",workflowId:M.workflowId,workflowName:M.workflowName,...M.workflowColor?{workflowColor:M.workflowColor}:{},status:M.status,...U,stepOutput:{},params:{},createdAt:Date.now(),updatedAt:Date.now()}}});break}case"criteria.updated":{if(!xn(e,((P=n().currentSession)==null?void 0:P.id)??null)){l();break}const M=e.payload;t(U=>({currentSession:U.currentSession?{...U.currentSession,criteria:M.criteria}:null}));break}case"metadata.updated":{if(!xn(e,((V=n().currentSession)==null?void 0:V.id)??null)){l();break}const M=e.payload;t(U=>({currentSession:U.currentSession?{...U.currentSession,metadataEntries:{...U.currentSession.metadataEntries,[M.key]:M.entries}}:null}));break}case"context.state":{const M=e.payload,U=xn(e,((z=n().currentSession)==null?void 0:z.id)??null);M.subAgentId?U&&n().updateSubAgentContextState(M.subAgentId,M.context):U?t({contextState:M.context}):l();break}case"session.name_generated":{const M=e.payload,U=e.sessionId,F=(W=n().currentSession)==null?void 0:W.id;t(Q=>{const X=Q.sessions.map(I=>I.id===U?{...I,title:M.name}:I),H=F===U?Q.currentSession?{...Q.currentSession,metadata:{...Q.currentSession.metadata,title:M.name}}:null:Q.currentSession;return{sessions:X,currentSession:H}});break}case"queue.state":{const M=e.payload;t({queuedMessages:M.messages??[]});break}case"mcp.servers.changed":{const M=e.payload;if(M!=null&&M.servers){const U=[...M.servers].sort((F,Q)=>F.name.localeCompare(Q.name));Kc.getState().setServers(U)}else window.dispatchEvent(new CustomEvent("mcp-servers-changed"));break}case"git.status":{const M=e.payload;t({gitStatus:{branch:M.branch,diff:M.diff}});break}case"devServer.output":case"devServer.state":{Yn.getState().handleMessage(e);break}case"backgroundProcess.started":case"backgroundProcess.output":case"backgroundProcess.exited":case"backgroundProcess.removed":{Pc.getState().handleMessage(e.type,e.payload);break}case"error":{const M=e.payload;console.error("Server error:",M),t({error:{code:M.code,message:M.message}});break}}}let xc=!1,ys=null;const vg=new Set,_a=new Set,zd=new Map;let yc=null;function C1(e,t,n){return e==null?void 0:e.map(r=>{const a=t.filter(l=>l.callId===r.id);return a.length===0?r:(n.add(r.id),{...r,streamingOutput:[...r.streamingOutput??[],...a.map(l=>({stream:l.stream,content:l.content,timestamp:Date.now()}))]})})}async function k1(e,t,n,r,a){try{const u=await(await we(`/api/sessions/${e}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:t,attachments:n,messageKind:r})})).json();u.queueState&&a({queuedMessages:u.queueState})}catch(l){console.error("Error queueing message:",l)}}function E1(e,t){return e.map(n=>{var a,l;const r=t.sessions.find(u=>u.id===n.id);return{...n,title:n.title??(r==null?void 0:r.title),mode:((a=t.currentSession)==null?void 0:a.id)===n.id?t.currentSession.mode:(r==null?void 0:r.mode)??n.mode,phase:((l=t.currentSession)==null?void 0:l.id)===n.id?t.currentSession.phase:(r==null?void 0:r.phase)??n.phase,isRunning:n.isRunning&&(r==null?void 0:r.isRunning)!==!1,messageCount:n.messageCount,...n.recentUserPrompts!==void 0&&{recentUserPrompts:n.recentUserPrompts}}})}const De=Jn((e,t)=>{e3(()=>{const r=Dc();if(!r.messageId)return;const a=r.deltaContent.length>0,l=r.thinkingContent.length>0,u=r.toolOutput.length>0;if(!a&&!l&&!u)return;const c=r.deltaContent,d=r.thinkingContent,h=r.toolOutput;r.deltaContent="",r.thinkingContent="",r.toolOutput=[],e(p=>{const m=p.messages.find(g=>g.id===r.messageId);if(m){const g={...m};if(a&&(g.content=g.content+c),l&&(g.thinkingContent=(g.thinkingContent??"")+d),u){const y=new Set;g.toolCalls=C1(g.toolCalls,h,y);const w=h.filter(C=>!y.has(C.callId));w.length>0&&r.toolOutput.push(...w)}return{messages:p.messages.map(y=>y.id===r.messageId?g:y)}}if(u){const g=new Set,y=p.messages.map(C=>C.id!==r.messageId?C:{...C,toolCalls:C1(C.toolCalls,h,g)}),w=h.filter(C=>!g.has(C.callId));return w.length>0&&r.toolOutput.push(...w),{messages:y}}return p})});function n(r,a,l,u,c){return{workflowId:r.workflowId,resumeFrom:r.currentStepId,stepOutput:r.stepOutput,...r.params&&Object.keys(r.params).length>0?{params:r.params}:{},...c?{userChoice:c}:{},...a!=null&&a.trim()?{content:a}:{},...l&&l.length>0?{attachments:l}:{},...u?{messageKind:u}:{}}}return{connectionStatus:"disconnected",showPasswordModal:!1,passwordModalRetry:!1,sessions:[],searchSessions:null,currentSession:null,unreadSessionIds:[],messages:[],hiddenCount:0,currentTodos:[],contextState:null,subAgentContextStates:{},pendingPathConfirmations:[],crossSessionConfirmations:{},sessionsWithPendingConfirmations:[],pendingQuestions:[],visionFallbackByMessage:{},gitStatus:null,queuedMessages:[],abortInProgress:!1,restoredInput:null,error:null,activeWorkflowExecution:null,sessionsHasMore:!0,sessionsPaginationLoading:!1,pendingSessionCreate:!1,pendingUpdate:!1,connect:async()=>{if(t().connectionStatus==="connected")return;e({connectionStatus:"reconnecting"});let a=!1;try{a=(await(await we("/api/auth")).json()).requiresAuth}catch{}if(a&&!Pt.hasToken()){e({showPasswordModal:!0,passwordModalRetry:!1,connectionStatus:"reconnecting"});return}Pt.onStatusChange(l=>{var u,c;if(e({connectionStatus:l}),l==="connected"){const d=(u=t().currentSession)==null?void 0:u.projectId;d&&t().listSessions(d),tn.getState().listProjects();const h=(c=t().currentSession)==null?void 0:c.id;h&&t().loadSession(h)}else(l==="disconnected"||l==="reconnecting")&&_a.clear()});try{await Pt.connect(),xc||(xc=!0,ys=Pt.subscribe(l=>{w1(l,e,t)}))}catch(l){console.error("Failed to connect:",l);const u=Pt.getLastCloseCode();if(!Pt.hasToken()&&(u===1006||u===4e3)){e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"});return}ys&&(ys(),ys=null),xc=!1,e({connectionStatus:"disconnected"})}},reconnect:()=>{Pt.disconnect(),ys&&(ys(),ys=null),xc=!1,_a.clear(),e({connectionStatus:"disconnected"}),t().connect()},disconnect:()=>{Pt.disconnect(),ys&&(ys(),ys=null),xc=!1,_a.clear(),e({connectionStatus:"disconnected",showPasswordModal:!1})},submitPassword:async r=>{try{const a=await fetch(hs("/api/auth/login"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({password:r})});if(!a.ok){e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"});return}const{token:l}=await a.json();Pt.setToken(l),e({showPasswordModal:!1}),t().connect();const{listProjects:u}=tn.getState(),{fetchConfig:c}=Zt.getState();u(),c(),t().connect()}catch{e({showPasswordModal:!0,passwordModalRetry:!0,connectionStatus:"reconnecting"})}},cancelPassword:()=>{Pt.clearToken(),e({showPasswordModal:!1,connectionStatus:"disconnected"})},createSession:async(r,a)=>{if(t().pendingSessionCreate)return null;try{e({pendingSessionCreate:!0});const u=await we("/api/sessions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectId:r,title:a})});if(!u.ok)return e({pendingSessionCreate:!1}),null;const c=await u.json();e({searchSessions:null});try{Pt.send("session.load",{sessionId:c.session.id})}catch{}return c.session}catch{return e({pendingSessionCreate:!1}),null}},loadSession:async(r,a=!1)=>{if(!(!a&&vg.has(r))&&!(!a&&_a.has(r))){vg.add(r);try{const l=t().currentSession;if(!l||l.id!==r){_a.clear();const g=l==null?void 0:l.id,y=t().pendingPathConfirmations,C={...t().crossSessionConfirmations};g&&y.length>0&&(C[g]=[...C[g]??[],...y]),Da(),e({currentSession:null,unreadSessionIds:t().unreadSessionIds.filter(_=>_!==r),subAgentContextStates:{},messages:[],currentTodos:[],contextState:null,pendingPathConfirmations:[],pendingQuestions:[],queuedMessages:[],abortInProgress:!1,restoredInput:null,error:null,gitStatus:null,pendingSessionCreate:!1,crossSessionConfirmations:C,sessionsWithPendingConfirmations:Object.keys(C)})}else e({unreadSessionIds:t().unreadSessionIds.filter(g=>g!==r)});const u=KD(r),c=u?u.then(async g=>{if(g.ok)return g.data;const y=await we(`/api/sessions/${r}`);return y.ok?await y.json():null}):we(`/api/sessions/${r}`).then(async g=>g.ok?await g.json():null),d=we(`/api/sessions/${r}/background-processes`),h=await c;if(!h)return;const p=h.messages??[],m={...t().crossSessionConfirmations};delete m[r],e({currentSession:h.session,messages:p,hiddenCount:h.hiddenCount??0,contextState:h.contextState,queuedMessages:h.queueState??[],pendingPathConfirmations:h.pendingConfirmations??[],pendingQuestions:h.pendingQuestions??[],activeWorkflowExecution:h.activeWorkflowExecution??null,crossSessionConfirmations:m,sessionsWithPendingConfirmations:Object.keys(m)}),Pt.send("session.load",{sessionId:r});try{const g=await d;if(g.ok){const y=await g.json();Pc.getState().setProcesses(y.processes??[])}}catch{}_a.add(r)}catch{}finally{vg.delete(r)}}},listSessions:async(r,a=20)=>{const l=r??"global";if(zd.has(l))return zd.get(l);const u=(async()=>{var c;try{const d=new URLSearchParams;d.set("limit",String(a)),r&&d.set("projectId",r);const p=await(await we(`/api/sessions?${d.toString()}`)).json(),m=p.sessions??[];e(y=>({sessions:E1(m,y),sessionsHasMore:r?p.hasMore??!1:!0}));const g=p.pendingConfirmationsBySession;if(g){const y=(c=t().currentSession)==null?void 0:c.id,w={};for(const[C,_]of Object.entries(g))C!==y&&(w[C]=_);e({crossSessionConfirmations:w,sessionsWithPendingConfirmations:Object.keys(w)})}}catch{}finally{zd.delete(l)}})();return zd.set(l,u),u},listHomeSessions:async()=>{try{const r=await we("/api/sessions/home");if(!r.ok)return;const a=await r.json();e(l=>({sessions:E1(a.sessions,l),sessionsHasMore:!1}))}catch{}},ensureFullSessionList:async()=>{if(!t().searchSessions)return yc||(yc=(async()=>{try{const l=(await(await we("/api/sessions")).json()).sessions??[];e({searchSessions:l})}catch{}finally{yc=null}})(),yc)},loadMoreSessions:async r=>{const a=t();if(!(a.sessionsPaginationLoading||!a.sessionsHasMore)){e({sessionsPaginationLoading:!0});try{const l=new URLSearchParams;l.set("limit","20"),l.set("offset",String(a.sessions.length)),l.set("projectId",r);const c=await(await we(`/api/sessions?${l.toString()}`)).json(),d=c.sessions??[];e(h=>({sessions:[...h.sessions,...d.map(p=>{const m=h.sessions.find(g=>g.id===p.id);return(m==null?void 0:m.isRunning)===!1?{...p,isRunning:!1}:p})],sessionsHasMore:c.hasMore??!1,sessionsPaginationLoading:!1}))}catch{e({sessionsPaginationLoading:!1})}}},deleteSession:async r=>{var a;try{return(await we(`/api/sessions/${r}`,{method:"DELETE"})).ok?(e({searchSessions:null}),await t().listSessions(),((a=t().currentSession)==null?void 0:a.id)===r&&t().clearSession(),!0):!1}catch{return!1}},renameSession:async(r,a)=>{var l;try{const u=await we(`/api/sessions/${r}/title`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:a})});if(!u.ok)return!1;if(e({searchSessions:null}),await t().listSessions(),((l=t().currentSession)==null?void 0:l.id)===r){const d=await u.json();d.session&&e({currentSession:d.session})}return!0}catch{return!1}},toggleFavorite:async(r,a)=>{e(l=>({sessions:l.sessions.map(u=>u.id===r?{...u,isFavorite:a}:u)}));try{const l=await we(`/api/sessions/${r}/favorite`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({isFavorite:a})});return l.ok?(await t().listSessions(),!0):(console.warn("Failed to toggle favorite",{sessionId:r,isFavorite:a,status:l.status}),e(u=>({sessions:u.sessions.map(c=>c.id===r?{...c,isFavorite:!a}:c)})),!1)}catch(l){return console.error("Error toggling favorite:",l),e(u=>({sessions:u.sessions.map(c=>c.id===r?{...c,isFavorite:!a}:c)})),!1}},deleteAllSessions:async r=>{try{return(await we(`/api/projects/${r}/sessions`,{method:"DELETE"})).ok?(e({searchSessions:null}),await t().listSessions(),!0):!1}catch{return!1}},clearSession:()=>{Da(),_a.clear(),e(r=>({currentSession:null,messages:[],hiddenCount:0,currentTodos:[],contextState:null,restoredInput:null,pendingSessionCreate:!1,unreadSessionIds:r.currentSession?r.unreadSessionIds.filter(a=>a!==r.currentSession.id):r.unreadSessionIds}))},sendMessage:async(r,a,l)=>{var d;e({error:null});const u=(d=t().currentSession)==null?void 0:d.id;if(!u)return;const c=t().activeWorkflowExecution;if(c&&c.status==="running"){Pt.send("runner.launch",n(c,r,a,l==null?void 0:l.messageKind));return}try{const h=r==null?void 0:r.trim(),p=a&&a.length>0,m={};h&&(m.content=r),p&&(m.attachments=a),l!=null&&l.messageKind&&(m.messageKind=l.messageKind);const y=await(await we(`/api/sessions/${u}/message`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(m)})).json();y.queueState&&e({queuedMessages:y.queueState})}catch(h){console.error("Error sending message:",h)}},stopGeneration:async()=>{var a;const r=(a=t().currentSession)==null?void 0:a.id;if(r&&!t().abortInProgress){Da(),e({abortInProgress:!0});try{const u=await(await we(`/api/sessions/${r}/stop`,{method:"POST"})).json();if(u.queuedMessages&&u.queuedMessages.length>0){const c=u.queuedMessages.map(d=>d.content).join(`
67
+ `);e({restoredInput:c})}}catch(l){console.error("Error stopping generation:",l)}}},continueGeneration:async()=>{var a;const r=(a=t().currentSession)==null?void 0:a.id;if(r)try{await we(`/api/sessions/${r}/continue`,{method:"POST"})}catch(l){console.error("Error continuing generation:",l)}},launchWorkflow:(r,a,l,u,c,d)=>{const h={};r!=null&&r.trim()&&(h.content=r),a&&a.length>0&&(h.attachments=a),l&&(h.workflowId=l),u&&(h.subGroup=u),c&&(h.params=c),h.scope=d??"auto",Pt.send("runner.launch",h)},continueWorkflow:r=>{const l=t().activeWorkflowExecution;!l||l.status!=="waiting"||Pt.send("runner.launch",n(l,void 0,void 0,void 0,r))},exitWorkflow:()=>{Pt.send("workflow.exit",{})},switchMode:async r=>{var l;const a=(l=t().currentSession)==null?void 0:l.id;if(a)try{const u=await we(`/api/sessions/${a}/mode`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({mode:r})});if(!u.ok){console.error("Failed to switch mode:",await u.json());return}const c=await u.json();c.session&&e({currentSession:c.session}),c.messages&&e({messages:c.messages,hiddenCount:c.hiddenCount??0})}catch(u){console.error("Error switching mode:",u)}},switchDangerLevel:async r=>{var l;const a=(l=t().currentSession)==null?void 0:l.id;if(a)try{const u=await we(`/api/sessions/${a}/danger-level`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({dangerLevel:r})});if(!u.ok){console.error("Failed to switch danger level:",await u.json());return}const c=await u.json();c.session&&e({currentSession:c.session})}catch(u){console.error("Error switching danger level:",u)}},editCriteria:async r=>{var l;const a=(l=t().currentSession)==null?void 0:l.id;if(a)try{const u=await we(`/api/sessions/${a}/criteria`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({criteria:r})});u.ok||console.error("Failed to update criteria:",await u.json())}catch(u){console.error("Error updating criteria:",u)}},compactContext:()=>{Pt.send("context.compact",{})},setSessionProvider:async(r,a)=>{var l;try{const u=(l=t().currentSession)==null?void 0:l.id;if(!u)return null;const c=await we(`/api/sessions/${u}/provider`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerId:r,...a?{model:a}:{}})});if(!c.ok)return null;const d=await c.json();return e({currentSession:d.session,messages:d.messages??[],hiddenCount:d.hiddenCount??0,contextState:d.contextState}),d.session}catch{return null}},updateContextState:r=>{e({contextState:r})},updateSubAgentContextState:(r,a)=>{e(l=>({subAgentContextStates:{...l.subAgentContextStates,[r]:a}}))},clearSubAgentContextState:r=>{e(a=>{const l={...a.subAgentContextStates};return delete l[r],{subAgentContextStates:l}})},confirmPath:async(r,a,l=!1)=>{var c;const u=(c=t().currentSession)==null?void 0:c.id;if(u)try{const d=await we(`/api/sessions/${u}/confirm-path`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({callId:r,approved:a,alwaysAllow:l})});if(!d.ok){const h=await d.json().catch(()=>({}));console.error("Error confirming path:",h.error??`HTTP ${d.status}`)}}catch(d){console.error("Error confirming path:",d)}},answerQuestion:async(r,a,l)=>{var c;const u=(c=t().currentSession)==null?void 0:c.id;if(u){try{await we(`/api/sessions/${u}/answer`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({callId:r,answer:a,skip:l})})}catch(d){console.error("Error answering question:",d)}e(d=>({pendingQuestions:d.pendingQuestions.filter(h=>h.callId!==r)}))}},queueAsap:async(r,a,l)=>{var c;const u=(c=t().currentSession)==null?void 0:c.id;u&&await k1(u,r,a,l,e)},queueCompletion:async(r,a,l)=>{var c;const u=(c=t().currentSession)==null?void 0:c.id;u&&await k1(u,r,a,l,e)},cancelQueued:async r=>{var l;const a=(l=t().currentSession)==null?void 0:l.id;if(a)try{const c=await(await we(`/api/sessions/${a}/queue/${r}`,{method:"DELETE"})).json();c.queueState&&e({queuedMessages:c.queueState})}catch(u){console.error("Error canceling queued message:",u)}},clearError:()=>{e({error:null})},clearRestoredInput:()=>{e({restoredInput:null})},resetPendingSessionCreate:()=>{e({pendingSessionCreate:!1})},queueUpdate:()=>{e({pendingUpdate:!0})},triggerPendingUpdate:()=>{t().pendingUpdate&&(e({pendingUpdate:!1}),Pt.send("context.applyDynamic",{}))},handleServerMessage:r=>{w1(r,e,t)}}});function gf(){return De(e=>{var t;return((t=e.currentSession)==null?void 0:t.isRunning)??!1})}function y3(){return De(e=>e.abortInProgress)}function b3(){const e=De(a=>a.connect),t=De(a=>a.connectionStatus),n=La(a=>a.load),r=ml("/p/:projectId/s/:sessionId/readonly")[0];return E.useEffect(()=>{r||e()},[e,r]),E.useEffect(()=>{r||t==="connected"&&n()},[t,n,r]),{connectionStatus:t}}const v3="modulepreload",_3=function(e){return"/"+e},j1={},te=function(t,n,r){let a=Promise.resolve();if(n&&n.length>0){let u=function(h){return Promise.all(h.map(p=>Promise.resolve(p).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};document.getElementsByTagName("link");const 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(h=>{if(h=_3(h),h in j1)return;j1[h]=!0;const p=h.endsWith(".css"),m=p?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${m}`))return;const g=document.createElement("link");if(g.rel=p?"stylesheet":v3,p||(g.as="script"),g.crossOrigin="",g.href=h,d&&g.setAttribute("nonce",d),document.head.appendChild(g),p)return new Promise((y,w)=>{g.addEventListener("load",y),g.addEventListener("error",()=>w(new Error(`Unable to preload CSS for ${h}`)))})}))}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)})},S3=[{key:"color-bg-primary",category:"background",label:"Primary Background",defaultValue:"13 17 23"},{key:"color-bg-secondary",category:"background",label:"Secondary Background",defaultValue:"22 27 34"},{key:"color-bg-tertiary",category:"background",label:"Tertiary Background",defaultValue:"33 38 45"},{key:"color-primary",category:"surface",label:"Primary Surface",defaultValue:"10 10 10"},{key:"color-secondary",category:"surface",label:"Secondary Surface",defaultValue:"20 20 20"},{key:"color-text-primary",category:"text",label:"Primary Text",defaultValue:"139 148 158"},{key:"color-text-secondary",category:"text",label:"Secondary Text",defaultValue:"139 148 158"},{key:"color-text-muted",category:"text",label:"Muted Text",defaultValue:"72 79 88"},{key:"color-accent-primary",category:"accent",label:"Primary Accent",defaultValue:"88 166 255"},{key:"color-accent-success",category:"accent",label:"Success Accent",defaultValue:"63 185 80"},{key:"color-accent-warning",category:"accent",label:"Warning Accent",defaultValue:"210 153 34"},{key:"color-accent-error",category:"accent",label:"Error Accent",defaultValue:"248 81 73"},{key:"color-border",category:"border",label:"Border",defaultValue:"48 53 60"},{key:"color-text-heading",category:"text",label:"Heading Text",defaultValue:"56 189 248"},{key:"color-text-bold",category:"text",label:"Bold Text",defaultValue:"251 191 36"},{key:"color-text-code",category:"text",label:"Inline Code Text",defaultValue:"88 166 255"},{key:"color-text-link",category:"text",label:"Link Text",defaultValue:"88 166 255"},{key:"color-bg-system",category:"background",label:"System Message Background",defaultValue:"40 35 28"},{key:"color-border-system",category:"border",label:"System Message Border",defaultValue:"65 55 25"},{key:"color-text-system",category:"text",label:"System Message Text",defaultValue:"253 230 138"},{key:"color-text-thinking",category:"text",label:"Thinking Label",defaultValue:"192 132 252"},{key:"color-text-truncated",category:"text",label:"Truncation Warning",defaultValue:"251 191 36"},{key:"color-text-tool-error",category:"text",label:"Tool Error Text",defaultValue:"248 81 73"}],w3=JSON.parse('[{"id":"system","name":"System","tokens":{}},{"id":"dark","name":"Dark","tokens":{"color-bg-primary":"13 17 23","color-bg-secondary":"22 27 34","color-bg-tertiary":"33 38 45","color-primary":"10 10 10","color-secondary":"20 20 20","color-text-primary":"255 255 255","color-text-secondary":"139 148 158","color-text-muted":"72 79 88","color-accent-primary":"88 166 255","color-accent-success":"63 185 80","color-accent-warning":"210 153 34","color-accent-error":"248 81 73","color-border":"48 53 60","color-text-heading":"56 189 248","color-text-bold":"251 191 36","color-text-code":"255 255 255","color-text-link":"88 166 255","color-bg-system":"40 35 28","color-border-system":"65 55 25","color-text-system":"253 230 138","color-text-thinking":"192 132 252","color-text-truncated":"251 191 36","color-text-tool-error":"248 113 113"},"mode":"dark"},{"id":"light","name":"Light","tokens":{"color-bg-primary":"255 255 255","color-bg-secondary":"250 251 252","color-bg-tertiary":"243 244 246","color-primary":"245 245 245","color-secondary":"229 229 229","color-text-primary":"15 23 42","color-text-secondary":"30 41 59","color-text-muted":"100 116 139","color-accent-primary":"37 99 235","color-accent-success":"22 163 74","color-accent-warning":"217 119 6","color-accent-error":"220 38 38","color-border":"203 213 225","color-text-heading":"2 132 199","color-text-bold":"217 119 6","color-text-code":"37 99 235","color-text-link":"37 99 235","color-bg-system":"254 243 199","color-border-system":"252 211 77","color-text-system":"146 100 30","color-text-thinking":"147 51 234","color-text-truncated":"217 119 6","color-text-tool-error":"220 38 38"},"mode":"light"},{"id":"monokai","name":"Monokai","tokens":{"color-bg-primary":"39 40 34","color-bg-secondary":"30 31 28","color-bg-tertiary":"62 61 50","color-primary":"30 31 28","color-secondary":"45 46 39","color-text-primary":"248 248 242","color-text-secondary":"207 207 194","color-text-muted":"117 113 94","color-accent-primary":"102 217 239","color-accent-success":"166 226 46","color-accent-warning":"230 219 116","color-accent-error":"249 38 114","color-border":"73 72 62","color-text-heading":"56 189 248","color-text-bold":"251 191 36","color-text-code":"248 248 242","color-text-link":"102 217 239","color-bg-system":"62 57 40","color-border-system":"85 75 40","color-text-system":"230 219 116","color-text-thinking":"192 132 252","color-text-truncated":"251 191 36","color-text-tool-error":"248 113 113"},"mode":"dark"},{"id":"dracula","name":"Dracula","tokens":{"color-bg-primary":"40 42 54","color-bg-secondary":"33 34 44","color-bg-tertiary":"68 71 90","color-primary":"30 31 41","color-secondary":"44 46 61","color-text-primary":"248 248 242","color-text-secondary":"230 230 230","color-text-muted":"98 114 164","color-accent-primary":"189 147 249","color-accent-success":"80 250 123","color-accent-warning":"255 184 108","color-accent-error":"255 85 85","color-border":"68 71 90","color-text-heading":"189 147 249","color-text-bold":"255 184 108","color-text-code":"189 147 249","color-text-link":"189 147 249","color-bg-system":"68 64 50","color-border-system":"90 80 60","color-text-system":"255 184 108","color-text-thinking":"255 121 198","color-text-truncated":"255 184 108","color-text-tool-error":"255 85 85"},"mode":"dark"},{"id":"nord","name":"Nord","tokens":{"color-bg-primary":"46 52 64","color-bg-secondary":"59 66 82","color-bg-tertiary":"67 76 94","color-primary":"46 52 64","color-secondary":"59 66 82","color-text-primary":"236 239 244","color-text-secondary":"229 233 240","color-text-muted":"121 133 160","color-accent-primary":"129 161 193","color-accent-success":"163 190 140","color-accent-warning":"235 203 139","color-accent-error":"191 97 106","color-border":"121 133 160","color-text-heading":"129 161 193","color-text-bold":"235 203 139","color-text-code":"129 161 193","color-text-link":"129 161 193","color-bg-system":"67 62 50","color-border-system":"85 80 60","color-text-system":"235 203 139","color-text-thinking":"184 142 173","color-text-truncated":"235 203 139","color-text-tool-error":"191 97 106"},"mode":"dark"},{"id":"rose-pine-dawn","name":"Rose Pine Dawn","tokens":{"color-bg-primary":"250 244 237","color-bg-secondary":"244 237 228","color-bg-tertiary":"235 226 216","color-primary":"250 244 237","color-secondary":"244 237 228","color-text-primary":"87 82 95","color-text-secondary":"111 105 120","color-text-muted":"175 170 180","color-accent-primary":"215 130 126","color-accent-success":"104 157 153","color-accent-warning":"234 157 84","color-accent-error":"215 85 112","color-border":"230 218 206","color-text-heading":"215 130 126","color-text-bold":"234 157 84","color-text-code":"145 117 186","color-text-link":"215 130 126","color-bg-system":"244 237 228","color-border-system":"230 218 206","color-text-system":"162 137 123","color-text-thinking":"145 117 186","color-text-truncated":"234 157 84","color-text-tool-error":"215 85 112"},"mode":"light"},{"id":"everforest-light","name":"Everforest Light","tokens":{"color-bg-primary":"255 248 235","color-bg-secondary":"245 238 220","color-bg-tertiary":"237 228 208","color-primary":"255 248 235","color-secondary":"245 238 220","color-text-primary":"91 105 86","color-text-secondary":"127 139 116","color-text-muted":"179 181 158","color-accent-primary":"100 153 117","color-accent-success":"141 169 73","color-accent-warning":"224 146 66","color-accent-error":"203 97 80","color-border":"230 216 194","color-text-heading":"100 153 117","color-text-bold":"224 146 66","color-text-code":"146 131 176","color-text-link":"100 153 117","color-bg-system":"245 238 220","color-border-system":"230 216 194","color-text-system":"163 147 121","color-text-thinking":"146 131 176","color-text-truncated":"224 146 66","color-text-tool-error":"203 97 80"},"mode":"light"},{"id":"synthwave-84","name":"Synthwave-84","tokens":{"color-bg-primary":"13 15 26","color-bg-secondary":"20 24 41","color-bg-tertiary":"26 31 51","color-primary":"10 12 20","color-secondary":"20 24 41","color-text-primary":"212 230 255","color-text-secondary":"136 153 187","color-text-muted":"68 85 119","color-accent-primary":"0 229 255","color-accent-success":"0 255 65","color-accent-warning":"255 106 0","color-accent-error":"255 0 60","color-border":"26 51 102","color-text-heading":"0 229 255","color-text-bold":"255 140 0","color-text-code":"0 255 170","color-text-link":"0 229 255","color-bg-system":"26 20 10","color-border-system":"51 40 20","color-text-system":"255 170 80","color-text-thinking":"191 0 255","color-text-truncated":"255 140 0","color-text-tool-error":"255 0 60"},"mode":"dark"},{"id":"one-dark-pro","name":"One Dark Pro","tokens":{"color-bg-primary":"40 44 52","color-bg-secondary":"33 37 43","color-bg-tertiary":"47 52 62","color-primary":"28 31 37","color-secondary":"33 37 43","color-text-primary":"171 178 191","color-text-secondary":"150 155 168","color-text-muted":"92 99 112","color-accent-primary":"97 175 239","color-accent-success":"152 195 121","color-accent-warning":"209 154 102","color-accent-error":"224 108 117","color-border":"57 62 72","color-text-heading":"97 175 239","color-text-bold":"209 154 102","color-text-code":"198 120 221","color-text-link":"97 175 239","color-bg-system":"47 42 32","color-border-system":"68 60 46","color-text-system":"224 190 79","color-text-thinking":"198 120 221","color-text-truncated":"209 154 102","color-text-tool-error":"224 108 117"},"mode":"dark"},{"id":"night-owl","name":"Night Owl","tokens":{"color-bg-primary":"1 22 39","color-bg-secondary":"0 30 55","color-bg-tertiary":"11 41 66","color-primary":"1 20 33","color-secondary":"0 30 55","color-text-primary":"214 222 235","color-text-secondary":"162 176 196","color-text-muted":"82 98 126","color-accent-primary":"130 170 255","color-accent-success":"34 218 110","color-accent-warning":"247 140 108","color-accent-error":"239 83 80","color-border":"30 56 85","color-text-heading":"130 170 255","color-text-bold":"247 140 108","color-text-code":"199 146 234","color-text-link":"130 170 255","color-bg-system":"30 25 20","color-border-system":"60 50 40","color-text-system":"247 199 120","color-text-thinking":"199 146 234","color-text-truncated":"247 140 108","color-text-tool-error":"239 83 80"},"mode":"dark"},{"id":"catppuccin-mocha","name":"Catppuccin Mocha","tokens":{"color-bg-primary":"30 30 46","color-bg-secondary":"24 24 37","color-bg-tertiary":"49 50 68","color-primary":"17 17 27","color-secondary":"24 24 37","color-text-primary":"205 214 244","color-text-secondary":"186 194 222","color-text-muted":"108 112 134","color-accent-primary":"137 180 250","color-accent-success":"166 227 161","color-accent-warning":"249 226 175","color-accent-error":"243 139 168","color-border":"69 71 90","color-text-heading":"137 180 250","color-text-bold":"249 226 175","color-text-code":"203 166 247","color-text-link":"137 180 250","color-bg-system":"37 37 54","color-border-system":"69 71 90","color-text-system":"250 179 135","color-text-thinking":"203 166 247","color-text-truncated":"249 226 175","color-text-tool-error":"243 139 168"},"mode":"dark"},{"id":"rose-pine","name":"Rose Pine","tokens":{"color-bg-primary":"25 23 36","color-bg-secondary":"31 29 46","color-bg-tertiary":"38 35 58","color-primary":"20 18 30","color-secondary":"31 29 46","color-text-primary":"224 222 244","color-text-secondary":"196 194 220","color-text-muted":"110 106 134","color-accent-primary":"235 188 186","color-accent-success":"156 207 216","color-accent-warning":"246 193 119","color-accent-error":"235 111 146","color-border":"44 40 67","color-text-heading":"235 188 186","color-text-bold":"246 193 119","color-text-code":"196 167 231","color-text-link":"235 188 186","color-bg-system":"44 38 36","color-border-system":"60 52 50","color-text-system":"246 193 119","color-text-thinking":"196 167 231","color-text-truncated":"246 193 119","color-text-tool-error":"235 111 146"},"mode":"dark"},{"id":"kanagawa-wave","name":"Kanagawa Wave","tokens":{"color-bg-primary":"31 34 44","color-bg-secondary":"25 28 36","color-bg-tertiary":"42 47 58","color-primary":"25 28 36","color-secondary":"25 28 36","color-text-primary":"220 224 206","color-text-secondary":"188 193 178","color-text-muted":"108 112 99","color-accent-primary":"133 189 168","color-accent-success":"157 198 113","color-accent-warning":"226 190 107","color-accent-error":"227 116 102","color-border":"51 59 72","color-text-heading":"133 189 168","color-text-bold":"226 190 107","color-text-code":"194 160 191","color-text-link":"133 189 168","color-bg-system":"42 38 30","color-border-system":"60 54 44","color-text-system":"226 190 107","color-text-thinking":"194 160 191","color-text-truncated":"226 190 107","color-text-tool-error":"227 116 102"},"mode":"dark"},{"id":"light-plus","name":"Light Plus","tokens":{"color-bg-primary":"255 255 255","color-bg-secondary":"243 244 245","color-bg-tertiary":"233 235 238","color-primary":"255 255 255","color-secondary":"243 244 245","color-text-primary":"0 0 0","color-text-secondary":"80 80 80","color-text-muted":"140 140 140","color-accent-primary":"0 92 197","color-accent-success":"0 128 0","color-accent-warning":"178 110 0","color-accent-error":"204 0 0","color-border":"217 217 217","color-text-heading":"0 0 0","color-text-bold":"0 0 0","color-text-code":"204 0 0","color-text-link":"0 92 197","color-bg-system":"255 243 207","color-border-system":"255 220 150","color-text-system":"130 80 0","color-text-thinking":"130 50 180","color-text-truncated":"178 110 0","color-text-tool-error":"204 0 0"},"mode":"light"}]'),_E={tokens:S3,presets:w3},SE=_E.tokens,rr=_E.presets;function N1(){try{const e=localStorage.getItem("openfox:userPresets");if(e)return JSON.parse(e)}catch{}return[]}function C3(){try{const e=localStorage.getItem("openfox:systemThemePrefs");if(e)return JSON.parse(e)}catch{}return{darkPreset:"dark",lightPreset:"light"}}const qt=Jn((e,t)=>{const n=C3();return{currentPreset:"dark",basePreset:"",customTokens:{},isCustom:!1,isCustomizing:!1,userPresets:N1(),followSystemTheme:!0,isSystem:!1,systemDarkPreset:n.darkPreset,systemLightPreset:n.lightPreset,activeUserPresetId:null,applySavedTheme:()=>{const{getSavedTheme:r,applyPreset:a,applyTokens:l}=t(),u=r();if(u)try{const c=JSON.parse(u);c.preset&&c.tokens?(a(c.preset),e({basePreset:c.preset}),l(c.tokens)):c.preset?a(c.preset):c.tokens&&l(c.tokens)}catch{a("dark")}else a("dark")},applyPreset:r=>{if(rr.find(l=>l.id===r))if(r==="system"){const l=window.matchMedia("(prefers-color-scheme: dark)"),{systemDarkPreset:u,systemLightPreset:c,userPresets:d}=t(),h=l.matches?u:c,p=d.find(m=>m.id===h);e(p?{basePreset:"system",currentPreset:p.basePreset,customTokens:{...p.tokens},isCustom:!0,isCustomizing:!1,isSystem:!0,activeUserPresetId:p.id}:{basePreset:"system",currentPreset:h,customTokens:{},isCustom:!1,isCustomizing:!1,isSystem:!0,activeUserPresetId:null}),t().applyTheme()}else e({currentPreset:r,basePreset:"",customTokens:{},isCustom:!1,isCustomizing:!1,isSystem:!1,activeUserPresetId:null}),t().applyTheme()},startCustomizing:()=>{var l;const{currentPreset:r}=t(),a=((l=rr.find(u=>u.id===r))==null?void 0:l.tokens)??{};e({basePreset:r,customTokens:{...a},isCustom:!0,isCustomizing:!0})},setCustomToken:(r,a)=>{e(l=>({customTokens:{...l.customTokens,[r]:a}})),t().applyTheme()},cancelCustomizing:()=>{t().applyPreset(t().basePreset||t().currentPreset)},saveCustomTheme:()=>{const{customTokens:r}=t();t().saveTheme(JSON.stringify({tokens:r})).catch(()=>{}),e({isCustomizing:!1})},applyTokens:r=>{e({customTokens:r,isCustom:!0,isCustomizing:!1}),t().applyTheme()},getActiveTheme:()=>{var c,d;const{basePreset:r,customTokens:a,isCustom:l}=t();if(l&&r)return{...((c=rr.find(p=>p.id===r))==null?void 0:c.tokens)??{},...a};if(l)return{...SE.reduce((h,p)=>({...h,[p.key]:p.defaultValue}),{}),...a};const u=rr.find(h=>h.id===t().currentPreset);return(u==null?void 0:u.tokens)??((d=rr[0])==null?void 0:d.tokens)??{}},applyTheme:()=>{if(typeof document>"u")return;const r=t().getActiveTheme(),a=document.documentElement;Object.entries(r).forEach(([l,u])=>{a.style.setProperty(`--${l}`,u)})},getSavedTheme:()=>{try{const r=localStorage.getItem("openfox:theme");if(!r)return null;if(r[0]!=="{")return JSON.stringify({preset:r});const a=JSON.parse(r);if(a.preset)return JSON.stringify({preset:a.preset});if(a.tokens)return JSON.stringify({tokens:a.tokens})}catch{return null}return null},saveTheme:async r=>{localStorage.setItem("openfox:theme",r);const{useSettingsStore:a}=await te(async()=>{const{useSettingsStore:l}=await Promise.resolve().then(()=>pc);return{useSettingsStore:l}},void 0);await a.getState().setSetting(je.DISPLAY_THEME,r)},clearCustomTheme:()=>{localStorage.removeItem("openfox:theme"),e({isCustom:!1,isCustomizing:!1,basePreset:""})},setFollowSystemTheme:r=>{e({followSystemTheme:r}),te(async()=>{const{useSettingsStore:a,SETTINGS_KEYS:l}=await Promise.resolve().then(()=>pc);return{useSettingsStore:a,SETTINGS_KEYS:l}},void 0).then(({useSettingsStore:a,SETTINGS_KEYS:l})=>{a.getState().setSetting(l.DISPLAY_FOLLOW_SYSTEM_THEME,String(r))})},initSystemThemeListener:()=>{if(typeof window>"u")return()=>{};const r=window.matchMedia("(prefers-color-scheme: dark)"),a=u=>{const{followSystemTheme:c,systemDarkPreset:d,systemLightPreset:h}=t();if(!c)return;const p=u?d:h;t().applyPreset(p),t().saveTheme(JSON.stringify({preset:p}))},l=u=>a(u.matches);return r.addEventListener("change",l),()=>r.removeEventListener("change",l)},reset:()=>{e({currentPreset:"dark",basePreset:"",customTokens:{},isCustom:!1,isCustomizing:!1,userPresets:[],followSystemTheme:!0,systemDarkPreset:"dark",systemLightPreset:"light",activeUserPresetId:null})},addUserPreset:r=>{const{basePreset:a,customTokens:l,currentPreset:u}=t(),c=a||u,d=rr.find(m=>m.id===c),h={id:"custom-"+Date.now(),name:r,basePreset:c,mode:d==null?void 0:d.mode,tokens:{...l}},p=[...t().userPresets,h];e({userPresets:p}),t().saveUserPresets()},applyUserPreset:r=>{const a=t().userPresets[r];a&&(e({currentPreset:a.basePreset,basePreset:a.basePreset,customTokens:{...a.tokens},isCustom:!0,isCustomizing:!1,activeUserPresetId:a.id}),t().applyTheme(),t().saveTheme(JSON.stringify({preset:a.basePreset,tokens:a.tokens})).catch(()=>{}))},deleteUserPreset:r=>{const a=t().userPresets.filter((l,u)=>u!==r);e({userPresets:a}),t().saveUserPresets()},loadUserPresets:()=>{e({userPresets:N1()})},saveUserPresets:()=>{localStorage.setItem("openfox:userPresets",JSON.stringify(t().userPresets)),te(async()=>{const{useSettingsStore:r}=await Promise.resolve().then(()=>pc);return{useSettingsStore:r}},void 0).then(({useSettingsStore:r})=>{r.getState().setSetting(je.DISPLAY_USER_PRESETS,JSON.stringify(t().userPresets)).catch(()=>{})})},setSystemDarkPreset:r=>{e({systemDarkPreset:r}),localStorage.setItem("openfox:systemThemePrefs",JSON.stringify({darkPreset:r,lightPreset:t().systemLightPreset})),te(async()=>{const{useSettingsStore:a,SETTINGS_KEYS:l}=await Promise.resolve().then(()=>pc);return{useSettingsStore:a,SETTINGS_KEYS:l}},void 0).then(({useSettingsStore:a,SETTINGS_KEYS:l})=>{a.getState().setSetting(l.DISPLAY_SYSTEM_THEME_PREFS,JSON.stringify({darkPreset:r,lightPreset:t().systemLightPreset}))}),t().isSystem&&t().applyPreset("system")},setSystemLightPreset:r=>{e({systemLightPreset:r}),localStorage.setItem("openfox:systemThemePrefs",JSON.stringify({darkPreset:t().systemDarkPreset,lightPreset:r})),te(async()=>{const{useSettingsStore:a,SETTINGS_KEYS:l}=await Promise.resolve().then(()=>pc);return{useSettingsStore:a,SETTINGS_KEYS:l}},void 0).then(({useSettingsStore:a,SETTINGS_KEYS:l})=>{a.getState().setSetting(l.DISPLAY_SYSTEM_THEME_PREFS,JSON.stringify({darkPreset:t().systemDarkPreset,lightPreset:r}))}),t().isSystem&&t().applyPreset("system")}}});function k3({canLoad:e,projectId:t,currentProjectId:n}){const r=tn(u=>u.loadProject),a=De(u=>u.listSessions),l=De(u=>u.clearSession);E.useEffect(()=>{e&&t&&(n!==t&&r(t),a(t),l())},[e,t,n,r,a,l])}function E3({canLoad:e,projectId:t,sessionId:n,currentProjectId:r,currentSessionId:a}){const l=De(h=>h.loadSession),u=tn(h=>h.loadProject),c=De(h=>h.listSessions),d=De(h=>h.pendingSessionCreate);E.useEffect(()=>{e&&t&&r!==t&&u(t)},[e,t,r,u]),E.useEffect(()=>{e&&n&&a!==n&&l(n),e&&t&&c(t)},[e,n,a,l,c,d,t])}function j3({className:e="w-5 h-5"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 19l-7-7 7-7"})})}function wE({className:e="w-3.5 h-3.5"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M14 5l7 7m0 0l-7 7m7-7H3"})})}function N3({className:e="w-5 h-5"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15.172 7l-6.586 6.586a2 2 0 102.828 2.828l6.414-6.586a4 4 0 00-5.656-5.656l-6.415 6.585a6 6 0 108.486 8.486L20.5 13"})})}function T3({className:e="w-3 h-3 text-text-muted"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})})}function Fa({className:e="w-4 h-4"}){return s.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:s.jsx("path",{d:"M9.5 3.25a2.25 2.25 0 1 1 3 2.122V6A2.5 2.5 0 0 1 10 8.5H6a1 1 0 0 0-1 1v1.128a2.251 2.251 0 1 1-1.5 0V5.372a2.25 2.25 0 1 1 1.5 0v1.836A2.493 2.493 0 0 1 6 7h4a1 1 0 0 0 1-1v-.628A2.25 2.25 0 0 1 9.5 3.25Zm-6 0a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Zm8.25-.75a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5ZM4.25 12a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Z"})})}function Ls({className:e="w-3.5 h-3.5 text-text-muted"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}function CE({className:e="w-3 h-3 text-text-muted",rotate:t,direction:n="down"}){return s.jsx("svg",{className:e,fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,style:t!==void 0?{transform:`rotate(${t}deg)`}:void 0,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:n==="up"?"M5 15l7-7 7 7":"M19 9l-7 7-7-7"})})}function vn(e){return s.jsx(CE,{direction:"down",...e})}function A3(e){return s.jsx(CE,{direction:"up",...e})}function L3({className:e="w-4 h-4"}){return s.jsxs("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[s.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2",strokeWidth:"2"}),s.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1",strokeWidth:"2"})]})}function Yc({className:e="w-3.5 h-3.5"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"})})}function kE({className:e="w-3 h-3"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"})})}function EE({className:e="w-4 h-4"}){return s.jsxs("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24",children:[s.jsx("circle",{cx:"12",cy:"5",r:"2"}),s.jsx("circle",{cx:"12",cy:"12",r:"2"}),s.jsx("circle",{cx:"12",cy:"19",r:"2"})]})}function My({className:e="w-3.5 h-3.5"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"})})}function Qr({className:e="w-5 h-5 text-accent-primary"}){return s.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{d:"M10 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z"})})}function R3({className:e="w-4 h-4"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 9V4.5M9 9H4.5M9 9L3.75 3.75M9 15v4.5M9 15H4.5M9 15l-5.25 5.25M15 9h4.5M15 9V4.5M15 9l5.25-5.25M15 15h4.5M15 15v4.5m0-4.5l5.25 5.25"})})}function D3({className:e="w-4 h-4"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"})})}function O3({className:e="w-4 h-4"}){return s.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:s.jsx("path",{d:"M8 0a8.2 8.2 0 0 1 .701.031C9.444.095 9.99.645 10.16 1.29l.288 1.107c.018.066.079.158.212.224.231.114.454.243.668.386.123.082.233.09.299.071l1.1-.303c.652-.18 1.37.008 1.755.653a8.043 8.043 0 0 1 .683 1.18c.227.568.096 1.26-.378 1.726l-.812.804a.312.312 0 0 0-.081.283c.024.166.04.335.04.507s-.016.341-.04.507a.312.312 0 0 0 .08.283l.813.804c.474.466.605 1.158.378 1.726a8.07 8.07 0 0 1-.683 1.18c-.385.645-1.103.833-1.755.653l-1.1-.303c-.066-.019-.176-.011-.299.071a5.1 5.1 0 0 1-.668.386c-.133.066-.194.158-.211.224l-.29 1.107c-.168.645-.714 1.196-1.458 1.26a8.094 8.094 0 0 1-1.402 0c-.744-.064-1.29-.615-1.458-1.26l-.29-1.107a.426.426 0 0 0-.211-.224 5.11 5.11 0 0 1-.668-.386c-.123-.082-.233-.09-.299-.071l-1.1.303c-.652.18-1.37-.008-1.755-.653a8.044 8.044 0 0 1-.683-1.18c-.227-.568-.096-1.26.378-1.726l.812-.804a.312.312 0 0 0 .081-.283A5.18 5.18 0 0 1 2.3 8c0-.172.016-.341.04-.507a.312.312 0 0 0-.08-.283l-.813-.804C.973 5.94.842 5.248 1.069 4.68c.181-.452.395-.882.683-1.18.385-.645 1.103-.833 1.755-.653l1.1.303c.066.019.176.011.299-.071.214-.143.437-.272.668-.386a.426.426 0 0 0 .211-.224l.29-1.107C6.009.645 6.556.095 7.299.03 7.53.01 7.764 0 8 0Zm0 5.5a2.5 2.5 0 1 0 0 5 2.5 2.5 0 0 0 0-5Z"})})}function Py({className:e="w-3 h-3"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}function I3({className:e="w-4 h-4"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1"})})}function T1({className:e="w-4 h-4"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 6h16M4 12h16M4 18h16"})})}function jE({className:e="w-[18px] h-[18px]"}){return s.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[s.jsx("circle",{cx:"12",cy:"5",r:"1.5",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"12",cy:"12",r:"1.5",fill:"currentColor",stroke:"none"}),s.jsx("circle",{cx:"12",cy:"19",r:"1.5",fill:"currentColor",stroke:"none"})]})}function NE({className:e="w-4 h-4"}){return s.jsxs("svg",{className:e,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{d:"M6.5 3.5H3a1 1 0 0 0-1 1V13a1 1 0 0 0 1 1h8.5a1 1 0 0 0 1-1V9.5"}),s.jsx("path",{d:"M9.5 2h4.5v4.5"}),s.jsx("path",{d:"M14 2L7.5 8.5"})]})}function TE({className:e="w-3 h-3",color:t}){return s.jsx("svg",{className:e,fill:t??"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{d:"M8 5v14l11-7z"})})}function Ns({className:e="w-3 h-3 text-accent-primary"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})})}function M3({className:e="w-5 h-5"}){return s.jsx("svg",{className:e,viewBox:"0 0 20 20",fill:"currentColor",children:s.jsx("path",{fillRule:"evenodd",d:"M10 3a1 1 0 011 1v5h5a1 1 0 110 2h-5v5a1 1 0 11-2 0v-5H4a1 1 0 110-2h5V4a1 1 0 011-1z",clipRule:"evenodd"})})}function xf({className:e="w-4 h-4"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})})}function AE({className:e="w-4 h-4"}){return s.jsxs("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})}function P3({className:e="w-3 h-3 text-blue-400 animate-spin flex-shrink-0"}){return s.jsxs("svg",{"aria-label":"Session running",className:e,viewBox:"0 0 24 24",fill:"none",children:[s.jsx("title",{children:"Running"}),s.jsx("circle",{className:"opacity-30",cx:"12",cy:"12",r:"9",stroke:"currentColor",strokeWidth:"3"}),s.jsx("path",{d:"M21 12a9 9 0 00-9-9",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round"})]})}function Xc({className:e="w-3.5 h-3.5 text-text-muted"}){return s.jsx("svg",{className:e,fill:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{d:"M10.788 3.21c.448-1.077 1.976-1.077 2.424 0l2.082 5.007 5.404.433c1.164.093 1.636 1.545.749 2.305l-4.117 3.527 1.257 5.273c.271 1.136-.964 2.033-1.96 1.425L12 18.354 7.373 21.18c-.996.608-2.231-.29-1.96-1.425l1.257-5.273-4.117-3.527c-.887-.76-.415-2.212.749-2.305l5.404-.433 2.082-5.006z"})})}function yf({className:e="w-3.5 h-3.5 text-text-muted"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11.049 2.927c.3-.921 1.603-.921 1.902 0l1.519 4.674a1 1 0 00.95.69h4.915c.969 0 1.371 1.24.588 1.81l-3.976 2.888a1 1 0 00-.363 1.118l1.518 4.674c.3.922-.755 1.688-1.538 1.118l-3.976-2.888a1 1 0 00-1.176 0l-3.976 2.888c-.783.57-1.838-.197-1.538-1.118l1.518-4.674a1 1 0 00-.363-1.118l-3.976-2.888c-.784-.57-.38-1.81.588-1.81h4.914a1 1 0 00.951-.69l1.519-4.674z"})})}function By({className:e="w-4 h-4"}){return s.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:s.jsx("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1"})})}function B3({className:e="w-3.5 h-3.5 shrink-0",color:t}){return s.jsx("svg",{className:e,fill:"none",stroke:t,viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"})})}function $3({className:e="w-4 h-4"}){return s.jsxs("svg",{className:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("polyline",{points:"4 17 10 11 4 5"}),s.jsx("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]})}function Ya({className:e="w-3.5 h-3.5"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"})})}function Xi({className:e="w-3.5 h-3.5"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})})}function z3({className:e="w-4 h-4"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}function Tx({className:e="w-2.5 h-2.5"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}function Ji({className:e="w-4 h-4"}){return s.jsx("svg",{className:e,viewBox:"0 0 20 20",fill:"currentColor",children:s.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})}function $y({className:e="w-4 h-4"}){return s.jsx("svg",{className:e,viewBox:"0 0 16 16",fill:"currentColor",children:s.jsx("path",{d:"M4.646 4.646a.5.5 0 0 1 .708 0L8 7.293l2.646-2.647a.5.5 0 0 1 .708.708L8.707 8l2.647 2.646a.5.5 0 0 1-.708.708L8 8.707l-2.646 2.647a.5.5 0 0 1-.708-.708L7.293 8 4.646 5.354a.55.55 0 0 1 0-.708z"})})}function H3({className:e="w-3.5 h-3.5 text-text-muted"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"})})}function F3({className:e="w-3.5 h-3.5 text-text-muted"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z"})})}function A1({className:e="w-3.5 h-3.5 text-text-muted"}){return s.jsx("svg",{className:e,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9.75 17L9 20l-1 1h8l-1-1-.75-3M3 13h18M5 17h14a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"})})}function Ax(){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 L1(e,t){const n=Pt.ws;!n||n.readyState!==WebSocket.OPEN||n.send(JSON.stringify({id:Ax(),type:e,payload:t}))}const is=Jn((e,t)=>({isOpen:!1,sessions:[],workdir:null,setOpen:n=>e({isOpen:n}),toggleOpen:()=>e(n=>({isOpen:!n.isOpen})),setWorkdir:n=>e({workdir:n}),fetchSessions:async n=>{if(!n){e({sessions:[]});return}try{const r=await we(`/api/terminals?projectId=${encodeURIComponent(n)}`);if(r.ok){const a=await r.json();e({sessions:a});const l=Pt.ws;if(l&&l.readyState===WebSocket.OPEN)for(const u of a)l.send(JSON.stringify({id:Ax(),type:"terminal.subscribe",payload:{sessionId:u.id}}))}}catch(r){console.error("Failed to fetch terminals:",r)}},createSession:async(n,r)=>{try{const a=await we("/api/terminals",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workdir:n??t().workdir??void 0,projectId:r})});if(a.ok){const l=await a.json();e(c=>({sessions:[...c.sessions,l]}));const u=Pt.ws;u&&u.readyState===WebSocket.OPEN&&u.send(JSON.stringify({id:Ax(),type:"terminal.subscribe",payload:{sessionId:l.id}}))}}catch(a){console.error("Failed to create terminal:",a)}},writeSession:(n,r)=>{L1("terminal.write",{sessionId:n,data:r})},resizeSession:(n,r,a)=>{L1("terminal.resize",{sessionId:n,cols:r,rows:a})},killSession:async n=>{try{(await we(`/api/terminals/${n}`,{method:"DELETE"})).ok&&e(a=>({sessions:a.sessions.filter(l=>l.id!==n)}))}catch(r){console.error("Failed to kill terminal:",r)}},handleMessage:n=>{switch(n.type){case"terminal.exit":{const{sessionId:r}=n.payload||{};r&&e(a=>{const l=a.sessions.filter(u=>u.id!==r);return l.length===0&&a.isOpen?{sessions:[],isOpen:!1}:{sessions:l}});break}}}}));Pt.subscribe(e=>{var t;(t=e.type)!=null&&t.startsWith("terminal.")&&is.getState().handleMessage(e)});const li=Jn((e,t)=>({status:"idle",current:null,latest:null,check:async n=>{if(!(!n&&t().status==="checking")){e({status:"checking"});try{const r=await fetch(hs(`/api/auto-update/check${n?"?force=true":""}`));if(!r.ok)throw new Error(`HTTP ${r.status}`);const a=await r.json();e({status:a.isUpdateAvailable?"available":"upToDate",current:a.current,latest:a.latest})}catch{e({status:"error"})}}}})),Cs={terminalToggle:{type:"double-press",key:"Control",threshold:300},quickAction:{type:"double-press",key:"Shift",threshold:300},modelSelector:{type:"chord",key:"m",modifiers:["ctrl"]},sessionSearch:{type:"chord",key:"s",modifiers:["ctrl"]},criteriaSidebar:{type:"chord",key:"d",modifiers:["ctrl"]},agentSwitching:[{type:"chord",key:"1",modifiers:["ctrl"]},{type:"chord",key:"2",modifiers:["ctrl"]},{type:"chord",key:"3",modifiers:["ctrl"]},{type:"chord",key:"4",modifiers:["ctrl"]}]};function Lx(e){if(!e)return structuredClone(Cs);try{const t=JSON.parse(e),n=r=>t[r]===void 0?structuredClone(Cs[r]):t[r];return{terminalToggle:n("terminalToggle"),quickAction:n("quickAction"),modelSelector:n("modelSelector"),sessionSearch:n("sessionSearch"),criteriaSidebar:n("criteriaSidebar"),agentSwitching:n("agentSwitching")}}catch{return structuredClone(Cs)}}function R1(e){return e.code.startsWith("Digit")?e.code.slice(-1):/^[a-zA-Z]$/.test(e.key)?e.key.toLowerCase():e.key}function Th(e){if(e.type==="double-press")return`Double ${e.key==="Control"?"Ctrl":e.key==="Shift"?"Shift":e.key==="Alt"?"Alt":e.key==="Meta"?"Meta":e.key}`;const t=e.modifiers.map(r=>{switch(r){case"ctrl":return"Ctrl";case"meta":return"⌘";case"alt":return"Alt";case"shift":return"Shift"}}),n=e.key.length===1?e.key.toUpperCase():e.key;return[...t,n].join("+")}function U3(e){return e.type==="double-press"}function LE(e){return e.type==="chord"}function V3(e,t){return t.length===1&&/^[a-z]$/i.test(t)?e.key.toLowerCase()===t.toLowerCase():t.length===1&&/^[0-9]$/.test(t)?e.code===`Digit${t}`:e.key.toLowerCase()===t.toLowerCase()}function RE(e,t){const n=t.modifiers.includes("ctrl"),r=t.modifiers.includes("meta"),a=t.modifiers.includes("alt"),l=t.modifiers.includes("shift");return V3(e,t.key)&&e.ctrlKey===n&&e.metaKey===r&&e.altKey===a&&e.shiftKey===l}function uu(){const e=Lt(t=>t.settings[je.KEYBINDINGS]);return Lx(e)}function W3(e,t,n){const r=E.useRef(0),a=E.useRef(t);a.current=t,E.useEffect(()=>{if(!e)return;const l=e.threshold??300,u=c=>{if(c.key!==e.key)return;const d=e.key==="Control",h=e.key==="Shift",p=e.key==="Alt",m=e.key==="Meta";if(!d&&c.ctrlKey||!h&&c.shiftKey||!p&&c.altKey||!m&&c.metaKey)return;const g=Date.now();g-r.current<l?(c.preventDefault(),c.stopPropagation(),a.current(),r.current=0):r.current=g};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 G3(e,t){const n=E.useRef(t);n.current=t,E.useEffect(()=>{if(!e)return;const r=a=>{RE(a,e)&&(a.preventDefault(),n.current())};return window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)},[e])}function Qc(e,t,n){W3(e&&U3(e)?e:void 0,t,n),G3(e&&LE(e)?e:void 0,t)}function q3(e,t,n){const r=E.useRef(n);r.current=n,E.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&&LE(c)&&RE(l,c)){l.preventDefault(),r.current(d.id);return}}};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[e,t])}var ui=fk();const bf=E.forwardRef(({icon:e,iconSize:t="w-3.5 h-3.5",className:n="",...r},a)=>s.jsx("button",{ref:a,type:"button",className:`p-1 rounded text-text-muted hover:text-text-primary hover:bg-bg-primary transition-colors ${n}`,...r,children:s.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:e})})}));bf.displayName="IconButton";const K3="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",ci=E.forwardRef((e,t)=>s.jsx(bf,{ref:t,icon:K3,title:"Edit",...e}));ci.displayName="EditButton";const Y3="M6 18L18 6M6 6l12 12",zy=E.forwardRef((e,t)=>s.jsx(bf,{ref:t,icon:Y3,...e}));zy.displayName="CloseButton";const X3={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:r="md",minHeight:a,children:l,footer:u,className:c,onClose:d,isOpen:h,closeOnBackdropClick:p=!0,closeOnEscape:m=!0,showCloseButton:g=!0,scrollable:y=!0}){const[w,C]=E.useState(!1),_=h!==void 0,S=_?h:w,b=E.useCallback(()=>{_||C(!0)},[_]),v=E.useCallback(()=>{_||C(!1),d==null||d()},[_,d]);E.useEffect(()=>{if(!S||!m)return;const T=N=>{if(N.key==="Escape"){const R=document.activeElement;if(R&&(R.tagName==="INPUT"||R.tagName==="TEXTAREA"))return;N.stopPropagation(),v()}};return document.addEventListener("keydown",T),()=>document.removeEventListener("keydown",T)},[S,v,m]);const k=e&&(typeof e=="string"?s.jsx("button",{type:"button",onClick:b,className:c,children:e}):s.jsx("span",{onClick:b,className:c,style:{cursor:"pointer"},children:e}));return s.jsxs(s.Fragment,{children:[k,S&&(typeof document<"u"?ui.createPortal(s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[s.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:p?v:void 0}),s.jsxs("div",{role:"dialog",className:`relative w-full ${X3[r]} max-h-[90vh] bg-bg-secondary border border-border rounded shadow-xl flex flex-col`,children:[(t||n||g)&&s.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[t&&s.jsx("h2",{className:"text-lg font-semibold text-text-primary",children:t}),s.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[n,g&&s.jsx(zy,{onClick:v,"aria-label":"Close"})]})]}),y?s.jsx(ct,{className:"p-4 flex-1 min-h-0",style:a?{minHeight:a}:void 0,children:l}):s.jsx("div",{className:"p-4 flex-1 min-h-0 overflow-hidden flex flex-col",style:a?{minHeight:a}:void 0,children:l}),u&&s.jsx("div",{className:"px-4 py-3 border-t border-border",children:u})]})]}),document.body):null)]})}function Q3({value:e,defaultUrl:t,disabled:n,onChange:r}){const a=e??t;return s.jsxs("div",{className:"relative",children:[s.jsx("select",{value:a,disabled:n,onChange:l=>{const u=l.target.value;r(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:r3.map(({url:l,label:u})=>s.jsx("option",{value:l,title:u,children:u.split(" ")[0]},l))}),s.jsx(vn,{className:"absolute right-0.5 top-1/2 -translate-y-1/2 w-3 h-3 pointer-events-none text-text-muted"})]})}const D1=[{key:"general",label:"General"},{key:"build",label:"Agent"},{key:"sub-agent",label:"Sub-agent"}];function J3(){const e=La(d=>d.settings),t=La(d=>d.update),n=La(d=>d.updateEvent),r=La(d=>d.updateAgentOverride),a=La(d=>d.load);E.useEffect(()=>{a()},[a]);const l=async()=>{await i3()==="granted"&&t({...e,browserNotificationEnabled:!0})},u=(d,h,p,m)=>{d==="general"?n(h,{[p]:m}):r(d,h,{[p]:m})},c=(d,h,p)=>{d==="general"?n(h,{customSoundUrl:p}):r(d,h,{customSoundUrl:p})};return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"space-y-3",children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Master Controls"}),s.jsx(O1,{label:"Sound notifications",description:"Play sounds when events occur",checked:e.soundEnabled,onChange:d=>t({...e,soundEnabled:d})}),s.jsx(O1,{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&&s.jsx("p",{className:"text-xs text-accent-error ml-6",children:"Browser notifications are blocked. Please enable them in your browser settings."})]}),s.jsxs("div",{className:"space-y-3",children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Notification Settings"}),s.jsx("div",{className:"border border-border rounded overflow-hidden",children:s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{className:"sticky top-0 bg-bg-tertiary",children:s.jsxs("tr",{className:"border-b border-border",children:[s.jsx("th",{className:"text-left px-3 py-2 text-text-primary font-medium w-40",children:"Event"}),D1.map(d=>s.jsx("th",{className:"text-center px-2 py-2 text-text-primary font-medium",children:d.label},d.key))]})}),s.jsx("tbody",{children:n3.map(d=>s.jsxs("tr",{className:"border-b border-border last:border-b-0 hover:bg-bg-secondary/50",children:[s.jsx("td",{className:"px-3 py-2",children:s.jsx("div",{className:"text-text-primary text-xs",children:d.label})}),D1.map(h=>{const p=bE(e,d.key,h.key==="general"?void 0:h.key),m=xE[d.key];return s.jsx("td",{className:"px-2 py-2 align-top",children:s.jsxs("div",{className:"flex flex-col items-center gap-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("label",{className:"flex items-center gap-1 text-text-secondary",children:s.jsx("input",{type:"checkbox",checked:p.soundEnabled,onChange:g=>u(h.key,d.key,"soundEnabled",g.target.checked),disabled:!e.soundEnabled,className:"rounded border-border",title:"Sound"})}),s.jsx("label",{className:"flex items-center gap-1 text-text-secondary",children:s.jsx("input",{type:"checkbox",checked:p.browserNotification,onChange:g=>u(h.key,d.key,"browserNotification",g.target.checked),disabled:!e.browserNotificationEnabled,className:"rounded border-border",title:"Browser"})})]}),p.soundEnabled&&e.soundEnabled&&s.jsx(Q3,{value:p.customSoundUrl,defaultUrl:m,disabled:!e.soundEnabled,onChange:g=>c(h.key,d.key,g)})]})},h.key)})]},d.key))})]})})]})]})}function O1({label:e,description:t,checked:n,onChange:r}){return s.jsxs("label",{className:"flex items-start justify-between gap-3 cursor-pointer group",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-text-primary group-hover:text-accent-primary transition-colors",children:e}),s.jsx("div",{className:"text-xs text-text-muted mt-0.5",children:t})]}),s.jsx("div",{className:"flex-shrink-0 pt-0.5",children:s.jsx("div",{className:`relative w-9 h-5 rounded-full transition-colors ${n?"bg-accent-primary":"bg-bg-tertiary border border-border"}`,onClick:a=>{a.preventDefault(),r(!n)},children:s.jsx("div",{className:`absolute top-0.5 w-4 h-4 rounded-full bg-white shadow transition-transform ${n?"translate-x-4":"translate-x-0.5"}`})})})]})}const dt=E.forwardRef(({variant:e="secondary",size:t="md",className:n="",children:r,...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 s.jsx("button",{ref:l,className:`${u} ${c[e]} ${d[t]} ${n}`,...a,children:r})});dt.displayName="Button";async function I1(e,t,n){try{const r=await we(e,t);return r.ok?(await n(),{success:!0}):{success:!1,error:(await r.json()).error}}catch{return{success:!1,error:"Network error"}}}function Sa(e,t){return t?`${e}?workdir=${encodeURIComponent(t)}`:e}const $n=Jn((e,t)=>({defaults:[],userItems:[],projectItems:[],items:[],selectedDirectory:null,diagnostics:[],loading:!1,workdir:null,setWorkdir:n=>{e({workdir:n})},fetchSkills:async n=>{const r=n??t().workdir;e({loading:!0});try{const l=await(await we(Sa("/api/skills",r))).json();e({defaults:l.defaults??[],userItems:l.userItems??[],projectItems:l.projectItems??[],items:l.items??[],selectedDirectory:l.selectedDirectory??null,diagnostics:l.diagnostics??[],loading:!1})}catch{e({loading:!1})}},toggleSkill:async n=>{try{const a=await(await we(Sa(`/api/skills/${n}/toggle`,t().workdir),{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 r=await we(Sa(`/api/skills/${n}`,t().workdir));return r.ok?await r.json():null}catch{return null}},fetchDefaultContent:async n=>{try{const r=await we(`/api/skills/defaults/${n}`);return r.ok?await r.json():null}catch{return null}},createSkill:async(n,r)=>{const a=await Yi("POST",Sa("/api/skills",t().workdir),{...n,destination:r});return a.success&&await t().fetchSkills(),a},updateSkill:async(n,r)=>{const a=await Yi("PUT",Sa(`/api/skills/${n}`,t().workdir),r);return a.success&&await t().fetchSkills(),a},deleteSkill:async n=>{try{const r=await we(Sa(`/api/skills/${n}`,t().workdir),{method:"DELETE"}),a=await r.json();return r.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,r)=>pf(Sa(`/api/skills/${n}/duplicate`,t().workdir),()=>t().fetchSkills(),r),selectDirectory:async n=>I1("/api/skills/library",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n})},t().fetchSkills),removeDirectory:async()=>{await we("/api/skills/library",{method:"DELETE"}),await t().fetchSkills()},installSkill:async n=>{const r=new FormData;r.append("packageName",n.packageName),r.append("paths",JSON.stringify(n.files.map(a=>a.path)));for(const a of n.files)r.append("files",a.file,a.file.name);return I1("/api/skills/install",{method:"POST",body:r},t().fetchSkills)}}));function du(){const[e,t]=E.useState({id:null,type:null}),n=E.useCallback(l=>t({id:l,type:"delete"}),[]),r=E.useCallback(()=>t({id:null,type:null}),[]),a=E.useCallback((l,u)=>e.id===l&&e.type===u,[e.id,e.type]);return{requestDelete:n,clearConfirm:r,isConfirming:a}}function Ah({onConfirm:e,onCancel:t}){return s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{onClick:e,className:"px-1.5 py-0.5 rounded text-xs hover:opacity-90 transition-colors bg-accent-error/20 text-accent-error hover:bg-accent-error/30",children:"Delete"}),s.jsx("button",{onClick:t,className:"px-1.5 py-0.5 rounded text-text-muted text-xs hover:bg-bg-primary transition-colors",children:"Cancel"})]})}function Lh({onClick:e}){return s.jsx("button",{onClick:e,className:"p-1.5 rounded hover:bg-bg-primary text-text-muted hover:text-accent-error transition-colors",title:"Delete",children:s.jsx(Ya,{})})}function Jc({onClick:e}){return s.jsx("button",{onClick:e,className:"p-1.5 rounded hover:bg-bg-primary text-text-muted hover:text-text-primary transition-colors",title:"Duplicate",children:s.jsx(Yc,{})})}function Yr({label:e,value:t,onChange:n,placeholder:r,readOnly:a,hint:l,mono:u}){return s.jsxs("div",{children:[s.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:[e,l&&s.jsx("span",{className:"text-text-muted ml-1",children:l})]}),s.jsx("input",{value:t,onChange:c=>n(c.target.value),readOnly:a,placeholder:r,className:`w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary ${u?"font-mono":""} ${a?"opacity-60":""}`})]})}function DE({onCancel:e,onSave:t,saving:n,saveDisabled:r}){return s.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[s.jsx(dt,{variant:"secondary",onClick:e,children:"Cancel"}),s.jsx(dt,{variant:"primary",onClick:t,disabled:n||r,children:n?"Saving...":"Save"})]})}function nl({message:e}){return s.jsx("div",{className:"text-accent-error text-sm px-3 py-2 bg-accent-error/10 rounded",children:e})}function vf({value:e,onChange:t}){return s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("label",{className:"text-xs text-text-secondary",children:"Save to:"}),s.jsxs("select",{value:e,onChange:n=>t(n.target.value),className:"px-2 py-1 bg-bg-tertiary border border-border rounded text-xs focus:outline-none focus:ring-1 focus:ring-accent-primary",children:[s.jsx("option",{value:"user",children:"Global config"}),s.jsx("option",{value:"project",children:"Project (.openfox/)"})]})]})}function OE({description:e,onNew:t,loading:n,hasItems:r,children:a}){return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsx("p",{className:"text-text-secondary text-sm",children:e}),s.jsx("div",{className:"flex items-center gap-2 flex-shrink-0 ml-3",children:s.jsx(dt,{variant:"primary",size:"sm",onClick:t,children:"+ New"})})]}),n&&!r?s.jsx("div",{className:"text-text-muted text-sm",children:"Loading..."}):r?a:s.jsx("div",{className:"text-text-muted text-sm",children:"No items defined."})]})}function IE({label:e="Custom",children:t}){return s.jsxs("div",{children:[s.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:e}),s.jsx("div",{className:"space-y-2",children:t})]})}function ME({description:e,onNew:t,newLabel:n="+ New"}){return s.jsxs("div",{className:"flex items-center justify-between mb-4",children:[s.jsx("p",{className:"text-text-secondary text-sm",children:e}),s.jsx("div",{className:"flex items-center gap-2 flex-shrink-0 ml-3",children:s.jsx(dt,{variant:"primary",size:"sm",onClick:t,children:n})})]})}function Hy({loading:e,hasItems:t,loadingLabel:n,emptyLabel:r,children:a}){return e&&!t?s.jsx("div",{className:"text-text-muted text-sm",children:n}):t?s.jsx("div",{className:"space-y-4",children:a}):r?s.jsx("div",{className:"text-text-muted text-sm",children:r}):null}function PE({name:e,id:t,nameLabel:n="Name",idLabel:r="ID",namePlaceholder:a="My Item",idPlaceholder:l="my-item",nameHint:u,readOnlyId:c=!1,readOnlyHint:d="(read-only)",onNameChange:h,onIdChange:p}){return s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsx(Yr,{label:n,value:e,onChange:h,placeholder:a,hint:u}),s.jsx(Yr,{label:r,value:t,onChange:p,readOnly:c,placeholder:l,hint:c?d:void 0,mono:!0})]})}function BE(e={}){const{initialData:t={}}=e,[n,r]=E.useState("list"),[a,l]=E.useState(null),[u,c]=E.useState(""),[d,h]=E.useState(!1),[p,m]=E.useState(t),g=E.useCallback(()=>{m(t),c(""),l(null)},[t]),y=E.useCallback(S=>{r(S),S==="list"&&g()},[g]),w=E.useCallback(S=>{m(b=>typeof S=="function"?S(b):S)},[]),C=E.useCallback((S,b={})=>{l(S),r("edit"),m({...b}),c("")},[]),_=E.useCallback(()=>{l(null),r("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:h,resetForm:g,startEditing:C,startNew:_}}function Zc({isOpen:e,onClose:t,onConfirm:n,title:r,message:a,confirmLabel:l="Confirm",confirmVariant:u="primary",disabled:c=!1}){return s.jsx(jt,{isOpen:e,onClose:t,title:r,size:"sm",children:s.jsxs("div",{className:"space-y-4",children:[s.jsx("div",{className:"text-text-secondary",children:a}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(dt,{variant:"secondary",onClick:t,disabled:c,children:"Cancel"}),s.jsx(dt,{variant:u,onClick:n,disabled:c,autoFocus:!0,children:l})]})]})})}const Z3={sm:"w-4 h-4",md:"w-8 h-8",lg:"w-12 h-12"};function Zi({size:e="md",className:t=""}){return s.jsx("div",{className:`animate-spin border-2 border-accent-primary border-t-transparent rounded-full ${Z3[e]} ${t}`})}function e5({text:e,...t}){return s.jsxs("div",{className:"text-center",children:[s.jsx(Zi,{...t,className:"mx-auto mb-4"}),e&&s.jsx("div",{className:"text-text-secondary",children:e})]})}function hu(e){return e.split(/[\\/]/).filter(Boolean).pop()??""}function t5(e){const t=e.includes("\\")?"\\":"/";return e.split(/[\\/]/).filter(Boolean).map((n,r,a)=>({name:n,path:t==="/"?"/"+a.slice(0,r+1).join("/"):a.slice(0,r+1).join("\\")+(r===0?"\\":"")}))}function $E(e,t=28){if(e.length<=t)return e;const n=e.includes("\\")?"\\":"/",r=e.split(/[\\/]/).filter(Boolean);if(r.length<=2)return e;const a=r[0],l=r[r.length-1],u=r.slice(1,-1).join(n),c=t-a.length-l.length-3;if(c<0)return e;const d=u.slice(0,Math.floor(c/2)),h=u.slice(-Math.ceil(c/2));return`${e.startsWith(n)?n:""}${a}${n}${d}...${h}${n}${l}`}function Bt(){return typeof window>"u"||typeof window.matchMedia!="function"?!0:!window.matchMedia("(hover: none) and (pointer: coarse)").matches}const Gi=E.forwardRef(({className:e="",...t},n)=>s.jsx("input",{ref:n,className:`bg-bg-tertiary border border-border rounded px-3 py-2 text-text-primary placeholder-text-muted focus:outline-none focus:ring-2 focus:ring-accent-primary/50 focus:border-accent-primary ${e}`,...t}));Gi.displayName="Input";function _f({onSelect:e,onClose:t,initialPath:n}){const[r,a]=E.useState(null),[l,u]=E.useState(!0),[c,d]=E.useState(""),[h,p]=E.useState(-1),m=E.useRef(null),g=E.useRef(null),y=E.useCallback(async v=>{u(!0),d(""),p(-1);try{const k=v?`/api/directories?path=${encodeURIComponent(v)}`:"/api/directories",N=await(await we(k)).json();a(N)}catch(k){console.error("Failed to load directories:",k)}finally{u(!1)}},[]);E.useEffect(()=>{y(n)},[n,y]);const w=t5((r==null?void 0:r.current)??""),C=(r==null?void 0:r.directories.filter(v=>c===""||v.name.toLowerCase().includes(c.toLowerCase())))??[],_=[...!c&&(r!=null&&r.parent)?[{type:"parent",path:r.parent,name:".."}]:[],...C.map(v=>({type:"dir",path:v.path,name:v.name}))];E.useEffect(()=>{p(c?0:-1)},[c,C.length]),E.useEffect(()=>{if(h>=0&&g.current){const v=g.current.querySelector(`[data-index="${h}"]`);v==null||v.scrollIntoView({block:"nearest"})}},[h]);const S=v=>{var k;if(v.key==="ArrowDown")v.preventDefault(),p(T=>Math.min(T+1,_.length-1));else if(v.key==="ArrowUp")v.preventDefault(),p(T=>Math.max(T-1,0));else if(v.key==="Enter"){if(h<0||!_[h]||v.target instanceof HTMLElement&&v.target.dataset.select==="true")return;v.preventDefault(),v.shiftKey?y(_[h].path):e(_[h].path)}else v.key==="Escape"&&(d(""),Bt()&&((k=m.current)==null||k.focus()))},b=s.jsx("div",{className:"flex flex-col gap-2",children:s.jsx("button",{onClick:t,className:"w-full text-center text-text-muted hover:text-text-secondary text-sm",children:"Cancel"})});return s.jsx(jt,{isOpen:!0,onClose:t,title:"Select Folder",size:"lg",footer:b,scrollable:!1,children:s.jsxs("div",{ref:g,className:"flex flex-col flex-1 min-h-0 -m-4",onKeyDown:S,children:[s.jsxs("div",{className:"flex-shrink-0 bg-bg-secondary border-b border-border",children:[r&&s.jsx("div",{className:"px-3 pt-3 pb-1",children:s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsxs("div",{className:"flex items-center flex-wrap min-w-0",children:[w.map((v,k)=>s.jsxs("span",{className:"flex items-center shrink-0",children:[s.jsx("span",{className:"text-text-muted",children:"/"}),s.jsx("button",{onClick:()=>y(v.path),className:`px-1 ${k===w.length-1?"text-accent-primary font-medium":"text-text-secondary hover:text-accent-primary"}`,children:v.name})]},v.path)),w.length===0&&s.jsx("button",{onClick:()=>y("/"),className:"text-text-muted hover:text-accent-primary",children:"/"})]}),(r==null?void 0:r.current)&&s.jsx("button",{onClick:()=>e(r.current),className:"ml-auto shrink-0 px-4 py-2 text-sm font-medium rounded-lg bg-accent-primary text-text-primary hover:bg-accent-primary/90",children:"Select"})]})}),s.jsx("div",{className:"px-4 py-2",children:s.jsxs("div",{className:"relative",children:[s.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-text-muted pointer-events-none flex items-center justify-center",children:s.jsx(Xi,{})}),s.jsx(Gi,{autoFocus:Bt(),ref:m,value:c,onChange:v=>d(v.target.value),placeholder:"Filter directories...",className:"w-full pl-9"})]})})]}),s.jsx(ct,{className:"flex-1",children:l?s.jsx("div",{className:"p-8 text-center",children:s.jsx(Zi,{size:"sm"})}):_.length===0?s.jsx("div",{className:"p-8 text-center text-text-muted text-sm",children:c?"No matching directories":"No subdirectories"}):s.jsx("div",{className:"divide-y divide-border",children:_.map((v,k)=>s.jsxs("div",{"data-index":k,className:`group flex items-center ${k===h?"bg-accent-primary/20":"hover:bg-bg-tertiary/50"}`,children:[s.jsxs("button",{onClick:()=>{y(v.path)},className:"flex-1 flex items-center gap-3 p-3 text-left min-w-0",tabIndex:-1,children:[v.type==="parent"?s.jsx(j3,{className:"w-5 h-5 text-text-muted shrink-0"}):s.jsx(Qr,{className:"w-5 h-5 shrink-0"}),s.jsx("span",{className:"truncate",children:v.name}),v.type==="dir"&&s.jsx(vn,{className:`w-5 h-5 text-text-muted shrink-0 ml-1 ${k===h?"opacity-100":"opacity-0 group-hover:opacity-100"}`,rotate:-90})]}),v.type==="dir"&&s.jsx("button",{"data-select":"true",tabIndex:k===h?0:-1,onClick:T=>{T.stopPropagation(),e(v.path)},className:`mr-2 shrink-0 px-4 py-2 text-sm font-medium rounded-lg bg-accent-primary text-text-primary hover:bg-accent-primary/90 ${k===h?"opacity-100":"opacity-0 group-hover:opacity-100"}`,"aria-label":`Select ${v.name}`,children:"Select"})]},v.path))})})]})})}function zE(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 n5(e){const t=[...e];if(!t.length)throw new Error("Choose one skill folder.");const n=new Set(t.map(a=>a.webkitRelativePath.split("/")[0]).filter(Boolean));if(n.size!==1)throw new Error("Choose exactly one skill folder.");const r=[...n][0];return zE(r,t.map(a=>({path:a.webkitRelativePath.slice(r.length+1),file:a})))}function r5(e){return new Promise((t,n)=>e.file(t,n))}async function HE(e,t=""){const n=e.createReader(),r=[];for(;;){const l=await new Promise((u,c)=>n.readEntries(u,c));if(!l.length)break;r.push(...l)}return(await Promise.all(r.map(async l=>{const u=t?`${t}/${l.name}`:l.name;return l.isDirectory?HE(l,u):[{path:u,file:await r5(l)}]}))).flat()}async function s5(e){const t=[...e.items].filter(r=>r.kind==="file").map(r=>{var a;return((a=r.webkitGetAsEntry)==null?void 0:a.call(r))??null}).filter(r=>!!r);if(t.length!==1||!t[0].isDirectory)throw new Error("Drop exactly one skill folder.");const n=t[0];return zE(n.name,await HE(n))}function i5({selectedDirectory:e,onSelect:t,onRemove:n,onRefresh:r,onInstall:a}){const[l,u]=E.useState(!1),[c,d]=E.useState(!1),[h,p]=E.useState(""),[m,g]=E.useState(null),[y,w]=E.useState(!1),C=E.useRef(null);E.useEffect(()=>{var k;(k=C.current)==null||k.setAttribute("webkitdirectory","")},[]);const _=k=>{g(k)},S=async()=>{if(!m||y)return;w(!0);const k=await t(m);if(k&&!k.success){p(k.error??"Cannot use selected folder."),w(!1);return}g(null),u(!1),w(!1)},b=async k=>{d(!0),p("");const T=await a(k);d(!1),T.success||p(T.error??"Failed to install skill package.")},v=async k=>{if(k.preventDefault(),!(!(e!=null&&e.available)||c))try{await b(await s5(k.dataTransfer))}catch(T){p(T instanceof Error?T.message:"Invalid skill folder.")}};return s.jsxs("section",{className:"mb-4 rounded border border-border bg-bg-tertiary/30 p-3",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Skills folder"}),s.jsx("p",{className:"mt-1 truncate text-xs text-text-muted",children:(e==null?void 0:e.configuredPath)??"No shared folder selected"})]}),s.jsxs("div",{className:"flex shrink-0 gap-2",children:[s.jsx(dt,{variant:"secondary",onClick:()=>u(!0),children:"Change folder"}),e&&s.jsxs(s.Fragment,{children:[s.jsx(dt,{variant:"secondary",onClick:r,children:"Refresh"}),e.custom&&s.jsx(dt,{variant:"secondary",onClick:n,children:"Use default"})]})]})]}),s.jsx("button",{type:"button",disabled:!(e!=null&&e.available)||c,onClick:()=>{var k;return(k=C.current)==null?void 0:k.click()},onDragOver:k=>k.preventDefault(),onDrop:v,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."}),s.jsx("input",{ref:C,hidden:!0,type:"file",multiple:!0,onChange:k=>{var T;if((T=k.target.files)!=null&&T.length)try{b(n5(k.target.files))}catch(N){p(N instanceof Error?N.message:"Invalid skill folder.")}finally{k.target.value=""}}}),h&&s.jsx("p",{className:"mt-2 text-xs text-error",children:h}),l&&s.jsx(_f,{initialPath:(e==null?void 0:e.resolvedPath)??void 0,onSelect:_,onClose:()=>u(!1)}),s.jsx(Zc,{isOpen:m!==null,onClose:()=>g(null),onConfirm:S,title:"Trust this folder?",message:"Skills may contain instructions and scripts. Select this folder for discovery without executing package content?",confirmLabel:"Trust folder",disabled:y})]})}function cs({enabled:e,onClick:t,label:n,disabled:r}){return s.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-label":n,onClick:r?void 0:t,className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors ${e?"bg-accent-primary":"bg-bg-tertiary"} ${r?"opacity-50 cursor-not-allowed":"cursor-pointer"}`,children:s.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${e?"translate-x-6":"translate-x-1"}`})})}function FE({isBuiltIn:e,isConfirmingDelete:t,onView:n,onEdit:r,onDuplicate:a,onDelete:l,onCancelDelete:u,actions:c,children:d}){return s.jsxs("div",{className:"flex items-center justify-between p-3 rounded border border-border bg-bg-tertiary",children:[s.jsx("div",{className:"min-w-0 flex-1 mr-3",children:d}),s.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[e&&r&&s.jsx(ci,{onClick:r}),e&&!r&&n&&s.jsx("button",{onClick:n,className:"p-1.5 rounded text-text-muted hover:text-text-primary hover:bg-bg-primary transition-colors",title:"View",children:s.jsx(My,{})}),s.jsx(Jc,{onClick:a}),!e&&r&&s.jsx(ci,{onClick:r}),!e&&l&&(t?s.jsx(Ah,{onConfirm:()=>{l==null||l()},onCancel:()=>u==null?void 0:u()}):s.jsx(Lh,{onClick:()=>l==null?void 0:l()})),c]})]})}function a5({id:e,name:t,description:n,isBuiltIn:r,isConfirmingDelete:a,onView:l,onEdit:u,onDuplicate:c,onDelete:d,onCancelDelete:h,actions:p}){return s.jsxs(FE,{isBuiltIn:r,isConfirmingDelete:a,onView:l,onEdit:u,onDuplicate:c,onDelete:d,onCancelDelete:h,actions:p,children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-text-primary text-sm font-medium",children:t}),s.jsx("span",{className:"text-text-muted text-xs font-mono",children:e})]}),n&&s.jsx("p",{className:"text-text-muted text-xs truncate",children:n})]})}function M1({skill:e,isBuiltIn:t,isConfirmingDelete:n,onView:r,onEdit:a,onDuplicate:l,onDelete:u,onToggle:c,readOnly:d=!1}){return s.jsx(a5,{id:e.id,name:e.name,description:e.description,isBuiltIn:t,isConfirmingDelete:n,onView:r,onEdit:d?void 0:a,onDuplicate:l,onDelete:d?void 0:u,actions:s.jsx(cs,{enabled:e.enabled,onClick:c,label:`Activation for ${e.name}`})})}function o5({skill:e,deleting:t,error:n,onClose:r,onConfirm:a}){return s.jsxs(jt,{isOpen:e!==null,onClose:r,title:"Delete skill?",size:"sm",closeOnBackdropClick:!t,closeOnEscape:!t,footer:s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(dt,{variant:"secondary",onClick:r,disabled:t,children:"Cancel"}),s.jsx(dt,{variant:"danger",onClick:a,disabled:t,children:t?"Deleting...":"Delete skill"})]}),children:[s.jsx("p",{className:"text-sm font-medium text-text-primary",children:"This skill files will be deleted."}),s.jsx("p",{className:"mt-2 text-sm text-text-secondary",children:"The full skill folder and all its contents will be removed."}),e&&s.jsx("p",{className:"mt-3 break-all font-mono text-xs text-text-muted",children:e.path}),n&&s.jsx("p",{className:"mt-3 text-sm text-error",children:n})]})}function l5({isOpen:e}){const t=$n(re=>re.defaults),n=$n(re=>re.userItems),r=$n(re=>re.projectItems),a=$n(re=>re.items),l=$n(re=>re.selectedDirectory),u=$n(re=>re.diagnostics),c=$n(re=>re.loading),d=$n(re=>re.fetchSkills),h=$n(re=>re.setWorkdir),p=$n(re=>re.fetchSkill),m=$n(re=>re.fetchDefaultContent),g=$n(re=>re.createSkill),y=$n(re=>re.updateSkill),w=$n(re=>re.deleteSkill),C=$n(re=>re.selectDirectory),_=$n(re=>re.removeDirectory),S=$n(re=>re.installSkill),b=$n(re=>re.toggleSkill),v=De(re=>re.currentSession),[k,T]=E.useState(null),[N,R]=E.useState(!1),[A,O]=E.useState(""),{view:P,editingId:V,formError:z,saving:W,formData:M,setView:U,setEditingId:F,setFormError:Q,setFormData:X,setSaving:H}=BE(),{clearConfirm:I}=du();E.useEffect(()=>{if(e){const re=(v==null?void 0:v.workspace)??(v==null?void 0:v.workdir)??null;h(re),d(re),U("list"),F(null),I()}},[e,d,h,I,v==null?void 0:v.workdir,v==null?void 0:v.workspace]);const D=(re,oe,ve,Se)=>{X({name:Se??re.metadata.name,id:ve??re.metadata.id,description:re.metadata.description??"",version:re.metadata.version??"1.0.0",prompt:re.prompt,isReadOnly:oe,destination:"user"})},q=async re=>{if(t.some(ve=>ve.id===re)){const ve=await m(re);if(!ve)return;D(ve,!0),F(re),Q(""),U("edit")}else{const ve=await p(re);if(!ve)return;D(ve,!0),F(re),Q(""),U("edit")}},$=async re=>{const ve=t.some($e=>$e.id===re)?await m(re):await p(re);if(!ve)return;const Se=`${re}-copy-${Date.now()}`;D(ve,!1,Se,`${ve.metadata.name} (copy)`),F(null),Q(""),U("edit")},J=()=>{X({name:"",id:"",description:"",version:"1.0.0",prompt:"",isReadOnly:!1,destination:"user"}),U("edit")},Y=async re=>{const oe=await p(re);oe&&(D(oe,!1),F(re),Q(""),U("edit"))},Z=async()=>{if(!k)return;R(!0),O("");const re=await w(k.id);if(R(!1),!re.success){O(re.error??"Failed to delete skill.");return}await d(),T(null),I()},K=async()=>{const re=V??M.id;if(!re||!M.name||!M.prompt){Q("Name, ID, and prompt are required.");return}H(!0),Q("");const oe={metadata:{id:re,name:M.name,description:M.description,version:M.version},prompt:M.prompt},ve=V?await y(V,oe):await g(oe,M.destination);if(H(!1),!ve.success){Q(ve.error??"Failed to save skill.");return}U("list")},B=re=>{X(oe=>({...oe,name:re})),V||X(oe=>({...oe,id:re.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}))},ne=M.isReadOnly;if(P==="edit")return s.jsxs("div",{className:"flex flex-col h-full",children:[s.jsxs("div",{className:"flex justify-between items-center mb-3",children:[s.jsx("h2",{className:"text-lg font-semibold text-text-primary",children:ne?M.name:V?"Edit Skill":"New Skill"}),s.jsx("button",{onClick:()=>U("list"),className:"text-text-muted hover:text-text-primary",children:"Cancel"})]}),z&&s.jsx(nl,{message:z}),s.jsxs("div",{className:"space-y-3 mb-3",children:[s.jsx(PE,{name:M.name,id:M.id,nameLabel:"Name",idLabel:"ID",namePlaceholder:"My Skill",idPlaceholder:"my-skill",readOnlyId:!0,onNameChange:B,onIdChange:()=>{}}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsx(Yr,{label:"Description",value:M.description,onChange:re=>X(oe=>({...oe,description:re})),placeholder:"What this skill does...",readOnly:ne}),s.jsx(Yr,{label:"Version",value:M.version,onChange:re=>X(oe=>({...oe,version:re})),placeholder:"1.0.0",readOnly:ne})]})]}),s.jsxs("div",{className:"flex-1 min-h-[120px] border-t border-border pt-3 flex flex-col",children:[s.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Prompt"}),s.jsx("textarea",{value:M.prompt,onChange:re=>X(oe=>({...oe,prompt:re.target.value})),readOnly:ne,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"})]}),!V&&s.jsx(vf,{value:M.destination,onChange:re=>X(oe=>({...oe,destination:re}))}),s.jsxs("div",{className:"flex justify-end gap-2 pt-3 border-t border-border flex-shrink-0",children:[s.jsx(dt,{variant:"secondary",onClick:()=>U("list"),children:"Cancel"}),ne?s.jsx(dt,{variant:"primary",onClick:()=>{X(re=>({...re,name:re.name+" (copy)",id:`${V}-copy-${Date.now()}`,isReadOnly:!1})),F(null)},children:"Duplicate & Customize"}):s.jsx(dt,{variant:"primary",onClick:K,disabled:W||!M.name||!M.id||!M.prompt,children:W?"Saving...":"Save"})]})]});function se({items:re}){return re.map(oe=>s.jsx(M1,{skill:oe,isBuiltIn:!1,isConfirmingDelete:!1,onView:()=>q(oe.id),onEdit:()=>Y(oe.id),onDuplicate:()=>$(oe.id),onDelete:()=>{O(""),T(oe)},onToggle:()=>b(oe.id),readOnly:oe.readOnly},oe.id))}return s.jsxs("div",{children:[s.jsx(o5,{skill:k,deleting:N,error:A,onClose:()=>{N||T(null)},onConfirm:Z}),s.jsx(i5,{selectedDirectory:l,onSelect:C,onRemove:_,onRefresh:d,onInstall:S}),u.length>0&&s.jsx("div",{className:"mb-3 rounded border border-accent-warning/40 bg-accent-warning/10 p-2 text-xs text-text-secondary",children:u.map((re,oe)=>s.jsx("p",{children:re},`${re}-${oe}`))}),s.jsx(ME,{description:"Skills provide domain-specific knowledge that agents can load on demand.",onNew:J}),s.jsxs(Hy,{loading:c,hasItems:t.length>0||n.length>0,loadingLabel:"Loading skills...",emptyLabel:"No skills created yet.",children:[t.length>0&&s.jsxs("div",{children:[s.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Built-in"}),s.jsx("div",{className:"space-y-2",children:t.map(re=>s.jsx(M1,{skill:re,isBuiltIn:!0,isConfirmingDelete:!1,onView:()=>q(re.id),onDuplicate:()=>$(re.id),onToggle:()=>b(re.id)},re.id))})]}),n.length>0&&s.jsx(IE,{children:s.jsx(se,{items:n})}),a.some(re=>["global-shared","selected","project-shared"].includes(re.source))&&s.jsxs("div",{className:"mt-4",children:[s.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Shared"}),s.jsx("div",{className:"space-y-2",children:s.jsx(se,{items:a.filter(re=>["global-shared","selected","project-shared"].includes(re.source))})})]}),r.length>0&&s.jsxs("div",{className:"mt-4",children:[s.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Project"}),s.jsx("div",{className:"space-y-2",children:s.jsx(se,{items:r})})]})]})]})}function ea(){const e=Lt(a=>a.settings),t=Lt(a=>a.loading),n=Lt(a=>a.getSetting),r=Lt(a=>a.setSetting);return{settings:e,loading:t,getSetting:n,setSetting:r}}function c5({isOpen:e}){const{settings:t,loading:n,getSetting:r,setSetting:a}=ea(),l=t[je.GLOBAL_INSTRUCTIONS]??"",u=n[je.GLOBAL_INSTRUCTIONS]??!1,[c,d]=E.useState(l),[h,p]=E.useState(!1),[m,g]=E.useState(!1);E.useEffect(()=>{e&&r(je.GLOBAL_INSTRUCTIONS)},[e,r]),E.useEffect(()=>{d(l),p(!1)},[l]);const y=async()=>{g(!0),await a(je.GLOBAL_INSTRUCTIONS,c),g(!1),p(!1)},w=()=>{d(l),p(!1)},C=u||m;return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-text-primary mb-2",children:"Global Instructions"}),s.jsx("p",{className:"text-sm text-text-muted mb-2",children:"These instructions are injected into every prompt, regardless of project."}),s.jsx("textarea",{value:c,onChange:_=>{d(_.target.value),p(!0)},placeholder:"Enter global instructions that apply to all projects...",className:"w-full min-h-80 px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono resize-y focus:outline-none focus:ring-1 focus:ring-accent-primary",disabled:C})]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(dt,{variant:"secondary",onClick:w,disabled:!h,children:"Discard"}),s.jsx(dt,{variant:"primary",onClick:y,disabled:!h||C,children:m?"Saving...":"Save"})]})]})}function u5(e){const t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);if(t){const n=parseInt(t[1]??"0",16),r=parseInt(t[2]??"0",16),a=parseInt(t[3]??"0",16);return`${n} ${r} ${a}`}return e}function gh(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 d5({isOpen:e,isNew:t,basePresetId:n,presetName:r,mode:a,initialTokens:l,onClose:u,onSave:c}){const[d,h]=E.useState(l),[p,m]=E.useState(r),[g,y]=E.useState(a);E.useEffect(()=>{h(l),m(r)},[l,r]);const w=(v,k)=>{const T=k.startsWith("#")?u5(k):k;h(N=>({...N,[v]:T}))},C=()=>{c(p.trim()||"Untitled",{...d},g)},_=SE.reduce((v,k)=>{const T=k.category;return v[T]||(v[T]=[]),v[T].push(k),v},{}),S={background:"Backgrounds",surface:"Surfaces",text:"Text",accent:"Accents",border:"Border"},b=rr.find(v=>v.id===n);return s.jsx(jt,{isOpen:e,onClose:u,size:"lg",title:t?"New Theme":"Edit Theme",closeOnBackdropClick:!0,closeOnEscape:!0,footer:s.jsxs("div",{className:"flex gap-2 justify-end",children:[s.jsx("button",{type:"button",onClick:u,className:"px-4 py-2 border border-border rounded text-sm text-text-primary hover:bg-bg-tertiary transition-colors",children:"Cancel"}),s.jsx("button",{type:"button",onClick:C,className:"px-4 py-2 bg-accent-primary text-white rounded hover:bg-accent-primary/80 transition-colors text-sm",children:"Save"})]}),children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsxs("div",{className:"flex-1",children:[s.jsx("label",{className:"text-xs text-text-muted block mb-1",children:"Name"}),s.jsx("input",{type:"text",value:p,onChange:v=>m(v.target.value),className:"w-full px-3 py-2 bg-bg-tertiary border border-border rounded text-sm text-text-primary focus:outline-none focus:ring-1 focus:ring-accent-primary"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-text-muted block mb-1",children:"Mode"}),s.jsxs("div",{className:"flex rounded overflow-hidden border border-border",children:[s.jsx("button",{type:"button",onClick:()=>y("dark"),className:`px-3 py-2 text-xs font-medium transition-colors ${g==="dark"?"bg-accent-primary text-white":"bg-bg-tertiary text-text-muted hover:text-text-primary"}`,children:"Dark"}),s.jsx("button",{type:"button",onClick:()=>y("light"),className:`px-3 py-2 text-xs font-medium transition-colors ${g==="light"?"bg-accent-primary text-white":"bg-bg-tertiary text-text-muted hover:text-text-primary"}`,children:"Light"})]})]})]}),!t&&s.jsxs("div",{className:"text-xs text-text-muted",children:["Based on ",s.jsx("span",{className:"text-text-primary",children:b==null?void 0:b.name})]}),Object.entries(_).map(([v,k])=>s.jsxs("div",{className:"space-y-3",children:[s.jsx("h4",{className:"text-xs font-medium text-text-muted uppercase",children:S[v]??v}),s.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:k.map(T=>s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx("label",{htmlFor:T.key,className:"text-xs text-text-muted",children:T.label}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"color",id:T.key,value:gh(d[T.key]??T.defaultValue),onChange:N=>w(T.key,N.target.value),className:"w-8 h-8 rounded cursor-pointer border border-border bg-transparent flex-shrink-0"}),s.jsx("input",{type:"text",value:d[T.key]??T.defaultValue,onChange:N=>w(T.key,N.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"})]})]},T.key))})]},v))]})})}function P1({preset:e,isActive:t,isUnderlying:n,onClick:r,onNewFrom:a,onEdit:l,onDelete:u}){return s.jsxs("div",{className:"relative group",children:[s.jsxs("button",{type:"button",onClick:r,className:`flex flex-col items-center gap-2 px-3 py-3 rounded-lg border transition-colors min-w-[80px] ${t?"border-accent-primary bg-bg-tertiary text-text-primary":n?"border-dashed border-accent-primary/50 bg-bg-tertiary/50 text-text-primary":"border-border bg-bg-secondary text-text-muted hover:border-text-muted"}`,children:[s.jsx("div",{className:"w-8 h-8 rounded border flex items-center justify-center",style:{backgroundColor:e.id==="system"?"transparent":gh(e.tokens["color-bg-primary"]??"#000"),borderColor:gh(e.tokens["color-border"]??"#000")},children:e.id==="system"?s.jsx("div",{className:"w-4 h-4 rounded-full",style:{background:"linear-gradient(135deg, #000 50%, #fff 50%)"}}):s.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:gh(e.tokens["color-text-primary"]??"#fff")}})}),s.jsx("span",{className:"text-xs",children:e.name})]}),a&&s.jsx("button",{type:"button",onClick:c=>{c.stopPropagation(),a()},className:"absolute top-1 right-1 w-6 h-6 rounded bg-bg-tertiary border border-border flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity z-10 hover:border-text-muted",title:"Create custom theme based on this",children:s.jsx("span",{className:"text-xs",children:"✎"})}),l&&s.jsx("button",{type:"button",onClick:c=>{c.stopPropagation(),l()},className:"absolute top-1 right-1 w-6 h-6 rounded bg-bg-tertiary border border-border flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity z-10 hover:border-text-muted",title:"Edit",children:s.jsx("span",{className:"text-xs",children:"✎"})}),u&&s.jsx("button",{type:"button",onClick:c=>u(c),className:"absolute -top-1 -left-1 w-5 h-5 rounded-full bg-accent-error text-white flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity z-20",children:s.jsx(Ji,{className:"w-3 h-3"})})]})}function h5(){const[e,t]=E.useState(null),n=qt(z=>z.currentPreset),r=qt(z=>z.isCustom),a=qt(z=>z.basePreset),l=qt(z=>z.isSystem),u=qt(z=>z.systemDarkPreset),c=qt(z=>z.systemLightPreset),d=qt(z=>z.applyPreset),h=qt(z=>z.applyUserPreset),p=qt(z=>z.deleteUserPreset),m=qt(z=>z.saveTheme),g=qt(z=>z.setSystemDarkPreset),y=qt(z=>z.setSystemLightPreset),w=qt(z=>z.activeUserPresetId),C=qt(z=>z.userPresets),_=rr.filter(z=>z.mode==="dark"),S=rr.filter(z=>z.mode==="light"),b=z=>{var W;if(l){const M=C[z];if(!M)return;const U=M.mode??((W=rr.find(F=>F.id===M.basePreset))==null?void 0:W.mode);U==="dark"?g(M.id):U==="light"&&y(M.id)}else h(z)},v=z=>{const W=rr.find(M=>M.id===z);W&&t({type:"new",presetIndex:C.length,basePresetId:z,presetName:W.name+" Copy",mode:W.mode??"dark",tokens:{...W.tokens}})},k=z=>{const W=C[z];if(!W)return;const M=rr.find(F=>F.id===W.basePreset),U=M?{...M.tokens,...W.tokens}:W.tokens;t({type:"edit",presetIndex:z,basePresetId:W.basePreset,presetName:W.name,mode:W.mode??"dark",tokens:U})},T=(z,W,M)=>{if(!e)return;const U=[...C];if(e.type==="new"){const F={id:"custom-"+Date.now(),name:z,basePreset:e.basePresetId,mode:M,tokens:W};U.push(F);const Q=U.length-1;qt.setState({userPresets:U}),qt.getState().saveUserPresets(),qt.getState().applyUserPreset(Q)}else{const F=U[e.presetIndex];F&&(U[e.presetIndex]={...F,name:z,mode:M,tokens:W}),qt.setState({userPresets:U}),qt.getState().saveUserPresets(),qt.getState().applyUserPreset(e.presetIndex)}t(null)},N=()=>{t(null)},R=(z,W)=>{z.stopPropagation(),p(W)},A=l?"system":r?a:n,O=()=>{l?(d(n),m(JSON.stringify({preset:n})).catch(()=>{})):(d("system"),m(JSON.stringify({preset:"system"})).catch(()=>{}))},P=z=>{if(l){const W=rr.find(M=>M.id===z);(W==null?void 0:W.mode)==="dark"?g(z):(W==null?void 0:W.mode)==="light"&&y(z)}else d(z),m(JSON.stringify({preset:z})).catch(()=>{})},V=z=>{const W=rr.find(M=>M.id===z.basePreset);return W?{...W.tokens,...z.tokens}:z.tokens};return s.jsxs("div",{className:"space-y-4",children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Theme"}),s.jsxs("label",{className:"flex items-center justify-between gap-3 cursor-pointer",children:[s.jsx("span",{className:"text-sm text-text-primary font-medium",children:"Follow system theme"}),s.jsx("button",{type:"button",onClick:O,className:`relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors ${l?"bg-accent-primary":"bg-bg-tertiary"}`,children:s.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${l?"translate-x-6":"translate-x-1"}`})})]}),[{title:"Dark Themes",mode:"dark"},{title:"Light Themes",mode:"light"}].map(({title:z,mode:W})=>{const M=W==="dark"?_:S,U=C.filter(F=>{var X;return(F.mode??((X=rr.find(H=>H.id===F.basePreset))==null?void 0:X.mode))===W});return s.jsxs("div",{children:[s.jsx("h4",{className:"text-xs font-medium text-text-muted uppercase mb-2",children:z}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[M.map(F=>s.jsx(P1,{preset:F,isActive:F.id===A&&!r,isUnderlying:l&&(F.id===u||F.id===c),onClick:()=>P(F.id),onNewFrom:()=>v(F.id)},F.id)),U.map(F=>{const Q=C.indexOf(F),X=V(F);return s.jsx(P1,{preset:{id:F.id,name:F.name,tokens:X},isActive:w===F.id,isUnderlying:l&&(F.id===u||F.id===c),onClick:()=>b(Q),onEdit:()=>k(Q),onDelete:H=>R(H,Q)},F.id)})]})]},z)}),e&&s.jsx(d5,{isOpen:!0,isNew:e.type==="new",presetIndex:e.presetIndex,basePresetId:e.basePresetId,presetName:e.presetName,mode:e.mode,initialTokens:e.tokens,onClose:N,onSave:T})]})}const f5=["monospace","serif","sans-serif"],UE=["JetBrains Mono","Cascadia Mono","Menlo","Consolas","DejaVu Sans Mono","Liberation Mono"],xh=`${UE.map(e=>`"${e}"`).join(", ")}, monospace`,m5=["Andale Mono","Anonymous Pro","Cascadia Code","Cascadia Mono","Consolas","Courier New","DejaVu Sans Mono","Fira Code","Fira Mono","Geist Mono","Hack","IBM Plex Mono","Inconsolata","Iosevka","JetBrains Mono","Liberation Mono","Menlo","Monaco","Noto Sans Mono","Roboto Mono","SF Mono","Source Code Pro","Space Mono","Ubuntu Mono","Victor Mono","CaskaydiaCove Nerd Font","CaskaydiaCove Nerd Font Mono","DejaVuSansMono Nerd Font","FiraCode Nerd Font","FiraCode Nerd Font Mono","Hack Nerd Font","Hack Nerd Font Mono","Iosevka Nerd Font","JetBrainsMono Nerd Font","JetBrainsMono Nerd Font Mono","MesloLGS NF","MesloLGS Nerd Font","SauceCodePro Nerd Font","SauceCodePro Nerd Font Mono","UbuntuMono Nerd Font"],p5="mmmmmmmmmmlliWWWW@0Oo",g5="72px";let bc;function x5(){if(bc!==void 0)return bc;try{bc=document.createElement("canvas").getContext("2d")}catch{bc=null}return bc}function Fy(e){const t=x5();if(!t)throw new Error("Canvas 2D context unavailable");return t.font=`${g5} ${e}`,t.measureText(p5).width}function VE(e,t=Fy){const n=e.trim();if(!n)return!1;try{return f5.some(r=>{const a=t(r);return t(`"${n}", ${r}`)!==a})}catch{return!1}}function y5(e=m5,t=Fy){const n=new Set;for(const r of e)VE(r,t)&&n.add(r);return[...n].sort((r,a)=>r.localeCompare(a))}function b5(e=UE,t=Fy){return e.find(n=>VE(n,t))??""}function v5(e){const t=e.trim();return t?`"${t}", monospace`:""}function _5(e){var n;return(((n=e.split(",")[0])==null?void 0:n.trim())??"").replace(/^['"]|['"]$/g,"")}function S5(){return s.jsx(h5,{})}function w5(){const{settings:e,loading:t,getSetting:n,setSetting:r}=ea(),a=t[je.DISPLAY_SHOW_THINKING]??!1,l=e[je.DISPLAY_MAX_VISIBLE_ITEMS]??"300",[u,c]=E.useState(l);E.useEffect(()=>{n(je.DISPLAY_MAX_VISIBLE_ITEMS)},[n]),E.useEffect(()=>{c(l)},[l]);const d=()=>{const b=parseInt(u,10),v=isNaN(b)||b<0?0:Math.min(b,9999);c(String(v)),r(je.DISPLAY_MAX_VISIBLE_ITEMS,String(v))},h=[{key:je.DISPLAY_SHOW_THINKING,label:"Show thinking blocks",description:"Display AI reasoning content in the feed"},{key:je.DISPLAY_SHOW_VERBOSE_TOOL_OUTPUT,label:"Show expanded tool output",description:"Always show full tool call details instead of compact view"},{key:je.DISPLAY_SHOW_STATS,label:"Show stats bar",description:"Display model, tokens, and timing information"},{key:je.DISPLAY_SHOW_AGENT_DEFINITIONS,label:"Show agent definitions",description:"Display agent definition injections in the feed"},{key:je.DISPLAY_SHOW_WORKFLOW_BARS,label:"Show workflow bars",description:"Display workflow start and end markers"}],p=[{key:je.DISPLAY_USE_NATIVE_SCROLLBARS,label:"Use native scrollbars in tool calls",description:"Swap custom styled scrollbars for native ones in tool call views (file previews, arguments, results). Faster, but native scrollbars look different on some platforms.",defaultValue:"false"},{key:je.DISPLAY_USE_NATIVE_SCROLLBARS_CODE_BLOCKS,label:"Use native scrollbars in code blocks",description:"Swap custom styled scrollbars for native ones in markdown code blocks and tables.",defaultValue:"false"},{key:je.DISPLAY_COLLAPSE_LARGE_TOOL_CALLS,label:"Collapse large tool calls automatically",description:"Start finished tool calls with large outputs collapsed; click to expand. Speeds up loading long sessions.",defaultValue:"false"},{key:je.DISPLAY_DEFER_CODE_HIGHLIGHT_WHILE_STREAMING,label:"Defer code highlighting while streaming",description:"While a code block is streaming, wait until it closes to highlight it. Smoother streaming, but code stays plain until the end.",defaultValue:"false"},{key:je.DISPLAY_FEED_VIRTUALIZATION,label:"Virtualize long feeds",description:"Mount only the most recent items and reveal older ones as you scroll up. Faster on very long sessions, but older history loading is experimental.",defaultValue:"false"},{key:je.DISPLAY_SHOW_SYNTAX_HIGHLIGHTING,label:"Show syntax highlighting",description:"Nicer formatting, but costly - applies to code blocks, diffs, and file previews",defaultValue:"true"}],m=[...h,...p],g=Object.fromEntries(h.map(b=>[b.key,e[b.key]??"true"])),y=Object.fromEntries(p.map(b=>[b.key,e[b.key]??b.defaultValue])),w={...g,...y},[C,_]=E.useState(()=>Object.fromEntries(m.map(b=>[b.key,w[b.key]==="true"])));E.useEffect(()=>{m.forEach(b=>n(b.key))},[n]),E.useEffect(()=>{_(Object.fromEntries(m.map(b=>[b.key,w[b.key]==="true"])))},[JSON.stringify(w)]);const S=async b=>{const v=String(!C[b]);_(k=>({...k,[b]:!k[b]})),await r(b,v)};return a?s.jsx("div",{className:"text-sm text-text-muted",children:"Loading..."}):s.jsxs("div",{className:"space-y-6",children:[s.jsx(S5,{}),s.jsxs("div",{className:"border-t border-border pt-4",children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary mb-2",children:"Custom CSS"}),s.jsx("p",{className:"text-xs text-text-muted mb-3",children:"Add global CSS overrides for any element."}),s.jsx(E5,{})]}),s.jsxs("div",{className:"border-t border-border pt-4",children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary mb-4",children:"Feed Display"}),s.jsx(B1,{toggles:h,local:C,onToggle:S})]}),s.jsxs("div",{className:"border-t border-border pt-4",children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary mb-4",children:"Performance"}),s.jsxs("div",{className:"space-y-4",children:[s.jsx(B1,{toggles:p,local:C,onToggle:S}),s.jsxs("label",{className:"flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-text-primary font-medium",children:"Max visible items"}),s.jsx("div",{className:"text-xs text-text-muted mt-0.5",children:"Keep only the last N items in the feed. Set to 0 to show all."})]}),s.jsx("input",{type:"number",min:0,max:9999,value:u,onChange:b=>{const v=b.target.value.replace(/[^0-9]/g,"");c(v)},onBlur:d,onKeyDown:b=>{b.key==="Enter"&&d()},className:"w-20 px-2 py-1 text-sm text-text-primary bg-bg-tertiary border border-border rounded text-right"})]})]})]}),s.jsxs("div",{className:"border-t border-border pt-4",children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary mb-2",children:"Terminal"}),s.jsx(k5,{})]})]})}const C5="~/project  git status ✓ ✗ → 0123 iIlL1 |─┤";function B1({toggles:e,local:t,onToggle:n}){return s.jsx("div",{className:"space-y-4",children:e.map(({key:r,label:a,description:l})=>s.jsxs("label",{className:"flex items-start justify-between gap-3 cursor-pointer",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-text-primary font-medium",children:a}),s.jsx("div",{className:"text-xs text-text-muted mt-0.5",children:l})]}),s.jsx("button",{type:"button",onClick:()=>n(r),className:`relative inline-flex h-6 w-11 flex-shrink-0 items-center rounded-full transition-colors ${t[r]?"bg-accent-primary":"bg-bg-tertiary"}`,children:s.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${t[r]?"translate-x-6":"translate-x-1"}`})})]},r))})}function k5(){const{settings:e,getSetting:t,setSetting:n}=ea(),r=e[je.DISPLAY_TERMINAL_FONT]??xh,[a,l]=E.useState(r),u=E.useMemo(()=>y5(),[]),c=E.useMemo(()=>b5(),[]);E.useEffect(()=>{t(je.DISPLAY_TERMINAL_FONT)},[t]),E.useEffect(()=>{l(r)},[r]);const h=r===xh?c:_5(r),p=h!==""&&!u.includes(h),m=y=>{const w=y.target.value;w&&n(je.DISPLAY_TERMINAL_FONT,v5(w))},g=()=>{n(je.DISPLAY_TERMINAL_FONT,a.trim()||xh)};return s.jsxs("div",{className:"space-y-2",children:[s.jsx("p",{className:"text-xs text-text-muted",children:"Only monospace fonts detected on this machine are listed. If your shell theme uses icons or powerline glyphs, pick a Nerd Font."}),s.jsxs("select",{value:p?"":h,onChange:m,className:"w-full px-2 py-1.5 text-sm text-text-primary bg-bg-tertiary border border-border rounded focus:outline-none focus:ring-2 focus:ring-accent-primary/50 focus:border-accent-primary",children:[p&&s.jsx("option",{value:"",children:`Custom: ${h}`}),u.length===0&&s.jsx("option",{value:"",children:"No monospace font detected"}),u.map(y=>s.jsx("option",{value:y,style:{fontFamily:`"${y}", monospace`},children:y},y))]}),s.jsx(ct,{horizontal:!0,className:"px-3 py-2 text-sm text-text-primary bg-bg-tertiary border border-border rounded whitespace-nowrap",style:{fontFamily:r},children:C5}),s.jsxs("div",{children:[s.jsx("div",{className:"text-xs text-text-muted mb-1",children:'Not listed? Enter a CSS font-family manually (e.g. "My Font", monospace)'}),s.jsx("input",{type:"text",value:a,onChange:y=>l(y.target.value),onBlur:g,onKeyDown:y=>{y.key==="Enter"&&g()},className:"w-full px-2 py-1 text-xs font-mono text-text-primary bg-bg-tertiary border border-border rounded focus:outline-none focus:ring-2 focus:ring-accent-primary/50 focus:border-accent-primary",spellCheck:!1})]})]})}function E5(){const{settings:e,getSetting:t,setSetting:n}=ea(),r=e[je.DISPLAY_CUSTOM_CSS]??"",[a,l]=E.useState(r);E.useEffect(()=>{t(je.DISPLAY_CUSTOM_CSS)},[t]),E.useEffect(()=>{l(r)},[r]);const u=()=>{n(je.DISPLAY_CUSTOM_CSS,a)};return s.jsx("div",{className:"space-y-2",children:s.jsx("textarea",{value:a,onChange:c=>l(c.target.value),onBlur:u,placeholder:"/* Paste your custom CSS here */",className:"w-full h-32 px-3 py-2 text-xs font-mono text-text-primary bg-bg-tertiary border border-border rounded resize-y focus:outline-none focus:ring-2 focus:ring-accent-primary/50 focus:border-accent-primary",spellCheck:!1})})}function Rx(){const[e,t]=E.useState("Test"),[n,r]=E.useState(""),[a,l]=E.useState(!1),u=E.useCallback(async c=>{t("Testing..."),r(""),l(!1);try{const d=await c();d.success?(t("Success"),l(!0),setTimeout(()=>{t("Test"),l(!1)},3e3)):(r(d.error??"Test failed"),t("Test"))}catch{r("Connection error"),t("Test")}},[]);return[e,n,a,u]}function j5(e){try{return new RegExp(e),!0}catch{return!1}}function N5({value:e,onChange:t}){const[n,r]=E.useState({}),a=(d,h)=>{const p=e.patterns.map((m,g)=>g===d?{...m,...h}:m);t({...e,patterns:p})},l=d=>{const h=e.patterns.filter((p,m)=>m!==d);t({...e,patterns:h})},u=()=>{const d={field:"content",pattern:"",action:"retry",active:!0};t({...e,patterns:[...e.patterns,d]})},c=(d,h)=>{r(p=>({...p,[d]:h.length>0&&!j5(h)})),a(d,{pattern:h})};return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-sm font-medium text-text-primary",children:"Max Retries Per Turn"}),s.jsx("input",{type:"number",min:1,max:100,value:e.maxRetriesPerTurn,onChange:d=>{const h=parseInt(d.target.value,10),p=isNaN(h)?10:Math.max(1,Math.min(100,h));t({...e,maxRetriesPerTurn:p})},className:"mt-1 block w-24 px-2 py-1 text-sm bg-bg-secondary border border-border rounded"})]}),e.patterns.length===0?s.jsx("p",{className:"text-sm text-text-muted",children:"No retry patterns configured."}):s.jsxs("table",{className:"w-full text-sm",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"text-left text-text-muted border-b border-border",children:[s.jsx("th",{className:"pb-2 pr-2 w-12",children:"Active"}),s.jsx("th",{className:"pb-2 pr-2",children:"Field"}),s.jsx("th",{className:"pb-2 pr-2",children:"Pattern"}),s.jsx("th",{className:"pb-2 pr-2",children:"Action"}),s.jsx("th",{className:"pb-2 w-8"})]})}),s.jsx("tbody",{children:e.patterns.map((d,h)=>s.jsxs("tr",{className:"border-b border-border",children:[s.jsx("td",{className:"py-2 pr-2",children:s.jsx("input",{type:"checkbox",checked:d.active,onChange:()=>a(h,{active:!d.active}),className:"accent-accent-primary","aria-label":`Toggle pattern ${h+1}`})}),s.jsx("td",{className:"py-2 pr-2",children:s.jsxs("select",{value:d.field,onChange:p=>a(h,{field:p.target.value}),className:"px-2 py-1 bg-bg-secondary border border-border rounded text-sm",children:[s.jsx("option",{value:"content",children:"content"}),s.jsx("option",{value:"thinking",children:"thinking"}),s.jsx("option",{value:"both",children:"both"})]})}),s.jsx("td",{className:"py-2 pr-2",children:s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("input",{type:"text",value:d.pattern,onChange:p=>c(h,p.target.value),placeholder:"regex pattern",className:"flex-1 px-2 py-1 bg-bg-secondary border border-border rounded text-sm font-mono"}),d.pattern.length>0&&s.jsx("span",{className:`text-sm ${n[h]?"text-red-500":"text-green-500"}`,children:n[h]?"✗":"✓"})]})}),s.jsx("td",{className:"py-2 pr-2 text-text-muted",children:"retry"}),s.jsx("td",{className:"py-2",children:s.jsx("button",{onClick:()=>l(h),title:"Remove pattern",className:"text-text-muted hover:text-red-500 transition-colors",children:"×"})})]},h))})]}),s.jsx(dt,{variant:"secondary",onClick:u,children:"Add Pattern"})]})}const $1=1e3,T5=3e4;function z1({message:e,command:t,hint:n}){return s.jsxs("div",{className:"flex flex-col gap-3 mt-2",children:[s.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-accent-danger/10 border border-accent-danger/30 rounded text-xs",children:[s.jsx("span",{children:"⚠️"}),s.jsx("p",{className:"text-text-secondary",children:e})]}),s.jsx("div",{className:"bg-bg-tertiary rounded px-3 py-2 text-xs font-mono text-text-secondary",children:t}),s.jsx("p",{className:"text-xs text-text-muted",children:n})]})}function WE({isOpen:e,onClose:t,versionInfo:n}){const[r,a]=E.useState("ready"),[l,u]=E.useState(""),[c,d]=E.useState(n),[h,p]=E.useState(null),[m,g]=E.useState(null),[y,w]=E.useState(!1),[C,_]=E.useState(!1),[S,b]=E.useState(!1),v=E.useRef(!1),k=E.useRef(null),T=E.useRef(null),N=E.useRef(!0),R=E.useRef(n);R.current=n,E.useEffect(()=>{if(!e)return;let X=!1;return(async()=>{try{const I=await(await fetch(hs("/api/auto-update/check"))).json();if(X)return;_(!!I.isService),!R.current&&I.current&&I.latest&&d({current:I.current,latest:I.latest})}catch{X||_(!1)}})(),()=>{X=!0}},[e]),E.useEffect(()=>{if(!e||r!=="updating"&&r!=="restarting")return;const X=setInterval(()=>{u(H=>H.length>=3?"":H+".")},400);return()=>clearInterval(X)},[e,r]);const A=E.useCallback(()=>{k.current!==null&&(clearTimeout(k.current),k.current=null),T.current=null},[]),O=E.useCallback(X=>{g(X),a("restartFailed")},[]),P=E.useCallback(X=>{v.current=X,b(X)},[]),V=E.useCallback(X=>{localStorage.setItem("openfox_updated_to",X),localStorage.setItem("update_pending","true")},[]),z=E.useCallback(async X=>{a("restarting"),g(null),A();try{await we("/api/auto-update/restart",{method:"POST"})}catch{}if(!N.current)return;T.current=Date.now();const H=async()=>{if(!N.current){A();return}const I=T.current;if(I!==null&&Date.now()-I>=T5){A(),O("OpenFox could not be reached after restart within 30 seconds. Please restart OpenFox manually.");return}try{const D=await fetch(hs("/api/auto-update/check?force=true"));if(!D.ok)throw new Error(`HTTP ${D.status}`);if((await D.json()).current===X){A(),V(X),window.location.reload();return}}catch{}if(!N.current){A();return}k.current=setTimeout(()=>{H()},$1)};k.current=setTimeout(()=>{H()},$1)},[A,O,V]),W=E.useCallback(async()=>{a("updating"),g(null);try{const H=await(await we("/api/auto-update",{method:"POST"})).json();if(H.success){const I=H.version??"unknown";p(I),w(!!H.isService),v.current&&H.isService?z(I):a("complete")}else g(H.error??"Update failed"),a("failed")}catch(X){g(X instanceof Error?X.message:"Update request failed"),a("failed")}},[z]),M=E.useCallback(()=>{const X=h??(c==null?void 0:c.latest)??null;if(!X){O("Installed version unknown; cannot verify restart.");return}z(X)},[h,c,O,z]);E.useEffect(()=>(N.current=!0,()=>{N.current=!1,A()}),[A]),E.useEffect(()=>{e&&(u(""),A(),a("ready"),p(null),g(null),w(!1),_(!1),P(!1))},[e,A,P]);const U=r!=="updating"&&r!=="restarting",F=X=>X,Q=r==="failed"?"Update Failed":r==="restarting"?"Restarting…":r==="complete"?"Update Complete":r==="restartFailed"?"Restart Not Confirmed":"New OpenFox version available";return s.jsxs(jt,{isOpen:e,onClose:U?t:void 0,title:Q,size:"md",closeOnBackdropClick:U,showCloseButton:U,children:[s.jsxs("div",{className:"flex flex-col gap-4",children:[c&&s.jsxs("div",{className:"flex justify-between text-sm",children:[s.jsx("span",{className:"text-text-muted",children:"Current version"}),s.jsx("span",{className:"text-text-primary font-mono",children:F(c.current)})]}),c&&s.jsxs("div",{className:"flex justify-between text-sm pb-2",children:[s.jsx("span",{className:"text-text-muted",children:"Latest version"}),s.jsx("span",{className:"text-accent-primary font-mono font-semibold",children:c.latest})]}),(r==="updating"||r==="restarting")&&s.jsxs("div",{className:"flex flex-col gap-2 mt-2",children:[s.jsx("div",{className:"h-1.5 bg-bg-tertiary rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full bg-accent-primary animate-pulse w-full"})}),s.jsxs("p",{className:"text-xs text-text-muted text-center",children:[r==="restarting"?"Restarting":"Updating",l]})]}),r==="complete"&&s.jsx("div",{className:"flex flex-col gap-3 mt-2",children:s.jsxs("div",{className:"bg-bg-tertiary rounded px-3 py-2 text-xs text-text-secondary",children:["OpenFox has been updated to v",h??(c==null?void 0:c.latest),".",y?' Click "Restart OpenFox now" to apply the update.':" Please restart OpenFox to use the new version."]})}),r==="failed"&&s.jsx(z1,{message:m,command:"openfox update",hint:"Run this command in your terminal to complete the update."}),r==="restartFailed"&&s.jsx(z1,{message:m,command:"openfox service restart",hint:"Run this command in your terminal to restart OpenFox."})]}),r==="ready"&&s.jsx("button",{onClick:W,className:"w-full px-3 py-2 text-sm rounded bg-accent-primary hover:brightness-110 transition-all text-white font-medium",children:"Update OpenFox"}),(r==="ready"||r==="updating")&&C&&s.jsxs("label",{className:"flex items-center justify-center gap-2 text-xs text-text-muted cursor-pointer select-none mt-2",children:[s.jsx("input",{type:"checkbox",checked:S,onChange:X=>P(X.target.checked)}),"Auto-restart once update is done"]}),r==="complete"&&y&&s.jsxs("div",{className:"flex flex-col gap-2 mt-2",children:[s.jsx("button",{onClick:M,className:"w-full px-3 py-2 text-sm rounded bg-accent-primary hover:brightness-110 transition-all text-white font-medium",children:"Restart OpenFox now"}),s.jsx("button",{onClick:t,className:"w-full px-3 py-2 text-sm rounded bg-bg-tertiary hover:bg-bg-secondary transition-colors text-text-primary font-medium",children:"Later"})]}),r==="complete"&&!y&&s.jsx("button",{onClick:t,className:"w-full px-3 py-2 text-sm rounded bg-bg-tertiary hover:bg-bg-secondary transition-colors text-text-primary font-medium mt-2",children:"Close"}),(r==="failed"||r==="restartFailed")&&s.jsx("button",{onClick:t,className:"w-full px-3 py-2 text-sm rounded bg-bg-tertiary hover:bg-bg-secondary transition-colors text-text-primary font-medium mt-2",children:"Close"})]})}function bn({children:e,className:t="",horizontal:n=!1,style:r,scope:a="toolCalls"}){const{useNativeScrollbars:l,useNativeScrollbarsCodeBlocks:u}=As();if(a==="codeBlocks"?u:l){const d=n?"overflow-x-auto":"overflow-y-auto";return s.jsx("div",{className:`${d} ${t}`.trim(),style:r,children:e})}return s.jsx(ct,{horizontal:n,className:t,style:r,children:e})}function A5(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const L5=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,R5=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,D5={};function H1(e,t){return(D5.jsx?R5:L5).test(e)}const O5=/[ \t\n\f\r]/g;function I5(e){return typeof e=="object"?e.type==="text"?F1(e.value):!1:F1(e)}function F1(e){return e.replace(O5,"")===""}let fu=class{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}};fu.prototype.normal={};fu.prototype.property={};fu.prototype.space=void 0;function GE(e,t){const n={},r={};for(const a of e)Object.assign(n,a.property),Object.assign(r,a.normal);return new fu(n,r,t)}function Dx(e){return e.toLowerCase()}let yr=class{constructor(t,n){this.attribute=n,this.property=t}};yr.prototype.attribute="";yr.prototype.booleanish=!1;yr.prototype.boolean=!1;yr.prototype.commaOrSpaceSeparated=!1;yr.prototype.commaSeparated=!1;yr.prototype.defined=!1;yr.prototype.mustUseProperty=!1;yr.prototype.number=!1;yr.prototype.overloadedBoolean=!1;yr.prototype.property="";yr.prototype.spaceSeparated=!1;yr.prototype.space=void 0;let M5=0;const pt=Xa(),Nn=Xa(),Ox=Xa(),qe=Xa(),Xt=Xa(),Ua=Xa(),jr=Xa();function Xa(){return 2**++M5}const Ix=Object.freeze(Object.defineProperty({__proto__:null,boolean:pt,booleanish:Nn,commaOrSpaceSeparated:jr,commaSeparated:Ua,number:qe,overloadedBoolean:Ox,spaceSeparated:Xt},Symbol.toStringTag,{value:"Module"})),_g=Object.keys(Ix);let Uy=class extends yr{constructor(t,n,r,a){let l=-1;if(super(t,n),U1(this,"space",a),typeof r=="number")for(;++l<_g.length;){const u=_g[l];U1(this,_g[l],(r&Ix[u])===Ix[u])}}};Uy.prototype.defined=!0;function U1(e,t,n){n&&(e[t]=n)}function yl(e){const t={},n={};for(const[r,a]of Object.entries(e.properties)){const l=new Uy(r,e.transform(e.attributes||{},r),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(l.mustUseProperty=!0),t[r]=l,n[Dx(r)]=r,n[Dx(l.attribute)]=r}return new fu(t,n,e.space)}const qE=yl({properties:{ariaActiveDescendant:null,ariaAtomic:Nn,ariaAutoComplete:null,ariaBusy:Nn,ariaChecked:Nn,ariaColCount:qe,ariaColIndex:qe,ariaColSpan:qe,ariaControls:Xt,ariaCurrent:null,ariaDescribedBy:Xt,ariaDetails:null,ariaDisabled:Nn,ariaDropEffect:Xt,ariaErrorMessage:null,ariaExpanded:Nn,ariaFlowTo:Xt,ariaGrabbed:Nn,ariaHasPopup:null,ariaHidden:Nn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Xt,ariaLevel:qe,ariaLive:null,ariaModal:Nn,ariaMultiLine:Nn,ariaMultiSelectable:Nn,ariaOrientation:null,ariaOwns:Xt,ariaPlaceholder:null,ariaPosInSet:qe,ariaPressed:Nn,ariaReadOnly:Nn,ariaRelevant:null,ariaRequired:Nn,ariaRoleDescription:Xt,ariaRowCount:qe,ariaRowIndex:qe,ariaRowSpan:qe,ariaSelected:Nn,ariaSetSize:qe,ariaSort:null,ariaValueMax:qe,ariaValueMin:qe,ariaValueNow:qe,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function KE(e,t){return t in e?e[t]:t}function YE(e,t){return KE(e,t.toLowerCase())}const P5=yl({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Ua,acceptCharset:Xt,accessKey:Xt,action:null,allow:null,allowFullScreen:pt,allowPaymentRequest:pt,allowUserMedia:pt,alpha:pt,alt:null,as:null,async:pt,autoCapitalize:null,autoComplete:Xt,autoFocus:pt,autoPlay:pt,blocking:Xt,capture:null,charSet:null,checked:pt,cite:null,className:Xt,closedBy:null,colorSpace:null,cols:qe,colSpan:qe,command:null,commandFor:null,content:null,contentEditable:Nn,controls:pt,controlsList:Xt,coords:qe|Ua,crossOrigin:null,data:null,dateTime:null,decoding:null,default:pt,defer:pt,dir:null,dirName:null,disabled:pt,download:Ox,draggable:Nn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:pt,formTarget:null,headers:Xt,height:qe,hidden:Ox,high:qe,href:null,hrefLang:null,htmlFor:Xt,httpEquiv:Xt,id:null,imageSizes:null,imageSrcSet:null,inert:pt,inputMode:null,integrity:null,is:null,isMap:pt,itemId:null,itemProp:Xt,itemRef:Xt,itemScope:pt,itemType:Xt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:pt,low:qe,manifest:null,max:null,maxLength:qe,media:null,method:null,min:null,minLength:qe,multiple:pt,muted:pt,name:null,nonce:null,noModule:pt,noValidate:pt,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:pt,optimum:qe,pattern:null,ping:Xt,placeholder:null,playsInline:pt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:pt,referrerPolicy:null,rel:Xt,required:pt,reversed:pt,rows:qe,rowSpan:qe,sandbox:Xt,scope:null,scoped:pt,seamless:pt,selected:pt,shadowRootClonable:pt,shadowRootCustomElementRegistry:pt,shadowRootDelegatesFocus:pt,shadowRootMode:null,shadowRootSerializable:pt,shape:null,size:qe,sizes:null,slot:null,span:qe,spellCheck:Nn,src:null,srcDoc:null,srcLang:null,srcSet:null,start:qe,step:null,style:null,tabIndex:qe,target:null,title:null,translate:null,type:null,typeMustMatch:pt,useMap:null,value:Nn,width:qe,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Xt,axis:null,background:null,bgColor:null,border:qe,borderColor:null,bottomMargin:qe,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:pt,declare:pt,event:null,face:null,frame:null,frameBorder:null,hSpace:qe,leftMargin:qe,link:null,longDesc:null,lowSrc:null,marginHeight:qe,marginWidth:qe,noResize:pt,noHref:pt,noShade:pt,noWrap:pt,object:null,profile:null,prompt:null,rev:null,rightMargin:qe,rules:null,scheme:null,scrolling:Nn,standby:null,summary:null,text:null,topMargin:qe,valueType:null,version:null,vAlign:null,vLink:null,vSpace:qe,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:pt,disablePictureInPicture:pt,disableRemotePlayback:pt,exportParts:Ua,part:Xt,prefix:null,property:null,results:qe,security:null,unselectable:null},space:"html",transform:YE}),B5=yl({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",maskType:"mask-type",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:jr,accentHeight:qe,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:qe,amplitude:qe,arabicForm:null,ascent:qe,attributeName:null,attributeType:null,azimuth:qe,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:qe,by:null,calcMode:null,capHeight:qe,className:Xt,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:qe,diffuseConstant:qe,direction:null,display:null,dur:null,divisor:qe,dominantBaseline:null,download:pt,dx:null,dy:null,edgeMode:null,editable:null,elevation:qe,enableBackground:null,end:null,event:null,exponent:qe,externalResourcesRequired:null,fill:null,fillOpacity:qe,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Ua,g2:Ua,glyphName:Ua,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:qe,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:qe,horizOriginX:qe,horizOriginY:qe,id:null,ideographic:qe,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:qe,k:qe,k1:qe,k2:qe,k3:qe,k4:qe,kernelMatrix:jr,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:qe,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:qe,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:qe,overlineThickness:qe,paintOrder:null,panose1:null,path:null,pathLength:qe,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Xt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:qe,pointsAtY:qe,pointsAtZ:qe,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:jr,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:jr,rev:jr,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:jr,requiredFeatures:jr,requiredFonts:jr,requiredFormats:jr,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:qe,specularExponent:qe,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:qe,strikethroughThickness:qe,string:null,stroke:null,strokeDashArray:jr,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:qe,strokeOpacity:qe,strokeWidth:null,style:null,surfaceScale:qe,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:jr,tabIndex:qe,tableValues:null,target:null,targetX:qe,targetY:qe,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:jr,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:qe,underlineThickness:qe,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:qe,values:null,vAlphabetic:qe,vMathematical:qe,vectorEffect:null,vHanging:qe,vIdeographic:qe,version:null,vertAdvY:qe,vertOriginX:qe,vertOriginY:qe,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:qe,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:KE}),XE=yl({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()}}),QE=yl({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:YE}),JE=yl({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),$5={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"},z5=/[A-Z]/g,V1=/-[a-z]/g,H5=/^data[-\w.:]+$/i;function F5(e,t){const n=Dx(t);let r=t,a=yr;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&H5.test(t)){if(t.charAt(4)==="-"){const l=t.slice(5).replace(V1,V5);r="data"+l.charAt(0).toUpperCase()+l.slice(1)}else{const l=t.slice(4);if(!V1.test(l)){let u=l.replace(z5,U5);u.charAt(0)!=="-"&&(u="-"+u),t="data"+u}}a=Uy}return new a(r,t)}function U5(e){return"-"+e.toLowerCase()}function V5(e){return e.charAt(1).toUpperCase()}const W5=GE([qE,P5,XE,QE,JE],"html"),Vy=GE([qE,B5,XE,QE,JE],"svg");function G5(e){return e.join(" ").trim()}var Po={},Sg,W1;function q5(){if(W1)return Sg;W1=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,a=/^:\s*/,l=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,u=/^[;\s]*/,c=/^\s+|\s+$/g,d=`
68
+ `,h="/",p="*",m="",g="comment",y="declaration";function w(_,S){if(typeof _!="string")throw new TypeError("First argument must be a string");if(!_)return[];S=S||{};var b=1,v=1;function k(M){var U=M.match(t);U&&(b+=U.length);var F=M.lastIndexOf(d);v=~F?M.length-F:v+M.length}function T(){var M={line:b,column:v};return function(U){return U.position=new N(M),O(),U}}function N(M){this.start=M,this.end={line:b,column:v},this.source=S.source}N.prototype.content=_;function R(M){var U=new Error(S.source+":"+b+":"+v+": "+M);if(U.reason=M,U.filename=S.source,U.line=b,U.column=v,U.source=_,!S.silent)throw U}function A(M){var U=M.exec(_);if(U){var F=U[0];return k(F),_=_.slice(F.length),U}}function O(){A(n)}function P(M){var U;for(M=M||[];U=V();)U!==!1&&M.push(U);return M}function V(){var M=T();if(!(h!=_.charAt(0)||p!=_.charAt(1))){for(var U=2;m!=_.charAt(U)&&(p!=_.charAt(U)||h!=_.charAt(U+1));)++U;if(U+=2,m===_.charAt(U-1))return R("End of comment missing");var F=_.slice(2,U-2);return v+=2,k(F),_=_.slice(U),v+=2,M({type:g,comment:F})}}function z(){var M=T(),U=A(r);if(U){if(V(),!A(a))return R("property missing ':'");var F=A(l),Q=M({type:y,property:C(U[0].replace(e,m)),value:F?C(F[0].replace(e,m)):m});return A(u),Q}}function W(){var M=[];P(M);for(var U;U=z();)U!==!1&&(M.push(U),P(M));return M}return O(),W()}function C(_){return _?_.replace(c,m):m}return Sg=w,Sg}var G1;function K5(){if(G1)return Po;G1=1;var e=Po&&Po.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Po,"__esModule",{value:!0}),Po.default=n;const t=e(q5());function n(r,a){let l=null;if(!r||typeof r!="string")return l;const u=(0,t.default)(r),c=typeof a=="function";return u.forEach(d=>{if(d.type!=="declaration")return;const{property:h,value:p}=d;c?a(h,p,d):p&&(l=l||{},l[h]=p)}),l}return Po}var vc={},q1;function Y5(){if(q1)return vc;q1=1,Object.defineProperty(vc,"__esModule",{value:!0}),vc.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,l=function(h){return!h||n.test(h)||e.test(h)},u=function(h,p){return p.toUpperCase()},c=function(h,p){return"".concat(p,"-")},d=function(h,p){return p===void 0&&(p={}),l(h)?h:(h=h.toLowerCase(),p.reactCompat?h=h.replace(a,c):h=h.replace(r,c),h.replace(t,u))};return vc.camelCase=d,vc}var _c,K1;function X5(){if(K1)return _c;K1=1;var e=_c&&_c.__importDefault||function(a){return a&&a.__esModule?a:{default:a}},t=e(K5()),n=Y5();function r(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 r.default=r,_c=r,_c}var Q5=X5();const J5=nf(Q5),ZE=ej("end"),Wy=ej("start");function ej(e){return t;function t(n){const r=n&&n.position&&n.position[e]||{};if(typeof r.line=="number"&&r.line>0&&typeof r.column=="number"&&r.column>0)return{line:r.line,column:r.column,offset:typeof r.offset=="number"&&r.offset>-1?r.offset:void 0}}}function Z5(e){const t=Wy(e),n=ZE(e);if(t&&n)return{start:t,end:n}}function Bc(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?Y1(e.position):"start"in e||"end"in e?Y1(e):"line"in e||"column"in e?Mx(e):""}function Mx(e){return X1(e&&e.line)+":"+X1(e&&e.column)}function Y1(e){return Mx(e&&e.start)+"-"+Mx(e&&e.end)}function X1(e){return e&&typeof e=="number"?e:1}class Zn extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=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 r=="string"){const d=r.indexOf(":");d===-1?l.ruleId=r:(l.source=r.slice(0,d),l.ruleId=r.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=Bc(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}}Zn.prototype.file="";Zn.prototype.name="";Zn.prototype.reason="";Zn.prototype.message="";Zn.prototype.stack="";Zn.prototype.column=void 0;Zn.prototype.line=void 0;Zn.prototype.ancestors=void 0;Zn.prototype.cause=void 0;Zn.prototype.fatal=void 0;Zn.prototype.place=void 0;Zn.prototype.ruleId=void 0;Zn.prototype.source=void 0;const Gy={}.hasOwnProperty,eO=new Map,tO=/[A-Z]/g,nO=new Set(["table","tbody","thead","tfoot","tr"]),rO=new Set(["td","th"]),tj="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function sO(e,t){if(!t||t.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if(typeof t.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=hO(n,t.jsxDEV)}else{if(typeof t.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof t.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");r=dO(n,t.jsx,t.jsxs)}const a={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space==="svg"?Vy:W5,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},l=nj(a,e,void 0);return l&&typeof l!="string"?l:a.create(e,a.Fragment,{children:l||void 0},void 0)}function nj(e,t,n){if(t.type==="element")return iO(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return aO(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return lO(e,t,n);if(t.type==="mdxjsEsm")return oO(e,t);if(t.type==="root")return cO(e,t,n);if(t.type==="text")return uO(e,t)}function iO(e,t,n){const r=e.schema;let a=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(a=Vy,e.schema=a),e.ancestors.push(t);const l=sj(e,t.tagName,!1),u=fO(e,t);let c=Ky(e,t);return nO.has(t.tagName)&&(c=c.filter(function(d){return typeof d=="string"?!I5(d):!0})),rj(e,u,l,t),qy(u,c),e.ancestors.pop(),e.schema=r,e.create(t,l,u,n)}function aO(e,t){if(t.data&&t.data.estree&&e.evaluater){const r=t.data.estree.body[0];return r.type,e.evaluater.evaluateExpression(r.expression)}eu(e,t.position)}function oO(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);eu(e,t.position)}function lO(e,t,n){const r=e.schema;let a=r;t.name==="svg"&&r.space==="html"&&(a=Vy,e.schema=a),e.ancestors.push(t);const l=t.name===null?e.Fragment:sj(e,t.name,!0),u=mO(e,t),c=Ky(e,t);return rj(e,u,l,t),qy(u,c),e.ancestors.pop(),e.schema=r,e.create(t,l,u,n)}function cO(e,t,n){const r={};return qy(r,Ky(e,t)),e.create(t,e.Fragment,r,n)}function uO(e,t){return t.value}function rj(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function qy(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function dO(e,t,n){return r;function r(a,l,u,c){const h=Array.isArray(u.children)?n:t;return c?h(l,u,c):h(l,u)}}function hO(e,t){return n;function n(r,a,l,u){const c=Array.isArray(l.children),d=Wy(r);return t(a,l,u,c,{columnNumber:d?d.column-1:void 0,fileName:e,lineNumber:d?d.line:void 0},void 0)}}function fO(e,t){const n={};let r,a;for(a in t.properties)if(a!=="children"&&Gy.call(t.properties,a)){const l=pO(e,a,t.properties[a]);if(l){const[u,c]=l;e.tableCellAlignToStyle&&u==="align"&&typeof c=="string"&&rO.has(t.tagName)?r=c:n[u]=c}}if(r){const l=n.style||(n.style={});l[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function mO(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const l=r.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 eu(e,t.position);else{const a=r.name;let l;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const c=r.value.data.estree.body[0];c.type,l=e.evaluater.evaluateExpression(c.expression)}else eu(e,t.position);else l=r.value===null?!0:r.value;n[a]=l}return n}function Ky(e,t){const n=[];let r=-1;const a=e.passKeys?new Map:eO;for(;++r<t.children.length;){const l=t.children[r];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 h=a.get(d)||0;u=d+"-"+h,a.set(d,h+1)}}const c=nj(e,l,u);c!==void 0&&n.push(c)}return n}function pO(e,t,n){const r=F5(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?A5(n):G5(n)),r.property==="style"){let a=typeof n=="object"?n:gO(e,String(n));return e.stylePropertyNameCase==="css"&&(a=xO(a)),["style",a]}return[e.elementAttributeNameCase==="react"&&r.space?$5[r.property]||r.property:r.attribute,n]}}function gO(e,t){try{return J5(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,a=new Zn("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw a.file=e.filePath||void 0,a.url=tj+"#cannot-parse-style-attribute",a}}function sj(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const a=t.split(".");let l=-1,u;for(;++l<a.length;){const c=H1(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}r=u}else r=H1(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const a=r.value;return Gy.call(e.components,a)?e.components[a]:a}if(e.evaluater)return e.evaluater.evaluateExpression(r);eu(e)}function eu(e,t){const n=new Zn("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=tj+"#cannot-handle-mdx-estrees-without-createevaluater",n}function xO(e){const t={};let n;for(n in e)Gy.call(e,n)&&(t[yO(n)]=e[n]);return t}function yO(e){let t=e.replace(tO,bO);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function bO(e){return"-"+e.toLowerCase()}const wg={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"]},vO={};function Yy(e,t){const n=vO,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,a=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return ij(e,r,a)}function ij(e,t,n){if(_O(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 Q1(e.children,t,n)}return Array.isArray(e)?Q1(e,t,n):""}function Q1(e,t,n){const r=[];let a=-1;for(;++a<e.length;)r[a]=ij(e[a],t,n);return r.join("")}function _O(e){return!!(e&&typeof e=="object")}const J1=document.createElement("i");function Xy(e){const t="&"+e+";";J1.innerHTML=t;const n=J1.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function Rr(e,t,n,r){const a=e.length;let l=0,u;if(t<0?t=-t>a?0:a+t:t=t>a?a:t,n=n>0?n:0,r.length<1e4)u=Array.from(r),u.unshift(t,n),e.splice(...u);else for(n&&e.splice(t,n);l<r.length;)u=r.slice(l,l+1e4),u.unshift(t,0),e.splice(...u),l+=1e4,t+=1e4}function Wr(e,t){return e.length>0?(Rr(e,e.length,0,t),e):t}const Z1={}.hasOwnProperty;function aj(e){const t={};let n=-1;for(;++n<e.length;)SO(t,e[n]);return t}function SO(e,t){let n;for(n in t){const a=(Z1.call(e,n)?e[n]:void 0)||(e[n]={}),l=t[n];let u;if(l)for(u in l){Z1.call(a,u)||(a[u]=[]);const c=l[u];wO(a[u],Array.isArray(c)?c:c?[c]:[])}}}function wO(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);Rr(e,0,0,r)}function oj(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 us(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const ir=ta(/[A-Za-z]/),Qn=ta(/[\dA-Za-z]/),CO=ta(/[#-'*+\--9=?A-Z^-~]/);function Rh(e){return e!==null&&(e<32||e===127)}const Px=ta(/\d/),kO=ta(/[\dA-Fa-f]/),EO=ta(/[!-/:-@[-`{-~]/);function ot(e){return e!==null&&e<-2}function Jt(e){return e!==null&&(e<0||e===32)}function Ct(e){return e===-2||e===-1||e===32}const Sf=ta(new RegExp("\\p{P}|\\p{S}","u")),qa=ta(/\s/);function ta(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function bl(e){const t=[];let n=-1,r=0,a=0;for(;++n<e.length;){const l=e.charCodeAt(n);let u="";if(l===37&&Qn(e.charCodeAt(n+1))&&Qn(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(r,n),encodeURIComponent(u)),r=n+a+1,u=""),a&&(n+=a,a=0)}return t.join("")+e.slice(r)}function Tt(e,t,n,r){const a=r?r-1:Number.POSITIVE_INFINITY;let l=0;return u;function u(d){return Ct(d)?(e.enter(n),c(d)):t(d)}function c(d){return Ct(d)&&l++<a?(e.consume(d),c):(e.exit(n),t(d))}}const jO={tokenize:NO};function NO(e){const t=e.attempt(this.parser.constructs.contentInitial,r,a);let n;return t;function r(c){if(c===null){e.consume(c);return}return e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),Tt(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 ot(c)?(e.consume(c),e.exit("chunkText"),l):(e.consume(c),u)}}const TO={tokenize:AO},ew={tokenize:LO};function AO(e){const t=this,n=[];let r=0,a,l,u;return c;function c(v){if(r<n.length){const k=n[r];return t.containerState=k[1],e.attempt(k[0].continuation,d,h)(v)}return h(v)}function d(v){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,a&&b();const k=t.events.length;let T=k,N;for(;T--;)if(t.events[T][0]==="exit"&&t.events[T][1].type==="chunkFlow"){N=t.events[T][1].end;break}S(r);let R=k;for(;R<t.events.length;)t.events[R][1].end={...N},R++;return Rr(t.events,T+1,0,t.events.slice(k)),t.events.length=R,h(v)}return c(v)}function h(v){if(r===n.length){if(!a)return g(v);if(a.currentConstruct&&a.currentConstruct.concrete)return w(v);t.interrupt=!!(a.currentConstruct&&!a._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(ew,p,m)(v)}function p(v){return a&&b(),S(r),g(v)}function m(v){return t.parser.lazy[t.now().line]=r!==n.length,u=t.now().offset,w(v)}function g(v){return t.containerState={},e.attempt(ew,y,w)(v)}function y(v){return r++,n.push([t.currentConstruct,t.containerState]),g(v)}function w(v){if(v===null){a&&b(),S(0),e.consume(v);return}return a=a||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:a,contentType:"flow",previous:l}),C(v)}function C(v){if(v===null){_(e.exit("chunkFlow"),!0),S(0),e.consume(v);return}return ot(v)?(e.consume(v),_(e.exit("chunkFlow")),r=0,t.interrupt=void 0,c):(e.consume(v),C)}function _(v,k){const T=t.sliceStream(v);if(k&&T.push(null),v.previous=l,l&&(l.next=v),l=v,a.defineSkip(v.start),a.write(T),t.parser.lazy[v.start.line]){let N=a.events.length;for(;N--;)if(a.events[N][1].start.offset<u&&(!a.events[N][1].end||a.events[N][1].end.offset>u))return;const R=t.events.length;let A=R,O,P;for(;A--;)if(t.events[A][0]==="exit"&&t.events[A][1].type==="chunkFlow"){if(O){P=t.events[A][1].end;break}O=!0}for(S(r),N=R;N<t.events.length;)t.events[N][1].end={...P},N++;Rr(t.events,A+1,0,t.events.slice(R)),t.events.length=N}}function S(v){let k=n.length;for(;k-- >v;){const T=n[k];t.containerState=T[1],T[0].exit.call(t,e)}n.length=v}function b(){a.write([null]),l=void 0,a=void 0,t.containerState._closeFlow=void 0}}function LO(e,t,n){return Tt(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function cl(e){if(e===null||Jt(e)||qa(e))return 1;if(Sf(e))return 2}function wf(e,t,n){const r=[];let a=-1;for(;++a<e.length;){const l=e[a].resolveAll;l&&!r.includes(l)&&(t=l(t,n),r.push(l))}return t}const Bx={name:"attention",resolveAll:RO,tokenize:DO};function RO(e,t){let n=-1,r,a,l,u,c,d,h,p;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;d=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const m={...e[r][1].end},g={...e[n][1].start};tw(m,-d),tw(g,d),u={type:d>1?"strongSequence":"emphasisSequence",start:m,end:{...e[r][1].end}},c={type:d>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:g},l={type:d>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},a={type:d>1?"strong":"emphasis",start:{...u.start},end:{...c.end}},e[r][1].end={...u.start},e[n][1].start={...c.end},h=[],e[r][1].end.offset-e[r][1].start.offset&&(h=Wr(h,[["enter",e[r][1],t],["exit",e[r][1],t]])),h=Wr(h,[["enter",a,t],["enter",u,t],["exit",u,t],["enter",l,t]]),h=Wr(h,wf(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),h=Wr(h,[["exit",l,t],["enter",c,t],["exit",c,t],["exit",a,t]]),e[n][1].end.offset-e[n][1].start.offset?(p=2,h=Wr(h,[["enter",e[n][1],t],["exit",e[n][1],t]])):p=0,Rr(e,r-1,n-r+3,h),n=r+h.length-p-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function DO(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,a=cl(r);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 h=e.exit("attentionSequence"),p=cl(d),m=!p||p===2&&a||n.includes(d),g=!a||a===2&&p||n.includes(r);return h._open=!!(l===42?m:m&&(a||!g)),h._close=!!(l===42?g:g&&(p||!m)),t(d)}}function tw(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const OO={name:"autolink",tokenize:IO};function IO(e,t,n){let r=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 ir(y)?(e.consume(y),u):y===64?n(y):h(y)}function u(y){return y===43||y===45||y===46||Qn(y)?(r=1,c(y)):h(y)}function c(y){return y===58?(e.consume(y),r=0,d):(y===43||y===45||y===46||Qn(y))&&r++<32?(e.consume(y),c):(r=0,h(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||Rh(y)?n(y):(e.consume(y),d)}function h(y){return y===64?(e.consume(y),p):CO(y)?(e.consume(y),h):n(y)}function p(y){return Qn(y)?m(y):n(y)}function m(y){return y===46?(e.consume(y),r=0,p):y===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(y),e.exit("autolinkMarker"),e.exit("autolink"),t):g(y)}function g(y){if((y===45||Qn(y))&&r++<63){const w=y===45?g:m;return e.consume(y),w}return n(y)}}const mu={partial:!0,tokenize:MO};function MO(e,t,n){return r;function r(l){return Ct(l)?Tt(e,a,"linePrefix")(l):a(l)}function a(l){return l===null||ot(l)?t(l):n(l)}}const lj={continuation:{tokenize:BO},exit:$O,name:"blockQuote",tokenize:PO};function PO(e,t,n){const r=this;return a;function a(u){if(u===62){const c=r.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 Ct(u)?(e.enter("blockQuotePrefixWhitespace"),e.consume(u),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(u))}}function BO(e,t,n){const r=this;return a;function a(u){return Ct(u)?Tt(e,l,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(u):l(u)}function l(u){return e.attempt(lj,t,n)(u)}}function $O(e){e.exit("blockQuote")}const cj={name:"characterEscape",tokenize:zO};function zO(e,t,n){return r;function r(l){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(l),e.exit("escapeMarker"),a}function a(l){return EO(l)?(e.enter("characterEscapeValue"),e.consume(l),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(l)}}const uj={name:"characterReference",tokenize:HO};function HO(e,t,n){const r=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"),h):(e.enter("characterReferenceValue"),l=31,u=Qn,p(m))}function h(m){return m===88||m===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(m),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),l=6,u=kO,p):(e.enter("characterReferenceValue"),l=7,u=Px,p(m))}function p(m){if(m===59&&a){const g=e.exit("characterReferenceValue");return u===Qn&&!Xy(r.sliceSerialize(g))?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 nw={partial:!0,tokenize:UO},rw={concrete:!0,name:"codeFenced",tokenize:FO};function FO(e,t,n){const r=this,a={partial:!0,tokenize:T};let l=0,u=0,c;return d;function d(N){return h(N)}function h(N){const R=r.events[r.events.length-1];return l=R&&R[1].type==="linePrefix"?R[2].sliceSerialize(R[1],!0).length:0,c=N,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),p(N)}function p(N){return N===c?(u++,e.consume(N),p):u<3?n(N):(e.exit("codeFencedFenceSequence"),Ct(N)?Tt(e,m,"whitespace")(N):m(N))}function m(N){return N===null||ot(N)?(e.exit("codeFencedFence"),r.interrupt?t(N):e.check(nw,C,k)(N)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),g(N))}function g(N){return N===null||ot(N)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),m(N)):Ct(N)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),Tt(e,y,"whitespace")(N)):N===96&&N===c?n(N):(e.consume(N),g)}function y(N){return N===null||ot(N)?m(N):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),w(N))}function w(N){return N===null||ot(N)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),m(N)):N===96&&N===c?n(N):(e.consume(N),w)}function C(N){return e.attempt(a,k,_)(N)}function _(N){return e.enter("lineEnding"),e.consume(N),e.exit("lineEnding"),S}function S(N){return l>0&&Ct(N)?Tt(e,b,"linePrefix",l+1)(N):b(N)}function b(N){return N===null||ot(N)?e.check(nw,C,k)(N):(e.enter("codeFlowValue"),v(N))}function v(N){return N===null||ot(N)?(e.exit("codeFlowValue"),b(N)):(e.consume(N),v)}function k(N){return e.exit("codeFenced"),t(N)}function T(N,R,A){let O=0;return P;function P(U){return N.enter("lineEnding"),N.consume(U),N.exit("lineEnding"),V}function V(U){return N.enter("codeFencedFence"),Ct(U)?Tt(N,z,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(U):z(U)}function z(U){return U===c?(N.enter("codeFencedFenceSequence"),W(U)):A(U)}function W(U){return U===c?(O++,N.consume(U),W):O>=u?(N.exit("codeFencedFenceSequence"),Ct(U)?Tt(N,M,"whitespace")(U):M(U)):A(U)}function M(U){return U===null||ot(U)?(N.exit("codeFencedFence"),R(U)):A(U)}}}function UO(e,t,n){const r=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 r.parser.lazy[r.now().line]?n(u):t(u)}}const Cg={name:"codeIndented",tokenize:WO},VO={partial:!0,tokenize:GO};function WO(e,t,n){const r=this;return a;function a(h){return e.enter("codeIndented"),Tt(e,l,"linePrefix",5)(h)}function l(h){const p=r.events[r.events.length-1];return p&&p[1].type==="linePrefix"&&p[2].sliceSerialize(p[1],!0).length>=4?u(h):n(h)}function u(h){return h===null?d(h):ot(h)?e.attempt(VO,u,d)(h):(e.enter("codeFlowValue"),c(h))}function c(h){return h===null||ot(h)?(e.exit("codeFlowValue"),u(h)):(e.consume(h),c)}function d(h){return e.exit("codeIndented"),t(h)}}function GO(e,t,n){const r=this;return a;function a(u){return r.parser.lazy[r.now().line]?n(u):ot(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),a):Tt(e,l,"linePrefix",5)(u)}function l(u){const c=r.events[r.events.length-1];return c&&c[1].type==="linePrefix"&&c[2].sliceSerialize(c[1],!0).length>=4?t(u):ot(u)?a(u):n(u)}}const qO={name:"codeText",previous:YO,resolve:KO,tokenize:XO};function KO(e){let t=e.length-4,n=3,r,a;if((e[n][1].type==="lineEnding"||e[n][1].type==="space")&&(e[t][1].type==="lineEnding"||e[t][1].type==="space")){for(r=n;++r<t;)if(e[r][1].type==="codeTextData"){e[n][1].type="codeTextPadding",e[t][1].type="codeTextPadding",n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)a===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(a=r):(r===t||e[r][1].type==="lineEnding")&&(e[a][1].type="codeTextData",r!==a+2&&(e[a][1].end=e[r-1][1].end,e.splice(a+2,r-a-2),t-=r-a-2,r=a+2),a=void 0);return e}function YO(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function XO(e,t,n){let r=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),r++,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)):ot(m)?(e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),d):(e.enter("codeTextData"),h(m))}function h(m){return m===null||m===32||m===96||ot(m)?(e.exit("codeTextData"),d(m)):(e.consume(m),h)}function p(m){return m===96?(e.consume(m),a++,p):a===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(m)):(l.type="codeTextData",h(m))}}class QO{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const a=n||0;this.setCursor(Math.trunc(t));const l=this.right.splice(this.right.length-a,Number.POSITIVE_INFINITY);return r&&Sc(this.left,r),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),Sc(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Sc(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);Sc(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Sc(this.left,n.reverse())}}}function Sc(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 dj(e){const t={};let n=-1,r,a,l,u,c,d,h;const p=new QO(e);for(;++n<p.length;){for(;n in t;)n=t[n];if(r=p.get(n),n&&r[1].type==="chunkFlow"&&p.get(n-1)[1].type==="listItemPrefix"&&(d=r[1]._tokenizer.events,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(r[0]==="enter")r[1].contentType&&(Object.assign(t,JO(p,n)),n=t[n],h=!0);else if(r[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&&(r[1].end={...p.get(a)[1].start},c=p.slice(a,n),c.unshift(r),p.splice(a,n-a+1,c))}}return Rr(e,0,Number.POSITIVE_INFINITY,p.slice(0)),!h}function JO(e,t){const n=e.get(t)[1],r=e.get(t)[2];let a=t-1;const l=[];let u=n._tokenizer;u||(u=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(u._contentTypeTextTrailing=!0));const c=u.events,d=[],h={};let p,m,g=-1,y=n,w=0,C=0;const _=[C];for(;y;){for(;e.get(++a)[1]!==y;);l.push(a),y._tokenizer||(p=r.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;++g<c.length;)c[g][0]==="exit"&&c[g-1][0]==="enter"&&c[g][1].type===c[g-1][1].type&&c[g][1].start.line!==c[g][1].end.line&&(C=g+1,_.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):_.pop(),g=_.length;g--;){const S=c.slice(_[g],_[g+1]),b=l.pop();d.push([b,b+S.length-1]),e.splice(b,2,S)}for(d.reverse(),g=-1;++g<d.length;)h[w+d[g][0]]=w+d[g][1],w+=d[g][1]-d[g][0]-1;return h}const ZO={resolve:tI,tokenize:nI},eI={partial:!0,tokenize:rI};function tI(e){return dj(e),e}function nI(e,t){let n;return r;function r(c){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),a(c)}function a(c){return c===null?l(c):ot(c)?e.check(eI,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 rI(e,t,n){const r=this;return a;function a(u){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),Tt(e,l,"linePrefix")}function l(u){if(u===null||ot(u))return n(u);const c=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&c&&c[1].type==="linePrefix"&&c[2].sliceSerialize(c[1],!0).length>=4?t(u):e.interrupt(r.parser.constructs.flow,n,t)(u)}}function hj(e,t,n,r,a,l,u,c,d){const h=d||Number.POSITIVE_INFINITY;let p=0;return m;function m(S){return S===60?(e.enter(r),e.enter(a),e.enter(l),e.consume(S),e.exit(l),g):S===null||S===32||S===41||Rh(S)?n(S):(e.enter(r),e.enter(u),e.enter(c),e.enter("chunkString",{contentType:"string"}),C(S))}function g(S){return S===62?(e.enter(l),e.consume(S),e.exit(l),e.exit(a),e.exit(r),t):(e.enter(c),e.enter("chunkString",{contentType:"string"}),y(S))}function y(S){return S===62?(e.exit("chunkString"),e.exit(c),g(S)):S===null||S===60||ot(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||Jt(S))?(e.exit("chunkString"),e.exit(c),e.exit(u),e.exit(r),t(S)):p<h&&S===40?(e.consume(S),p++,C):S===41?(e.consume(S),p--,C):S===null||S===32||S===40||Rh(S)?n(S):(e.consume(S),S===92?_:C)}function _(S){return S===40||S===41||S===92?(e.consume(S),C):C(S)}}function fj(e,t,n,r,a,l){const u=this;let c=0,d;return h;function h(y){return e.enter(r),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(r),t):ot(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||ot(y)||c++>999?(e.exit("chunkString"),p(y)):(e.consume(y),d||(d=!Ct(y)),y===92?g:m)}function g(y){return y===91||y===92||y===93?(e.consume(y),c++,m):m(y)}}function mj(e,t,n,r,a,l){let u;return c;function c(g){return g===34||g===39||g===40?(e.enter(r),e.enter(a),e.consume(g),e.exit(a),u=g===40?41:g,d):n(g)}function d(g){return g===u?(e.enter(a),e.consume(g),e.exit(a),e.exit(r),t):(e.enter(l),h(g))}function h(g){return g===u?(e.exit(l),d(u)):g===null?n(g):ot(g)?(e.enter("lineEnding"),e.consume(g),e.exit("lineEnding"),Tt(e,h,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),p(g))}function p(g){return g===u||g===null||ot(g)?(e.exit("chunkString"),h(g)):(e.consume(g),g===92?m:p)}function m(g){return g===u||g===92?(e.consume(g),p):p(g)}}function $c(e,t){let n;return r;function r(a){return ot(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),n=!0,r):Ct(a)?Tt(e,r,n?"linePrefix":"lineSuffix")(a):t(a)}}const sI={name:"definition",tokenize:aI},iI={partial:!0,tokenize:oI};function aI(e,t,n){const r=this;let a;return l;function l(y){return e.enter("definition"),u(y)}function u(y){return fj.call(r,e,c,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(y)}function c(y){return a=us(r.sliceSerialize(r.events[r.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 Jt(y)?$c(e,h)(y):h(y)}function h(y){return hj(e,p,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(y)}function p(y){return e.attempt(iI,m,m)(y)}function m(y){return Ct(y)?Tt(e,g,"whitespace")(y):g(y)}function g(y){return y===null||ot(y)?(e.exit("definition"),r.parser.defined.push(a),t(y)):n(y)}}function oI(e,t,n){return r;function r(c){return Jt(c)?$c(e,a)(c):n(c)}function a(c){return mj(e,l,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(c)}function l(c){return Ct(c)?Tt(e,u,"whitespace")(c):u(c)}function u(c){return c===null||ot(c)?t(c):n(c)}}const lI={name:"hardBreakEscape",tokenize:cI};function cI(e,t,n){return r;function r(l){return e.enter("hardBreakEscape"),e.consume(l),a}function a(l){return ot(l)?(e.exit("hardBreakEscape"),t(l)):n(l)}}const uI={name:"headingAtx",resolve:dI,tokenize:hI};function dI(e,t){let n=e.length-2,r=3,a,l;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(a={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},l={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},Rr(e,r,n-r+1,[["enter",a,t],["enter",l,t],["exit",l,t],["exit",a,t]])),e}function hI(e,t,n){let r=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&&r++<6?(e.consume(p),u):p===null||Jt(p)?(e.exit("atxHeadingSequence"),c(p)):n(p)}function c(p){return p===35?(e.enter("atxHeadingSequence"),d(p)):p===null||ot(p)?(e.exit("atxHeading"),t(p)):Ct(p)?Tt(e,c,"whitespace")(p):(e.enter("atxHeadingText"),h(p))}function d(p){return p===35?(e.consume(p),d):(e.exit("atxHeadingSequence"),c(p))}function h(p){return p===null||p===35||Jt(p)?(e.exit("atxHeadingText"),c(p)):(e.consume(p),h)}}const fI=["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"],sw=["pre","script","style","textarea"],mI={concrete:!0,name:"htmlFlow",resolveTo:xI,tokenize:yI},pI={partial:!0,tokenize:vI},gI={partial:!0,tokenize:bI};function xI(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 yI(e,t,n){const r=this;let a,l,u,c,d;return h;function h($){return p($)}function p($){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume($),m}function m($){return $===33?(e.consume($),g):$===47?(e.consume($),l=!0,C):$===63?(e.consume($),a=3,r.interrupt?t:I):ir($)?(e.consume($),u=String.fromCharCode($),_):n($)}function g($){return $===45?(e.consume($),a=2,y):$===91?(e.consume($),a=5,c=0,w):ir($)?(e.consume($),a=4,r.interrupt?t:I):n($)}function y($){return $===45?(e.consume($),r.interrupt?t:I):n($)}function w($){const J="CDATA[";return $===J.charCodeAt(c++)?(e.consume($),c===J.length?r.interrupt?t:z:w):n($)}function C($){return ir($)?(e.consume($),u=String.fromCharCode($),_):n($)}function _($){if($===null||$===47||$===62||Jt($)){const J=$===47,Y=u.toLowerCase();return!J&&!l&&sw.includes(Y)?(a=1,r.interrupt?t($):z($)):fI.includes(u.toLowerCase())?(a=6,J?(e.consume($),S):r.interrupt?t($):z($)):(a=7,r.interrupt&&!r.parser.lazy[r.now().line]?n($):l?b($):v($))}return $===45||Qn($)?(e.consume($),u+=String.fromCharCode($),_):n($)}function S($){return $===62?(e.consume($),r.interrupt?t:z):n($)}function b($){return Ct($)?(e.consume($),b):P($)}function v($){return $===47?(e.consume($),P):$===58||$===95||ir($)?(e.consume($),k):Ct($)?(e.consume($),v):P($)}function k($){return $===45||$===46||$===58||$===95||Qn($)?(e.consume($),k):T($)}function T($){return $===61?(e.consume($),N):Ct($)?(e.consume($),T):v($)}function N($){return $===null||$===60||$===61||$===62||$===96?n($):$===34||$===39?(e.consume($),d=$,R):Ct($)?(e.consume($),N):A($)}function R($){return $===d?(e.consume($),d=null,O):$===null||ot($)?n($):(e.consume($),R)}function A($){return $===null||$===34||$===39||$===47||$===60||$===61||$===62||$===96||Jt($)?T($):(e.consume($),A)}function O($){return $===47||$===62||Ct($)?v($):n($)}function P($){return $===62?(e.consume($),V):n($)}function V($){return $===null||ot($)?z($):Ct($)?(e.consume($),V):n($)}function z($){return $===45&&a===2?(e.consume($),F):$===60&&a===1?(e.consume($),Q):$===62&&a===4?(e.consume($),D):$===63&&a===3?(e.consume($),I):$===93&&a===5?(e.consume($),H):ot($)&&(a===6||a===7)?(e.exit("htmlFlowData"),e.check(pI,q,W)($)):$===null||ot($)?(e.exit("htmlFlowData"),W($)):(e.consume($),z)}function W($){return e.check(gI,M,q)($)}function M($){return e.enter("lineEnding"),e.consume($),e.exit("lineEnding"),U}function U($){return $===null||ot($)?W($):(e.enter("htmlFlowData"),z($))}function F($){return $===45?(e.consume($),I):z($)}function Q($){return $===47?(e.consume($),u="",X):z($)}function X($){if($===62){const J=u.toLowerCase();return sw.includes(J)?(e.consume($),D):z($)}return ir($)&&u.length<8?(e.consume($),u+=String.fromCharCode($),X):z($)}function H($){return $===93?(e.consume($),I):z($)}function I($){return $===62?(e.consume($),D):$===45&&a===2?(e.consume($),I):z($)}function D($){return $===null||ot($)?(e.exit("htmlFlowData"),q($)):(e.consume($),D)}function q($){return e.exit("htmlFlow"),t($)}}function bI(e,t,n){const r=this;return a;function a(u){return ot(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),l):n(u)}function l(u){return r.parser.lazy[r.now().line]?n(u):t(u)}}function vI(e,t,n){return r;function r(a){return e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),e.attempt(mu,t,n)}}const _I={name:"htmlText",tokenize:SI};function SI(e,t,n){const r=this;let a,l,u;return c;function c(I){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(I),d}function d(I){return I===33?(e.consume(I),h):I===47?(e.consume(I),T):I===63?(e.consume(I),v):ir(I)?(e.consume(I),A):n(I)}function h(I){return I===45?(e.consume(I),p):I===91?(e.consume(I),l=0,w):ir(I)?(e.consume(I),b):n(I)}function p(I){return I===45?(e.consume(I),y):n(I)}function m(I){return I===null?n(I):I===45?(e.consume(I),g):ot(I)?(u=m,Q(I)):(e.consume(I),m)}function g(I){return I===45?(e.consume(I),y):m(I)}function y(I){return I===62?F(I):I===45?g(I):m(I)}function w(I){const D="CDATA[";return I===D.charCodeAt(l++)?(e.consume(I),l===D.length?C:w):n(I)}function C(I){return I===null?n(I):I===93?(e.consume(I),_):ot(I)?(u=C,Q(I)):(e.consume(I),C)}function _(I){return I===93?(e.consume(I),S):C(I)}function S(I){return I===62?F(I):I===93?(e.consume(I),S):C(I)}function b(I){return I===null||I===62?F(I):ot(I)?(u=b,Q(I)):(e.consume(I),b)}function v(I){return I===null?n(I):I===63?(e.consume(I),k):ot(I)?(u=v,Q(I)):(e.consume(I),v)}function k(I){return I===62?F(I):v(I)}function T(I){return ir(I)?(e.consume(I),N):n(I)}function N(I){return I===45||Qn(I)?(e.consume(I),N):R(I)}function R(I){return ot(I)?(u=R,Q(I)):Ct(I)?(e.consume(I),R):F(I)}function A(I){return I===45||Qn(I)?(e.consume(I),A):I===47||I===62||Jt(I)?O(I):n(I)}function O(I){return I===47?(e.consume(I),F):I===58||I===95||ir(I)?(e.consume(I),P):ot(I)?(u=O,Q(I)):Ct(I)?(e.consume(I),O):F(I)}function P(I){return I===45||I===46||I===58||I===95||Qn(I)?(e.consume(I),P):V(I)}function V(I){return I===61?(e.consume(I),z):ot(I)?(u=V,Q(I)):Ct(I)?(e.consume(I),V):O(I)}function z(I){return I===null||I===60||I===61||I===62||I===96?n(I):I===34||I===39?(e.consume(I),a=I,W):ot(I)?(u=z,Q(I)):Ct(I)?(e.consume(I),z):(e.consume(I),M)}function W(I){return I===a?(e.consume(I),a=void 0,U):I===null?n(I):ot(I)?(u=W,Q(I)):(e.consume(I),W)}function M(I){return I===null||I===34||I===39||I===60||I===61||I===96?n(I):I===47||I===62||Jt(I)?O(I):(e.consume(I),M)}function U(I){return I===47||I===62||Jt(I)?O(I):n(I)}function F(I){return I===62?(e.consume(I),e.exit("htmlTextData"),e.exit("htmlText"),t):n(I)}function Q(I){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(I),e.exit("lineEnding"),X}function X(I){return Ct(I)?Tt(e,H,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(I):H(I)}function H(I){return e.enter("htmlTextData"),u(I)}}const Qy={name:"labelEnd",resolveAll:EI,resolveTo:jI,tokenize:NI},wI={tokenize:TI},CI={tokenize:AI},kI={tokenize:LI};function EI(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const a=r.type==="labelImage"?4:2;r.type="data",t+=a}}return e.length!==n.length&&Rr(e,0,e.length,n),e}function jI(e,t){let n=e.length,r=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")){r=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}},h={type:"label",start:{...e[l][1].start},end:{...e[u][1].end}},p={type:"labelText",start:{...e[l+r+2][1].end},end:{...e[u-2][1].start}};return c=[["enter",d,t],["enter",h,t]],c=Wr(c,e.slice(l+1,l+r+3)),c=Wr(c,[["enter",p,t]]),c=Wr(c,wf(t.parser.constructs.insideSpan.null,e.slice(l+r+4,u-3),t)),c=Wr(c,[["exit",p,t],e[u-2],e[u-1],["exit",h,t]]),c=Wr(c,e.slice(u+1)),c=Wr(c,[["exit",d,t]]),Rr(e,l,e.length,c),e}function NI(e,t,n){const r=this;let a=r.events.length,l,u;for(;a--;)if((r.events[a][1].type==="labelImage"||r.events[a][1].type==="labelLink")&&!r.events[a][1]._balanced){l=r.events[a][1];break}return c;function c(g){return l?l._inactive?m(g):(u=r.parser.defined.includes(us(r.sliceSerialize({start:l.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(g),e.exit("labelMarker"),e.exit("labelEnd"),d):n(g)}function d(g){return g===40?e.attempt(wI,p,u?p:m)(g):g===91?e.attempt(CI,p,u?h:m)(g):u?p(g):m(g)}function h(g){return e.attempt(kI,p,m)(g)}function p(g){return t(g)}function m(g){return l._balanced=!0,n(g)}}function TI(e,t,n){return r;function r(m){return e.enter("resource"),e.enter("resourceMarker"),e.consume(m),e.exit("resourceMarker"),a}function a(m){return Jt(m)?$c(e,l)(m):l(m)}function l(m){return m===41?p(m):hj(e,u,c,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(m)}function u(m){return Jt(m)?$c(e,d)(m):p(m)}function c(m){return n(m)}function d(m){return m===34||m===39||m===40?mj(e,h,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(m):p(m)}function h(m){return Jt(m)?$c(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 AI(e,t,n){const r=this;return a;function a(c){return fj.call(r,e,l,u,"reference","referenceMarker","referenceString")(c)}function l(c){return r.parser.defined.includes(us(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(c):n(c)}function u(c){return n(c)}}function LI(e,t,n){return r;function r(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 RI={name:"labelStartImage",resolveAll:Qy.resolveAll,tokenize:DI};function DI(e,t,n){const r=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 r.parser.constructs?n(c):t(c)}}const OI={name:"labelStartLink",resolveAll:Qy.resolveAll,tokenize:II};function II(e,t,n){const r=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 r.parser.constructs?n(u):t(u)}}const kg={name:"lineEnding",tokenize:MI};function MI(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),Tt(e,t,"linePrefix")}}const yh={name:"thematicBreak",tokenize:PI};function PI(e,t,n){let r=0,a;return l;function l(h){return e.enter("thematicBreak"),u(h)}function u(h){return a=h,c(h)}function c(h){return h===a?(e.enter("thematicBreakSequence"),d(h)):r>=3&&(h===null||ot(h))?(e.exit("thematicBreak"),t(h)):n(h)}function d(h){return h===a?(e.consume(h),r++,d):(e.exit("thematicBreakSequence"),Ct(h)?Tt(e,c,"whitespace")(h):c(h))}}const hr={continuation:{tokenize:HI},exit:UI,name:"list",tokenize:zI},BI={partial:!0,tokenize:VI},$I={partial:!0,tokenize:FI};function zI(e,t,n){const r=this,a=r.events[r.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=r.containerState.type||(y===42||y===43||y===45?"listUnordered":"listOrdered");if(w==="listUnordered"?!r.containerState.marker||y===r.containerState.marker:Px(y)){if(r.containerState.type||(r.containerState.type=w,e.enter(w,{_container:!0})),w==="listUnordered")return e.enter("listItemPrefix"),y===42||y===45?e.check(yh,n,h)(y):h(y);if(!r.interrupt||y===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),d(y)}return n(y)}function d(y){return Px(y)&&++u<10?(e.consume(y),d):(!r.interrupt||u<2)&&(r.containerState.marker?y===r.containerState.marker:y===41||y===46)?(e.exit("listItemValue"),h(y)):n(y)}function h(y){return e.enter("listItemMarker"),e.consume(y),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||y,e.check(mu,r.interrupt?n:p,e.attempt(BI,g,m))}function p(y){return r.containerState.initialBlankLine=!0,l++,g(y)}function m(y){return Ct(y)?(e.enter("listItemPrefixWhitespace"),e.consume(y),e.exit("listItemPrefixWhitespace"),g):n(y)}function g(y){return r.containerState.size=l+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(y)}}function HI(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(mu,a,l);function a(c){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,Tt(e,t,"listItemIndent",r.containerState.size+1)(c)}function l(c){return r.containerState.furtherBlankLines||!Ct(c)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,u(c)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt($I,t,u)(c))}function u(c){return r.containerState._closeFlow=!0,r.interrupt=void 0,Tt(e,e.attempt(hr,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(c)}}function FI(e,t,n){const r=this;return Tt(e,a,"listItemIndent",r.containerState.size+1);function a(l){const u=r.events[r.events.length-1];return u&&u[1].type==="listItemIndent"&&u[2].sliceSerialize(u[1],!0).length===r.containerState.size?t(l):n(l)}}function UI(e){e.exit(this.containerState.type)}function VI(e,t,n){const r=this;return Tt(e,a,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function a(l){const u=r.events[r.events.length-1];return!Ct(l)&&u&&u[1].type==="listItemPrefixWhitespace"?t(l):n(l)}}const iw={name:"setextUnderline",resolveTo:WI,tokenize:GI};function WI(e,t){let n=e.length,r,a,l;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(a=n)}else e[n][1].type==="content"&&e.splice(n,1),!l&&e[n][1].type==="definition"&&(l=n);const u={type:"setextHeading",start:{...e[r][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[r][1],t]),e[r][1].end={...e[l][1].end}):e[r][1]=u,e.push(["exit",u,t]),e}function GI(e,t,n){const r=this;let a;return l;function l(h){let p=r.events.length,m;for(;p--;)if(r.events[p][1].type!=="lineEnding"&&r.events[p][1].type!=="linePrefix"&&r.events[p][1].type!=="content"){m=r.events[p][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||m)?(e.enter("setextHeadingLine"),a=h,u(h)):n(h)}function u(h){return e.enter("setextHeadingLineSequence"),c(h)}function c(h){return h===a?(e.consume(h),c):(e.exit("setextHeadingLineSequence"),Ct(h)?Tt(e,d,"lineSuffix")(h):d(h))}function d(h){return h===null||ot(h)?(e.exit("setextHeadingLine"),t(h)):n(h)}}const qI={tokenize:KI};function KI(e){const t=this,n=e.attempt(mu,r,e.attempt(this.parser.constructs.flowInitial,a,Tt(e,e.attempt(this.parser.constructs.flow,a,e.attempt(ZO,a)),"linePrefix")));return n;function r(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 YI={resolveAll:gj()},XI=pj("string"),QI=pj("text");function pj(e){return{resolveAll:gj(e==="text"?JI:void 0),tokenize:t};function t(n){const r=this,a=this.parser.constructs[e],l=n.attempt(a,u,c);return u;function u(p){return h(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 h(p)?(n.exit("data"),l(p)):(n.consume(p),d)}function h(p){if(p===null)return!0;const m=a[p];let g=-1;if(m)for(;++g<m.length;){const y=m[g];if(!y.previous||y.previous.call(r,r.previous))return!0}return!1}}}function gj(e){return t;function t(n,r){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,r):n}}function JI(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type==="lineEnding")&&e[n-1][1].type==="data"){const r=e[n-1][1],a=t.sliceStream(r);let l=a.length,u=-1,c=0,d;for(;l--;){const h=a[l];if(typeof h=="string"){for(u=h.length;h.charCodeAt(u-1)===32;)c++,u--;if(u)break;u=-1}else if(h===-2)d=!0,c++;else if(h!==-1){l++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(c=0),c){const h={type:n===e.length||d||c<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:l?u:r.start._bufferIndex+u,_index:r.start._index+l,line:r.end.line,column:r.end.column-c,offset:r.end.offset-c},end:{...r.end}};r.end={...h.start},r.start.offset===r.end.offset?Object.assign(r,h):(e.splice(n,0,["enter",h,t],["exit",h,t]),n+=2)}n++}return e}const ZI={42:hr,43:hr,45:hr,48:hr,49:hr,50:hr,51:hr,52:hr,53:hr,54:hr,55:hr,56:hr,57:hr,62:lj},eM={91:sI},tM={[-2]:Cg,[-1]:Cg,32:Cg},nM={35:uI,42:yh,45:[iw,yh],60:mI,61:iw,95:yh,96:rw,126:rw},rM={38:uj,92:cj},sM={[-5]:kg,[-4]:kg,[-3]:kg,33:RI,38:uj,42:Bx,60:[OO,_I],91:OI,92:[lI,cj],93:Qy,95:Bx,96:qO},iM={null:[Bx,YI]},aM={null:[42,95]},oM={null:[]},lM=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:aM,contentInitial:eM,disable:oM,document:ZI,flow:nM,flowInitial:tM,insideSpan:iM,string:rM,text:sM},Symbol.toStringTag,{value:"Module"}));function cM(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const a={},l=[];let u=[],c=[];const d={attempt:R(T),check:R(N),consume:b,enter:v,exit:k,interrupt:R(N,{interrupt:!0})},h={code:null,containerState:{},defineSkip:C,events:[],now:w,parser:e,previous:null,sliceSerialize:g,sliceStream:y,write:m};let p=t.tokenize.call(h,d);return t.resolveAll&&l.push(t),h;function m(V){return u=Wr(u,V),_(),u[u.length-1]!==null?[]:(A(t,0),h.events=wf(l,h.events,h),h.events)}function g(V,z){return dM(y(V),z)}function y(V){return uM(u,V)}function w(){const{_bufferIndex:V,_index:z,line:W,column:M,offset:U}=r;return{_bufferIndex:V,_index:z,line:W,column:M,offset:U}}function C(V){a[V.line]=V.column,P()}function _(){let V;for(;r._index<u.length;){const z=u[r._index];if(typeof z=="string")for(V=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===V&&r._bufferIndex<z.length;)S(z.charCodeAt(r._bufferIndex));else S(z)}}function S(V){p=p(V)}function b(V){ot(V)?(r.line++,r.column=1,r.offset+=V===-3?2:1,P()):V!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===u[r._index].length&&(r._bufferIndex=-1,r._index++)),h.previous=V}function v(V,z){const W=z||{};return W.type=V,W.start=w(),h.events.push(["enter",W,h]),c.push(W),W}function k(V){const z=c.pop();return z.end=w(),h.events.push(["exit",z,h]),z}function T(V,z){A(V,z.from)}function N(V,z){z.restore()}function R(V,z){return W;function W(M,U,F){let Q,X,H,I;return Array.isArray(M)?q(M):"tokenize"in M?q([M]):D(M);function D(Z){return K;function K(B){const ne=B!==null&&Z[B],se=B!==null&&Z.null,re=[...Array.isArray(ne)?ne:ne?[ne]:[],...Array.isArray(se)?se:se?[se]:[]];return q(re)(B)}}function q(Z){return Q=Z,X=0,Z.length===0?F:$(Z[X])}function $(Z){return K;function K(B){return I=O(),H=Z,Z.partial||(h.currentConstruct=Z),Z.name&&h.parser.constructs.disable.null.includes(Z.name)?Y():Z.tokenize.call(z?Object.assign(Object.create(h),z):h,d,J,Y)(B)}}function J(Z){return V(H,I),U}function Y(Z){return I.restore(),++X<Q.length?$(Q[X]):F}}}function A(V,z){V.resolveAll&&!l.includes(V)&&l.push(V),V.resolve&&Rr(h.events,z,h.events.length-z,V.resolve(h.events.slice(z),h)),V.resolveTo&&(h.events=V.resolveTo(h.events,h))}function O(){const V=w(),z=h.previous,W=h.currentConstruct,M=h.events.length,U=Array.from(c);return{from:M,restore:F};function F(){r=V,h.previous=z,h.currentConstruct=W,h.events.length=M,c=U,P()}}function P(){r.line in a&&r.column<2&&(r.column=a[r.line],r.offset+=a[r.line]-1)}}function uM(e,t){const n=t.start._index,r=t.start._bufferIndex,a=t.end._index,l=t.end._bufferIndex;let u;if(n===a)u=[e[n].slice(r,l)];else{if(u=e.slice(n,a),r>-1){const c=u[0];typeof c=="string"?u[0]=c.slice(r):u.shift()}l>0&&u.push(e[a].slice(0,l))}return u}function dM(e,t){let n=-1;const r=[];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=`
69
+ `;break}case-3:{u=`\r
70
+ `;break}case-2:{u=t?" ":" ";break}case-1:{if(!t&&a)continue;u=" ";break}default:u=String.fromCharCode(l)}a=l===-2,r.push(u)}return r.join("")}function hM(e){const r={constructs:aj([lM,...(e||{}).extensions||[]]),content:a(jO),defined:[],document:a(TO),flow:a(qI),lazy:{},string:a(XI),text:a(QI)};return r;function a(l){return u;function u(c){return cM(r,l,c)}}}function fM(e){for(;!dj(e););return e}const aw=/[\0\t\n\r]/g;function mM(){let e=1,t="",n=!0,r;return a;function a(l,u,c){const d=[];let h,p,m,g,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(aw.lastIndex=m,h=aw.exec(l),g=h&&h.index!==void 0?h.index:l.length,y=l.charCodeAt(g),!h){t=l.slice(m);break}if(y===10&&m===g&&r)d.push(-3),r=void 0;else switch(r&&(d.push(-5),r=void 0),m<g&&(d.push(l.slice(m,g)),e+=g-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:r=!0,e=1}m=g+1}return c&&(r&&d.push(-5),t&&d.push(t),d.push(null)),d}}const pM=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function gM(e){return e.replace(pM,xM)}function xM(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const a=n.charCodeAt(1),l=a===120||a===88;return oj(n.slice(l?2:1),l?16:10)}return Xy(n)||e}const xj={}.hasOwnProperty;function yM(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),bM(n)(fM(hM(n).document().write(mM()(e,t,!0))))}function bM(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:l(Je),autolinkProtocol:O,autolinkEmail:O,atxHeading:l($e),blockQuote:l(se),characterEscape:O,characterReference:O,codeFenced:l(re),codeFencedFenceInfo:u,codeFencedFenceMeta:u,codeIndented:l(re,u),codeText:l(oe,u),codeTextData:O,data:O,codeFlowValue:O,definition:l(ve),definitionDestinationString:u,definitionLabelString:u,definitionTitleString:u,emphasis:l(Se),hardBreakEscape:l(ze),hardBreakTrailing:l(ze),htmlFlow:l(ke,u),htmlFlowData:O,htmlText:l(ke,u),htmlTextData:O,image:l(Ge),label:u,link:l(Je),listItem:l(me),listItemValue:g,listOrdered:l(Ce,m),listUnordered:l(Ce),paragraph:l(We),reference:$,referenceString:u,resourceDestinationString:u,resourceTitleString:u,setextHeading:l($e),strong:l(he),thematicBreak:l(He)},exit:{atxHeading:d(),atxHeadingSequence:T,autolink:d(),autolinkEmail:ne,autolinkProtocol:B,blockQuote:d(),characterEscapeValue:P,characterReferenceMarkerHexadecimal:Y,characterReferenceMarkerNumeric:Y,characterReferenceValue:Z,characterReference:K,codeFenced:d(_),codeFencedFence:C,codeFencedFenceInfo:y,codeFencedFenceMeta:w,codeFlowValue:P,codeIndented:d(S),codeText:d(U),codeTextData:P,data:P,definition:d(),definitionDestinationString:k,definitionLabelString:b,definitionTitleString:v,emphasis:d(),hardBreakEscape:d(z),hardBreakTrailing:d(z),htmlFlow:d(W),htmlFlowData:P,htmlText:d(M),htmlTextData:P,image:d(Q),label:H,labelText:X,lineEnding:V,link:d(F),listItem:d(),listOrdered:d(),listUnordered:d(),paragraph:d(),referenceString:J,resourceDestinationString:I,resourceTitleString:D,resource:q,setextHeading:d(A),setextHeadingLineSequence:R,setextHeadingText:N,strong:d(),thematicBreak:d()}};yj(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(ie){let ye={type:"root",children:[]};const Le={stack:[ye],tokenStack:[],config:t,enter:c,exit:h,buffer:u,resume:p,data:n},ue=[];let de=-1;for(;++de<ie.length;)if(ie[de][1].type==="listOrdered"||ie[de][1].type==="listUnordered")if(ie[de][0]==="enter")ue.push(de);else{const Fe=ue.pop();de=a(ie,Fe,de)}for(de=-1;++de<ie.length;){const Fe=t[ie[de][0]];xj.call(Fe,ie[de][1].type)&&Fe[ie[de][1].type].call(Object.assign({sliceSerialize:ie[de][2].sliceSerialize},Le),ie[de][1])}if(Le.tokenStack.length>0){const Fe=Le.tokenStack[Le.tokenStack.length-1];(Fe[1]||ow).call(Le,void 0,Fe[0])}for(ye.position={start:Ii(ie.length>0?ie[0][1].start:{line:1,column:1,offset:0}),end:Ii(ie.length>0?ie[ie.length-2][1].end:{line:1,column:1,offset:0})},de=-1;++de<t.transforms.length;)ye=t.transforms[de](ye)||ye;return ye}function a(ie,ye,Le){let ue=ye-1,de=-1,Fe=!1,Ue,Qe,rt,pe;for(;++ue<=Le;){const Ie=ie[ue];switch(Ie[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{Ie[0]==="enter"?de++:de--,pe=void 0;break}case"lineEndingBlank":{Ie[0]==="enter"&&(Ue&&!pe&&!de&&!rt&&(rt=ue),pe=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:pe=void 0}if(!de&&Ie[0]==="enter"&&Ie[1].type==="listItemPrefix"||de===-1&&Ie[0]==="exit"&&(Ie[1].type==="listUnordered"||Ie[1].type==="listOrdered")){if(Ue){let it=ue;for(Qe=void 0;it--;){const ut=ie[it];if(ut[1].type==="lineEnding"||ut[1].type==="lineEndingBlank"){if(ut[0]==="exit")continue;Qe&&(ie[Qe][1].type="lineEndingBlank",Fe=!0),ut[1].type="lineEnding",Qe=it}else if(!(ut[1].type==="linePrefix"||ut[1].type==="blockQuotePrefix"||ut[1].type==="blockQuotePrefixWhitespace"||ut[1].type==="blockQuoteMarker"||ut[1].type==="listItemIndent"))break}rt&&(!Qe||rt<Qe)&&(Ue._spread=!0),Ue.end=Object.assign({},Qe?ie[Qe][1].start:Ie[1].end),ie.splice(Qe||ue,0,["exit",Ue,Ie[2]]),ue++,Le++}if(Ie[1].type==="listItemPrefix"){const it={type:"listItem",_spread:!1,start:Object.assign({},Ie[1].start),end:void 0};Ue=it,ie.splice(ue,0,["enter",it,Ie[2]]),ue++,Le++,rt=void 0,pe=!0}}}return ie[ye][1]._spread=Fe,Le}function l(ie,ye){return Le;function Le(ue){c.call(this,ie(ue),ue),ye&&ye.call(this,ue)}}function u(){this.stack.push({type:"fragment",children:[]})}function c(ie,ye,Le){this.stack[this.stack.length-1].children.push(ie),this.stack.push(ie),this.tokenStack.push([ye,Le||void 0]),ie.position={start:Ii(ye.start),end:void 0}}function d(ie){return ye;function ye(Le){ie&&ie.call(this,Le),h.call(this,Le)}}function h(ie,ye){const Le=this.stack.pop(),ue=this.tokenStack.pop();if(ue)ue[0].type!==ie.type&&(ye?ye.call(this,ie,ue[0]):(ue[1]||ow).call(this,ie,ue[0]));else throw new Error("Cannot close `"+ie.type+"` ("+Bc({start:ie.start,end:ie.end})+"): it’s not open");Le.position.end=Ii(ie.end)}function p(){return Yy(this.stack.pop())}function m(){this.data.expectingFirstListItemValue=!0}function g(ie){if(this.data.expectingFirstListItemValue){const ye=this.stack[this.stack.length-2];ye.start=Number.parseInt(this.sliceSerialize(ie),10),this.data.expectingFirstListItemValue=void 0}}function y(){const ie=this.resume(),ye=this.stack[this.stack.length-1];ye.lang=ie}function w(){const ie=this.resume(),ye=this.stack[this.stack.length-1];ye.meta=ie}function C(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function _(){const ie=this.resume(),ye=this.stack[this.stack.length-1];ye.value=ie.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function S(){const ie=this.resume(),ye=this.stack[this.stack.length-1];ye.value=ie.replace(/(\r?\n|\r)$/g,"")}function b(ie){const ye=this.resume(),Le=this.stack[this.stack.length-1];Le.label=ye,Le.identifier=us(this.sliceSerialize(ie)).toLowerCase()}function v(){const ie=this.resume(),ye=this.stack[this.stack.length-1];ye.title=ie}function k(){const ie=this.resume(),ye=this.stack[this.stack.length-1];ye.url=ie}function T(ie){const ye=this.stack[this.stack.length-1];if(!ye.depth){const Le=this.sliceSerialize(ie).length;ye.depth=Le}}function N(){this.data.setextHeadingSlurpLineEnding=!0}function R(ie){const ye=this.stack[this.stack.length-1];ye.depth=this.sliceSerialize(ie).codePointAt(0)===61?1:2}function A(){this.data.setextHeadingSlurpLineEnding=void 0}function O(ie){const Le=this.stack[this.stack.length-1].children;let ue=Le[Le.length-1];(!ue||ue.type!=="text")&&(ue=Ve(),ue.position={start:Ii(ie.start),end:void 0},Le.push(ue)),this.stack.push(ue)}function P(ie){const ye=this.stack.pop();ye.value+=this.sliceSerialize(ie),ye.position.end=Ii(ie.end)}function V(ie){const ye=this.stack[this.stack.length-1];if(this.data.atHardBreak){const Le=ye.children[ye.children.length-1];Le.position.end=Ii(ie.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(ye.type)&&(O.call(this,ie),P.call(this,ie))}function z(){this.data.atHardBreak=!0}function W(){const ie=this.resume(),ye=this.stack[this.stack.length-1];ye.value=ie}function M(){const ie=this.resume(),ye=this.stack[this.stack.length-1];ye.value=ie}function U(){const ie=this.resume(),ye=this.stack[this.stack.length-1];ye.value=ie}function F(){const ie=this.stack[this.stack.length-1];if(this.data.inReference){const ye=this.data.referenceType||"shortcut";ie.type+="Reference",ie.referenceType=ye,delete ie.url,delete ie.title}else delete ie.identifier,delete ie.label;this.data.referenceType=void 0}function Q(){const ie=this.stack[this.stack.length-1];if(this.data.inReference){const ye=this.data.referenceType||"shortcut";ie.type+="Reference",ie.referenceType=ye,delete ie.url,delete ie.title}else delete ie.identifier,delete ie.label;this.data.referenceType=void 0}function X(ie){const ye=this.sliceSerialize(ie),Le=this.stack[this.stack.length-2];Le.label=gM(ye),Le.identifier=us(ye).toLowerCase()}function H(){const ie=this.stack[this.stack.length-1],ye=this.resume(),Le=this.stack[this.stack.length-1];if(this.data.inReference=!0,Le.type==="link"){const ue=ie.children;Le.children=ue}else Le.alt=ye}function I(){const ie=this.resume(),ye=this.stack[this.stack.length-1];ye.url=ie}function D(){const ie=this.resume(),ye=this.stack[this.stack.length-1];ye.title=ie}function q(){this.data.inReference=void 0}function $(){this.data.referenceType="collapsed"}function J(ie){const ye=this.resume(),Le=this.stack[this.stack.length-1];Le.label=ye,Le.identifier=us(this.sliceSerialize(ie)).toLowerCase(),this.data.referenceType="full"}function Y(ie){this.data.characterReferenceType=ie.type}function Z(ie){const ye=this.sliceSerialize(ie),Le=this.data.characterReferenceType;let ue;Le?(ue=oj(ye,Le==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):ue=Xy(ye);const de=this.stack[this.stack.length-1];de.value+=ue}function K(ie){const ye=this.stack.pop();ye.position.end=Ii(ie.end)}function B(ie){P.call(this,ie);const ye=this.stack[this.stack.length-1];ye.url=this.sliceSerialize(ie)}function ne(ie){P.call(this,ie);const ye=this.stack[this.stack.length-1];ye.url="mailto:"+this.sliceSerialize(ie)}function se(){return{type:"blockquote",children:[]}}function re(){return{type:"code",lang:null,meta:null,value:""}}function oe(){return{type:"inlineCode",value:""}}function ve(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function Se(){return{type:"emphasis",children:[]}}function $e(){return{type:"heading",depth:0,children:[]}}function ze(){return{type:"break"}}function ke(){return{type:"html",value:""}}function Ge(){return{type:"image",title:null,url:"",alt:null}}function Je(){return{type:"link",title:null,url:"",children:[]}}function Ce(ie){return{type:"list",ordered:ie.type==="listOrdered",start:null,spread:ie._spread,children:[]}}function me(ie){return{type:"listItem",spread:ie._spread,checked:null,children:[]}}function We(){return{type:"paragraph",children:[]}}function he(){return{type:"strong",children:[]}}function Ve(){return{type:"text",value:""}}function He(){return{type:"thematicBreak"}}}function Ii(e){return{line:e.line,column:e.column,offset:e.offset}}function yj(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?yj(e,r):vM(e,r)}}function vM(e,t){let n;for(n in t)if(xj.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function ow(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Bc({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Bc({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Bc({start:t.start,end:t.end})+") is still open")}function _M(e){const t=this;t.parser=n;function n(r){return yM(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function SM(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 wM(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
71
+ `}]}function CM(e,t){const n=t.value?t.value+`
72
+ `:"",r={},a=t.lang?t.lang.split(/\s+/):[];a.length>0&&(r.className=["language-"+a[0]]);let l={type:"element",tagName:"code",properties:r,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 kM(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function EM(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function jM(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),a=bl(r.toLowerCase()),l=e.footnoteOrder.indexOf(r);let u,c=e.footnoteCounts.get(r);c===void 0?(c=0,e.footnoteOrder.push(r),u=e.footnoteOrder.length):u=l+1,c+=1,e.footnoteCounts.set(r,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 h={type:"element",tagName:"sup",properties:{},children:[d]};return e.patch(t,h),e.applyData(t,h)}function NM(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 TM(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function bj(e,t){const n=t.referenceType;let r="]";if(n==="collapsed"?r+="[]":n==="full"&&(r+="["+(t.label||t.identifier)+"]"),t.type==="imageReference")return[{type:"text",value:"!["+t.alt+r}];const a=e.all(t),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+=r:a.push({type:"text",value:r}),a}function AM(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return bj(e,t);const a={src:bl(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(a.title=r.title);const l={type:"element",tagName:"img",properties:a,children:[]};return e.patch(t,l),e.applyData(t,l)}function LM(e,t){const n={src:bl(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function RM(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function DM(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return bj(e,t);const a={href:bl(r.url||"")};r.title!==null&&r.title!==void 0&&(a.title=r.title);const l={type:"element",tagName:"a",properties:a,children:e.all(t)};return e.patch(t,l),e.applyData(t,l)}function OM(e,t){const n={href:bl(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);const r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function IM(e,t,n){const r=e.all(t),a=n?MM(n):vj(t),l={},u=[];if(typeof t.checked=="boolean"){const p=r[0];let m;p&&p.type==="element"&&p.tagName==="p"?m=p:(m={type:"element",tagName:"p",properties:{},children:[]},r.unshift(m)),m.children.length>0&&m.children.unshift({type:"text",value:" "}),m.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),l.className=["task-list-item"]}let c=-1;for(;++c<r.length;){const p=r[c];(a||c!==0||p.type!=="element"||p.tagName!=="p")&&u.push({type:"text",value:`
73
+ `}),p.type==="element"&&p.tagName==="p"&&!a?u.push(...p.children):u.push(p)}const d=r[r.length-1];d&&(a||d.type!=="element"||d.tagName!=="p")&&u.push({type:"text",value:`
74
+ `});const h={type:"element",tagName:"li",properties:l,children:u};return e.patch(t,h),e.applyData(t,h)}function MM(e){let t=!1;if(e.type==="list"){t=e.spread||!1;const n=e.children;let r=-1;for(;!t&&++r<n.length;)t=vj(n[r])}return t}function vj(e){const t=e.spread;return t??e.children.length>1}function PM(e,t){const n={},r=e.all(t);let a=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++a<r.length;){const u=r[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(r,!0)};return e.patch(t,l),e.applyData(t,l)}function BM(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function $M(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function zM(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function HM(e,t){const n=e.all(t),r=n.shift(),a=[];if(r){const u={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!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=Wy(t.children[1]),d=ZE(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 FM(e,t,n){const r=n?n.children:void 0,l=(r?r.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 h=[];for(;++d<c;){const m=t.children[d],g={},y=u?u[d]:void 0;y&&(g.align=y);let w={type:"element",tagName:l,properties:g,children:[]};m&&(w.children=e.all(m),e.patch(m,w),w=e.applyData(m,w)),h.push(w)}const p={type:"element",tagName:"tr",properties:{},children:e.wrap(h,!0)};return e.patch(t,p),e.applyData(t,p)}function UM(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const lw=9,cw=32;function VM(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),a=0;const l=[];for(;r;)l.push(uw(t.slice(a,r.index),a>0,!0),r[0]),a=r.index+r[0].length,r=n.exec(t);return l.push(uw(t.slice(a),a>0,!1)),l.join("")}function uw(e,t,n){let r=0,a=e.length;if(t){let l=e.codePointAt(r);for(;l===lw||l===cw;)r++,l=e.codePointAt(r)}if(n){let l=e.codePointAt(a-1);for(;l===lw||l===cw;)a--,l=e.codePointAt(a-1)}return a>r?e.slice(r,a):""}function WM(e,t){const n={type:"text",value:VM(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function GM(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const qM={blockquote:SM,break:wM,code:CM,delete:kM,emphasis:EM,footnoteReference:jM,heading:NM,html:TM,imageReference:AM,image:LM,inlineCode:RM,linkReference:DM,link:OM,listItem:IM,list:PM,paragraph:BM,root:$M,strong:zM,table:HM,tableCell:UM,tableRow:FM,text:WM,thematicBreak:GM,toml:Hd,yaml:Hd,definition:Hd,footnoteDefinition:Hd};function Hd(){}const _j=-1,Cf=0,zc=1,Dh=2,Jy=3,Zy=4,eb=5,tb=6,Sj=7,wj=8,Cj=typeof self=="object"?self:globalThis,dw=(e,t)=>{switch(e){case"Function":case"SharedWorker":case"Worker":case"eval":case"setInterval":case"setTimeout":throw new TypeError("unable to deserialize "+e)}return new Cj[e](t)},KM=(e,t)=>{const n=(a,l)=>(e.set(l,a),a),r=a=>{if(e.has(a))return e.get(a);const[l,u]=t[a];switch(l){case Cf:case _j:return n(u,a);case zc:{const c=n([],a);for(const d of u)c.push(r(d));return c}case Dh:{const c=n({},a);for(const[d,h]of u)c[r(d)]=r(h);return c}case Jy:return n(new Date(u),a);case Zy:{const{source:c,flags:d}=u;return n(new RegExp(c,d),a)}case eb:{const c=n(new Map,a);for(const[d,h]of u)c.set(r(d),r(h));return c}case tb:{const c=n(new Set,a);for(const d of u)c.add(r(d));return c}case Sj:{const{name:c,message:d}=u;return n(typeof Cj[c]=="function"?dw(c,d):new Error(d),a)}case wj: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(dw(l,u),a)};return r},hw=e=>KM(new Map,e)(0),Aa="",{toString:YM}={},{keys:XM}=Object,wc=e=>{const t=typeof e;if(t!=="object"||!e)return[Cf,t];const n=YM.call(e).slice(8,-1);switch(n){case"Array":return[zc,Aa];case"Object":return[Dh,Aa];case"Date":return[Jy,Aa];case"RegExp":return[Zy,Aa];case"Map":return[eb,Aa];case"Set":return[tb,Aa];case"DataView":return[zc,n]}return n.includes("Array")?[zc,n]:e instanceof Error?[Sj,e.name||"Error"]:[Dh,n]},Fd=([e,t])=>e===Cf&&(t==="function"||t==="symbol"),QM=(e,t,n,r)=>{const a=(u,c)=>{const d=r.push(u)-1;return n.set(c,d),d},l=u=>{if(n.has(u))return n.get(u);let[c,d]=wc(u);switch(c){case Cf:{let p=u;switch(d){case"bigint":c=wj,p=u.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+d);p=null;break;case"undefined":return a([_j],u)}return a([c,p],u)}case zc:{if(d){let g=u;return d==="DataView"?g=new Uint8Array(u.buffer):d==="ArrayBuffer"&&(g=new Uint8Array(u)),a([d,[...g]],u)}const p=[],m=a([c,p],u);for(const g of u)p.push(l(g));return m}case Dh:{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 g of XM(u))(e||!Fd(wc(u[g])))&&p.push([l(g),l(u[g])]);return m}case Jy:return a([c,isNaN(u.getTime())?Aa:u.toISOString()],u);case Zy:{const{source:p,flags:m}=u;return a([c,{source:p,flags:m}],u)}case eb:{const p=[],m=a([c,p],u);for(const[g,y]of u)(e||!(Fd(wc(g))||Fd(wc(y))))&&p.push([l(g),l(y)]);return m}case tb:{const p=[],m=a([c,p],u);for(const g of u)(e||!Fd(wc(g)))&&p.push(l(g));return m}}const{message:h}=u;return a([c,{name:d,message:h}],u)};return l},fw=(e,{json:t,lossy:n}={})=>{const r=[];return QM(!(t||n),!!t,new Map,r)(e),r},Oh=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?hw(fw(e,t)):structuredClone(e):(e,t)=>hw(fw(e,t));function JM(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 ZM(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function e4(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||JM,r=e.options.footnoteBackLabel||ZM,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 h=e.footnoteById.get(e.footnoteOrder[d]);if(!h)continue;const p=e.all(h),m=String(h.identifier).toUpperCase(),g=bl(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 b=typeof n=="string"?n:n(d,y);typeof b=="string"&&(b={type:"text",value:b}),w.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+g+(y>1?"-"+y:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(d,y),className:["data-footnote-backref"]},children:Array.isArray(b)?b:[b]})}const _=p[p.length-1];if(_&&_.type==="element"&&_.tagName==="p"){const b=_.children[_.children.length-1];b&&b.type==="text"?b.value+=" ":_.children.push({type:"text",value:" "}),_.children.push(...w)}else p.push(...w);const S={type:"element",tagName:"li",properties:{id:t+"fn-"+g},children:e.wrap(p,!0)};e.patch(h,S),c.push(S)}if(c.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:l,properties:{...Oh(u),id:"footnote-label"},children:[{type:"text",value:a}]},{type:"text",value:`
75
+ `},{type:"element",tagName:"ol",properties:{},children:e.wrap(c,!0)},{type:"text",value:`
76
+ `}]}}const kf=(function(e){if(e==null)return s4;if(typeof e=="function")return Ef(e);if(typeof e=="object")return Array.isArray(e)?t4(e):n4(e);if(typeof e=="string")return r4(e);throw new Error("Expected function, string, or object as test")});function t4(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=kf(e[n]);return Ef(r);function r(...a){let l=-1;for(;++l<t.length;)if(t[l].apply(this,a))return!0;return!1}}function n4(e){const t=e;return Ef(n);function n(r){const a=r;let l;for(l in e)if(a[l]!==t[l])return!1;return!0}}function r4(e){return Ef(t);function t(n){return n&&n.type===e}}function Ef(e){return t;function t(n,r,a){return!!(i4(n)&&e.call(this,n,typeof r=="number"?r:void 0,a||void 0))}}function s4(){return!0}function i4(e){return e!==null&&typeof e=="object"&&"type"in e}const kj=[],a4=!0,$x=!1,o4="skip";function Ej(e,t,n,r){let a;typeof t=="function"&&typeof n!="function"?(r=n,n=t):a=t;const l=kf(a),u=r?-1:1;c(e,void 0,[])();function c(d,h,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(g,"name",{value:"node ("+(d.type+(y?"<"+y+">":""))+")"})}return g;function g(){let y=kj,w,C,_;if((!t||l(d,h,p[p.length-1]||void 0))&&(y=l4(n(d,p)),y[0]===$x))return y;if("children"in d&&d.children){const S=d;if(S.children&&y[0]!==o4)for(C=(r?S.children.length:-1)+u,_=p.concat(S);C>-1&&C<S.children.length;){const b=S.children[C];if(w=c(b,C,_)(),w[0]===$x)return w;C=typeof w[1]=="number"?w[1]:C+u}}return y}}}function l4(e){return Array.isArray(e)?e:typeof e=="number"?[a4,e]:e==null?kj:[e]}function nb(e,t,n,r){let a,l,u;typeof t=="function"&&typeof n!="function"?(l=void 0,u=t,a=n):(l=t,u=n,a=r),Ej(e,l,c,a);function c(d,h){const p=h[h.length-1],m=p?p.children.indexOf(d):void 0;return u(d,m,p)}}const zx={}.hasOwnProperty,c4={};function u4(e,t){const n=t||c4,r=new Map,a=new Map,l=new Map,u={...qM,...n.handlers},c={all:h,applyData:h4,definitionById:r,footnoteById:a,footnoteCounts:l,footnoteOrder:[],handlers:u,one:d,options:n,patch:d4,wrap:m4};return nb(e,function(p){if(p.type==="definition"||p.type==="footnoteDefinition"){const m=p.type==="definition"?r:a,g=String(p.identifier).toUpperCase();m.has(g)||m.set(g,p)}}),c;function d(p,m){const g=p.type,y=c.handlers[g];if(zx.call(c.handlers,g)&&y)return y(c,p,m);if(c.options.passThrough&&c.options.passThrough.includes(g)){if("children"in p){const{children:C,..._}=p,S=Oh(_);return S.children=c.all(p),S}return Oh(p)}return(c.options.unknownHandler||f4)(c,p,m)}function h(p){const m=[];if("children"in p){const g=p.children;let y=-1;for(;++y<g.length;){const w=c.one(g[y],p);if(w){if(y&&g[y-1].type==="break"&&(!Array.isArray(w)&&w.type==="text"&&(w.value=mw(w.value)),!Array.isArray(w)&&w.type==="element")){const C=w.children[0];C&&C.type==="text"&&(C.value=mw(C.value))}Array.isArray(w)?m.push(...w):m.push(w)}}}return m}}function d4(e,t){e.position&&(t.position=Z5(e))}function h4(e,t){let n=t;if(e&&e.data){const r=e.data.hName,a=e.data.hChildren,l=e.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{const u="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:u}}n.type==="element"&&l&&Object.assign(n.properties,Oh(l)),"children"in n&&n.children&&a!==null&&a!==void 0&&(n.children=a)}return n}function f4(e,t){const n=t.data||{},r="value"in t&&!(zx.call(n,"hProperties")||zx.call(n,"hChildren"))?{type:"text",value:t.value}:{type:"element",tagName:"div",properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function m4(e,t){const n=[];let r=-1;for(t&&n.push({type:"text",value:`
77
+ `});++r<e.length;)r&&n.push({type:"text",value:`
78
+ `}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:`
79
+ `}),n}function mw(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function pw(e,t){const n=u4(e,t),r=n.one(e,void 0),a=e4(n),l=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return a&&l.children.push({type:"text",value:`
80
+ `},a),l}function p4(e,t){return e&&"run"in e?async function(n,r){const a=pw(n,{file:r,...t});await e.run(a,r)}:function(n,r){return pw(n,{file:r,...e||t})}}function gw(e){if(e)throw e}var Eg,xw;function g4(){if(xw)return Eg;xw=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,a=function(h){return typeof Array.isArray=="function"?Array.isArray(h):t.call(h)==="[object Array]"},l=function(h){if(!h||t.call(h)!=="[object Object]")return!1;var p=e.call(h,"constructor"),m=h.constructor&&h.constructor.prototype&&e.call(h.constructor.prototype,"isPrototypeOf");if(h.constructor&&!p&&!m)return!1;var g;for(g in h);return typeof g>"u"||e.call(h,g)},u=function(h,p){n&&p.name==="__proto__"?n(h,p.name,{enumerable:!0,configurable:!0,value:p.newValue,writable:!0}):h[p.name]=p.newValue},c=function(h,p){if(p==="__proto__")if(e.call(h,p)){if(r)return r(h,p).value}else return;return h[p]};return Eg=function d(){var h,p,m,g,y,w,C=arguments[0],_=1,S=arguments.length,b=!1;for(typeof C=="boolean"&&(b=C,C=arguments[1]||{},_=2),(C==null||typeof C!="object"&&typeof C!="function")&&(C={});_<S;++_)if(h=arguments[_],h!=null)for(p in h)m=c(C,p),g=c(h,p),C!==g&&(b&&g&&(l(g)||(y=a(g)))?(y?(y=!1,w=m&&a(m)?m:[]):w=m&&l(m)?m:{},u(C,{name:p,newValue:d(b,w,g)})):typeof g<"u"&&u(C,{name:p,newValue:g}));return C},Eg}var x4=g4();const jg=nf(x4);function Hx(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 y4(){const e=[],t={run:n,use:r};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,...h){const p=e[++l];let m=-1;if(d){u(d);return}for(;++m<a.length;)(h[m]===null||h[m]===void 0)&&(h[m]=a[m]);a=h,p?b4(p,c)(...h):u(null,...h)}}function r(a){if(typeof a!="function")throw new TypeError("Expected `middelware` to be a function, not "+a);return e.push(a),t}}function b4(e,t){let n;return r;function r(...u){const c=e.length>u.length;let d;c&&u.push(a);try{d=e.apply(this,u)}catch(h){const p=h;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 ws={basename:v4,dirname:_4,extname:S4,join:w4,sep:"/"};function v4(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');pu(e);let n=0,r=-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 r<0&&(l=!0,r=a+1);return r<0?"":e.slice(n,r)}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&&(r=a):(c=-1,r=u));return n===r?r=u:r<0&&(r=e.length),e.slice(n,r)}function _4(e){if(pu(e),e.length===0)return".";let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function S4(e){pu(e);let t=e.length,n=-1,r=0,a=-1,l=0,u;for(;t--;){const c=e.codePointAt(t);if(c===47){if(u){r=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===r+1?"":e.slice(a,n)}function w4(...e){let t=-1,n;for(;++t<e.length;)pu(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":C4(n)}function C4(e){pu(e);const t=e.codePointAt(0)===47;let n=k4(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function k4(e,t){let n="",r=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||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(d=n.lastIndexOf("/"),d!==n.length-1){d<0?(n="",r=0):(n=n.slice(0,d),r=n.length-1-n.lastIndexOf("/")),a=u,l=0;continue}}else if(n.length>0){n="",r=0,a=u,l=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(a+1,u):n=e.slice(a+1,u),r=u-a-1;a=u,l=0}else c===46&&l>-1?l++:l=-1}return n}function pu(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const E4={cwd:j4};function j4(){return"/"}function Fx(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function N4(e){if(typeof e=="string")e=new URL(e);else if(!Fx(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 T4(e)}function T4(e){if(e.hostname!==""){const r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const t=e.pathname;let n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){const r=t.codePointAt(n+2);if(r===70||r===102){const a=new TypeError("File URL path must not include encoded / characters");throw a.code="ERR_INVALID_FILE_URL_PATH",a}}return decodeURIComponent(t)}const Ng=["history","path","basename","stem","extname","dirname"];class jj{constructor(t){let n;t?Fx(t)?n={path:t}:typeof t=="string"||A4(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":E4.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<Ng.length;){const l=Ng[r];l in n&&n[l]!==void 0&&n[l]!==null&&(this[l]=l==="history"?[...n[l]]:n[l])}let a;for(a in n)Ng.includes(a)||(this[a]=n[a])}get basename(){return typeof this.path=="string"?ws.basename(this.path):void 0}set basename(t){Ag(t,"basename"),Tg(t,"basename"),this.path=ws.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?ws.dirname(this.path):void 0}set dirname(t){yw(this.basename,"dirname"),this.path=ws.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?ws.extname(this.path):void 0}set extname(t){if(Tg(t,"extname"),yw(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=ws.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Fx(t)&&(t=N4(t)),Ag(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?ws.basename(this.path,this.extname):void 0}set stem(t){Ag(t,"stem"),Tg(t,"stem"),this.path=ws.join(this.dirname||"",t+(this.extname||""))}fail(t,n,r){const a=this.message(t,n,r);throw a.fatal=!0,a}info(t,n,r){const a=this.message(t,n,r);return a.fatal=void 0,a}message(t,n,r){const a=new Zn(t,n,r);return this.path&&(a.name=this.path+":"+a.name,a.file=this.path),a.fatal=!1,this.messages.push(a),a}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function Tg(e,t){if(e&&e.includes(ws.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+ws.sep+"`")}function Ag(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function yw(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function A4(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const L4=(function(e){const r=this.constructor.prototype,a=r[e],l=function(){return a.apply(l,arguments)};return Object.setPrototypeOf(l,r),l}),R4={}.hasOwnProperty;class rb extends L4{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=y4()}copy(){const t=new rb;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(jg(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(Dg("data",this.frozen),this.namespace[t]=n,this):R4.call(this.namespace,t)&&this.namespace[t]||void 0:t?(Dg("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);const a=n.call(t,...r);typeof a=="function"&&this.transformers.use(a)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=Ud(t),r=this.parser||this.Parser;return Lg("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),Lg("process",this.parser||this.Parser),Rg("process",this.compiler||this.Compiler),n?a(void 0,n):new Promise(a);function a(l,u){const c=Ud(t),d=r.parse(c);r.run(d,c,function(p,m,g){if(p||!m||!g)return h(p);const y=m,w=r.stringify(y,g);I4(w)?g.value=w:g.result=w,h(p,g)});function h(p,m){p||!m?u(p):l?l(m):n(void 0,m)}}}processSync(t){let n=!1,r;return this.freeze(),Lg("processSync",this.parser||this.Parser),Rg("processSync",this.compiler||this.Compiler),this.process(t,a),vw("processSync","process",n),r;function a(l,u){n=!0,gw(l),r=u}}run(t,n,r){bw(t),this.freeze();const a=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?l(void 0,r):new Promise(l);function l(u,c){const d=Ud(n);a.run(t,d,h);function h(p,m,g){const y=m||t;p?c(p):u?u(y):r(void 0,y,g)}}}runSync(t,n){let r=!1,a;return this.run(t,n,l),vw("runSync","run",r),a;function l(u,c){gw(u),a=c,r=!0}}stringify(t,n){this.freeze();const r=Ud(n),a=this.compiler||this.Compiler;return Rg("stringify",a),bw(t),a(t,r)}use(t,...n){const r=this.attachers,a=this.namespace;if(Dg("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(h){if(typeof h=="function")d(h,[]);else if(typeof h=="object")if(Array.isArray(h)){const[p,...m]=h;d(p,m)}else u(h);else throw new TypeError("Expected usable value, not `"+h+"`")}function u(h){if(!("plugins"in h)&&!("settings"in h))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");c(h.plugins),h.settings&&(a.settings=jg(!0,a.settings,h.settings))}function c(h){let p=-1;if(h!=null)if(Array.isArray(h))for(;++p<h.length;){const m=h[p];l(m)}else throw new TypeError("Expected a list of plugins, not `"+h+"`")}function d(h,p){let m=-1,g=-1;for(;++m<r.length;)if(r[m][0]===h){g=m;break}if(g===-1)r.push([h,...p]);else if(p.length>0){let[y,...w]=p;const C=r[g][1];Hx(C)&&Hx(y)&&(y=jg(!0,C,y)),r[g]=[h,y,...w]}}}}const D4=new rb().freeze();function Lg(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Rg(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Dg(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 bw(e){if(!Hx(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function vw(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Ud(e){return O4(e)?e:new jj(e)}function O4(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function I4(e){return typeof e=="string"||M4(e)}function M4(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const P4="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",_w=[],Sw={allowDangerousHtml:!0},B4=/^(https?|ircs?|mailto|xmpp)$/i,$4=[{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 z4(e){const t=H4(e),n=F4(e);return U4(t.runSync(t.parse(n),n),e)}function H4(e){const t=e.rehypePlugins||_w,n=e.remarkPlugins||_w,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Sw}:Sw;return D4().use(_M).use(n).use(p4,r).use(t)}function F4(e){const t=e.children||"",n=new jj;return typeof t=="string"&&(n.value=t),n}function U4(e,t){const n=t.allowedElements,r=t.allowElement,a=t.components,l=t.disallowedElements,u=t.skipHtml,c=t.unwrapDisallowed,d=t.urlTransform||V4;for(const p of $4)Object.hasOwn(t,p.from)&&(""+p.from+(p.to?"use `"+p.to+"` instead":"remove it")+P4+p.id,void 0);return nb(e,h),sO(e,{Fragment:s.Fragment,components:a,ignoreInvalidStyle:!0,jsx:s.jsx,jsxs:s.jsxs,passKeys:!0,passNode:!0});function h(p,m,g){if(p.type==="raw"&&g&&typeof m=="number")return u?g.children.splice(m,1):g.children[m]={type:"text",value:p.value},m;if(p.type==="element"){let y;for(y in wg)if(Object.hasOwn(wg,y)&&Object.hasOwn(p.properties,y)){const w=p.properties[y],C=wg[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&&r&&typeof m=="number"&&(y=!r(p,m,g)),y&&g&&typeof m=="number")return c&&p.children?g.children.splice(m,1,...p.children):g.children.splice(m,1),m}}}function V4(e){const t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),a=e.indexOf("/");return t===-1||a!==-1&&t>a||n!==-1&&t>n||r!==-1&&t>r||B4.test(e.slice(0,t))?e:""}function ww(e,t){const n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let r=0,a=n.indexOf(t);for(;a!==-1;)r++,a=n.indexOf(t,a+t.length);return r}function W4(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function G4(e,t,n){const a=kf((n||{}).ignore||[]),l=q4(t);let u=-1;for(;++u<l.length;)Ej(e,"text",c);function c(h,p){let m=-1,g;for(;++m<p.length;){const y=p[m],w=g?g.children:void 0;if(a(y,w?w.indexOf(y):void 0,g))return;g=y}if(g)return d(h,p)}function d(h,p){const m=p[p.length-1],g=l[u][0],y=l[u][1];let w=0;const _=m.children.indexOf(h);let S=!1,b=[];g.lastIndex=0;let v=g.exec(h.value);for(;v;){const k=v.index,T={index:v.index,input:v.input,stack:[...p,h]};let N=y(...v,T);if(typeof N=="string"&&(N=N.length>0?{type:"text",value:N}:void 0),N===!1?g.lastIndex=k+1:(w!==k&&b.push({type:"text",value:h.value.slice(w,k)}),Array.isArray(N)?b.push(...N):N&&b.push(N),w=k+v[0].length,S=!0),!g.global)break;v=g.exec(h.value)}return S?(w<h.value.length&&b.push({type:"text",value:h.value.slice(w)}),m.children.splice(_,1,...b)):b=[h],_+b.length}}function q4(e){const t=[];if(!Array.isArray(e))throw new TypeError("Expected find and replace tuple or list of tuples");const n=!e[0]||Array.isArray(e[0])?e:[e];let r=-1;for(;++r<n.length;){const a=n[r];t.push([K4(a[0]),Y4(a[1])])}return t}function K4(e){return typeof e=="string"?new RegExp(W4(e),"g"):e}function Y4(e){return typeof e=="function"?e:function(){return e}}const Og="phrasing",Ig=["autolink","link","image","label"];function X4(){return{transforms:[rP],enter:{literalAutolink:J4,literalAutolinkEmail:Mg,literalAutolinkHttp:Mg,literalAutolinkWww:Mg},exit:{literalAutolink:nP,literalAutolinkEmail:tP,literalAutolinkHttp:Z4,literalAutolinkWww:eP}}}function Q4(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:Og,notInConstruct:Ig},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:Og,notInConstruct:Ig},{character:":",before:"[ps]",after:"\\/",inConstruct:Og,notInConstruct:Ig}]}}function J4(e){this.enter({type:"link",title:null,url:"",children:[]},e)}function Mg(e){this.config.enter.autolinkProtocol.call(this,e)}function Z4(e){this.config.exit.autolinkProtocol.call(this,e)}function eP(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 tP(e){this.config.exit.autolinkEmail.call(this,e)}function nP(e){this.exit(e)}function rP(e){G4(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,sP],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),iP]],{ignore:["link","linkReference"]})}function sP(e,t,n,r,a){let l="";if(!Nj(a)||(/^w/i.test(t)&&(n=t+n,t="",l="http://"),!aP(n)))return!1;const u=oP(n+r);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 iP(e,t,n,r){return!Nj(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+t+"@"+n,children:[{type:"text",value:t+"@"+n}]}}function aP(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 oP(e){const t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(")");const a=ww(e,"(");let l=ww(e,")");for(;r!==-1&&a>l;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(")"),l++;return[e,n]}function Nj(e,t){const n=e.input.charCodeAt(e.index-1);return(e.index===0||qa(n)||Sf(n))&&(!t||n!==47)}Tj.peek=gP;function lP(){this.buffer()}function cP(e){this.enter({type:"footnoteReference",identifier:"",label:""},e)}function uP(){this.buffer()}function dP(e){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},e)}function hP(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=us(this.sliceSerialize(e)).toLowerCase(),n.label=t}function fP(e){this.exit(e)}function mP(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=us(this.sliceSerialize(e)).toLowerCase(),n.label=t}function pP(e){this.exit(e)}function gP(){return"["}function Tj(e,t,n,r){const a=n.createTracker(r);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 xP(){return{enter:{gfmFootnoteCallString:lP,gfmFootnoteCall:cP,gfmFootnoteDefinitionLabelString:uP,gfmFootnoteDefinition:dP},exit:{gfmFootnoteCallString:hP,gfmFootnoteCall:fP,gfmFootnoteDefinitionLabelString:mP,gfmFootnoteDefinition:pP}}}function yP(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:Tj},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(r,a,l,u){const c=l.createTracker(u);let d=c.move("[^");const h=l.enter("footnoteDefinition"),p=l.enter("label");return d+=c.move(l.safe(l.associationId(r),{before:d,after:"]"})),p(),d+=c.move("]:"),r.children&&r.children.length>0&&(c.shift(4),d+=c.move((t?`
81
+ `:" ")+l.indentLines(l.containerFlow(r,c.current()),t?Aj:bP))),h(),d}}function bP(e,t,n){return t===0?e:Aj(e,t,n)}function Aj(e,t,n){return(n?"":" ")+e}const vP=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];Lj.peek=kP;function _P(){return{canContainEols:["delete"],enter:{strikethrough:wP},exit:{strikethrough:CP}}}function SP(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:vP}],handlers:{delete:Lj}}}function wP(e){this.enter({type:"delete",children:[]},e)}function CP(e){this.exit(e)}function Lj(e,t,n,r){const a=n.createTracker(r),l=n.enter("strikethrough");let u=a.move("~~");return u+=n.containerPhrasing(e,{...a.current(),before:u,after:"~"}),u+=a.move("~~"),l(),u}function kP(){return"~"}function EP(e){return e.length}function jP(e,t){const n=t||{},r=(n.align||[]).concat(),a=n.stringLength||EP,l=[],u=[],c=[],d=[];let h=0,p=-1;for(;++p<e.length;){const C=[],_=[];let S=-1;for(e[p].length>h&&(h=e[p].length);++S<e[p].length;){const b=NP(e[p][S]);if(n.alignDelimiters!==!1){const v=a(b);_[S]=v,(d[S]===void 0||v>d[S])&&(d[S]=v)}C.push(b)}u[p]=C,c[p]=_}let m=-1;if(typeof r=="object"&&"length"in r)for(;++m<h;)l[m]=Cw(r[m]);else{const C=Cw(r);for(;++m<h;)l[m]=C}m=-1;const g=[],y=[];for(;++m<h;){const C=l[m];let _="",S="";C===99?(_=":",S=":"):C===108?_=":":C===114&&(S=":");let b=n.alignDelimiters===!1?1:Math.max(1,d[m]-_.length-S.length);const v=_+"-".repeat(b)+S;n.alignDelimiters!==!1&&(b=_.length+b+S.length,b>d[m]&&(d[m]=b),y[m]=b),g[m]=v}u.splice(1,0,g),c.splice(1,0,y),p=-1;const w=[];for(;++p<u.length;){const C=u[p],_=c[p];m=-1;const S=[];for(;++m<h;){const b=C[m]||"";let v="",k="";if(n.alignDelimiters!==!1){const T=d[m]-(_[m]||0),N=l[m];N===114?v=" ".repeat(T):N===99?T%2?(v=" ".repeat(T/2+.5),k=" ".repeat(T/2-.5)):(v=" ".repeat(T/2),k=v):k=" ".repeat(T)}n.delimiterStart!==!1&&!m&&S.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&b==="")&&(n.delimiterStart!==!1||m)&&S.push(" "),n.alignDelimiters!==!1&&S.push(v),S.push(b),n.alignDelimiters!==!1&&S.push(k),n.padding!==!1&&S.push(" "),(n.delimiterEnd!==!1||m!==h-1)&&S.push("|")}w.push(n.delimiterEnd===!1?S.join("").replace(/ +$/,""):S.join(""))}return w.join(`
82
+ `)}function NP(e){return e==null?"":String(e)}function Cw(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 TP(e,t,n,r){const a=n.enter("blockquote"),l=n.createTracker(r);l.move("> "),l.shift(2);const u=n.indentLines(n.containerFlow(e,l.current()),AP);return a(),u}function AP(e,t,n){return">"+(n?"":" ")+e}function LP(e,t){return kw(e,t.inConstruct,!0)&&!kw(e,t.notInConstruct,!1)}function kw(e,t,n){if(typeof t=="string"&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function Ew(e,t,n,r){let a=-1;for(;++a<n.unsafe.length;)if(n.unsafe[a].character===`
83
+ `&&LP(n.stack,n.unsafe[a]))return/[ \t]/.test(r.before)?"":" ";return`\\
84
+ `}function RP(e,t){const n=String(e);let r=n.indexOf(t),a=r,l=0,u=0;if(typeof t!="string")throw new TypeError("Expected substring");for(;r!==-1;)r===a?++l>u&&(u=l):l=1,a=r+t.length,r=n.indexOf(t,a);return u}function DP(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 OP(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 IP(e,t,n,r){const a=OP(n),l=e.value||"",u=a==="`"?"GraveAccent":"Tilde";if(DP(e,n)){const m=n.enter("codeIndented"),g=n.indentLines(l,MP);return m(),g}const c=n.createTracker(r),d=a.repeat(Math.max(RP(l,a)+1,3)),h=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:`
85
+ `,encode:["`"],...c.current()})),m()}return p+=c.move(`
86
+ `),l&&(p+=c.move(l+`
87
+ `)),p+=c.move(d),h(),p}function MP(e,t,n){return(n?"":" ")+e}function sb(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 PP(e,t,n,r){const a=sb(n),l=a==='"'?"Quote":"Apostrophe",u=n.enter("definition");let c=n.enter("label");const d=n.createTracker(r);let h=d.move("[");return h+=d.move(n.safe(n.associationId(e),{before:h,after:"]",...d.current()})),h+=d.move("]: "),c(),!e.url||/[\0- \u007F]/.test(e.url)?(c=n.enter("destinationLiteral"),h+=d.move("<"),h+=d.move(n.safe(e.url,{before:h,after:">",...d.current()})),h+=d.move(">")):(c=n.enter("destinationRaw"),h+=d.move(n.safe(e.url,{before:h,after:e.title?" ":`
88
+ `,...d.current()}))),c(),e.title&&(c=n.enter(`title${l}`),h+=d.move(" "+a),h+=d.move(n.safe(e.title,{before:h,after:a,...d.current()})),h+=d.move(a),c()),u(),h}function BP(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 tu(e){return"&#x"+e.toString(16).toUpperCase()+";"}function Ih(e,t,n){const r=cl(e),a=cl(t);return r===void 0?a===void 0?n==="_"?{inside:!0,outside:!0}:{inside:!1,outside:!1}:a===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?a===void 0?{inside:!1,outside:!1}:a===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:a===void 0?{inside:!1,outside:!1}:a===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}Rj.peek=$P;function Rj(e,t,n,r){const a=BP(n),l=n.enter("emphasis"),u=n.createTracker(r),c=u.move(a);let d=u.move(n.containerPhrasing(e,{after:a,before:c,...u.current()}));const h=d.charCodeAt(0),p=Ih(r.before.charCodeAt(r.before.length-1),h,a);p.inside&&(d=tu(h)+d.slice(1));const m=d.charCodeAt(d.length-1),g=Ih(r.after.charCodeAt(0),m,a);g.inside&&(d=d.slice(0,-1)+tu(m));const y=u.move(a);return l(),n.attentionEncodeSurroundingInfo={after:g.outside,before:p.outside},c+d+y}function $P(e,t,n){return n.options.emphasis||"*"}function zP(e,t){let n=!1;return nb(e,function(r){if("value"in r&&/\r?\n|\r/.test(r.value)||r.type==="break")return n=!0,$x}),!!((!e.depth||e.depth<3)&&Yy(e)&&(t.options.setext||n))}function HP(e,t,n,r){const a=Math.max(Math.min(6,e.depth||1),1),l=n.createTracker(r);if(zP(e,n)){const p=n.enter("headingSetext"),m=n.enter("phrasing"),g=n.containerPhrasing(e,{...l.current(),before:`
89
+ `,after:`
90
+ `});return m(),p(),g+`
91
+ `+(a===1?"=":"-").repeat(g.length-(Math.max(g.lastIndexOf("\r"),g.lastIndexOf(`
92
+ `))+1))}const u="#".repeat(a),c=n.enter("headingAtx"),d=n.enter("phrasing");l.move(u+" ");let h=n.containerPhrasing(e,{before:"# ",after:`
93
+ `,...l.current()});return/^[\t ]/.test(h)&&(h=tu(h.charCodeAt(0))+h.slice(1)),h=h?u+" "+h:u,n.options.closeAtx&&(h+=" "+u),d(),c(),h}Dj.peek=FP;function Dj(e){return e.value||""}function FP(){return"<"}Oj.peek=UP;function Oj(e,t,n,r){const a=sb(n),l=a==='"'?"Quote":"Apostrophe",u=n.enter("image");let c=n.enter("label");const d=n.createTracker(r);let h=d.move("![");return h+=d.move(n.safe(e.alt,{before:h,after:"]",...d.current()})),h+=d.move("]("),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter("destinationLiteral"),h+=d.move("<"),h+=d.move(n.safe(e.url,{before:h,after:">",...d.current()})),h+=d.move(">")):(c=n.enter("destinationRaw"),h+=d.move(n.safe(e.url,{before:h,after:e.title?" ":")",...d.current()}))),c(),e.title&&(c=n.enter(`title${l}`),h+=d.move(" "+a),h+=d.move(n.safe(e.title,{before:h,after:a,...d.current()})),h+=d.move(a),c()),h+=d.move(")"),u(),h}function UP(){return"!"}Ij.peek=VP;function Ij(e,t,n,r){const a=e.referenceType,l=n.enter("imageReference");let u=n.enter("label");const c=n.createTracker(r);let d=c.move("![");const h=n.safe(e.alt,{before:d,after:"]",...c.current()});d+=c.move(h+"]["),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"||!h||h!==m?d+=c.move(m+"]"):a==="shortcut"?d=d.slice(0,-1):d+=c.move("]"),d}function VP(){return"!"}Mj.peek=WP;function Mj(e,t,n){let r=e.value||"",a="`",l=-1;for(;new RegExp("(^|[^`])"+a+"([^`]|$)").test(r);)a+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=" "+r+" ");++l<n.unsafe.length;){const u=n.unsafe[l],c=n.compilePattern(u);let d;if(u.atBreak)for(;d=c.exec(r);){let h=d.index;r.charCodeAt(h)===10&&r.charCodeAt(h-1)===13&&h--,r=r.slice(0,h)+" "+r.slice(d.index+1)}}return a+r+a}function WP(){return"`"}function Pj(e,t){const n=Yy(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))}Bj.peek=GP;function Bj(e,t,n,r){const a=sb(n),l=a==='"'?"Quote":"Apostrophe",u=n.createTracker(r);let c,d;if(Pj(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 h=u.move("[");return h+=u.move(n.containerPhrasing(e,{before:h,after:"](",...u.current()})),h+=u.move("]("),d(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(d=n.enter("destinationLiteral"),h+=u.move("<"),h+=u.move(n.safe(e.url,{before:h,after:">",...u.current()})),h+=u.move(">")):(d=n.enter("destinationRaw"),h+=u.move(n.safe(e.url,{before:h,after:e.title?" ":")",...u.current()}))),d(),e.title&&(d=n.enter(`title${l}`),h+=u.move(" "+a),h+=u.move(n.safe(e.title,{before:h,after:a,...u.current()})),h+=u.move(a),d()),h+=u.move(")"),c(),h}function GP(e,t,n){return Pj(e,n)?"<":"["}$j.peek=qP;function $j(e,t,n,r){const a=e.referenceType,l=n.enter("linkReference");let u=n.enter("label");const c=n.createTracker(r);let d=c.move("[");const h=n.containerPhrasing(e,{before:d,after:"]",...c.current()});d+=c.move(h+"]["),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"||!h||h!==m?d+=c.move(m+"]"):a==="shortcut"?d=d.slice(0,-1):d+=c.move("]"),d}function qP(){return"["}function ib(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 KP(e){const t=ib(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 YP(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 zj(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 XP(e,t,n,r){const a=n.enter("list"),l=n.bulletCurrent;let u=e.ordered?YP(n):ib(n);const c=e.ordered?u==="."?")":".":KP(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),zj(n)===u&&p){let m=-1;for(;++m<e.children.length;){const g=e.children[m];if(g&&g.type==="listItem"&&g.children&&g.children[0]&&g.children[0].type==="thematicBreak"){d=!0;break}}}}d&&(u=c),n.bulletCurrent=u;const h=n.containerFlow(e,r);return n.bulletLastUsed=u,n.bulletCurrent=l,a(),h}function QP(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 JP(e,t,n,r){const a=QP(n);let l=n.bulletCurrent||ib(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(r);c.move(l+" ".repeat(u-l.length)),c.shift(u);const d=n.enter("listItem"),h=n.indentLines(n.containerFlow(e,c.current()),p);return d(),h;function p(m,g,y){return g?(y?"":" ".repeat(u))+m:(y?l:l+" ".repeat(u-l.length))+m}}function ZP(e,t,n,r){const a=n.enter("paragraph"),l=n.enter("phrasing"),u=n.containerPhrasing(e,r);return l(),a(),u}const e6=kf(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);function t6(e,t,n,r){return(e.children.some(function(u){return e6(u)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function n6(e){const t=e.options.strong||"*";if(t!=="*"&&t!=="_")throw new Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}Hj.peek=r6;function Hj(e,t,n,r){const a=n6(n),l=n.enter("strong"),u=n.createTracker(r),c=u.move(a+a);let d=u.move(n.containerPhrasing(e,{after:a,before:c,...u.current()}));const h=d.charCodeAt(0),p=Ih(r.before.charCodeAt(r.before.length-1),h,a);p.inside&&(d=tu(h)+d.slice(1));const m=d.charCodeAt(d.length-1),g=Ih(r.after.charCodeAt(0),m,a);g.inside&&(d=d.slice(0,-1)+tu(m));const y=u.move(a+a);return l(),n.attentionEncodeSurroundingInfo={after:g.outside,before:p.outside},c+d+y}function r6(e,t,n){return n.options.strong||"*"}function s6(e,t,n,r){return n.safe(e.value,r)}function i6(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 a6(e,t,n){const r=(zj(n)+(n.options.ruleSpaces?" ":"")).repeat(i6(n));return n.options.ruleSpaces?r.slice(0,-1):r}const Fj={blockquote:TP,break:Ew,code:IP,definition:PP,emphasis:Rj,hardBreak:Ew,heading:HP,html:Dj,image:Oj,imageReference:Ij,inlineCode:Mj,link:Bj,linkReference:$j,list:XP,listItem:JP,paragraph:ZP,root:t6,strong:Hj,text:s6,thematicBreak:a6};function o6(){return{enter:{table:l6,tableData:jw,tableHeader:jw,tableRow:u6},exit:{codeText:d6,table:c6,tableData:Pg,tableHeader:Pg,tableRow:Pg}}}function l6(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 c6(e){this.exit(e),this.data.inTable=void 0}function u6(e){this.enter({type:"tableRow",children:[]},e)}function Pg(e){this.exit(e)}function jw(e){this.enter({type:"tableCell",children:[]},e)}function d6(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,h6));const n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function h6(e,t){return t==="|"?t:e}function f6(e){const t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,a=t.stringLength,l=n?" ":"|";return{unsafe:[{character:"\r",inConstruct:"tableCell"},{character:`
94
+ `,inConstruct:"tableCell"},{atBreak:!0,character:"|",after:"[ :-]"},{character:"|",inConstruct:"tableCell"},{atBreak:!0,character:":",after:"-"},{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{inlineCode:g,table:u,tableCell:d,tableRow:c}};function u(y,w,C,_){return h(p(y,C,_),y.align)}function c(y,w,C,_){const S=m(y,C,_),b=h([S]);return b.slice(0,b.indexOf(`
95
+ `))}function d(y,w,C,_){const S=C.enter("tableCell"),b=C.enter("phrasing"),v=C.containerPhrasing(y,{..._,before:l,after:l});return b(),S(),v}function h(y,w){return jP(y,{align:w,alignDelimiters:r,padding:n,stringLength:a})}function p(y,w,C){const _=y.children;let S=-1;const b=[],v=w.enter("table");for(;++S<_.length;)b[S]=m(_[S],w,C);return v(),b}function m(y,w,C){const _=y.children;let S=-1;const b=[],v=w.enter("tableRow");for(;++S<_.length;)b[S]=d(_[S],y,w,C);return v(),b}function g(y,w,C){let _=Fj.inlineCode(y,w,C);return C.stack.includes("tableCell")&&(_=_.replace(/\|/g,"\\$&")),_}}function m6(){return{exit:{taskListCheckValueChecked:Nw,taskListCheckValueUnchecked:Nw,paragraph:g6}}}function p6(){return{unsafe:[{atBreak:!0,character:"-",after:"[:|-]"}],handlers:{listItem:x6}}}function Nw(e){const t=this.stack[this.stack.length-2];t.type,t.checked=e.type==="taskListCheckValueChecked"}function g6(e){const t=this.stack[this.stack.length-2];if(t&&t.type==="listItem"&&typeof t.checked=="boolean"){const n=this.stack[this.stack.length-1];n.type;const r=n.children[0];if(r&&r.type==="text"){const a=t.children;let l=-1,u;for(;++l<a.length;){const c=a[l];if(c.type==="paragraph"){u=c;break}}u===n&&(r.value=r.value.slice(1),r.value.length===0?n.children.shift():n.position&&r.position&&typeof r.position.start.offset=="number"&&(r.position.start.column++,r.position.start.offset++,n.position.start=Object.assign({},r.position.start)))}}this.exit(e)}function x6(e,t,n,r){const a=e.children[0],l=typeof e.checked=="boolean"&&a&&a.type==="paragraph",u="["+(e.checked?"x":" ")+"] ",c=n.createTracker(r);l&&c.move(u);let d=Fj.listItem(e,t,n,{...r,...c.current()});return l&&(d=d.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,h)),d;function h(p){return p+u}}function y6(){return[X4(),xP(),_P(),o6(),m6()]}function b6(e){return{extensions:[Q4(),yP(e),SP(),f6(e),p6()]}}const v6={tokenize:E6,partial:!0},Uj={tokenize:j6,partial:!0},Vj={tokenize:N6,partial:!0},Wj={tokenize:T6,partial:!0},_6={tokenize:A6,partial:!0},Gj={name:"wwwAutolink",tokenize:C6,previous:Kj},qj={name:"protocolAutolink",tokenize:k6,previous:Yj},di={name:"emailAutolink",tokenize:w6,previous:Xj},Rs={};function S6(){return{text:Rs}}let wa=48;for(;wa<123;)Rs[wa]=di,wa++,wa===58?wa=65:wa===91&&(wa=97);Rs[43]=di;Rs[45]=di;Rs[46]=di;Rs[95]=di;Rs[72]=[di,qj];Rs[104]=[di,qj];Rs[87]=[di,Gj];Rs[119]=[di,Gj];function w6(e,t,n){const r=this;let a,l;return u;function u(m){return!Ux(m)||!Xj.call(r,r.previous)||ab(r.events)?n(m):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),c(m))}function c(m){return Ux(m)?(e.consume(m),c):m===64?(e.consume(m),d):n(m)}function d(m){return m===46?e.check(_6,p,h)(m):m===45||m===95||Qn(m)?(l=!0,e.consume(m),d):p(m)}function h(m){return e.consume(m),a=!0,d}function p(m){return l&&a&&ir(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(m)):n(m)}}function C6(e,t,n){const r=this;return a;function a(u){return u!==87&&u!==119||!Kj.call(r,r.previous)||ab(r.events)?n(u):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(v6,e.attempt(Uj,e.attempt(Vj,l),n),n)(u))}function l(u){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(u)}}function k6(e,t,n){const r=this;let a="",l=!1;return u;function u(m){return(m===72||m===104)&&Yj.call(r,r.previous)&&!ab(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),a+=String.fromCodePoint(m),e.consume(m),c):n(m)}function c(m){if(ir(m)&&a.length<5)return a+=String.fromCodePoint(m),e.consume(m),c;if(m===58){const g=a.toLowerCase();if(g==="http"||g==="https")return e.consume(m),d}return n(m)}function d(m){return m===47?(e.consume(m),l?h:(l=!0,d)):n(m)}function h(m){return m===null||Rh(m)||Jt(m)||qa(m)||Sf(m)?n(m):e.attempt(Uj,e.attempt(Vj,p),n)(m)}function p(m){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(m)}}function E6(e,t,n){let r=0;return a;function a(u){return(u===87||u===119)&&r<3?(r++,e.consume(u),a):u===46&&r===3?(e.consume(u),l):n(u)}function l(u){return u===null?n(u):t(u)}}function j6(e,t,n){let r,a,l;return u;function u(h){return h===46||h===95?e.check(Wj,d,c)(h):h===null||Jt(h)||qa(h)||h!==45&&Sf(h)?d(h):(l=!0,e.consume(h),u)}function c(h){return h===95?r=!0:(a=r,r=void 0),e.consume(h),u}function d(h){return a||r||!l?n(h):t(h)}}function N6(e,t){let n=0,r=0;return a;function a(u){return u===40?(n++,e.consume(u),a):u===41&&r<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(Wj,t,l)(u):u===null||Jt(u)||qa(u)?t(u):(e.consume(u),a)}function l(u){return u===41&&r++,e.consume(u),a}}function T6(e,t,n){return r;function r(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),r):c===38?(e.consume(c),l):c===93?(e.consume(c),a):c===60||c===null||Jt(c)||qa(c)?t(c):n(c)}function a(c){return c===null||c===40||c===91||Jt(c)||qa(c)?t(c):r(c)}function l(c){return ir(c)?u(c):n(c)}function u(c){return c===59?(e.consume(c),r):ir(c)?(e.consume(c),u):n(c)}}function A6(e,t,n){return r;function r(l){return e.consume(l),a}function a(l){return Qn(l)?n(l):t(l)}}function Kj(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||Jt(e)}function Yj(e){return!ir(e)}function Xj(e){return!(e===47||Ux(e))}function Ux(e){return e===43||e===45||e===46||e===95||Qn(e)}function ab(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const L6={tokenize:$6,partial:!0};function R6(){return{document:{91:{name:"gfmFootnoteDefinition",tokenize:M6,continuation:{tokenize:P6},exit:B6}},text:{91:{name:"gfmFootnoteCall",tokenize:I6},93:{name:"gfmPotentialFootnoteCall",add:"after",tokenize:D6,resolveTo:O6}}}}function D6(e,t,n){const r=this;let a=r.events.length;const l=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]);let u;for(;a--;){const d=r.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 h=us(r.sliceSerialize({start:u.end,end:r.now()}));return h.codePointAt(0)!==94||!l.includes(h.slice(1))?n(d):(e.enter("gfmFootnoteCallLabelMarker"),e.consume(d),e.exit("gfmFootnoteCallLabelMarker"),t(d))}}function O6(e,t){let n=e.length;for(;n--;)if(e[n][1].type==="labelImage"&&e[n][0]==="enter"){e[n][1];break}e[n+1][1].type="data",e[n+3][1].type="gfmFootnoteCallLabelMarker";const r={type:"gfmFootnoteCall",start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},a={type:"gfmFootnoteCallMarker",start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};a.end.column++,a.end.offset++,a.end._bufferIndex++;const 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",r,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",r,t]];return e.splice(n,e.length-n+1,...c),e}function I6(e,t,n){const r=this,a=r.parser.gfmFootnotes||(r.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",h)}function h(m){if(l>999||m===93&&!u||m===null||m===91||Jt(m))return n(m);if(m===93){e.exit("chunkString");const g=e.exit("gfmFootnoteCallString");return a.includes(us(r.sliceSerialize(g)))?(e.enter("gfmFootnoteCallLabelMarker"),e.consume(m),e.exit("gfmFootnoteCallLabelMarker"),e.exit("gfmFootnoteCall"),t):n(m)}return Jt(m)||(u=!0),l++,e.consume(m),m===92?p:h}function p(m){return m===91||m===92||m===93?(e.consume(m),l++,h):h(m)}}function M6(e,t,n){const r=this,a=r.parser.gfmFootnotes||(r.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"),h}function h(w){return w===94?(e.enter("gfmFootnoteDefinitionMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionMarker"),e.enter("gfmFootnoteDefinitionLabelString"),e.enter("chunkString").contentType="string",p):n(w)}function p(w){if(u>999||w===93&&!c||w===null||w===91||Jt(w))return n(w);if(w===93){e.exit("chunkString");const C=e.exit("gfmFootnoteDefinitionLabelString");return l=us(r.sliceSerialize(C)),e.enter("gfmFootnoteDefinitionLabelMarker"),e.consume(w),e.exit("gfmFootnoteDefinitionLabelMarker"),e.exit("gfmFootnoteDefinitionLabel"),g}return Jt(w)||(c=!0),u++,e.consume(w),w===92?m:p}function m(w){return w===91||w===92||w===93?(e.consume(w),u++,p):p(w)}function g(w){return w===58?(e.enter("definitionMarker"),e.consume(w),e.exit("definitionMarker"),a.includes(l)||a.push(l),Tt(e,y,"gfmFootnoteDefinitionWhitespace")):n(w)}function y(w){return t(w)}}function P6(e,t,n){return e.check(mu,t,e.attempt(L6,t,n))}function B6(e){e.exit("gfmFootnoteDefinition")}function $6(e,t,n){const r=this;return Tt(e,a,"gfmFootnoteDefinitionIndent",5);function a(l){const u=r.events[r.events.length-1];return u&&u[1].type==="gfmFootnoteDefinitionIndent"&&u[2].sliceSerialize(u[1],!0).length===4?t(l):n(l)}}function z6(e){let n=(e||{}).singleTilde;const r={name:"strikethrough",tokenize:l,resolveAll:a};return n==null&&(n=!0),{text:{126:r},insideSpan:{null:[r]},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 h=d;for(;h--;)if(u[h][0]==="exit"&&u[h][1].type==="strikethroughSequenceTemporary"&&u[h][1]._open&&u[d][1].end.offset-u[d][1].start.offset===u[h][1].end.offset-u[h][1].start.offset){u[d][1].type="strikethroughSequence",u[h][1].type="strikethroughSequence";const p={type:"strikethrough",start:Object.assign({},u[h][1].start),end:Object.assign({},u[d][1].end)},m={type:"strikethroughText",start:Object.assign({},u[h][1].end),end:Object.assign({},u[d][1].start)},g=[["enter",p,c],["enter",u[h][1],c],["exit",u[h][1],c],["enter",m,c]],y=c.parser.constructs.insideSpan.null;y&&Rr(g,g.length,0,wf(y,u.slice(h+1,d),c)),Rr(g,g.length,0,[["exit",m,c],["enter",u[d][1],c],["exit",u[d][1],c],["exit",p,c]]),Rr(u,h-1,d-h+3,g),d=h+g.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 h=this.previous,p=this.events;let m=0;return g;function g(w){return h===126&&p[p.length-1][1].type!=="characterEscape"?d(w):(u.enter("strikethroughSequenceTemporary"),y(w))}function y(w){const C=cl(h);if(w===126)return m>1?d(w):(u.consume(w),m++,y);if(m<2&&!n)return d(w);const _=u.exit("strikethroughSequenceTemporary"),S=cl(w);return _._open=!S||S===2&&!!C,_._close=!C||C===2&&!!S,c(w)}}}class H6{constructor(){this.map=[]}add(t,n,r){F6(this,t,n,r)}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 r=[];for(;n>0;)n-=1,r.push(t.slice(this.map[n][0]+this.map[n][1]),this.map[n][2]),t.length=this.map[n][0];r.push(t.slice()),t.length=0;let a=r.pop();for(;a;){for(const l of a)t.push(l);a=r.pop()}this.map.length=0}}function F6(e,t,n,r){let a=0;if(!(n===0&&r.length===0)){for(;a<e.map.length;){if(e.map[a][0]===t){e.map[a][1]+=n,e.map[a][2].push(...r);return}a+=1}e.map.push([t,n,r])}}function U6(e,t){let n=!1;const r=[];for(;t<e.length;){const a=e[t];if(n){if(a[0]==="enter")a[1].type==="tableContent"&&r.push(e[t+1][1].type==="tableDelimiterMarker"?"left":"none");else if(a[1].type==="tableContent"){if(e[t-1][1].type==="tableDelimiterMarker"){const l=r.length-1;r[l]=r[l]==="left"?"center":"right"}}else if(a[1].type==="tableDelimiterRow")break}else a[0]==="enter"&&a[1].type==="tableDelimiterRow"&&(n=!0);t+=1}return r}function V6(){return{flow:{null:{name:"table",tokenize:W6,resolveAll:G6}}}}function W6(e,t,n){const r=this;let a=0,l=0,u;return c;function c(P){let V=r.events.length-1;for(;V>-1;){const M=r.events[V][1].type;if(M==="lineEnding"||M==="linePrefix")V--;else break}const z=V>-1?r.events[V][1].type:null,W=z==="tableHead"||z==="tableRow"?N:d;return W===N&&r.parser.lazy[r.now().line]?n(P):W(P)}function d(P){return e.enter("tableHead"),e.enter("tableRow"),h(P)}function h(P){return P===124||(u=!0,l+=1),p(P)}function p(P){return P===null?n(P):ot(P)?l>1?(l=0,r.interrupt=!0,e.exit("tableRow"),e.enter("lineEnding"),e.consume(P),e.exit("lineEnding"),y):n(P):Ct(P)?Tt(e,p,"whitespace")(P):(l+=1,u&&(u=!1,a+=1),P===124?(e.enter("tableCellDivider"),e.consume(P),e.exit("tableCellDivider"),u=!0,p):(e.enter("data"),m(P)))}function m(P){return P===null||P===124||Jt(P)?(e.exit("data"),p(P)):(e.consume(P),P===92?g:m)}function g(P){return P===92||P===124?(e.consume(P),m):m(P)}function y(P){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(P):(e.enter("tableDelimiterRow"),u=!1,Ct(P)?Tt(e,w,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(P):w(P))}function w(P){return P===45||P===58?_(P):P===124?(u=!0,e.enter("tableCellDivider"),e.consume(P),e.exit("tableCellDivider"),C):T(P)}function C(P){return Ct(P)?Tt(e,_,"whitespace")(P):_(P)}function _(P){return P===58?(l+=1,u=!0,e.enter("tableDelimiterMarker"),e.consume(P),e.exit("tableDelimiterMarker"),S):P===45?(l+=1,S(P)):P===null||ot(P)?k(P):T(P)}function S(P){return P===45?(e.enter("tableDelimiterFiller"),b(P)):T(P)}function b(P){return P===45?(e.consume(P),b):P===58?(u=!0,e.exit("tableDelimiterFiller"),e.enter("tableDelimiterMarker"),e.consume(P),e.exit("tableDelimiterMarker"),v):(e.exit("tableDelimiterFiller"),v(P))}function v(P){return Ct(P)?Tt(e,k,"whitespace")(P):k(P)}function k(P){return P===124?w(P):P===null||ot(P)?!u||a!==l?T(P):(e.exit("tableDelimiterRow"),e.exit("tableHead"),t(P)):T(P)}function T(P){return n(P)}function N(P){return e.enter("tableRow"),R(P)}function R(P){return P===124?(e.enter("tableCellDivider"),e.consume(P),e.exit("tableCellDivider"),R):P===null||ot(P)?(e.exit("tableRow"),t(P)):Ct(P)?Tt(e,R,"whitespace")(P):(e.enter("data"),A(P))}function A(P){return P===null||P===124||Jt(P)?(e.exit("data"),R(P)):(e.consume(P),P===92?O:A)}function O(P){return P===92||P===124?(e.consume(P),A):A(P)}}function G6(e,t){let n=-1,r=!0,a=0,l=[0,0,0,0],u=[0,0,0,0],c=!1,d=0,h,p,m;const g=new H6;for(;++n<e.length;){const y=e[n],w=y[1];y[0]==="enter"?w.type==="tableHead"?(c=!1,d!==0&&(Tw(g,t,d,h,p),p=void 0,d=0),h={type:"table",start:Object.assign({},w.start),end:Object.assign({},w.end)},g.add(n,0,[["enter",h,t]])):w.type==="tableRow"||w.type==="tableDelimiterRow"?(r=!0,m=void 0,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)},g.add(n,0,[["enter",p,t]])),a=w.type==="tableDelimiterRow"?2:p?3:1):a&&(w.type==="data"||w.type==="tableDelimiterMarker"||w.type==="tableDelimiterFiller")?(r=!1,u[2]===0&&(l[1]!==0&&(u[0]=u[1],m=Vd(g,t,l,a,void 0,m),l=[0,0,0,0]),u[2]=n)):w.type==="tableCellDivider"&&(r?r=!1:(l[1]!==0&&(u[0]=u[1],m=Vd(g,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=Vd(g,t,l,a,n,m)):u[1]!==0&&(m=Vd(g,t,u,a,n,m)),a=0):a&&(w.type==="data"||w.type==="tableDelimiterMarker"||w.type==="tableDelimiterFiller")&&(u[3]=n)}for(d!==0&&Tw(g,t,d,h,p),g.consume(t.events),n=-1;++n<t.events.length;){const y=t.events[n];y[0]==="enter"&&y[1].type==="table"&&(y[1]._align=U6(t.events,n))}return e}function Vd(e,t,n,r,a,l){const u=r===1?"tableHeader":r===2?"tableDelimiter":"tableData",c="tableContent";n[0]!==0&&(l.end=Object.assign({},Wo(t.events,n[0])),e.add(n[0],0,[["exit",l,t]]));const d=Wo(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 h=Wo(t.events,n[2]),p=Wo(t.events,n[3]),m={type:c,start:Object.assign({},h),end:Object.assign({},p)};if(e.add(n[2],0,[["enter",m,t]]),r!==2){const g=t.events[n[2]],y=t.events[n[3]];if(g[1].end=Object.assign({},y[1].end),g[1].type="chunkText",g[1].contentType="text",n[3]>n[2]+1){const w=n[2]+1,C=n[3]-n[2]-1;e.add(w,C,[])}}e.add(n[3]+1,0,[["exit",m,t]])}return a!==void 0&&(l.end=Object.assign({},Wo(t.events,a)),e.add(a,0,[["exit",l,t]]),l=void 0),l}function Tw(e,t,n,r,a){const l=[],u=Wo(t.events,n);a&&(a.end=Object.assign({},u),l.push(["exit",a,t])),r.end=Object.assign({},u),l.push(["exit",r,t]),e.add(n+1,0,l)}function Wo(e,t){const n=e[t],r=n[0]==="enter"?"start":"end";return n[1][r]}const q6={name:"tasklistCheck",tokenize:Y6};function K6(){return{text:{91:q6}}}function Y6(e,t,n){const r=this;return a;function a(d){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(d):(e.enter("taskListCheck"),e.enter("taskListCheckMarker"),e.consume(d),e.exit("taskListCheckMarker"),l)}function l(d){return Jt(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 ot(d)?t(d):Ct(d)?e.check({tokenize:X6},t,n)(d):n(d)}}function X6(e,t,n){return Tt(e,r,"whitespace");function r(a){return a===null?n(a):t(a)}}function Q6(e){return aj([S6(),R6(),z6(e),V6(),K6()])}const J6={};function Z6(e){const t=this,n=e||J6,r=t.data(),a=r.micromarkExtensions||(r.micromarkExtensions=[]),l=r.fromMarkdownExtensions||(r.fromMarkdownExtensions=[]),u=r.toMarkdownExtensions||(r.toMarkdownExtensions=[]);a.push(Q6(n)),l.push(y6()),u.push(b6(n))}var Vx=Object.defineProperty,eB=Object.getOwnPropertyDescriptor,tB=Object.getOwnPropertyNames,nB=Object.prototype.hasOwnProperty,ob=(e,t)=>{let n={};for(var r in e)Vx(n,r,{get:e[r],enumerable:!0});return Vx(n,Symbol.toStringTag,{value:"Module"}),n},rB=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(var a=tB(t),l=0,u=a.length,c;l<u;l++)c=a[l],!nB.call(e,c)&&c!==n&&Vx(e,c,{get:(d=>t[d]).bind(null,c),enumerable:!(r=eB(t,c))||r.enumerable});return e},Qj=(e,t,n)=>(rB(e,t,"default"),n);const jf=[{id:"abap",name:"ABAP",import:(()=>te(()=>import("./abap-BdImnpbu.js"),[]))},{id:"actionscript-3",name:"ActionScript",import:(()=>te(()=>import("./actionscript-3-CoDkCxhg.js"),[]))},{id:"ada",name:"Ada",import:(()=>te(()=>import("./ada-bCR0ucgS.js"),[]))},{id:"angular-html",name:"Angular HTML",import:(()=>te(()=>import("./angular-html-DA-rfuFy.js").then(e=>e.f),__vite__mapDeps([0,1,2,3])))},{id:"angular-ts",name:"Angular TypeScript",import:(()=>te(()=>import("./angular-ts-BrjP3tb8.js"),__vite__mapDeps([4,0,1,2,3,5])))},{id:"apache",name:"Apache Conf",import:(()=>te(()=>import("./apache-Pmp26Uib.js"),[]))},{id:"apex",name:"Apex",import:(()=>te(()=>import("./apex-Dqspr-GT.js"),[]))},{id:"apl",name:"APL",import:(()=>te(()=>import("./apl-CORt7UWP.js"),__vite__mapDeps([6,1,2,3,7,8,9])))},{id:"applescript",name:"AppleScript",import:(()=>te(()=>import("./applescript-Co6uUVPk.js"),[]))},{id:"ara",name:"Ara",import:(()=>te(()=>import("./ara-BRHolxvo.js"),[]))},{id:"asciidoc",name:"AsciiDoc",aliases:["adoc"],import:(()=>te(()=>import("./asciidoc-Ve4PFQV2.js"),[]))},{id:"asm",name:"Assembly",import:(()=>te(()=>import("./asm-D_Q5rh1f.js"),[]))},{id:"astro",name:"Astro",import:(()=>te(()=>import("./astro-HNnZUWAn.js"),__vite__mapDeps([10,9,2,11,3,12,13])))},{id:"awk",name:"AWK",import:(()=>te(()=>import("./awk-DMzUqQB5.js"),[]))},{id:"ballerina",name:"Ballerina",import:(()=>te(()=>import("./ballerina-BFfxhgS-.js"),[]))},{id:"bat",name:"Batch File",aliases:["batch"],import:(()=>te(()=>import("./bat-BkioyH1T.js"),[]))},{id:"beancount",name:"Beancount",import:(()=>te(()=>import("./beancount-k_qm7-4y.js"),[]))},{id:"berry",name:"Berry",aliases:["be"],import:(()=>te(()=>import("./berry-uYugtg8r.js"),[]))},{id:"bibtex",name:"BibTeX",import:(()=>te(()=>import("./bibtex-CHM0blh-.js"),[]))},{id:"bicep",name:"Bicep",import:(()=>te(()=>import("./bicep-Bmn6On1c.js"),[]))},{id:"bird2",name:"BIRD2 Configuration",aliases:["bird"],import:(()=>te(()=>import("./bird2-BIv1doCn.js"),[]))},{id:"blade",name:"Blade",import:(()=>te(()=>import("./blade-2xfisSek.js"),__vite__mapDeps([14,15,1,2,3,7,8,16,9])))},{id:"bsl",name:"1C (Enterprise)",aliases:["1c"],import:(()=>te(()=>import("./bsl-BO_Y6i37.js"),__vite__mapDeps([17,18])))},{id:"c",name:"C",import:(()=>te(()=>import("./c-BIGW1oBm.js"),[]))},{id:"c3",name:"C3",import:(()=>te(()=>import("./c3-MRO5bC_T.js"),[]))},{id:"cadence",name:"Cadence",aliases:["cdc"],import:(()=>te(()=>import("./cadence-Bv_4Rxtq.js"),[]))},{id:"cairo",name:"Cairo",import:(()=>te(()=>import("./cairo-KRGpt6FW.js"),__vite__mapDeps([19,20])))},{id:"clarity",name:"Clarity",import:(()=>te(()=>import("./clarity-D53aC0YG.js"),[]))},{id:"clojure",name:"Clojure",aliases:["clj"],import:(()=>te(()=>import("./clojure-P80f7IUj.js"),[]))},{id:"cmake",name:"CMake",import:(()=>te(()=>import("./cmake-D1j8_8rp.js"),[]))},{id:"cobol",name:"COBOL",import:(()=>te(()=>import("./cobol-nBiQ_Alo.js"),__vite__mapDeps([21,1,2,3,8])))},{id:"codeowners",name:"CODEOWNERS",import:(()=>te(()=>import("./codeowners-Bp6g37R7.js"),[]))},{id:"codeql",name:"CodeQL",aliases:["ql"],import:(()=>te(()=>import("./codeql-DsOJ9woJ.js"),[]))},{id:"coffee",name:"CoffeeScript",aliases:["coffeescript"],import:(()=>te(()=>import("./coffee-Ch7k5sss.js"),__vite__mapDeps([22,2])))},{id:"common-lisp",name:"Common Lisp",aliases:["lisp"],import:(()=>te(()=>import("./common-lisp-Cg-RD9OK.js"),[]))},{id:"coq",name:"Coq",import:(()=>te(()=>import("./coq-DkFqJrB1.js"),[]))},{id:"cpp",name:"C++",aliases:["c++"],import:(()=>te(()=>import("./cpp-UfJy6YNI.js"),__vite__mapDeps([23,24,25,26,16])))},{id:"crystal",name:"Crystal",import:(()=>te(()=>import("./crystal-DGywbUpC.js"),__vite__mapDeps([27,1,2,3,16,26,28])))},{id:"csharp",name:"C#",aliases:["c#","cs"],import:(()=>te(()=>import("./csharp-DSvCPggb.js"),[]))},{id:"css",name:"CSS",import:(()=>te(()=>import("./css-CLj8gQPS.js"),[]))},{id:"csv",name:"CSV",import:(()=>te(()=>import("./csv-fuZLfV_i.js"),[]))},{id:"cue",name:"CUE",import:(()=>te(()=>import("./cue-D82EKSYY.js"),[]))},{id:"cypher",name:"Cypher",aliases:["cql"],import:(()=>te(()=>import("./cypher-COkxafJQ.js"),[]))},{id:"d",name:"D",import:(()=>te(()=>import("./d-85-TOEBH.js"),[]))},{id:"dart",name:"Dart",import:(()=>te(()=>import("./dart-bE4Kk8sk.js"),[]))},{id:"dax",name:"DAX",import:(()=>te(()=>import("./dax-CEL-wOlO.js"),[]))},{id:"desktop",name:"Desktop",import:(()=>te(()=>import("./desktop-BmXAJ9_W.js"),[]))},{id:"diff",name:"Diff",import:(()=>te(()=>import("./diff-D97Zzqfu.js"),[]))},{id:"docker",name:"Dockerfile",aliases:["dockerfile"],import:(()=>te(()=>import("./docker-BcOcwvcX.js"),[]))},{id:"dotenv",name:"dotEnv",import:(()=>te(()=>import("./dotenv-Da5cRb03.js"),[]))},{id:"dream-maker",name:"Dream Maker",import:(()=>te(()=>import("./dream-maker-BtqSS_iP.js"),[]))},{id:"edge",name:"Edge",import:(()=>te(()=>import("./edge-FbVlp4U3.js"),__vite__mapDeps([29,11,1,2,3,15])))},{id:"elixir",name:"Elixir",import:(()=>te(()=>import("./elixir-CkH2-t6x.js"),__vite__mapDeps([30,1,2,3])))},{id:"elm",name:"Elm",import:(()=>te(()=>import("./elm-DbKCFpqz.js"),__vite__mapDeps([31,25,26])))},{id:"emacs-lisp",name:"Emacs Lisp",aliases:["elisp"],import:(()=>te(()=>import("./emacs-lisp-CXvaQtF9.js"),[]))},{id:"erb",name:"ERB",import:(()=>te(()=>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:(()=>te(()=>import("./erlang-DsQrWhSR.js"),__vite__mapDeps([39,40])))},{id:"fennel",name:"Fennel",import:(()=>te(()=>import("./fennel-BYunw83y.js"),[]))},{id:"fish",name:"Fish",import:(()=>te(()=>import("./fish-BvzEVeQv.js"),[]))},{id:"fluent",name:"Fluent",aliases:["ftl"],import:(()=>te(()=>import("./fluent-C4IJs8-o.js"),[]))},{id:"fortran-fixed-form",name:"Fortran (Fixed Form)",aliases:["f","for","f77"],import:(()=>te(()=>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:(()=>te(()=>import("./fortran-free-form-BxgE0vQu.js"),[]))},{id:"fsharp",name:"F#",aliases:["f#","fs"],import:(()=>te(()=>import("./fsharp-CXgrBDvD.js"),__vite__mapDeps([43,40])))},{id:"gdresource",name:"GDResource",aliases:["tscn","tres"],import:(()=>te(()=>import("./gdresource-BOOCDP_w.js"),__vite__mapDeps([44,45,46])))},{id:"gdscript",name:"GDScript",aliases:["gd"],import:(()=>te(()=>import("./gdscript-C5YyOfLZ.js"),[]))},{id:"gdshader",name:"GDShader",import:(()=>te(()=>import("./gdshader-DkwncUOv.js"),[]))},{id:"genie",name:"Genie",import:(()=>te(()=>import("./genie-D0YGMca9.js"),[]))},{id:"gherkin",name:"Gherkin",import:(()=>te(()=>import("./gherkin-DyxjwDmM.js"),[]))},{id:"git-commit",name:"Git Commit Message",import:(()=>te(()=>import("./git-commit-F4YmCXRG.js"),__vite__mapDeps([47,48])))},{id:"git-rebase",name:"Git Rebase Message",import:(()=>te(()=>import("./git-rebase-r7XF79zn.js"),__vite__mapDeps([49,28])))},{id:"gleam",name:"Gleam",import:(()=>te(()=>import("./gleam-BspZqrRM.js"),[]))},{id:"glimmer-js",name:"Glimmer JS",aliases:["gjs"],import:(()=>te(()=>import("./glimmer-js-ByusRIyA.js"),__vite__mapDeps([50,2,11,3,1])))},{id:"glimmer-ts",name:"Glimmer TS",aliases:["gts"],import:(()=>te(()=>import("./glimmer-ts-BfAWNZQY.js"),__vite__mapDeps([51,11,3,2,1])))},{id:"glsl",name:"GLSL",import:(()=>te(()=>import("./glsl-DplSGwfg.js"),__vite__mapDeps([25,26])))},{id:"gn",name:"GN",import:(()=>te(()=>import("./gn-n2N0HUVH.js"),[]))},{id:"gnuplot",name:"Gnuplot",import:(()=>te(()=>import("./gnuplot-DdkO51Og.js"),[]))},{id:"go",name:"Go",import:(()=>te(()=>import("./go-C27-OAKa.js"),[]))},{id:"graphql",name:"GraphQL",aliases:["gql"],import:(()=>te(()=>import("./graphql-ChdNCCLP.js"),__vite__mapDeps([35,2,11,36,13])))},{id:"groovy",name:"Groovy",import:(()=>te(()=>import("./groovy-gcz8RCvz.js"),[]))},{id:"hack",name:"Hack",import:(()=>te(()=>import("./hack-DbPARsA_.js"),__vite__mapDeps([52,1,2,3,16])))},{id:"haml",name:"Ruby Haml",import:(()=>te(()=>import("./haml-D5jkg6IW.js"),__vite__mapDeps([34,2,3])))},{id:"handlebars",name:"Handlebars",aliases:["hbs"],import:(()=>te(()=>import("./handlebars-BpdQsYii.js"),__vite__mapDeps([53,1,2,3,38])))},{id:"haskell",name:"Haskell",aliases:["hs"],import:(()=>te(()=>import("./haskell-Df6bDoY_.js"),[]))},{id:"haxe",name:"Haxe",import:(()=>te(()=>import("./haxe-CzTSHFRz.js"),[]))},{id:"hcl",name:"HashiCorp HCL",import:(()=>te(()=>import("./hcl-BWvSN4gD.js"),[]))},{id:"hjson",name:"Hjson",import:(()=>te(()=>import("./hjson-D5-asLiD.js"),[]))},{id:"hlsl",name:"HLSL",import:(()=>te(()=>import("./hlsl-D3lLCCz7.js"),[]))},{id:"html",name:"HTML",import:(()=>te(()=>import("./html-pp8916En.js"),__vite__mapDeps([1,2,3])))},{id:"html-derivative",name:"HTML (Derivative)",import:(()=>te(()=>import("./html-derivative-DlHx6ybY.js"),__vite__mapDeps([15,1,2,3])))},{id:"http",name:"HTTP",import:(()=>te(()=>import("./http-jrhK8wxY.js"),__vite__mapDeps([54,28,9,7,8,35,2,11,36,13])))},{id:"hurl",name:"Hurl",import:(()=>te(()=>import("./hurl-irOxFIW8.js"),__vite__mapDeps([55,35,2,11,36,13,7,8,56])))},{id:"hxml",name:"HXML",import:(()=>te(()=>import("./hxml-Bvhsp5Yf.js"),__vite__mapDeps([57,58])))},{id:"hy",name:"Hy",import:(()=>te(()=>import("./hy-DFXneXwc.js"),[]))},{id:"imba",name:"Imba",import:(()=>te(()=>import("./imba-DGztddWO.js"),[]))},{id:"ini",name:"INI",aliases:["properties"],import:(()=>te(()=>import("./ini-BEwlwnbL.js"),[]))},{id:"java",name:"Java",import:(()=>te(()=>import("./java-CylS5w8V.js"),[]))},{id:"javascript",name:"JavaScript",aliases:["js","cjs","mjs"],import:(()=>te(()=>import("./javascript-wDzz0qaB.js"),[]))},{id:"jinja",name:"Jinja",import:(()=>te(()=>import("./jinja-f2NsQr07.js"),__vite__mapDeps([59,1,2,3])))},{id:"jison",name:"Jison",import:(()=>te(()=>import("./jison-wvAkD_A8.js"),__vite__mapDeps([60,2])))},{id:"json",name:"JSON",import:(()=>te(()=>import("./json-Cp-IABpG.js"),[]))},{id:"json5",name:"JSON5",import:(()=>te(()=>import("./json5-C9tS-k6U.js"),[]))},{id:"jsonc",name:"JSON with Comments",import:(()=>te(()=>import("./jsonc-Des-eS-w.js"),[]))},{id:"jsonl",name:"JSON Lines",import:(()=>te(()=>import("./jsonl-DcaNXYhu.js"),[]))},{id:"jsonnet",name:"Jsonnet",import:(()=>te(()=>import("./jsonnet-DFQXde-d.js"),[]))},{id:"jssm",name:"JSSM",aliases:["fsl"],import:(()=>te(()=>import("./jssm-C2t-YnRu.js"),[]))},{id:"jsx",name:"JSX",import:(()=>te(()=>import("./jsx-g9-lgVsj.js"),[]))},{id:"julia",name:"Julia",aliases:["jl"],import:(()=>te(()=>import("./julia-D7OTSIA_.js"),__vite__mapDeps([61,23,24,25,26,16,20,2,62])))},{id:"just",name:"Just",import:(()=>te(()=>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:(()=>te(()=>import("./kdl-DV7GczEv.js"),[]))},{id:"kotlin",name:"Kotlin",aliases:["kt","kts"],import:(()=>te(()=>import("./kotlin-BdnUsdx6.js"),[]))},{id:"kusto",name:"Kusto",aliases:["kql"],import:(()=>te(()=>import("./kusto-wEQ09or8.js"),[]))},{id:"latex",name:"LaTeX",import:(()=>te(()=>import("./latex-CaSxy8MP.js"),__vite__mapDeps([65,66,62])))},{id:"lean",name:"Lean 4",aliases:["lean4"],import:(()=>te(()=>import("./lean-BZvkOJ9d.js"),[]))},{id:"less",name:"Less",import:(()=>te(()=>import("./less-B1dDrJ26.js"),[]))},{id:"liquid",name:"Liquid",import:(()=>te(()=>import("./liquid-C0sCDyMI.js"),__vite__mapDeps([67,1,2,3,9])))},{id:"llvm",name:"LLVM IR",import:(()=>te(()=>import("./llvm-DjAJT7YJ.js"),[]))},{id:"log",name:"Log file",import:(()=>te(()=>import("./log-2UxHyX5q.js"),[]))},{id:"logo",name:"Logo",import:(()=>te(()=>import("./logo-BtOb2qkB.js"),[]))},{id:"lua",name:"Lua",import:(()=>te(()=>import("./lua-BaeVxFsk.js"),__vite__mapDeps([37,26])))},{id:"luau",name:"Luau",import:(()=>te(()=>import("./luau-KW6xsasC.js"),[]))},{id:"make",name:"Makefile",aliases:["makefile"],import:(()=>te(()=>import("./make-CHLpvVh8.js"),[]))},{id:"markdown",name:"Markdown",aliases:["md"],import:(()=>te(()=>import("./markdown-Cvjx9yec.js"),[]))},{id:"marko",name:"Marko",import:(()=>te(()=>import("./marko-DjSrsDqO.js"),__vite__mapDeps([68,3,69,5,11])))},{id:"matlab",name:"MATLAB",import:(()=>te(()=>import("./matlab-D7o27uSR.js"),[]))},{id:"mdc",name:"MDC",import:(()=>te(()=>import("./mdc-DTYItulj.js"),__vite__mapDeps([70,40,38,15,1,2,3])))},{id:"mdx",name:"MDX",import:(()=>te(()=>import("./mdx-Cmh6b_Ma.js"),[]))},{id:"mermaid",name:"Mermaid",aliases:["mmd"],import:(()=>te(()=>import("./mermaid-mWjccvbQ.js"),[]))},{id:"mipsasm",name:"MIPS Assembly",aliases:["mips"],import:(()=>te(()=>import("./mipsasm-CKIfxQSi.js"),[]))},{id:"mojo",name:"Mojo",import:(()=>te(()=>import("./mojo-rZm6bMo-.js"),[]))},{id:"moonbit",name:"MoonBit",aliases:["mbt","mbti"],import:(()=>te(()=>import("./moonbit-_H4v1dQx.js"),[]))},{id:"move",name:"Move",import:(()=>te(()=>import("./move-IF9eRakj.js"),[]))},{id:"narrat",name:"Narrat Language",aliases:["nar"],import:(()=>te(()=>import("./narrat-DRg8JJMk.js"),[]))},{id:"nextflow",name:"Nextflow",aliases:["nf"],import:(()=>te(()=>import("./nextflow-C-mBbutL.js"),__vite__mapDeps([71,72])))},{id:"nextflow-groovy",name:"Nextflow Groovy",import:(()=>te(()=>import("./nextflow-groovy-vE_lwT2v.js"),[]))},{id:"nginx",name:"Nginx",import:(()=>te(()=>import("./nginx-BpAMiNFr.js"),__vite__mapDeps([73,37,26])))},{id:"nim",name:"Nim",import:(()=>te(()=>import("./nim-BIad80T-.js"),__vite__mapDeps([74,26,1,2,3,7,8,25,40])))},{id:"nix",name:"Nix",import:(()=>te(()=>import("./nix-CwoSXNpI.js"),[]))},{id:"nushell",name:"nushell",aliases:["nu"],import:(()=>te(()=>import("./nushell-Cz2AlsmD.js"),[]))},{id:"objective-c",name:"Objective-C",aliases:["objc"],import:(()=>te(()=>import("./objective-c-DXmwc3jG.js"),[]))},{id:"objective-cpp",name:"Objective-C++",import:(()=>te(()=>import("./objective-cpp-CLxacb5B.js"),[]))},{id:"ocaml",name:"OCaml",import:(()=>te(()=>import("./ocaml-C0hk2d4L.js"),[]))},{id:"odin",name:"Odin",import:(()=>te(()=>import("./odin-BBf5iR-q.js"),[]))},{id:"openscad",name:"OpenSCAD",aliases:["scad"],import:(()=>te(()=>import("./openscad-C4EeE6gA.js"),[]))},{id:"pascal",name:"Pascal",import:(()=>te(()=>import("./pascal-D93ZcfNL.js"),[]))},{id:"perl",name:"Perl",import:(()=>te(()=>import("./perl-B9cMNwum.js"),__vite__mapDeps([64,1,2,3,7,8,16])))},{id:"php",name:"PHP",import:(()=>te(()=>import("./php-Csjmro_R.js"),__vite__mapDeps([75,1,2,3,7,8,16,9])))},{id:"pkl",name:"Pkl",import:(()=>te(()=>import("./pkl-u5AG7uiY.js"),[]))},{id:"plsql",name:"PL/SQL",import:(()=>te(()=>import("./plsql-ChMvpjG-.js"),[]))},{id:"po",name:"Gettext PO",aliases:["pot","potx"],import:(()=>te(()=>import("./po-BTJTHyun.js"),[]))},{id:"polar",name:"Polar",import:(()=>te(()=>import("./polar-C0HS_06l.js"),[]))},{id:"postcss",name:"PostCSS",import:(()=>te(()=>import("./postcss-CXtECtnM.js"),[]))},{id:"powerquery",name:"PowerQuery",import:(()=>te(()=>import("./powerquery-CEu0bR-o.js"),[]))},{id:"powershell",name:"PowerShell",aliases:["ps","ps1"],import:(()=>te(()=>import("./powershell-Dpen1YoG.js"),[]))},{id:"prisma",name:"Prisma",import:(()=>te(()=>import("./prisma-Dd19v3D-.js"),[]))},{id:"prolog",name:"Prolog",import:(()=>te(()=>import("./prolog-CbFg5uaA.js"),[]))},{id:"proto",name:"Protocol Buffer 3",aliases:["protobuf"],import:(()=>te(()=>import("./proto-C7zT0LnQ.js"),[]))},{id:"pug",name:"Pug",aliases:["jade"],import:(()=>te(()=>import("./pug-DKIMFp6K.js"),__vite__mapDeps([76,2,3,1])))},{id:"puppet",name:"Puppet",import:(()=>te(()=>import("./puppet-BMWR74SV.js"),[]))},{id:"purescript",name:"PureScript",import:(()=>te(()=>import("./purescript-CklMAg4u.js"),[]))},{id:"python",name:"Python",aliases:["py"],import:(()=>te(()=>import("./python-B6aJPvgy.js"),[]))},{id:"qml",name:"QML",import:(()=>te(()=>import("./qml-3beO22l8.js"),__vite__mapDeps([77,2])))},{id:"qmldir",name:"QML Directory",import:(()=>te(()=>import("./qmldir-C8lEn-DE.js"),[]))},{id:"qss",name:"Qt Style Sheets",import:(()=>te(()=>import("./qss-IeuSbFQv.js"),[]))},{id:"r",name:"R",import:(()=>te(()=>import("./r-Dspwwk_N.js"),[]))},{id:"racket",name:"Racket",import:(()=>te(()=>import("./racket-BqYA7rlc.js"),[]))},{id:"raku",name:"Raku",aliases:["perl6"],import:(()=>te(()=>import("./raku-DXvB9xmW.js"),[]))},{id:"razor",name:"ASP.NET Razor",import:(()=>te(()=>import("./razor-BjBPvh-w.js"),__vite__mapDeps([78,1,2,3,79])))},{id:"reg",name:"Windows Registry Script",import:(()=>te(()=>import("./reg-C-SQnVFl.js"),[]))},{id:"regexp",name:"RegExp",aliases:["regex"],import:(()=>te(()=>import("./regexp-CDVJQ6XC.js"),[]))},{id:"rel",name:"Rel",import:(()=>te(()=>import("./rel-C3B-1QV4.js"),[]))},{id:"riscv",name:"RISC-V",import:(()=>te(()=>import("./riscv-BM1_JUlF.js"),[]))},{id:"ron",name:"RON",import:(()=>te(()=>import("./ron-D8l8udqQ.js"),[]))},{id:"rosmsg",name:"ROS Interface",import:(()=>te(()=>import("./rosmsg-BJDFO7_C.js"),[]))},{id:"rst",name:"reStructuredText",import:(()=>te(()=>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:(()=>te(()=>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:(()=>te(()=>import("./rust-B1yitclQ.js"),[]))},{id:"sas",name:"SAS",import:(()=>te(()=>import("./sas-DEy46yEz.js"),__vite__mapDeps([82,16])))},{id:"sass",name:"Sass",import:(()=>te(()=>import("./sass-Cj5Yp3dK.js"),[]))},{id:"scala",name:"Scala",import:(()=>te(()=>import("./scala-C151Ov-r.js"),[]))},{id:"scheme",name:"Scheme",import:(()=>te(()=>import("./scheme-C98Dy4si.js"),[]))},{id:"scss",name:"SCSS",import:(()=>te(()=>import("./scss-D5BDwBP9.js"),__vite__mapDeps([5,3])))},{id:"sdbl",name:"1C (Query)",aliases:["1c-query"],import:(()=>te(()=>import("./sdbl-DVxCFoDh.js"),[]))},{id:"shaderlab",name:"ShaderLab",aliases:["shader"],import:(()=>te(()=>import("./shaderlab-Dg9Lc6iA.js"),__vite__mapDeps([83,84])))},{id:"shellscript",name:"Shell",aliases:["bash","sh","shell","zsh"],import:(()=>te(()=>import("./shellscript-Yzrsuije.js"),[]))},{id:"shellsession",name:"Shell Session",aliases:["console"],import:(()=>te(()=>import("./shellsession-BADoaaVG.js"),__vite__mapDeps([85,28])))},{id:"smalltalk",name:"Smalltalk",import:(()=>te(()=>import("./smalltalk-BERRCDM3.js"),[]))},{id:"solidity",name:"Solidity",import:(()=>te(()=>import("./solidity-rGO070M0.js"),[]))},{id:"soy",name:"Closure Templates",aliases:["closure-templates"],import:(()=>te(()=>import("./soy-8wufbnw4.js"),__vite__mapDeps([86,1,2,3])))},{id:"sparql",name:"SPARQL",import:(()=>te(()=>import("./sparql-rVzFXLq3.js"),__vite__mapDeps([87,88])))},{id:"splunk",name:"Splunk Query Language",aliases:["spl"],import:(()=>te(()=>import("./splunk-BtCnVYZw.js"),[]))},{id:"sql",name:"SQL",import:(()=>te(()=>import("./sql-CRqJ_cUM.js"),[]))},{id:"ssh-config",name:"SSH Config",import:(()=>te(()=>import("./ssh-config-_ykCGR6B.js"),[]))},{id:"stata",name:"Stata",import:(()=>te(()=>import("./stata-DI20mbqo.js"),__vite__mapDeps([89,16])))},{id:"stylus",name:"Stylus",aliases:["styl"],import:(()=>te(()=>import("./stylus-BEDo0Tqx.js"),[]))},{id:"surrealql",name:"SurrealQL",aliases:["surql"],import:(()=>te(()=>import("./surrealql-Bq5Q-fJD.js"),__vite__mapDeps([90,2])))},{id:"svelte",name:"Svelte",import:(()=>te(()=>import("./svelte-Cy7k_4gC.js"),__vite__mapDeps([91,2,11,3,12])))},{id:"swift",name:"Swift",import:(()=>te(()=>import("./swift-D82vCrfD.js"),[]))},{id:"system-verilog",name:"SystemVerilog",import:(()=>te(()=>import("./system-verilog-CnnmHF94.js"),[]))},{id:"systemd",name:"Systemd Units",import:(()=>te(()=>import("./systemd-4A_iFExJ.js"),[]))},{id:"talonscript",name:"TalonScript",aliases:["talon"],import:(()=>te(()=>import("./talonscript-CkByrt1z.js"),[]))},{id:"tasl",name:"Tasl",import:(()=>te(()=>import("./tasl-QIJgUcNo.js"),[]))},{id:"tcl",name:"Tcl",import:(()=>te(()=>import("./tcl-dwOrl1Do.js"),[]))},{id:"templ",name:"Templ",import:(()=>te(()=>import("./templ-DhtptRzy.js"),__vite__mapDeps([92,93,2,3])))},{id:"terraform",name:"Terraform",aliases:["tf","tfvars"],import:(()=>te(()=>import("./terraform-BETggiCN.js"),[]))},{id:"tex",name:"TeX",import:(()=>te(()=>import("./tex-idrVyKtj.js"),__vite__mapDeps([66,62])))},{id:"toml",name:"TOML",import:(()=>te(()=>import("./toml-vGWfd6FD.js"),[]))},{id:"ts-tags",name:"TypeScript with Tags",aliases:["lit"],import:(()=>te(()=>import("./ts-tags-D351s5mN.js"),__vite__mapDeps([94,11,3,2,25,26,1,16,7,8])))},{id:"tsv",name:"TSV",import:(()=>te(()=>import("./tsv-B_m7g4N7.js"),[]))},{id:"tsx",name:"TSX",import:(()=>te(()=>import("./tsx-COt5Ahok.js"),[]))},{id:"turtle",name:"Turtle",import:(()=>te(()=>import("./turtle-BsS91CYL.js"),[]))},{id:"twig",name:"Twig",import:(()=>te(()=>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:(()=>te(()=>import("./typescript-BPQ3VLAy.js"),[]))},{id:"typespec",name:"TypeSpec",aliases:["tsp"],import:(()=>te(()=>import("./typespec-CAFt9gP4.js"),[]))},{id:"typst",name:"Typst",aliases:["typ"],import:(()=>te(()=>import("./typst-DHCkPAjA.js"),[]))},{id:"v",name:"V",import:(()=>te(()=>import("./v-BcVCzyr7.js"),[]))},{id:"vala",name:"Vala",import:(()=>te(()=>import("./vala-CsfeWuGM.js"),[]))},{id:"vb",name:"Visual Basic",aliases:["cmd"],import:(()=>te(()=>import("./vb-D17OF-Vu.js"),[]))},{id:"verilog",name:"Verilog",import:(()=>te(()=>import("./verilog-BQ8w6xss.js"),[]))},{id:"vhdl",name:"VHDL",import:(()=>te(()=>import("./vhdl-CeAyd5Ju.js"),[]))},{id:"viml",name:"Vim Script",aliases:["vim","vimscript"],import:(()=>te(()=>import("./viml-CJc9bBzg.js"),[]))},{id:"vue",name:"Vue",import:(()=>te(()=>import("./vue-D2xRrEX4.js"),__vite__mapDeps([96,3,2,11,9,1,15])))},{id:"vue-html",name:"Vue HTML",import:(()=>te(()=>import("./vue-html-AaS7Mt5G.js"),__vite__mapDeps([97,2])))},{id:"vue-vine",name:"Vue Vine",import:(()=>te(()=>import("./vue-vine-BoDAl6tE.js"),__vite__mapDeps([98,3,5,69,99,12,2])))},{id:"vyper",name:"Vyper",aliases:["vy"],import:(()=>te(()=>import("./vyper-CDx5xZoG.js"),[]))},{id:"wasm",name:"WebAssembly",import:(()=>te(()=>import("./wasm-MzD3tlZU.js"),[]))},{id:"wenyan",name:"Wenyan",aliases:["文言"],import:(()=>te(()=>import("./wenyan-BV7otONQ.js"),[]))},{id:"wgsl",name:"WGSL",import:(()=>te(()=>import("./wgsl-Dx-B1_4e.js"),[]))},{id:"wikitext",name:"Wikitext",aliases:["mediawiki","wiki"],import:(()=>te(()=>import("./wikitext-BhOHFoWU.js"),[]))},{id:"wit",name:"WebAssembly Interface Types",import:(()=>te(()=>import("./wit-5i3qLPDT.js"),[]))},{id:"wolfram",name:"Wolfram",aliases:["wl"],import:(()=>te(()=>import("./wolfram-lXgVvXCa.js"),[]))},{id:"xml",name:"XML",import:(()=>te(()=>import("./xml-sdJ4AIDG.js"),__vite__mapDeps([7,8])))},{id:"xsl",name:"XSL",import:(()=>te(()=>import("./xsl-CtQFsRM5.js"),__vite__mapDeps([100,7,8])))},{id:"yaml",name:"YAML",aliases:["yml"],import:(()=>te(()=>import("./yaml-Buea-lGh.js"),[]))},{id:"zenscript",name:"ZenScript",import:(()=>te(()=>import("./zenscript-DVFEvuxE.js"),[]))},{id:"zig",name:"Zig",import:(()=>te(()=>import("./zig-VOosw3JB.js"),[]))}],lb=Object.fromEntries(jf.map(e=>[e.id,e.import])),cb=Object.fromEntries(jf.flatMap(e=>{var t;return((t=e.aliases)==null?void 0:t.map(n=>[n,e.import]))||[]})),Nf={...lb,...cb},ub=[{id:"andromeeda",displayName:"Andromeeda",type:"dark",import:(()=>te(()=>import("./andromeeda-C4gqWexZ.js"),[]))},{id:"aurora-x",displayName:"Aurora X",type:"dark",import:(()=>te(()=>import("./aurora-x-D-2ljcwZ.js"),[]))},{id:"ayu-dark",displayName:"Ayu Dark",type:"dark",import:(()=>te(()=>import("./ayu-dark-DYE7WIF3.js"),[]))},{id:"ayu-light",displayName:"Ayu Light",type:"light",import:(()=>te(()=>import("./ayu-light-BA47KaF1.js"),[]))},{id:"ayu-mirage",displayName:"Ayu Mirage",type:"dark",import:(()=>te(()=>import("./ayu-mirage-32ctXXKs.js"),[]))},{id:"catppuccin-frappe",displayName:"Catppuccin Frappé",type:"dark",import:(()=>te(()=>import("./catppuccin-frappe-DFWUc33u.js"),[]))},{id:"catppuccin-latte",displayName:"Catppuccin Latte",type:"light",import:(()=>te(()=>import("./catppuccin-latte-C9dUb6Cb.js"),[]))},{id:"catppuccin-macchiato",displayName:"Catppuccin Macchiato",type:"dark",import:(()=>te(()=>import("./catppuccin-macchiato-DQyhUUbL.js"),[]))},{id:"catppuccin-mocha",displayName:"Catppuccin Mocha",type:"dark",import:(()=>te(()=>import("./catppuccin-mocha-D87Tk5Gz.js"),[]))},{id:"dark-plus",displayName:"Dark Plus",type:"dark",import:(()=>te(()=>import("./dark-plus-C3mMm8J8.js"),[]))},{id:"dracula",displayName:"Dracula Theme",type:"dark",import:(()=>te(()=>import("./dracula-BzJJZx-M.js"),[]))},{id:"dracula-soft",displayName:"Dracula Theme Soft",type:"dark",import:(()=>te(()=>import("./dracula-soft-BXkSAIEj.js"),[]))},{id:"everforest-dark",displayName:"Everforest Dark",type:"dark",import:(()=>te(()=>import("./everforest-dark-BgDCqdQA.js"),[]))},{id:"everforest-light",displayName:"Everforest Light",type:"light",import:(()=>te(()=>import("./everforest-light-C8M2exoo.js"),[]))},{id:"github-dark",displayName:"GitHub Dark",type:"dark",import:(()=>te(()=>import("./github-dark-DHJKELXO.js"),[]))},{id:"github-dark-default",displayName:"GitHub Dark Default",type:"dark",import:(()=>te(()=>import("./github-dark-default-Cuk6v7N8.js"),[]))},{id:"github-dark-dimmed",displayName:"GitHub Dark Dimmed",type:"dark",import:(()=>te(()=>import("./github-dark-dimmed-DH5Ifo-i.js"),[]))},{id:"github-dark-high-contrast",displayName:"GitHub Dark High Contrast",type:"dark",import:(()=>te(()=>import("./github-dark-high-contrast-E3gJ1_iC.js"),[]))},{id:"github-light",displayName:"GitHub Light",type:"light",import:(()=>te(()=>import("./github-light-DAi9KRSo.js"),[]))},{id:"github-light-default",displayName:"GitHub Light Default",type:"light",import:(()=>te(()=>import("./github-light-default-D7oLnXFd.js"),[]))},{id:"github-light-high-contrast",displayName:"GitHub Light High Contrast",type:"light",import:(()=>te(()=>import("./github-light-high-contrast-BfjtVDDH.js"),[]))},{id:"gruvbox-dark-hard",displayName:"Gruvbox Dark Hard",type:"dark",import:(()=>te(()=>import("./gruvbox-dark-hard-CFHQjOhq.js"),[]))},{id:"gruvbox-dark-medium",displayName:"Gruvbox Dark Medium",type:"dark",import:(()=>te(()=>import("./gruvbox-dark-medium-GsRaNv29.js"),[]))},{id:"gruvbox-dark-soft",displayName:"Gruvbox Dark Soft",type:"dark",import:(()=>te(()=>import("./gruvbox-dark-soft-CVdnzihN.js"),[]))},{id:"gruvbox-light-hard",displayName:"Gruvbox Light Hard",type:"light",import:(()=>te(()=>import("./gruvbox-light-hard-CH1njM8p.js"),[]))},{id:"gruvbox-light-medium",displayName:"Gruvbox Light Medium",type:"light",import:(()=>te(()=>import("./gruvbox-light-medium-DRw_LuNl.js"),[]))},{id:"gruvbox-light-soft",displayName:"Gruvbox Light Soft",type:"light",import:(()=>te(()=>import("./gruvbox-light-soft-hJgmCMqR.js"),[]))},{id:"horizon",displayName:"Horizon",type:"dark",import:(()=>te(()=>import("./horizon-BUw7H-hv.js"),[]))},{id:"horizon-bright",displayName:"Horizon Bright",type:"light",import:(()=>te(()=>import("./horizon-bright-CUuTKBJd.js"),[]))},{id:"houston",displayName:"Houston",type:"dark",import:(()=>te(()=>import("./houston-DnULxvSX.js"),[]))},{id:"kanagawa-dragon",displayName:"Kanagawa Dragon",type:"dark",import:(()=>te(()=>import("./kanagawa-dragon-CkXjmgJE.js"),[]))},{id:"kanagawa-lotus",displayName:"Kanagawa Lotus",type:"light",import:(()=>te(()=>import("./kanagawa-lotus-CfQXZHmo.js"),[]))},{id:"kanagawa-wave",displayName:"Kanagawa Wave",type:"dark",import:(()=>te(()=>import("./kanagawa-wave-DWedfzmr.js"),[]))},{id:"laserwave",displayName:"LaserWave",type:"dark",import:(()=>te(()=>import("./laserwave-DUszq2jm.js"),[]))},{id:"light-plus",displayName:"Light Plus",type:"light",import:(()=>te(()=>import("./light-plus-B7mTdjB0.js"),[]))},{id:"material-theme",displayName:"Material Theme",type:"dark",import:(()=>te(()=>import("./material-theme-D5KoaKCx.js"),[]))},{id:"material-theme-darker",displayName:"Material Theme Darker",type:"dark",import:(()=>te(()=>import("./material-theme-darker-BfHTSMKl.js"),[]))},{id:"material-theme-lighter",displayName:"Material Theme Lighter",type:"light",import:(()=>te(()=>import("./material-theme-lighter-B0m2ddpp.js"),[]))},{id:"material-theme-ocean",displayName:"Material Theme Ocean",type:"dark",import:(()=>te(()=>import("./material-theme-ocean-CyktbL80.js"),[]))},{id:"material-theme-palenight",displayName:"Material Theme Palenight",type:"dark",import:(()=>te(()=>import("./material-theme-palenight-Csfq5Kiy.js"),[]))},{id:"min-dark",displayName:"Min Dark",type:"dark",import:(()=>te(()=>import("./min-dark-CafNBF8u.js"),[]))},{id:"min-light",displayName:"Min Light",type:"light",import:(()=>te(()=>import("./min-light-CTRr51gU.js"),[]))},{id:"monokai",displayName:"Monokai",type:"dark",import:(()=>te(()=>import("./monokai-D4h5O-jR.js"),[]))},{id:"night-owl",displayName:"Night Owl",type:"dark",import:(()=>te(()=>import("./night-owl-C39BiMTA.js"),[]))},{id:"night-owl-light",displayName:"Night Owl Light",type:"light",import:(()=>te(()=>import("./night-owl-light-CMTm3GFP.js"),[]))},{id:"nord",displayName:"Nord",type:"dark",import:(()=>te(()=>import("./nord-Ddv68eIx.js"),[]))},{id:"one-dark-pro",displayName:"One Dark Pro",type:"dark",import:(()=>te(()=>import("./one-dark-pro-DVMEJ2y_.js"),[]))},{id:"one-light",displayName:"One Light",type:"light",import:(()=>te(()=>import("./one-light-C3Wv6jpd.js"),[]))},{id:"plastic",displayName:"Plastic",type:"dark",import:(()=>te(()=>import("./plastic-3e1v2bzS.js"),[]))},{id:"poimandres",displayName:"Poimandres",type:"dark",import:(()=>te(()=>import("./poimandres-CS3Unz2-.js"),[]))},{id:"red",displayName:"Red",type:"dark",import:(()=>te(()=>import("./red-bN70gL4F.js"),[]))},{id:"rose-pine",displayName:"Rosé Pine",type:"dark",import:(()=>te(()=>import("./rose-pine-qdsjHGoJ.js"),[]))},{id:"rose-pine-dawn",displayName:"Rosé Pine Dawn",type:"light",import:(()=>te(()=>import("./rose-pine-dawn-DHQR4-dF.js"),[]))},{id:"rose-pine-moon",displayName:"Rosé Pine Moon",type:"dark",import:(()=>te(()=>import("./rose-pine-moon-D4_iv3hh.js"),[]))},{id:"slack-dark",displayName:"Slack Dark",type:"dark",import:(()=>te(()=>import("./slack-dark-BthQWCQV.js"),[]))},{id:"slack-ochin",displayName:"Slack Ochin",type:"light",import:(()=>te(()=>import("./slack-ochin-DqwNpetd.js"),[]))},{id:"snazzy-light",displayName:"Snazzy Light",type:"light",import:(()=>te(()=>import("./snazzy-light-Bw305WKR.js"),[]))},{id:"solarized-dark",displayName:"Solarized Dark",type:"dark",import:(()=>te(()=>import("./solarized-dark-DXbdFlpD.js"),[]))},{id:"solarized-light",displayName:"Solarized Light",type:"light",import:(()=>te(()=>import("./solarized-light-L9t79GZl.js"),[]))},{id:"synthwave-84",displayName:"Synthwave '84",type:"dark",import:(()=>te(()=>import("./synthwave-84-CbfX1IO0.js"),[]))},{id:"tokyo-night",displayName:"Tokyo Night",type:"dark",import:(()=>te(()=>import("./tokyo-night-hegEt444.js"),[]))},{id:"vesper",displayName:"Vesper",type:"dark",import:(()=>te(()=>import("./vesper-DRje8inN.js"),[]))},{id:"vitesse-black",displayName:"Vitesse Black",type:"dark",import:(()=>te(()=>import("./vitesse-black-Bkuqu6BP.js"),[]))},{id:"vitesse-dark",displayName:"Vitesse Dark",type:"dark",import:(()=>te(()=>import("./vitesse-dark-D0r3Knsf.js"),[]))},{id:"vitesse-light",displayName:"Vitesse Light",type:"light",import:(()=>te(()=>import("./vitesse-light-CVO1_9PV.js"),[]))}],db=Object.fromEntries(ub.map(e=>[e.id,e.import]));var hb=class extends Error{constructor(t){super(t),this.name="ShikiError"}};function sB(){return 2147483648}function iB(){return typeof performance<"u"?performance.now():Date.now()}const aB=(e,t)=>e+(t-e%t)%t;async function oB(e){let t,n;const r={};function a(y){n=y,r.HEAPU8=new Uint8Array(y),r.HEAPU32=new Uint32Array(y)}function l(y,w,C){r.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=r.HEAPU8.length;y=y>>>0;const C=sB();if(y>C)return!1;for(let _=1;_<=4;_*=2){let S=w*(1+.2/_);S=Math.min(S,y+100663296);const b=Math.min(C,aB(Math.max(y,S),65536));if(u(b))return!0}return!1}const d=typeof TextDecoder<"u"?new TextDecoder("utf8"):void 0;function h(y,w,C=1024){const _=w+C;let S=w;for(;y[S]&&!(S>=_);)++S;if(S-w>16&&y.buffer&&d)return d.decode(y.subarray(w,S));let b="";for(;w<S;){let v=y[w++];if(!(v&128)){b+=String.fromCharCode(v);continue}const k=y[w++]&63;if((v&224)===192){b+=String.fromCharCode((v&31)<<6|k);continue}const T=y[w++]&63;if((v&240)===224?v=(v&15)<<12|k<<6|T:v=(v&7)<<18|k<<12|T<<6|y[w++]&63,v<65536)b+=String.fromCharCode(v);else{const N=v-65536;b+=String.fromCharCode(55296|N>>10,56320|N&1023)}}return b}function p(y,w){return y?h(r.HEAPU8,y,w):""}const m={emscripten_get_now:iB,emscripten_memcpy_big:l,emscripten_resize_heap:c,fd_write:()=>0};async function g(){const w=await e({env:m,wasi_snapshot_preview1:m});t=w.memory,a(t.buffer),Object.assign(r,w),r.UTF8ToString=p}return await g(),r}var lB=Object.defineProperty,cB=(e,t,n)=>t in e?lB(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Dn=(e,t,n)=>cB(e,typeof t!="symbol"?t+"":t,n);let zn=null;function uB(e){throw new hb(e.UTF8ToString(e.getLastOnigError()))}class Tf{constructor(t){Dn(this,"utf16Length"),Dn(this,"utf8Length"),Dn(this,"utf16Value"),Dn(this,"utf8Value"),Dn(this,"utf16OffsetToUtf8"),Dn(this,"utf8OffsetToUtf16");const n=t.length,r=Tf._utf8ByteLength(t),a=r!==n,l=a?new Uint32Array(n+1):null;a&&(l[n]=r);const u=a?new Uint32Array(r+1):null;a&&(u[r]=n);const c=new Uint8Array(r);let d=0;for(let h=0;h<n;h++){const p=t.charCodeAt(h);let m=p,g=!1;if(p>=55296&&p<=56319&&h+1<n){const y=t.charCodeAt(h+1);y>=56320&&y<=57343&&(m=(p-55296<<10)+65536|y-56320,g=!0)}a&&(l[h]=d,g&&(l[h+1]=d),m<=127?u[d+0]=h:m<=2047?(u[d+0]=h,u[d+1]=h):m<=65535?(u[d+0]=h,u[d+1]=h,u[d+2]=h):(u[d+0]=h,u[d+1]=h,u[d+2]=h,u[d+3]=h)),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),g&&h++}this.utf16Length=n,this.utf8Length=r,this.utf16Value=t,this.utf8Value=c,this.utf16OffsetToUtf8=l,this.utf8OffsetToUtf16=u}static _utf8ByteLength(t){let n=0;for(let r=0,a=t.length;r<a;r++){const l=t.charCodeAt(r);let u=l,c=!1;if(l>=55296&&l<=56319&&r+1<a){const d=t.charCodeAt(r+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&&r++}return n}createString(t){const n=t.omalloc(this.utf8Length);return t.HEAPU8.set(this.utf8Value,n),n}}const Af=class _s{constructor(t){if(Dn(this,"id",++_s.LAST_ID),Dn(this,"_onigBinding"),Dn(this,"content"),Dn(this,"utf16Length"),Dn(this,"utf8Length"),Dn(this,"utf16OffsetToUtf8"),Dn(this,"utf8OffsetToUtf16"),Dn(this,"ptr"),!zn)throw new hb("Must invoke loadWasm first.");this._onigBinding=zn,this.content=t;const n=new Tf(t);this.utf16Length=n.utf16Length,this.utf8Length=n.utf8Length,this.utf16OffsetToUtf8=n.utf16OffsetToUtf8,this.utf8OffsetToUtf16=n.utf8OffsetToUtf16,this.utf8Length<1e4&&!_s._sharedPtrInUse?(_s._sharedPtr||(_s._sharedPtr=zn.omalloc(1e4)),_s._sharedPtrInUse=!0,zn.HEAPU8.set(n.utf8Value,_s._sharedPtr),this.ptr=_s._sharedPtr):this.ptr=n.createString(zn)}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===_s._sharedPtr?_s._sharedPtrInUse=!1:this._onigBinding.ofree(this.ptr)}};Dn(Af,"LAST_ID",0);Dn(Af,"_sharedPtr",0);Dn(Af,"_sharedPtrInUse",!1);let Jj=Af;class dB{constructor(t){if(Dn(this,"_onigBinding"),Dn(this,"_ptr"),!zn)throw new hb("Must invoke loadWasm first.");const n=[],r=[];for(let c=0,d=t.length;c<d;c++){const h=new Tf(t[c]);n[c]=h.createString(zn),r[c]=h.utf8Length}const a=zn.omalloc(4*t.length);zn.HEAPU32.set(n,a/4);const l=zn.omalloc(4*t.length);zn.HEAPU32.set(r,l/4);const u=zn.createOnigScanner(a,l,t.length);for(let c=0,d=t.length;c<d;c++)zn.ofree(n[c]);zn.ofree(l),zn.ofree(a),u===0&&uB(zn),this._onigBinding=zn,this._ptr=u}dispose(){this._onigBinding.freeOnigScanner(this._ptr)}findNextMatchSync(t,n,r){let a=0;if(typeof r=="number"&&(a=r),typeof t=="string"){t=new Jj(t);const l=this._findNextMatchSync(t,n,!1,a);return t.dispose(),l}return this._findNextMatchSync(t,n,!1,a)}_findNextMatchSync(t,n,r,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 h=c[d++],p=c[d++],m=[];for(let g=0;g<p;g++){const y=t.convertUtf8OffsetToUtf16(c[d++]),w=t.convertUtf8OffsetToUtf16(c[d++]);m[g]={start:y,end:w,length:w-y}}return{index:h,captureIndices:m}}}function hB(e){return typeof e.instantiator=="function"}function fB(e){return typeof e.default=="function"}function mB(e){return typeof e.data<"u"}function pB(e){return typeof Response<"u"&&e instanceof Response}function gB(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 Wd;function fb(e){if(Wd)return Wd;async function t(){zn=await oB(async n=>{let r=e;return r=await r,typeof r=="function"&&(r=await r(n)),typeof r=="function"&&(r=await r(n)),hB(r)?r=await r.instantiator(n):fB(r)?r=await r.default(n):(mB(r)&&(r=r.data),pB(r)?typeof WebAssembly.instantiateStreaming=="function"?r=await xB(r)(n):r=await yB(r)(n):gB(r)?r=await Bg(r)(n):r instanceof WebAssembly.Module?r=await Bg(r)(n):"default"in r&&r.default instanceof WebAssembly.Module&&(r=await Bg(r.default)(n))),"instance"in r&&(r=r.instance),"exports"in r&&(r=r.exports),r})}return Wd=t(),Wd}function Bg(e){return t=>WebAssembly.instantiate(e,t)}function xB(e){return t=>WebAssembly.instantiateStreaming(e,t)}function yB(e){return async t=>{const n=await e.arrayBuffer();return WebAssembly.instantiate(n,t)}}let Zj;function bB(e){Zj=e}function vB(){return Zj}async function e2(e){return e&&await fb(e),{createScanner(t){return new dB(t.map(n=>typeof n=="string"?n:n.source))},createString(t){return new Jj(t)}}}const _B=Object.freeze(Object.defineProperty({__proto__:null,createOnigurumaEngine:e2,getDefaultWasmLoader:vB,loadWasm:fb,setDefaultWasmLoader:bB},Symbol.toStringTag,{value:"Module"}));var t2=ob({});Qj(t2,_B);var en=class extends Error{constructor(e){super(e),this.name="ShikiError"}};function SB(e){return mb(e)}function mb(e){return Array.isArray(e)?wB(e):e instanceof RegExp?e:typeof e=="object"?CB(e):e}function wB(e){let t=[];for(let n=0,r=e.length;n<r;n++)t[n]=mb(e[n]);return t}function CB(e){let t={};for(let n in e)t[n]=mb(e[n]);return t}function n2(e,...t){return t.forEach(n=>{for(let r in n)e[r]=n[r]}),e}function r2(e){const t=~e.lastIndexOf("/")||~e.lastIndexOf("\\");return t===0?e:~t===e.length-1?r2(e.substring(0,e.length-1)):e.substr(~t+1)}var $g=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,Gd=class{static hasCaptures(e){return e===null?!1:($g.lastIndex=0,$g.test(e))}static replaceCaptures(e,t,n){return e.replace($g,(r,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 r})}};function s2(e,t){return e<t?-1:e>t?1:0}function i2(e,t){if(e===null&&t===null)return 0;if(!e)return-1;if(!t)return 1;let n=e.length,r=t.length;if(n===r){for(let a=0;a<n;a++){let l=s2(e[a],t[a]);if(l!==0)return l}return 0}return n-r}function Aw(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 a2(e){return e.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var o2=class{constructor(e){Ae(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}},Mh=class{constructor(e,t,n){Ae(this,"_cachedMatchRoot",new o2(e=>this._root.match(e)));this._colorMap=e,this._defaults=t,this._root=n}static createFromRawTheme(e,t){return this.createFromParsedTheme(jB(e),t)}static createFromParsedTheme(e,t){return TB(e,t)}getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(e){if(e===null)return this._defaults;const t=e.scopeName,r=this._cachedMatchRoot.get(t).find(a=>kB(e.parent,a.parentScopes));return r?new l2(r.fontStyle,r.foreground,r.background):null}},zg=class bh{constructor(t,n){this.parent=t,this.scopeName=n}static push(t,n){for(const r of n)t=new bh(t,r);return t}static from(...t){let n=null;for(let r=0;r<t.length;r++)n=new bh(n,t[r]);return n}push(t){return new bh(this,t)}getSegments(){let t=this;const n=[];for(;t;)n.push(t.scopeName),t=t.parent;return n.reverse(),n}toString(){return this.getSegments().join(" ")}extends(t){return this===t?!0:this.parent===null?!1:this.parent.extends(t)}getExtensionIfDefined(t){const n=[];let r=this;for(;r&&r!==t;)n.push(r.scopeName),r=r.parent;return r===t?n.reverse():void 0}};function kB(e,t){if(t.length===0)return!0;for(let n=0;n<t.length;n++){let r=t[n],a=!1;if(r===">"){if(n===t.length-1)return!1;r=t[++n],a=!0}for(;e&&!EB(e.scopeName,r);){if(a)return!1;e=e.parent}if(!e)return!1;e=e.parent}return!0}function EB(e,t){return t===e||e.startsWith(t)&&e[t.length]==="."}var l2=class{constructor(e,t,n){this.fontStyle=e,this.foregroundId=t,this.backgroundId=n}};function jB(e){if(!e)return[];if(!e.settings||!Array.isArray(e.settings))return[];let t=e.settings,n=[],r=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 g=0,y=m.length;g<y;g++)switch(m[g]){case"italic":d=d|1;break;case"bold":d=d|2;break;case"underline":d=d|4;break;case"strikethrough":d=d|8;break}}let h=null;typeof u.settings.foreground=="string"&&Aw(u.settings.foreground)&&(h=u.settings.foreground);let p=null;typeof u.settings.background=="string"&&Aw(u.settings.background)&&(p=u.settings.background);for(let m=0,g=c.length;m<g;m++){let w=c[m].trim().split(" "),C=w[w.length-1],_=null;w.length>1&&(_=w.slice(0,w.length-1),_.reverse()),n[r++]=new NB(C,_,a,d,h,p)}}return n}var NB=class{constructor(e,t,n,r,a,l){this.scope=e,this.parentScopes=t,this.index=n,this.fontStyle=r,this.foreground=a,this.background=l}},Xn=(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))(Xn||{});function TB(e,t){e.sort((d,h)=>{let p=s2(d.scope,h.scope);return p!==0||(p=i2(d.parentScopes,h.parentScopes),p!==0)?p:d.index-h.index});let n=0,r="#000000",a="#ffffff";for(;e.length>=1&&e[0].scope==="";){let d=e.shift();d.fontStyle!==-1&&(n=d.fontStyle),d.foreground!==null&&(r=d.foreground),d.background!==null&&(a=d.background)}let l=new AB(t),u=new l2(n,l.getId(r),l.getId(a)),c=new RB(new Wx(0,null,-1,0,0),[]);for(let d=0,h=e.length;d<h;d++){let p=e[d];c.insert(0,p.scope,p.parentScopes,p.fontStyle,l.getId(p.foreground),l.getId(p.background))}return new Mh(l,u,c)}var AB=class{constructor(e){Ae(this,"_isFrozen");Ae(this,"_lastColorId");Ae(this,"_id2color");Ae(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)}},LB=Object.freeze([]),Wx=class c2{constructor(t,n,r,a,l){Ae(this,"scopeDepth");Ae(this,"parentScopes");Ae(this,"fontStyle");Ae(this,"foreground");Ae(this,"background");this.scopeDepth=t,this.parentScopes=n||LB,this.fontStyle=r,this.foreground=a,this.background=l}clone(){return new c2(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(t){let n=[];for(let r=0,a=t.length;r<a;r++)n[r]=t[r].clone();return n}acceptOverwrite(t,n,r,a){this.scopeDepth>t?console.log("how did this happen?"):this.scopeDepth=t,n!==-1&&(this.fontStyle=n),r!==0&&(this.foreground=r),a!==0&&(this.background=a)}},RB=class Gx{constructor(t,n=[],r={}){Ae(this,"_rulesWithParentScopes");this._mainRule=t,this._children=r,this._rulesWithParentScopes=n}static _cmpBySpecificity(t,n){if(t.scopeDepth!==n.scopeDepth)return n.scopeDepth-t.scopeDepth;let r=0,a=0;for(;t.parentScopes[r]===">"&&r++,n.parentScopes[a]===">"&&a++,!(r>=t.parentScopes.length||a>=n.parentScopes.length);){const l=n.parentScopes[a].length-t.parentScopes[r].length;if(l!==0)return l;r++,a++}return n.parentScopes.length-t.parentScopes.length}match(t){if(t!==""){let r=t.indexOf("."),a,l;if(r===-1?(a=t,l=""):(a=t.substring(0,r),l=t.substring(r+1)),this._children.hasOwnProperty(a))return this._children[a].match(l)}const n=this._rulesWithParentScopes.concat(this._mainRule);return n.sort(Gx._cmpBySpecificity),n}insert(t,n,r,a,l,u){if(n===""){this._doInsertHere(t,r,a,l,u);return}let c=n.indexOf("."),d,h;c===-1?(d=n,h=""):(d=n.substring(0,c),h=n.substring(c+1));let p;this._children.hasOwnProperty(d)?p=this._children[d]:(p=new Gx(this._mainRule.clone(),Wx.cloneArr(this._rulesWithParentScopes)),this._children[d]=p),p.insert(t+1,h,r,a,l,u)}_doInsertHere(t,n,r,a,l){if(n===null){this._mainRule.acceptOverwrite(t,r,a,l);return}for(let u=0,c=this._rulesWithParentScopes.length;u<c;u++){let d=this._rulesWithParentScopes[u];if(i2(d.parentScopes,n)===0){d.acceptOverwrite(t,r,a,l);return}}r===-1&&(r=this._mainRule.fontStyle),a===0&&(a=this._mainRule.foreground),l===0&&(l=this._mainRule.background),this._rulesWithParentScopes.push(new Wx(t,n,r,a,l))}},Va=class Vr{static toBinaryStr(t){return t.toString(2).padStart(32,"0")}static print(t){const n=Vr.getLanguageId(t),r=Vr.getTokenType(t),a=Vr.getFontStyle(t),l=Vr.getForeground(t),u=Vr.getBackground(t);console.log({languageId:n,tokenType:r,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,r,a,l,u,c){let d=Vr.getLanguageId(t),h=Vr.getTokenType(t),p=Vr.containsBalancedBrackets(t)?1:0,m=Vr.getFontStyle(t),g=Vr.getForeground(t),y=Vr.getBackground(t);return n!==0&&(d=n),r!==8&&(h=r),a!==null&&(p=a?1:0),l!==-1&&(m=l),u!==0&&(g=u),c!==0&&(y=c),(d<<0|h<<8|p<<10|m<<11|g<<15|y<<24)>>>0}};function Ph(e,t){const n=[],r=DB(e);let a=r.next();for(;a!==null;){let d=0;if(a.length===2&&a.charAt(1)===":"){switch(a.charAt(0)){case"R":d=1;break;case"L":d=-1;break;default:console.log(`Unknown priority ${a} in scope selector`)}a=r.next()}let h=u();if(n.push({matcher:h,priority:d}),a!==",")break;a=r.next()}return n;function l(){if(a==="-"){a=r.next();const d=l();return h=>!!d&&!d(h)}if(a==="("){a=r.next();const d=c();return a===")"&&(a=r.next()),d}if(Lw(a)){const d=[];do d.push(a),a=r.next();while(Lw(a));return h=>t(d,h)}return null}function u(){const d=[];let h=l();for(;h;)d.push(h),h=l();return p=>d.every(m=>m(p))}function c(){const d=[];let h=u();for(;h&&(d.push(h),a==="|"||a===",");){do a=r.next();while(a==="|"||a===",");h=u()}return p=>d.some(m=>m(p))}}function Lw(e){return!!e&&!!e.match(/[\w\.:]+/)}function DB(e){let t=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,n=t.exec(e);return{next:()=>{if(!n)return null;const r=n[0];return n=t.exec(e),r}}}function u2(e){typeof e.dispose=="function"&&e.dispose()}var nu=class{constructor(e){this.scopeName=e}toKey(){return this.scopeName}},OB=class{constructor(e,t){this.scopeName=e,this.ruleName=t}toKey(){return`${this.scopeName}#${this.ruleName}`}},IB=class{constructor(){Ae(this,"_references",[]);Ae(this,"_seenReferenceKeys",new Set);Ae(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))}},MB=class{constructor(e,t){Ae(this,"seenFullScopeRequests",new Set);Ae(this,"seenPartialScopeRequests",new Set);Ae(this,"Q");this.repo=e,this.initialScopeName=t,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new nu(this.initialScopeName)]}processQueue(){const e=this.Q;this.Q=[];const t=new IB;for(const n of e)PB(n,this.initialScopeName,this.repo,t);for(const n of t.references)if(n instanceof nu){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 PB(e,t,n,r){const a=n.lookup(e.scopeName);if(!a){if(e.scopeName===t)throw new Error(`No grammar provided for <${t}>`);return}const l=n.lookup(t);e instanceof nu?vh({baseGrammar:l,selfGrammar:a},r):qx(e.ruleName,{baseGrammar:l,selfGrammar:a,repository:a.repository},r);const u=n.injections(e.scopeName);if(u)for(const c of u)r.add(new nu(c))}function qx(e,t,n){if(t.repository&&t.repository[e]){const r=t.repository[e];Bh([r],t,n)}}function vh(e,t){e.selfGrammar.patterns&&Array.isArray(e.selfGrammar.patterns)&&Bh(e.selfGrammar.patterns,{...e,repository:e.selfGrammar.repository},t),e.selfGrammar.injections&&Bh(Object.values(e.selfGrammar.injections),{...e,repository:e.selfGrammar.repository},t)}function Bh(e,t,n){for(const r of e){if(n.visitedRule.has(r))continue;n.visitedRule.add(r);const a=r.repository?n2({},t.repository,r.repository):t.repository;Array.isArray(r.patterns)&&Bh(r.patterns,{...t,repository:a},n);const l=r.include;if(!l)continue;const u=d2(l);switch(u.kind){case 0:vh({...t,selfGrammar:t.baseGrammar},n);break;case 1:vh(t,n);break;case 2:qx(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?qx(u.ruleName,d,n):vh(d,n)}else u.kind===4?n.add(new OB(u.scopeName,u.ruleName)):n.add(new nu(u.scopeName));break}}}var BB=class{constructor(){Ae(this,"kind",0)}},$B=class{constructor(){Ae(this,"kind",1)}},zB=class{constructor(e){Ae(this,"kind",2);this.ruleName=e}},HB=class{constructor(e){Ae(this,"kind",3);this.scopeName=e}},FB=class{constructor(e,t){Ae(this,"kind",4);this.scopeName=e,this.ruleName=t}};function d2(e){if(e==="$base")return new BB;if(e==="$self")return new $B;const t=e.indexOf("#");if(t===-1)return new HB(e);if(t===0)return new zB(e.substring(1));{const n=e.substring(0,t),r=e.substring(t+1);return new FB(n,r)}}var UB=/\\(\d+)/,Rw=/\\(\d+)/g,VB=-1,h2=-2;var gu=class{constructor(e,t,n,r){Ae(this,"$location");Ae(this,"id");Ae(this,"_nameIsCapturing");Ae(this,"_name");Ae(this,"_contentNameIsCapturing");Ae(this,"_contentName");this.$location=e,this.id=t,this._name=n||null,this._nameIsCapturing=Gd.hasCaptures(this._name),this._contentName=r||null,this._contentNameIsCapturing=Gd.hasCaptures(this._contentName)}get debugName(){const e=this.$location?`${r2(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:Gd.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:Gd.replaceCaptures(this._contentName,e,t)}},WB=class extends gu{constructor(t,n,r,a,l){super(t,n,r,a);Ae(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,r,a){throw new Error("Not supported!")}},GB=class extends gu{constructor(t,n,r,a,l){super(t,n,r,null);Ae(this,"_match");Ae(this,"captures");Ae(this,"_cachedCompiledPatterns");this._match=new ru(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,r,a){return this._getCachedCompiledPatterns(t).compileAG(t,r,a)}_getCachedCompiledPatterns(t){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new su,this.collectPatterns(t,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Dw=class extends gu{constructor(t,n,r,a,l){super(t,n,r,a);Ae(this,"hasMissingPatterns");Ae(this,"patterns");Ae(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 r of this.patterns)t.getRule(r).collectPatterns(t,n)}compile(t,n){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,n,r,a){return this._getCachedCompiledPatterns(t).compileAG(t,r,a)}_getCachedCompiledPatterns(t){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new su,this.collectPatterns(t,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Kx=class extends gu{constructor(t,n,r,a,l,u,c,d,h,p){super(t,n,r,a);Ae(this,"_begin");Ae(this,"beginCaptures");Ae(this,"_end");Ae(this,"endHasBackReferences");Ae(this,"endCaptures");Ae(this,"applyEndPatternLast");Ae(this,"hasMissingPatterns");Ae(this,"patterns");Ae(this,"_cachedCompiledPatterns");this._begin=new ru(l,this.id),this.beginCaptures=u,this._end=new ru(c||"￿",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=d,this.applyEndPatternLast=h||!1,this.patterns=p.patterns,this.hasMissingPatterns=p.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugEndRegExp(){return`${this._end.source}`}getEndWithResolvedBackReferences(t,n){return this._end.resolveBackReferences(t,n)}collectPatterns(t,n){n.push(this._begin)}compile(t,n){return this._getCachedCompiledPatterns(t,n).compile(t)}compileAG(t,n,r,a){return this._getCachedCompiledPatterns(t,n).compileAG(t,r,a)}_getCachedCompiledPatterns(t,n){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new su;for(const r of this.patterns)t.getRule(r).collectPatterns(t,this._cachedCompiledPatterns);this.applyEndPatternLast?this._cachedCompiledPatterns.push(this._end.hasBackReferences?this._end.clone():this._end):this._cachedCompiledPatterns.unshift(this._end.hasBackReferences?this._end.clone():this._end)}return this._end.hasBackReferences&&(this.applyEndPatternLast?this._cachedCompiledPatterns.setSource(this._cachedCompiledPatterns.length()-1,n):this._cachedCompiledPatterns.setSource(0,n)),this._cachedCompiledPatterns}},$h=class extends gu{constructor(t,n,r,a,l,u,c,d,h){super(t,n,r,a);Ae(this,"_begin");Ae(this,"beginCaptures");Ae(this,"whileCaptures");Ae(this,"_while");Ae(this,"whileHasBackReferences");Ae(this,"hasMissingPatterns");Ae(this,"patterns");Ae(this,"_cachedCompiledPatterns");Ae(this,"_cachedCompiledWhilePatterns");this._begin=new ru(l,this.id),this.beginCaptures=u,this.whileCaptures=d,this._while=new ru(c,h2),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=h.patterns,this.hasMissingPatterns=h.hasMissingPatterns,this._cachedCompiledPatterns=null,this._cachedCompiledWhilePatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null),this._cachedCompiledWhilePatterns&&(this._cachedCompiledWhilePatterns.dispose(),this._cachedCompiledWhilePatterns=null)}get debugBeginRegExp(){return`${this._begin.source}`}get debugWhileRegExp(){return`${this._while.source}`}getWhileWithResolvedBackReferences(t,n){return this._while.resolveBackReferences(t,n)}collectPatterns(t,n){n.push(this._begin)}compile(t,n){return this._getCachedCompiledPatterns(t).compile(t)}compileAG(t,n,r,a){return this._getCachedCompiledPatterns(t).compileAG(t,r,a)}_getCachedCompiledPatterns(t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new su;for(const n of this.patterns)t.getRule(n).collectPatterns(t,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(t,n){return this._getCachedCompiledWhilePatterns(t,n).compile(t)}compileWhileAG(t,n,r,a){return this._getCachedCompiledWhilePatterns(t,n).compileAG(t,r,a)}_getCachedCompiledWhilePatterns(t,n){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new su,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,n||"￿"),this._cachedCompiledWhilePatterns}},f2=class Kn{static createCaptureRule(t,n,r,a,l){return t.registerRule(u=>new WB(n,u,r,a,l))}static getCompiledRuleId(t,n,r){return t.id||n.registerRule(a=>{if(t.id=a,t.match)return new GB(t.$vscodeTextmateLocation,t.id,t.name,t.match,Kn._compileCaptures(t.captures,n,r));if(typeof t.begin>"u"){t.repository&&(r=n2({},r,t.repository));let l=t.patterns;return typeof l>"u"&&t.include&&(l=[{include:t.include}]),new Dw(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,Kn._compilePatterns(l,n,r))}return t.while?new $h(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,Kn._compileCaptures(t.beginCaptures||t.captures,n,r),t.while,Kn._compileCaptures(t.whileCaptures||t.captures,n,r),Kn._compilePatterns(t.patterns,n,r)):new Kx(t.$vscodeTextmateLocation,t.id,t.name,t.contentName,t.begin,Kn._compileCaptures(t.beginCaptures||t.captures,n,r),t.end,Kn._compileCaptures(t.endCaptures||t.captures,n,r),t.applyEndPatternLast,Kn._compilePatterns(t.patterns,n,r))}),t.id}static _compileCaptures(t,n,r){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=Kn.getCompiledRuleId(t[u],n,r)),a[c]=Kn.createCaptureRule(n,t[u].$vscodeTextmateLocation,t[u].name,t[u].contentName,d)}}return a}static _compilePatterns(t,n,r){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 h=d2(c.include);switch(h.kind){case 0:case 1:d=Kn.getCompiledRuleId(r[c.include],n,r);break;case 2:let p=r[h.ruleName];p&&(d=Kn.getCompiledRuleId(p,n,r));break;case 3:case 4:const m=h.scopeName,g=h.kind===4?h.ruleName:null,y=n.getExternalGrammar(m,r);if(y)if(g){let w=y.repository[g];w&&(d=Kn.getCompiledRuleId(w,n,y.repository))}else d=Kn.getCompiledRuleId(y.repository.$self,n,y.repository);break}}else d=Kn.getCompiledRuleId(c,n,r);if(d!==-1){const h=n.getRule(d);let p=!1;if((h instanceof Dw||h instanceof Kx||h instanceof $h)&&h.hasMissingPatterns&&h.patterns.length===0&&(p=!0),p)continue;a.push(d)}}return{patterns:a,hasMissingPatterns:(t?t.length:0)!==a.length}}},ru=class m2{constructor(t,n){Ae(this,"source");Ae(this,"ruleId");Ae(this,"hasAnchor");Ae(this,"hasBackReferences");Ae(this,"_anchorCache");if(t&&typeof t=="string"){const r=t.length;let a=0,l=[],u=!1;for(let c=0;c<r;c++)if(t.charAt(c)==="\\"&&c+1<r){const h=t.charAt(c+1);h==="z"?(l.push(t.substring(a,c)),l.push("$(?!\\n)(?<!\\n)"),a=c+2):(h==="A"||h==="G")&&(u=!0),c++}this.hasAnchor=u,a===0?this.source=t:(l.push(t.substring(a,r)),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=UB.test(this.source):this.hasBackReferences=!1}clone(){return new m2(this.source,this.ruleId)}setSource(t){this.source!==t&&(this.source=t,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(t,n){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let r=n.map(a=>t.substring(a.start,a.end));return Rw.lastIndex=0,this.source.replace(Rw,(a,l)=>a2(r[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=[],r=[],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,r[l]=c,a[l]=c,c==="\\"&&l+1<u&&(d=this.source.charAt(l+1),d==="A"?(t[l+1]="￿",n[l+1]="￿",r[l+1]="A",a[l+1]="A"):d==="G"?(t[l+1]="￿",n[l+1]="G",r[l+1]="￿",a[l+1]="G"):(t[l+1]=d,n[l+1]=d,r[l+1]=d,a[l+1]=d),l++);return{A0_G0:t.join(""),A0_G1:n.join(""),A1_G0:r.join(""),A1_G1:a.join("")}}resolveAnchors(t,n){return!this.hasAnchor||!this._anchorCache||typeof this.source!="string"?this.source:t?n?this._anchorCache.A1_G1:this._anchorCache.A1_G0:n?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},su=class{constructor(){Ae(this,"_items");Ae(this,"_hasAnchors");Ae(this,"_cached");Ae(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 Ow(e,t,this._items.map(n=>n.ruleId))}return this._cached}compileAG(e,t,n){return this._hasAnchors?t?n?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A1_G0):n?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(e,t,n)),this._anchorCache.A0_G0):this.compile(e)}_resolveAnchors(e,t,n){let r=this._items.map(a=>a.resolveAnchors(t,n));return new Ow(e,r,this._items.map(a=>a.ruleId))}},Ow=class{constructor(e,t,n){Ae(this,"scanner");this.regExps=t,this.rules=n,this.scanner=e.createOnigScanner(t)}dispose(){typeof this.scanner.dispose=="function"&&this.scanner.dispose()}toString(){const e=[];for(let t=0,n=this.rules.length;t<n;t++)e.push(" - "+this.rules[t]+": "+this.regExps[t]);return e.join(`
96
+ `)}findNextMatchSync(e,t,n){const r=this.scanner.findNextMatchSync(e,t,n);return r?{ruleId:this.rules[r.index],captureIndices:r.captureIndices}:null}},Hg=class{constructor(e,t){this.languageId=e,this.tokenType=t}},ii,qB=(ii=class{constructor(t,n){Ae(this,"_defaultAttributes");Ae(this,"_embeddedLanguagesMatcher");Ae(this,"_getBasicScopeAttributes",new o2(t=>{const n=this._scopeToLanguage(t),r=this._toStandardTokenType(t);return new Hg(n,r)}));this._defaultAttributes=new Hg(t,8),this._embeddedLanguagesMatcher=new KB(Object.entries(n||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(t){return t===null?ii._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(t)}_scopeToLanguage(t){return this._embeddedLanguagesMatcher.match(t)||0}_toStandardTokenType(t){const n=t.match(ii.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!")}},Ae(ii,"_NULL_SCOPE_METADATA",new Hg(0,0)),Ae(ii,"STANDARD_TOKEN_TYPE_REGEXP",/\b(comment|string|regex|meta\.embedded)\b/),ii),KB=class{constructor(e){Ae(this,"values");Ae(this,"scopesRegExp");if(e.length===0)this.values=null,this.scopesRegExp=null;else{this.values=new Map(e);const t=e.map(([n,r])=>a2(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])}},Iw=class{constructor(e,t){this.stack=e,this.stoppedEarly=t}};function p2(e,t,n,r,a,l,u,c){const d=t.content.length;let h=!1,p=-1;if(u){const y=YB(e,t,n,r,a,l);a=y.stack,r=y.linePos,n=y.isFirstLine,p=y.anchorPosition}const m=Date.now();for(;!h;){if(c!==0&&Date.now()-m>c)return new Iw(a,!0);g()}return new Iw(a,!1);function g(){const y=XB(e,t,n,r,a,p);if(!y){l.produce(a,d),h=!0;return}const w=y.captureIndices,C=y.matchedRuleId,_=w&&w.length>0?w[0].end>r:!1;if(C===VB){const S=a.getRule(e);l.produce(a,w[0].start),a=a.withContentNameScopesList(a.nameScopesList),Oc(e,t,n,a,l,S.endCaptures,w),l.produce(a,w[0].end);const b=a;if(a=a.parent,p=b.getAnchorPos(),!_&&b.getEnterPos()===r){a=b,l.produce(a,d),h=!0;return}}else{const S=e.getRule(C);l.produce(a,w[0].start);const b=a,v=S.getName(t.content,w),k=a.contentNameScopesList.pushAttributed(v,e);if(a=a.push(C,r,p,w[0].end===d,null,k,k),S instanceof Kx){const T=S;Oc(e,t,n,a,l,T.beginCaptures,w),l.produce(a,w[0].end),p=w[0].end;const N=T.getContentName(t.content,w),R=k.pushAttributed(N,e);if(a=a.withContentNameScopesList(R),T.endHasBackReferences&&(a=a.withEndRule(T.getEndWithResolvedBackReferences(t.content,w))),!_&&b.hasSameRuleAs(a)){a=a.pop(),l.produce(a,d),h=!0;return}}else if(S instanceof $h){const T=S;Oc(e,t,n,a,l,T.beginCaptures,w),l.produce(a,w[0].end),p=w[0].end;const N=T.getContentName(t.content,w),R=k.pushAttributed(N,e);if(a=a.withContentNameScopesList(R),T.whileHasBackReferences&&(a=a.withEndRule(T.getWhileWithResolvedBackReferences(t.content,w))),!_&&b.hasSameRuleAs(a)){a=a.pop(),l.produce(a,d),h=!0;return}}else if(Oc(e,t,n,a,l,S.captures,w),l.produce(a,w[0].end),a=a.pop(),!_){a=a.safePop(),l.produce(a,d),h=!0;return}}w[0].end>r&&(r=w[0].end,n=!1)}}function YB(e,t,n,r,a,l){let u=a.beginRuleCapturedEOL?0:-1;const c=[];for(let d=a;d;d=d.pop()){const h=d.getRule(e);h instanceof $h&&c.push({rule:h,stack:d})}for(let d=c.pop();d;d=c.pop()){const{ruleScanner:h,findOptions:p}=ZB(d.rule,e,d.stack.endRule,n,r===u),m=h.findNextMatchSync(t,r,p);if(m){if(m.ruleId!==h2){a=d.stack.pop();break}m.captureIndices&&m.captureIndices.length&&(l.produce(d.stack,m.captureIndices[0].start),Oc(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>r&&(r=m.captureIndices[0].end,n=!1))}else{a=d.stack.pop();break}}return{stack:a,linePos:r,anchorPosition:u,isFirstLine:n}}function XB(e,t,n,r,a,l){const u=QB(e,t,n,r,a,l),c=e.getInjections();if(c.length===0)return u;const d=JB(c,e,t,n,r,a,l);if(!d)return u;if(!u)return d;const h=u.captureIndices[0].start,p=d.captureIndices[0].start;return p<h||d.priorityMatch&&p===h?d:u}function QB(e,t,n,r,a,l){const u=a.getRule(e),{ruleScanner:c,findOptions:d}=g2(u,e,a.endRule,n,r===l),h=c.findNextMatchSync(t,r,d);return h?{captureIndices:h.captureIndices,matchedRuleId:h.ruleId}:null}function JB(e,t,n,r,a,l,u){let c=Number.MAX_VALUE,d=null,h,p=0;const m=l.contentNameScopesList.getScopeNames();for(let g=0,y=e.length;g<y;g++){const w=e[g];if(!w.matcher(m))continue;const C=t.getRule(w.ruleId),{ruleScanner:_,findOptions:S}=g2(C,t,null,r,a===u),b=_.findNextMatchSync(n,a,S);if(!b)continue;const v=b.captureIndices[0].start;if(!(v>=c)&&(c=v,d=b.captureIndices,h=b.ruleId,p=w.priority,c===a))break}return d?{priorityMatch:p===-1,captureIndices:d,matchedRuleId:h}:null}function g2(e,t,n,r,a){return{ruleScanner:e.compileAG(t,n,r,a),findOptions:0}}function ZB(e,t,n,r,a){return{ruleScanner:e.compileWhileAG(t,n,r,a),findOptions:0}}function Oc(e,t,n,r,a,l,u){if(l.length===0)return;const c=t.content,d=Math.min(l.length,u.length),h=[],p=u[0].end;for(let m=0;m<d;m++){const g=l[m];if(g===null)continue;const y=u[m];if(y.length===0)continue;if(y.start>p)break;for(;h.length>0&&h[h.length-1].endPos<=y.start;)a.produceFromScopes(h[h.length-1].scopes,h[h.length-1].endPos),h.pop();if(h.length>0?a.produceFromScopes(h[h.length-1].scopes,y.start):a.produce(r,y.start),g.retokenizeCapturedWithRuleId){const C=g.getName(c,u),_=r.contentNameScopesList.pushAttributed(C,e),S=g.getContentName(c,u),b=_.pushAttributed(S,e),v=r.push(g.retokenizeCapturedWithRuleId,y.start,-1,!1,null,_,b),k=e.createOnigString(c.substring(0,y.end));p2(e,k,n&&y.start===0,y.start,v,a,!1,0),u2(k);continue}const w=g.getName(c,u);if(w!==null){const _=(h.length>0?h[h.length-1].scopes:r.contentNameScopesList).pushAttributed(w,e);h.push(new e8(_,y.end))}}for(;h.length>0;)a.produceFromScopes(h[h.length-1].scopes,h[h.length-1].endPos),h.pop()}var e8=class{constructor(e,t){Ae(this,"scopes");Ae(this,"endPos");this.scopes=e,this.endPos=t}};function t8(e,t,n,r,a,l,u,c){return new r8(e,t,n,r,a,l,u,c)}function Mw(e,t,n,r,a){const l=Ph(t,zh),u=f2.getCompiledRuleId(n,r,a.repository);for(const c of l)e.push({debugSelector:t,matcher:c.matcher,ruleId:u,grammar:a,priority:c.priority})}function zh(e,t){if(t.length<e.length)return!1;let n=0;return e.every(r=>{for(let a=n;a<t.length;a++)if(n8(t[a],r))return n=a+1,!0;return!1})}function n8(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 r8=class{constructor(e,t,n,r,a,l,u,c){Ae(this,"_rootId");Ae(this,"_lastRuleId");Ae(this,"_ruleId2desc");Ae(this,"_includedGrammars");Ae(this,"_grammarRepository");Ae(this,"_grammar");Ae(this,"_injections");Ae(this,"_basicScopeAttributesProvider");Ae(this,"_tokenTypeMatchers");if(this._rootScopeName=e,this.balancedBracketSelectors=l,this._onigLib=c,this._basicScopeAttributesProvider=new qB(n,r),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=u,this._grammar=Pw(t,null),this._injections=null,this._tokenTypeMatchers=[],a)for(const d of Object.keys(a)){const h=Ph(d,zh);for(const p of h)this._tokenTypeMatchers.push({matcher:p.matcher,type:a[d]})}}get themeProvider(){return this._grammarRepository}dispose(){for(const e of this._ruleId2desc)e&&e.dispose()}createOnigScanner(e){return this._onigLib.createOnigScanner(e)}createOnigString(e){return this._onigLib.createOnigString(e)}getMetadataForScope(e){return this._basicScopeAttributesProvider.getBasicScopeAttributes(e)}_collectInjections(){const e={lookup:a=>a===this._rootScopeName?this._grammar:this.getExternalGrammar(a),injections:a=>this._grammarRepository.injections(a)},t=[],n=this._rootScopeName,r=e.lookup(n);if(r){const a=r.injections;if(a)for(let u in a)Mw(t,u,a[u],this,r);const l=this._grammarRepository.injections(n);l&&l.forEach(u=>{const c=this.getExternalGrammar(u);if(c){const d=c.injectionSelector;d&&Mw(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]=Pw(n,t&&t.$base),this._includedGrammars[e]}}tokenizeLine(e,t,n=0){const r=this._tokenize(e,t,!1,n);return{tokens:r.lineTokens.getResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}tokenizeLine2(e,t,n=0){const r=this._tokenize(e,t,!0,n);return{tokens:r.lineTokens.getBinaryResult(r.ruleStack,r.lineLength),ruleStack:r.ruleStack,stoppedEarly:r.stoppedEarly}}_tokenize(e,t,n,r){this._rootId===-1&&(this._rootId=f2.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let a;if(!t||t===Yx.NULL){a=!0;const h=this._basicScopeAttributesProvider.getDefaultAttributes(),p=this.themeProvider.getDefaults(),m=Va.set(0,h.languageId,h.tokenType,null,p.fontStyle,p.foregroundId,p.backgroundId),g=this.getRule(this._rootId).getName(null,null);let y;g?y=Hc.createRootAndLookUpScopeName(g,m,this):y=Hc.createRoot("unknown",m),t=new Yx(null,this._rootId,-1,-1,!1,null,y,y)}else a=!1,t.reset();e=e+`
97
+ `;const l=this.createOnigString(e),u=l.content.length,c=new i8(n,e,this._tokenTypeMatchers,this.balancedBracketSelectors),d=p2(this,l,a,0,t,c,!0,r);return u2(l),{lineLength:u,lineTokens:c,ruleStack:d.stack,stoppedEarly:d.stoppedEarly}}};function Pw(e,t){return e=SB(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 Hc=class Ss{constructor(t,n,r){this.parent=t,this.scopePath=n,this.tokenAttributes=r}static fromExtension(t,n){let r=t,a=(t==null?void 0:t.scopePath)??null;for(const l of n)a=zg.push(a,l.scopeNames),r=new Ss(r,a,l.encodedTokenAttributes);return r}static createRoot(t,n){return new Ss(null,new zg(null,t),n)}static createRootAndLookUpScopeName(t,n,r){const a=r.getMetadataForScope(t),l=new zg(null,t),u=r.themeProvider.themeMatch(l),c=Ss.mergeAttributes(n,a,u);return new Ss(null,l,c)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(t){return Ss.equals(this,t)}static equals(t,n){do{if(t===n||!t&&!n)return!0;if(!t||!n||t.scopeName!==n.scopeName||t.tokenAttributes!==n.tokenAttributes)return!1;t=t.parent,n=n.parent}while(!0)}static mergeAttributes(t,n,r){let a=-1,l=0,u=0;return r!==null&&(a=r.fontStyle,l=r.foregroundId,u=r.backgroundId),Va.set(t,n.languageId,n.tokenType,null,a,l,u)}pushAttributed(t,n){if(t===null)return this;if(t.indexOf(" ")===-1)return Ss._pushAttributed(this,t,n);const r=t.split(/ /g);let a=this;for(const l of r)a=Ss._pushAttributed(a,l,n);return a}static _pushAttributed(t,n,r){const a=r.getMetadataForScope(n),l=t.scopePath.push(n),u=r.themeProvider.themeMatch(l),c=Ss.mergeAttributes(t.tokenAttributes,a,u);return new Ss(t,l,c)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(t){var a;const n=[];let r=this;for(;r&&r!==t;)n.push({encodedTokenAttributes:r.tokenAttributes,scopeNames:r.scopePath.getExtensionIfDefined(((a=r.parent)==null?void 0:a.scopePath)??null)}),r=r.parent;return r===t?n.reverse():void 0}},qr,Yx=(qr=class{constructor(t,n,r,a,l,u,c,d){Ae(this,"_stackElementBrand");Ae(this,"_enterPos");Ae(this,"_anchorPos");Ae(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=r,this._anchorPos=a}equals(t){return t===null?!1:qr._equals(this,t)}static _equals(t,n){return t===n?!0:this._structuralEquals(t,n)?Hc.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(){qr._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(t,n,r,a,l,u,c){return new qr(this,t,n,r,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 r,a;return this.parent&&(n=this.parent._writeString(t,n)),t[n++]=`(${this.ruleId}, ${(r=this.nameScopesList)==null?void 0:r.toString()}, ${(a=this.contentNameScopesList)==null?void 0:a.toString()})`,n}withContentNameScopesList(t){return this.contentNameScopesList===t?this:this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,t)}withEndRule(t){return this.endRule===t?this:new qr(this.parent,this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,t,this.nameScopesList,this.contentNameScopesList)}hasSameRuleAs(t){let n=this;for(;n&&n._enterPos===t._enterPos;){if(n.ruleId===t.ruleId)return!0;n=n.parent}return!1}toStateStackFrame(){var t,n,r;return{ruleId:this.ruleId,beginRuleCapturedEOL:this.beginRuleCapturedEOL,endRule:this.endRule,nameScopesList:((n=this.nameScopesList)==null?void 0:n.getExtensionIfDefined(((t=this.parent)==null?void 0:t.nameScopesList)??null))??[],contentNameScopesList:((r=this.contentNameScopesList)==null?void 0:r.getExtensionIfDefined(this.nameScopesList))??[]}}static pushFrame(t,n){const r=Hc.fromExtension((t==null?void 0:t.nameScopesList)??null,n.nameScopesList);return new qr(t,n.ruleId,n.enterPos??-1,n.anchorPos??-1,n.beginRuleCapturedEOL,n.endRule,r,Hc.fromExtension(r,n.contentNameScopesList))}},Ae(qr,"NULL",new qr(null,0,0,0,!1,null,null,null)),qr),s8=class{constructor(e,t){Ae(this,"balancedBracketScopes");Ae(this,"unbalancedBracketScopes");Ae(this,"allowAny",!1);this.balancedBracketScopes=e.flatMap(n=>n==="*"?(this.allowAny=!0,[]):Ph(n,zh).map(r=>r.matcher)),this.unbalancedBracketScopes=t.flatMap(n=>Ph(n,zh).map(r=>r.matcher))}get matchesAlways(){return this.allowAny&&this.unbalancedBracketScopes.length===0}get matchesNever(){return this.balancedBracketScopes.length===0&&!this.allowAny}match(e){for(const t of this.unbalancedBracketScopes)if(t(e))return!1;for(const t of this.balancedBracketScopes)if(t(e))return!0;return this.allowAny}},i8=class{constructor(e,t,n,r){Ae(this,"_emitBinaryTokens");Ae(this,"_lineText");Ae(this,"_tokens");Ae(this,"_binaryTokens");Ae(this,"_lastTokenEndIndex");Ae(this,"_tokenTypeOverrides");this.balancedBracketSelectors=r,this._emitBinaryTokens=e,this._tokenTypeOverrides=n,this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}produce(e,t){this.produceFromScopes(e.contentNameScopesList,t)}produceFromScopes(e,t){var r;if(this._lastTokenEndIndex>=t)return;if(this._emitBinaryTokens){let a=(e==null?void 0:e.tokenAttributes)??0,l=!1;if((r=this.balancedBracketSelectors)!=null&&r.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=Va.set(a,0,c.type,null,-1,0,0));this.balancedBracketSelectors&&(l=this.balancedBracketSelectors.match(u))}if(l&&(a=Va.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 r=0,a=this._binaryTokens.length;r<a;r++)n[r]=this._binaryTokens[r];return n}},a8=class{constructor(e,t){Ae(this,"_grammars",new Map);Ae(this,"_rawGrammars",new Map);Ae(this,"_injectionGrammars",new Map);Ae(this,"_theme");this._onigLib=t,this._theme=e}dispose(){for(const e of this._grammars.values())e.dispose()}setTheme(e){this._theme=e}getColorMap(){return this._theme.getColorMap()}addGrammar(e,t){this._rawGrammars.set(e.scopeName,e),t&&this._injectionGrammars.set(e.scopeName,t)}lookup(e){return this._rawGrammars.get(e)}injections(e){return this._injectionGrammars.get(e)}getDefaults(){return this._theme.getDefaults()}themeMatch(e){return this._theme.match(e)}grammarForScopeName(e,t,n,r,a){if(!this._grammars.has(e)){let l=this._rawGrammars.get(e);if(!l)return null;this._grammars.set(e,t8(e,l,t,n,r,a,this,this._onigLib))}return this._grammars.get(e)}},o8=class{constructor(t){Ae(this,"_options");Ae(this,"_syncRegistry");Ae(this,"_ensureGrammarCache");this._options=t,this._syncRegistry=new a8(Mh.createFromRawTheme(t.theme,t.colorMap),t.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(t,n){this._syncRegistry.setTheme(Mh.createFromRawTheme(t,n))}getColorMap(){return this._syncRegistry.getColorMap()}loadGrammarWithEmbeddedLanguages(t,n,r){return this.loadGrammarWithConfiguration(t,n,{embeddedLanguages:r})}loadGrammarWithConfiguration(t,n,r){return this._loadGrammar(t,n,r.embeddedLanguages,r.tokenTypes,new s8(r.balancedBracketSelectors||[],r.unbalancedBracketSelectors||[]))}loadGrammar(t){return this._loadGrammar(t,0,null,null,null)}_loadGrammar(t,n,r,a,l){const u=new MB(this._syncRegistry,t);for(;u.Q.length>0;)u.Q.map(c=>this._loadSingleGrammar(c.scopeName)),u.processQueue();return this._grammarForScopeName(t,n,r,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 r=typeof this._options.getInjections=="function"?this._options.getInjections(t):void 0;this._syncRegistry.addGrammar(n,r)}}addGrammar(t,n=[],r=0,a=null){return this._syncRegistry.addGrammar(t,n),this._grammarForScopeName(t.scopeName,r,a)}_grammarForScopeName(t,n=0,r=null,a=null,l=null){return this._syncRegistry.grammarForScopeName(t,n,r,a,l)}},Xx=Yx.NULL;function Hh(e,t){const n=typeof e=="string"?{}:{...e.colorReplacements},r=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===r&&Object.assign(n,l);return n}function qi(e,t){return e&&((t==null?void 0:t[e==null?void 0:e.toLowerCase()])||e)}function l8(e){return Array.isArray(e)?e:[e]}async function x2(e){return Promise.resolve(typeof e=="function"?e():e).then(t=>t.default||t)}function Lf(e){return!e||["plaintext","txt","text","plain"].includes(e)}function y2(e){return e==="ansi"||Lf(e)}function Rf(e){return e==="none"}function b2(e){return Rf(e)}const c8=/(\r?\n)/g;function Df(e,t=!1){var l;if(e.length===0)return[["",0]];const n=e.split(c8);let r=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,r]),r+=n[u].length,r+=((l=n[u+1])==null?void 0:l.length)||0}return a}const Bw={light:"#333333",dark:"#bbbbbb"},$w={light:"#fffffe",dark:"#1e1e1e"},zw="__shiki_resolved";function pb(e){var c,d,h,p,m;if(e!=null&&e[zw])return e;const t={...e};t.tokenColors&&!t.settings&&(t.settings=t.tokenColors,delete t.tokenColors),t.type||(t.type="dark"),t.colorReplacements={...t.colorReplacements},t.settings||(t.settings=[]);let{bg:n,fg:r}=t;if(!n||!r){const g=t.settings?t.settings.find(y=>!y.name&&!y.scope):void 0;(c=g==null?void 0:g.settings)!=null&&c.foreground&&(r=g.settings.foreground),(d=g==null?void 0:g.settings)!=null&&d.background&&(n=g.settings.background),!r&&((h=t==null?void 0:t.colors)!=null&&h["editor.foreground"])&&(r=t.colors["editor.foreground"]),!n&&((p=t==null?void 0:t.colors)!=null&&p["editor.background"])&&(n=t.colors["editor.background"]),r||(r=t.type==="light"?Bw.light:Bw.dark),n||(n=t.type==="light"?$w.light:$w.dark),t.fg=r,t.bg=n}t.settings[0]&&t.settings[0].settings&&!t.settings[0].scope||t.settings.unshift({settings:{foreground:t.fg,background:t.bg}});let a=0;const l=new Map;function u(g){var w;if(l.has(g))return l.get(g);a+=1;const y=`#${a.toString(16).padStart(8,"0").toLowerCase()}`;return(w=t.colorReplacements)!=null&&w[`#${y}`]?u(g):(l.set(g,y),y)}t.settings=t.settings.map(g=>{var _,S;const y=((_=g.settings)==null?void 0:_.foreground)&&!g.settings.foreground.startsWith("#"),w=((S=g.settings)==null?void 0:S.background)&&!g.settings.background.startsWith("#");if(!y&&!w)return g;const C={...g,settings:{...g.settings}};if(y){const b=u(g.settings.foreground);t.colorReplacements[b]=g.settings.foreground,C.settings.foreground=b}if(w){const b=u(g.settings.background);t.colorReplacements[b]=g.settings.background,C.settings.background=b}return C});for(const g of Object.keys(t.colors||{}))if((g==="editor.foreground"||g==="editor.background"||g.startsWith("terminal.ansi"))&&!((m=t.colors[g])!=null&&m.startsWith("#"))){const y=u(t.colors[g]);t.colorReplacements[y]=t.colors[g],t.colors[g]=y}return Object.defineProperty(t,zw,{enumerable:!1,writable:!1,value:!0}),t}async function v2(e){return[...new Set((await Promise.all(e.filter(t=>!y2(t)).map(async t=>await x2(t).then(n=>Array.isArray(n)?n:[n])))).flat())]}async function _2(e){return(await Promise.all(e.map(async t=>b2(t)?null:pb(await x2(t))))).filter(t=>!!t)}function S2(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 en(`Circular alias \`${[...n].join(" -> ")} -> ${e}\``);n.add(e)}}return e}var u8=class extends o8{constructor(t,n,r,a={}){super(t);Ae(this,"_resolver");Ae(this,"_themes");Ae(this,"_langs");Ae(this,"_alias");Ae(this,"_resolvedThemes",new Map);Ae(this,"_resolvedGrammars",new Map);Ae(this,"_langMap",new Map);Ae(this,"_langGraph",new Map);Ae(this,"_textmateThemeCache",new WeakMap);Ae(this,"_loadedThemesCache",null);Ae(this,"_loadedLanguagesCache",null);this._resolver=t,this._themes=n,this._langs=r,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=pb(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=Mh.createFromRawTheme(t),this._textmateThemeCache.set(t,n)),this._syncRegistry.setTheme(n)}getGrammar(t){return t=S2(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(h=>{var p;return(p=h.embeddedLangsLazy)==null?void 0:p.includes(t.name)}));this._resolver.addLanguage(t);const r={balancedBracketSelectors:t.balancedBracketSelectors||["*"],unbalancedBracketSelectors:t.unbalancedBracketSelectors||[]};this._syncRegistry._rawGrammars.set(t.scopeName,t);const a=this.loadGrammarWithConfiguration(t.scopeName,1,r);if(a.name=t.name,this._resolvedGrammars.set(t.name,a),t.aliases&&t.aliases.forEach(h=>{this._alias[h]=t.name}),this._loadedLanguagesCache=null,n.size)for(const h of n)this._resolvedGrammars.delete(h.name),this._loadedLanguagesCache=null,(u=(l=this._syncRegistry)==null?void 0:l._injectionGrammars)==null||u.delete(h.scopeName),(d=(c=this._syncRegistry)==null?void 0:c._grammars)==null||d.delete(h.scopeName),this.loadLanguage(this._langMap.get(h.name))}dispose(){super.dispose(),this._resolvedThemes.clear(),this._resolvedGrammars.clear(),this._langMap.clear(),this._langGraph.clear(),this._loadedThemesCache=null}loadLanguages(t){for(const a of t)this.resolveEmbeddedLanguages(a);const n=[...this._langGraph.entries()],r=n.filter(([a,l])=>!l);if(r.length){const a=n.filter(([l,u])=>{var c;return u?(c=u.embeddedLanguages||u.embeddedLangs)==null?void 0:c.some(d=>r.map(([h])=>h).includes(d)):!1}).filter(l=>!r.includes(l));throw new en(`Missing languages ${r.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 r of n)this._langGraph.set(r,this._langMap.get(r))}},d8=class{constructor(e,t){Ae(this,"_langs",new Map);Ae(this,"_scopeToLang",new Map);Ae(this,"_injections",new Map);Ae(this,"_onigLib");this._onigLib={createOnigScanner:n=>e.createScanner(n),createOnigString:n=>e.createString(n)},t.forEach(n=>this.addLanguage(n))}get onigLib(){return this._onigLib}getLangRegistration(e){return this._langs.get(e)}loadGrammar(e){return this._scopeToLang.get(e)}addLanguage(e){this._langs.set(e.name,e),e.aliases&&e.aliases.forEach(t=>{this._langs.set(t,e)}),this._scopeToLang.set(e.scopeName,e),e.injectTo&&e.injectTo.forEach(t=>{this._injections.get(t)||this._injections.set(t,[]),this._injections.get(t).push(e.scopeName)})}getInjections(e){const t=e.split(".");let n=[];for(let r=1;r<=t.length;r++){const a=t.slice(0,r).join(".");n=[...n,...this._injections.get(a)||[]]}return n}};let Cc=0;function h8(e){Cc+=1,e.warnings!==!1&&Cc>=10&&Cc%10===0&&console.warn(`[Shiki] ${Cc} 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 en("`engine` option is required for synchronous mode");const n=(e.langs||[]).flat(1),r=(e.themes||[]).flat(1).map(pb),a=new u8(new d8(e.engine,n),r,n,e.langAlias);let l;function u(b){return S2(b,e.langAlias)}function c(b){_();const v=a.getGrammar(typeof b=="string"?b:b.name);if(!v)throw new en(`Language \`${b}\` not found, you may need to load it first`);return v}function d(b){if(b==="none")return{bg:"",fg:"",name:"none",settings:[],type:"dark"};_();const v=a.getTheme(b);if(!v)throw new en(`Theme \`${b}\` not found, you may need to load it first`);return v}function h(b){_();const v=d(b);return l!==b&&(a.setTheme(v),l=b),{theme:v,colorMap:a.getColorMap()}}function p(){return _(),a.getLoadedThemes()}function m(){return _(),a.getLoadedLanguages()}function g(...b){_(),a.loadLanguages(b.flat(1))}async function y(...b){return g(await v2(b))}function w(...b){_();for(const v of b.flat(1))a.loadTheme(v)}async function C(...b){return _(),w(await _2(b))}function _(){if(t)throw new en("Shiki instance has been disposed")}function S(){t||(t=!0,a.dispose(),Cc-=1)}return{setTheme:h,getTheme:d,getLanguage:c,getLoadedThemes:p,getLoadedLanguages:m,resolveLangAlias:u,loadLanguage:y,loadLanguageSync:g,loadTheme:C,loadThemeSync:w,dispose:S,[Symbol.dispose]:S}}async function f8(e){e.engine||console.warn("`engine` option is required. Use `createOnigurumaEngine` or `createJavaScriptRegexEngine` to create an engine.");const[t,n,r]=await Promise.all([_2(e.themes||[]),v2(e.langs||[]),e.engine]);return h8({...e,themes:t,langs:n,engine:r})}const w2=new WeakMap;function Of(e,t){w2.set(e,t)}function iu(e){return w2.get(e)}var If=class C2{constructor(...t){Ae(this,"_stacks",{});Ae(this,"lang");if(t.length===2){const[n,r]=t;this.lang=r,this._stacks=n}else{const[n,r,a]=t;this.lang=r,this._stacks={[a]:n}}}get themes(){return Object.keys(this._stacks)}get theme(){return this.themes[0]}get _stack(){return this._stacks[this.theme]}static initial(t,n){return new C2(Object.fromEntries(l8(n).map(r=>[r,Xx])),t)}getInternalStack(t=this.theme){return this._stacks[t]}getScopes(t=this.theme){return m8(this._stacks[t])}toJSON(){return{lang:this.lang,theme:this.theme,themes:this.themes,scopes:this.getScopes()}}};function m8(e){const t=[],n=new Set;function r(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&&r(a.parent)}return r(e),t}function p8(e,t){if(!(e instanceof If))throw new en("Invalid grammar state");return e.getInternalStack(t)}const g8=/,/,x8=/ /;function k2(e,t,n={}){const{theme:r=e.getLoadedThemes()[0]}=n;if(Lf(e.resolveLangAlias(n.lang||"text"))||Rf(r))return Df(t).map(c=>[{content:c[0],offset:c[1]}]);const{theme:a,colorMap:l}=e.setTheme(r),u=e.getLanguage(n.lang||"text");if(n.grammarState){if(n.grammarState.lang!==u.name)throw new en(`Grammar state language "${n.grammarState.lang}" does not match highlight language "${u.name}"`);if(!n.grammarState.themes.includes(a.name))throw new en(`Grammar state themes "${n.grammarState.themes}" do not contain highlight theme "${a.name}"`)}return b8(t,u,a,l,n)}function y8(...e){if(e.length===2)return iu(e[1]);const[t,n,r={}]=e,{lang:a="text",theme:l=t.getLoadedThemes()[0]}=r;if(Lf(a)||Rf(l))throw new en("Plain language does not have grammar state");if(a==="ansi")throw new en("ANSI language does not have grammar state");const{theme:u,colorMap:c}=t.setTheme(l),d=t.getLanguage(a);return new If(gb(n,d,u,c,r).stateStack,d.name,u.name)}function b8(e,t,n,r,a){const l=gb(e,t,n,r,a),u=new If(l.stateStack,t.name,n.name);return Of(l.tokens,u),l.tokens}function gb(e,t,n,r,a){const l=Hh(n,a),{tokenizeMaxLineLength:u=0,tokenizeTimeLimit:c=500,includeExplanation:d=!1}=a,h=Df(e);let p=a.grammarState?p8(a.grammarState,n.name)??Xx:a.grammarContextCode!=null?gb(a.grammarContextCode,t,n,r,{...a,grammarState:void 0,grammarContextCode:void 0}).stateStack:Xx,m=[];const g=[];for(let y=0,w=h.length;y<w;y++){const[C,_]=h[y];if(C===""){m=[],g.push([]);continue}if(u>0&&C.length>=u){m=[],g.push([{content:C,offset:_,color:"",fontStyle:0}]);continue}let S,b,v;d&&d!=="tokenType"&&(S=t.tokenizeLine(C,p,c),b=S.tokens,v=0);const k=t.tokenizeLine2(C,p,c),T=k.tokens.length/2;for(let N=0;N<T;N++){const R=k.tokens[2*N],A=N+1<T?k.tokens[2*N+2]:C.length;if(R===A)continue;const O=k.tokens[2*N+1],P=qi(r[Va.getForeground(O)],l),V=Va.getFontStyle(O),z={content:C.substring(R,A),offset:_+R,color:P,fontStyle:V};if(d==="tokenType")z.type=Va.getTokenType(O);else if(d){const W=[];if(d!=="scopeName")for(const U of n.settings){let F;switch(typeof U.scope){case"string":F=U.scope.split(g8).map(Q=>Q.trim());break;case"object":F=U.scope;break;default:continue}W.push({settings:U,selectors:F.map(Q=>Q.split(x8))})}z.explanation=[];let M=0;for(;R+M<A;){const U=b[v],F=C.substring(U.startIndex,U.endIndex);M+=F.length,z.explanation.push({content:F,scopes:d==="scopeName"?v8(U.scopes):_8(W,U.scopes)}),v+=1}}m.push(z)}g.push(m),m=[],p=k.ruleStack}return{tokens:g,stateStack:p}}function v8(e){return e.map(t=>({scopeName:t}))}function _8(e,t){const n=[];for(let r=0,a=t.length;r<a;r++){const l=t[r];n[r]={scopeName:l,themeMatches:w8(e,l,t.slice(0,r))}}return n}function Hw(e,t){return e===t||t.substring(0,e.length)===e&&t[e.length]==="."}function S8(e,t,n){if(!Hw(e.at(-1),t))return!1;let r=e.length-2,a=n.length-1;for(;r>=0&&a>=0;)Hw(e[r],n[a])&&(r-=1),a-=1;return r===-1}function w8(e,t,n){const r=[];for(const{selectors:a,settings:l}of e)for(const u of a)if(S8(u,t,n)){r.push(l);break}return r}function E2(e,t,n,r=k2){const a=Object.entries(n.themes).filter(h=>h[1]).map(h=>({color:h[0],theme:h[1]})),l=a.map(h=>{const p=r(e,t,{...n,theme:h.theme});return{tokens:p,state:iu(p),theme:typeof h.theme=="string"?h.theme:h.theme.name}}),u=C8(...l.map(h=>h.tokens)),c=u[0].map((h,p)=>h.map((m,g)=>{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:_,explanation:S,offset:b,...v}=w[p][g];y.variants[a[C].color]=v}),y})),d=l[0].state?new If(Object.fromEntries(l.map(h=>{var p;return[h.theme,(p=h.state)==null?void 0:p.getInternalStack(h.theme)]})),l[0].state.lang):void 0;return d&&Of(c,d),c}function C8(...e){const t=e.map(()=>[]),n=e.length;for(let r=0;r<e[0].length;r++){const a=e.map(d=>d[r]),l=t.map(()=>[]);t.forEach((d,h)=>d.push(l[h]));const u=a.map(()=>0),c=a.map(d=>d[0]);for(;c.every(d=>d);){const d=Math.min(...c.map(h=>h.content.length));for(let h=0;h<n;h++){const p=c[h];p.content.length===d?(l[h].push(p),u[h]+=1,c[h]=a[h][u[h]]):(l[h].push({...p,content:p.content.slice(0,d)}),c[h]={...p,content:p.content.slice(d),offset:p.offset+d})}}}return t}const k8=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"];class xu{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}xu.prototype.normal={};xu.prototype.property={};xu.prototype.space=void 0;function j2(e,t){const n={},r={};for(const a of e)Object.assign(n,a.property),Object.assign(r,a.normal);return new xu(n,r,t)}function Qx(e){return e.toLowerCase()}class br{constructor(t,n){this.attribute=n,this.property=t}}br.prototype.attribute="";br.prototype.booleanish=!1;br.prototype.boolean=!1;br.prototype.commaOrSpaceSeparated=!1;br.prototype.commaSeparated=!1;br.prototype.defined=!1;br.prototype.mustUseProperty=!1;br.prototype.number=!1;br.prototype.overloadedBoolean=!1;br.prototype.property="";br.prototype.spaceSeparated=!1;br.prototype.space=void 0;let E8=0;const gt=Qa(),Tn=Qa(),Jx=Qa(),Ke=Qa(),Qt=Qa(),Wa=Qa(),Nr=Qa();function Qa(){return 2**++E8}const Zx=Object.freeze(Object.defineProperty({__proto__:null,boolean:gt,booleanish:Tn,commaOrSpaceSeparated:Nr,commaSeparated:Wa,number:Ke,overloadedBoolean:Jx,spaceSeparated:Qt},Symbol.toStringTag,{value:"Module"})),Fg=Object.keys(Zx);class xb extends br{constructor(t,n,r,a){let l=-1;if(super(t,n),Fw(this,"space",a),typeof r=="number")for(;++l<Fg.length;){const u=Fg[l];Fw(this,Fg[l],(r&Zx[u])===Zx[u])}}}xb.prototype.defined=!0;function Fw(e,t,n){n&&(e[t]=n)}function vl(e){const t={},n={};for(const[r,a]of Object.entries(e.properties)){const l=new xb(r,e.transform(e.attributes||{},r),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(l.mustUseProperty=!0),t[r]=l,n[Qx(r)]=r,n[Qx(l.attribute)]=r}return new xu(t,n,e.space)}const N2=vl({properties:{ariaActiveDescendant:null,ariaAtomic:Tn,ariaAutoComplete:null,ariaBusy:Tn,ariaChecked:Tn,ariaColCount:Ke,ariaColIndex:Ke,ariaColSpan:Ke,ariaControls:Qt,ariaCurrent:null,ariaDescribedBy:Qt,ariaDetails:null,ariaDisabled:Tn,ariaDropEffect:Qt,ariaErrorMessage:null,ariaExpanded:Tn,ariaFlowTo:Qt,ariaGrabbed:Tn,ariaHasPopup:null,ariaHidden:Tn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Qt,ariaLevel:Ke,ariaLive:null,ariaModal:Tn,ariaMultiLine:Tn,ariaMultiSelectable:Tn,ariaOrientation:null,ariaOwns:Qt,ariaPlaceholder:null,ariaPosInSet:Ke,ariaPressed:Tn,ariaReadOnly:Tn,ariaRelevant:null,ariaRequired:Tn,ariaRoleDescription:Qt,ariaRowCount:Ke,ariaRowIndex:Ke,ariaRowSpan:Ke,ariaSelected:Tn,ariaSetSize:Ke,ariaSort:null,ariaValueMax:Ke,ariaValueMin:Ke,ariaValueNow:Ke,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function T2(e,t){return t in e?e[t]:t}function A2(e,t){return T2(e,t.toLowerCase())}const j8=vl({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Wa,acceptCharset:Qt,accessKey:Qt,action:null,allow:null,allowFullScreen:gt,allowPaymentRequest:gt,allowUserMedia:gt,alpha:gt,alt:null,as:null,async:gt,autoCapitalize:null,autoComplete:Qt,autoFocus:gt,autoPlay:gt,blocking:Qt,capture:null,charSet:null,checked:gt,cite:null,className:Qt,closedBy:null,colorSpace:null,cols:Ke,colSpan:Ke,command:null,commandFor:null,content:null,contentEditable:Tn,controls:gt,controlsList:Qt,coords:Ke|Wa,crossOrigin:null,data:null,dateTime:null,decoding:null,default:gt,defer:gt,dir:null,dirName:null,disabled:gt,download:Jx,draggable:Tn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:gt,formTarget:null,headers:Qt,height:Ke,hidden:Jx,high:Ke,href:null,hrefLang:null,htmlFor:Qt,httpEquiv:Qt,id:null,imageSizes:null,imageSrcSet:null,inert:gt,inputMode:null,integrity:null,is:null,isMap:gt,itemId:null,itemProp:Qt,itemRef:Qt,itemScope:gt,itemType:Qt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:gt,low:Ke,manifest:null,max:null,maxLength:Ke,media:null,method:null,min:null,minLength:Ke,multiple:gt,muted:gt,name:null,nonce:null,noModule:gt,noValidate:gt,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:gt,optimum:Ke,pattern:null,ping:Qt,placeholder:null,playsInline:gt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:gt,referrerPolicy:null,rel:Qt,required:gt,reversed:gt,rows:Ke,rowSpan:Ke,sandbox:Qt,scope:null,scoped:gt,seamless:gt,selected:gt,shadowRootClonable:gt,shadowRootCustomElementRegistry:gt,shadowRootDelegatesFocus:gt,shadowRootMode:null,shadowRootSerializable:gt,shape:null,size:Ke,sizes:null,slot:null,span:Ke,spellCheck:Tn,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Ke,step:null,style:null,tabIndex:Ke,target:null,title:null,translate:null,type:null,typeMustMatch:gt,useMap:null,value:Tn,width:Ke,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Qt,axis:null,background:null,bgColor:null,border:Ke,borderColor:null,bottomMargin:Ke,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:gt,declare:gt,event:null,face:null,frame:null,frameBorder:null,hSpace:Ke,leftMargin:Ke,link:null,longDesc:null,lowSrc:null,marginHeight:Ke,marginWidth:Ke,noResize:gt,noHref:gt,noShade:gt,noWrap:gt,object:null,profile:null,prompt:null,rev:null,rightMargin:Ke,rules:null,scheme:null,scrolling:Tn,standby:null,summary:null,text:null,topMargin:Ke,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Ke,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:gt,disablePictureInPicture:gt,disableRemotePlayback:gt,exportParts:Wa,part:Qt,prefix:null,property:null,results:Ke,security:null,unselectable:null},space:"html",transform:A2}),N8=vl({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",maskType:"mask-type",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Nr,accentHeight:Ke,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Ke,amplitude:Ke,arabicForm:null,ascent:Ke,attributeName:null,attributeType:null,azimuth:Ke,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Ke,by:null,calcMode:null,capHeight:Ke,className:Qt,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Ke,diffuseConstant:Ke,direction:null,display:null,dur:null,divisor:Ke,dominantBaseline:null,download:gt,dx:null,dy:null,edgeMode:null,editable:null,elevation:Ke,enableBackground:null,end:null,event:null,exponent:Ke,externalResourcesRequired:null,fill:null,fillOpacity:Ke,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Wa,g2:Wa,glyphName:Wa,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Ke,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Ke,horizOriginX:Ke,horizOriginY:Ke,id:null,ideographic:Ke,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Ke,k:Ke,k1:Ke,k2:Ke,k3:Ke,k4:Ke,kernelMatrix:Nr,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Ke,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Ke,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Ke,overlineThickness:Ke,paintOrder:null,panose1:null,path:null,pathLength:Ke,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Qt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Ke,pointsAtY:Ke,pointsAtZ:Ke,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Nr,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Nr,rev:Nr,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Nr,requiredFeatures:Nr,requiredFonts:Nr,requiredFormats:Nr,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Ke,specularExponent:Ke,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Ke,strikethroughThickness:Ke,string:null,stroke:null,strokeDashArray:Nr,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Ke,strokeOpacity:Ke,strokeWidth:null,style:null,surfaceScale:Ke,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Nr,tabIndex:Ke,tableValues:null,target:null,targetX:Ke,targetY:Ke,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Nr,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Ke,underlineThickness:Ke,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Ke,values:null,vAlphabetic:Ke,vMathematical:Ke,vectorEffect:null,vHanging:Ke,vIdeographic:Ke,version:null,vertAdvY:Ke,vertOriginX:Ke,vertOriginY:Ke,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Ke,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:T2}),L2=vl({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()}}),R2=vl({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:A2}),D2=vl({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),T8=/[A-Z]/g,Uw=/-[a-z]/g,A8=/^data[-\w.:]+$/i;function L8(e,t){const n=Qx(t);let r=t,a=br;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&A8.test(t)){if(t.charAt(4)==="-"){const l=t.slice(5).replace(Uw,D8);r="data"+l.charAt(0).toUpperCase()+l.slice(1)}else{const l=t.slice(4);if(!Uw.test(l)){let u=l.replace(T8,R8);u.charAt(0)!=="-"&&(u="-"+u),t="data"+u}}a=xb}return new a(r,t)}function R8(e){return"-"+e.toLowerCase()}function D8(e){return e.charAt(1).toUpperCase()}const O8=j2([N2,j8,L2,R2,D2],"html"),O2=j2([N2,N8,L2,R2,D2],"svg"),Vw={}.hasOwnProperty;function I8(e,t){const n=t||{};function r(a,...l){let u=r.invalid;const c=r.handlers;if(a&&Vw.call(a,e)){const d=String(a[e]);u=Vw.call(c,d)?c[d]:r.unknown}if(u)return u.call(this,a,...l)}return r.handlers=n.handlers||{},r.invalid=n.invalid,r.unknown=n.unknown,r}const M8=/["&'<>`]/g,P8=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,B8=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,$8=/[|\\{}()[\]^$+*?.]/g,Ww=new WeakMap;function z8(e,t){if(e=e.replace(t.subset?H8(t.subset):M8,r),t.subset||t.escapeOnly)return e;return e.replace(P8,n).replace(B8,r);function n(a,l,u){return t.format((a.charCodeAt(0)-55296)*1024+a.charCodeAt(1)-56320+65536,u.charCodeAt(l+2),t)}function r(a,l,u){return t.format(a.charCodeAt(0),u.charCodeAt(l+1),t)}}function H8(e){let t=Ww.get(e);return t||(t=F8(e),Ww.set(e,t)),t}function F8(e){const t=[];let n=-1;for(;++n<e.length;)t.push(e[n].replace($8,"\\$&"));return new RegExp("(?:"+t.join("|")+")","g")}const U8=/[\dA-Fa-f]/;function V8(e,t,n){const r="&#x"+e.toString(16).toUpperCase();return n&&t&&!U8.test(String.fromCharCode(t))?r:r+";"}const W8=/\d/;function G8(e,t,n){const r="&#"+String(e);return n&&t&&!W8.test(String.fromCharCode(t))?r:r+";"}const q8=["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"],Ug={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:"€"},K8=["cent","copy","divide","gt","lt","not","para","times"],I2={}.hasOwnProperty,ey={};let qd;for(qd in Ug)I2.call(Ug,qd)&&(ey[Ug[qd]]=qd);const Y8=/[^\dA-Za-z]/;function X8(e,t,n,r){const a=String.fromCharCode(e);if(I2.call(ey,a)){const l=ey[a],u="&"+l;return n&&q8.includes(l)&&!K8.includes(l)&&(!r||t&&t!==61&&Y8.test(String.fromCharCode(t)))?u:u+";"}return""}function Q8(e,t,n){let r=V8(e,t,n.omitOptionalSemicolons),a;if((n.useNamedReferences||n.useShortestReferences)&&(a=X8(e,t,n.omitOptionalSemicolons,n.attribute)),(n.useShortestReferences||!a)&&n.useShortestReferences){const l=G8(e,t,n.omitOptionalSemicolons);l.length<r.length&&(r=l)}return a&&(!n.useShortestReferences||a.length<r.length)?a:r}function rl(e,t){return z8(e,Object.assign({format:Q8},t))}const J8=/^>|^->|<!--|-->|--!>|<!-$/g,Z8=[">"],e$=["<",">"];function t$(e,t,n,r){return r.settings.bogusComments?"<?"+rl(e.value,Object.assign({},r.settings.characterReferences,{subset:Z8}))+">":"<!--"+e.value.replace(J8,a)+"-->";function a(l){return rl(l,Object.assign({},r.settings.characterReferences,{subset:e$}))}}function n$(e,t,n,r){return"<!"+(r.settings.upperDoctype?"DOCTYPE":"doctype")+(r.settings.tightDoctype?"":" ")+"html>"}function Gw(e,t){const n=String(e);if(typeof t!="string")throw new TypeError("Expected character");let r=0,a=n.indexOf(t);for(;a!==-1;)r++,a=n.indexOf(t,a+t.length);return r}function r$(e,t){const n=t||{};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}function s$(e){return e.join(" ").trim()}const i$=/[ \t\n\f\r]/g;function yb(e){return typeof e=="object"?e.type==="text"?qw(e.value):!1:qw(e)}function qw(e){return e.replace(i$,"")===""}const In=P2(1),M2=P2(-1),a$=[];function P2(e){return t;function t(n,r,a){const l=n?n.children:a$;let u=(r||0)+e,c=l[u];if(!a)for(;c&&yb(c);)u+=e,c=l[u];return c}}const o$={}.hasOwnProperty;function B2(e){return t;function t(n,r,a){return o$.call(e,n.tagName)&&e[n.tagName](n,r,a)}}const bb=B2({body:c$,caption:Vg,colgroup:Vg,dd:f$,dt:h$,head:Vg,html:l$,li:d$,optgroup:m$,option:p$,p:u$,rp:Kw,rt:Kw,tbody:x$,td:Yw,tfoot:y$,th:Yw,thead:g$,tr:b$});function Vg(e,t,n){const r=In(n,t,!0);return!r||r.type!=="comment"&&!(r.type==="text"&&yb(r.value.charAt(0)))}function l$(e,t,n){const r=In(n,t);return!r||r.type!=="comment"}function c$(e,t,n){const r=In(n,t);return!r||r.type!=="comment"}function u$(e,t,n){const r=In(n,t);return r?r.type==="element"&&(r.tagName==="address"||r.tagName==="article"||r.tagName==="aside"||r.tagName==="blockquote"||r.tagName==="details"||r.tagName==="div"||r.tagName==="dl"||r.tagName==="fieldset"||r.tagName==="figcaption"||r.tagName==="figure"||r.tagName==="footer"||r.tagName==="form"||r.tagName==="h1"||r.tagName==="h2"||r.tagName==="h3"||r.tagName==="h4"||r.tagName==="h5"||r.tagName==="h6"||r.tagName==="header"||r.tagName==="hgroup"||r.tagName==="hr"||r.tagName==="main"||r.tagName==="menu"||r.tagName==="nav"||r.tagName==="ol"||r.tagName==="p"||r.tagName==="pre"||r.tagName==="section"||r.tagName==="table"||r.tagName==="ul"):!n||!(n.type==="element"&&(n.tagName==="a"||n.tagName==="audio"||n.tagName==="del"||n.tagName==="ins"||n.tagName==="map"||n.tagName==="noscript"||n.tagName==="video"))}function d$(e,t,n){const r=In(n,t);return!r||r.type==="element"&&r.tagName==="li"}function h$(e,t,n){const r=In(n,t);return!!(r&&r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd"))}function f$(e,t,n){const r=In(n,t);return!r||r.type==="element"&&(r.tagName==="dt"||r.tagName==="dd")}function Kw(e,t,n){const r=In(n,t);return!r||r.type==="element"&&(r.tagName==="rp"||r.tagName==="rt")}function m$(e,t,n){const r=In(n,t);return!r||r.type==="element"&&r.tagName==="optgroup"}function p$(e,t,n){const r=In(n,t);return!r||r.type==="element"&&(r.tagName==="option"||r.tagName==="optgroup")}function g$(e,t,n){const r=In(n,t);return!!(r&&r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot"))}function x$(e,t,n){const r=In(n,t);return!r||r.type==="element"&&(r.tagName==="tbody"||r.tagName==="tfoot")}function y$(e,t,n){return!In(n,t)}function b$(e,t,n){const r=In(n,t);return!r||r.type==="element"&&r.tagName==="tr"}function Yw(e,t,n){const r=In(n,t);return!r||r.type==="element"&&(r.tagName==="td"||r.tagName==="th")}const v$=B2({body:w$,colgroup:C$,head:S$,html:_$,tbody:k$});function _$(e){const t=In(e,-1);return!t||t.type!=="comment"}function S$(e){const t=new Set;for(const r of e.children)if(r.type==="element"&&(r.tagName==="base"||r.tagName==="title")){if(t.has(r.tagName))return!1;t.add(r.tagName)}const n=e.children[0];return!n||n.type==="element"}function w$(e){const t=In(e,-1,!0);return!t||t.type!=="comment"&&!(t.type==="text"&&yb(t.value.charAt(0)))&&!(t.type==="element"&&(t.tagName==="meta"||t.tagName==="link"||t.tagName==="script"||t.tagName==="style"||t.tagName==="template"))}function C$(e,t,n){const r=M2(n,t),a=In(e,-1,!0);return n&&r&&r.type==="element"&&r.tagName==="colgroup"&&bb(r,n.children.indexOf(r),n)?!1:!!(a&&a.type==="element"&&a.tagName==="col")}function k$(e,t,n){const r=M2(n,t),a=In(e,-1);return n&&r&&r.type==="element"&&(r.tagName==="thead"||r.tagName==="tbody")&&bb(r,n.children.indexOf(r),n)?!1:!!(a&&a.type==="element"&&a.tagName==="tr")}const Kd={name:[[`
98
+ \f\r &/=>`.split(""),`
99
+ \f\r "&'/=>\``.split("")],[`\0
100
+ \f\r "&'/<=>`.split(""),`\0
101
+ \f\r "&'/<=>\``.split("")]],unquoted:[[`
102
+ \f\r &>`.split(""),`\0
103
+ \f\r "&'<=>\``.split("")],[`\0
104
+ \f\r "&'<=>\``.split(""),`\0
105
+ \f\r "&'<=>\``.split("")]],single:[["&'".split(""),"\"&'`".split("")],["\0&'".split(""),"\0\"&'`".split("")]],double:[['"&'.split(""),"\"&'`".split("")],['\0"&'.split(""),"\0\"&'`".split("")]]};function E$(e,t,n,r){const a=r.schema,l=a.space==="svg"?!1:r.settings.omitOptionalTags;let u=a.space==="svg"?r.settings.closeEmptyElements:r.settings.voids.includes(e.tagName.toLowerCase());const c=[];let d;a.space==="html"&&e.tagName==="svg"&&(r.schema=O2);const h=j$(r,e.properties),p=r.all(a.space==="html"&&e.tagName==="template"?e.content:e);return r.schema=a,p&&(u=!1),(h||!l||!v$(e,t,n))&&(c.push("<",e.tagName,h?" "+h:""),u&&(a.space==="svg"||r.settings.closeSelfClosing)&&(d=h.charAt(h.length-1),(!r.settings.tightSelfClosing||d==="/"||d&&d!=='"'&&d!=="'")&&c.push(" "),c.push("/")),c.push(">")),c.push(p),!u&&(!l||!bb(e,t,n))&&c.push("</"+e.tagName+">"),c.join("")}function j$(e,t){const n=[];let r=-1,a;if(t){for(a in t)if(t[a]!==null&&t[a]!==void 0){const l=N$(e,a,t[a]);l&&n.push(l)}}for(;++r<n.length;){const l=e.settings.tightAttributes?n[r].charAt(n[r].length-1):void 0;r!==n.length-1&&l!=='"'&&l!=="'"&&(n[r]+=" ")}return n.join("")}function N$(e,t,n){const r=L8(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(r.overloadedBoolean&&(n===r.attribute||n==="")?n=!0:(r.boolean||r.overloadedBoolean)&&(typeof n!="string"||n===r.attribute||n==="")&&(n=!!n),n==null||n===!1||typeof n=="number"&&Number.isNaN(n))return"";const d=rl(r.attribute,Object.assign({},e.settings.characterReferences,{subset:Kd.name[a][l]}));return n===!0||(n=Array.isArray(n)?(r.commaSeparated?r$:s$)(n,{padLeft:!e.settings.tightCommaSeparatedLists}):String(n),e.settings.collapseEmptyAttributes&&!n)?d:(e.settings.preferUnquoted&&(c=rl(n,Object.assign({},e.settings.characterReferences,{attribute:!0,subset:Kd.unquoted[a][l]}))),c!==n&&(e.settings.quoteSmart&&Gw(n,u)>Gw(n,e.alternative)&&(u=e.alternative),c=u+rl(n,Object.assign({},e.settings.characterReferences,{subset:(u==="'"?Kd.single:Kd.double)[a][l],attribute:!0}))+u),d+(c&&"="+c))}const T$=["<","&"];function $2(e,t,n,r){return n&&n.type==="element"&&(n.tagName==="script"||n.tagName==="style")?e.value:rl(e.value,Object.assign({},r.settings.characterReferences,{subset:T$}))}function A$(e,t,n,r){return r.settings.allowDangerousHtml?e.value:$2(e,t,n,r)}function L$(e,t,n,r){return r.all(e)}const R$=I8("type",{invalid:D$,unknown:O$,handlers:{comment:t$,doctype:n$,element:E$,raw:A$,root:L$,text:$2}});function D$(e){throw new Error("Expected node, not `"+e+"`")}function O$(e){const t=e;throw new Error("Cannot compile unknown node `"+t.type+"`")}const I$={},M$={},P$=[];function B$(e,t){const n=t||I$,r=n.quote||'"',a=r==='"'?"'":'"';if(r!=='"'&&r!=="'")throw new Error("Invalid quote `"+r+"`, expected `'` or `\"`");return{one:$$,all:z$,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||k8,characterReferences:n.characterReferences||M$,closeSelfClosing:n.closeSelfClosing||!1,closeEmptyElements:n.closeEmptyElements||!1},schema:n.space==="svg"?O2:O8,quote:r,alternative:a}.one(Array.isArray(e)?{type:"root",children:e}:e,void 0,void 0)}function $$(e,t,n){return R$(e,t,n,this)}function z$(e){const t=[],n=e&&e.children||P$;let r=-1;for(;++r<n.length;)t[r]=this.one(n[r],r,e);return t.join("")}const Xw=/\s+/g;function z2(e,t){var r;if(!t)return e;e.properties||(e.properties={}),(r=e.properties).class||(r.class=[]),typeof e.properties.class=="string"&&(e.properties.class=e.properties.class.split(Xw)),Array.isArray(e.properties.class)||(e.properties.class=[]);const n=Array.isArray(t)?t:t.split(Xw);for(const a of n)a&&!e.properties.class.includes(a)&&e.properties.class.push(a);return e}const H$=/:?lang=["']([^"']+)["']/g,F$=/(?:```|~~~)([\w-]+)/g,U$=/\\begin\{([\w-]+)\}/g,V$=/<script\s+(?:type|lang)=["']([^"']+)["']/gi;function W$(e){const t=Df(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 r(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:r}}function G$(e,t,n){const r=new Set;for(const l of e.matchAll(H$)){const u=l[1].toLowerCase().trim();u&&r.add(u)}for(const l of e.matchAll(F$)){const u=l[1].toLowerCase().trim();u&&r.add(u)}for(const l of e.matchAll(U$)){const u=l[1].toLowerCase().trim();u&&r.add(u)}for(const l of e.matchAll(V$)){const u=l[1].toLowerCase().trim(),c=u.includes("/")?u.split("/").pop():u;c&&r.add(c)}if(!n)return[...r];const a=n.getBundledLanguages();return[...r].filter(l=>l&&a[l])}const q$=["color","background-color"];function K$(e,t){let n=0;const r=[];for(const a of t)a>n&&r.push({...e,content:e.content.slice(n,a),offset:e.offset+n}),n=a;return n<e.content.length&&r.push({...e,content:e.content.slice(n),offset:e.offset+n}),r}function Y$(e,t){const n=[...t instanceof Set?t:new Set(t)].sort((r,a)=>r-a);return n.length?e.map(r=>r.flatMap(a=>{const 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?K$(a,l):a})):e}function X$(e,t,n,r,a="css-vars"){const l={content:e.content,explanation:e.explanation,offset:e.offset},u=t.map(p=>Fh(e.variants[p])),c=new Set(u.flatMap(p=>Object.keys(p))),d={},h=(p,m)=>{const g=m==="color"?"":m==="background-color"?"-bg":`-${m}`;return n+t[p]+(m==="color"?"":g)};return u.forEach((p,m)=>{for(const g of c){const y=p[g]||"inherit";if(m===0&&r&&q$.includes(g))if(r==="light-dark()"&&u.length>1){const w=t.findIndex(_=>_==="light"),C=t.findIndex(_=>_==="dark");if(w===-1||C===-1)throw new en('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');d[g]=`light-dark(${u[w][g]||"inherit"}, ${u[C][g]||"inherit"})`,a==="css-vars"&&(d[h(m,g)]=y)}else d[g]=y;else a==="css-vars"&&(d[h(m,g)]=y)}}),l.htmlStyle=d,l}function Fh(e){const t={};if(e.color&&(t.color=e.color),e.bgColor&&(t["background-color"]=e.bgColor),e.fontStyle){e.fontStyle&Xn.Italic&&(t["font-style"]="italic"),e.fontStyle&Xn.Bold&&(t["font-weight"]="bold");const n=[];e.fontStyle&Xn.Underline&&n.push("underline"),e.fontStyle&Xn.Strikethrough&&n.push("line-through"),n.length&&(t["text-decoration"]=n.join(" "))}return t}function ty(e){return typeof e=="string"?e:Object.entries(e).map(([t,n])=>`${t}:${n}`).join(";")}function Q$(){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 en(`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 en(`Invalid decoration position ${JSON.stringify(c)}. Lines length: ${a.lines.length}`);let h=c.character;if(h<0&&(h=d.length+h),h<0||h>d.length)throw new en(`Invalid decoration position ${JSON.stringify(c)}. Line ${c.line} length: ${d.length}`);return{...c,character:h,offset:a.posToIndex(c.line,h)}}};var r=l;const a=W$(n.source),u=(n.options.decorations||[]).map(c=>({...c,start:l(c.start),end:l(c.end)}));J$(u),e.set(n.meta,{decorations:u,converter:a,source:n.source})}return e.get(n.meta)}return{name:"shiki:decorations",tokens(n){var r;if((r=this.options.decorations)!=null&&r.length)return Y$(n,t(this).decorations.flatMap(a=>[a.start.offset,a.end.offset]))},code(n){var p;if(!((p=this.options.decorations)!=null&&p.length))return;const r=t(this),a=[...n.children].filter(m=>m.type==="element"&&m.tagName==="span");if(a.length!==r.converter.lines.length)throw new en(`Number of lines in code element (${a.length}) does not match the number of lines in the source (${r.converter.lines.length}). Failed to apply decorations.`);function l(m,g,y,w){const C=a[m];let _="",S=-1,b=-1;if(g===0&&(S=0),y===0&&(b=0),y===Number.POSITIVE_INFINITY&&(b=C.children.length),S===-1||b===-1)for(let k=0;k<C.children.length;k++)_+=H2(C.children[k]),S===-1&&_.length===g&&(S=k+1),b===-1&&_.length===y&&(b=k+1);if(S===-1)throw new en(`Failed to find start index for decoration ${JSON.stringify(w.start)}`);if(b===-1)throw new en(`Failed to find end index for decoration ${JSON.stringify(w.end)}`);const v=C.children.slice(S,b);if(!w.alwaysWrap&&v.length===C.children.length)c(C,w,"line");else if(!w.alwaysWrap&&v.length===1&&v[0].type==="element")c(v[0],w,"token");else{const k={type:"element",tagName:"span",properties:{},children:v};c(k,w,"wrapper"),C.children.splice(S,v.length,k)}}function u(m,g){a[m]=c(a[m],g,"line")}function c(m,g,y){var _;const w=g.properties||{},C=g.transform||(S=>S);return m.tagName=g.tagName||"span",m.properties={...m.properties,...w,class:m.properties.class},(_=g.properties)!=null&&_.class&&z2(m,g.properties.class),m=C(m,y)||m,m}const d=[],h=r.decorations.sort((m,g)=>g.start.offset-m.start.offset||m.end.offset-g.end.offset);for(const m of h){const{start:g,end:y}=m;if(g.line===y.line)l(g.line,g.character,y.character,m);else if(g.line<y.line){l(g.line,g.character,Number.POSITIVE_INFINITY,m);for(let w=g.line+1;w<y.line;w++)d.unshift(()=>u(w,m));l(y.line,0,y.character,m)}}d.forEach(m=>m())}}}function J$(e){for(let t=0;t<e.length;t++){const n=e[t];if(n.start.offset>n.end.offset)throw new en(`Invalid decoration range: ${JSON.stringify(n.start)} - ${JSON.stringify(n.end)}`);for(let r=t+1;r<e.length;r++){const a=e[r],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 en(`Decorations ${JSON.stringify(n.start)} and ${JSON.stringify(a.start)} intersect.`)}}}}function H2(e){return e.type==="text"?e.value:e.type==="element"?e.children.map(H2).join(""):""}const Z$=[Q$()];function Uh(e){const t=ez(e.transformers||[]);return[...t.pre,...t.normal,...t.post,...Z$]}function ez(e){const t=[],n=[],r=[];for(const a of e)switch(a.enforce){case"pre":t.push(a);break;case"post":n.push(a);break;default:r.push(a)}return{pre:t,post:n,normal:r}}var Oa=["black","red","green","yellow","blue","magenta","cyan","white","brightBlack","brightRed","brightGreen","brightYellow","brightBlue","brightMagenta","brightCyan","brightWhite"],Wg={1:"bold",2:"dim",3:"italic",4:"underline",7:"reverse",8:"hidden",9:"strikethrough"};function tz(e,t){const n=e.indexOf("\x1B",t);if(n!==-1&&e[n+1]==="["){const r=e.indexOf("m",n);if(r!==-1)return{sequence:e.substring(n+2,r).split(";"),startPosition:n,position:r+1}}return{position:e.length}}function Qw(e){const t=e.shift();if(t==="2"){const n=e.splice(0,3).map(r=>Number.parseInt(r));return n.length!==3||n.some(r=>Number.isNaN(r))?void 0:{type:"rgb",rgb:n}}else if(t==="5"){const n=e.shift();if(n)return{type:"table",index:Number(n)}}}function nz(e){const t=[];for(;e.length>0;){const n=e.shift();if(!n)continue;const r=Number.parseInt(n);if(!Number.isNaN(r))if(r===0)t.push({type:"resetAll"});else if(r<=9)Wg[r]&&t.push({type:"setDecoration",value:Wg[r]});else if(r<=29){const a=Wg[r-20];a&&(t.push({type:"resetDecoration",value:a}),a==="dim"&&t.push({type:"resetDecoration",value:"bold"}))}else if(r<=37)t.push({type:"setForegroundColor",value:{type:"named",name:Oa[r-30]}});else if(r===38){const a=Qw(e);a&&t.push({type:"setForegroundColor",value:a})}else if(r===39)t.push({type:"resetForegroundColor"});else if(r<=47)t.push({type:"setBackgroundColor",value:{type:"named",name:Oa[r-40]}});else if(r===48){const a=Qw(e);a&&t.push({type:"setBackgroundColor",value:a})}else r===49?t.push({type:"resetBackgroundColor"}):r===53?t.push({type:"setDecoration",value:"overline"}):r===55?t.push({type:"resetDecoration",value:"overline"}):r>=90&&r<=97?t.push({type:"setForegroundColor",value:{type:"named",name:Oa[r-90+8]}}):r>=100&&r<=107&&t.push({type:"setBackgroundColor",value:{type:"named",name:Oa[r-100+8]}})}return t}function rz(){let e=null,t=null,n=new Set;return{parse(r){const a=[];let l=0;do{const u=tz(r,l),c=u.sequence?r.substring(l,u.startPosition):r.substring(l);if(c.length>0&&a.push({value:c,foreground:e,background:t,decorations:new Set(n)}),u.sequence){const d=nz(u.sequence);for(const h of d)h.type==="resetAll"?(e=null,t=null,n.clear()):h.type==="resetForegroundColor"?e=null:h.type==="resetBackgroundColor"?t=null:h.type==="resetDecoration"&&n.delete(h.value);for(const h of d)h.type==="setForegroundColor"?e=h.value:h.type==="setBackgroundColor"?t=h.value:h.type==="setDecoration"&&n.add(h.value)}l=u.position}while(l<r.length);return a}}}var sz={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 iz(e=sz){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 r;function a(){if(r)return r;r=[];for(let h=0;h<Oa.length;h++)r.push(t(Oa[h]));let c=[0,95,135,175,215,255];for(let h=0;h<6;h++)for(let p=0;p<6;p++)for(let m=0;m<6;m++)r.push(n([c[h],c[p],c[m]]));let d=8;for(let h=0;h<24;h++,d+=10)r.push(n([d,d,d]));return r}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 az=/#([0-9a-f]{3,8})/i,oz=/var\((--[\w-]+-ansi-[\w-]+)\)/,lz={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 cz(e,t,n){const r=Hh(e,n),a=Df(t),l=iz(Object.fromEntries(Oa.map(c=>{var h;const d=`terminal.ansi${c[0].toUpperCase()}${c.substring(1)}`;return[c,((h=e.colors)==null?void 0:h[d])||lz[c]]}))),u=rz();return a.map(c=>u.parse(c[0]).map(d=>{let h,p;d.decorations.has("reverse")?(h=d.background?l.value(d.background):e.bg,p=d.foreground?l.value(d.foreground):e.fg):(h=d.foreground?l.value(d.foreground):e.fg,p=d.background?l.value(d.background):void 0),h=qi(h,r),p=qi(p,r),d.decorations.has("dim")&&(h=uz(h));let m=Xn.None;return d.decorations.has("bold")&&(m|=Xn.Bold),d.decorations.has("italic")&&(m|=Xn.Italic),d.decorations.has("underline")&&(m|=Xn.Underline),d.decorations.has("strikethrough")&&(m|=Xn.Strikethrough),{content:d.value,offset:c[1],color:h,bgColor:p,fontStyle:m}}))}function uz(e){const t=e.match(az);if(t){const r=t[1];if(r.length===8){const a=Math.round(Number.parseInt(r.slice(6,8),16)/2).toString(16).padStart(2,"0");return`#${r.slice(0,6)}${a}`}else{if(r.length===6)return`#${r}80`;if(r.length===4){const a=r[0],l=r[1],u=r[2],c=r[3];return`#${a}${a}${l}${l}${u}${u}${Math.round(Number.parseInt(`${c}${c}`,16)/2).toString(16).padStart(2,"0")}`}else if(r.length===3){const a=r[0],l=r[1],u=r[2];return`#${a}${a}${l}${l}${u}${u}80`}}}const n=e.match(oz);return n?`var(${n[1]}-dim)`:e}function ny(e,t,n={}){const r=e.resolveLangAlias(n.lang||"text"),{theme:a=e.getLoadedThemes()[0]}=n;if(!Lf(r)&&!Rf(a)&&r==="ansi"){const{theme:l}=e.setTheme(a);return cz(l,t,n)}return k2(e,t,n)}function Vh(e,t,n){let r,a,l,u,c,d;if("themes"in n){const{defaultColor:h="light",cssVariablePrefix:p="--shiki-",colorsRendering:m="css-vars"}=n,g=Object.entries(n.themes).filter(S=>S[1]).map(S=>({color:S[0],theme:S[1]})).sort((S,b)=>S.color===h?-1:b.color===h?1:0);if(g.length===0)throw new en("`themes` option must not be empty");const y=E2(e,t,n,ny);if(d=iu(y),h&&h!=="light-dark()"&&!g.some(S=>S.color===h))throw new en(`\`themes\` option must contain the defaultColor key \`${h}\``);const w=g.map(S=>e.getTheme(S.theme)),C=g.map(S=>S.color);l=y.map(S=>S.map(b=>X$(b,C,p,h,m))),d&&Of(l,d);const _=g.map(S=>Hh(S.theme,n));a=Jw(g,w,_,p,h,"fg",m),r=Jw(g,w,_,p,h,"bg",m),u=`shiki-themes ${w.map(S=>S.name).join(" ")}`,c=h?void 0:[a,r].join(";")}else if("theme"in n){const h=Hh(n.theme,n);l=ny(e,t,n);const p=e.getTheme(n.theme);r=qi(p.bg,h),a=qi(p.fg,h),u=p.name,d=iu(l)}else throw new en("Invalid options, either `theme` or `themes` must be provided");return{tokens:l,fg:a,bg:r,themeName:u,rootStyle:c,grammarState:d}}function Jw(e,t,n,r,a,l,u){return e.map((c,d)=>{const h=qi(t[d][l],n[d])||"inherit",p=`${r+c.color}${l==="bg"?"-bg":""}:${h}`;if(d===0&&a){if(a==="light-dark()"&&e.length>1){const m=e.findIndex(y=>y.color==="light"),g=e.findIndex(y=>y.color==="dark");if(m===-1||g===-1)throw new en('When using `defaultColor: "light-dark()"`, you must provide both `light` and `dark` themes');return`light-dark(${qi(t[m][l],n[m])||"inherit"}, ${qi(t[g][l],n[g])||"inherit"});${p}`}return h}return u==="css-vars"?p:null}).filter(c=>!!c).join(";")}const F2=/^\s+$/,dz=/^(\s*)(.*?)(\s*)$/;function Wh(e,t,n,r={meta:{},options:n,codeToHast:(a,l)=>Wh(e,a,l),codeToTokens:(a,l)=>Vh(e,a,l)}){var w,C;let a=t;for(const _ of Uh(n))a=((w=_.preprocess)==null?void 0:w.call(r,a,n))||a;let{tokens:l,fg:u,bg:c,themeName:d,rootStyle:h,grammarState:p}=Vh(e,a,n);const{mergeWhitespaces:m=!0,mergeSameStyleTokens:g=!1}=n;m===!0?l=fz(l):m==="never"&&(l=mz(l)),g&&(l=pz(l));const y={...r,get source(){return a}};for(const _ of Uh(n))l=((C=_.tokens)==null?void 0:C.call(y,l))||l;return hz(l,{...n,fg:u,bg:c,themeName:d,rootStyle:n.rootStyle===!1?!1:n.rootStyle??h},y,p)}function hz(e,t,n,r=iu(e)){var C,_,S,b;const a=Uh(t),l=[],u={type:"root",children:[]},{structure:c="classic",tabindex:d="0"}=t,h={class:`shiki ${t.themeName||""}`};t.rootStyle!==!1&&(t.rootStyle!=null?h.style=t.rootStyle:h.style=`background-color:${t.bg};color:${t.fg}`),d!==!1&&d!=null&&(h.tabindex=d.toString());for(const[v,k]of Object.entries(t.meta||{}))v.startsWith("_")||(h[v]=k);let p={type:"element",tagName:"pre",properties:h,children:[],data:t.data},m={type:"element",tagName:"code",properties:{},children:l};const g=[],y={...n,structure:c,addClassToHast:z2,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 g}};if(e.forEach((v,k)=>{var R,A;k&&(c==="inline"?u.children.push({type:"element",tagName:"br",properties:{},children:[]}):c==="classic"&&l.push({type:"text",value:`
106
+ `}));let T={type:"element",tagName:"span",properties:{class:"line"},children:[]},N=0;for(const O of v){let P={type:"element",tagName:"span",properties:{...O.htmlAttrs},children:[{type:"text",value:O.content}]};const V=ty(O.htmlStyle||Fh(O));V&&(P.properties.style=V);for(const z of a)P=((R=z==null?void 0:z.span)==null?void 0:R.call(y,P,k+1,N,T,O))||P;c==="inline"?u.children.push(P):c==="classic"&&T.children.push(P),N+=O.content.length}if(c==="classic"){for(const O of a)T=((A=O==null?void 0:O.line)==null?void 0:A.call(y,T,k+1))||T;g.push(T),l.push(T)}else c==="inline"&&g.push(T)}),c==="classic"){for(const v of a)m=((C=v==null?void 0:v.code)==null?void 0:C.call(y,m))||m;p.children.push(m);for(const v of a)p=((_=v==null?void 0:v.pre)==null?void 0:_.call(y,p))||p;u.children.push(p)}else if(c==="inline"){const v=[];let k={type:"element",tagName:"span",properties:{class:"line"},children:[]};for(const N of u.children)N.type==="element"&&N.tagName==="br"?(v.push(k),k={type:"element",tagName:"span",properties:{class:"line"},children:[]}):(N.type==="element"||N.type==="text")&&k.children.push(N);v.push(k);let T={type:"element",tagName:"code",properties:{},children:v};for(const N of a)T=((S=N==null?void 0:N.code)==null?void 0:S.call(y,T))||T;u.children=[];for(let N=0;N<T.children.length;N++){N>0&&u.children.push({type:"element",tagName:"br",properties:{},children:[]});const R=T.children[N];R.type==="element"&&u.children.push(...R.children)}}let w=u;for(const v of a)w=((b=v==null?void 0:v.root)==null?void 0:b.call(y,w))||w;return r&&Of(w,r),w}function fz(e){return e.map(t=>{const n=[];let r="",a;return t.forEach((l,u)=>{const c=!(l.fontStyle&&(l.fontStyle&Xn.Underline||l.fontStyle&Xn.Strikethrough));c&&F2.test(l.content)&&t[u+1]?(a===void 0&&(a=l.offset),r+=l.content):r?(c?n.push({...l,offset:a,content:r+l.content}):n.push({content:r,offset:a},l),a=void 0,r=""):n.push(l)}),n})}function mz(e){return e.map(t=>t.flatMap(n=>{if(F2.test(n.content))return n;const r=n.content.match(dz);if(!r)return n;const[,a,l,u]=r;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 pz(e){return e.map(t=>{const n=[];for(const r of t){if(n.length===0){n.push({...r});continue}const a=n.at(-1),l=ty(a.htmlStyle||Fh(a)),u=ty(r.htmlStyle||Fh(r)),c=a.fontStyle&&(a.fontStyle&Xn.Underline||a.fontStyle&Xn.Strikethrough),d=r.fontStyle&&(r.fontStyle&Xn.Underline||r.fontStyle&Xn.Strikethrough);!c&&!d&&l===u?a.content+=r.content:n.push({...r})}return n})}const gz=B$;function xz(e,t,n){var l;const r={meta:{},options:n,codeToHast:(u,c)=>Wh(e,u,c),codeToTokens:(u,c)=>Vh(e,u,c)};let a=gz(Wh(e,t,n,r));for(const u of Uh(n))a=((l=u.postprocess)==null?void 0:l.call(r,a,n))||a;return a}async function yz(e){const t=await f8(e);return{getLastGrammarState:(...n)=>y8(t,...n),codeToTokensBase:(n,r)=>ny(t,n,r),codeToTokensWithThemes:(n,r)=>E2(t,n,r),codeToTokens:(n,r)=>Vh(t,n,r),codeToHast:(n,r)=>Wh(t,n,r),codeToHtml:(n,r)=>xz(t,n,r),getBundledLanguages:()=>({}),getBundledThemes:()=>({}),...t,getInternalContext:()=>t}}function bz(e){const t=e.langs,n=e.themes,r=e.engine;async function a(l){function u(m){var g;if(typeof m=="string"){if(m=((g=l.langAlias)==null?void 0:g[m])||m,y2(m))return[];const y=t[m];if(!y)throw new en(`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(b2(m))return"none";if(typeof m=="string"){const g=n[m];if(!g)throw new en(`Theme \`${m}\` is not included in this bundle. You may want to load it from external source.`);return g}return m}const d=(l.themes??[]).map(m=>c(m)),h=(l.langs??[]).map(m=>u(m)),p=await yz({engine:l.engine??r(),...l,themes:d,langs:h});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 vz(e){let t;async function n(r={}){if(t){const a=await t;return await Promise.all([a.loadTheme(...r.themes||[]),a.loadLanguage(...r.langs||[])]),a}else{t=e({...r,themes:[],langs:[]});const a=await t;return await Promise.all([a.loadTheme(...r.themes||[]),a.loadLanguage(...r.langs||[])]),a}}return n}function _z(e,t){const n=vz(e);async function r(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 r(a,l)).codeToHtml(a,l)},async codeToHast(a,l){return(await r(a,l)).codeToHast(a,l)},async codeToTokens(a,l){return(await r(a,l)).codeToTokens(a,l)},async codeToTokensBase(a,l){return(await r(a,l)).codeToTokensBase(a,l)},async codeToTokensWithThemes(a,l){return(await r(a,l)).codeToTokensWithThemes(a,l)},async getLastGrammarState(a,l){return(await n({langs:[l.lang],themes:[l.theme]})).getLastGrammarState(a,l)}}}var Sz=ob({bundledLanguages:()=>Nf,bundledLanguagesAlias:()=>cb,bundledLanguagesBase:()=>lb,bundledLanguagesInfo:()=>jf,bundledThemes:()=>db,bundledThemesInfo:()=>ub,codeToHast:()=>V2,codeToHtml:()=>U2,codeToTokens:()=>W2,codeToTokensBase:()=>G2,codeToTokensWithThemes:()=>q2,createHighlighter:()=>Mf,getLastGrammarState:()=>Y2,getSingletonHighlighter:()=>K2});const Mf=bz({langs:Nf,themes:db,engine:()=>(0,t2.createOnigurumaEngine)(te(()=>import("./wasm-CG6Dc4jp.js"),[]))}),{codeToHtml:U2,codeToHast:V2,codeToTokens:W2,codeToTokensBase:G2,codeToTokensWithThemes:q2,getSingletonHighlighter:K2,getLastGrammarState:Y2}=_z(Mf,{guessEmbeddedLanguages:G$}),Zw=4294967295;var wz=class{constructor(e,t={}){Ae(this,"patterns");Ae(this,"options");Ae(this,"regexps");this.patterns=e,this.options=t;const{forgiving:n=!1,cache:r,regexConstructor:a}=t;if(!a)throw new Error("Option `regexConstructor` is not provided");this.regexps=e.map(l=>{if(typeof l!="string")return l;const u=r==null?void 0:r.get(l);if(u){if(u instanceof RegExp)return u;if(n)return null;throw u}try{const c=a(l);return r==null||r.set(l,c),c}catch(c){if(r==null||r.set(l,c),n)return null;throw c}})}findNextMatchSync(e,t,n){const r=typeof e=="string"?e:e.content,a=[];function l(u,c,d=0){return{index:u,captureIndices:c.indices.map(h=>h==null?{start:Zw,end:Zw,length:0}:{start:h[0]+d,end:h[1]+d,length:h[1]-h[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(r);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,h]of a)if(d.index===u)return l(c,d,h)}return null}};function _l(e){if([...e].length!==1)throw new Error(`Expected "${e}" to be a single code point`);return e.codePointAt(0)}function Cz(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}const vb=new Set(["alnum","alpha","ascii","blank","cntrl","digit","graph","lower","print","punct","space","upper","word","xdigit"]),Hn=String.raw;function Sl(e,t){if(e==null)throw new Error(t??"Value expected");return e}const X2=Hn`\[\^?`,Q2=`c.? | C(?:-.?)?|${Hn`[pP]\{(?:\^?[-\x20_]*[A-Za-z][-\x20\w]*\})?`}|${Hn`x[89A-Fa-f]\p{AHex}(?:\\x[89A-Fa-f]\p{AHex})*`}|${Hn`u(?:\p{AHex}{4})? | x\{[^\}]*\}? | x\p{AHex}{0,2}`}|${Hn`o\{[^\}]*\}?`}|${Hn`\d{1,3}`}`,_b=/[?*+][?+]?|\{(?:\d+(?:,\d*)?|,\d+)\}\??/,Yd=new RegExp(Hn`
107
+ \\ (?:
108
+ ${Q2}
109
+ | [gk]<[^>]*>?
110
+ | [gk]'[^']*'?
111
+ | .
112
+ )
113
+ | \( (?:
114
+ \? (?:
115
+ [:=!>({]
116
+ | <[=!]
117
+ | <[^>]*>
118
+ | '[^']*'
119
+ | ~\|?
120
+ | #(?:[^)\\]|\\.?)*
121
+ | [^:)]*[:)]
122
+ )?
123
+ | \*[^\)]*\)?
124
+ )?
125
+ | (?:${_b.source})+
126
+ | ${X2}
127
+ | .
128
+ `.replace(/\s+/g,""),"gsu"),Gg=new RegExp(Hn`
129
+ \\ (?:
130
+ ${Q2}
131
+ | .
132
+ )
133
+ | \[:(?:\^?\p{Alpha}+|\^):\]
134
+ | ${X2}
135
+ | &&
136
+ | .
137
+ `.replace(/\s+/g,""),"gsu");function kz(e,t={}){const n={flags:"",...t,rules:{captureGroup:!1,singleline:!1,...t.rules}};if(typeof e!="string")throw new Error("String expected as pattern");const r=Vz(n.flags),a=[r.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(Yd.lastIndex=0;c=Yd.exec(e);){const m=Ez(l,e,c[0],Yd.lastIndex);m.tokens?u.push(...m.tokens):m.token&&u.push(m.token),m.lastIndex!==void 0&&(Yd.lastIndex=m.lastIndex)}const d=[];let h=0;u.filter(m=>m.type==="GroupOpen").forEach(m=>{m.kind==="capturing"?m.number=++h:m.raw==="("&&d.push(m)}),h||d.forEach((m,g)=>{m.kind="capturing",m.number=g+1});const p=h||d.length;return{tokens:u.map(m=>m.type==="EscapedNumber"?Gz(m,p):m).flat(),flags:r}}function Ez(e,t,n,r){const[a,l]=n;if(n==="["||n==="[^"){const u=jz(t,n,r);return{tokens:u.tokens,lastIndex:u.lastIndex}}if(a==="\\"){if("AbBGyYzZ".includes(l))return{token:eC(n,n)};if(/^\\g[<']/.test(n)){if(!/^\\g(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:Pz(n)}}if(/^\\k[<']/.test(n)){if(!/^\\k(?:<[^>]+>|'[^']+')$/.test(n))throw new Error(`Invalid group name "${n}"`);return{token:Z2(n)}}if(l==="K")return{token:eN("keep",n)};if(l==="N"||l==="R")return{token:Ia("newline",n,{negate:l==="N"})};if(l==="O")return{token:Ia("any",n)};if(l==="X")return{token:Ia("text_segment",n)};const u=J2(n,{inCharClass:!1});return Array.isArray(u)?{tokens:u}:{token:u}}if(a==="("){if(l==="*")return{token:Hz(n)};if(n==="(?{")throw new Error(`Unsupported callout "${n}"`);if(n.startsWith("(?#")){if(t[r]!==")")throw new Error('Unclosed comment group "(?#"');return{lastIndex:r+1}}if(/^\(\?[-imx]+[:)]$/.test(n))return{token:zz(n,e)};if(e.pushModX(e.getCurrentModX()),e.numOpenGroups++,n==="("&&!e.captureGroup||n==="(?:")return{token:Go("group",n)};if(n==="(?>")return{token:Go("atomic",n)};if(n==="(?="||n==="(?!"||n==="(?<="||n==="(?<!")return{token:Go(n[2]==="<"?"lookbehind":"lookahead",n,{negate:n.endsWith("!")})};if(n==="("&&e.captureGroup||n.startsWith("(?<")&&n.endsWith(">")||n.startsWith("(?'")&&n.endsWith("'"))return{token:Go("capturing",n,{...n!=="("&&{name:n.slice(3,-1)}})};if(n.startsWith("(?~")){if(n==="(?~|")throw new Error(`Unsupported absence function kind "${n}"`);return{token:Go("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:Oz(n)}}if(e.getCurrentModX()){if(n==="#"){const u=t.indexOf(`
138
+ `,r);return{lastIndex:u===-1?t.length:u}}if(/^\s$/.test(n)){const u=/\s+/y;return u.lastIndex=r,{lastIndex:u.exec(t)?u.lastIndex:r}}}if(n===".")return{token:Ia("dot",n)};if(n==="^"||n==="$"){const u=e.singleline?{"^":Hn`\A`,$:Hn`\Z`}[n]:n;return{token:eC(u,n)}}return n==="|"?{token:Tz(n)}:_b.test(n)?{tokens:qz(n)}:{token:oi(_l(n),n)}}function jz(e,t,n){const r=[tC(t[1]==="^",t)];let a=1,l;for(Gg.lastIndex=n;l=Gg.exec(e);){const u=l[0];if(u[0]==="["&&u[1]!==":")a++,r.push(tC(u[1]==="^",u));else if(u==="]"){if(r.at(-1).type==="CharacterClassOpen")r.push(oi(93,u));else if(a--,r.push(Az(u)),!a)break}else{const c=Nz(u);Array.isArray(c)?r.push(...c):r.push(c)}}return{tokens:r,lastIndex:Gg.lastIndex||e.length}}function Nz(e){if(e[0]==="\\")return J2(e,{inCharClass:!0});if(e[0]==="["){const t=/\[:(?<negate>\^?)(?<name>[a-z]+):\]/.exec(e);if(!t||!vb.has(t.groups.name))throw new Error(`Invalid POSIX class "${e}"`);return Ia("posix",e,{value:t.groups.name,negate:!!t.groups.negate})}return e==="-"?Lz(e):e==="&&"?Rz(e):oi(_l(e),e)}function J2(e,{inCharClass:t}){const n=e[1];if(n==="c"||n==="C")return $z(e);if("dDhHsSwW".includes(n))return Fz(e);if(e.startsWith(Hn`\o{`))throw new Error(`Incomplete, invalid, or unsupported octal code point "${e}"`);if(/^\\[pP]\{/.test(e)){if(e.length===3)throw new Error(`Incomplete or invalid Unicode property "${e}"`);return Uz(e)}if(new RegExp("^\\\\x[89A-Fa-f]\\p{AHex}","u").test(e))try{const r=e.split(/\\x/).slice(1).map(u=>parseInt(u,16)),a=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}).decode(new Uint8Array(r)),l=new TextEncoder;return[...a].map(u=>{const c=[...l.encode(u)].map(d=>`\\x${d.toString(16)}`).join("");return oi(_l(u),c)})}catch{throw new Error(`Multibyte code "${e}" incomplete or invalid in Oniguruma`)}if(n==="u"||n==="x")return oi(Wz(e),e);if(nC.has(n))return oi(nC.get(n),e);if(/\d/.test(n))return Dz(t,e);if(e==="\\")throw new Error(Hn`Incomplete escape "\"`);if(n==="M")throw new Error(`Unsupported meta "${e}"`);if([...e].length===2)return oi(e.codePointAt(1),e);throw new Error(`Unexpected escape "${e}"`)}function Tz(e){return{type:"Alternator",raw:e}}function eC(e,t){return{type:"Assertion",kind:e,raw:t}}function Z2(e){return{type:"Backreference",raw:e}}function oi(e,t){return{type:"Character",value:e,raw:t}}function Az(e){return{type:"CharacterClassClose",raw:e}}function Lz(e){return{type:"CharacterClassHyphen",raw:e}}function Rz(e){return{type:"CharacterClassIntersector",raw:e}}function tC(e,t){return{type:"CharacterClassOpen",negate:e,raw:t}}function Ia(e,t,n={}){return{type:"CharacterSet",kind:e,...n,raw:t}}function eN(e,t,n={}){return e==="keep"?{type:"Directive",kind:e,raw:t}:{type:"Directive",kind:e,flags:Sl(n.flags),raw:t}}function Dz(e,t){return{type:"EscapedNumber",inCharClass:e,raw:t}}function Oz(e){return{type:"GroupClose",raw:e}}function Go(e,t,n={}){return{type:"GroupOpen",kind:e,...n,raw:t}}function Iz(e,t,n,r){return{type:"NamedCallout",kind:e,tag:t,arguments:n,raw:r}}function Mz(e,t,n,r){return{type:"Quantifier",kind:e,min:t,max:n,raw:r}}function Pz(e){return{type:"Subroutine",raw:e}}const Bz=new Set(["COUNT","CMP","ERROR","FAIL","MAX","MISMATCH","SKIP","TOTAL_COUNT"]),nC=new Map([["a",7],["b",8],["e",27],["f",12],["n",10],["r",13],["t",9],["v",11]]);function $z(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 oi(_l(t.toUpperCase())-64,e)}function zz(e,t){let{on:n,off:r}=/^\(\?(?<on>[imx]*)(?:-(?<off>[-imx]*))?/.exec(e).groups;r??(r="");const a=(t.getCurrentModX()||n.includes("x"))&&!r.includes("x"),l=sC(n),u=sC(r),c={};if(l&&(c.enable=l),u&&(c.disable=u),e.endsWith(")"))return t.replaceCurrentModX(a),eN("flags",e,{flags:c});if(e.endsWith(":"))return t.pushModX(a),t.numOpenGroups++,Go("group",e,{...(l||u)&&{flags:c}});throw new Error(`Unexpected flag modifier "${e}"`)}function Hz(e){const t=/\(\*(?<name>[A-Za-z_]\w*)?(?:\[(?<tag>(?:[A-Za-z_]\w*)?)\])?(?:\{(?<args>[^}]*)\})?\)/.exec(e);if(!t)throw new Error(`Incomplete or invalid named callout "${e}"`);const{name:n,tag:r,args:a}=t.groups;if(!n)throw new Error(`Invalid named callout "${e}"`);if(r==="")throw new Error(`Named callout tag with empty value not allowed "${e}"`);const l=a?a.split(",").filter(p=>p!=="").map(p=>/^[+-]?\d+$/.test(p)?+p:p):[],[u,c,d]=l,h=Bz.has(n)?n.toLowerCase():"custom";switch(h){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 "${h}"`)}return Iz(h,r??null,(a==null?void 0:a.split(","))??null,e)}function rC(e){let t=null,n,r;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,r=l===void 0?+a:l===""?1/0:+l,n>r&&(t="possessive",[n,r]=[r,n]),e.endsWith("?")){if(t==="possessive")throw new Error('Unsupported possessive interval quantifier chain with "?"');t="lazy"}else t||(t="greedy")}else n=e[0]==="+"?1:0,r=e[0]==="?"?1:1/0,t=e[1]==="+"?"possessive":e[1]==="?"?"lazy":"greedy";return Mz(t,n,r,e)}function Fz(e){const t=e[1].toLowerCase();return Ia({d:"digit",h:"hex",s:"space",w:"word"}[t],e,{negate:e[1]!==t})}function Uz(e){const{p:t,neg:n,value:r}=/^\\(?<p>[pP])\{(?<neg>\^?)(?<value>[^}]+)/.exec(e).groups;return Ia("property",e,{value:r,negate:t==="P"&&!n||t==="p"&&!!n})}function sC(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 Vz(e){const t={ignoreCase:!1,dotAll:!1,extended:!1,digitIsAscii:!1,posixIsAscii:!1,spaceIsAscii:!1,wordIsAscii:!1,textSegmentMode:null};for(let n=0;n<e.length;n++){const r=e[n];if(!"imxDPSWy".includes(r))throw new Error(`Invalid flag "${r}"`);if(r==="y"){if(!/^y{[gw]}/.test(e.slice(n)))throw new Error('Invalid or unspecified flag "y" mode');t.textSegmentMode=e[n+2]==="g"?"grapheme":"word",n+=3;continue}t[{i:"ignoreCase",m:"dotAll",x:"extended",D:"digitIsAscii",P:"posixIsAscii",S:"spaceIsAscii",W:"wordIsAscii"}[r]]=!0}return t}function Wz(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 Gz(e,t){const{raw:n,inCharClass:r}=e,a=n.slice(1);if(!r&&(a!=="0"&&a.length===1||a[0]!=="0"&&+a<=t))return[Z2(n)];const l=[],u=a.match(/^[0-7]+|\d/g);for(let c=0;c<u.length;c++){const d=u[c];let h;if(c===0&&d!=="8"&&d!=="9"){if(h=parseInt(d,8),h>127)throw new Error(Hn`Octal encoded byte above 177 unsupported "${n}"`)}else h=_l(d);l.push(oi(h,(c===0?"\\":"")+d))}return l}function qz(e){const t=[],n=new RegExp(_b,"gy");let r;for(;r=n.exec(e);){const a=r[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(rC(a.slice(0,-1)));continue}}}t.push(rC(a))}return t}function tN(e,t){if(!Array.isArray(e.body))throw new Error("Expected node with body array");if(e.body.length!==1)return!1;const n=e.body[0];return!t||Object.keys(t).every(r=>t[r]===n[r])}function Kz(e){return Yz.has(e.type)}const Yz=new Set(["AbsenceFunction","Backreference","CapturingGroup","Character","CharacterClass","CharacterSet","Group","Quantifier","Subroutine"]);function nN(e,t={}){const n={flags:"",normalizeUnknownPropertyNames:!1,skipBackrefValidation:!1,skipLookbehindValidation:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t,rules:{captureGroup:!1,singleline:!1,...t.rules}},r=kz(e,{flags:n.flags,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline}}),a=(g,y)=>{const w=r.tokens[l.nextIndex];switch(l.parent=g,l.nextIndex++,w.type){case"Alternator":return Ka();case"Assertion":return Xz(w);case"Backreference":return Qz(w,l);case"Character":return Pf(w.value,{useLastValid:!!y.isCheckingRangeEnd});case"CharacterClassHyphen":return Jz(w,l,y);case"CharacterClassOpen":return Zz(w,l,y);case"CharacterSet":return eH(w,l);case"Directive":return aH(w.kind,{flags:w.flags});case"GroupOpen":return tH(w,l,y);case"NamedCallout":return lH(w.kind,w.tag,w.arguments);case"Quantifier":return nH(w,l);case"Subroutine":return rH(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:r.tokens,unicodePropertyMap:n.unicodePropertyMap,walk:a},u=uH(oH(r.flags));let c=u.body[0];for(;l.nextIndex<r.tokens.length;){const g=a(c,{});g.type==="Alternative"?(u.body.push(g),c=g):c.body.push(g)}const{capturingGroups:d,hasNumberedRef:h,namedGroupsByName:p,subroutines:m}=l;if(h&&p.size&&!n.rules.captureGroup)throw new Error("Numbered backref/subroutine not allowed when using named capture");for(const{ref:g}of m)if(typeof g=="number"){if(g>d.length)throw new Error("Subroutine uses a group number that's not defined");g&&(d[g-1].isSubroutined=!0)}else if(p.has(g)){if(p.get(g).length>1)throw new Error(Hn`Subroutine uses a duplicate group name "\g<${g}>"`);p.get(g)[0].isSubroutined=!0}else throw new Error(Hn`Subroutine uses a group name that's not defined "\g<${g}>"`);return u}function Xz({kind:e}){return ry(Sl({"^":"line_start",$:"line_end","\\A":"string_start","\\b":"word_boundary","\\B":"word_boundary","\\G":"search_start","\\y":"text_segment_boundary","\\Y":"text_segment_boundary","\\z":"string_end","\\Z":"string_end_newline"}[e],`Unexpected assertion kind "${e}"`),{negate:e===Hn`\B`||e===Hn`\Y`})}function Qz({raw:e},t){const n=/^\\k[<']/.test(e),r=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,sy(u?c+1-l:l,{orphan:d})};if(n){const l=/^(?<sign>-?)0*(?<num>[1-9]\d*)$/.exec(r);if(l)return a(+l.groups.num,!!l.groups.sign);if(/[-+]/.test(r))throw new Error(`Invalid backref name "${e}"`);if(!t.namedGroupsByName.has(r))throw new Error(`Group name not defined to the left "${e}"`);return sy(r)}return a(+r)}function Jz(e,t,n){const{tokens:r,walk:a}=t,l=t.parent,u=l.body.at(-1),c=r[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(),iH(u,d);throw new Error("Invalid character class range")}return Pf(_l("-"))}function Zz({negate:e},t,n){const{tokens:r,walk:a}=t,l=[_h()],u=r[t.nextIndex];let c=oC(u);for(;c.type!=="CharacterClassClose";){if(c.type==="CharacterClassIntersector")l.push(_h()),t.nextIndex++;else{const h=l.at(-1);h.body.push(a(h,n))}c=oC(r[t.nextIndex],u)}const d=_h({negate:e});return l.length===1?d.body=l[0].body:(d.kind="intersection",d.body=l.map(h=>h.body.length===1?h.body[0]:h)),t.nextIndex++,d}function eH({kind:e,negate:t,value:n},r){const{normalizeUnknownPropertyNames:a,skipPropertyNameValidation:l,unicodePropertyMap:u}=r;if(e==="property"){const c=Bf(n);if(vb.has(c)&&!(u!=null&&u.has(c)))e="posix",n=c;else return qo(n,{negate:t,normalizeUnknownPropertyNames:a,skipPropertyNameValidation:l,unicodePropertyMap:u})}return e==="posix"?cH(n,{negate:t}):iy(e,{negate:t})}function tH(e,t,n){const{tokens:r,capturingGroups:a,namedGroupsByName:l,skipLookbehindValidation:u,walk:c}=t,d=dH(e),h=d.type==="AbsenceFunction",p=aC(d),m=p&&d.negate;if(d.type==="CapturingGroup"&&(a.push(d),d.name&&Cz(l,d.name,[]).push(d)),h&&n.isInAbsenceFunction)throw new Error("Nested absence function not supported by Oniguruma");let g=lC(r[t.nextIndex]);for(;g.type!=="GroupClose";){if(g.type==="Alternator")d.body.push(Ka()),t.nextIndex++;else{const y=d.body.at(-1),w=c(y,{...n,isInAbsenceFunction:n.isInAbsenceFunction||h,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(iC(w)||w.type==="CapturingGroup")throw new Error(C)}else if(iC(w)||aC(w)&&w.negate)throw new Error(C)}}g=lC(r[t.nextIndex])}return t.nextIndex++,d}function nH({kind:e,min:t,max:n},r){const a=r.parent,l=a.body.at(-1);if(!l||!Kz(l))throw new Error("Quantifier requires a repeatable token");const u=sN(e,t,n,l);return a.body.pop(),u}function rH({raw:e},t){const{capturingGroups:n,subroutines:r}=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=iN(a);return r.push(u),u}function sH(e,t){return{type:"AbsenceFunction",kind:e,body:yu(t==null?void 0:t.body)}}function Ka(e){return{type:"Alternative",body:aN(e==null?void 0:e.body)}}function ry(e,t){const n={type:"Assertion",kind:e};return(e==="word_boundary"||e==="text_segment_boundary")&&(n.negate=!!(t!=null&&t.negate)),n}function sy(e,t){const n=!!(t!=null&&t.orphan);return{type:"Backreference",ref:e,...n&&{orphan:n}}}function rN(e,t){const n={name:void 0,isSubroutined:!1,...t};if(n.name!==void 0&&!hH(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:yu(t==null?void 0:t.body)}}function Pf(e,t){const n={useLastValid:!1,...t};if(e>1114111){const r=e.toString(16);if(n.useLastValid)e=1114111;else throw e>1310719?new Error(`Invalid code point out of range "\\x{${r}}"`):new Error(`Invalid code point out of range in JS "\\x{${r}}"`)}return{type:"Character",value:e}}function _h(e){const t={kind:"union",negate:!1,...e};return{type:"CharacterClass",kind:t.kind,negate:t.negate,body:aN(e==null?void 0:e.body)}}function iH(e,t){if(t.value<e.value)throw new Error("Character class range out of order");return{type:"CharacterClassRange",min:e,max:t}}function iy(e,t){const n=!!(t!=null&&t.negate),r={type:"CharacterSet",kind:e};return(e==="digit"||e==="hex"||e==="newline"||e==="space"||e==="word")&&(r.negate=n),(e==="text_segment"||e==="newline"&&!n)&&(r.variableLength=!0),r}function aH(e,t={}){if(e==="keep")return{type:"Directive",kind:e};if(e==="flags")return{type:"Directive",kind:e,flags:Sl(t.flags)};throw new Error(`Unexpected directive kind "${e}"`)}function oH(e){return{type:"Flags",...e}}function as(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:yu(e==null?void 0:e.body)}}function Ra(e){const t={behind:!1,negate:!1,...e};return{type:"LookaroundAssertion",kind:t.behind?"lookbehind":"lookahead",negate:t.negate,body:yu(e==null?void 0:e.body)}}function lH(e,t,n){return{type:"NamedCallout",kind:e,tag:t,arguments:n}}function cH(e,t){const n=!!(t!=null&&t.negate);if(!vb.has(e))throw new Error(`Invalid POSIX class "${e}"`);return{type:"CharacterSet",kind:"posix",value:e,negate:n}}function sN(e,t,n,r){if(t>n)throw new Error("Invalid reversed quantifier range");return{type:"Quantifier",kind:e,min:t,max:n,body:r}}function uH(e,t){return{type:"Regex",body:yu(t==null?void 0:t.body),flags:e}}function iN(e){return{type:"Subroutine",ref:e}}function qo(e,t){var a;const n={negate:!1,normalizeUnknownPropertyNames:!1,skipPropertyNameValidation:!1,unicodePropertyMap:null,...t};let r=(a=n.unicodePropertyMap)==null?void 0:a.get(Bf(e));if(!r){if(n.normalizeUnknownPropertyNames)r=fH(e);else if(n.unicodePropertyMap&&!n.skipPropertyNameValidation)throw new Error(Hn`Invalid Unicode property "\p{${e}}"`)}return{type:"CharacterSet",kind:"property",value:r??e,negate:n.negate}}function dH({flags:e,kind:t,name:n,negate:r,number:a}){switch(t){case"absence_repeater":return sH("repeater");case"atomic":return as({atomic:!0});case"capturing":return rN(a,{name:n});case"group":return as({flags:e});case"lookahead":case"lookbehind":return Ra({behind:t==="lookbehind",negate:r});default:throw new Error(`Unexpected group kind "${t}"`)}}function yu(e){if(e===void 0)e=[Ka()];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 aN(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 iC(e){return e.type==="LookaroundAssertion"&&e.kind==="lookahead"}function aC(e){return e.type==="LookaroundAssertion"&&e.kind==="lookbehind"}function hH(e){return/^[\p{Alpha}\p{Pc}][^)]*$/u.test(e)}function fH(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 Bf(e){return e.replace(/[- _]+/g,"").toLowerCase()}function oC(e,t){const n=t;return Sl(e,`Unclosed character class${(n==null?void 0:n.type)==="Character"&&n.value===93&&n.raw==="]"?' (started with "]")':""}`)}function lC(e){return Sl(e,"Unclosed group")}function Fc(e,t,n=null){function r(l,u){for(let c=0;c<l.length;c++){const d=a(l[c],u,c,l);c=Math.max(-1,c+d)}}function a(l,u=null,c=null,d=null){var S,b;let h=0,p=!1;const m={node:l,parent:u,key:c,container:d,root:e,remove(){Xd(d).splice(Math.max(0,Bo(c)+h),1),h--,p=!0},removeAllNextSiblings(){return Xd(d).splice(Bo(c)+1)},removeAllPrevSiblings(){const v=Bo(c)+h;return h-=v,Xd(d).splice(0,Math.max(0,v))},replaceWith(v,k={}){const T=!!k.traverse;d?d[Math.max(0,Bo(c)+h)]=v:Sl(u,"Can't replace root node")[c]=v,T&&a(v,u,c,d),p=!0},replaceWithMultiple(v,k={}){const T=!!k.traverse;if(Xd(d).splice(Math.max(0,Bo(c)+h),1,...v),h+=v.length-1,T){let N=0;for(let R=0;R<v.length;R++)N+=a(v[R],u,Bo(c)+R+N,d)}p=!0},skip(){p=!0}},{type:g}=l,y=t["*"],w=t[g],C=typeof y=="function"?y:y==null?void 0:y.enter,_=typeof w=="function"?w:w==null?void 0:w.enter;if(C==null||C(m,n),_==null||_(m,n),!p)switch(g){case"AbsenceFunction":case"Alternative":case"CapturingGroup":case"CharacterClass":case"Group":case"LookaroundAssertion":r(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":r(l.body,l),a(l.flags,l,"flags");break;default:throw new Error(`Unexpected node type "${g}"`)}return(S=w==null?void 0:w.exit)==null||S.call(w,m,n),(b=y==null?void 0:y.exit)==null||b.call(y,m,n),h}return a(e),e}function Xd(e){if(!Array.isArray(e))throw new Error("Container expected");return e}function Bo(e){if(typeof e!="number")throw new Error("Numeric key expected");return e}const mH=String.raw`\(\?(?:[:=!>A-Za-z\-]|<[=!]|\(DEFINE\))`;function pH(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function gH(e,t,n,r){return e.slice(0,t)+r+e.slice(t+n.length)}const Xr=Object.freeze({DEFAULT:"DEFAULT",CHAR_CLASS:"CHAR_CLASS"});function Sb(e,t,n,r){const a=new RegExp(String.raw`${t}|(?<$skip>\[\^?|\\?.)`,"gsu"),l=[!1];let u=0,c="";for(const d of e.matchAll(a)){const{0:h,groups:{$skip:p}}=d;if(!p&&(!r||r===Xr.DEFAULT==!u)){n instanceof Function?c+=n(d,{context:u?Xr.CHAR_CLASS:Xr.DEFAULT,negated:l[l.length-1]}):c+=n;continue}h[0]==="["?(u++,l.push(h[1]==="^")):h==="]"&&u&&(u--,l.pop()),c+=h}return c}function oN(e,t,n,r){Sb(e,t,n,r)}function xH(e,t,n=0,r){if(!new RegExp(t,"su").test(e))return null;const a=new RegExp(`${t}|(?<$skip>\\\\?.)`,"gsu");a.lastIndex=n;let l=0,u;for(;u=a.exec(e);){const{0:c,groups:{$skip:d}}=u;if(!d&&(!r||r===Xr.DEFAULT==!l))return u;c==="["?l++:c==="]"&&l&&l--,a.lastIndex==u.index&&a.lastIndex++}return null}function Qd(e,t,n){return!!xH(e,t,0,n)}function yH(e,t){const n=/\\?./gsu;n.lastIndex=t;let r=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)){r=u.index;break}}return e.slice(t,r)}const cC=new RegExp(String.raw`(?<noncapturingStart>${mH})|(?<capturingStart>\((?:\?<[^>]+>)?)|\\?.`,"gsu");function bH(e,t){const n=(t==null?void 0:t.hiddenCaptures)??[];let r=(t==null?void 0:t.captureTransfers)??new Map;if(!/\(\?>/.test(e))return{pattern:e,captureTransfers:r,hiddenCaptures:n};const a="(?>",l="(?:(?=(",u=[0],c=[];let d=0,h=0,p=NaN,m;do{m=!1;let g=0,y=0,w=!1,C;for(cC.lastIndex=Number.isNaN(p)?0:p+l.length;C=cC.exec(e);){const{0:_,index:S,groups:{capturingStart:b,noncapturingStart:v}}=C;if(_==="[")g++;else if(g)_==="]"&&g--;else if(_===a&&!w)p=S,w=!0;else if(w&&v)y++;else if(b)w?y++:(d++,u.push(d+h));else if(_===")"&&w){if(!y){h++;const k=d+h;if(e=`${e.slice(0,p)}${l}${e.slice(p+a.length,S)}))<$$${k}>)${e.slice(S+1)}`,m=!0,c.push(k),pH(n,k),r.size){const T=new Map;r.forEach((N,R)=>{T.set(R>=k?R+1:R,N.map(A=>A>=k?A+1:A))}),r=T}break}y--}}}while(m);return n.push(...c),e=Sb(e,String.raw`\\(?<backrefNum>[1-9]\d*)|<\$\$(?<wrappedBackrefNum>\d+)>`,({0:g,groups:{backrefNum:y,wrappedBackrefNum:w}})=>{if(y){const C=+y;if(C>u.length-1)throw new Error(`Backref "${g}" greater than number of captures`);return`\\${u[C]}`}return`\\${w}`},Xr.DEFAULT),{pattern:e,captureTransfers:r,hiddenCaptures:n}}const lN=String.raw`(?:[?*+]|\{\d+(?:,\d*)?\})`,qg=new RegExp(String.raw`
139
+ \\(?: \d+
140
+ | c[A-Za-z]
141
+ | [gk]<[^>]+>
142
+ | [pPu]\{[^\}]+\}
143
+ | u[A-Fa-f\d]{4}
144
+ | x[A-Fa-f\d]{2}
145
+ )
146
+ | \((?: \? (?: [:=!>]
147
+ | <(?:[=!]|[^>]+>)
148
+ | [A-Za-z\-]+:
149
+ | \(DEFINE\)
150
+ ))?
151
+ | (?<qBase>${lN})(?<qMod>[?+]?)(?<invalidQ>[?*+\{]?)
152
+ | \\?.
153
+ `.replace(/\s+/g,""),"gsu");function vH(e){if(!new RegExp(`${lN}\\+`).test(e))return{pattern:e};const t=[];let n=null,r=null,a="",l=0,u;for(qg.lastIndex=0;u=qg.exec(e);){const{0:c,index:d,groups:{qBase:h,qMod:p,invalidQ:m}}=u;if(c==="[")l||(r=d),l++;else if(c==="]")l?l--:r=null;else if(!l)if(p==="+"&&a&&!a.startsWith("(")){if(m)throw new Error(`Invalid quantifier "${c}"`);let g=-1;if(/^\{\d+\}$/.test(h))e=gH(e,d+h.length,p,"");else{if(a===")"||a==="]"){const y=a===")"?n:r;if(y===null)throw new Error(`Invalid unmatched "${a}"`);e=`${e.slice(0,y)}(?>${e.slice(y,d)}${h})${e.slice(d+c.length)}`}else e=`${e.slice(0,d-a.length)}(?>${a}${h})${e.slice(d+c.length)}`;g+=4}qg.lastIndex+=g}else c[0]==="("?t.push(d):c===")"&&(n=t.length?t.pop():null);a=c}return{pattern:e}}const Kr=String.raw,_H=Kr`\\g<(?<gRNameOrNum>[^>&]+)&R=(?<gRDepth>[^>]+)>`,ay=Kr`\(\?R=(?<rDepth>[^\)]+)\)|${_H}`,$f=Kr`\(\?<(?![=!])(?<captureName>[^>]+)>`,cN=Kr`${$f}|(?<unnamed>\()(?!\?)`,Ca=new RegExp(Kr`${$f}|${ay}|\(\?|\\?.`,"gsu"),Kg="Cannot use multiple overlapping recursions";function SH(e,t){const{hiddenCaptures:n,mode:r}={hiddenCaptures:[],mode:"plugin",...t};let a=(t==null?void 0:t.captureTransfers)??new Map;if(!new RegExp(ay,"su").test(e))return{pattern:e,captureTransfers:a,hiddenCaptures:n};if(r==="plugin"&&Qd(e,Kr`\(\?\(DEFINE\)`,Xr.DEFAULT))throw new Error("DEFINE groups cannot be used with recursion");const l=[],u=Qd(e,Kr`\\[1-9]`,Xr.DEFAULT),c=new Map,d=[];let h=!1,p=0,m=0,g;for(Ca.lastIndex=0;g=Ca.exec(e);){const{0:y,groups:{captureName:w,rDepth:C,gRNameOrNum:_,gRDepth:S}}=g;if(y==="[")p++;else if(p)y==="]"&&p--;else if(C){if(uC(C),h)throw new Error(Kg);if(u)throw new Error(`${r==="external"?"Backrefs":"Numbered backrefs"} cannot be used with global recursion`);const b=e.slice(0,g.index),v=e.slice(Ca.lastIndex);if(Qd(v,ay,Xr.DEFAULT))throw new Error(Kg);const k=+C-1;e=dC(b,v,k,!1,n,l,m),a=fC(a,b,k,l.length,0,m);break}else if(_){uC(S);let b=!1;for(const z of d)if(z.name===_||z.num===+_){if(b=!0,z.hasRecursedWithin)throw new Error(Kg);break}if(!b)throw new Error(Kr`Recursive \g cannot be used outside the referenced group "${r==="external"?_:Kr`\g<${_}&R=${S}>`}"`);const v=c.get(_),k=yH(e,v);if(u&&Qd(k,Kr`${$f}|\((?!\?)`,Xr.DEFAULT))throw new Error(`${r==="external"?"Backrefs":"Numbered backrefs"} cannot be used with recursion of capturing groups`);const T=e.slice(v,g.index),N=k.slice(T.length+y.length),R=l.length,A=+S-1,O=dC(T,N,A,!0,n,l,m);a=fC(a,T,A,l.length-R,R,m);const P=e.slice(0,v),V=e.slice(v+k.length);e=`${P}${O}${V}`,Ca.lastIndex+=O.length-y.length-T.length-N.length,d.forEach(z=>z.hasRecursedWithin=!0),h=!0}else if(w)m++,c.set(String(m),Ca.lastIndex),c.set(w,Ca.lastIndex),d.push({num:m,name:w});else if(y[0]==="("){const b=y==="(";b&&(m++,c.set(String(m),Ca.lastIndex)),d.push(b?{num:m}:{})}else y===")"&&d.pop()}return n.push(...l),{pattern:e,captureTransfers:a,hiddenCaptures:n}}function uC(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 dC(e,t,n,r,a,l,u){const c=new Set;r&&oN(e+t,$f,({groups:{captureName:h}})=>{c.add(h)},Xr.DEFAULT);const d=[n,r?c:null,a,l,u];return`${e}${hC(`(?:${e}`,"forward",...d)}(?:)${hC(`${t})`,"backward",...d)}${t}`}function hC(e,t,n,r,a,l,u){const d=p=>t==="forward"?p+2:n-p+2-1;let h="";for(let p=0;p<n;p++){const m=d(p);h+=Sb(e,Kr`${cN}|\\k<(?<backref>[^>]+)>`,({0:g,groups:{captureName:y,unnamed:w,backref:C}})=>{if(C&&r&&!r.has(C))return g;const _=`_$${m}`;if(w||y){const S=u+l.length+1;return l.push(S),wH(a,S),w?g:`(?<${y}${_}>`}return Kr`\k<${C}${_}>`},Xr.DEFAULT)}return h}function wH(e,t){for(let n=0;n<e.length;n++)e[n]>=t&&e[n]++}function fC(e,t,n,r,a,l){if(e.size&&r){let u=0;oN(t,cN,()=>u++,Xr.DEFAULT);const c=l-u+a,d=new Map;return e.forEach((h,p)=>{const m=(r-u*n)/n,g=u*n,y=p>c+u?p+r:p,w=[];for(const C of h)if(C<=c)w.push(C);else if(C>c+u+m)w.push(C+r);else if(C<=c+u)for(let _=0;_<=n;_++)w.push(C+u*_);else for(let _=0;_<=n;_++)w.push(C+g+m*_);d.set(y,w)}),d}return e}var On=String.fromCodePoint,yt=String.raw,ds={},zf=globalThis.RegExp;ds.flagGroups=(()=>{try{new zf("(?i:)")}catch{return!1}return!0})();ds.unicodeSets=(()=>{try{new zf("[[]]","v")}catch{return!1}return!0})();ds.bugFlagVLiteralHyphenIsRange=ds.unicodeSets?(()=>{try{new zf(yt`[\d\-a]`,"v")}catch{return!0}return!1})():!1;ds.bugNestedClassIgnoresNegation=ds.unicodeSets&&new zf("[[^a]]","v").test("a");function Gh(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 au(e,t,n){return e.has(t)||e.set(t,n),e.get(t)}function oy(e,t){return mC[e]>=mC[t]}function CH(e,t){if(e==null)throw new Error(t??"Value expected");return e}var mC={ES2025:2025,ES2024:2024,ES2018:2018},kH={auto:"auto",ES2025:"ES2025",ES2024:"ES2024",ES2018:"ES2018"};function uN(e={}){if({}.toString.call(e)!=="[object Object]")throw new Error("Unexpected options");if(e.target!==void 0&&!kH[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=ds.flagGroups?"ES2025":ds.unicodeSets?"ES2024":"ES2018"),t}var EH="[ -\r ]",jH=new Set([On(304),On(305)]),Qs=yt`[\p{L}\p{M}\p{N}\p{Pc}]`;function dN(e){if(jH.has(e))return[e];const t=new Set,n=e.toLowerCase(),r=n.toUpperCase(),a=AH.get(n),l=NH.get(n),u=TH.get(n);return[...r].length===1&&t.add(r),u&&t.add(u),a&&t.add(a),t.add(n),l&&t.add(l),[...t]}var wb=new Map(`C Other
154
+ Cc Control cntrl
155
+ Cf Format
156
+ Cn Unassigned
157
+ Co Private_Use
158
+ Cs Surrogate
159
+ L Letter
160
+ LC Cased_Letter
161
+ Ll Lowercase_Letter
162
+ Lm Modifier_Letter
163
+ Lo Other_Letter
164
+ Lt Titlecase_Letter
165
+ Lu Uppercase_Letter
166
+ M Mark Combining_Mark
167
+ Mc Spacing_Mark
168
+ Me Enclosing_Mark
169
+ Mn Nonspacing_Mark
170
+ N Number
171
+ Nd Decimal_Number digit
172
+ Nl Letter_Number
173
+ No Other_Number
174
+ P Punctuation punct
175
+ Pc Connector_Punctuation
176
+ Pd Dash_Punctuation
177
+ Pe Close_Punctuation
178
+ Pf Final_Punctuation
179
+ Pi Initial_Punctuation
180
+ Po Other_Punctuation
181
+ Ps Open_Punctuation
182
+ S Symbol
183
+ Sc Currency_Symbol
184
+ Sk Modifier_Symbol
185
+ Sm Math_Symbol
186
+ So Other_Symbol
187
+ Z Separator
188
+ Zl Line_Separator
189
+ Zp Paragraph_Separator
190
+ Zs Space_Separator
191
+ ASCII
192
+ ASCII_Hex_Digit AHex
193
+ Alphabetic Alpha
194
+ Any
195
+ Assigned
196
+ Bidi_Control Bidi_C
197
+ Bidi_Mirrored Bidi_M
198
+ Case_Ignorable CI
199
+ Cased
200
+ Changes_When_Casefolded CWCF
201
+ Changes_When_Casemapped CWCM
202
+ Changes_When_Lowercased CWL
203
+ Changes_When_NFKC_Casefolded CWKCF
204
+ Changes_When_Titlecased CWT
205
+ Changes_When_Uppercased CWU
206
+ Dash
207
+ Default_Ignorable_Code_Point DI
208
+ Deprecated Dep
209
+ Diacritic Dia
210
+ Emoji
211
+ Emoji_Component EComp
212
+ Emoji_Modifier EMod
213
+ Emoji_Modifier_Base EBase
214
+ Emoji_Presentation EPres
215
+ Extended_Pictographic ExtPict
216
+ Extender Ext
217
+ Grapheme_Base Gr_Base
218
+ Grapheme_Extend Gr_Ext
219
+ Hex_Digit Hex
220
+ IDS_Binary_Operator IDSB
221
+ IDS_Trinary_Operator IDST
222
+ ID_Continue IDC
223
+ ID_Start IDS
224
+ Ideographic Ideo
225
+ Join_Control Join_C
226
+ Logical_Order_Exception LOE
227
+ Lowercase Lower
228
+ Math
229
+ Noncharacter_Code_Point NChar
230
+ Pattern_Syntax Pat_Syn
231
+ Pattern_White_Space Pat_WS
232
+ Quotation_Mark QMark
233
+ Radical
234
+ Regional_Indicator RI
235
+ Sentence_Terminal STerm
236
+ Soft_Dotted SD
237
+ Terminal_Punctuation Term
238
+ Unified_Ideograph UIdeo
239
+ Uppercase Upper
240
+ Variation_Selector VS
241
+ White_Space space
242
+ XID_Continue XIDC
243
+ XID_Start XIDS`.split(/\s/).map(e=>[Bf(e),e])),NH=new Map([["s",On(383)],[On(383),"s"]]),TH=new Map([[On(223),On(7838)],[On(107),On(8490)],[On(229),On(8491)],[On(969),On(8486)]]),AH=new Map([Pi(453),Pi(456),Pi(459),Pi(498),...Yg(8072,8079),...Yg(8088,8095),...Yg(8104,8111),Pi(8124),Pi(8140),Pi(8188)]),LH=new Map([["alnum",yt`[\p{Alpha}\p{Nd}]`],["alpha",yt`\p{Alpha}`],["ascii",yt`\p{ASCII}`],["blank",yt`[\p{Zs}\t]`],["cntrl",yt`\p{Cc}`],["digit",yt`\p{Nd}`],["graph",yt`[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]`],["lower",yt`\p{Lower}`],["print",yt`[[\P{space}&&\P{Cc}&&\P{Cn}&&\P{Cs}]\p{Zs}]`],["punct",yt`[\p{P}\p{S}]`],["space",yt`\p{space}`],["upper",yt`\p{Upper}`],["word",yt`[\p{Alpha}\p{M}\p{Nd}\p{Pc}]`],["xdigit",yt`\p{AHex}`]]);function RH(e,t){const n=[];for(let r=e;r<=t;r++)n.push(r);return n}function Pi(e){const t=On(e);return[t.toLowerCase(),t]}function Yg(e,t){return RH(e,t).map(n=>Pi(n))}var hN=new Set(["Lower","Lowercase","Upper","Uppercase","Ll","Lowercase_Letter","Lt","Titlecase_Letter","Lu","Uppercase_Letter"]);function DH(e,t){const n={accuracy:"default",asciiWordBoundaries:!1,avoidSubclass:!1,bestEffortTarget:"ES2025",...t};fN(e);const r={accuracy:n.accuracy,asciiWordBoundaries:n.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,flagDirectivesByAlt:new Map,jsGroupNameMap:new Map,minTargetEs2024:oy(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};Fc(e,OH,r);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:r.subroutineRefMap};Fc(e,IH,l);const u={groupsByName:l.groupsByName,highestOrphanBackref:0,numCapturesToLeft:0,reffedNodesByReferencer:l.reffedNodesByReferencer};return Fc(e,MH,u),e._originMap=l.groupOriginByCopy,e._strategy=r.strategy,e}var OH={AbsenceFunction({node:e,parent:t,replaceWith:n}){const{body:r,kind:a}=e;if(a==="repeater"){const l=as();l.body[0].body.push(Ra({negate:!0,body:r}),qo("Any"));const u=as();u.body[0].body.push(sN("greedy",0,1/0,l)),n(yn(u,t),{traverse:!0})}else throw new Error('Unsupported absence function "(?~|"')},Alternative:{enter({node:e,parent:t,key:n},{flagDirectivesByAlt:r}){const a=e.body.filter(l=>l.kind==="flags");for(let l=n+1;l<t.body.length;l++){const u=t.body[l];au(r,u,[]).push(...a)}},exit({node:e},{flagDirectivesByAlt:t}){var n;if((n=t.get(e))!=null&&n.length){const r=pN(t.get(e));if(r){const a=as({flags:r});a.body[0].body=e.body,e.body=[yn(a,e)]}}}},Assertion({node:e,parent:t,key:n,container:r,root:a,remove:l,replaceWith:u},c){const{kind:d,negate:h}=e,{asciiWordBoundaries:p,avoidSubclass:m,supportedGNodes:g,wordIsAscii:y}=c;if(d==="text_segment_boundary")throw new Error(`Unsupported text segment boundary "\\${h?"Y":"y"}"`);if(d==="line_end")u(yn(Ra({body:[Ka({body:[ry("string_end")]}),Ka({body:[Pf(10)]})]}),t));else if(d==="line_start")u(yn(Js(yt`(?<=\A|\n(?!\z))`,{skipLookbehindValidation:!0}),t));else if(d==="search_start")if(g.has(e))a.flags.sticky=!0,l();else{const w=r[n-1];if(w&&FH(w))u(yn(Ra({negate:!0}),t));else{if(m)throw new Error(yt`Uses "\G" in a way that requires a subclass`);u(Bi(ry("string_start"),t)),c.strategy="clip_search"}}else if(!(d==="string_end"||d==="string_start"))if(d==="string_end_newline")u(yn(Js(yt`(?=\n?\z)`),t));else if(d==="word_boundary"){if(!y&&!p){const w=`(?:(?<=${Qs})(?!${Qs})|(?<!${Qs})(?=${Qs}))`,C=`(?:(?<=${Qs})(?=${Qs})|(?<!${Qs})(?!${Qs}))`;u(yn(Js(h?C:w),t))}}else throw new Error(`Unexpected assertion kind "${d}"`)},Backreference({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n=="string"&&!Qg(n)&&(n=Xg(n,t),e.ref=n)},CapturingGroup({node:e},{jsGroupNameMap:t,subroutineRefMap:n}){let{name:r}=e;r&&!Qg(r)&&(r=Xg(r,t),e.name=r),n.set(e.number,e),r&&n.set(r,e)},CharacterClassRange({node:e,parent:t,replaceWith:n}){if(t.kind==="intersection"){const r=_h({body:[e]});n(yn(r,t),{traverse:!0})}},CharacterSet({node:e,parent:t,replaceWith:n},{accuracy:r,minTargetEs2024:a,digitIsAscii:l,spaceIsAscii:u,wordIsAscii:c}){const{kind:d,negate:h,value:p}=e;if(l&&(d==="digit"||p==="digit")){n(Bi(iy("digit",{negate:h}),t));return}if(u&&(d==="space"||p==="space")){n(yn(Jg(Js(EH),h),t));return}if(c&&(d==="word"||p==="word")){n(Bi(iy("word",{negate:h}),t));return}if(d==="any")n(Bi(qo("Any"),t));else if(d==="digit")n(Bi(qo("Nd",{negate:h}),t));else if(d!=="dot")if(d==="text_segment"){if(r==="strict")throw new Error(yt`Use of "\X" requires non-strict accuracy`);const m="\\p{Emoji}(?:\\p{EMod}|\\uFE0F\\u20E3?|[\\x{E0020}-\\x{E007E}]+\\x{E007F})?",g=yt`\p{RI}{2}|${m}(?:\u200D${m})*`;n(yn(Js(yt`(?>\r\n|${a?yt`\p{RGI_Emoji}`:g}|\P{M}\p{M}*)`,{skipPropertyNameValidation:!0}),t))}else if(d==="hex")n(Bi(qo("AHex",{negate:h}),t));else if(d==="newline")n(yn(Js(h?`[^
244
+ ]`:`(?>\r
245
+ ?|[
246
+ \v\f…\u2028\u2029])`),t));else if(d==="posix")if(!a&&(p==="graph"||p==="print")){if(r==="strict")throw new Error(`POSIX class "${p}" requires min target ES2024 or non-strict accuracy`);let m={graph:"!-~",print:" -~"}[p];h&&(m=`\0-${On(m.codePointAt(0)-1)}${On(m.codePointAt(2)+1)}-􏿿`),n(yn(Js(`[${m}]`),t))}else n(yn(Jg(Js(LH.get(p)),h),t));else if(d==="property")wb.has(Bf(p))||(e.key="sc");else if(d==="space")n(Bi(qo("space",{negate:h}),t));else if(d==="word")n(yn(Jg(Js(Qs),h),t));else throw new Error(`Unexpected character set kind "${d}"`)},Directive({node:e,parent:t,root:n,remove:r,replaceWith:a,removeAllPrevSiblings:l,removeAllNextSiblings:u}){const{kind:c,flags:d}=e;if(c==="flags")if(!d.enable&&!d.disable)r();else{const h=as({flags:d});h.body[0].body=u(),a(yn(h,t),{traverse:!0})}else if(c==="keep"){const h=n.body[0],m=n.body.length===1&&tN(h,{type:"Group"})&&h.body[0].body.length===1?h.body[0]:n;if(t.parent!==m||m.body.length>1)throw new Error(yt`Uses "\K" in a way that's unsupported`);const g=Ra({behind:!0});g.body[0].body=l(),a(yn(g,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:r}=e;if(r==="fail")n(yn(Ra({negate:!0}),t));else throw new Error(`Unsupported named callout "(*${r.toUpperCase()}"`)},Quantifier({node:e}){if(e.body.type==="Quantifier"){const t=as();t.body[0].body.push(e.body),e.body=yn(t,e)}},Regex:{enter({node:e},{supportedGNodes:t}){const n=[];let r=!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=xN(l.body);u?(r=!0,Array.isArray(u)?n.push(...u):n.push(u)):a=!0}r&&!a&&n.forEach(l=>t.add(l))},exit(e,{accuracy:t,passedLookbehind:n,strategy:r}){if(t==="strict"&&n&&r)throw new Error(yt`Uses "\G" in a way that requires non-strict accuracy`)}},Subroutine({node:e},{jsGroupNameMap:t}){let{ref:n}=e;typeof n=="string"&&!Qg(n)&&(n=Xg(n,t),e.ref=n)}},IH={Backreference({node:e},{multiplexCapturesToLeftByRef:t,reffedNodesByReferencer:n}){const{orphan:r,ref:a}=e;r||n.set(e,[...t.get(a).map(({node:l})=>l)])},CapturingGroup:{enter({node:e,parent:t,replaceWith:n,skip:r},{groupOriginByCopy:a,groupsByName:l,multiplexCapturesToLeftByRef:u,openRefs:c,reffedNodesByReferencer:d}){const h=a.get(e);if(h&&c.has(e.number)){const m=Bi(pC(e.number),t);d.set(m,c.get(e.number)),n(m);return}c.set(e.number,e),u.set(e.number,[]),e.name&&au(u,e.name,[]);const p=u.get(e.name??e.number);for(let m=0;m<p.length;m++){const g=p[m];if(h===g.node||h&&h===g.origin||e===g.origin){p.splice(m,1);break}}if(u.get(e.number).push({node:e,origin:h}),e.name&&u.get(e.name).push({node:e,origin:h}),e.name){const m=au(l,e.name,new Map);let g=!1;if(h)g=!0;else for(const y of m.values())if(!y.hasDuplicateNameToRemove){g=!0;break}l.get(e.name).set(e,{node:e,hasDuplicateNameToRemove:g})}},exit({node:e},{openRefs:t}){t.get(e.number)===e&&t.delete(e.number)}},Group:{enter({node:e},t){t.prevFlags=t.currentFlags,e.flags&&(t.currentFlags=Gh(t.currentFlags,e.flags))},exit(e,t){t.currentFlags=t.prevFlags}},Subroutine({node:e,parent:t,replaceWith:n},r){const{isRecursive:a,ref:l}=e;if(a){let p=t;for(;(p=p.parent)&&!(p.type==="CapturingGroup"&&(p.name===l||p.number===l)););r.reffedNodesByReferencer.set(e,p);return}const u=r.subroutineRefMap.get(l),c=l===0,d=c?pC(0):mN(u,r.groupOriginByCopy,null);let h=d;if(!c){const p=pN($H(u,g=>g.type==="Group"&&!!g.flags)),m=p?Gh(r.globalFlags,p):r.globalFlags;PH(m,r.currentFlags)||(h=as({flags:zH(m)}),h.body[0].body.push(d))}n(yn(h,t),{traverse:!c})}},MH={Backreference({node:e,parent:t,replaceWith:n},r){if(e.orphan){r.highestOrphanBackref=Math.max(r.highestOrphanBackref,e.ref);return}const l=r.reffedNodesByReferencer.get(e).filter(u=>BH(u,e));if(!l.length)n(yn(Ra({negate:!0}),t));else if(l.length>1){const u=as({atomic:!0,body:l.reverse().map(c=>Ka({body:[sy(c.number)]}))});n(yn(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 r=0;r<n;r++){const a=rN();e.body.at(-1).body.push(a)}}},Subroutine({node:e},t){!e.isRecursive||e.ref===0||(e.ref=t.reffedNodesByReferencer.get(e).number)}};function fN(e){Fc(e,{"*"({node:t,parent:n}){t.parent=n}})}function PH(e,t){return e.dotAll===t.dotAll&&e.ignoreCase===t.ignoreCase}function BH(e,t){let n=t;do{if(n.type==="Regex")return!1;if(n.type==="Alternative")continue;if(n===e)return!1;const r=gN(n.parent);for(const a of r){if(a===n)break;if(a===e||yN(a,e))return!0}}while(n=n.parent);throw new Error("Unexpected path")}function mN(e,t,n,r){const a=Array.isArray(e)?[]:{};for(const[l,u]of Object.entries(e))l==="parent"?a.parent=Array.isArray(n)?r:n:u&&typeof u=="object"?a[l]=mN(u,t,a,n):(l==="type"&&u==="CapturingGroup"&&t.set(a,t.get(e)??e),a[l]=u);return a}function pC(e){const t=iN(e);return t.isRecursive=!0,t}function $H(e,t){const n=[];for(;e=e.parent;)(!t||t(e))&&n.push(e);return n}function Xg(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 pN(e){const t=["dotAll","ignoreCase"],n={enable:{},disable:{}};return e.forEach(({flags:r})=>{t.forEach(a=>{var l,u;(l=r.enable)!=null&&l[a]&&(delete n.disable[a],n.enable[a]=!0),(u=r.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 zH({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 gN(e){if(!e)throw new Error("Node expected");const{body:t}=e;return Array.isArray(t)?t:t?[t]:null}function xN(e){const t=e.find(n=>n.kind==="search_start"||UH(n,{negate:!1})||!HH(n));if(!t)return null;if(t.kind==="search_start")return t;if(t.type==="LookaroundAssertion")return t.body[0].body[0];if(t.type==="CapturingGroup"||t.type==="Group"){const n=[];for(const r of t.body){const a=xN(r.body);if(!a)return null;Array.isArray(a)?n.push(...a):n.push(a)}return n}return null}function yN(e,t){const n=gN(e)??[];for(const r of n)if(r===t||yN(r,t))return!0;return!1}function HH({type:e}){return e==="Assertion"||e==="Directive"||e==="LookaroundAssertion"}function FH(e){const t=["Character","CharacterClass","CharacterSet"];return t.includes(e.type)||e.type==="Quantifier"&&e.min&&t.includes(e.body.type)}function UH(e,t){const n={negate:null,...t};return e.type==="LookaroundAssertion"&&(n.negate===null||e.negate===n.negate)&&e.body.length===1&&tN(e.body[0],{type:"Assertion",kind:"search_start"})}function Qg(e){return/^[$_\p{IDS}][$\u200C\u200D\p{IDC}]*$/u.test(e)}function Js(e,t){const r=nN(e,{...t,unicodePropertyMap:wb}).body;return r.length>1||r[0].body.length>1?as({body:r}):r[0].body[0]}function Jg(e,t){return e.negate=t,e}function Bi(e,t){return e.parent=t,e}function yn(e,t){return fN(e),e.parent=t,e}function VH(e,t){const n=uN(t),r=oy(n.target,"ES2024"),a=oy(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];Fc(e,WH,{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 h=e;const p={accuracy:n.accuracy,appliedGlobalFlags:d,captureMap:new Map,currentFlags:{dotAll:e.flags.dotAll,ignoreCase:e.flags.ignoreCase},inCharClass:!1,lastNode:h,originMap:e._originMap,recursionLimit:l,useAppliedIgnoreCase:!!(!a&&u&&c),useFlagMods:a,useFlagV:r,verbose:n.verbose};function m(y){return p.lastNode=h,h=y,CH(GH[y.type],`Unexpected node type "${y.type}"`)(y,p,m)}const g={pattern:e.body.map(m).join("|"),flags:m(e.flags),options:{...e.options}};return r||(delete g.options.force.v,g.options.disable.v=!0,g.options.unicodeSetsPlugin=null),g._captureTransfers=new Map,g._hiddenCaptures=[],p.captureMap.forEach((y,w)=>{y.hidden&&g._hiddenCaptures.push(w),y.transferTo&&au(g._captureTransfers,y.transferTo,[]).push(w)}),g}var WH={"*":{enter({node:e},t){if(xC(e)){const n=t.getCurrentModI();t.pushModI(e.flags?Gh({ignoreCase:n},e.flags).ignoreCase:n)}},exit({node:e},t){xC(e)&&t.popModI()}},Backreference(e,t){t.setHasCasedChar()},Character({node:e},t){Cb(On(e.value))&&t.setHasCasedChar()},CharacterClassRange({node:e,skip:t},n){t(),bN(e,{firstOnly:!0}).length&&n.setHasCasedChar()},CharacterSet({node:e},t){e.kind==="property"&&hN.has(e.value)&&t.setHasCasedChar()}},GH={Alternative({body:e},t,n){return e.map(n).join("")},Assertion({kind:e,negate:t}){if(e==="string_end")return"$";if(e==="string_start")return"^";if(e==="word_boundary")return t?yt`\B`:yt`\b`;throw new Error(`Unexpected assertion kind "${e}"`)},Backreference({ref:e},t){if(typeof e!="number")throw new Error("Unexpected named backref in transformed AST");if(!t.useFlagMods&&t.accuracy==="strict"&&t.currentFlags.ignoreCase&&!t.captureMap.get(e).ignoreCase)throw new Error("Use of case-insensitive backref to case-sensitive group requires target ES2025 or non-strict accuracy");return"\\"+e},CapturingGroup(e,t,n){const{body:r,name:a,number: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}>`:""}${r.map(n).join("|")})`},Character({value:e},t){const n=On(e),r=$o(e,{escDigit:t.lastNode.type==="Backreference",inCharClass:t.inCharClass,useFlagV:t.useFlagV});if(r!==n)return r;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase&&Cb(n)){const a=dN(n);return t.inCharClass?a.join(""):a.length>1?`[${a.join("")}]`:a[0]}return n},CharacterClass(e,t,n){const{kind:r,negate:a,parent:l}=e;let{body:u}=e;if(r==="intersection"&&!t.useFlagV)throw new Error("Use of character class intersection requires min target ES2024");ds.bugFlagVLiteralHyphenIsRange&&t.useFlagV&&u.some(yC)&&(u=[Pf(45),...u.filter(h=>!yC(h))]);const c=()=>`[${a?"^":""}${u.map(n).join(r==="intersection"?"&&":"")}]`;if(!t.inCharClass){if((!t.useFlagV||ds.bugNestedClassIgnoresNegation)&&!a){const p=u.filter(m=>m.type==="CharacterClass"&&m.kind==="union"&&m.negate);if(p.length){const m=as(),g=m.body[0];return m.parent=l,g.parent=m,u=u.filter(y=>!p.includes(y)),e.body=u,u.length?(e.parent=g,g.body.push(e)):m.body.pop(),p.forEach(y=>{const w=Ka({body:[y]});y.parent=w,w.parent=m,m.body.push(w)}),n(m)}}t.inCharClass=!0;const h=c();return t.inCharClass=!1,h}const d=u[0];if(r==="union"&&!a&&d&&((!t.useFlagV||!t.verbose)&&l.kind==="union"&&!(ds.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,r=e.max.value,a={escDigit:!1,inCharClass:!0,useFlagV:t.useFlagV},l=$o(n,a),u=$o(r,a),c=new Set;if(t.useAppliedIgnoreCase&&t.currentFlags.ignoreCase){const d=bN(e);QH(d).forEach(p=>{c.add(Array.isArray(p)?`${$o(p[0],a)}-${$o(p[1],a)}`:$o(p,a))})}return`${l}-${u}${[...c].join("")}`},CharacterSet({kind:e,negate:t,value:n,key:r},a){if(e==="dot")return a.currentFlags.dotAll?a.appliedGlobalFlags.dotAll||a.useFlagMods?".":"[^]":yt`[^\n]`;if(e==="digit")return t?yt`\D`:yt`\d`;if(e==="property"){if(a.useAppliedIgnoreCase&&a.currentFlags.ignoreCase&&hN.has(n))throw new Error(`Unicode property "${n}" can't be case-insensitive when other chars have specific case`);return`${t?yt`\P`:yt`\p`}{${r?`${r}=`:""}${n}}`}if(e==="word")return t?yt`\W`:yt`\w`;throw new Error(`Unexpected character set kind "${e}"`)},Flags(e,t){return(t.appliedGlobalFlags.ignoreCase?"i":"")+(e.dotAll?"s":"")+(e.sticky?"y":"")},Group({atomic:e,body:t,flags:n,parent:r},a,l){const u=a.currentFlags;n&&(a.currentFlags=Gh(u,n));const c=t.map(l).join("|"),d=!a.verbose&&t.length===1&&r.type!=="Quantifier"&&!e&&(!a.useFlagMods||!n)?c:`(?${JH(e,n,a.useFlagMods)}${c})`;return a.currentFlags=u,d},LookaroundAssertion({body:e,kind:t,negate:n},r,a){return`(?${`${t==="lookahead"?"":"<"}${n?"!":"="}`}${e.map(a).join("|")})`},Quantifier(e,t,n){return n(e.body)+ZH(e)},Subroutine({isRecursive:e,ref:t},n){if(!e)throw new Error("Unexpected non-recursive subroutine in transformed AST");const r=n.recursionLimit;return t===0?`(?R=${r})`:yt`\g<${t}&R=${r}>`}},qH=new Set(["$","(",")","*","+",".","?","[","\\","]","^","{","|","}"]),KH=new Set(["-","\\","]","^","["]),YH=new Set(["(",")","-","/","[","\\","]","^","{","|","}","!","#","$","%","&","*","+",",",".",":",";","<","=",">","?","@","`","~"]),gC=new Map([[9,yt`\t`],[10,yt`\n`],[11,yt`\v`],[12,yt`\f`],[13,yt`\r`],[8232,yt`\u2028`],[8233,yt`\u2029`],[65279,yt`\uFEFF`]]),XH=new RegExp("^\\p{Cased}$","u");function Cb(e){return XH.test(e)}function bN(e,t){const n=!!(t!=null&&t.firstOnly),r=e.min.value,a=e.max.value,l=[];if(r<65&&(a===65535||a>=131071)||r===65536&&a>=131071)return l;for(let u=r;u<=a;u++){const c=On(u);if(!Cb(c))continue;const d=dN(c).filter(h=>{const p=h.codePointAt(0);return p<r||p>a});if(d.length&&(l.push(...d),n))break}return l}function $o(e,{escDigit:t,inCharClass:n,useFlagV:r}){if(gC.has(e))return gC.get(e);if(e<32||e>126&&e<160||e>262143||t&&eF(e))return e>255?`\\u{${e.toString(16).toUpperCase()}}`:`\\x${e.toString(16).toUpperCase().padStart(2,"0")}`;const a=n?r?YH:KH:qH,l=On(e);return(a.has(l)?"\\":"")+l}function QH(e){const t=e.map(a=>a.codePointAt(0)).sort((a,l)=>a-l),n=[];let r=null;for(let a=0;a<t.length;a++)t[a+1]===t[a]+1?r??(r=t[a]):r===null?n.push(t[a]):(n.push([r,t[a]]),r=null);return n}function JH(e,t,n){if(e)return">";let r="";if(t&&n){const{enable:a,disable:l}=t;r=(a!=null&&a.ignoreCase?"i":"")+(a!=null&&a.dotAll?"s":"")+(l?"-":"")+(l!=null&&l.ignoreCase?"i":"")+(l!=null&&l.dotAll?"s":"")}return`${r}:`}function ZH({kind:e,max:t,min:n}){let r;return!n&&t===1?r="?":!n&&t===1/0?r="*":n===1&&t===1/0?r="+":n===t?r=`{${n}}`:r=`{${n},${t===1/0?"":t}}`,r+{greedy:"",lazy:"?",possessive:"+"}[e]}function xC({type:e}){return e==="CapturingGroup"||e==="Group"||e==="LookaroundAssertion"}function eF(e){return e>47&&e<58}function yC({type:e,value:t}){return e==="Character"&&t===45}var $i,ri,Pa,zi,Ba,lu,ly,Ki,tF=(Ki=class extends RegExp{constructor(n,r,a){var t=(...lG)=>(super(...lG),ba(this,lu),ba(this,$i,new Map),ba(this,ri,null),ba(this,Pa),ba(this,zi,null),ba(this,Ba,null),Ae(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,r),ns(this,Pa,u.source),u instanceof Ki&&(ns(this,$i,nr(u,$i)),ns(this,zi,nr(u,zi)),ns(this,Ba,nr(u,Ba)),this.rawOptions=u.rawOptions)}else{const u={hiddenCaptures:[],strategy:null,transfers:[],...a};t(l?"":n,r),ns(this,Pa,n),ns(this,$i,rF(u.hiddenCaptures,u.transfers)),ns(this,Ba,u.strategy),this.rawOptions=a??{}}l||ns(this,ri,this)}get source(){return nr(this,Pa)||"(?:)"}exec(n){if(!nr(this,ri)){const{lazyCompile:l,...u}=this.rawOptions;ns(this,ri,new Ki(nr(this,Pa),this.flags,u))}const r=this.global||this.sticky,a=this.lastIndex;if(nr(this,Ba)==="clip_search"&&r&&a){this.lastIndex=0;const l=Zp(this,lu,ly).call(this,n.slice(a));return l&&(nF(l,a,n,this.hasIndices),this.lastIndex+=a),l}return Zp(this,lu,ly).call(this,n)}},$i=new WeakMap,ri=new WeakMap,Pa=new WeakMap,zi=new WeakMap,Ba=new WeakMap,lu=new WeakSet,ly=function(n){nr(this,ri).lastIndex=this.lastIndex;const r=AS(Ki.prototype,this,"exec").call(nr(this,ri),n);if(this.lastIndex=nr(this,ri).lastIndex,!r||!nr(this,$i).size)return r;const a=[...r];r.length=1;let l;this.hasIndices&&(l=[...r.indices],r.indices.length=1);const u=[0];for(let c=1;c<a.length;c++){const{hidden:d,transferTo:h}=nr(this,$i).get(c)??{};if(d?u.push(null):(u.push(r.length),r.push(a[c]),this.hasIndices&&r.indices.push(l[c])),h&&a[c]!==void 0){const p=u[h];if(!p)throw new Error(`Invalid capture transfer to "${p}"`);if(r[p]=a[c],this.hasIndices&&(r.indices[p]=l[c]),r.groups){nr(this,zi)||ns(this,zi,sF(this.source));const m=nr(this,zi).get(h);m&&(r.groups[m]=a[c],this.hasIndices&&(r.indices.groups[m]=l[c]))}}}return r},Ki);function nF(e,t,n,r){if(e.index+=t,e.input=n,r){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 rF(e,t){const n=new Map;for(const r of e)n.set(r,{hidden:!0});for(const[r,a]of t)for(const l of a)au(n,l,{}).transferTo=r;return n}function sF(e){const t=/(?<capture>\((?:\?<(?![=!])(?<name>[^>]+)>|(?!\?)))|\\?./gsu,n=new Map;let r=0,a=0,l;for(;l=t.exec(e);){const{0:u,groups:{capture:c,name:d}}=l;u==="["?r++:r?u==="]"&&r--:c&&(a++,d&&n.set(a,d))}return n}function iF(e,t){const n=aF(e,t);return n.options?new tF(n.pattern,n.flags,n.options):new RegExp(n.pattern,n.flags)}function aF(e,t){const n=uN(t),r=nN(e,{flags:n.flags,normalizeUnknownPropertyNames:!0,rules:{captureGroup:n.rules.captureGroup,singleline:n.rules.singleline},skipBackrefValidation:n.rules.allowOrphanBackrefs,unicodePropertyMap:wb}),a=DH(r,{accuracy:n.accuracy,asciiWordBoundaries:n.rules.asciiWordBoundaries,avoidSubclass:n.avoidSubclass,bestEffortTarget:n.target}),l=VH(a,n),u=SH(l.pattern,{captureTransfers:l._captureTransfers,hiddenCaptures:l._hiddenCaptures,mode:"external"}),c=vH(u.pattern),d=bH(c.pattern,{captureTransfers:u.captureTransfers,hiddenCaptures:u.hiddenCaptures}),h={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),g=a._strategy,y=h.pattern.length>=n.lazyCompileLength;(p.length||m.length||g||y)&&(h.options={...p.length&&{hiddenCaptures:p},...m.length&&{transfers:m},...g&&{strategy:g},...y&&{lazyCompile:y}})}return h}function vN(e,t){return iF(e,{global:!0,hasIndices:!0,lazyCompileLength:3e3,rules:{allowOrphanBackrefs:!0,asciiWordBoundaries:!0,captureGroup:!0,recursionLimit:5,singleline:!0},...t})}function oF(e={}){const t={target:"auto",cache:new Map,...e};return t.regexConstructor||(t.regexConstructor=n=>vN(n,{target:t.target})),{createScanner(n){return new wz(n,t)},createString(n){return{content:n}}}}Qj(ob({bundledLanguages:()=>Nf,bundledLanguagesAlias:()=>cb,bundledLanguagesBase:()=>lb,bundledLanguagesInfo:()=>jf,bundledThemes:()=>db,bundledThemesInfo:()=>ub,codeToHast:()=>V2,codeToHtml:()=>U2,codeToTokens:()=>W2,codeToTokensBase:()=>G2,codeToTokensWithThemes:()=>q2,createHighlighter:()=>Mf,createJavaScriptRegexEngine:()=>oF,createOnigurumaEngine:()=>e2,defaultJavaScriptRegexConstructor:()=>vN,getLastGrammarState:()=>Y2,getSingletonHighlighter:()=>K2,loadWasm:()=>fb}),Sz);let Zg=null;const Uc=new Set,Jd=new Map,bC=["typescript","javascript","tsx","jsx","python","bash","json","css","html","sql","yaml","markdown","diff","rust","go","java","c","cpp","ruby","toml","scss","graphql","docker","powershell"],lF=["github-dark-default","vitesse-light","monokai","dracula","nord","everforest-light","rose-pine-dawn","synthwave-84","one-dark-pro","night-owl","catppuccin-mocha","rose-pine","kanagawa-wave","light-plus"],ex={dark:"github-dark-default",light:"vitesse-light",monokai:"monokai",dracula:"dracula",nord:"nord","rose-pine-dawn":"rose-pine-dawn","everforest-light":"everforest-light","synthwave-84":"synthwave-84","one-dark-pro":"one-dark-pro","night-owl":"night-owl","catppuccin-mocha":"catppuccin-mocha","rose-pine":"rose-pine","kanagawa-wave":"kanagawa-wave","light-plus":"light-plus"};function cF(){return{name:"line-numbers",line(e,t){e.properties["data-line"]=String(t+1)}}}async function _N(){return Zg||(Zg=Mf({themes:lF,langs:bC}).then(e=>(bC.forEach(t=>Uc.add(t)),e))),Zg}async function uF(e){if(Uc.has(e))return;if(Jd.has(e))return Jd.get(e);const t=(async()=>{const n=await _N(),r=Nf[e];if(r){await n.loadLanguage(r),Uc.add(e);return}try{const a=await te(()=>import(`shiki/langs/${e}.mjs`),[]);a.default&&(await n.loadLanguage(a.default),Uc.add(e))}catch(a){console.warn(`Failed to load language ${e}:`,a)}})();Jd.set(e,t),await t,Jd.delete(e)}const kc=new Map,dF=50;function hF(e,t,n){return`${e}|${t}|${n}`}async function SN(e,t,n="github-dark-default"){t!=="text"&&!Uc.has(t)&&await uF(t);const r=hF(e,t,n),a=kc.get(r);if(a)return a;const u=(await _N()).codeToHtml(e,{lang:t,theme:n,transformers:[cF()]});if(kc.size>=dF){const c=kc.keys().next().value;c&&kc.delete(c)}return kc.set(r,u),u}const fF={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 Hf(e){var a;if(!e)return"text";const t=hu(e),n=t.toLowerCase();if(n==="dockerfile")return"docker";if(n==="makefile")return"makefile";if(n==="cmakelists.txt")return"cmake";const r=(a=t.split(".").pop())==null?void 0:a.toLowerCase();return r?fF[r]??"text":"text"}function wN(){const e=qt(r=>r.currentPreset),t=qt(r=>r.isCustom),n=qt(r=>r.basePreset);return mF(e,t,n)}function mF(e,t,n){return t?n&&n!=="system"&&ex[n]?ex[n]??"github-dark-default":"github-dark-default":ex[e]??"github-dark-default"}function CN(e=2e3){const[t,n]=E.useState(!1),r=E.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:r}}const pF=5e3,Ic=new Map,gF=100,xF=20*1024*1024;let tx=0;function yF(e,t){for(Ic.set(e,t),tx+=e.length;Ic.size>gF||tx>xF;){const n=Ic.keys().next().value;if(n===void 0)break;Ic.delete(n),tx-=n.length}return t}const bF=E.memo(function({language:t,codeString:n,showSyntaxHighlighting:r,deferHighlight:a}){const{copied:l,copy:u}=CN(),[c,d]=E.useState(null),h=wN(),p=E.useRef(n),m=t==="text"||n.length>pF;return E.useEffect(()=>{!r||a||m||(p.current=n,SN(n,t,h).then(g=>{p.current===n&&d(g)}))},[n,t,h,r,a,m]),s.jsxs("div",{className:"relative group my-1.5 rounded overflow-hidden",children:[s.jsxs("div",{className:"absolute bottom-0 right-0 flex items-center gap-2 px-2 py-1 text-xs text-text-muted/70 bg-bg-tertiary/60 rounded-tl rounded-tr z-10",children:[s.jsx("span",{children:t}),s.jsx("button",{type:"button",onClick:g=>{g.preventDefault(),g.stopPropagation(),u(n)},className:"opacity-0 group-hover:opacity-100 transition-opacity hover:text-text-primary p-0.5",title:"Copy code",children:l?s.jsx(Ls,{}):s.jsx(Yc,{})})]}),r&&c?s.jsx("div",{className:"min-w-0",dangerouslySetInnerHTML:{__html:c}}):s.jsx(bn,{horizontal:!0,scope:"codeBlocks",children:s.jsx("pre",{className:"my-0 px-4 py-3 font-mono text-sm whitespace-pre-wrap break-word",children:s.jsx("code",{className:`language-${t}`,children:n})})})]})});function vF(e,t,n){const r=e?"text-text-muted":"text-text-heading",a=e?"text-text-secondary":"text-text-bold";return{code({className:l,children:u,...c}){const d=/language-(\w+)/.exec(l||"");if(!d&&!String(u).includes(`
247
+ `)){const g=e?"text-text-muted":"text-text-code";return s.jsx("code",{className:`bg-bg-tertiary px-1 py-0.5 rounded ${g} font-mono text-xs`,...c,children:u})}const p=(d==null?void 0:d[1])||"text",m=String(u).replace(/\n$/,"");return s.jsx(bF,{language:p,codeString:m,showSyntaxHighlighting:t,deferHighlight:n})},p({children:l}){const u=e?"text-text-muted":"text-text-primary";return s.jsx("p",{className:`${u} mb-1.5 last:mb-0 leading-tight break-words`,children:l})},ul({children:l}){return s.jsx("ul",{className:"list-disc list-inside mb-1.5 space-y-0.5",children:l})},ol({children:l}){return s.jsx("ol",{className:"list-decimal list-inside mb-1.5 space-y-0.5",children:l})},li({children:l}){const u=e?"text-text-muted":"text-text-primary";return s.jsx("li",{className:`${u} text-sm list-item`,children:l})},h1({children:l}){return s.jsx("h1",{className:`text-base font-bold mb-1.5 mt-2 first:mt-0 ${r}`,children:l})},h2({children:l}){return s.jsx("h2",{className:`text-sm font-bold mb-1.5 mt-2 first:mt-0 ${r}`,children:l})},h3({children:l}){return s.jsx("h3",{className:`text-sm font-bold mb-1.5 mt-1.5 first:mt-0 ${r}`,children:l})},h4({children:l}){return s.jsx("h4",{className:`text-sm font-bold mb-1.5 mt-1.5 first:mt-0 ${r}`,children:l})},strong({children:l}){return s.jsx("strong",{className:`font-bold ${a}`,children:l})},em({children:l}){return s.jsx("em",{className:e?"italic text-text-secondary":"italic",children:l})},a({href:l,children:u}){return s.jsx("a",{href:l,className:"text-text-link hover:underline text-sm",target:"_blank",rel:"noopener noreferrer",children:u})},blockquote({children:l}){const u=e?"text-text-muted":"text-text-secondary";return s.jsx("blockquote",{className:`border-l-2 border-accent-primary pl-2 my-1.5 ${u} italic text-sm`,children:l})},table({children:l}){return s.jsx(bn,{horizontal:!0,className:"my-1.5",scope:"codeBlocks",children:s.jsx("table",{className:"min-w-full border border-border",children:l})})},th({children:l}){return s.jsx("th",{className:"border border-border bg-bg-tertiary px-2 py-1 text-left font-semibold text-sm",children:l})},td({children:l}){return s.jsx("td",{className:"border border-border px-2 py-1 text-sm",children:l})},hr(){return s.jsx("hr",{className:"border-border my-2"})},input({checked:l,...u}){return s.jsx("input",{type:"checkbox",checked:l,disabled:!0,className:"mr-1.5 w-3.5 h-3.5",...u})}}}const sr=E.memo(function({content:t,className:n="",muted:r=!1,isStreaming:a=!1}){const{showSyntaxHighlighting:l,deferCodeHighlightWhileStreaming:u}=As(),c=E.useMemo(()=>a&&u&&EN(t)%2===1,[a,u,t]),d=E.useMemo(()=>vF(r,l,c),[r,l,c]),h=E.useMemo(()=>{const p=_F(t);if(!wF(p)){if(!p.trim())return null;const m=r?"text-text-muted":"text-text-primary";return s.jsx("p",{className:`${m} mb-1.5 last:mb-0 leading-tight break-words whitespace-pre-line`,children:SF(p)})}return a?kN(p,d):CF(p,d,r,l)},[t,a,d,r,l]);return s.jsx("div",{className:`markdown-content [&_li>p]:inline ${n}`,children:h})});function _F(e){let t=kF(e);return t=EF(t),t.trimEnd()}function SF(e){const t=e.split(/(https?:\/\/[^\s<>"']+)/g);return t.length===1?e:t.map((n,r)=>/^https?:\/\//.test(n)?s.jsx("a",{href:n,className:"text-text-link hover:underline",target:"_blank",rel:"noopener noreferrer",children:n},r):n)}function wF(e){return e.includes("`")||e.includes("~")||e.includes("<")||/^#{1,6}\s/m.test(e)||/^\s*[-*+]\s/m.test(e)||/^\s*\d+[.)]\s/m.test(e)||/^\s*>\s?/m.test(e)||/^\s*\|.*\|/m.test(e)||/^\s*([-*_])\1{2,}\s*$/m.test(e)||/\[[^\]]*\]\([^)]*\)/.test(e)||/!\[[^\]]*\]/.test(e)||/[*_]/.test(e)||e.includes("&")}function kN(e,t){return s.jsx(z4,{remarkPlugins:[Z6],components:t,children:e})}function CF(e,t,n,r){const a=`${n?"m":"n"}|${r?"h":"p"}|${e}`,l=Ic.get(a);if(l!==void 0)return l;const u=kN(e,t);return yF(a,u)}function kF(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 EN(e){var t;return((t=e.match(/```/g))==null?void 0:t.length)??0}function EF(e){if(EN(e)%2===1){const n=e.lastIndexOf("```");return e.slice(n+3).includes(`
248
+ `),e+"\n```"}return e}function jN({isOpen:e,onClose:t}){const[n,r]=E.useState(null),[a,l]=E.useState(!1),{settings:u,getSetting:c,setSetting:d}=ea(),h=u[je.DISPLAY_SHOW_CHANGELOG_ON_UPDATE]!=="false";E.useEffect(()=>{e&&c(je.DISPLAY_SHOW_CHANGELOG_ON_UPDATE)},[e,c]),E.useEffect(()=>{e&&(l(!0),we("/api/changelog").then(m=>m.json()).then(m=>{r(m.content)}).catch(()=>{r(`# Changelog
249
+
250
+ Failed to load changelog.`)}).finally(()=>l(!1)))},[e]);const p=E.useCallback(()=>{const m=h?"false":"true";d(je.DISPLAY_SHOW_CHANGELOG_ON_UPDATE,m)},[h,d]);return s.jsx(jt,{isOpen:e,onClose:t,title:"What's New in OpenFox",size:"xl",closeOnBackdropClick:!0,showCloseButton:!0,footer:s.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[s.jsx(cs,{enabled:h,onClick:p}),s.jsx("span",{className:"text-sm text-text-muted",children:"Show changelog on future updates"})]}),children:s.jsx("div",{className:"flex flex-col gap-4 min-h-0",children:a?s.jsx("div",{className:"flex items-center justify-center py-12",children:s.jsx("div",{className:"w-5 h-5 border-2 border-accent-primary border-t-transparent rounded-full animate-spin"})}):s.jsx("div",{className:"prose prose-sm dark:prose-invert max-w-none",children:s.jsx(sr,{content:n??""})})})})}const jF="#6b7280";function ul(e,t){var n;return((n=e.find(r=>r.id===t))==null?void 0:n.color)??jF}const ft=Jn(e=>{const t=async()=>{e({loading:!0});try{const r=await(await we("/api/agents")).json();e({defaults:r.defaults??[],userItems:r.userItems??[],projectItems:r.projectItems??[],modelOverrides:r.modelOverrides??{},loading:!1})}catch{e({loading:!1})}};return{defaults:[],userItems:[],projectItems:[],modelOverrides:{},loading:!1,fetchAgents:t,fetchAgent:async n=>{try{const r=await we(`/api/agents/${n}`);return r.ok?await r.json():null}catch{return null}},fetchDefaultContent:async n=>{try{const r=await we(`/api/agents/defaults/${n}`);return r.ok?await r.json():null}catch{return null}},createAgent:async(n,r)=>{const a=await Yi("POST","/api/agents",{...n,destination:r});return a.success&&await t(),a},updateAgent:async(n,r)=>{const a=await Yi("PUT",`/api/agents/${n}`,r);return a.success&&await t(),a},deleteAgent:async n=>{try{const r=await we(`/api/agents/${n}`,{method:"DELETE"}),a=await r.json();return r.ok?(e(l=>({userItems:l.userItems.filter(u=>u.id!==n),projectItems:l.projectItems.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,r)=>pf(`/api/agents/${n}/duplicate`,t,r)}});function NF({onClose:e}){const[,t]=Gn(),{settings:n,getSetting:r,setSetting:a}=ea(),l=n[je.DISPLAY_SHOW_OPEN_IN_EDITOR]==="true",u=n[je.LLM_DYNAMIC_SYSTEM_PROMPT]==="true",c=n[je.CACHE_WARMING]==="true",[d,h]=E.useState({openInEditor:l,dynamicPrompt:u,cacheWarming:c}),[p,m]=E.useState({patterns:[],maxRetriesPerTurn:10}),[g,y]=E.useState(""),[w,C]=E.useState(""),[_,S]=E.useState(!1),[b,v,k,T]=Rx(),[N,R]=E.useState(!1),[A,O]=E.useState(!1),P=Zt(B=>B.version),V=li(B=>B.status),z=li(B=>B.latest),W=li(B=>B.check),M=P&&z?{current:P,latest:z}:null,[U,F]=E.useState(!1),Q=ft(B=>B.defaults),X=ft(B=>B.userItems),H=ft(B=>B.fetchAgents),I=[...Q,...X].filter(B=>!B.subagent);E.useEffect(()=>{h({openInEditor:l,dynamicPrompt:u,cacheWarming:c})},[l,u,c]),E.useEffect(()=>{r(je.DISPLAY_SHOW_OPEN_IN_EDITOR),r(je.LLM_DYNAMIC_SYSTEM_PROMPT),r(je.CACHE_WARMING),r(je.RETRY_PATTERNS),r(je.PROXY_URL)},[r]),E.useEffect(()=>{const B=n[je.RETRY_PATTERNS];if(B)try{m(JSON.parse(B))}catch{}},[n]),E.useEffect(()=>{const B=n[je.PROXY_URL];B!==void 0&&y(B)},[n]),E.useEffect(()=>{H().catch(()=>{})},[H]),E.useEffect(()=>{r(je.DEFAULT_AGENT)},[r]),E.useEffect(()=>{const B=n[je.DEFAULT_AGENT];B!==void 0&&(C(B),S(!0))},[n]);const D=E.useCallback(B=>{m(B),a(je.RETRY_PATTERNS,JSON.stringify(B))},[a]),q=B=>{y(B),a(je.PROXY_URL,B)};function $(){T(async()=>(await we("/api/proxy/test",{method:"POST"})).json())}const J=()=>{const B=!d.openInEditor;h(ne=>({...ne,openInEditor:B})),a(je.DISPLAY_SHOW_OPEN_IN_EDITOR,String(B))},Y=()=>{const B=!d.dynamicPrompt;h(ne=>({...ne,dynamicPrompt:B})),a(je.LLM_DYNAMIC_SYSTEM_PROMPT,String(B))},Z=()=>{const B=!d.cacheWarming;h(ne=>({...ne,cacheWarming:B})),a(je.CACHE_WARMING,String(B))};function K(){e(),t("/onboarding")}return s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{children:[s.jsxs("h3",{className:"text-sm font-medium text-text-primary mb-1",children:[V==="available"&&s.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-accent-primary mr-1.5 align-middle"}),"Updates"]}),s.jsx("p",{className:"text-sm text-text-muted mb-4",children:P?s.jsxs(s.Fragment,{children:["Current version: ",s.jsxs("span",{className:"font-mono",children:["v",P]})]}):"Check for a new OpenFox version."}),s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx(dt,{variant:"secondary",onClick:()=>{F(!0),W()},disabled:V==="checking",children:V==="checking"?"Checking…":"Check for Updates"}),U&&V==="upToDate"&&s.jsx("span",{className:"text-sm text-text-muted",children:"Up to date"}),V==="error"&&s.jsx("span",{className:"text-sm text-text-muted",children:"Update check failed"}),V==="available"&&s.jsxs("button",{onClick:()=>R(!0),className:"text-sm text-accent-primary hover:underline",children:["Update to v",z," →"]})]})]}),s.jsx(WE,{isOpen:N,onClose:()=>R(!1),versionInfo:M}),s.jsxs("div",{className:"flex items-center justify-between pt-2",children:[s.jsx("button",{onClick:()=>O(!0),className:"text-sm text-accent-primary hover:underline",children:"View Changelog →"}),s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("span",{className:"text-xs text-text-muted",children:"Show on update"}),s.jsx(cs,{enabled:(n[je.DISPLAY_SHOW_CHANGELOG_ON_UPDATE]??"true")==="true",onClick:()=>{const ne=(n[je.DISPLAY_SHOW_CHANGELOG_ON_UPDATE]??"true")==="true"?"false":"true";a(je.DISPLAY_SHOW_CHANGELOG_ON_UPDATE,ne)}})]})]}),s.jsx(jN,{isOpen:A,onClose:()=>O(!1)}),s.jsx("hr",{className:"border-border"}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary mb-1",children:"Default Agent"}),s.jsx("p",{className:"text-sm text-text-muted mb-3",children:"Choose which agent is used by default for new sessions. The stock Planner is read-only; custom agents can have broader capabilities."}),s.jsxs("select",{value:_?w:"",onChange:B=>{const ne=B.target.value;C(ne),a(je.DEFAULT_AGENT,ne)},className:"w-full px-3 py-2 text-sm bg-bg-primary border border-border rounded-lg text-text-primary focus:outline-none focus:ring-2 focus:ring-accent-primary",children:[!_&&s.jsx("option",{value:"",children:"Loading…"}),_&&s.jsx("option",{value:"",children:"System default (planner)"}),I.map(B=>s.jsx("option",{value:B.id,children:B.name},B.id))]}),I.length===0&&_&&s.jsx("p",{className:"text-xs text-text-muted mt-1",children:"No agents available. Create one in the Agents modal."})]}),s.jsx("hr",{className:"border-border"}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary mb-1",children:"Onboarding"}),s.jsx("p",{className:"text-sm text-text-muted mb-4",children:"Manage providers, workdir and vision fallback."}),s.jsx(dt,{variant:"secondary",onClick:K,children:"Launch Onboarding"})]}),s.jsx("hr",{className:"border-border"}),s.jsx("div",{children:s.jsx(nx,{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:J})}),s.jsx("hr",{className:"border-border"}),s.jsx(nx,{title:"Speculative Cache Warming",description:"On first keystroke in an empty session, prefill the LLM KV cache to reduce time-to-first-token.",enabled:d.cacheWarming,onToggle:Z,boldTitle:!0}),s.jsx("hr",{className:"border-border"}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Network"}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-text-secondary block mb-1",children:"HTTP Proxy"}),s.jsxs("div",{className:"flex gap-2 items-center",children:[s.jsx(Gi,{type:"text",value:g,onChange:B=>q(B.target.value),placeholder:"http://proxy:8080",className:"flex-1"}),s.jsx(dt,{variant:"secondary",onClick:$,style:k?{color:"rgb(63, 185, 80)"}:void 0,children:b})]}),v&&s.jsx("p",{className:"text-xs text-red-500 mt-1",children:v}),s.jsx("p",{className:"text-xs text-text-muted mt-1",children:"Proxy server all OpenFox network requests (AI, model fetching, web search, terminal). Leave empty for direct connection."})]})]}),s.jsx("hr",{className:"border-border"}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Auto-Retry Patterns"}),s.jsx("p",{className:"text-sm text-text-muted mb-3",children:'Define regex patterns that, when matched against LLM responses mid-stream, trigger an automatic retry with a "continue" prompt. The content that triggered the match is preserved in the chat feed.'}),s.jsx(N5,{value:p,onChange:D})]}),s.jsx("hr",{className:"border-border"}),s.jsx(nx,{title:"Dynamic System Prompt",description:"Rebuild the system prompt on every turn. Recommended value: off.",enabled:d.dynamicPrompt,onToggle:Y,boldTitle:!0})]})}function nx({title:e,description:t,enabled:n,onToggle:r,boldTitle:a}){return s.jsxs("label",{className:"flex items-start justify-between gap-3 cursor-pointer",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:`text-sm ${a?"font-medium":""} text-text-primary`,children:e}),s.jsx("div",{className:"text-sm text-text-muted mt-0.5",children:t})]}),s.jsx("div",{className:"flex-shrink-0",children:s.jsx(cs,{enabled:n,onClick:r})})]})}function TF(e,t){return e===null&&t===null?!0:e===null||t===null?!1:JSON.stringify(e)===JSON.stringify(t)}function AF({label:e,binding:t,defaultBinding:n,isRecording:r,onStartRecording:a,onBindingRecorded:l,onClear:u,onReset:c,onCancelRecording:d}){const h=E.useRef(null),p=E.useRef(0),m=E.useRef("");return E.useEffect(()=>{if(!r)return;const g=new Set(["Control","Shift","Alt","Meta"]);let y=[];const w=_=>{if(_.preventDefault(),_.stopPropagation(),_.key==="Escape"){d();return}if(g.has(_.key)){const v=Date.now();if(_.key===m.current&&v-p.current<400){l({type:"double-press",key:_.key,threshold:300});return}p.current=v,m.current=_.key,_.ctrlKey&&!y.includes("ctrl")&&y.push("ctrl"),_.metaKey&&!y.includes("meta")&&y.push("meta"),_.altKey&&!y.includes("alt")&&y.push("alt"),_.shiftKey&&!y.includes("shift")&&y.push("shift");return}if(y.length>0||_.ctrlKey||_.metaKey||_.altKey||_.shiftKey){const v=[...y];_.ctrlKey&&!v.includes("ctrl")&&v.push("ctrl"),_.metaKey&&!v.includes("meta")&&v.push("meta"),_.altKey&&!v.includes("alt")&&v.push("alt"),_.shiftKey&&!v.includes("shift")&&v.push("shift"),l({type:"chord",key:R1(_),modifiers:v});return}const S=Date.now(),b=R1(_);if(b===m.current&&S-p.current<400){l({type:"double-press",key:b,threshold:300});return}p.current=S,m.current=b},C=_=>{_.key==="Control"&&(y=y.filter(S=>S!=="ctrl")),_.key==="Shift"&&(y=y.filter(S=>S!=="shift")),_.key==="Alt"&&(y=y.filter(S=>S!=="alt")),_.key==="Meta"&&(y=y.filter(S=>S!=="meta"))};return window.addEventListener("keydown",w,!0),window.addEventListener("keyup",C,!0),()=>{window.removeEventListener("keydown",w,!0),window.removeEventListener("keyup",C,!0)}},[r,l,d]),s.jsxs("div",{ref:h,className:`flex items-center justify-between px-3 py-2 rounded transition-colors ${r?"bg-accent-primary/10 ring-1 ring-accent-primary":"hover:bg-bg-tertiary"}`,children:[s.jsx("span",{className:"text-sm text-text-primary",children:e}),s.jsx("div",{className:"flex items-center gap-2",children:r?s.jsx("span",{className:"text-xs text-accent-primary font-medium animate-pulse",children:"Press shortcut..."}):s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",onClick:a,className:"px-2 py-0.5 text-xs font-mono bg-bg-tertiary text-text-secondary rounded border border-border hover:border-accent-primary hover:text-accent-primary transition-colors",children:t?Th(t):"None"}),t&&s.jsx("button",{type:"button",onClick:u,title:"Remove shortcut","aria-label":`Remove shortcut for ${e}`,className:"p-1 text-text-muted rounded hover:text-accent-error hover:bg-bg-tertiary transition-colors",children:s.jsx($y,{className:"w-3.5 h-3.5"})}),!TF(t,n)&&s.jsx("button",{type:"button",onClick:c,title:"Reset to default","aria-label":`Reset ${e} to default`,className:"p-1 text-text-muted rounded hover:text-accent-primary hover:bg-bg-tertiary transition-colors",children:s.jsx(xf,{className:"w-3.5 h-3.5"})})]})})]})}function LF(){const{settings:e,loading:t,setSetting:n}=ea(),r=e[je.KEYBINDINGS],a=t[je.KEYBINDINGS]??!1,l=Lx(r),[u,c]=E.useState(null),d=[{id:"terminalToggle",label:"Toggle Terminal",binding:l.terminalToggle,defaultBinding:Cs.terminalToggle},{id:"quickAction",label:"Quick Action",binding:l.quickAction,defaultBinding:Cs.quickAction},{id:"modelSelector",label:"Select Model",binding:l.modelSelector,defaultBinding:Cs.modelSelector},{id:"sessionSearch",label:"Search Sessions",binding:l.sessionSearch,defaultBinding:Cs.sessionSearch},{id:"criteriaSidebar",label:"Toggle Criteria Sidebar",binding:l.criteriaSidebar,defaultBinding:Cs.criteriaSidebar},...l.agentSwitching.map((y,w)=>({id:`agentSwitching.${w}`,label:`Switch to Agent ${w+1}`,binding:y,defaultBinding:Cs.agentSwitching[w]??null}))],h=y=>{c(y)},p=E.useCallback((y,w)=>{const C=Lx(r);if(y.startsWith("agentSwitching.")){const _=parseInt(y.split(".")[1],10);C.agentSwitching[_]=w}else y==="terminalToggle"?C.terminalToggle=w:y==="quickAction"?C.quickAction=w:y==="modelSelector"?C.modelSelector=w:y==="sessionSearch"?C.sessionSearch=w:y==="criteriaSidebar"&&(C.criteriaSidebar=w);n(je.KEYBINDINGS,JSON.stringify(C))},[r,n]),m=E.useCallback(y=>{u&&(c(null),p(u,y))},[u,p]),g=()=>{n(je.KEYBINDINGS,JSON.stringify(Cs))};return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary",children:"Keyboard Shortcuts"}),s.jsx("button",{type:"button",onClick:g,disabled:a,className:"text-xs text-text-muted hover:text-text-primary px-2 py-1 rounded hover:bg-bg-tertiary transition-colors disabled:opacity-30",children:"Reset to defaults"})]}),a?s.jsx("div",{className:"text-sm text-text-muted",children:"Loading..."}):s.jsx("div",{className:"space-y-1",children:d.map(y=>s.jsx(AF,{label:y.label,binding:y.binding,defaultBinding:y.defaultBinding,isRecording:u===y.id,onStartRecording:()=>h(y.id),onBindingRecorded:m,onClear:()=>p(y.id,null),onReset:()=>p(y.id,y.defaultBinding),onCancelRecording:()=>c(null)},y.id))})]})}function kb(e){switch(e){case"connected":return"text-accent-success";case"error":return"text-accent-error";case"disabled":return"text-text-muted";default:return"text-text-muted"}}function Eb(e){switch(e){case"connected":return"●";case"error":return"✕";default:return"○"}}function qh(e){return e>=1e3?`~${(e/1e3).toFixed(1)}K`:`~${e}`}function NN({server:e,expanded:t,onToggleExpand:n,serverToggleEnabled:r,onServerToggle:a,tools:l,onToolToggle:u,statusDot:c,statusColor:d,actions:h,authPanel:p}){var w;const[m,g]=E.useState(new Set),y=e.name;return s.jsxs("div",{className:"rounded border border-border bg-bg-tertiary overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between p-3 hover:bg-bg-primary/50 transition-colors",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1 cursor-pointer",onClick:()=>n(y),children:[s.jsx("span",{className:`text-sm ${d}`,children:c}),s.jsx("span",{className:"text-sm font-medium text-text-primary",children:y}),s.jsx("span",{className:"text-xs text-text-muted",children:e.config.transport}),s.jsxs("span",{className:"text-xs text-text-muted",children:["(",l.length," tools)"]}),s.jsxs("span",{className:"text-xs text-text-muted",children:[qh(e.estimatedTokens)," tokens"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(cs,{enabled:r,onClick:a}),h,s.jsx("span",{className:"text-xs text-text-muted",children:t?"▲":"▼"})]})]}),t&&s.jsxs("div",{className:"border-t border-border px-3 py-2 space-y-1.5",children:[e.config.command&&s.jsxs("div",{className:"text-xs text-text-muted font-mono",children:[e.config.command," ",((w=e.config.args)==null?void 0:w.join(" "))??""]}),e.config.url&&s.jsx("div",{className:"text-xs text-text-muted font-mono",children:e.config.url}),p,l.length===0?s.jsx("div",{className:"text-xs text-text-muted",children:"No tools available"}):s.jsx("div",{className:"space-y-1",children:l.map(C=>s.jsxs("div",{className:"py-1",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"min-w-0 flex-1 mr-2",children:[s.jsx("span",{className:"text-xs text-text-primary font-mono",children:C.name}),C.description&&C.description.length>80?s.jsxs("button",{onClick:()=>{const _=C.name;g(S=>{const b=new Set(S);return b.has(_)?b.delete(_):b.add(_),b})},className:"inline-flex items-center gap-0.5 text-xs text-text-muted hover:text-text-primary transition-colors ml-2",children:[s.jsx("span",{className:"truncate max-w-[300px]",children:C.description}),s.jsx(vn,{rotate:m.has(C.name)?180:0,className:"w-3 h-3 flex-shrink-0"})]}):C.description?s.jsx("span",{className:"text-xs text-text-muted ml-2",children:C.description}):null]}),s.jsx("span",{className:"text-xs text-text-muted mr-2 flex-shrink-0",children:qh(C.estimatedTokens)}),s.jsx(cs,{enabled:C.enabled,onClick:()=>u(C.name)})]}),C.description&&C.description.length>80&&m.has(C.name)&&s.jsx("div",{className:"text-xs text-text-muted mt-1 ml-1",children:C.description})]},C.name))})]})]},y)}function vC(e){const t={};return e.split(`
251
+ `).filter(Boolean).forEach(n=>{const r=n.indexOf("=");r>0&&(t[n.slice(0,r).trim()]=n.slice(r+1).trim())}),t}function _C({formData:e,onChange:t}){return s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Transport"}),s.jsxs("div",{className:"flex gap-1",children:[s.jsx("button",{onClick:()=>t({...e,transport:"stdio"}),className:`px-3 py-1.5 rounded text-xs font-medium transition-colors ${e.transport==="stdio"?"bg-accent-primary text-white":"bg-bg-tertiary text-text-secondary hover:bg-bg-primary"}`,children:"Stdio"}),s.jsx("button",{onClick:()=>t({...e,transport:"http"}),className:`px-3 py-1.5 rounded text-xs font-medium transition-colors ${e.transport==="http"?"bg-accent-primary text-white":"bg-bg-tertiary text-text-secondary hover:bg-bg-primary"}`,children:"HTTP"})]})]}),e.transport==="stdio"?s.jsxs(s.Fragment,{children:[s.jsx(Yr,{label:"Command",value:e.command,onChange:n=>t({...e,command:n}),placeholder:"e.g. npx"}),s.jsx(Yr,{label:"Arguments",value:e.args,onChange:n=>t({...e,args:n}),placeholder:"space-separated args"}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:["Environment variables ",s.jsx("span",{className:"text-text-muted",children:"(KEY=VALUE, one per line)"})]}),s.jsx("textarea",{value:e.env,onChange:n=>t({...e,env:n.target.value}),placeholder:"API_KEY=xxx",className:"w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm font-mono resize-none focus:outline-none focus:ring-1 focus:ring-accent-primary",rows:3})]})]}):s.jsxs(s.Fragment,{children:[s.jsx(Yr,{label:"URL",value:e.url,onChange:n=>t({...e,url:n}),placeholder:"e.g. https://mcp.example.com/mcp"}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:["Headers ",s.jsx("span",{className:"text-text-muted",children:"(KEY=VALUE, one per line)"})]}),s.jsx("textarea",{value:e.headers,onChange:n=>t({...e,headers:n.target.value}),placeholder:"X-API-Key=xxx",className:"w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm font-mono resize-none focus:outline-none focus:ring-1 focus:ring-accent-primary",rows:3})]}),s.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:e.oauth,onChange:n=>t({...e,oauth:n.target.checked}),className:"mt-0.5"}),s.jsxs("span",{className:"text-xs text-text-secondary",children:["Authorize with OAuth",s.jsx("span",{className:"block text-text-muted",children:"For servers that require a sign in rather than a static credential. Expand the server afterwards to authorize."})]})]})]}),s.jsx(Yr,{label:"Timeout (seconds)",value:e.timeout,onChange:n=>t({...e,timeout:n}),placeholder:"optional, e.g. 30"})]})}const rx="px-2 py-1 rounded text-xs font-medium text-text-muted hover:text-text-primary hover:bg-bg-primary transition-colors disabled:opacity-50";function RF({serverName:e,onChanged:t}){const[n,r]=E.useState(!1),[a,l]=E.useState(""),[u,c]=E.useState(""),[d,h]=E.useState(""),p=`/api/mcp/servers/${encodeURIComponent(e)}/oauth`,m=async _=>{r(!0),h("");try{await _()}catch(S){h(S instanceof Error?S.message:String(S))}finally{r(!1)}},g=async(_,S)=>{const b=await we(_,{method:"POST",headers:{"Content-Type":"application/json"},...S!==void 0?{body:JSON.stringify(S)}:{}}),v=await b.json();if(!b.ok)throw new Error(v.error??"Request failed");return v},y=()=>m(async()=>{const _=await g(`${p}/start`);if(_.status!=="redirect"){t();return}l(_.redirectUri??""),window.open(_.authorizationUrl,"_blank","noopener,noreferrer")}),w=()=>m(async()=>{await g(`${p}/complete`,{response:u}),c(""),l(""),t()}),C=()=>m(async()=>{if(!(await we(p,{method:"DELETE"})).ok)throw new Error("Could not clear the stored credentials");t()});return s.jsxs("div",{className:"space-y-1.5 py-1",children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{onClick:y,disabled:n,className:rx,children:"Authorize"}),s.jsx("button",{onClick:C,disabled:n,className:rx,children:"Forget credentials"})]}),a&&s.jsxs("div",{className:"space-y-1",children:[s.jsx("div",{className:"text-xs text-text-muted",children:"A tab opened for you to sign in. If it ends up on a page that will not load, copy the whole address from it and paste it below."}),s.jsx("div",{className:"text-xs text-text-muted font-mono break-all",children:a}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("input",{value:u,onChange:_=>c(_.target.value),placeholder:"paste the callback URL",className:"flex-1 px-2 py-1 bg-bg-tertiary border border-border rounded text-xs font-mono focus:outline-none focus:ring-1 focus:ring-accent-primary"}),s.jsx("button",{onClick:w,disabled:n||!u,className:rx,children:"Finish"})]})]}),d&&s.jsx("div",{className:"text-xs text-accent-error",children:d})]})}function sx(e,t,n,r=250){const a=E.useRef(!0);E.useEffect(()=>{if(a.current){a.current=!1;return}const l=setTimeout(()=>{n(t,e)},r);return()=>clearTimeout(l)},[e,t,r,n])}function SC({saving:e,saveLabel:t,savingLabel:n,onCancel:r,onSave:a}){return s.jsxs("div",{className:"flex justify-end gap-2 pt-2 border-t border-border",children:[s.jsx(dt,{variant:"secondary",onClick:r,disabled:e,children:"Cancel"}),s.jsx(dt,{variant:"primary",onClick:a,disabled:e,children:e?n:t})]})}function DF(){const{settings:e,getSetting:t,setSetting:n}=ea(),[r,a]=E.useState(""),[l,u]=E.useState(""),[c,d]=E.useState(""),[h,p]=E.useState("");sx(l,je.SEARCH_TAVILY_API_KEY,n),sx(c,je.SEARCH_SEARXNG_URL,n),sx(h,je.SEARCH_SEARXNG_API_KEY,n);const[m,g,y,w]=Rx(),[C,_,S,b]=Rx();E.useEffect(()=>{t(je.SEARCH_ENGINE),t(je.SEARCH_TAVILY_API_KEY),t(je.SEARCH_SEARXNG_URL),t(je.SEARCH_SEARXNG_API_KEY),t(je.TOOLS_USE_RTK),t(je.CONFIRM_ON_WORKSPACE_ACTIONS)},[t]),E.useEffect(()=>{e[je.SEARCH_ENGINE]!==void 0&&(a(e[je.SEARCH_ENGINE]??""),u(e[je.SEARCH_TAVILY_API_KEY]??""),d(e[je.SEARCH_SEARXNG_URL]??""),p(e[je.SEARCH_SEARXNG_API_KEY]??""))},[e]);function v(he){a(he),n(je.SEARCH_ENGINE,he)}function k(){w(async()=>(await we("/api/search/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({engine:"tavily",tavilyApiKey:l||void 0})})).json())}function T(){b(async()=>(await we("/api/search/test",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({engine:"searxng",searxngUrl:c||void 0,searxngApiKey:h||void 0})})).json())}const[N,R]=E.useState("checking");E.useEffect(()=>{we("/api/tools/rtk-check").then(he=>he.json()).then(he=>R(he.available?"available":"unavailable")).catch(()=>R("unavailable"))},[]);const[A,O]=E.useState([]);E.useEffect(()=>{t(je.TOOLS_SHELL),we("/api/tools/shells").then(he=>he.json()).then(he=>O(he.shells??[])).catch(()=>O([]))},[t]);const P=e[je.TOOLS_SHELL]||"cmd",[V,z]=E.useState([]),[W,M]=E.useState(!0),[U,F]=E.useState(!1),[Q,X]=E.useState(null),[H,I]=E.useState(new Set),[D,q]=E.useState({name:"",transport:"stdio",command:"",args:"",env:"",url:"",headers:"",oauth:!1,timeout:""}),[$,J]=E.useState(""),[Y,Z]=E.useState(""),[K,B]=E.useState(!1),{requestDelete:ne,clearConfirm:se,isConfirming:re}=du(),oe=E.useCallback(async()=>{try{const He=((await(await we("/api/mcp/servers")).json()).servers??[]).sort((ie,ye)=>ie.name.localeCompare(ye.name));z(He)}catch{}M(!1)},[]);E.useEffect(()=>{oe()},[oe]),E.useEffect(()=>{const he=()=>oe();return window.addEventListener("mcp-servers-changed",he),()=>window.removeEventListener("mcp-servers-changed",he)},[oe]);const ve=he=>{I(Ve=>{const He=new Set(Ve);return He.has(he)?(He.delete(he),He):(He.add(he),He)})};function Se(){if(D.transport==="stdio"&&!D.command)return"Command is required for stdio transport";if(D.transport==="http"&&!D.url)return"URL is required for HTTP transport";if(D.timeout){const he=parseFloat(D.timeout);if(isNaN(he)||he<=0)return"Timeout must be a positive number"}return null}function $e(he){const Ve=he?{name:D.name,transport:D.transport}:{transport:D.transport};if(D.transport==="stdio"?(Ve.command=D.command,Ve.args=D.args?D.args.split(" ").filter(Boolean):[],Ve.env=vC(D.env)):(Ve.url=D.url,Ve.headers=vC(D.headers),Ve.oauth=D.oauth),D.timeout){const He=parseFloat(D.timeout);!isNaN(He)&&He>0&&(Ve.timeout=He)}return Ve}const ze={name:"",transport:"stdio",command:"",args:"",env:"",url:"",headers:"",oauth:!1,timeout:""},ke=async()=>{if(J(""),!D.name){J("Name is required");return}const he=Se();if(he){J(he);return}B(!0);try{const Ve=$e(!0),He=await we("/api/mcp/servers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Ve)});if(!He.ok){const ie=await He.json();throw new Error(ie.error??"Failed to add server")}F(!1),q(ze),await oe()}catch(Ve){J(Ve instanceof Error?Ve.message:String(Ve))}finally{B(!1)}},Ge=he=>{var Ve;q({name:he.name,transport:he.config.transport,command:he.config.command??"",args:((Ve=he.config.args)==null?void 0:Ve.join(" "))??"",env:he.config.env?Object.entries(he.config.env).map(([He,ie])=>`${He}=${ie}`).join(`
252
+ `):"",url:he.config.url??"",headers:he.config.headers?Object.entries(he.config.headers).map(([He,ie])=>`${He}=${ie}`).join(`
253
+ `):"",oauth:he.config.oauth??!1,timeout:he.config.timeout!==void 0?String(he.config.timeout):""}),J(""),X(he.name)},Je=async()=>{J("");const he=Se();if(he){J(he);return}B(!0);try{const Ve=$e(!1),He=await we(`/api/mcp/servers/${encodeURIComponent(Q)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(Ve)});if(!He.ok){const ie=await He.json();throw new Error(ie.error??"Failed to update server")}X(null),q(ze),await oe()}catch(Ve){J(Ve instanceof Error?Ve.message:String(Ve))}finally{B(!1)}},Ce=async he=>{try{const Ve=await we(`/api/mcp/servers/${encodeURIComponent(he)}`,{method:"DELETE"});if(!Ve.ok){const He=await Ve.json().catch(()=>({}));throw new Error(He.error??"Failed to remove server")}se(),Z(""),await oe()}catch(Ve){Z(Ve instanceof Error?Ve.message:String(Ve))}},me=async(he,Ve,He)=>{try{const ie=await we(`/api/mcp/servers/${encodeURIComponent(he)}/tools/${encodeURIComponent(Ve)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:He})});if(!ie.ok){const ye=await ie.json().catch(()=>({}));throw new Error(ye.error??"Failed to toggle tool")}Z(""),await oe()}catch(ie){Z(ie instanceof Error?ie.message:String(ie))}},We=async(he,Ve)=>{try{const He=await we(`/api/mcp/servers/${encodeURIComponent(he)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({disabled:Ve})});if(!He.ok){const ie=await He.json().catch(()=>({}));throw new Error(ie.error??"Failed to toggle server")}Z(""),await oe()}catch(He){Z(He instanceof Error?He.message:String(He))}};return s.jsxs("div",{className:"space-y-8",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Search Engine"}),s.jsx("p",{className:"text-sm text-text-muted mb-3",children:"Configure a web search engine for the web_search tool."}),s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs font-medium text-text-primary mb-1",children:"Engine"}),s.jsx("div",{className:"flex gap-2",children:["","tavily","searxng"].map(he=>s.jsx("button",{onClick:()=>v(he),className:`px-3 py-1.5 rounded text-sm border transition-colors ${r===he?"bg-accent-primary/10 border-accent-primary text-accent-primary":"border-border text-text-muted hover:text-text-primary"}`,children:he||"Off"},he))})]}),r==="tavily"&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs font-medium text-text-primary mb-1",children:"Tavily API Key"}),s.jsxs("div",{className:"flex gap-2 items-center",children:[s.jsx(Gi,{type:"password",value:l,onChange:he=>u(he.target.value),placeholder:"tvly-...",className:"flex-1"}),s.jsx(dt,{variant:"secondary",onClick:k,style:y?{color:"rgb(63, 185, 80)"}:void 0,children:m})]}),g&&s.jsx("p",{className:"text-xs text-red-500 mt-1",children:g}),s.jsxs("p",{className:"text-xs text-text-muted mt-1",children:["Get a free API key at"," ",s.jsx("a",{href:"https://app.tavily.com",target:"_blank",rel:"noopener noreferrer",className:"text-accent-primary hover:underline",children:"tavily.com"})]})]}),r==="searxng"&&s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs font-medium text-text-primary mb-1",children:"SearXNG URL"}),s.jsx(Gi,{type:"url",value:c,onChange:he=>d(he.target.value),placeholder:"http://localhost:4000",className:"w-full"})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-xs font-medium text-text-primary mb-1",children:["API Key ",s.jsx("span",{className:"text-text-muted",children:"(optional)"})]}),s.jsx(Gi,{type:"password",value:h,onChange:he=>p(he.target.value),placeholder:"Optional API key",className:"w-full"})]}),s.jsx(dt,{variant:"secondary",onClick:T,style:S?{color:"rgb(63, 185, 80)"}:void 0,children:C}),_&&s.jsx("p",{className:"text-xs text-red-500",children:_})]})]})]}),A.length>0&&s.jsxs(s.Fragment,{children:[s.jsx("hr",{className:"border-border"}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Shell"}),s.jsx("p",{className:"text-sm text-text-muted mb-3",children:"Shell used to run agent commands and integrated terminals. Git Bash gives the agent a Unix-like toolset (grep, sed, ls…) and usually works better than cmd.exe."}),s.jsx("div",{className:"flex gap-2",children:A.map(he=>s.jsxs("button",{onClick:()=>n(je.TOOLS_SHELL,he.id),disabled:!he.available,title:he.available?void 0:"Not found on this machine",className:`px-3 py-1.5 rounded text-sm border transition-colors ${P===he.id?"bg-accent-primary/10 border-accent-primary text-accent-primary":he.available?"border-border text-text-muted hover:text-text-primary":"border-border text-text-muted opacity-50 cursor-not-allowed"}`,children:[he.label,!he.available&&" (not found)"]},he.id))}),s.jsx("p",{className:"text-xs text-text-muted mt-2",children:"Applies to new commands and newly opened terminals. Running terminals keep their current shell."})]})]}),s.jsx("hr",{className:"border-border"}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Token Optimization"}),s.jsxs("p",{className:"text-sm text-text-muted mb-3",children:["Reduce token consumption by filtering command output through RTK. See the"," ",s.jsx("a",{href:"https://github.com/rtk-ai/rtk",target:"_blank",rel:"noopener noreferrer",className:"text-accent-primary hover:underline",children:"README"})," ","for installation."]}),s.jsxs("div",{className:"flex items-center justify-between py-2",children:[s.jsx("div",{className:"flex-1",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-sm text-text-primary",children:"Enable RTK auto-rewrite"}),N==="checking"&&s.jsx("span",{className:"text-xs text-text-muted animate-pulse",children:"checking…"}),N==="available"&&s.jsx("span",{className:"text-xs text-accent-success",children:"● installed"}),N==="unavailable"&&s.jsx("span",{className:"text-xs text-accent-error",children:"○ not found"})]})}),s.jsx(cs,{enabled:e[je.TOOLS_USE_RTK]==="true",onClick:()=>n(je.TOOLS_USE_RTK,e[je.TOOLS_USE_RTK]==="true"?"false":"true")})]}),A.length>0&&e[je.TOOLS_USE_RTK]==="true"&&P!=="gitbash"&&s.jsx("p",{className:"text-xs text-accent-warning mt-1",children:"RTK only rewrites Unix-style commands — with this shell it will rarely apply and can break some commands. Git Bash is recommended."})]}),s.jsx("hr",{className:"border-border"}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Agent Confirmations"}),s.jsx("p",{className:"text-sm text-text-muted mb-3",children:"Require confirmation for workspace changes and git mutations. When disabled, the agent proceeds without interruption."}),s.jsxs("div",{className:"flex items-center justify-between py-2",children:[s.jsx("div",{className:"flex-1",children:s.jsx("span",{className:"text-sm text-text-primary",children:"Confirm on workspace & git actions"})}),s.jsx(cs,{enabled:e[je.CONFIRM_ON_WORKSPACE_ACTIONS]==="true",onClick:()=>n(je.CONFIRM_ON_WORKSPACE_ACTIONS,e[je.CONFIRM_ON_WORKSPACE_ACTIONS]==="true"?"false":"true")})]})]}),s.jsx("hr",{className:"border-border"}),s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary","data-testid":"mcp-servers-heading",children:"MCP Servers"}),s.jsx(dt,{variant:"primary",size:"sm",onClick:()=>F(!0),children:"+ Add Server"})]}),s.jsx("p",{className:"text-sm text-text-muted mb-3",children:"MCP servers provide external tools that extend OpenFox's capabilities."}),s.jsxs("div",{className:"flex items-center justify-between py-2",children:[s.jsx("div",{className:"flex-1",children:s.jsx("span",{className:"text-sm text-text-primary",children:"Show per-conversation MCP toggle in chat bar"})}),s.jsx(cs,{enabled:e[je.FEATURES_PER_SESSION_MCP]==="true",onClick:()=>n(je.FEATURES_PER_SESSION_MCP,e[je.FEATURES_PER_SESSION_MCP]==="true"?"false":"true")})]}),Y&&s.jsx(nl,{message:Y}),s.jsx(Hy,{loading:W,hasItems:V.length>0,loadingLabel:"Loading MCP servers...",emptyLabel:"No MCP servers configured.",children:V.map(he=>{const Ve=H.has(he.name)?re(he.name,"delete")?s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:ie=>{ie.stopPropagation(),Ce(he.name)},className:"px-2 py-1 rounded text-xs font-medium hover:opacity-90 transition-colors bg-accent-error/20 text-accent-error hover:bg-accent-error/30",children:"Delete"}),s.jsx("button",{onClick:ie=>{ie.stopPropagation(),se()},className:"px-2 py-1 rounded text-xs text-text-muted hover:bg-bg-primary transition-colors",children:"Cancel"})]}):s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:ie=>{ie.stopPropagation(),Ge(he)},className:"px-2 py-1 rounded text-xs font-medium text-text-muted hover:text-text-primary hover:bg-bg-primary transition-colors",children:"Edit"}),s.jsx("button",{onClick:ie=>{ie.stopPropagation(),ne(he.name)},className:"px-2 py-1 rounded text-xs font-medium text-accent-error/80 hover:text-accent-error hover:bg-accent-error/10 transition-colors",children:"Remove"})]}):null,He=he.status==="error"&&he.error?s.jsx("span",{className:"text-xs text-accent-error truncate max-w-[200px]",title:he.error,children:he.error}):null;return s.jsx(NN,{server:he,expanded:H.has(he.name),onToggleExpand:ve,serverToggleEnabled:!he.config.disabled,onServerToggle:()=>We(he.name,!he.config.disabled),tools:he.tools,onToolToggle:ie=>{var ye;return me(he.name,ie,!((ye=he.tools.find(Le=>Le.name===ie))!=null&&ye.enabled))},statusDot:Eb(he.status),statusColor:kb(he.status),authPanel:he.config.oauth?s.jsx(RF,{serverName:he.name,onChanged:oe}):null,actions:s.jsxs(s.Fragment,{children:[He,Ve]})},he.name)})}),U&&s.jsx(jt,{isOpen:U,onClose:()=>{F(!1),J("")},title:"Add MCP Server",size:"sm",children:s.jsxs("div",{className:"space-y-3",children:[s.jsx(Yr,{label:"Name",value:D.name,onChange:he=>q({...D,name:he}),placeholder:"e.g. filesystem"}),s.jsx(_C,{formData:D,onChange:q}),$&&s.jsx(nl,{message:$}),s.jsx(SC,{saving:K,saveLabel:"Add",savingLabel:"Adding...",onCancel:()=>{F(!1),J(""),B(!1),q(ze)},onSave:ke})]})}),Q!==null&&s.jsx(jt,{isOpen:!0,onClose:()=>{X(null),J("")},title:`Edit MCP Server: ${Q}`,size:"sm",children:s.jsxs("div",{className:"space-y-3",children:[s.jsx(_C,{formData:D,onChange:q}),$&&s.jsx(nl,{message:$}),s.jsx(SC,{saving:K,saveLabel:"Save",savingLabel:"Saving...",onCancel:()=>{X(null),J(""),B(!1),q(ze)},onSave:Je})]})})]})]})}const TN="openfox_user_plugins";function OF(e){const t=e.match(/github\.com\/([^/]+)\/([^/]+?)(?:\/|$)/);return t?{owner:t[1],repo:t[2].replace(/\.git$/,"")}:null}async function ix(e){const t=OF(e);if(!t)return null;try{const n=await fetch(`https://api.github.com/repos/${t.owner}/${t.repo}/releases/latest`,{signal:AbortSignal.timeout(5e3)});return n.ok?(await n.json()).tag_name??null:null}catch{return null}}function Zd(){try{return JSON.parse(localStorage.getItem(TN)??"[]")}catch{return[]}}function wC(e){localStorage.setItem(TN,JSON.stringify(e))}function IF({onAdd:e}){const[t,n]=E.useState(""),[r,a]=E.useState(""),[l,u]=E.useState(!1),c=d=>{d.preventDefault(),!(!t.trim()||!r.trim())&&(e({name:t.trim(),displayName:t.trim(),description:"User-added plugin",githubUrl:r.trim()}),n(""),a(""),u(!0),setTimeout(()=>u(!1),2e3))};return s.jsxs("form",{onSubmit:c,className:"flex gap-2 items-end",children:[s.jsxs("div",{className:"flex-1",children:[s.jsx("label",{className:"text-xs text-text-muted block mb-1",children:"Name"}),s.jsx("input",{type:"text",value:t,onChange:d=>n(d.target.value),placeholder:"my-plugin",className:"w-full px-2 py-1 text-sm text-text-primary bg-bg-tertiary border border-border rounded"})]}),s.jsxs("div",{className:"flex-[2]",children:[s.jsx("label",{className:"text-xs text-text-muted block mb-1",children:"GitHub URL"}),s.jsx("input",{type:"text",value:r,onChange:d=>a(d.target.value),placeholder:"https://github.com/user/repo",className:"w-full px-2 py-1 text-sm text-text-primary bg-bg-tertiary border border-border rounded"})]}),s.jsx(dt,{type:"submit",variant:"primary",size:"sm",children:l?"Added":"Add"})]})}function MF({plugin:e,initiallyInstalled:t,installedVersion:n,onRemove:r,onOpenFolder:a}){const[l,u]=E.useState(t?"installed":"idle"),[c,d]=E.useState(!1),[h,p]=E.useState(""),[m,g]=E.useState(n),[y,w]=E.useState(!1),[C,_]=E.useState(!1);E.useEffect(()=>{g(n)},[n]);const S=E.useCallback(async()=>{const P=await we("/api/plugins/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({githubUrl:e.githubUrl})}),V=await P.json();if(P.ok)u("installed"),e.latestVersion&&g(e.latestVersion),V.loaded||p(V.loadError??"Plugin installed but failed to load");else throw new Error(V.error??"Install failed")},[e.githubUrl,e.name]),b=async()=>{u("installing"),p("");try{await S()}catch(P){u("error"),p(P instanceof Error?P.message:"Connection error")}},v=()=>{w(!0)},k=async()=>{_(!0);try{(await we(`/api/plugins/${e.name}`,{method:"DELETE"})).ok&&(u("idle"),r(e.name))}catch{}_(!1),w(!1)},T=async()=>{d(!0),p("");try{await S()}catch(P){p(P instanceof Error?P.message:"Update failed")}d(!1)},N=m??n,R=e.latestVersion&&N&&N!=="unknown"&&e.latestVersion!==N,A=l==="installing"?"Installing…":c?"Updating…":l==="installed"?"Installed ✓":"Install",O=l==="installing"||l==="installed"||c;return s.jsxs("div",{className:"border border-border rounded-lg p-4",children:[s.jsxs("div",{className:"flex items-start justify-between gap-4",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary",children:e.displayName}),s.jsxs("span",{className:"text-xs text-text-muted",children:["(",e.name,")"]})]}),s.jsx("p",{className:"text-xs text-text-muted mt-1",children:e.description}),s.jsxs("div",{className:"flex items-center gap-3 mt-2 text-xs",children:[e.githubUrl&&s.jsx("a",{href:e.githubUrl,target:"_blank",rel:"noreferrer",className:"text-accent-primary hover:underline",children:"GitHub"}),e.versionLoading?s.jsx("span",{className:"text-text-muted",children:"Loading version…"}):e.latestVersion?s.jsxs("span",{className:"text-text-muted",children:["v",e.latestVersion]}):null,N&&N!=="unknown"&&s.jsxs("span",{className:"text-text-muted",children:["installed: v",N]})]}),l==="error"&&h&&s.jsx("p",{className:"text-xs text-accent-error mt-1",children:h})]}),s.jsxs("div",{className:"flex flex-col items-end gap-1",children:[s.jsxs("div",{className:"flex gap-1",children:[e.githubUrl&&s.jsx(dt,{variant:l==="installed"?"secondary":"primary",size:"sm",onClick:b,disabled:O,children:A}),R&&s.jsx(dt,{variant:"primary",size:"sm",onClick:T,children:"Update"}),l==="installed"&&s.jsx(dt,{variant:"danger",size:"sm",onClick:v,children:"Remove"})]}),l==="installed"&&s.jsx("button",{onClick:()=>a(e.name),className:"text-xs text-accent-primary hover:underline",children:"Open folder"})]})]}),s.jsx(Zc,{isOpen:y,onClose:()=>w(!1),onConfirm:k,title:`Remove "${e.displayName}"?`,message:`Remove the "${e.displayName}" plugin from your installation.`,confirmLabel:"Remove",confirmVariant:"danger",disabled:C})]})}function PF(){const[e,t]=E.useState([]),[n,r]=E.useState([]),[a,l]=E.useState({}),[u,c]=E.useState(!0),[d,h]=E.useState(""),[p,m]=E.useState("");E.useEffect(()=>{let S=!1;Promise.all([we("/api/plugins/registry").then(v=>{if(!v.ok)throw new Error(`HTTP ${v.status}`);return v.json()}),we("/api/plugins/installed").then(v=>v.ok?v.json():{installed:[]})]).then(([v,k])=>{if(S)return;const T={},N=k.installed;for(const V of N)T[V.name]=V.version;l(T);const R=v.plugins.map(V=>({...V,latestVersion:null,versionLoading:!0}));t(R),R.forEach(V=>{ix(V.githubUrl).then(z=>{S||t(W=>W.map(M=>M.name===V.name?{...M,latestVersion:z,versionLoading:!1}:M))})});const A=new Set(R.map(V=>V.name)),O=Zd(),P=[];for(const V of N)!A.has(V.name)&&!O.some(z=>z.name===V.name)&&P.push({name:V.name,displayName:V.name,description:"Found on disk",githubUrl:"",latestVersion:null,versionLoading:!1});P.length>0&&r(V=>[...V,...P])}).catch(v=>{S||h(v instanceof Error?v.message:"Failed to load plugins")}).finally(()=>{S||c(!1)});const b=Zd();return b.length>0&&(r(b.map(v=>({...v,latestVersion:null,versionLoading:!0}))),b.forEach(v=>{ix(v.githubUrl).then(k=>{S||r(T=>T.map(N=>N.name===v.name?{...N,latestVersion:k,versionLoading:!1}:N))})})),()=>{S=!0}},[]);const g=async S=>{try{S?await we(`/api/plugins/${S}/open-folder`):await we("/api/plugins/open-folder")}catch{}},y=E.useCallback(S=>{l(k=>{const T={...k};return delete T[S],T});const b=Zd(),v=b.filter(k=>k.name!==S);v.length!==b.length&&wC(v),r(k=>k.filter(T=>T.name!==S))},[]),w=E.useCallback(S=>{if(new Set(e.map(k=>k.name)).has(S.name)){m(`"${S.displayName}" is already listed in the registry and won't be added again.`);return}const v=Zd();wC([...v,S]),r(k=>[...k,{...S,latestVersion:null,versionLoading:!0}]),ix(S.githubUrl).then(k=>{r(T=>T.map(N=>N.name===S.name?{...N,latestVersion:k,versionLoading:!1}:N))})},[e]),C=new Set,_=[...e,...n].filter(S=>C.has(S.name)?!1:(C.add(S.name),!0));return u?s.jsx("div",{className:"text-sm text-text-muted",children:"Loading plugins..."}):s.jsxs("div",{className:"space-y-4",children:[d&&s.jsxs("div",{className:"text-sm text-accent-error bg-accent-error/10 border border-accent-error/30 rounded-lg p-3",children:["Failed to load plugin registry: ",d]}),p&&s.jsxs("div",{className:"text-sm text-accent-warning bg-accent-warning/10 border border-accent-warning/30 rounded-lg p-3 flex justify-between items-center",children:[s.jsx("span",{children:p}),s.jsx("button",{onClick:()=>m(""),className:"text-text-muted hover:text-text-primary ml-2",children:"×"})]}),s.jsxs("div",{className:"border border-border rounded-lg p-4",children:[s.jsx("h3",{className:"text-sm font-medium text-text-primary mb-3",children:"Add Plugin"}),s.jsx(IF,{onAdd:w})]}),_.length===0&&!d&&s.jsx("div",{className:"text-sm text-text-muted",children:"No plugins found."}),_.map(S=>s.jsx(MF,{plugin:S,initiallyInstalled:S.name in a,installedVersion:a[S.name]??null,onRemove:y,onOpenFolder:g},S.name))]})}function BF({isOpen:e,onClose:t}){const[n,r]=E.useState("instructions"),a=li(u=>u.status==="available"),l=()=>{try{Pt.send("context.checkDynamic",{})}catch{}t()};return s.jsx(jt,{isOpen:e,onClose:l,title:"Settings",size:"xl",scrollable:!1,children:s.jsxs("div",{"data-global-settings":!0,className:"flex flex-col h-full min-h-0 -m-4",children:[s.jsxs(ct,{horizontal:!0,options:{scrollbars:{visibility:"hidden"}},className:"flex border-b border-border mb-4 flex-shrink-0 px-4 pt-4",children:[s.jsx(Mi,{label:"Instructions",active:n==="instructions",onClick:()=>r("instructions")}),s.jsx(Mi,{label:"Tools",active:n==="tools",onClick:()=>r("tools")}),s.jsx(Mi,{label:"Skills",active:n==="skills",onClick:()=>r("skills")}),s.jsx(Mi,{label:"Plugins",active:n==="plugins",onClick:()=>r("plugins")}),s.jsx(Mi,{label:"Notifications",active:n==="notifications",onClick:()=>r("notifications")}),s.jsx(Mi,{label:"Display",active:n==="display",onClick:()=>r("display")}),s.jsx(Mi,{label:"Keybindings",active:n==="keybindings",onClick:()=>r("keybindings")}),s.jsx(Mi,{label:"Advanced",active:n==="advanced",onClick:()=>r("advanced"),showDot:a})]}),s.jsxs(ct,{className:"flex-1 min-h-0 px-4 pb-4",children:[n==="instructions"&&s.jsx(c5,{isOpen:e}),n==="skills"&&s.jsx(l5,{isOpen:e}),n==="plugins"&&s.jsx(PF,{}),n==="notifications"&&s.jsx(J3,{}),n==="display"&&s.jsx(w5,{}),n==="keybindings"&&s.jsx(LF,{}),n==="tools"&&s.jsx(DF,{}),n==="advanced"&&s.jsx(NF,{onClose:t})]})]})})}function Mi({label:e,active:t,onClick:n,showDot:r}){return s.jsxs("button",{onClick:n,className:`relative px-4 py-2 text-sm font-medium border-b-2 transition-colors whitespace-nowrap ${t?"border-accent-primary text-accent-primary":"border-transparent text-text-muted hover:text-text-secondary hover:border-border"}`,children:[e,r&&s.jsx("span",{className:"absolute top-1 right-1 w-1.5 h-1.5 rounded-full bg-accent-primary"})]})}var ax={exports:{}},CC;function $F(){return CC||(CC=1,(function(e,t){(function(n,r){e.exports=r()})(globalThis,(()=>(()=>{var n={4567:function(u,c,d){var h=this&&this.__decorate||function(b,v,k,T){var N,R=arguments.length,A=R<3?v:T===null?T=Object.getOwnPropertyDescriptor(v,k):T;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(b,v,k,T);else for(var O=b.length-1;O>=0;O--)(N=b[O])&&(A=(R<3?N(A):R>3?N(v,k,A):N(v,k))||A);return R>3&&A&&Object.defineProperty(v,k,A),A},p=this&&this.__param||function(b,v){return function(k,T){v(k,T,b)}};Object.defineProperty(c,"__esModule",{value:!0}),c.AccessibilityManager=void 0;const m=d(9042),g=d(9924),y=d(844),w=d(4725),C=d(2585),_=d(3656);let S=c.AccessibilityManager=class extends y.Disposable{constructor(b,v,k,T){super(),this._terminal=b,this._coreBrowserService=k,this._renderService=T,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=this._coreBrowserService.mainDocument.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=this._coreBrowserService.mainDocument.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let N=0;N<this._terminal.rows;N++)this._rowElements[N]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[N]);if(this._topBoundaryFocusListener=N=>this._handleBoundaryFocus(N,0),this._bottomBoundaryFocusListener=N=>this._handleBoundaryFocus(N,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=this._coreBrowserService.mainDocument.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new g.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize((N=>this._handleResize(N.rows)))),this.register(this._terminal.onRender((N=>this._refreshRows(N.start,N.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((N=>this._handleChar(N)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
254
+ `)))),this.register(this._terminal.onA11yTab((N=>this._handleTab(N)))),this.register(this._terminal.onKey((N=>this._handleKey(N.key)))),this.register(this._terminal.onBlur((()=>this._clearLiveRegion()))),this.register(this._renderService.onDimensionsChange((()=>this._refreshRowsDimensions()))),this.register((0,_.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(b){for(let v=0;v<b;v++)this._handleChar(" ")}_handleChar(b){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==b&&(this._charsToAnnounce+=b):this._charsToAnnounce+=b,b===`
255
+ `&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=m.tooMuchOutput)))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(b){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(b)||this._charsToConsume.push(b)}_refreshRows(b,v){this._liveRegionDebouncer.refresh(b,v,this._terminal.rows)}_renderRows(b,v){const k=this._terminal.buffer,T=k.lines.length.toString();for(let N=b;N<=v;N++){const R=k.lines.get(k.ydisp+N),A=[],O=(R==null?void 0:R.translateToString(!0,void 0,void 0,A))||"",P=(k.ydisp+N+1).toString(),V=this._rowElements[N];V&&(O.length===0?(V.innerText=" ",this._rowColumns.set(V,[0,1])):(V.textContent=O,this._rowColumns.set(V,A)),V.setAttribute("aria-posinset",P),V.setAttribute("aria-setsize",T))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(b,v){const k=b.target,T=this._rowElements[v===0?1:this._rowElements.length-2];if(k.getAttribute("aria-posinset")===(v===0?"1":`${this._terminal.buffer.lines.length}`)||b.relatedTarget!==T)return;let N,R;if(v===0?(N=k,R=this._rowElements.pop(),this._rowContainer.removeChild(R)):(N=this._rowElements.shift(),R=k,this._rowContainer.removeChild(N)),N.removeEventListener("focus",this._topBoundaryFocusListener),R.removeEventListener("focus",this._bottomBoundaryFocusListener),v===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(v===0?-1:1),this._rowElements[v===0?1:this._rowElements.length-2].focus(),b.preventDefault(),b.stopImmediatePropagation()}_handleSelectionChange(){var O;if(this._rowElements.length===0)return;const b=document.getSelection();if(!b)return;if(b.isCollapsed)return void(this._rowContainer.contains(b.anchorNode)&&this._terminal.clearSelection());if(!b.anchorNode||!b.focusNode)return void console.error("anchorNode and/or focusNode are null");let v={node:b.anchorNode,offset:b.anchorOffset},k={node:b.focusNode,offset:b.focusOffset};if((v.node.compareDocumentPosition(k.node)&Node.DOCUMENT_POSITION_PRECEDING||v.node===k.node&&v.offset>k.offset)&&([v,k]=[k,v]),v.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(v={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(v.node))return;const T=this._rowElements.slice(-1)[0];if(k.node.compareDocumentPosition(T)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(k={node:T,offset:((O=T.textContent)==null?void 0:O.length)??0}),!this._rowContainer.contains(k.node))return;const N=({node:P,offset:V})=>{const z=P instanceof Text?P.parentNode:P;let W=parseInt(z==null?void 0:z.getAttribute("aria-posinset"),10)-1;if(isNaN(W))return console.warn("row is invalid. Race condition?"),null;const M=this._rowColumns.get(z);if(!M)return console.warn("columns is null. Race condition?"),null;let U=V<M.length?M[V]:M.slice(-1)[0]+1;return U>=this._terminal.cols&&(++W,U=0),{row:W,column:U}},R=N(v),A=N(k);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(b){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let v=this._rowContainer.children.length;v<this._terminal.rows;v++)this._rowElements[v]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[v]);for(;this._rowElements.length>b;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const b=this._coreBrowserService.mainDocument.createElement("div");return b.setAttribute("role","listitem"),b.tabIndex=-1,this._refreshRowDimensions(b),b}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){this._accessibilityContainer.style.width=`${this._renderService.dimensions.css.canvas.width}px`,this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let b=0;b<this._terminal.rows;b++)this._refreshRowDimensions(this._rowElements[b])}}_refreshRowDimensions(b){b.style.height=`${this._renderService.dimensions.css.cell.height}px`}};c.AccessibilityManager=S=h([p(1,C.IInstantiationService),p(2,w.ICoreBrowserService),p(3,w.IRenderService)],S)},3614:(u,c)=>{function d(g){return g.replace(/\r?\n/g,"\r")}function h(g,y){return y?"\x1B[200~"+g+"\x1B[201~":g}function p(g,y,w,C){g=h(g=d(g),w.decPrivateModes.bracketedPasteMode&&C.rawOptions.ignoreBracketedPasteMode!==!0),w.triggerDataEvent(g,!0),y.value=""}function m(g,y,w){const C=w.getBoundingClientRect(),_=g.clientX-C.left-10,S=g.clientY-C.top-10;y.style.width="20px",y.style.height="20px",y.style.left=`${_}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=h,c.copyHandler=function(g,y){g.clipboardData&&g.clipboardData.setData("text/plain",y.selectionText),g.preventDefault()},c.handlePasteEvent=function(g,y,w,C){g.stopPropagation(),g.clipboardData&&p(g.clipboardData.getData("text/plain"),y,w,C)},c.paste=p,c.moveTextAreaUnderMouseCursor=m,c.rightClickHandler=function(g,y,w,C,_){m(g,y,w),_&&C.rightClickSelect(g),y.value=C.selectionText,y.select()}},7239:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.ColorContrastCache=void 0;const h=d(1505);c.ColorContrastCache=class{constructor(){this._color=new h.TwoKeyMap,this._css=new h.TwoKeyMap}setCss(p,m,g){this._css.set(p,m,g)}getCss(p,m){return this._css.get(p,m)}setColor(p,m,g){this._color.set(p,m,g)}getColor(p,m){return this._color.get(p,m)}clear(){this._color.clear(),this._css.clear()}}},3656:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.addDisposableDomListener=void 0,c.addDisposableDomListener=function(d,h,p,m){d.addEventListener(h,p,m);let g=!1;return{dispose:()=>{g||(g=!0,d.removeEventListener(h,p,m))}}}},3551:function(u,c,d){var h=this&&this.__decorate||function(S,b,v,k){var T,N=arguments.length,R=N<3?b:k===null?k=Object.getOwnPropertyDescriptor(b,v):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(S,b,v,k);else for(var A=S.length-1;A>=0;A--)(T=S[A])&&(R=(N<3?T(R):N>3?T(b,v,R):T(b,v))||R);return N>3&&R&&Object.defineProperty(b,v,R),R},p=this&&this.__param||function(S,b){return function(v,k){b(v,k,S)}};Object.defineProperty(c,"__esModule",{value:!0}),c.Linkifier=void 0;const m=d(3656),g=d(8460),y=d(844),w=d(2585),C=d(4725);let _=c.Linkifier=class extends y.Disposable{get currentLink(){return this._currentLink}constructor(S,b,v,k,T){super(),this._element=S,this._mouseService=b,this._renderService=v,this._bufferService=k,this._linkProviderService=T,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new g.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new g.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,y.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,y.toDisposable)((()=>{var N;this._lastMouseEvent=void 0,(N=this._activeProviderReplies)==null||N.clear()}))),this.register(this._bufferService.onResize((()=>{this._clearCurrentLink(),this._wasResized=!0}))),this.register((0,m.addDisposableDomListener)(this._element,"mouseleave",(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this.register((0,m.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,m.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,m.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_handleMouseMove(S){this._lastMouseEvent=S;const b=this._positionFromMouseEvent(S,this._element,this._mouseService);if(!b)return;this._isMouseOut=!1;const v=S.composedPath();for(let k=0;k<v.length;k++){const T=v[k];if(T.classList.contains("xterm"))break;if(T.classList.contains("xterm-hover"))return}this._lastBufferCell&&b.x===this._lastBufferCell.x&&b.y===this._lastBufferCell.y||(this._handleHover(b),this._lastBufferCell=b)}_handleHover(S){if(this._activeLine!==S.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(S,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,S)||(this._clearCurrentLink(),this._askForLink(S,!0))}_askForLink(S,b){var k,T;this._activeProviderReplies&&b||((k=this._activeProviderReplies)==null||k.forEach((N=>{N==null||N.forEach((R=>{R.link.dispose&&R.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=S.y);let v=!1;for(const[N,R]of this._linkProviderService.linkProviders.entries())b?(T=this._activeProviderReplies)!=null&&T.get(N)&&(v=this._checkLinkProviderResult(N,S,v)):R.provideLinks(S.y,(A=>{var P,V;if(this._isMouseOut)return;const O=A==null?void 0:A.map((z=>({link:z})));(P=this._activeProviderReplies)==null||P.set(N,O),v=this._checkLinkProviderResult(N,S,v),((V=this._activeProviderReplies)==null?void 0:V.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(S.y,this._activeProviderReplies)}))}_removeIntersectingLinks(S,b){const v=new Set;for(let k=0;k<b.size;k++){const T=b.get(k);if(T)for(let N=0;N<T.length;N++){const R=T[N],A=R.link.range.start.y<S?0:R.link.range.start.x,O=R.link.range.end.y>S?this._bufferService.cols:R.link.range.end.x;for(let P=A;P<=O;P++){if(v.has(P)){T.splice(N--,1);break}v.add(P)}}}}_checkLinkProviderResult(S,b,v){var N;if(!this._activeProviderReplies)return v;const k=this._activeProviderReplies.get(S);let T=!1;for(let R=0;R<S;R++)this._activeProviderReplies.has(R)&&!this._activeProviderReplies.get(R)||(T=!0);if(!T&&k){const R=k.find((A=>this._linkAtPosition(A.link,b)));R&&(v=!0,this._handleNewLink(R))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!v)for(let R=0;R<this._activeProviderReplies.size;R++){const A=(N=this._activeProviderReplies.get(R))==null?void 0:N.find((O=>this._linkAtPosition(O.link,b)));if(A){v=!0,this._handleNewLink(A);break}}return v}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(S){if(!this._currentLink)return;const b=this._positionFromMouseEvent(S,this._element,this._mouseService);b&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,b)&&this._currentLink.link.activate(S,this._currentLink.link.text)}_clearCurrentLink(S,b){this._currentLink&&this._lastMouseEvent&&(!S||!b||this._currentLink.link.range.start.y>=S&&this._currentLink.link.range.end.y<=b)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,y.disposeArray)(this._linkCacheDisposables))}_handleNewLink(S){if(!this._lastMouseEvent)return;const b=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);b&&this._linkAtPosition(S.link,b)&&(this._currentLink=S,this._currentLink.state={decorations:{underline:S.link.decorations===void 0||S.link.decorations.underline,pointerCursor:S.link.decorations===void 0||S.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,S.link,this._lastMouseEvent),S.link.decorations={},Object.defineProperties(S.link.decorations,{pointerCursor:{get:()=>{var v,k;return(k=(v=this._currentLink)==null?void 0:v.state)==null?void 0:k.decorations.pointerCursor},set:v=>{var k;(k=this._currentLink)!=null&&k.state&&this._currentLink.state.decorations.pointerCursor!==v&&(this._currentLink.state.decorations.pointerCursor=v,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",v))}},underline:{get:()=>{var v,k;return(k=(v=this._currentLink)==null?void 0:v.state)==null?void 0:k.decorations.underline},set:v=>{var k,T,N;(k=this._currentLink)!=null&&k.state&&((N=(T=this._currentLink)==null?void 0:T.state)==null?void 0:N.decorations.underline)!==v&&(this._currentLink.state.decorations.underline=v,this._currentLink.state.isHovered&&this._fireUnderlineEvent(S.link,v))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((v=>{if(!this._currentLink)return;const k=v.start===0?0:v.start+1+this._bufferService.buffer.ydisp,T=this._bufferService.buffer.ydisp+1+v.end;if(this._currentLink.link.range.start.y>=k&&this._currentLink.link.range.end.y<=T&&(this._clearCurrentLink(k,T),this._lastMouseEvent)){const N=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);N&&this._askForLink(N,!1)}}))))}_linkHover(S,b,v){var k;(k=this._currentLink)!=null&&k.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(b,!0),this._currentLink.state.decorations.pointerCursor&&S.classList.add("xterm-cursor-pointer")),b.hover&&b.hover(v,b.text)}_fireUnderlineEvent(S,b){const v=S.range,k=this._bufferService.buffer.ydisp,T=this._createLinkUnderlineEvent(v.start.x-1,v.start.y-k-1,v.end.x,v.end.y-k-1,void 0);(b?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(T)}_linkLeave(S,b,v){var k;(k=this._currentLink)!=null&&k.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(b,!1),this._currentLink.state.decorations.pointerCursor&&S.classList.remove("xterm-cursor-pointer")),b.leave&&b.leave(v,b.text)}_linkAtPosition(S,b){const v=S.range.start.y*this._bufferService.cols+S.range.start.x,k=S.range.end.y*this._bufferService.cols+S.range.end.x,T=b.y*this._bufferService.cols+b.x;return v<=T&&T<=k}_positionFromMouseEvent(S,b,v){const k=v.getCoords(S,b,this._bufferService.cols,this._bufferService.rows);if(k)return{x:k[0],y:k[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(S,b,v,k,T){return{x1:S,y1:b,x2:v,y2:k,cols:this._bufferService.cols,fg:T}}};c.Linkifier=_=h([p(1,C.IMouseService),p(2,C.IRenderService),p(3,w.IBufferService),p(4,C.ILinkProviderService)],_)},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 h=this&&this.__decorate||function(C,_,S,b){var v,k=arguments.length,T=k<3?_:b===null?b=Object.getOwnPropertyDescriptor(_,S):b;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")T=Reflect.decorate(C,_,S,b);else for(var N=C.length-1;N>=0;N--)(v=C[N])&&(T=(k<3?v(T):k>3?v(_,S,T):v(_,S))||T);return k>3&&T&&Object.defineProperty(_,S,T),T},p=this&&this.__param||function(C,_){return function(S,b){_(S,b,C)}};Object.defineProperty(c,"__esModule",{value:!0}),c.OscLinkProvider=void 0;const m=d(511),g=d(2585);let y=c.OscLinkProvider=class{constructor(C,_,S){this._bufferService=C,this._optionsService=_,this._oscLinkService=S}provideLinks(C,_){var O;const S=this._bufferService.buffer.lines.get(C-1);if(!S)return void _(void 0);const b=[],v=this._optionsService.rawOptions.linkHandler,k=new m.CellData,T=S.getTrimmedLength();let N=-1,R=-1,A=!1;for(let P=0;P<T;P++)if(R!==-1||S.hasContent(P)){if(S.loadCell(P,k),k.hasExtendedAttrs()&&k.extended.urlId){if(R===-1){R=P,N=k.extended.urlId;continue}A=k.extended.urlId!==N}else R!==-1&&(A=!0);if(A||R!==-1&&P===T-1){const V=(O=this._oscLinkService.getLinkData(N))==null?void 0:O.uri;if(V){const z={start:{x:R+1,y:C},end:{x:P+(A||P!==T-1?0:1),y:C}};let W=!1;if(!(v!=null&&v.allowNonHttpProtocols))try{const M=new URL(V);["http:","https:"].includes(M.protocol)||(W=!0)}catch{W=!0}W||b.push({text:V,range:z,activate:(M,U)=>v?v.activate(M,U,z):w(0,U),hover:(M,U)=>{var F;return(F=v==null?void 0:v.hover)==null?void 0:F.call(v,M,U,z)},leave:(M,U)=>{var F;return(F=v==null?void 0:v.leave)==null?void 0:F.call(v,M,U,z)}})}A=!1,k.hasExtendedAttrs()&&k.extended.urlId?(R=P,N=k.extended.urlId):(R=-1,N=-1)}}_(b)}};function w(C,_){if(confirm(`Do you want to navigate to ${_}?
256
+
257
+ WARNING: This link could potentially be dangerous`)){const S=window.open();if(S){try{S.opener=null}catch{}S.location.href=_}else console.warn("Opening link blocked as opener could not be cleared")}}c.OscLinkProvider=y=h([p(0,g.IBufferService),p(1,g.IOptionsService),p(2,g.IOscLinkService)],y)},6193:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.RenderDebouncer=void 0,c.RenderDebouncer=class{constructor(d,h){this._renderCallback=d,this._coreBrowserService=h,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(d){return this._refreshCallbacks.push(d),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh()))),this._animationFrame}refresh(d,h,p){this._rowCount=p,d=d!==void 0?d:0,h=h!==void 0?h:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,d):d,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,h):h,this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return void this._runRefreshCallbacks();const d=Math.max(this._rowStart,0),h=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(d,h),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(const d of this._refreshCallbacks)d(0);this._refreshCallbacks=[]}}},3236:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.Terminal=void 0;const h=d(3614),p=d(3656),m=d(3551),g=d(9042),y=d(3730),w=d(1680),C=d(3107),_=d(5744),S=d(2950),b=d(1296),v=d(428),k=d(4269),T=d(5114),N=d(8934),R=d(3230),A=d(9312),O=d(4725),P=d(6731),V=d(8055),z=d(8969),W=d(8460),M=d(844),U=d(6114),F=d(8437),Q=d(2584),X=d(7399),H=d(5941),I=d(9074),D=d(2585),q=d(5435),$=d(4567),J=d(779);class Y extends z.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(K={}){super(K),this.browser=U,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this.register(new M.MutableDisposable),this._onCursorMove=this.register(new W.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onKey=this.register(new W.EventEmitter),this.onKey=this._onKey.event,this._onRender=this.register(new W.EventEmitter),this.onRender=this._onRender.event,this._onSelectionChange=this.register(new W.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this.register(new W.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onBell=this.register(new W.EventEmitter),this.onBell=this._onBell.event,this._onFocus=this.register(new W.EventEmitter),this._onBlur=this.register(new W.EventEmitter),this._onA11yCharEmitter=this.register(new W.EventEmitter),this._onA11yTabEmitter=this.register(new W.EventEmitter),this._onWillOpen=this.register(new W.EventEmitter),this._setup(),this._decorationService=this._instantiationService.createInstance(I.DecorationService),this._instantiationService.setService(D.IDecorationService,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(J.LinkProviderService),this._instantiationService.setService(O.ILinkProviderService,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(y.OscLinkProvider)),this.register(this._inputHandler.onRequestBell((()=>this._onBell.fire()))),this.register(this._inputHandler.onRequestRefreshRows(((B,ne)=>this.refresh(B,ne)))),this.register(this._inputHandler.onRequestSendFocus((()=>this._reportFocus()))),this.register(this._inputHandler.onRequestReset((()=>this.reset()))),this.register(this._inputHandler.onRequestWindowsOptionsReport((B=>this._reportWindowsOptions(B)))),this.register(this._inputHandler.onColor((B=>this._handleColorEvent(B)))),this.register((0,W.forwardEvent)(this._inputHandler.onCursorMove,this._onCursorMove)),this.register((0,W.forwardEvent)(this._inputHandler.onTitleChange,this._onTitleChange)),this.register((0,W.forwardEvent)(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this.register((0,W.forwardEvent)(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this.register(this._bufferService.onResize((B=>this._afterResize(B.cols,B.rows)))),this.register((0,M.toDisposable)((()=>{var B,ne;this._customKeyEventHandler=void 0,(ne=(B=this.element)==null?void 0:B.parentNode)==null||ne.removeChild(this.element)})))}_handleColorEvent(K){if(this._themeService)for(const B of K){let ne,se="";switch(B.index){case 256:ne="foreground",se="10";break;case 257:ne="background",se="11";break;case 258:ne="cursor",se="12";break;default:ne="ansi",se="4;"+B.index}switch(B.type){case 0:const re=V.color.toColorRGB(ne==="ansi"?this._themeService.colors.ansi[B.index]:this._themeService.colors[ne]);this.coreService.triggerDataEvent(`${Q.C0.ESC}]${se};${(0,H.toRgbString)(re)}${Q.C1_ESCAPED.ST}`);break;case 1:if(ne==="ansi")this._themeService.modifyColors((oe=>oe.ansi[B.index]=V.channels.toColor(...B.color)));else{const oe=ne;this._themeService.modifyColors((ve=>ve[oe]=V.channels.toColor(...B.color)))}break;case 2:this._themeService.restoreColor(B.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(K){K?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance($.AccessibilityManager,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(K){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(Q.C0.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var K;return(K=this.textarea)==null?void 0:K.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(Q.C0.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;const K=this.buffer.ybase+this.buffer.y,B=this.buffer.lines.get(K);if(!B)return;const ne=Math.min(this.buffer.x,this.cols-1),se=this._renderService.dimensions.css.cell.height,re=B.getWidth(ne),oe=this._renderService.dimensions.css.cell.width*re,ve=this.buffer.y*this._renderService.dimensions.css.cell.height,Se=ne*this._renderService.dimensions.css.cell.width;this.textarea.style.left=Se+"px",this.textarea.style.top=ve+"px",this.textarea.style.width=oe+"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",(B=>{this.hasSelection()&&(0,h.copyHandler)(B,this._selectionService)})));const K=B=>(0,h.handlePasteEvent)(B,this.textarea,this.coreService,this.optionsService);this.register((0,p.addDisposableDomListener)(this.textarea,"paste",K)),this.register((0,p.addDisposableDomListener)(this.element,"paste",K)),U.isFirefox?this.register((0,p.addDisposableDomListener)(this.element,"mousedown",(B=>{B.button===2&&(0,h.rightClickHandler)(B,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))):this.register((0,p.addDisposableDomListener)(this.element,"contextmenu",(B=>{(0,h.rightClickHandler)(B,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))),U.isLinux&&this.register((0,p.addDisposableDomListener)(this.element,"auxclick",(B=>{B.button===1&&(0,h.moveTextAreaUnderMouseCursor)(B,this.textarea,this.screenElement)})))}_bindKeys(){this.register((0,p.addDisposableDomListener)(this.textarea,"keyup",(K=>this._keyUp(K)),!0)),this.register((0,p.addDisposableDomListener)(this.textarea,"keydown",(K=>this._keyDown(K)),!0)),this.register((0,p.addDisposableDomListener)(this.textarea,"keypress",(K=>this._keyPress(K)),!0)),this.register((0,p.addDisposableDomListener)(this.textarea,"compositionstart",(()=>this._compositionHelper.compositionstart()))),this.register((0,p.addDisposableDomListener)(this.textarea,"compositionupdate",(K=>this._compositionHelper.compositionupdate(K)))),this.register((0,p.addDisposableDomListener)(this.textarea,"compositionend",(()=>this._compositionHelper.compositionend()))),this.register((0,p.addDisposableDomListener)(this.textarea,"input",(K=>this._inputEvent(K)),!0)),this.register(this.onRender((()=>this._compositionHelper.updateCompositionElements())))}open(K){var ne;if(!K)throw new Error("Terminal requires a parent element.");if(K.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),((ne=this.element)==null?void 0:ne.ownerDocument.defaultView)&&this._coreBrowserService)return void(this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView));this._document=K.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"),K.appendChild(this.element);const B=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),B.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),B.appendChild(this.screenElement),this.textarea=this._document.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",g.promptLabel),U.isChromeOS||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._coreBrowserService=this.register(this._instantiationService.createInstance(T.CoreBrowserService,this.textarea,K.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(O.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(v.CharSizeService,this._document,this._helperContainer),this._instantiationService.setService(O.ICharSizeService,this._charSizeService),this._themeService=this._instantiationService.createInstance(P.ThemeService),this._instantiationService.setService(O.IThemeService,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(k.CharacterJoinerService),this._instantiationService.setService(O.ICharacterJoinerService,this._characterJoinerService),this._renderService=this.register(this._instantiationService.createInstance(R.RenderService,this.rows,this.screenElement)),this._instantiationService.setService(O.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(N.MouseService),this._instantiationService.setService(O.IMouseService,this._mouseService),this.linkifier=this.register(this._instantiationService.createInstance(m.Linkifier,this.screenElement)),this.element.appendChild(B);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(O.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($.AccessibilityManager,this)),this.register(this.optionsService.onSpecificOptionChange("screenReaderMode",(se=>this._handleScreenReaderModeOptionChange(se)))),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(_.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRulerWidth",(se=>{!this._overviewRulerRenderer&&se&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(_.OverviewRulerRenderer,this._viewportElement,this.screenElement)))})),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(b.DomRenderer,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){const K=this,B=this.element;function ne(oe){const ve=K._mouseService.getMouseReportCoords(oe,K.screenElement);if(!ve)return!1;let Se,$e;switch(oe.overrideType||oe.type){case"mousemove":$e=32,oe.buttons===void 0?(Se=3,oe.button!==void 0&&(Se=oe.button<3?oe.button:3)):Se=1&oe.buttons?0:4&oe.buttons?1:2&oe.buttons?2:3;break;case"mouseup":$e=0,Se=oe.button<3?oe.button:3;break;case"mousedown":$e=1,Se=oe.button<3?oe.button:3;break;case"wheel":if(K._customWheelEventHandler&&K._customWheelEventHandler(oe)===!1||K.viewport.getLinesScrolled(oe)===0)return!1;$e=oe.deltaY<0?0:1,Se=4;break;default:return!1}return!($e===void 0||Se===void 0||Se>4)&&K.coreMouseService.triggerMouseEvent({col:ve.col,row:ve.row,x:ve.x,y:ve.y,button:Se,action:$e,ctrl:oe.ctrlKey,alt:oe.altKey,shift:oe.shiftKey})}const se={mouseup:null,wheel:null,mousedrag:null,mousemove:null},re={mouseup:oe=>(ne(oe),oe.buttons||(this._document.removeEventListener("mouseup",se.mouseup),se.mousedrag&&this._document.removeEventListener("mousemove",se.mousedrag)),this.cancel(oe)),wheel:oe=>(ne(oe),this.cancel(oe,!0)),mousedrag:oe=>{oe.buttons&&ne(oe)},mousemove:oe=>{oe.buttons||ne(oe)}};this.register(this.coreMouseService.onProtocolChange((oe=>{oe?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(oe)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),8&oe?se.mousemove||(B.addEventListener("mousemove",re.mousemove),se.mousemove=re.mousemove):(B.removeEventListener("mousemove",se.mousemove),se.mousemove=null),16&oe?se.wheel||(B.addEventListener("wheel",re.wheel,{passive:!1}),se.wheel=re.wheel):(B.removeEventListener("wheel",se.wheel),se.wheel=null),2&oe?se.mouseup||(se.mouseup=re.mouseup):(this._document.removeEventListener("mouseup",se.mouseup),se.mouseup=null),4&oe?se.mousedrag||(se.mousedrag=re.mousedrag):(this._document.removeEventListener("mousemove",se.mousedrag),se.mousedrag=null)}))),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,p.addDisposableDomListener)(B,"mousedown",(oe=>{if(oe.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(oe))return ne(oe),se.mouseup&&this._document.addEventListener("mouseup",se.mouseup),se.mousedrag&&this._document.addEventListener("mousemove",se.mousedrag),this.cancel(oe)}))),this.register((0,p.addDisposableDomListener)(B,"wheel",(oe=>{if(!se.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(oe)===!1)return!1;if(!this.buffer.hasScrollback){const ve=this.viewport.getLinesScrolled(oe);if(ve===0)return;const Se=Q.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(oe.deltaY<0?"A":"B");let $e="";for(let ze=0;ze<Math.abs(ve);ze++)$e+=Se;return this.coreService.triggerDataEvent($e,!0),this.cancel(oe,!0)}return this.viewport.handleWheel(oe)?this.cancel(oe):void 0}}),{passive:!1})),this.register((0,p.addDisposableDomListener)(B,"touchstart",(oe=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(oe),this.cancel(oe)}),{passive:!0})),this.register((0,p.addDisposableDomListener)(B,"touchmove",(oe=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(oe)?void 0:this.cancel(oe)}),{passive:!1}))}refresh(K,B){var ne;(ne=this._renderService)==null||ne.refreshRows(K,B)}updateCursorStyle(K){var B;(B=this._selectionService)!=null&&B.shouldColumnSelect(K)?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(K,B,ne=0){var se;ne===1?(super.scrollLines(K,B,ne),this.refresh(0,this.rows-1)):(se=this.viewport)==null||se.scrollLines(K)}paste(K){(0,h.paste)(K,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(K){this._customKeyEventHandler=K}attachCustomWheelEventHandler(K){this._customWheelEventHandler=K}registerLinkProvider(K){return this._linkProviderService.registerLinkProvider(K)}registerCharacterJoiner(K){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");const B=this._characterJoinerService.register(K);return this.refresh(0,this.rows-1),B}deregisterCharacterJoiner(K){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(K)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(K){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+K)}registerDecoration(K){return this._decorationService.registerDecoration(K)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(K,B,ne){this._selectionService.setSelection(K,B,ne)}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 K;(K=this._selectionService)==null||K.clearSelection()}selectAll(){var K;(K=this._selectionService)==null||K.selectAll()}selectLines(K,B){var ne;(ne=this._selectionService)==null||ne.selectLines(K,B)}_keyDown(K){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(K)===!1)return!1;const B=this.browser.isMac&&this.options.macOptionIsMeta&&K.altKey;if(!B&&!this._compositionHelper.keydown(K))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;B||K.key!=="Dead"&&K.key!=="AltGraph"||(this._unprocessedDeadKey=!0);const ne=(0,X.evaluateKeyboardEvent)(K,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(K),ne.type===3||ne.type===2){const se=this.rows-1;return this.scrollLines(ne.type===2?-se:se),this.cancel(K,!0)}return ne.type===1&&this.selectAll(),!!this._isThirdLevelShift(this.browser,K)||(ne.cancel&&this.cancel(K,!0),!ne.key||!!(K.key&&!K.ctrlKey&&!K.altKey&&!K.metaKey&&K.key.length===1&&K.key.charCodeAt(0)>=65&&K.key.charCodeAt(0)<=90)||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):(ne.key!==Q.C0.ETX&&ne.key!==Q.C0.CR||(this.textarea.value=""),this._onKey.fire({key:ne.key,domEvent:K}),this._showCursor(),this.coreService.triggerDataEvent(ne.key,!0),!this.optionsService.rawOptions.screenReaderMode||K.altKey||K.ctrlKey?this.cancel(K,!0):void(this._keyDownHandled=!0))))}_isThirdLevelShift(K,B){const ne=K.isMac&&!this.options.macOptionIsMeta&&B.altKey&&!B.ctrlKey&&!B.metaKey||K.isWindows&&B.altKey&&B.ctrlKey&&!B.metaKey||K.isWindows&&B.getModifierState("AltGraph");return B.type==="keypress"?ne:ne&&(!B.keyCode||B.keyCode>47)}_keyUp(K){this._keyDownSeen=!1,this._customKeyEventHandler&&this._customKeyEventHandler(K)===!1||((function(B){return B.keyCode===16||B.keyCode===17||B.keyCode===18})(K)||this.focus(),this.updateCursorStyle(K),this._keyPressHandled=!1)}_keyPress(K){let B;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(K)===!1)return!1;if(this.cancel(K),K.charCode)B=K.charCode;else if(K.which===null||K.which===void 0)B=K.keyCode;else{if(K.which===0||K.charCode===0)return!1;B=K.which}return!(!B||(K.altKey||K.ctrlKey||K.metaKey)&&!this._isThirdLevelShift(this.browser,K)||(B=String.fromCharCode(B),this._onKey.fire({key:B,domEvent:K}),this._showCursor(),this.coreService.triggerDataEvent(B,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,0))}_inputEvent(K){if(K.data&&K.inputType==="insertText"&&(!K.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;const B=K.data;return this.coreService.triggerDataEvent(B,!0),this.cancel(K),!0}return!1}resize(K,B){K!==this.cols||B!==this.rows?super.resize(K,B):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(K,B){var ne,se;(ne=this._charSizeService)==null||ne.measure(),(se=this.viewport)==null||se.syncScrollArea(!0)}clear(){var K;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 B=1;B<this.rows;B++)this.buffer.lines.push(this.buffer.getBlankLine(F.DEFAULT_ATTR_DATA));this._onScroll.fire({position:this.buffer.ydisp,source:0}),(K=this.viewport)==null||K.reset(),this.refresh(0,this.rows-1)}}reset(){var B,ne;this.options.rows=this.rows,this.options.cols=this.cols;const K=this._customKeyEventHandler;this._setup(),super.reset(),(B=this._selectionService)==null||B.reset(),this._decorationService.reset(),(ne=this.viewport)==null||ne.reset(),this._customKeyEventHandler=K,this.refresh(0,this.rows-1)}clearTextureAtlas(){var K;(K=this._renderService)==null||K.clearTextureAtlas()}_reportFocus(){var K;(K=this.element)!=null&&K.classList.contains("focus")?this.coreService.triggerDataEvent(Q.C0.ESC+"[I"):this.coreService.triggerDataEvent(Q.C0.ESC+"[O")}_reportWindowsOptions(K){if(this._renderService)switch(K){case q.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:const B=this._renderService.dimensions.css.canvas.width.toFixed(0),ne=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${Q.C0.ESC}[4;${ne};${B}t`);break;case q.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:const se=this._renderService.dimensions.css.cell.width.toFixed(0),re=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${Q.C0.ESC}[6;${re};${se}t`)}}cancel(K,B){if(this.options.cancelEvents||B)return K.preventDefault(),K.stopPropagation(),!1}}c.Terminal=Y},9924:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.TimeBasedDebouncer=void 0,c.TimeBasedDebouncer=class{constructor(d,h=1e3){this._renderCallback=d,this._debounceThresholdMS=h,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(d,h,p){this._rowCount=p,d=d!==void 0?d:0,h=h!==void 0?h:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,d):d,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,h):h;const m=Date.now();if(m-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=m,this._innerRefresh();else if(!this._additionalRefreshRequested){const g=m-this._lastRefreshMs,y=this._debounceThresholdMS-g;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),h=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(d,h)}}},1680:function(u,c,d){var h=this&&this.__decorate||function(S,b,v,k){var T,N=arguments.length,R=N<3?b:k===null?k=Object.getOwnPropertyDescriptor(b,v):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(S,b,v,k);else for(var A=S.length-1;A>=0;A--)(T=S[A])&&(R=(N<3?T(R):N>3?T(b,v,R):T(b,v))||R);return N>3&&R&&Object.defineProperty(b,v,R),R},p=this&&this.__param||function(S,b){return function(v,k){b(v,k,S)}};Object.defineProperty(c,"__esModule",{value:!0}),c.Viewport=void 0;const m=d(3656),g=d(4725),y=d(8460),w=d(844),C=d(2585);let _=c.Viewport=class extends w.Disposable{constructor(S,b,v,k,T,N,R,A){super(),this._viewportElement=S,this._scrollArea=b,this._bufferService=v,this._optionsService=k,this._charSizeService=T,this._renderService=N,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((O=>this._activeBuffer=O.activeBuffer))),this._renderDimensions=this._renderService.dimensions,this.register(this._renderService.onDimensionsChange((O=>this._renderDimensions=O))),this._handleThemeChange(A.colors),this.register(A.onChangeColors((O=>this._handleThemeChange(O)))),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.syncScrollArea()))),setTimeout((()=>this.syncScrollArea()))}_handleThemeChange(S){this._viewportElement.style.backgroundColor=S.background.css}reset(){this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._coreBrowserService.window.requestAnimationFrame((()=>this.syncScrollArea()))}_refresh(S){if(S)return this._innerRefresh(),void(this._refreshAnimationFrame!==null&&this._coreBrowserService.window.cancelAnimationFrame(this._refreshAnimationFrame));this._refreshAnimationFrame===null&&(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._charSizeService.height>0){this._currentRowHeight=this._renderDimensions.device.cell.height/this._coreBrowserService.dpr,this._currentDeviceCellHeight=this._renderDimensions.device.cell.height,this._lastRecordedViewportHeight=this._viewportElement.offsetHeight;const b=Math.round(this._currentRowHeight*this._lastRecordedBufferLength)+(this._lastRecordedViewportHeight-this._renderDimensions.css.canvas.height);this._lastRecordedBufferHeight!==b&&(this._lastRecordedBufferHeight=b,this._scrollArea.style.height=this._lastRecordedBufferHeight+"px")}const S=this._bufferService.buffer.ydisp*this._currentRowHeight;this._viewportElement.scrollTop!==S&&(this._ignoreNextScrollEvent=!0,this._viewportElement.scrollTop=S),this._refreshAnimationFrame=null}syncScrollArea(S=!1){if(this._lastRecordedBufferLength!==this._bufferService.buffer.lines.length)return this._lastRecordedBufferLength=this._bufferService.buffer.lines.length,void this._refresh(S);this._lastRecordedViewportHeight===this._renderService.dimensions.css.canvas.height&&this._lastScrollTop===this._activeBuffer.ydisp*this._currentRowHeight&&this._renderDimensions.device.cell.height===this._currentDeviceCellHeight||this._refresh(S)}_handleScroll(S){if(this._lastScrollTop=this._viewportElement.scrollTop,!this._viewportElement.offsetParent)return;if(this._ignoreNextScrollEvent)return this._ignoreNextScrollEvent=!1,void this._onRequestScrollLines.fire({amount:0,suppressScrollEvent:!0});const b=Math.round(this._lastScrollTop/this._currentRowHeight)-this._bufferService.buffer.ydisp;this._onRequestScrollLines.fire({amount:b,suppressScrollEvent:!0})}_smoothScroll(){if(this._isDisposed||this._smoothScrollState.origin===-1||this._smoothScrollState.target===-1)return;const S=this._smoothScrollPercent();this._viewportElement.scrollTop=this._smoothScrollState.origin+Math.round(S*(this._smoothScrollState.target-this._smoothScrollState.origin)),S<1?this._coreBrowserService.window.requestAnimationFrame((()=>this._smoothScroll())):this._clearSmoothScrollState()}_smoothScrollPercent(){return this._optionsService.rawOptions.smoothScrollDuration&&this._smoothScrollState.startTime?Math.max(Math.min((Date.now()-this._smoothScrollState.startTime)/this._optionsService.rawOptions.smoothScrollDuration,1),0):1}_clearSmoothScrollState(){this._smoothScrollState.startTime=0,this._smoothScrollState.origin=-1,this._smoothScrollState.target=-1}_bubbleScroll(S,b){const v=this._viewportElement.scrollTop+this._lastRecordedViewportHeight;return!(b<0&&this._viewportElement.scrollTop!==0||b>0&&v<this._lastRecordedBufferHeight)||(S.cancelable&&S.preventDefault(),!1)}handleWheel(S){const b=this._getPixelsScrolled(S);return b!==0&&(this._optionsService.rawOptions.smoothScrollDuration?(this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target===-1?this._smoothScrollState.target=this._viewportElement.scrollTop+b:this._smoothScrollState.target+=b,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()):this._viewportElement.scrollTop+=b,this._bubbleScroll(S,b))}scrollLines(S){if(S!==0)if(this._optionsService.rawOptions.smoothScrollDuration){const b=S*this._currentRowHeight;this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target=this._smoothScrollState.origin+b,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()}else this._onRequestScrollLines.fire({amount:S,suppressScrollEvent:!1})}_getPixelsScrolled(S){if(S.deltaY===0||S.shiftKey)return 0;let b=this._applyScrollModifier(S.deltaY,S);return S.deltaMode===WheelEvent.DOM_DELTA_LINE?b*=this._currentRowHeight:S.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(b*=this._currentRowHeight*this._bufferService.rows),b}getBufferElements(S,b){var A;let v,k="";const T=[],N=b??this._bufferService.buffer.lines.length,R=this._bufferService.buffer.lines;for(let O=S;O<N;O++){const P=R.get(O);if(!P)continue;const V=(A=R.get(O+1))==null?void 0:A.isWrapped;if(k+=P.translateToString(!V),!V||O===R.length-1){const z=document.createElement("div");z.textContent=k,T.push(z),k.length>0&&(v=z),k=""}}return{bufferElements:T,cursorElement:v}}getLinesScrolled(S){if(S.deltaY===0||S.shiftKey)return 0;let b=this._applyScrollModifier(S.deltaY,S);return S.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(b/=this._currentRowHeight+0,this._wheelPartialScroll+=b,b=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):S.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(b*=this._bufferService.rows),b}_applyScrollModifier(S,b){const v=this._optionsService.rawOptions.fastScrollModifier;return v==="alt"&&b.altKey||v==="ctrl"&&b.ctrlKey||v==="shift"&&b.shiftKey?S*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:S*this._optionsService.rawOptions.scrollSensitivity}handleTouchStart(S){this._lastTouchY=S.touches[0].pageY}handleTouchMove(S){const b=this._lastTouchY-S.touches[0].pageY;return this._lastTouchY=S.touches[0].pageY,b!==0&&(this._viewportElement.scrollTop+=b,this._bubbleScroll(S,b))}};c.Viewport=_=h([p(2,C.IBufferService),p(3,C.IOptionsService),p(4,g.ICharSizeService),p(5,g.IRenderService),p(6,g.ICoreBrowserService),p(7,g.IThemeService)],_)},3107:function(u,c,d){var h=this&&this.__decorate||function(C,_,S,b){var v,k=arguments.length,T=k<3?_:b===null?b=Object.getOwnPropertyDescriptor(_,S):b;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")T=Reflect.decorate(C,_,S,b);else for(var N=C.length-1;N>=0;N--)(v=C[N])&&(T=(k<3?v(T):k>3?v(_,S,T):v(_,S))||T);return k>3&&T&&Object.defineProperty(_,S,T),T},p=this&&this.__param||function(C,_){return function(S,b){_(S,b,C)}};Object.defineProperty(c,"__esModule",{value:!0}),c.BufferDecorationRenderer=void 0;const m=d(4725),g=d(844),y=d(2585);let w=c.BufferDecorationRenderer=class extends g.Disposable{constructor(C,_,S,b,v){super(),this._screenElement=C,this._bufferService=_,this._coreBrowserService=S,this._decorationService=b,this._renderService=v,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this.register(this._renderService.onRenderedViewportChange((()=>this._doRefreshDecorations()))),this.register(this._renderService.onDimensionsChange((()=>{this._dimensionsChanged=!0,this._queueRefresh()}))),this.register(this._coreBrowserService.onDprChange((()=>this._queueRefresh()))),this.register(this._bufferService.buffers.onBufferActivate((()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt}))),this.register(this._decorationService.onDecorationRegistered((()=>this._queueRefresh()))),this.register(this._decorationService.onDecorationRemoved((k=>this._removeDecoration(k)))),this.register((0,g.toDisposable)((()=>{this._container.remove(),this._decorationElements.clear()})))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback((()=>{this._doRefreshDecorations(),this._animationFrame=void 0})))}_doRefreshDecorations(){for(const C of this._decorationService.decorations)this._renderDecoration(C);this._dimensionsChanged=!1}_renderDecoration(C){this._refreshStyle(C),this._dimensionsChanged&&this._refreshXPosition(C)}_createElement(C){var b;const _=this._coreBrowserService.mainDocument.createElement("div");_.classList.add("xterm-decoration"),_.classList.toggle("xterm-decoration-top-layer",((b=C==null?void 0:C.options)==null?void 0:b.layer)==="top"),_.style.width=`${Math.round((C.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,_.style.height=(C.options.height||1)*this._renderService.dimensions.css.cell.height+"px",_.style.top=(C.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height+"px",_.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;const S=C.options.x??0;return S&&S>this._bufferService.cols&&(_.style.display="none"),this._refreshXPosition(C,_),_}_refreshStyle(C){const _=C.marker.line-this._bufferService.buffers.active.ydisp;if(_<0||_>=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=_*this._renderService.dimensions.css.cell.height+"px",S.style.display=this._altBufferIsActive?"none":"block",C.onRenderEmitter.fire(S)}}_refreshXPosition(C,_=C.element){if(!_)return;const S=C.options.x??0;(C.options.anchor||"left")==="right"?_.style.right=S?S*this._renderService.dimensions.css.cell.width+"px":"":_.style.left=S?S*this._renderService.dimensions.css.cell.width+"px":""}_removeDecoration(C){var _;(_=this._decorationElements.get(C))==null||_.remove(),this._decorationElements.delete(C),C.dispose()}};c.BufferDecorationRenderer=w=h([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 h of this._zones)if(h.color===d.options.overviewRulerOptions.color&&h.position===d.options.overviewRulerOptions.position){if(this._lineIntersectsZone(h,d.marker.line))return;if(this._lineAdjacentToZone(h,d.marker.line,d.options.overviewRulerOptions.position))return void this._addLineToZone(h,d.marker.line)}if(this._zonePoolIndex<this._zonePool.length)return this._zonePool[this._zonePoolIndex].color=d.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=d.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=d.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=d.marker.line,void this._zones.push(this._zonePool[this._zonePoolIndex++]);this._zones.push({color:d.options.overviewRulerOptions.color,position:d.options.overviewRulerOptions.position,startBufferLine:d.marker.line,endBufferLine:d.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(d){this._linePadding=d}_lineIntersectsZone(d,h){return h>=d.startBufferLine&&h<=d.endBufferLine}_lineAdjacentToZone(d,h,p){return h>=d.startBufferLine-this._linePadding[p||"full"]&&h<=d.endBufferLine+this._linePadding[p||"full"]}_addLineToZone(d,h){d.startBufferLine=Math.min(d.startBufferLine,h),d.endBufferLine=Math.max(d.endBufferLine,h)}}},5744:function(u,c,d){var h=this&&this.__decorate||function(v,k,T,N){var R,A=arguments.length,O=A<3?k:N===null?N=Object.getOwnPropertyDescriptor(k,T):N;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")O=Reflect.decorate(v,k,T,N);else for(var P=v.length-1;P>=0;P--)(R=v[P])&&(O=(A<3?R(O):A>3?R(k,T,O):R(k,T))||O);return A>3&&O&&Object.defineProperty(k,T,O),O},p=this&&this.__param||function(v,k){return function(T,N){k(T,N,v)}};Object.defineProperty(c,"__esModule",{value:!0}),c.OverviewRulerRenderer=void 0;const m=d(5871),g=d(4725),y=d(844),w=d(2585),C={full:0,left:0,center:0,right:0},_={full:0,left:0,center:0,right:0},S={full:0,left:0,center:0,right:0};let b=c.OverviewRulerRenderer=class extends y.Disposable{get _width(){return this._optionsService.options.overviewRulerWidth||0}constructor(v,k,T,N,R,A,O){var V;super(),this._viewportElement=v,this._screenElement=k,this._bufferService=T,this._decorationService=N,this._renderService=R,this._optionsService=A,this._coreBrowserService=O,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(),(V=this._viewportElement.parentElement)==null||V.insertBefore(this._canvas,this._viewportElement);const P=this._canvas.getContext("2d");if(!P)throw new Error("Ctx cannot be null");this._ctx=P,this._registerDecorationListeners(),this._registerBufferChangeListeners(),this._registerDimensionChangeListeners(),this.register((0,y.toDisposable)((()=>{var z;(z=this._canvas)==null||z.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 v=Math.floor(this._canvas.width/3),k=Math.ceil(this._canvas.width/3);_.full=this._canvas.width,_.left=v,_.center=k,_.right=v,this._refreshDrawHeightConstants(),S.full=0,S.left=0,S.center=_.left,S.right=_.left+_.center}_refreshDrawHeightConstants(){C.full=Math.round(2*this._coreBrowserService.dpr);const v=this._canvas.height/this._bufferService.buffer.lines.length,k=Math.round(Math.max(Math.min(v,12),6)*this._coreBrowserService.dpr);C.left=k,C.center=k,C.right=k}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*C.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*C.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*C.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*C.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(const k of this._decorationService.decorations)this._colorZoneStore.addDecoration(k);this._ctx.lineWidth=1;const v=this._colorZoneStore.zones;for(const k of v)k.position!=="full"&&this._renderColorZone(k);for(const k of v)k.position==="full"&&this._renderColorZone(k);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderColorZone(v){this._ctx.fillStyle=v.color,this._ctx.fillRect(S[v.position||"full"],Math.round((this._canvas.height-1)*(v.startBufferLine/this._bufferService.buffers.active.lines.length)-C[v.position||"full"]/2),_[v.position||"full"],Math.round((this._canvas.height-1)*((v.endBufferLine-v.startBufferLine)/this._bufferService.buffers.active.lines.length)+C[v.position||"full"]))}_queueRefresh(v,k){this._shouldUpdateDimensions=v||this._shouldUpdateDimensions,this._shouldUpdateAnchor=k||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>{this._refreshDecorations(),this._animationFrame=void 0})))}};c.OverviewRulerRenderer=b=h([p(2,w.IBufferService),p(3,w.IDecorationService),p(4,g.IRenderService),p(5,w.IOptionsService),p(6,g.ICoreBrowserService)],b)},2950:function(u,c,d){var h=this&&this.__decorate||function(C,_,S,b){var v,k=arguments.length,T=k<3?_:b===null?b=Object.getOwnPropertyDescriptor(_,S):b;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")T=Reflect.decorate(C,_,S,b);else for(var N=C.length-1;N>=0;N--)(v=C[N])&&(T=(k<3?v(T):k>3?v(_,S,T):v(_,S))||T);return k>3&&T&&Object.defineProperty(_,S,T),T},p=this&&this.__param||function(C,_){return function(S,b){_(S,b,C)}};Object.defineProperty(c,"__esModule",{value:!0}),c.CompositionHelper=void 0;const m=d(4725),g=d(2585),y=d(2584);let w=c.CompositionHelper=class{get isComposing(){return this._isComposing}constructor(C,_,S,b,v,k){this._textarea=C,this._compositionView=_,this._bufferService=S,this._optionsService=b,this._coreService=v,this._renderService=k,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(C){this._compositionView.textContent=C.data,this.updateCompositionElements(),setTimeout((()=>{this._compositionPosition.end=this._textarea.value.length}),0)}compositionend(){this._finalizeComposition(!0)}keydown(C){if(this._isComposing||this._isSendingComposition){if(C.keyCode===229||C.keyCode===16||C.keyCode===17||C.keyCode===18)return!1;this._finalizeComposition(!1)}return C.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(C){if(this._compositionView.classList.remove("active"),this._isComposing=!1,C){const _={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout((()=>{if(this._isSendingComposition){let S;this._isSendingComposition=!1,_.start+=this._dataAlreadySent.length,S=this._isComposing?this._textarea.value.substring(_.start,_.end):this._textarea.value.substring(_.start),S.length>0&&this._coreService.triggerDataEvent(S,!0)}}),0)}else{this._isSendingComposition=!1;const _=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(_,!0)}}_handleAnyTextareaChanges(){const C=this._textarea.value;setTimeout((()=>{if(!this._isComposing){const _=this._textarea.value,S=_.replace(C,"");this._dataAlreadySent=S,_.length>C.length?this._coreService.triggerDataEvent(S,!0):_.length<C.length?this._coreService.triggerDataEvent(`${y.C0.DEL}`,!0):_.length===C.length&&_!==C&&this._coreService.triggerDataEvent(_,!0)}}),0)}updateCompositionElements(C){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){const _=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),S=this._renderService.dimensions.css.cell.height,b=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,v=_*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=v+"px",this._compositionView.style.top=b+"px",this._compositionView.style.height=S+"px",this._compositionView.style.lineHeight=S+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";const k=this._compositionView.getBoundingClientRect();this._textarea.style.left=v+"px",this._textarea.style.top=b+"px",this._textarea.style.width=Math.max(k.width,1)+"px",this._textarea.style.height=Math.max(k.height,1)+"px",this._textarea.style.lineHeight=k.height+"px"}C||setTimeout((()=>this.updateCompositionElements(!0)),0)}}};c.CompositionHelper=w=h([p(2,g.IBufferService),p(3,g.IOptionsService),p(4,g.ICoreService),p(5,m.IRenderService)],w)},9806:(u,c)=>{function d(h,p,m){const g=m.getBoundingClientRect(),y=h.getComputedStyle(m),w=parseInt(y.getPropertyValue("padding-left")),C=parseInt(y.getPropertyValue("padding-top"));return[p.clientX-g.left-w,p.clientY-g.top-C]}Object.defineProperty(c,"__esModule",{value:!0}),c.getCoords=c.getCoordsRelativeToElement=void 0,c.getCoordsRelativeToElement=d,c.getCoords=function(h,p,m,g,y,w,C,_,S){if(!w)return;const b=d(h,p,m);return b?(b[0]=Math.ceil((b[0]+(S?C/2:0))/C),b[1]=Math.ceil(b[1]/_),b[0]=Math.min(Math.max(b[0],1),g+(S?1:0)),b[1]=Math.min(Math.max(b[1],1),y),b):void 0}},9504:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.moveToCellSequence=void 0;const h=d(2584);function p(_,S,b,v){const k=_-m(_,b),T=S-m(S,b),N=Math.abs(k-T)-(function(R,A,O){let P=0;const V=R-m(R,O),z=A-m(A,O);for(let W=0;W<Math.abs(V-z);W++){const M=g(R,A)==="A"?-1:1,U=O.buffer.lines.get(V+M*W);U!=null&&U.isWrapped&&P++}return P})(_,S,b);return C(N,w(g(_,S),v))}function m(_,S){let b=0,v=S.buffer.lines.get(_),k=v==null?void 0:v.isWrapped;for(;k&&_>=0&&_<S.rows;)b++,v=S.buffer.lines.get(--_),k=v==null?void 0:v.isWrapped;return b}function g(_,S){return _>S?"A":"B"}function y(_,S,b,v,k,T){let N=_,R=S,A="";for(;N!==b||R!==v;)N+=k?1:-1,k&&N>T.cols-1?(A+=T.buffer.translateBufferLineToString(R,!1,_,N),N=0,_=0,R++):!k&&N<0&&(A+=T.buffer.translateBufferLineToString(R,!1,0,_+1),N=T.cols-1,_=N,R--);return A+T.buffer.translateBufferLineToString(R,!1,_,N)}function w(_,S){const b=S?"O":"[";return h.C0.ESC+b+_}function C(_,S){_=Math.floor(_);let b="";for(let v=0;v<_;v++)b+=S;return b}c.moveToCellSequence=function(_,S,b,v){const k=b.buffer.x,T=b.buffer.y;if(!b.buffer.hasScrollback)return(function(A,O,P,V,z,W){return p(O,V,z,W).length===0?"":C(y(A,O,A,O-m(O,z),!1,z).length,w("D",W))})(k,T,0,S,b,v)+p(T,S,b,v)+(function(A,O,P,V,z,W){let M;M=p(O,V,z,W).length>0?V-m(V,z):O;const U=V,F=(function(Q,X,H,I,D,q){let $;return $=p(H,I,D,q).length>0?I-m(I,D):X,Q<H&&$<=I||Q>=H&&$<I?"C":"D"})(A,O,P,V,z,W);return C(y(A,M,P,U,F==="C",z).length,w(F,W))})(k,T,_,S,b,v);let N;if(T===S)return N=k>_?"D":"C",C(Math.abs(k-_),w(N,v));N=T>S?"D":"C";const R=Math.abs(T-S);return C((function(A,O){return O.cols-A})(T>S?_:k,b)+(R-1)*b.cols+1+((T>S?k:_)-1),w(N,v))}},1296:function(u,c,d){var h=this&&this.__decorate||function(W,M,U,F){var Q,X=arguments.length,H=X<3?M:F===null?F=Object.getOwnPropertyDescriptor(M,U):F;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")H=Reflect.decorate(W,M,U,F);else for(var I=W.length-1;I>=0;I--)(Q=W[I])&&(H=(X<3?Q(H):X>3?Q(M,U,H):Q(M,U))||H);return X>3&&H&&Object.defineProperty(M,U,H),H},p=this&&this.__param||function(W,M){return function(U,F){M(U,F,W)}};Object.defineProperty(c,"__esModule",{value:!0}),c.DomRenderer=void 0;const m=d(3787),g=d(2550),y=d(2223),w=d(6171),C=d(6052),_=d(4725),S=d(8055),b=d(8460),v=d(844),k=d(2585),T="xterm-dom-renderer-owner-",N="xterm-rows",R="xterm-fg-",A="xterm-bg-",O="xterm-focus",P="xterm-selection";let V=1,z=c.DomRenderer=class extends v.Disposable{constructor(W,M,U,F,Q,X,H,I,D,q,$,J,Y){super(),this._terminal=W,this._document=M,this._element=U,this._screenElement=F,this._viewportElement=Q,this._helperContainer=X,this._linkifier2=H,this._charSizeService=D,this._optionsService=q,this._bufferService=$,this._coreBrowserService=J,this._themeService=Y,this._terminalClass=V++,this._rowElements=[],this._selectionRenderModel=(0,C.createSelectionRenderModel)(),this.onRequestRedraw=this.register(new b.EventEmitter).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(N),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(P),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=(0,w.createRenderDimensions)(),this._updateDimensions(),this.register(this._optionsService.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._themeService.onChangeColors((Z=>this._injectCss(Z)))),this._injectCss(this._themeService.colors),this._rowFactory=I.createInstance(m.DomRendererRowFactory,document),this._element.classList.add(T+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this.register(this._linkifier2.onShowLinkUnderline((Z=>this._handleLinkHover(Z)))),this.register(this._linkifier2.onHideLinkUnderline((Z=>this._handleLinkLeave(Z)))),this.register((0,v.toDisposable)((()=>{this._element.classList.remove(T+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()}))),this._widthCache=new g.WidthCache(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){const W=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*W,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*W),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/W),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/W),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 U of this._rowElements)U.style.width=`${this.dimensions.css.canvas.width}px`,U.style.height=`${this.dimensions.css.cell.height}px`,U.style.lineHeight=`${this.dimensions.css.cell.height}px`,U.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));const M=`${this._terminalSelector} .${N} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=M,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(W){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let M=`${this._terminalSelector} .${N} { color: ${W.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;M+=`${this._terminalSelector} .${N} .xterm-dim { color: ${S.color.multiplyOpacity(W.foreground,.5).css};}`,M+=`${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 U=`blink_underline_${this._terminalClass}`,F=`blink_bar_${this._terminalClass}`,Q=`blink_block_${this._terminalClass}`;M+=`@keyframes ${U} { 50% { border-bottom-style: hidden; }}`,M+=`@keyframes ${F} { 50% { box-shadow: none; }}`,M+=`@keyframes ${Q} { 0% { background-color: ${W.cursor.css}; color: ${W.cursorAccent.css}; } 50% { background-color: inherit; color: ${W.cursor.css}; }}`,M+=`${this._terminalSelector} .${N}.${O} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${U} 1s step-end infinite;}${this._terminalSelector} .${N}.${O} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${F} 1s step-end infinite;}${this._terminalSelector} .${N}.${O} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${Q} 1s step-end infinite;}${this._terminalSelector} .${N} .xterm-cursor.xterm-cursor-block { background-color: ${W.cursor.css}; color: ${W.cursorAccent.css};}${this._terminalSelector} .${N} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${W.cursor.css} !important; color: ${W.cursorAccent.css} !important;}${this._terminalSelector} .${N} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${W.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${N} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${W.cursor.css} inset;}${this._terminalSelector} .${N} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${W.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,M+=`${this._terminalSelector} .${P} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${P} div { position: absolute; background-color: ${W.selectionBackgroundOpaque.css};}${this._terminalSelector} .${P} div { position: absolute; background-color: ${W.selectionInactiveBackgroundOpaque.css};}`;for(const[X,H]of W.ansi.entries())M+=`${this._terminalSelector} .${R}${X} { color: ${H.css}; }${this._terminalSelector} .${R}${X}.xterm-dim { color: ${S.color.multiplyOpacity(H,.5).css}; }${this._terminalSelector} .${A}${X} { background-color: ${H.css}; }`;M+=`${this._terminalSelector} .${R}${y.INVERTED_DEFAULT_COLOR} { color: ${S.color.opaque(W.background).css}; }${this._terminalSelector} .${R}${y.INVERTED_DEFAULT_COLOR}.xterm-dim { color: ${S.color.multiplyOpacity(S.color.opaque(W.background),.5).css}; }${this._terminalSelector} .${A}${y.INVERTED_DEFAULT_COLOR} { background-color: ${W.foreground.css}; }`,this._themeStyleElement.textContent=M}_setDefaultSpacing(){const W=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${W}px`,this._rowFactory.defaultSpacing=W}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(W,M){for(let U=this._rowElements.length;U<=M;U++){const F=this._document.createElement("div");this._rowContainer.appendChild(F),this._rowElements.push(F)}for(;this._rowElements.length>M;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(W,M){this._refreshRowElements(W,M),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(O),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(O),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(W,M,U){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(W,M,U),this.renderRows(0,this._bufferService.rows-1),!W||!M)return;this._selectionRenderModel.update(this._terminal,W,M,U);const F=this._selectionRenderModel.viewportStartRow,Q=this._selectionRenderModel.viewportEndRow,X=this._selectionRenderModel.viewportCappedStartRow,H=this._selectionRenderModel.viewportCappedEndRow;if(X>=this._bufferService.rows||H<0)return;const I=this._document.createDocumentFragment();if(U){const D=W[0]>M[0];I.appendChild(this._createSelectionElement(X,D?M[0]:W[0],D?W[0]:M[0],H-X+1))}else{const D=F===X?W[0]:0,q=X===Q?M[0]:this._bufferService.cols;I.appendChild(this._createSelectionElement(X,D,q));const $=H-X-1;if(I.appendChild(this._createSelectionElement(X+1,0,this._bufferService.cols,$)),X!==H){const J=Q===H?M[0]:this._bufferService.cols;I.appendChild(this._createSelectionElement(H,0,J))}}this._selectionContainer.appendChild(I)}_createSelectionElement(W,M,U,F=1){const Q=this._document.createElement("div"),X=M*this.dimensions.css.cell.width;let H=this.dimensions.css.cell.width*(U-M);return X+H>this.dimensions.css.canvas.width&&(H=this.dimensions.css.canvas.width-X),Q.style.height=F*this.dimensions.css.cell.height+"px",Q.style.top=W*this.dimensions.css.cell.height+"px",Q.style.left=`${X}px`,Q.style.width=`${H}px`,Q}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(const W of this._rowElements)W.replaceChildren()}renderRows(W,M){const U=this._bufferService.buffer,F=U.ybase+U.y,Q=Math.min(U.x,this._bufferService.cols-1),X=this._optionsService.rawOptions.cursorBlink,H=this._optionsService.rawOptions.cursorStyle,I=this._optionsService.rawOptions.cursorInactiveStyle;for(let D=W;D<=M;D++){const q=D+U.ydisp,$=this._rowElements[D],J=U.lines.get(q);if(!$||!J)break;$.replaceChildren(...this._rowFactory.createRow(J,q,q===F,H,I,Q,X,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${T}${this._terminalClass}`}_handleLinkHover(W){this._setCellUnderline(W.x1,W.x2,W.y1,W.y2,W.cols,!0)}_handleLinkLeave(W){this._setCellUnderline(W.x1,W.x2,W.y1,W.y2,W.cols,!1)}_setCellUnderline(W,M,U,F,Q,X){U<0&&(W=0),F<0&&(M=0);const H=this._bufferService.rows-1;U=Math.max(Math.min(U,H),0),F=Math.max(Math.min(F,H),0),Q=Math.min(Q,this._bufferService.cols);const I=this._bufferService.buffer,D=I.ybase+I.y,q=Math.min(I.x,Q-1),$=this._optionsService.rawOptions.cursorBlink,J=this._optionsService.rawOptions.cursorStyle,Y=this._optionsService.rawOptions.cursorInactiveStyle;for(let Z=U;Z<=F;++Z){const K=Z+I.ydisp,B=this._rowElements[Z],ne=I.lines.get(K);if(!B||!ne)break;B.replaceChildren(...this._rowFactory.createRow(ne,K,K===D,J,Y,q,$,this.dimensions.css.cell.width,this._widthCache,X?Z===U?W:0:-1,X?(Z===F?M:Q)-1:-1))}}};c.DomRenderer=z=h([p(7,k.IInstantiationService),p(8,_.ICharSizeService),p(9,k.IOptionsService),p(10,k.IBufferService),p(11,_.ICoreBrowserService),p(12,_.IThemeService)],z)},3787:function(u,c,d){var h=this&&this.__decorate||function(N,R,A,O){var P,V=arguments.length,z=V<3?R:O===null?O=Object.getOwnPropertyDescriptor(R,A):O;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")z=Reflect.decorate(N,R,A,O);else for(var W=N.length-1;W>=0;W--)(P=N[W])&&(z=(V<3?P(z):V>3?P(R,A,z):P(R,A))||z);return V>3&&z&&Object.defineProperty(R,A,z),z},p=this&&this.__param||function(N,R){return function(A,O){R(A,O,N)}};Object.defineProperty(c,"__esModule",{value:!0}),c.DomRendererRowFactory=void 0;const m=d(2223),g=d(643),y=d(511),w=d(2585),C=d(8055),_=d(4725),S=d(4269),b=d(6171),v=d(3734);let k=c.DomRendererRowFactory=class{constructor(N,R,A,O,P,V,z){this._document=N,this._characterJoinerService=R,this._optionsService=A,this._coreBrowserService=O,this._coreService=P,this._decorationService=V,this._themeService=z,this._workCell=new y.CellData,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(N,R,A){this._selectionStart=N,this._selectionEnd=R,this._columnSelectMode=A}createRow(N,R,A,O,P,V,z,W,M,U,F){const Q=[],X=this._characterJoinerService.getJoinedCharacters(R),H=this._themeService.colors;let I,D=N.getNoBgTrimmedLength();A&&D<V+1&&(D=V+1);let q=0,$="",J=0,Y=0,Z=0,K=!1,B=0,ne=!1,se=0;const re=[],oe=U!==-1&&F!==-1;for(let ve=0;ve<D;ve++){N.loadCell(ve,this._workCell);let Se=this._workCell.getWidth();if(Se===0)continue;let $e=!1,ze=ve,ke=this._workCell;if(X.length>0&&ve===X[0][0]){$e=!0;const Ue=X.shift();ke=new S.JoinedCellData(this._workCell,N.translateToString(!0,Ue[0],Ue[1]),Ue[1]-Ue[0]),ze=Ue[1]-1,Se=ke.getWidth()}const Ge=this._isCellInSelection(ve,R),Je=A&&ve===V,Ce=oe&&ve>=U&&ve<=F;let me=!1;this._decorationService.forEachDecorationAtCell(ve,R,void 0,(Ue=>{me=!0}));let We=ke.getChars()||g.WHITESPACE_CELL_CHAR;if(We===" "&&(ke.isUnderline()||ke.isOverline())&&(We=" "),se=Se*W-M.get(We,ke.isBold(),ke.isItalic()),I){if(q&&(Ge&&ne||!Ge&&!ne&&ke.bg===J)&&(Ge&&ne&&H.selectionForeground||ke.fg===Y)&&ke.extended.ext===Z&&Ce===K&&se===B&&!Je&&!$e&&!me){ke.isInvisible()?$+=g.WHITESPACE_CELL_CHAR:$+=We,q++;continue}q&&(I.textContent=$),I=this._document.createElement("span"),q=0,$=""}else I=this._document.createElement("span");if(J=ke.bg,Y=ke.fg,Z=ke.extended.ext,K=Ce,B=se,ne=Ge,$e&&V>=ve&&V<=ze&&(V=ve),!this._coreService.isCursorHidden&&Je&&this._coreService.isCursorInitialized){if(re.push("xterm-cursor"),this._coreBrowserService.isFocused)z&&re.push("xterm-cursor-blink"),re.push(O==="bar"?"xterm-cursor-bar":O==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(P)switch(P){case"outline":re.push("xterm-cursor-outline");break;case"block":re.push("xterm-cursor-block");break;case"bar":re.push("xterm-cursor-bar");break;case"underline":re.push("xterm-cursor-underline")}}if(ke.isBold()&&re.push("xterm-bold"),ke.isItalic()&&re.push("xterm-italic"),ke.isDim()&&re.push("xterm-dim"),$=ke.isInvisible()?g.WHITESPACE_CELL_CHAR:ke.getChars()||g.WHITESPACE_CELL_CHAR,ke.isUnderline()&&(re.push(`xterm-underline-${ke.extended.underlineStyle}`),$===" "&&($=" "),!ke.isUnderlineColorDefault()))if(ke.isUnderlineColorRGB())I.style.textDecorationColor=`rgb(${v.AttributeData.toColorRGB(ke.getUnderlineColor()).join(",")})`;else{let Ue=ke.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&ke.isBold()&&Ue<8&&(Ue+=8),I.style.textDecorationColor=H.ansi[Ue].css}ke.isOverline()&&(re.push("xterm-overline"),$===" "&&($=" ")),ke.isStrikethrough()&&re.push("xterm-strikethrough"),Ce&&(I.style.textDecoration="underline");let he=ke.getFgColor(),Ve=ke.getFgColorMode(),He=ke.getBgColor(),ie=ke.getBgColorMode();const ye=!!ke.isInverse();if(ye){const Ue=he;he=He,He=Ue;const Qe=Ve;Ve=ie,ie=Qe}let Le,ue,de,Fe=!1;switch(this._decorationService.forEachDecorationAtCell(ve,R,void 0,(Ue=>{Ue.options.layer!=="top"&&Fe||(Ue.backgroundColorRGB&&(ie=50331648,He=Ue.backgroundColorRGB.rgba>>8&16777215,Le=Ue.backgroundColorRGB),Ue.foregroundColorRGB&&(Ve=50331648,he=Ue.foregroundColorRGB.rgba>>8&16777215,ue=Ue.foregroundColorRGB),Fe=Ue.options.layer==="top")})),!Fe&&Ge&&(Le=this._coreBrowserService.isFocused?H.selectionBackgroundOpaque:H.selectionInactiveBackgroundOpaque,He=Le.rgba>>8&16777215,ie=50331648,Fe=!0,H.selectionForeground&&(Ve=50331648,he=H.selectionForeground.rgba>>8&16777215,ue=H.selectionForeground)),Fe&&re.push("xterm-decoration-top"),ie){case 16777216:case 33554432:de=H.ansi[He],re.push(`xterm-bg-${He}`);break;case 50331648:de=C.channels.toColor(He>>16,He>>8&255,255&He),this._addStyle(I,`background-color:#${T((He>>>0).toString(16),"0",6)}`);break;default:ye?(de=H.foreground,re.push(`xterm-bg-${m.INVERTED_DEFAULT_COLOR}`)):de=H.background}switch(Le||ke.isDim()&&(Le=C.color.multiplyOpacity(de,.5)),Ve){case 16777216:case 33554432:ke.isBold()&&he<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(he+=8),this._applyMinimumContrast(I,de,H.ansi[he],ke,Le,void 0)||re.push(`xterm-fg-${he}`);break;case 50331648:const Ue=C.channels.toColor(he>>16&255,he>>8&255,255&he);this._applyMinimumContrast(I,de,Ue,ke,Le,ue)||this._addStyle(I,`color:#${T(he.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(I,de,H.foreground,ke,Le,ue)||ye&&re.push(`xterm-fg-${m.INVERTED_DEFAULT_COLOR}`)}re.length&&(I.className=re.join(" "),re.length=0),Je||$e||me?I.textContent=$:q++,se!==this.defaultSpacing&&(I.style.letterSpacing=`${se}px`),Q.push(I),ve=ze}return I&&q&&(I.textContent=$),Q}_applyMinimumContrast(N,R,A,O,P,V){if(this._optionsService.rawOptions.minimumContrastRatio===1||(0,b.treatGlyphAsBackgroundColor)(O.getCode()))return!1;const z=this._getContrastCache(O);let W;if(P||V||(W=z.getColor(R.rgba,A.rgba)),W===void 0){const M=this._optionsService.rawOptions.minimumContrastRatio/(O.isDim()?2:1);W=C.color.ensureContrastRatio(P||R,V||A,M),z.setColor((P||R).rgba,(V||A).rgba,W??null)}return!!W&&(this._addStyle(N,`color:${W.css}`),!0)}_getContrastCache(N){return N.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(N,R){N.setAttribute("style",`${N.getAttribute("style")||""}${R};`)}_isCellInSelection(N,R){const A=this._selectionStart,O=this._selectionEnd;return!(!A||!O)&&(this._columnSelectMode?A[0]<=O[0]?N>=A[0]&&R>=A[1]&&N<O[0]&&R<=O[1]:N<A[0]&&R>=A[1]&&N>=O[0]&&R<=O[1]:R>A[1]&&R<O[1]||A[1]===O[1]&&R===A[1]&&N>=A[0]&&N<O[0]||A[1]<O[1]&&R===O[1]&&N<O[0]||A[1]<O[1]&&R===A[1]&&N>=A[0])}};function T(N,R,A){for(;N.length<A;)N=R+N;return N}c.DomRendererRowFactory=k=h([p(1,_.ICharacterJoinerService),p(2,w.IOptionsService),p(3,_.ICoreBrowserService),p(4,w.ICoreService),p(5,w.IDecorationService),p(6,_.IThemeService)],k)},2550:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.WidthCache=void 0,c.WidthCache=class{constructor(d,h){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=d.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";const p=d.createElement("span");p.classList.add("xterm-char-measure-element");const m=d.createElement("span");m.classList.add("xterm-char-measure-element"),m.style.fontWeight="bold";const g=d.createElement("span");g.classList.add("xterm-char-measure-element"),g.style.fontStyle="italic";const y=d.createElement("span");y.classList.add("xterm-char-measure-element"),y.style.fontWeight="bold",y.style.fontStyle="italic",this._measureElements=[p,m,g,y],this._container.appendChild(p),this._container.appendChild(m),this._container.appendChild(g),this._container.appendChild(y),h.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(d,h,p,m){d===this._font&&h===this._fontSize&&p===this._weight&&m===this._weightBold||(this._font=d,this._fontSize=h,this._weight=p,this._weightBold=m,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${p}`,this._measureElements[1].style.fontWeight=`${m}`,this._measureElements[2].style.fontWeight=`${p}`,this._measureElements[3].style.fontWeight=`${m}`,this.clear())}get(d,h,p){let m=0;if(!h&&!p&&d.length===1&&(m=d.charCodeAt(0))<256){if(this._flat[m]!==-9999)return this._flat[m];const w=this._measure(d,0);return w>0&&(this._flat[m]=w),w}let g=d;h&&(g+="B"),p&&(g+="I");let y=this._holey.get(g);if(y===void 0){let w=0;h&&(w|=1),p&&(w|=2),y=this._measure(d,w),y>0&&this._holey.set(g,y)}return y}_measure(d,h){const p=this._measureElements[h];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 h=d(6114);c.INVERTED_DEFAULT_COLOR=257,c.DIM_OPACITY=.5,c.TEXT_BASELINE=h.isFirefox||h.isLegacyEdge?"bottom":"ideographic"},6171:(u,c)=>{function d(p){return 57508<=p&&p<=57558}function h(p){return p>=128512&&p<=128591||p>=127744&&p<=128511||p>=128640&&p<=128767||p>=9728&&p<=9983||p>=9984&&p<=10175||p>=65024&&p<=65039||p>=129280&&p<=129535||p>=127462&&p<=127487}Object.defineProperty(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=h,c.allowRescaling=function(p,m,g,y){return m===1&&g>Math.ceil(1.5*y)&&p!==void 0&&p>255&&!h(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,g=0){return(p-(2*Math.round(m)-g))%(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,g,y=!1){if(this.selectionStart=m,this.selectionEnd=g,!m||!g||m[0]===g[0]&&m[1]===g[1])return void this.clear();const w=p.buffers.active.ydisp,C=m[1]-w,_=g[1]-w,S=Math.max(C,0),b=Math.min(_,p.rows-1);S>=p.rows||b<0?this.clear():(this.hasSelection=!0,this.columnSelectMode=y,this.viewportStartRow=C,this.viewportEndRow=_,this.viewportCappedStartRow=S,this.viewportCappedEndRow=b,this.startCol=m[0],this.endCol=g[0])}isCellSelected(p,m,g){return!!this.hasSelection&&(g-=p.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?m>=this.startCol&&g>=this.viewportCappedStartRow&&m<this.endCol&&g<=this.viewportCappedEndRow:m<this.startCol&&g>=this.viewportCappedStartRow&&m>=this.endCol&&g<=this.viewportCappedEndRow:g>this.viewportStartRow&&g<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&g===this.viewportStartRow&&m>=this.startCol&&m<this.endCol||this.viewportStartRow<this.viewportEndRow&&g===this.viewportEndRow&&m<this.endCol||this.viewportStartRow<this.viewportEndRow&&g===this.viewportStartRow&&m>=this.startCol)}}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,h=this.selectionEnd;return!(!d||!h)&&(d[1]>h[1]||d[1]===h[1]&&d[0]>h[0])}handleTrim(d){return this.selectionStart&&(this.selectionStart[1]-=d),this.selectionEnd&&(this.selectionEnd[1]-=d),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}}},428:function(u,c,d){var h=this&&this.__decorate||function(b,v,k,T){var N,R=arguments.length,A=R<3?v:T===null?T=Object.getOwnPropertyDescriptor(v,k):T;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(b,v,k,T);else for(var O=b.length-1;O>=0;O--)(N=b[O])&&(A=(R<3?N(A):R>3?N(v,k,A):N(v,k))||A);return R>3&&A&&Object.defineProperty(v,k,A),A},p=this&&this.__param||function(b,v){return function(k,T){v(k,T,b)}};Object.defineProperty(c,"__esModule",{value:!0}),c.CharSizeService=void 0;const m=d(2585),g=d(8460),y=d(844);let w=c.CharSizeService=class extends y.Disposable{get hasValidSize(){return this.width>0&&this.height>0}constructor(b,v,k){super(),this._optionsService=k,this.width=0,this.height=0,this._onCharSizeChange=this.register(new g.EventEmitter),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this.register(new S(this._optionsService))}catch{this._measureStrategy=this.register(new _(b,v,this._optionsService))}this.register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],(()=>this.measure())))}measure(){const b=this._measureStrategy.measure();b.width===this.width&&b.height===this.height||(this.width=b.width,this.height=b.height,this._onCharSizeChange.fire())}};c.CharSizeService=w=h([p(2,m.IOptionsService)],w);class C extends y.Disposable{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(v,k){v!==void 0&&v>0&&k!==void 0&&k>0&&(this._result.width=v,this._result.height=k)}}class _ extends C{constructor(v,k,T){super(),this._document=v,this._parentElement=k,this._optionsService=T,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}}class S extends C{constructor(v){super(),this._optionsService=v,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");const k=this._ctx.measureText("W");if(!("width"in k&&"fontBoundingBoxAscent"in k&&"fontBoundingBoxDescent"in k))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;const v=this._ctx.measureText("W");return this._validateAndSet(v.width,v.fontBoundingBoxAscent+v.fontBoundingBoxDescent),this._result}}},4269:function(u,c,d){var h=this&&this.__decorate||function(S,b,v,k){var T,N=arguments.length,R=N<3?b:k===null?k=Object.getOwnPropertyDescriptor(b,v):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(S,b,v,k);else for(var A=S.length-1;A>=0;A--)(T=S[A])&&(R=(N<3?T(R):N>3?T(b,v,R):T(b,v))||R);return N>3&&R&&Object.defineProperty(b,v,R),R},p=this&&this.__param||function(S,b){return function(v,k){b(v,k,S)}};Object.defineProperty(c,"__esModule",{value:!0}),c.CharacterJoinerService=c.JoinedCellData=void 0;const m=d(3734),g=d(643),y=d(511),w=d(2585);class C extends m.AttributeData{constructor(b,v,k){super(),this.content=0,this.combinedData="",this.fg=b.fg,this.bg=b.bg,this.combinedData=v,this._width=k}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(b){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}c.JoinedCellData=C;let _=c.CharacterJoinerService=class AN{constructor(b){this._bufferService=b,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new y.CellData}register(b){const v={id:this._nextCharacterJoinerId++,handler:b};return this._characterJoiners.push(v),v.id}deregister(b){for(let v=0;v<this._characterJoiners.length;v++)if(this._characterJoiners[v].id===b)return this._characterJoiners.splice(v,1),!0;return!1}getJoinedCharacters(b){if(this._characterJoiners.length===0)return[];const v=this._bufferService.buffer.lines.get(b);if(!v||v.length===0)return[];const k=[],T=v.translateToString(!0);let N=0,R=0,A=0,O=v.getFg(0),P=v.getBg(0);for(let V=0;V<v.getTrimmedLength();V++)if(v.loadCell(V,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==O||this._workCell.bg!==P){if(V-N>1){const z=this._getJoinedRanges(T,A,R,v,N);for(let W=0;W<z.length;W++)k.push(z[W])}N=V,A=R,O=this._workCell.fg,P=this._workCell.bg}R+=this._workCell.getChars().length||g.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-N>1){const V=this._getJoinedRanges(T,A,R,v,N);for(let z=0;z<V.length;z++)k.push(V[z])}return k}_getJoinedRanges(b,v,k,T,N){const R=b.substring(v,k);let A=[];try{A=this._characterJoiners[0].handler(R)}catch(O){console.error(O)}for(let O=1;O<this._characterJoiners.length;O++)try{const P=this._characterJoiners[O].handler(R);for(let V=0;V<P.length;V++)AN._mergeRanges(A,P[V])}catch(P){console.error(P)}return this._stringRangesToCellRanges(A,T,N),A}_stringRangesToCellRanges(b,v,k){let T=0,N=!1,R=0,A=b[T];if(A){for(let O=k;O<this._bufferService.cols;O++){const P=v.getWidth(O),V=v.getString(O).length||g.WHITESPACE_CELL_CHAR.length;if(P!==0){if(!N&&A[0]<=R&&(A[0]=O,N=!0),A[1]<=R){if(A[1]=O,A=b[++T],!A)break;A[0]<=R?(A[0]=O,N=!0):N=!1}R+=V}}A&&(A[1]=this._bufferService.cols)}}static _mergeRanges(b,v){let k=!1;for(let T=0;T<b.length;T++){const N=b[T];if(k){if(v[1]<=N[0])return b[T-1][1]=v[1],b;if(v[1]<=N[1])return b[T-1][1]=Math.max(v[1],N[1]),b.splice(T,1),b;b.splice(T,1),T--}else{if(v[1]<=N[0])return b.splice(T,0,v),b;if(v[1]<=N[1])return N[0]=Math.min(v[0],N[0]),b;v[0]<N[1]&&(N[0]=Math.min(v[0],N[0]),k=!0)}}return k?b[b.length-1][1]=v[1]:b.push(v),b}};c.CharacterJoinerService=_=h([p(0,w.IBufferService)],_)},5114:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.CoreBrowserService=void 0;const h=d(844),p=d(8460),m=d(3656);class g extends h.Disposable{constructor(C,_,S){super(),this._textarea=C,this._window=_,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((b=>this._screenDprMonitor.setWindow(b)))),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=g;class y extends h.Disposable{constructor(C){super(),this._parentWindow=C,this._windowResizeListener=this.register(new h.MutableDisposable),this._onDprChange=this.register(new p.EventEmitter),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this.register((0,h.toDisposable)((()=>this.clearListener())))}setWindow(C){this._parentWindow=C,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=(0,m.addDisposableDomListener)(this._parentWindow,"resize",(()=>this._setDprAndFireIfDiffers()))}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var C;this._outerListener&&((C=this._resolutionMediaMatchList)==null||C.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){this._resolutionMediaMatchList&&this._outerListener&&(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}}},779:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.LinkProviderService=void 0;const h=d(844);class p extends h.Disposable{constructor(){super(),this.linkProviders=[],this.register((0,h.toDisposable)((()=>this.linkProviders.length=0)))}registerLinkProvider(g){return this.linkProviders.push(g),{dispose:()=>{const y=this.linkProviders.indexOf(g);y!==-1&&this.linkProviders.splice(y,1)}}}}c.LinkProviderService=p},8934:function(u,c,d){var h=this&&this.__decorate||function(w,C,_,S){var b,v=arguments.length,k=v<3?C:S===null?S=Object.getOwnPropertyDescriptor(C,_):S;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(w,C,_,S);else for(var T=w.length-1;T>=0;T--)(b=w[T])&&(k=(v<3?b(k):v>3?b(C,_,k):b(C,_))||k);return v>3&&k&&Object.defineProperty(C,_,k),k},p=this&&this.__param||function(w,C){return function(_,S){C(_,S,w)}};Object.defineProperty(c,"__esModule",{value:!0}),c.MouseService=void 0;const m=d(4725),g=d(9806);let y=c.MouseService=class{constructor(w,C){this._renderService=w,this._charSizeService=C}getCoords(w,C,_,S,b){return(0,g.getCoords)(window,w,C,_,S,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,b)}getMouseReportCoords(w,C){const _=(0,g.getCoordsRelativeToElement)(window,w,C);if(this._charSizeService.hasValidSize)return _[0]=Math.min(Math.max(_[0],0),this._renderService.dimensions.css.canvas.width-1),_[1]=Math.min(Math.max(_[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(_[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(_[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(_[0]),y:Math.floor(_[1])}}};c.MouseService=y=h([p(0,m.IRenderService),p(1,m.ICharSizeService)],y)},3230:function(u,c,d){var h=this&&this.__decorate||function(b,v,k,T){var N,R=arguments.length,A=R<3?v:T===null?T=Object.getOwnPropertyDescriptor(v,k):T;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(b,v,k,T);else for(var O=b.length-1;O>=0;O--)(N=b[O])&&(A=(R<3?N(A):R>3?N(v,k,A):N(v,k))||A);return R>3&&A&&Object.defineProperty(v,k,A),A},p=this&&this.__param||function(b,v){return function(k,T){v(k,T,b)}};Object.defineProperty(c,"__esModule",{value:!0}),c.RenderService=void 0;const m=d(6193),g=d(4725),y=d(8460),w=d(844),C=d(7226),_=d(2585);let S=c.RenderService=class extends w.Disposable{get dimensions(){return this._renderer.value.dimensions}constructor(b,v,k,T,N,R,A,O){super(),this._rowCount=b,this._charSizeService=T,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(((P,V)=>this._renderRows(P,V)),A),this.register(this._renderDebouncer),this.register(A.onDprChange((()=>this.handleDevicePixelRatioChange()))),this.register(R.onResize((()=>this._fullRefresh()))),this.register(R.buffers.onBufferActivate((()=>{var P;return(P=this._renderer.value)==null?void 0:P.clear()}))),this.register(k.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._charSizeService.onCharSizeChange((()=>this.handleCharSizeChanged()))),this.register(N.onDecorationRegistered((()=>this._fullRefresh()))),this.register(N.onDecorationRemoved((()=>this._fullRefresh()))),this.register(k.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],(()=>{this.clear(),this.handleResize(R.cols,R.rows),this._fullRefresh()}))),this.register(k.onMultipleOptionChange(["cursorBlink","cursorStyle"],(()=>this.refreshRows(R.buffer.y,R.buffer.y,!0)))),this.register(O.onChangeColors((()=>this._fullRefresh()))),this._registerIntersectionObserver(A.window,v),this.register(A.onWindowChange((P=>this._registerIntersectionObserver(P,v))))}_registerIntersectionObserver(b,v){if("IntersectionObserver"in b){const k=new b.IntersectionObserver((T=>this._handleIntersectionChange(T[T.length-1])),{threshold:0});k.observe(v),this._observerDisposable.value=(0,w.toDisposable)((()=>k.disconnect()))}}_handleIntersectionChange(b){this._isPaused=b.isIntersecting===void 0?b.intersectionRatio===0:!b.isIntersecting,this._isPaused||this._charSizeService.hasValidSize||this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(b,v,k=!1){this._isPaused?this._needsFullRefresh=!0:(k||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(b,v,this._rowCount))}_renderRows(b,v){this._renderer.value&&(b=Math.min(b,this._rowCount-1),v=Math.min(v,this._rowCount-1),this._renderer.value.renderRows(b,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:b,end:v}),this._onRender.fire({start:b,end:v}),this._isNextRenderRedrawOnly=!0)}resize(b,v){this._rowCount=v,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(b){this._renderer.value=b,this._renderer.value&&(this._renderer.value.onRequestRedraw((v=>this.refreshRows(v.start,v.end,!0))),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(b){return this._renderDebouncer.addRefreshCallback(b)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var b,v;this._renderer.value&&((v=(b=this._renderer.value).clearTextureAtlas)==null||v.call(b),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(b,v){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set((()=>{var k;return(k=this._renderer.value)==null?void 0:k.handleResize(b,v)})):this._renderer.value.handleResize(b,v),this._fullRefresh())}handleCharSizeChanged(){var b;(b=this._renderer.value)==null||b.handleCharSizeChanged()}handleBlur(){var b;(b=this._renderer.value)==null||b.handleBlur()}handleFocus(){var b;(b=this._renderer.value)==null||b.handleFocus()}handleSelectionChanged(b,v,k){var T;this._selectionState.start=b,this._selectionState.end=v,this._selectionState.columnSelectMode=k,(T=this._renderer.value)==null||T.handleSelectionChanged(b,v,k)}handleCursorMove(){var b;(b=this._renderer.value)==null||b.handleCursorMove()}clear(){var b;(b=this._renderer.value)==null||b.clear()}};c.RenderService=S=h([p(2,_.IOptionsService),p(3,g.ICharSizeService),p(4,_.IDecorationService),p(5,_.IBufferService),p(6,g.ICoreBrowserService),p(7,g.IThemeService)],S)},9312:function(u,c,d){var h=this&&this.__decorate||function(A,O,P,V){var z,W=arguments.length,M=W<3?O:V===null?V=Object.getOwnPropertyDescriptor(O,P):V;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")M=Reflect.decorate(A,O,P,V);else for(var U=A.length-1;U>=0;U--)(z=A[U])&&(M=(W<3?z(M):W>3?z(O,P,M):z(O,P))||M);return W>3&&M&&Object.defineProperty(O,P,M),M},p=this&&this.__param||function(A,O){return function(P,V){O(P,V,A)}};Object.defineProperty(c,"__esModule",{value:!0}),c.SelectionService=void 0;const m=d(9806),g=d(9504),y=d(456),w=d(4725),C=d(8460),_=d(844),S=d(6114),b=d(4841),v=d(511),k=d(2585),T=" ",N=new RegExp(T,"g");let R=c.SelectionService=class extends _.Disposable{constructor(A,O,P,V,z,W,M,U,F){super(),this._element=A,this._screenElement=O,this._linkifier=P,this._bufferService=V,this._coreService=z,this._mouseService=W,this._optionsService=M,this._renderService=U,this._coreBrowserService=F,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new v.CellData,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this.register(new C.EventEmitter),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this.register(new C.EventEmitter),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this.register(new C.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this.register(new C.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=Q=>this._handleMouseMove(Q),this._mouseUpListener=Q=>this._handleMouseUp(Q),this._coreService.onUserInput((()=>{this.hasSelection&&this.clearSelection()})),this._trimListener=this._bufferService.buffer.lines.onTrim((Q=>this._handleTrim(Q))),this.register(this._bufferService.buffers.onBufferActivate((Q=>this._handleBufferActivate(Q)))),this.enable(),this._model=new y.SelectionModel(this._bufferService),this._activeSelectionMode=0,this.register((0,_.toDisposable)((()=>{this._removeMouseDownListeners()})))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){const A=this._model.finalSelectionStart,O=this._model.finalSelectionEnd;return!(!A||!O||A[0]===O[0]&&A[1]===O[1])}get selectionText(){const A=this._model.finalSelectionStart,O=this._model.finalSelectionEnd;if(!A||!O)return"";const P=this._bufferService.buffer,V=[];if(this._activeSelectionMode===3){if(A[0]===O[0])return"";const z=A[0]<O[0]?A[0]:O[0],W=A[0]<O[0]?O[0]:A[0];for(let M=A[1];M<=O[1];M++){const U=P.translateBufferLineToString(M,!0,z,W);V.push(U)}}else{const z=A[1]===O[1]?O[0]:void 0;V.push(P.translateBufferLineToString(A[1],!0,A[0],z));for(let W=A[1]+1;W<=O[1]-1;W++){const M=P.lines.get(W),U=P.translateBufferLineToString(W,!0);M!=null&&M.isWrapped?V[V.length-1]+=U:V.push(U)}if(A[1]!==O[1]){const W=P.lines.get(O[1]),M=P.translateBufferLineToString(O[1],!0,0,O[0]);W&&W.isWrapped?V[V.length-1]+=M:V.push(M)}}return V.map((z=>z.replace(N," "))).join(S.isWindows?`\r
258
+ `:`
259
+ `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(A){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._refresh()))),S.isLinux&&A&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(A){const O=this._getMouseBufferCoords(A),P=this._model.finalSelectionStart,V=this._model.finalSelectionEnd;return!!(P&&V&&O)&&this._areCoordsInSelection(O,P,V)}isCellInSelection(A,O){const P=this._model.finalSelectionStart,V=this._model.finalSelectionEnd;return!(!P||!V)&&this._areCoordsInSelection([A,O],P,V)}_areCoordsInSelection(A,O,P){return A[1]>O[1]&&A[1]<P[1]||O[1]===P[1]&&A[1]===O[1]&&A[0]>=O[0]&&A[0]<P[0]||O[1]<P[1]&&A[1]===P[1]&&A[0]<P[0]||O[1]<P[1]&&A[1]===O[1]&&A[0]>=O[0]}_selectWordAtCursor(A,O){var z,W;const P=(W=(z=this._linkifier.currentLink)==null?void 0:z.link)==null?void 0:W.range;if(P)return this._model.selectionStart=[P.start.x-1,P.start.y-1],this._model.selectionStartLength=(0,b.getRangeLength)(P,this._bufferService.cols),this._model.selectionEnd=void 0,!0;const V=this._getMouseBufferCoords(A);return!!V&&(this._selectWordAt(V,O),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(A,O){this._model.clearSelection(),A=Math.max(A,0),O=Math.min(O,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,A],this._model.selectionEnd=[this._bufferService.cols,O],this.refresh(),this._onSelectionChange.fire()}_handleTrim(A){this._model.handleTrim(A)&&this.refresh()}_getMouseBufferCoords(A){const O=this._mouseService.getCoords(A,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(O)return O[0]--,O[1]--,O[1]+=this._bufferService.buffer.ydisp,O}_getMouseEventScrollAmount(A){let O=(0,m.getCoordsRelativeToElement)(this._coreBrowserService.window,A,this._screenElement)[1];const P=this._renderService.dimensions.css.canvas.height;return O>=0&&O<=P?0:(O>P&&(O-=P),O=Math.min(Math.max(O,-50),50),O/=50,O/Math.abs(O)+Math.round(14*O))}shouldForceSelection(A){return S.isMac?A.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:A.shiftKey}handleMouseDown(A){if(this._mouseDownTimeStamp=A.timeStamp,(A.button!==2||!this.hasSelection)&&A.button===0){if(!this._enabled){if(!this.shouldForceSelection(A))return;A.stopPropagation()}A.preventDefault(),this._dragScrollAmount=0,this._enabled&&A.shiftKey?this._handleIncrementalClick(A):A.detail===1?this._handleSingleClick(A):A.detail===2?this._handleDoubleClick(A):A.detail===3&&this._handleTripleClick(A),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval((()=>this._dragScroll()),50)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(A){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(A))}_handleSingleClick(A){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(A)?3:0,this._model.selectionStart=this._getMouseBufferCoords(A),!this._model.selectionStart)return;this._model.selectionEnd=void 0;const O=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);O&&O.length!==this._model.selectionStart[0]&&O.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(A){this._selectWordAtCursor(A,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(A){const O=this._getMouseBufferCoords(A);O&&(this._activeSelectionMode=2,this._selectLineAt(O[1]))}shouldColumnSelect(A){return A.altKey&&!(S.isMac&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(A){if(A.stopImmediatePropagation(),!this._model.selectionStart)return;const O=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(A),!this._model.selectionEnd)return void this.refresh(!0);this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(A),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));const P=this._bufferService.buffer;if(this._model.selectionEnd[1]<P.lines.length){const V=P.lines.get(this._model.selectionEnd[1]);V&&V.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}O&&O[0]===this._model.selectionEnd[0]&&O[1]===this._model.selectionEnd[1]||this.refresh(!0)}_dragScroll(){if(this._model.selectionEnd&&this._model.selectionStart&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});const A=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(A.ydisp+this._bufferService.rows,A.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=A.ydisp),this.refresh()}}_handleMouseUp(A){const O=A.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&O<500&&A.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){const P=this._mouseService.getCoords(A,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(P&&P[0]!==void 0&&P[1]!==void 0){const V=(0,g.moveToCellSequence)(P[0]-1,P[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(V,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){const A=this._model.finalSelectionStart,O=this._model.finalSelectionEnd,P=!(!A||!O||A[0]===O[0]&&A[1]===O[1]);P?A&&O&&(this._oldSelectionStart&&this._oldSelectionEnd&&A[0]===this._oldSelectionStart[0]&&A[1]===this._oldSelectionStart[1]&&O[0]===this._oldSelectionEnd[0]&&O[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(A,O,P)):this._oldHasSelection&&this._fireOnSelectionChange(A,O,P)}_fireOnSelectionChange(A,O,P){this._oldSelectionStart=A,this._oldSelectionEnd=O,this._oldHasSelection=P,this._onSelectionChange.fire()}_handleBufferActivate(A){this.clearSelection(),this._trimListener.dispose(),this._trimListener=A.activeBuffer.lines.onTrim((O=>this._handleTrim(O)))}_convertViewportColToCharacterIndex(A,O){let P=O;for(let V=0;O>=V;V++){const z=A.loadCell(V,this._workCell).getChars().length;this._workCell.getWidth()===0?P--:z>1&&O!==V&&(P+=z-1)}return P}setSelection(A,O,P){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[A,O],this._model.selectionStartLength=P,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(A){this._isClickInSelection(A)||(this._selectWordAtCursor(A,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(A,O,P=!0,V=!0){if(A[0]>=this._bufferService.cols)return;const z=this._bufferService.buffer,W=z.lines.get(A[1]);if(!W)return;const M=z.translateBufferLineToString(A[1],!1);let U=this._convertViewportColToCharacterIndex(W,A[0]),F=U;const Q=A[0]-U;let X=0,H=0,I=0,D=0;if(M.charAt(U)===" "){for(;U>0&&M.charAt(U-1)===" ";)U--;for(;F<M.length&&M.charAt(F+1)===" ";)F++}else{let J=A[0],Y=A[0];W.getWidth(J)===0&&(X++,J--),W.getWidth(Y)===2&&(H++,Y++);const Z=W.getString(Y).length;for(Z>1&&(D+=Z-1,F+=Z-1);J>0&&U>0&&!this._isCharWordSeparator(W.loadCell(J-1,this._workCell));){W.loadCell(J-1,this._workCell);const K=this._workCell.getChars().length;this._workCell.getWidth()===0?(X++,J--):K>1&&(I+=K-1,U-=K-1),U--,J--}for(;Y<W.length&&F+1<M.length&&!this._isCharWordSeparator(W.loadCell(Y+1,this._workCell));){W.loadCell(Y+1,this._workCell);const K=this._workCell.getChars().length;this._workCell.getWidth()===2?(H++,Y++):K>1&&(D+=K-1,F+=K-1),F++,Y++}}F++;let q=U+Q-X+I,$=Math.min(this._bufferService.cols,F-U+X+H-I-D);if(O||M.slice(U,F).trim()!==""){if(P&&q===0&&W.getCodePoint(0)!==32){const J=z.lines.get(A[1]-1);if(J&&W.isWrapped&&J.getCodePoint(this._bufferService.cols-1)!==32){const Y=this._getWordAt([this._bufferService.cols-1,A[1]-1],!1,!0,!1);if(Y){const Z=this._bufferService.cols-Y.start;q-=Z,$+=Z}}}if(V&&q+$===this._bufferService.cols&&W.getCodePoint(this._bufferService.cols-1)!==32){const J=z.lines.get(A[1]+1);if(J!=null&&J.isWrapped&&J.getCodePoint(0)!==32){const Y=this._getWordAt([0,A[1]+1],!1,!1,!0);Y&&($+=Y.length)}}return{start:q,length:$}}}_selectWordAt(A,O){const P=this._getWordAt(A,O);if(P){for(;P.start<0;)P.start+=this._bufferService.cols,A[1]--;this._model.selectionStart=[P.start,A[1]],this._model.selectionStartLength=P.length}}_selectToWordAt(A){const O=this._getWordAt(A,!0);if(O){let P=A[1];for(;O.start<0;)O.start+=this._bufferService.cols,P--;if(!this._model.areSelectionValuesReversed())for(;O.start+O.length>this._bufferService.cols;)O.length-=this._bufferService.cols,P++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?O.start:O.start+O.length,P]}}_isCharWordSeparator(A){return A.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(A.getChars())>=0}_selectLineAt(A){const O=this._bufferService.buffer.getWrappedRangeForLine(A),P={start:{x:0,y:O.first},end:{x:this._bufferService.cols-1,y:O.last}};this._model.selectionStart=[0,O.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=(0,b.getRangeLength)(P,this._bufferService.cols)}};c.SelectionService=R=h([p(3,k.IBufferService),p(4,k.ICoreService),p(5,w.IMouseService),p(6,k.IOptionsService),p(7,w.IRenderService),p(8,w.ICoreBrowserService)],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 h=d(8343);c.ICharSizeService=(0,h.createDecorator)("CharSizeService"),c.ICoreBrowserService=(0,h.createDecorator)("CoreBrowserService"),c.IMouseService=(0,h.createDecorator)("MouseService"),c.IRenderService=(0,h.createDecorator)("RenderService"),c.ISelectionService=(0,h.createDecorator)("SelectionService"),c.ICharacterJoinerService=(0,h.createDecorator)("CharacterJoinerService"),c.IThemeService=(0,h.createDecorator)("ThemeService"),c.ILinkProviderService=(0,h.createDecorator)("LinkProviderService")},6731:function(u,c,d){var h=this&&this.__decorate||function(R,A,O,P){var V,z=arguments.length,W=z<3?A:P===null?P=Object.getOwnPropertyDescriptor(A,O):P;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")W=Reflect.decorate(R,A,O,P);else for(var M=R.length-1;M>=0;M--)(V=R[M])&&(W=(z<3?V(W):z>3?V(A,O,W):V(A,O))||W);return z>3&&W&&Object.defineProperty(A,O,W),W},p=this&&this.__param||function(R,A){return function(O,P){A(O,P,R)}};Object.defineProperty(c,"__esModule",{value:!0}),c.ThemeService=c.DEFAULT_ANSI_COLORS=void 0;const m=d(7239),g=d(8055),y=d(8460),w=d(844),C=d(2585),_=g.css.toColor("#ffffff"),S=g.css.toColor("#000000"),b=g.css.toColor("#ffffff"),v=g.css.toColor("#000000"),k={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117};c.DEFAULT_ANSI_COLORS=Object.freeze((()=>{const R=[g.css.toColor("#2e3436"),g.css.toColor("#cc0000"),g.css.toColor("#4e9a06"),g.css.toColor("#c4a000"),g.css.toColor("#3465a4"),g.css.toColor("#75507b"),g.css.toColor("#06989a"),g.css.toColor("#d3d7cf"),g.css.toColor("#555753"),g.css.toColor("#ef2929"),g.css.toColor("#8ae234"),g.css.toColor("#fce94f"),g.css.toColor("#729fcf"),g.css.toColor("#ad7fa8"),g.css.toColor("#34e2e2"),g.css.toColor("#eeeeec")],A=[0,95,135,175,215,255];for(let O=0;O<216;O++){const P=A[O/36%6|0],V=A[O/6%6|0],z=A[O%6];R.push({css:g.channels.toCss(P,V,z),rgba:g.channels.toRgba(P,V,z)})}for(let O=0;O<24;O++){const P=8+10*O;R.push({css:g.channels.toCss(P,P,P),rgba:g.channels.toRgba(P,P,P)})}return R})());let T=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:_,background:S,cursor:b,cursorAccent:v,selectionForeground:void 0,selectionBackgroundTransparent:k,selectionBackgroundOpaque:g.color.blend(S,k),selectionInactiveBackgroundTransparent:k,selectionInactiveBackgroundOpaque:g.color.blend(S,k),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=N(R.foreground,_),A.background=N(R.background,S),A.cursor=N(R.cursor,b),A.cursorAccent=N(R.cursorAccent,v),A.selectionBackgroundTransparent=N(R.selectionBackground,k),A.selectionBackgroundOpaque=g.color.blend(A.background,A.selectionBackgroundTransparent),A.selectionInactiveBackgroundTransparent=N(R.selectionInactiveBackground,A.selectionBackgroundTransparent),A.selectionInactiveBackgroundOpaque=g.color.blend(A.background,A.selectionInactiveBackgroundTransparent),A.selectionForeground=R.selectionForeground?N(R.selectionForeground,g.NULL_COLOR):void 0,A.selectionForeground===g.NULL_COLOR&&(A.selectionForeground=void 0),g.color.isOpaque(A.selectionBackgroundTransparent)&&(A.selectionBackgroundTransparent=g.color.opacity(A.selectionBackgroundTransparent,.3)),g.color.isOpaque(A.selectionInactiveBackgroundTransparent)&&(A.selectionInactiveBackgroundTransparent=g.color.opacity(A.selectionInactiveBackgroundTransparent,.3)),A.ansi=c.DEFAULT_ANSI_COLORS.slice(),A.ansi[0]=N(R.black,c.DEFAULT_ANSI_COLORS[0]),A.ansi[1]=N(R.red,c.DEFAULT_ANSI_COLORS[1]),A.ansi[2]=N(R.green,c.DEFAULT_ANSI_COLORS[2]),A.ansi[3]=N(R.yellow,c.DEFAULT_ANSI_COLORS[3]),A.ansi[4]=N(R.blue,c.DEFAULT_ANSI_COLORS[4]),A.ansi[5]=N(R.magenta,c.DEFAULT_ANSI_COLORS[5]),A.ansi[6]=N(R.cyan,c.DEFAULT_ANSI_COLORS[6]),A.ansi[7]=N(R.white,c.DEFAULT_ANSI_COLORS[7]),A.ansi[8]=N(R.brightBlack,c.DEFAULT_ANSI_COLORS[8]),A.ansi[9]=N(R.brightRed,c.DEFAULT_ANSI_COLORS[9]),A.ansi[10]=N(R.brightGreen,c.DEFAULT_ANSI_COLORS[10]),A.ansi[11]=N(R.brightYellow,c.DEFAULT_ANSI_COLORS[11]),A.ansi[12]=N(R.brightBlue,c.DEFAULT_ANSI_COLORS[12]),A.ansi[13]=N(R.brightMagenta,c.DEFAULT_ANSI_COLORS[13]),A.ansi[14]=N(R.brightCyan,c.DEFAULT_ANSI_COLORS[14]),A.ansi[15]=N(R.brightWhite,c.DEFAULT_ANSI_COLORS[15]),R.extendedAnsi){const O=Math.min(A.ansi.length-16,R.extendedAnsi.length);for(let P=0;P<O;P++)A.ansi[P+16]=N(R.extendedAnsi[P],c.DEFAULT_ANSI_COLORS[P+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 N(R,A){if(R!==void 0)try{return g.css.toColor(R)}catch{}return A}c.ThemeService=T=h([p(0,C.IOptionsService)],T)},6349:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.CircularList=void 0;const h=d(8460),p=d(844);class m extends p.Disposable{constructor(y){super(),this._maxLength=y,this.onDeleteEmitter=this.register(new h.EventEmitter),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this.register(new h.EventEmitter),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this.register(new h.EventEmitter),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(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 _=y;_<this._length-w;_++)this._array[this._getCyclicIndex(_)]=this._array[this._getCyclicIndex(_+w)];this._length-=w,this.onDeleteEmitter.fire({index:y,amount:w})}for(let _=this._length-1;_>=y;_--)this._array[this._getCyclicIndex(_+C.length)]=this._array[this._getCyclicIndex(_)];for(let _=0;_<C.length;_++)this._array[this._getCyclicIndex(y+_)]=C[_];if(C.length&&this.onInsertEmitter.fire({index:y,amount:C.length}),this._length+C.length>this._maxLength){const _=this._length+C.length-this._maxLength;this._startIndex+=_,this._length=this._maxLength,this.onTrimEmitter.fire(_)}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 _=y+w+C-this._length;if(_>0)for(this._length+=_;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let _=0;_<w;_++)this.set(y+_+C,this.get(y+_))}}_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(h,p=5){if(typeof h!="object")return h;const m=Array.isArray(h)?[]:{};for(const g in h)m[g]=p<=1?h[g]:h[g]&&d(h[g],p-1);return m}},8055:(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,h=0,p=0,m=0;var g,y,w,C,_;function S(v){const k=v.toString(16);return k.length<2?"0"+k:k}function b(v,k){return v<k?(k+.05)/(v+.05):(v+.05)/(k+.05)}c.NULL_COLOR={css:"#00000000",rgba:0},(function(v){v.toCss=function(k,T,N,R){return R!==void 0?`#${S(k)}${S(T)}${S(N)}${S(R)}`:`#${S(k)}${S(T)}${S(N)}`},v.toRgba=function(k,T,N,R=255){return(k<<24|T<<16|N<<8|R)>>>0},v.toColor=function(k,T,N,R){return{css:v.toCss(k,T,N,R),rgba:v.toRgba(k,T,N,R)}}})(g||(c.channels=g={})),(function(v){function k(T,N){return m=Math.round(255*N),[d,h,p]=_.toChannels(T.rgba),{css:g.toCss(d,h,p,m),rgba:g.toRgba(d,h,p,m)}}v.blend=function(T,N){if(m=(255&N.rgba)/255,m===1)return{css:N.css,rgba:N.rgba};const R=N.rgba>>24&255,A=N.rgba>>16&255,O=N.rgba>>8&255,P=T.rgba>>24&255,V=T.rgba>>16&255,z=T.rgba>>8&255;return d=P+Math.round((R-P)*m),h=V+Math.round((A-V)*m),p=z+Math.round((O-z)*m),{css:g.toCss(d,h,p),rgba:g.toRgba(d,h,p)}},v.isOpaque=function(T){return(255&T.rgba)==255},v.ensureContrastRatio=function(T,N,R){const A=_.ensureContrastRatio(T.rgba,N.rgba,R);if(A)return g.toColor(A>>24&255,A>>16&255,A>>8&255)},v.opaque=function(T){const N=(255|T.rgba)>>>0;return[d,h,p]=_.toChannels(N),{css:g.toCss(d,h,p),rgba:N}},v.opacity=k,v.multiplyOpacity=function(T,N){return m=255&T.rgba,k(T,m*N/255)},v.toColorRGB=function(T){return[T.rgba>>24&255,T.rgba>>16&255,T.rgba>>8&255]}})(y||(c.color=y={})),(function(v){let k,T;try{const N=document.createElement("canvas");N.width=1,N.height=1;const R=N.getContext("2d",{willReadFrequently:!0});R&&(k=R,k.globalCompositeOperation="copy",T=k.createLinearGradient(0,0,1,1))}catch{}v.toColor=function(N){if(N.match(/#[\da-f]{3,8}/i))switch(N.length){case 4:return d=parseInt(N.slice(1,2).repeat(2),16),h=parseInt(N.slice(2,3).repeat(2),16),p=parseInt(N.slice(3,4).repeat(2),16),g.toColor(d,h,p);case 5:return d=parseInt(N.slice(1,2).repeat(2),16),h=parseInt(N.slice(2,3).repeat(2),16),p=parseInt(N.slice(3,4).repeat(2),16),m=parseInt(N.slice(4,5).repeat(2),16),g.toColor(d,h,p,m);case 7:return{css:N,rgba:(parseInt(N.slice(1),16)<<8|255)>>>0};case 9:return{css:N,rgba:parseInt(N.slice(1),16)>>>0}}const R=N.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(R)return d=parseInt(R[1]),h=parseInt(R[2]),p=parseInt(R[3]),m=Math.round(255*(R[5]===void 0?1:parseFloat(R[5]))),g.toColor(d,h,p,m);if(!k||!T)throw new Error("css.toColor: Unsupported css format");if(k.fillStyle=T,k.fillStyle=N,typeof k.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(k.fillRect(0,0,1,1),[d,h,p,m]=k.getImageData(0,0,1,1).data,m!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:g.toRgba(d,h,p,m),css:N}}})(w||(c.css=w={})),(function(v){function k(T,N,R){const A=T/255,O=N/255,P=R/255;return .2126*(A<=.03928?A/12.92:Math.pow((A+.055)/1.055,2.4))+.7152*(O<=.03928?O/12.92:Math.pow((O+.055)/1.055,2.4))+.0722*(P<=.03928?P/12.92:Math.pow((P+.055)/1.055,2.4))}v.relativeLuminance=function(T){return k(T>>16&255,T>>8&255,255&T)},v.relativeLuminance2=k})(C||(c.rgb=C={})),(function(v){function k(N,R,A){const O=N>>24&255,P=N>>16&255,V=N>>8&255;let z=R>>24&255,W=R>>16&255,M=R>>8&255,U=b(C.relativeLuminance2(z,W,M),C.relativeLuminance2(O,P,V));for(;U<A&&(z>0||W>0||M>0);)z-=Math.max(0,Math.ceil(.1*z)),W-=Math.max(0,Math.ceil(.1*W)),M-=Math.max(0,Math.ceil(.1*M)),U=b(C.relativeLuminance2(z,W,M),C.relativeLuminance2(O,P,V));return(z<<24|W<<16|M<<8|255)>>>0}function T(N,R,A){const O=N>>24&255,P=N>>16&255,V=N>>8&255;let z=R>>24&255,W=R>>16&255,M=R>>8&255,U=b(C.relativeLuminance2(z,W,M),C.relativeLuminance2(O,P,V));for(;U<A&&(z<255||W<255||M<255);)z=Math.min(255,z+Math.ceil(.1*(255-z))),W=Math.min(255,W+Math.ceil(.1*(255-W))),M=Math.min(255,M+Math.ceil(.1*(255-M))),U=b(C.relativeLuminance2(z,W,M),C.relativeLuminance2(O,P,V));return(z<<24|W<<16|M<<8|255)>>>0}v.blend=function(N,R){if(m=(255&R)/255,m===1)return R;const A=R>>24&255,O=R>>16&255,P=R>>8&255,V=N>>24&255,z=N>>16&255,W=N>>8&255;return d=V+Math.round((A-V)*m),h=z+Math.round((O-z)*m),p=W+Math.round((P-W)*m),g.toRgba(d,h,p)},v.ensureContrastRatio=function(N,R,A){const O=C.relativeLuminance(N>>8),P=C.relativeLuminance(R>>8);if(b(O,P)<A){if(P<O){const W=k(N,R,A),M=b(O,C.relativeLuminance(W>>8));if(M<A){const U=T(N,R,A);return M>b(O,C.relativeLuminance(U>>8))?W:U}return W}const V=T(N,R,A),z=b(O,C.relativeLuminance(V>>8));if(z<A){const W=k(N,R,A);return z>b(O,C.relativeLuminance(W>>8))?V:W}return V}},v.reduceLuminance=k,v.increaseLuminance=T,v.toChannels=function(N){return[N>>24&255,N>>16&255,N>>8&255,255&N]}})(_||(c.rgba=_={})),c.toPaddedHex=S,c.contrastRatio=b},8969:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.CoreTerminal=void 0;const h=d(844),p=d(2585),m=d(4348),g=d(7866),y=d(744),w=d(7302),C=d(6975),_=d(8460),S=d(1753),b=d(1480),v=d(7994),k=d(9282),T=d(5435),N=d(5981),R=d(2660);let A=!1;class O extends h.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new _.EventEmitter),this._onScroll.event((V=>{var z;(z=this._onScrollApi)==null||z.fire(V.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(V){for(const z in V)this.optionsService.options[z]=V[z]}constructor(V){super(),this._windowsWrappingHeuristics=this.register(new h.MutableDisposable),this._onBinary=this.register(new _.EventEmitter),this.onBinary=this._onBinary.event,this._onData=this.register(new _.EventEmitter),this.onData=this._onData.event,this._onLineFeed=this.register(new _.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onResize=this.register(new _.EventEmitter),this.onResize=this._onResize.event,this._onWriteParsed=this.register(new _.EventEmitter),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this.register(new _.EventEmitter),this._instantiationService=new m.InstantiationService,this.optionsService=this.register(new w.OptionsService(V)),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(g.LogService)),this._instantiationService.setService(p.ILogService,this._logService),this.coreService=this.register(this._instantiationService.createInstance(C.CoreService)),this._instantiationService.setService(p.ICoreService,this.coreService),this.coreMouseService=this.register(this._instantiationService.createInstance(S.CoreMouseService)),this._instantiationService.setService(p.ICoreMouseService,this.coreMouseService),this.unicodeService=this.register(this._instantiationService.createInstance(b.UnicodeService)),this._instantiationService.setService(p.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(v.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 T.InputHandler(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this.register((0,_.forwardEvent)(this._inputHandler.onLineFeed,this._onLineFeed)),this.register(this._inputHandler),this.register((0,_.forwardEvent)(this._bufferService.onResize,this._onResize)),this.register((0,_.forwardEvent)(this.coreService.onData,this._onData)),this.register((0,_.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((z=>{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((z=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this._writeBuffer=this.register(new N.WriteBuffer(((z,W)=>this._inputHandler.parse(z,W)))),this.register((0,_.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(V,z){this._writeBuffer.write(V,z)}writeSync(V,z){this._logService.logLevel<=p.LogLevelEnum.WARN&&!A&&(this._logService.warn("writeSync is unreliable and will be removed soon."),A=!0),this._writeBuffer.writeSync(V,z)}input(V,z=!0){this.coreService.triggerDataEvent(V,z)}resize(V,z){isNaN(V)||isNaN(z)||(V=Math.max(V,y.MINIMUM_COLS),z=Math.max(z,y.MINIMUM_ROWS),this._bufferService.resize(V,z))}scroll(V,z=!1){this._bufferService.scroll(V,z)}scrollLines(V,z,W){this._bufferService.scrollLines(V,z,W)}scrollPages(V){this.scrollLines(V*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(V){const z=V-this._bufferService.buffer.ydisp;z!==0&&this.scrollLines(z)}registerEscHandler(V,z){return this._inputHandler.registerEscHandler(V,z)}registerDcsHandler(V,z){return this._inputHandler.registerDcsHandler(V,z)}registerCsiHandler(V,z){return this._inputHandler.registerCsiHandler(V,z)}registerOscHandler(V,z){return this._inputHandler.registerOscHandler(V,z)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let V=!1;const z=this.optionsService.rawOptions.windowsPty;z&&z.buildNumber!==void 0&&z.buildNumber!==void 0?V=z.backend==="conpty"&&z.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(V=!0),V?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){const V=[];V.push(this.onLineFeed(k.updateWindowsModeWrappedState.bind(null,this._bufferService))),V.push(this.registerCsiHandler({final:"H"},(()=>((0,k.updateWindowsModeWrappedState)(this._bufferService),!1)))),this._windowsWrappingHeuristics.value=(0,h.toDisposable)((()=>{for(const z of V)z.dispose()}))}}}c.CoreTerminal=O},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 h=0;h<this._listeners.length;h++)if(this._listeners[h]===d)return void this._listeners.splice(h,1)}}})),this._event}fire(d,h){const p=[];for(let m=0;m<this._listeners.length;m++)p.push(this._listeners[m]);for(let m=0;m<p.length;m++)p[m].call(void 0,d,h)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},c.forwardEvent=function(d,h){return d((p=>h.fire(p)))},c.runAndSubscribe=function(d,h){return h(void 0),d((p=>h(p)))}},5435:function(u,c,d){var h=this&&this.__decorate||function(X,H,I,D){var q,$=arguments.length,J=$<3?H:D===null?D=Object.getOwnPropertyDescriptor(H,I):D;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")J=Reflect.decorate(X,H,I,D);else for(var Y=X.length-1;Y>=0;Y--)(q=X[Y])&&(J=($<3?q(J):$>3?q(H,I,J):q(H,I))||J);return $>3&&J&&Object.defineProperty(H,I,J),J},p=this&&this.__param||function(X,H){return function(I,D){H(I,D,X)}};Object.defineProperty(c,"__esModule",{value:!0}),c.InputHandler=c.WindowsOptionsReportType=void 0;const m=d(2584),g=d(7116),y=d(2015),w=d(844),C=d(482),_=d(8437),S=d(8460),b=d(643),v=d(511),k=d(3734),T=d(2585),N=d(1480),R=d(6242),A=d(6351),O=d(5941),P={"(":0,")":1,"*":2,"+":3,"-":1,".":2},V=131072;function z(X,H){if(X>24)return H.setWinLines||!1;switch(X){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 W;(function(X){X[X.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",X[X.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(W||(c.WindowsOptionsReportType=W={}));let M=0;class U extends w.Disposable{getAttrData(){return this._curAttrData}constructor(H,I,D,q,$,J,Y,Z,K=new y.EscapeSequenceParser){super(),this._bufferService=H,this._charsetService=I,this._coreService=D,this._logService=q,this._optionsService=$,this._oscLinkService=J,this._coreMouseService=Y,this._unicodeService=Z,this._parser=K,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new C.StringToUtf32,this._utf8Decoder=new C.Utf8ToUtf32,this._workCell=new v.CellData,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=_.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=_.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 F(this._bufferService),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((B=>this._activeBuffer=B.activeBuffer))),this._parser.setCsiHandlerFallback(((B,ne)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(B),params:ne.toArray()})})),this._parser.setEscHandlerFallback((B=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(B)})})),this._parser.setExecuteHandlerFallback((B=>{this._logService.debug("Unknown EXECUTE code: ",{code:B})})),this._parser.setOscHandlerFallback(((B,ne,se)=>{this._logService.debug("Unknown OSC code: ",{identifier:B,action:ne,data:se})})),this._parser.setDcsHandlerFallback(((B,ne,se)=>{ne==="HOOK"&&(se=se.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(B),action:ne,payload:se})})),this._parser.setPrintHandler(((B,ne,se)=>this.print(B,ne,se))),this._parser.registerCsiHandler({final:"@"},(B=>this.insertChars(B))),this._parser.registerCsiHandler({intermediates:" ",final:"@"},(B=>this.scrollLeft(B))),this._parser.registerCsiHandler({final:"A"},(B=>this.cursorUp(B))),this._parser.registerCsiHandler({intermediates:" ",final:"A"},(B=>this.scrollRight(B))),this._parser.registerCsiHandler({final:"B"},(B=>this.cursorDown(B))),this._parser.registerCsiHandler({final:"C"},(B=>this.cursorForward(B))),this._parser.registerCsiHandler({final:"D"},(B=>this.cursorBackward(B))),this._parser.registerCsiHandler({final:"E"},(B=>this.cursorNextLine(B))),this._parser.registerCsiHandler({final:"F"},(B=>this.cursorPrecedingLine(B))),this._parser.registerCsiHandler({final:"G"},(B=>this.cursorCharAbsolute(B))),this._parser.registerCsiHandler({final:"H"},(B=>this.cursorPosition(B))),this._parser.registerCsiHandler({final:"I"},(B=>this.cursorForwardTab(B))),this._parser.registerCsiHandler({final:"J"},(B=>this.eraseInDisplay(B,!1))),this._parser.registerCsiHandler({prefix:"?",final:"J"},(B=>this.eraseInDisplay(B,!0))),this._parser.registerCsiHandler({final:"K"},(B=>this.eraseInLine(B,!1))),this._parser.registerCsiHandler({prefix:"?",final:"K"},(B=>this.eraseInLine(B,!0))),this._parser.registerCsiHandler({final:"L"},(B=>this.insertLines(B))),this._parser.registerCsiHandler({final:"M"},(B=>this.deleteLines(B))),this._parser.registerCsiHandler({final:"P"},(B=>this.deleteChars(B))),this._parser.registerCsiHandler({final:"S"},(B=>this.scrollUp(B))),this._parser.registerCsiHandler({final:"T"},(B=>this.scrollDown(B))),this._parser.registerCsiHandler({final:"X"},(B=>this.eraseChars(B))),this._parser.registerCsiHandler({final:"Z"},(B=>this.cursorBackwardTab(B))),this._parser.registerCsiHandler({final:"`"},(B=>this.charPosAbsolute(B))),this._parser.registerCsiHandler({final:"a"},(B=>this.hPositionRelative(B))),this._parser.registerCsiHandler({final:"b"},(B=>this.repeatPrecedingCharacter(B))),this._parser.registerCsiHandler({final:"c"},(B=>this.sendDeviceAttributesPrimary(B))),this._parser.registerCsiHandler({prefix:">",final:"c"},(B=>this.sendDeviceAttributesSecondary(B))),this._parser.registerCsiHandler({final:"d"},(B=>this.linePosAbsolute(B))),this._parser.registerCsiHandler({final:"e"},(B=>this.vPositionRelative(B))),this._parser.registerCsiHandler({final:"f"},(B=>this.hVPosition(B))),this._parser.registerCsiHandler({final:"g"},(B=>this.tabClear(B))),this._parser.registerCsiHandler({final:"h"},(B=>this.setMode(B))),this._parser.registerCsiHandler({prefix:"?",final:"h"},(B=>this.setModePrivate(B))),this._parser.registerCsiHandler({final:"l"},(B=>this.resetMode(B))),this._parser.registerCsiHandler({prefix:"?",final:"l"},(B=>this.resetModePrivate(B))),this._parser.registerCsiHandler({final:"m"},(B=>this.charAttributes(B))),this._parser.registerCsiHandler({final:"n"},(B=>this.deviceStatus(B))),this._parser.registerCsiHandler({prefix:"?",final:"n"},(B=>this.deviceStatusPrivate(B))),this._parser.registerCsiHandler({intermediates:"!",final:"p"},(B=>this.softReset(B))),this._parser.registerCsiHandler({intermediates:" ",final:"q"},(B=>this.setCursorStyle(B))),this._parser.registerCsiHandler({final:"r"},(B=>this.setScrollRegion(B))),this._parser.registerCsiHandler({final:"s"},(B=>this.saveCursor(B))),this._parser.registerCsiHandler({final:"t"},(B=>this.windowOptions(B))),this._parser.registerCsiHandler({final:"u"},(B=>this.restoreCursor(B))),this._parser.registerCsiHandler({intermediates:"'",final:"}"},(B=>this.insertColumns(B))),this._parser.registerCsiHandler({intermediates:"'",final:"~"},(B=>this.deleteColumns(B))),this._parser.registerCsiHandler({intermediates:'"',final:"q"},(B=>this.selectProtected(B))),this._parser.registerCsiHandler({intermediates:"$",final:"p"},(B=>this.requestMode(B,!0))),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},(B=>this.requestMode(B,!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((B=>(this.setTitle(B),this.setIconName(B),!0)))),this._parser.registerOscHandler(1,new R.OscHandler((B=>this.setIconName(B)))),this._parser.registerOscHandler(2,new R.OscHandler((B=>this.setTitle(B)))),this._parser.registerOscHandler(4,new R.OscHandler((B=>this.setOrReportIndexedColor(B)))),this._parser.registerOscHandler(8,new R.OscHandler((B=>this.setHyperlink(B)))),this._parser.registerOscHandler(10,new R.OscHandler((B=>this.setOrReportFgColor(B)))),this._parser.registerOscHandler(11,new R.OscHandler((B=>this.setOrReportBgColor(B)))),this._parser.registerOscHandler(12,new R.OscHandler((B=>this.setOrReportCursorColor(B)))),this._parser.registerOscHandler(104,new R.OscHandler((B=>this.restoreIndexedColor(B)))),this._parser.registerOscHandler(110,new R.OscHandler((B=>this.restoreFgColor(B)))),this._parser.registerOscHandler(111,new R.OscHandler((B=>this.restoreBgColor(B)))),this._parser.registerOscHandler(112,new R.OscHandler((B=>this.restoreCursorColor(B)))),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 B in g.CHARSETS)this._parser.registerEscHandler({intermediates:"(",final:B},(()=>this.selectCharset("("+B))),this._parser.registerEscHandler({intermediates:")",final:B},(()=>this.selectCharset(")"+B))),this._parser.registerEscHandler({intermediates:"*",final:B},(()=>this.selectCharset("*"+B))),this._parser.registerEscHandler({intermediates:"+",final:B},(()=>this.selectCharset("+"+B))),this._parser.registerEscHandler({intermediates:"-",final:B},(()=>this.selectCharset("-"+B))),this._parser.registerEscHandler({intermediates:".",final:B},(()=>this.selectCharset("."+B))),this._parser.registerEscHandler({intermediates:"/",final:B},(()=>this.selectCharset("/"+B)));this._parser.registerEscHandler({intermediates:"#",final:"8"},(()=>this.screenAlignmentPattern())),this._parser.setErrorHandler((B=>(this._logService.error("Parsing error: ",B),B))),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new A.DcsHandler(((B,ne)=>this.requestStatusString(B,ne))))}_preserveStack(H,I,D,q){this._parseStack.paused=!0,this._parseStack.cursorStartX=H,this._parseStack.cursorStartY=I,this._parseStack.decodedLength=D,this._parseStack.position=q}_logSlowResolvingAsync(H){this._logService.logLevel<=T.LogLevelEnum.WARN&&Promise.race([H,new Promise(((I,D)=>setTimeout((()=>D("#SLOW_TIMEOUT")),5e3)))]).catch((I=>{if(I!=="#SLOW_TIMEOUT")throw I;console.warn("async parser handler taking longer than 5000 ms")}))}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(H,I){let D,q=this._activeBuffer.x,$=this._activeBuffer.y,J=0;const Y=this._parseStack.paused;if(Y){if(D=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,I))return this._logSlowResolvingAsync(D),D;q=this._parseStack.cursorStartX,$=this._parseStack.cursorStartY,this._parseStack.paused=!1,H.length>V&&(J=this._parseStack.position+V)}if(this._logService.logLevel<=T.LogLevelEnum.DEBUG&&this._logService.debug("parsing data"+(typeof H=="string"?` "${H}"`:` "${Array.prototype.map.call(H,(B=>String.fromCharCode(B))).join("")}"`),typeof H=="string"?H.split("").map((B=>B.charCodeAt(0))):H),this._parseBuffer.length<H.length&&this._parseBuffer.length<V&&(this._parseBuffer=new Uint32Array(Math.min(H.length,V))),Y||this._dirtyRowTracker.clearRange(),H.length>V)for(let B=J;B<H.length;B+=V){const ne=B+V<H.length?B+V:H.length,se=typeof H=="string"?this._stringDecoder.decode(H.substring(B,ne),this._parseBuffer):this._utf8Decoder.decode(H.subarray(B,ne),this._parseBuffer);if(D=this._parser.parse(this._parseBuffer,se))return this._preserveStack(q,$,se,B),this._logSlowResolvingAsync(D),D}else if(!Y){const B=typeof H=="string"?this._stringDecoder.decode(H,this._parseBuffer):this._utf8Decoder.decode(H,this._parseBuffer);if(D=this._parser.parse(this._parseBuffer,B))return this._preserveStack(q,$,B,0),this._logSlowResolvingAsync(D),D}this._activeBuffer.x===q&&this._activeBuffer.y===$||this._onCursorMove.fire();const Z=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),K=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);K<this._bufferService.rows&&this._onRequestRefreshRows.fire(Math.min(K,this._bufferService.rows-1),Math.min(Z,this._bufferService.rows-1))}print(H,I,D){let q,$;const J=this._charsetService.charset,Y=this._optionsService.rawOptions.screenReaderMode,Z=this._bufferService.cols,K=this._coreService.decPrivateModes.wraparound,B=this._coreService.modes.insertMode,ne=this._curAttrData;let se=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&D-I>0&&se.getWidth(this._activeBuffer.x-1)===2&&se.setCellFromCodepoint(this._activeBuffer.x-1,0,1,ne);let re=this._parser.precedingJoinState;for(let oe=I;oe<D;++oe){if(q=H[oe],q<127&&J){const ze=J[String.fromCharCode(q)];ze&&(q=ze.charCodeAt(0))}const ve=this._unicodeService.charProperties(q,re);$=N.UnicodeService.extractWidth(ve);const Se=N.UnicodeService.extractShouldJoin(ve),$e=Se?N.UnicodeService.extractWidth(re):0;if(re=ve,Y&&this._onA11yChar.fire((0,C.stringFromCodePoint)(q)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+$-$e>Z){if(K){const ze=se;let ke=this._activeBuffer.x-$e;for(this._activeBuffer.x=$e,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),$e>0&&se instanceof _.BufferLine&&se.copyCellsFrom(ze,ke,0,$e,!1);ke<Z;)ze.setCellFromCodepoint(ke++,0,1,ne)}else if(this._activeBuffer.x=Z-1,$===2)continue}if(Se&&this._activeBuffer.x){const ze=se.getWidth(this._activeBuffer.x-1)?1:2;se.addCodepointToCell(this._activeBuffer.x-ze,q,$);for(let ke=$-$e;--ke>=0;)se.setCellFromCodepoint(this._activeBuffer.x++,0,0,ne)}else if(B&&(se.insertCells(this._activeBuffer.x,$-$e,this._activeBuffer.getNullCell(ne)),se.getWidth(Z-1)===2&&se.setCellFromCodepoint(Z-1,b.NULL_CELL_CODE,b.NULL_CELL_WIDTH,ne)),se.setCellFromCodepoint(this._activeBuffer.x++,q,$,ne),$>0)for(;--$;)se.setCellFromCodepoint(this._activeBuffer.x++,0,0,ne)}this._parser.precedingJoinState=re,this._activeBuffer.x<Z&&D-I>0&&se.getWidth(this._activeBuffer.x)===0&&!se.hasContent(this._activeBuffer.x)&&se.setCellFromCodepoint(this._activeBuffer.x,0,1,ne),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(H,I){return H.final!=="t"||H.prefix||H.intermediates?this._parser.registerCsiHandler(H,I):this._parser.registerCsiHandler(H,(D=>!z(D.params[0],this._optionsService.rawOptions.windowOptions)||I(D)))}registerDcsHandler(H,I){return this._parser.registerDcsHandler(H,new A.DcsHandler(I))}registerEscHandler(H,I){return this._parser.registerEscHandler(H,I)}registerOscHandler(H,I){return this._parser.registerOscHandler(H,new R.OscHandler(I))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var H;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&((H=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&H.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;const I=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);I.hasWidth(this._activeBuffer.x)&&!I.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;const H=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-H),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(H=this._bufferService.cols-1){this._activeBuffer.x=Math.min(H,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(H,I){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=H,this._activeBuffer.y=this._activeBuffer.scrollTop+I):(this._activeBuffer.x=H,this._activeBuffer.y=I),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(H,I){this._restrictCursor(),this._setCursor(this._activeBuffer.x+H,this._activeBuffer.y+I)}cursorUp(H){const I=this._activeBuffer.y-this._activeBuffer.scrollTop;return I>=0?this._moveCursor(0,-Math.min(I,H.params[0]||1)):this._moveCursor(0,-(H.params[0]||1)),!0}cursorDown(H){const I=this._activeBuffer.scrollBottom-this._activeBuffer.y;return I>=0?this._moveCursor(0,Math.min(I,H.params[0]||1)):this._moveCursor(0,H.params[0]||1),!0}cursorForward(H){return this._moveCursor(H.params[0]||1,0),!0}cursorBackward(H){return this._moveCursor(-(H.params[0]||1),0),!0}cursorNextLine(H){return this.cursorDown(H),this._activeBuffer.x=0,!0}cursorPrecedingLine(H){return this.cursorUp(H),this._activeBuffer.x=0,!0}cursorCharAbsolute(H){return this._setCursor((H.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(H){return this._setCursor(H.length>=2?(H.params[1]||1)-1:0,(H.params[0]||1)-1),!0}charPosAbsolute(H){return this._setCursor((H.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(H){return this._moveCursor(H.params[0]||1,0),!0}linePosAbsolute(H){return this._setCursor(this._activeBuffer.x,(H.params[0]||1)-1),!0}vPositionRelative(H){return this._moveCursor(0,H.params[0]||1),!0}hVPosition(H){return this.cursorPosition(H),!0}tabClear(H){const I=H.params[0];return I===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:I===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(H){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let I=H.params[0]||1;for(;I--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(H){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let I=H.params[0]||1;for(;I--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(H){const I=H.params[0];return I===1&&(this._curAttrData.bg|=536870912),I!==2&&I!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(H,I,D,q=!1,$=!1){const J=this._activeBuffer.lines.get(this._activeBuffer.ybase+H);J.replaceCells(I,D,this._activeBuffer.getNullCell(this._eraseAttrData()),$),q&&(J.isWrapped=!1)}_resetBufferLine(H,I=!1){const D=this._activeBuffer.lines.get(this._activeBuffer.ybase+H);D&&(D.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),I),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+H),D.isWrapped=!1)}eraseInDisplay(H,I=!1){let D;switch(this._restrictCursor(this._bufferService.cols),H.params[0]){case 0:for(D=this._activeBuffer.y,this._dirtyRowTracker.markDirty(D),this._eraseInBufferLine(D++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,I);D<this._bufferService.rows;D++)this._resetBufferLine(D,I);this._dirtyRowTracker.markDirty(D);break;case 1:for(D=this._activeBuffer.y,this._dirtyRowTracker.markDirty(D),this._eraseInBufferLine(D,0,this._activeBuffer.x+1,!0,I),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(D+1).isWrapped=!1);D--;)this._resetBufferLine(D,I);this._dirtyRowTracker.markDirty(0);break;case 2:for(D=this._bufferService.rows,this._dirtyRowTracker.markDirty(D-1);D--;)this._resetBufferLine(D,I);this._dirtyRowTracker.markDirty(0);break;case 3:const q=this._activeBuffer.lines.length-this._bufferService.rows;q>0&&(this._activeBuffer.lines.trimStart(q),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-q,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-q,0),this._onScroll.fire(0))}return!0}eraseInLine(H,I=!1){switch(this._restrictCursor(this._bufferService.cols),H.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,I);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,I);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,I)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(H){this._restrictCursor();let I=H.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const D=this._activeBuffer.ybase+this._activeBuffer.y,q=this._bufferService.rows-1-this._activeBuffer.scrollBottom,$=this._bufferService.rows-1+this._activeBuffer.ybase-q+1;for(;I--;)this._activeBuffer.lines.splice($-1,1),this._activeBuffer.lines.splice(D,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(H){this._restrictCursor();let I=H.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const D=this._activeBuffer.ybase+this._activeBuffer.y;let q;for(q=this._bufferService.rows-1-this._activeBuffer.scrollBottom,q=this._bufferService.rows-1+this._activeBuffer.ybase-q;I--;)this._activeBuffer.lines.splice(D,1),this._activeBuffer.lines.splice(q,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(H){this._restrictCursor();const I=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return I&&(I.insertCells(this._activeBuffer.x,H.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(H){this._restrictCursor();const I=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return I&&(I.deleteCells(this._activeBuffer.x,H.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(H){let I=H.params[0]||1;for(;I--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(H){let I=H.params[0]||1;for(;I--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(_.DEFAULT_ATTR_DATA));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(H){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const I=H.params[0]||1;for(let D=this._activeBuffer.scrollTop;D<=this._activeBuffer.scrollBottom;++D){const q=this._activeBuffer.lines.get(this._activeBuffer.ybase+D);q.deleteCells(0,I,this._activeBuffer.getNullCell(this._eraseAttrData())),q.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(H){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const I=H.params[0]||1;for(let D=this._activeBuffer.scrollTop;D<=this._activeBuffer.scrollBottom;++D){const q=this._activeBuffer.lines.get(this._activeBuffer.ybase+D);q.insertCells(0,I,this._activeBuffer.getNullCell(this._eraseAttrData())),q.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(H){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const I=H.params[0]||1;for(let D=this._activeBuffer.scrollTop;D<=this._activeBuffer.scrollBottom;++D){const q=this._activeBuffer.lines.get(this._activeBuffer.ybase+D);q.insertCells(this._activeBuffer.x,I,this._activeBuffer.getNullCell(this._eraseAttrData())),q.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(H){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const I=H.params[0]||1;for(let D=this._activeBuffer.scrollTop;D<=this._activeBuffer.scrollBottom;++D){const q=this._activeBuffer.lines.get(this._activeBuffer.ybase+D);q.deleteCells(this._activeBuffer.x,I,this._activeBuffer.getNullCell(this._eraseAttrData())),q.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(H){this._restrictCursor();const I=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return I&&(I.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(H.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(H){const I=this._parser.precedingJoinState;if(!I)return!0;const D=H.params[0]||1,q=N.UnicodeService.extractWidth(I),$=this._activeBuffer.x-q,J=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString($),Y=new Uint32Array(J.length*D);let Z=0;for(let B=0;B<J.length;){const ne=J.codePointAt(B)||0;Y[Z++]=ne,B+=ne>65535?2:1}let K=Z;for(let B=1;B<D;++B)Y.copyWithin(K,0,Z),K+=Z;return this.print(Y,0,K),!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 I=0;I<H.length;I++)switch(H.params[I]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(H){for(let I=0;I<H.length;I++)switch(H.params[I]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,g.DEFAULT_CHARSET),this._charsetService.setgCharset(1,g.DEFAULT_CHARSET),this._charsetService.setgCharset(2,g.DEFAULT_CHARSET),this._charsetService.setgCharset(3,g.DEFAULT_CHARSET);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0}return!0}resetMode(H){for(let I=0;I<H.length;I++)switch(H.params[I]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(H){for(let I=0;I<H.length;I++)switch(H.params[I]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),H.params[I]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1}return!0}requestMode(H,I){const D=this._coreService.decPrivateModes,{activeProtocol:q,activeEncoding:$}=this._coreMouseService,J=this._coreService,{buffers:Y,cols:Z}=this._bufferService,{active:K,alt:B}=Y,ne=this._optionsService.rawOptions,se=Se=>Se?1:2,re=H.params[0];return oe=re,ve=I?re===2?4:re===4?se(J.modes.insertMode):re===12?3:re===20?se(ne.convertEol):0:re===1?se(D.applicationCursorKeys):re===3?ne.windowOptions.setWinLines?Z===80?2:Z===132?1:0:0:re===6?se(D.origin):re===7?se(D.wraparound):re===8?3:re===9?se(q==="X10"):re===12?se(ne.cursorBlink):re===25?se(!J.isCursorHidden):re===45?se(D.reverseWraparound):re===66?se(D.applicationKeypad):re===67?4:re===1e3?se(q==="VT200"):re===1002?se(q==="DRAG"):re===1003?se(q==="ANY"):re===1004?se(D.sendFocus):re===1005?4:re===1006?se($==="SGR"):re===1015?4:re===1016?se($==="SGR_PIXELS"):re===1048?1:re===47||re===1047||re===1049?se(K===B):re===2004?se(D.bracketedPasteMode):0,J.triggerDataEvent(`${m.C0.ESC}[${I?"":"?"}${oe};${ve}$y`),!0;var oe,ve}_updateAttrColor(H,I,D,q,$){return I===2?(H|=50331648,H&=-16777216,H|=k.AttributeData.fromColorRGB([D,q,$])):I===5&&(H&=-50331904,H|=33554432|255&D),H}_extractColor(H,I,D){const q=[0,0,-1,0,0,0];let $=0,J=0;do{if(q[J+$]=H.params[I+J],H.hasSubParams(I+J)){const Y=H.getSubParams(I+J);let Z=0;do q[1]===5&&($=1),q[J+Z+1+$]=Y[Z];while(++Z<Y.length&&Z+J+1+$<q.length);break}if(q[1]===5&&J+$>=2||q[1]===2&&J+$>=5)break;q[1]&&($=1)}while(++J+I<H.length&&J+$<q.length);for(let Y=2;Y<q.length;++Y)q[Y]===-1&&(q[Y]=0);switch(q[0]){case 38:D.fg=this._updateAttrColor(D.fg,q[1],q[3],q[4],q[5]);break;case 48:D.bg=this._updateAttrColor(D.bg,q[1],q[3],q[4],q[5]);break;case 58:D.extended=D.extended.clone(),D.extended.underlineColor=this._updateAttrColor(D.extended.underlineColor,q[1],q[3],q[4],q[5])}return J}_processUnderline(H,I){I.extended=I.extended.clone(),(!~H||H>5)&&(H=1),I.extended.underlineStyle=H,I.fg|=268435456,H===0&&(I.fg&=-268435457),I.updateExtended()}_processSGR0(H){H.fg=_.DEFAULT_ATTR_DATA.fg,H.bg=_.DEFAULT_ATTR_DATA.bg,H.extended=H.extended.clone(),H.extended.underlineStyle=0,H.extended.underlineColor&=-67108864,H.updateExtended()}charAttributes(H){if(H.length===1&&H.params[0]===0)return this._processSGR0(this._curAttrData),!0;const I=H.length;let D;const q=this._curAttrData;for(let $=0;$<I;$++)D=H.params[$],D>=30&&D<=37?(q.fg&=-50331904,q.fg|=16777216|D-30):D>=40&&D<=47?(q.bg&=-50331904,q.bg|=16777216|D-40):D>=90&&D<=97?(q.fg&=-50331904,q.fg|=16777224|D-90):D>=100&&D<=107?(q.bg&=-50331904,q.bg|=16777224|D-100):D===0?this._processSGR0(q):D===1?q.fg|=134217728:D===3?q.bg|=67108864:D===4?(q.fg|=268435456,this._processUnderline(H.hasSubParams($)?H.getSubParams($)[0]:1,q)):D===5?q.fg|=536870912:D===7?q.fg|=67108864:D===8?q.fg|=1073741824:D===9?q.fg|=2147483648:D===2?q.bg|=134217728:D===21?this._processUnderline(2,q):D===22?(q.fg&=-134217729,q.bg&=-134217729):D===23?q.bg&=-67108865:D===24?(q.fg&=-268435457,this._processUnderline(0,q)):D===25?q.fg&=-536870913:D===27?q.fg&=-67108865:D===28?q.fg&=-1073741825:D===29?q.fg&=2147483647:D===39?(q.fg&=-67108864,q.fg|=16777215&_.DEFAULT_ATTR_DATA.fg):D===49?(q.bg&=-67108864,q.bg|=16777215&_.DEFAULT_ATTR_DATA.bg):D===38||D===48||D===58?$+=this._extractColor(H,$,q):D===53?q.bg|=1073741824:D===55?q.bg&=-1073741825:D===59?(q.extended=q.extended.clone(),q.extended.underlineColor=-1,q.updateExtended()):D===100?(q.fg&=-67108864,q.fg|=16777215&_.DEFAULT_ATTR_DATA.fg,q.bg&=-67108864,q.bg|=16777215&_.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",D);return!0}deviceStatus(H){switch(H.params[0]){case 5:this._coreService.triggerDataEvent(`${m.C0.ESC}[0n`);break;case 6:const I=this._activeBuffer.y+1,D=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${m.C0.ESC}[${I};${D}R`)}return!0}deviceStatusPrivate(H){if(H.params[0]===6){const I=this._activeBuffer.y+1,D=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${m.C0.ESC}[?${I};${D}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=_.DEFAULT_ATTR_DATA.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(H){const I=H.params[0]||1;switch(I){case 1:case 2:this._optionsService.options.cursorStyle="block";break;case 3:case 4:this._optionsService.options.cursorStyle="underline";break;case 5:case 6:this._optionsService.options.cursorStyle="bar"}const D=I%2==1;return this._optionsService.options.cursorBlink=D,!0}setScrollRegion(H){const I=H.params[0]||1;let D;return(H.length<2||(D=H.params[1])>this._bufferService.rows||D===0)&&(D=this._bufferService.rows),D>I&&(this._activeBuffer.scrollTop=I-1,this._activeBuffer.scrollBottom=D-1,this._setCursor(0,0)),!0}windowOptions(H){if(!z(H.params[0],this._optionsService.rawOptions.windowOptions))return!0;const I=H.length>1?H.params[1]:0;switch(H.params[0]){case 14:I!==2&&this._onRequestWindowsOptionsReport.fire(W.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(W.GET_CELL_SIZE_PIXELS);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${m.C0.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:I!==0&&I!==2||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),I!==0&&I!==1||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:I!==0&&I!==2||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),I!==0&&I!==1||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(H){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(H){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(H){return this._windowTitle=H,this._onTitleChange.fire(H),!0}setIconName(H){return this._iconName=H,!0}setOrReportIndexedColor(H){const I=[],D=H.split(";");for(;D.length>1;){const q=D.shift(),$=D.shift();if(/^\d+$/.exec(q)){const J=parseInt(q);if(Q(J))if($==="?")I.push({type:0,index:J});else{const Y=(0,O.parseColor)($);Y&&I.push({type:1,index:J,color:Y})}}}return I.length&&this._onColor.fire(I),!0}setHyperlink(H){const I=H.split(";");return!(I.length<2)&&(I[1]?this._createHyperlink(I[0],I[1]):!I[0]&&this._finishHyperlink())}_createHyperlink(H,I){this._getCurrentLinkId()&&this._finishHyperlink();const D=H.split(":");let q;const $=D.findIndex((J=>J.startsWith("id=")));return $!==-1&&(q=D[$].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:q,uri:I}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(H,I){const D=H.split(";");for(let q=0;q<D.length&&!(I>=this._specialColors.length);++q,++I)if(D[q]==="?")this._onColor.fire([{type:0,index:this._specialColors[I]}]);else{const $=(0,O.parseColor)(D[q]);$&&this._onColor.fire([{type:1,index:this._specialColors[I],color:$}])}return!0}setOrReportFgColor(H){return this._setOrReportSpecialColor(H,0)}setOrReportBgColor(H){return this._setOrReportSpecialColor(H,1)}setOrReportCursorColor(H){return this._setOrReportSpecialColor(H,2)}restoreIndexedColor(H){if(!H)return this._onColor.fire([{type:2}]),!0;const I=[],D=H.split(";");for(let q=0;q<D.length;++q)if(/^\d+$/.exec(D[q])){const $=parseInt(D[q]);Q($)&&I.push({type:2,index:$})}return I.length&&this._onColor.fire(I),!0}restoreFgColor(H){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(H){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(H){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,g.DEFAULT_CHARSET),!0}selectCharset(H){return H.length!==2?(this.selectDefaultCharset(),!0):(H[0]==="/"||this._charsetService.setgCharset(P[H[0]],g.CHARSETS[H[1]]||g.DEFAULT_CHARSET),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){const 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=_.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=_.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 v.CellData;H.content=4194373,H.fg=this._curAttrData.fg,H.bg=this._curAttrData.bg,this._setCursor(0,0);for(let I=0;I<this._bufferService.rows;++I){const D=this._activeBuffer.ybase+this._activeBuffer.y+I,q=this._activeBuffer.lines.get(D);q&&(q.fill(H),q.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(H,I){const D=this._bufferService.buffer,q=this._optionsService.rawOptions;return($=>(this._coreService.triggerDataEvent(`${m.C0.ESC}${$}${m.C0.ESC}\\`),!0))(H==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:H==='"p'?'P1$r61;1"p':H==="r"?`P1$r${D.scrollTop+1};${D.scrollBottom+1}r`:H==="m"?"P1$r0m":H===" q"?`P1$r${{block:2,underline:4,bar:6}[q.cursorStyle]-(q.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(H,I){this._dirtyRowTracker.markRangeDirty(H,I)}}c.InputHandler=U;let F=class{constructor(X){this._bufferService=X,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(X){X<this.start?this.start=X:X>this.end&&(this.end=X)}markRangeDirty(X,H){X>H&&(M=X,X=H,H=M),X<this.start&&(this.start=X),H>this.end&&(this.end=H)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function Q(X){return 0<=X&&X<256}F=h([p(0,T.IBufferService)],F)},844:(u,c)=>{function d(h){for(const p of h)p.dispose();h.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 h of this._disposables)h.dispose();this._disposables.length=0}register(h){return this._disposables.push(h),h}unregister(h){const p=this._disposables.indexOf(h);p!==-1&&this._disposables.splice(p,1)}},c.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(h){var p;this._isDisposed||h===this._value||((p=this._value)==null||p.dispose(),this._value=h)}clear(){this.value=void 0}dispose(){var h;this._isDisposed=!0,(h=this._value)==null||h.dispose(),this._value=void 0}},c.toDisposable=function(h){return{dispose:h}},c.disposeArray=d,c.getDisposeArrayDisposable=function(h){return{dispose:()=>d(h)}}},1505:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.FourKeyMap=c.TwoKeyMap=void 0;class d{constructor(){this._data={}}set(p,m,g){this._data[p]||(this._data[p]={}),this._data[p][m]=g}get(p,m){return this._data[p]?this._data[p][m]:void 0}clear(){this._data={}}}c.TwoKeyMap=d,c.FourKeyMap=class{constructor(){this._data=new d}set(h,p,m,g,y){this._data.get(h,p)||this._data.set(h,p,new d),this._data.get(h,p).set(m,g,y)}get(h,p,m,g){var y;return(y=this._data.get(h,p))==null?void 0:y.get(m,g)}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,h=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(h),c.isIpad=h==="iPad",c.isIphone=h==="iPhone",c.isWindows=["Windows","Win16","Win32","WinCE"].includes(h),c.isLinux=h.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(h){this._getKey=h,this._array=[]}clear(){this._array.length=0}insert(h){this._array.length!==0?(d=this._search(this._getKey(h)),this._array.splice(d,0,h)):this._array.push(h)}delete(h){if(this._array.length===0)return!1;const p=this._getKey(h);if(p===void 0||(d=this._search(p),d===-1)||this._getKey(this._array[d])!==p)return!1;do if(this._array[d]===h)return this._array.splice(d,1),!0;while(++d<this._array.length&&this._getKey(this._array[d])===p);return!1}*getKeyIterator(h){if(this._array.length!==0&&(d=this._search(h),!(d<0||d>=this._array.length)&&this._getKey(this._array[d])===h))do yield this._array[d];while(++d<this._array.length&&this._getKey(this._array[d])===h)}forEachByKey(h,p){if(this._array.length!==0&&(d=this._search(h),!(d<0||d>=this._array.length)&&this._getKey(this._array[d])===h))do p(this._array[d]);while(++d<this._array.length&&this._getKey(this._array[d])===h)}values(){return[...this._array].values()}_search(h){let p=0,m=this._array.length-1;for(;m>=p;){let g=p+m>>1;const y=this._getKey(this._array[g]);if(y>h)m=g-1;else{if(!(y<h)){for(;g>0&&this._getKey(this._array[g-1])===h;)g--;return g}p=g+1}}return p}}},7226:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.DebouncedIdleTask=c.IdleTaskQueue=c.PriorityTaskQueue=void 0;const h=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,_=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 _-w<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(_-w))}ms`),void this._start();_=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=!h.isNode&&"requestIdleCallback"in window?class extends p{_requestCallback(g){return requestIdleCallback(g)}_cancelCallback(g){cancelIdleCallback(g)}}:m,c.DebouncedIdleTask=class{constructor(){this._queue=new c.IdleTaskQueue}set(g){this._queue.clear(),this._queue.enqueue(g)}flush(){this._queue.flush()}}},9282:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.updateWindowsModeWrappedState=void 0;const h=d(643);c.updateWindowsModeWrappedState=function(p){const m=p.buffer.lines.get(p.buffer.ybase+p.buffer.y-1),g=m==null?void 0:m.get(p.cols-1),y=p.buffer.lines.get(p.buffer.ybase+p.buffer.y);y&&g&&(y.isWrapped=g[h.CHAR_DATA_CODE_INDEX]!==h.NULL_CELL_CODE&&g[h.CHAR_DATA_CODE_INDEX]!==h.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 h}static toColorRGB(m){return[m>>>16&255,m>>>8&255,255&m]}static fromColorRGB(m){return(255&m[0])<<16|(255&m[1])<<8|255&m[2]}clone(){const m=new d;return m.fg=this.fg,m.bg=this.bg,m.extended=this.extended.clone(),m}isInverse(){return 67108864&this.fg}isBold(){return 134217728&this.fg}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:268435456&this.fg}isBlink(){return 536870912&this.fg}isInvisible(){return 1073741824&this.fg}isItalic(){return 67108864&this.bg}isDim(){return 134217728&this.bg}isStrikethrough(){return 2147483648&this.fg}isProtected(){return 536870912&this.bg}isOverline(){return 1073741824&this.bg}getFgColorMode(){return 50331648&this.fg}getBgColorMode(){return 50331648&this.bg}isFgRGB(){return(50331648&this.fg)==50331648}isBgRGB(){return(50331648&this.bg)==50331648}isFgPalette(){return(50331648&this.fg)==16777216||(50331648&this.fg)==33554432}isBgPalette(){return(50331648&this.bg)==16777216||(50331648&this.bg)==33554432}isFgDefault(){return(50331648&this.fg)==0}isBgDefault(){return(50331648&this.bg)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}}getBgColor(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}}hasExtendedAttrs(){return 268435456&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(268435456&this.bg&&~this.extended.underlineColor)switch(50331648&this.extended.underlineColor){case 16777216:case 33554432:return 255&this.extended.underlineColor;case 50331648:return 16777215&this.extended.underlineColor;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return 268435456&this.bg&&~this.extended.underlineColor?50331648&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==16777216||(50331648&this.extended.underlineColor)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==0:this.isFgDefault()}getUnderlineStyle(){return 268435456&this.fg?268435456&this.bg?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}}c.AttributeData=d;class h{get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(m){this._ext=m}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(m){this._ext&=-469762049,this._ext|=m<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(m){this._ext&=-67108864,this._ext|=67108863&m}get urlId(){return this._urlId}set urlId(m){this._urlId=m}get underlineVariantOffset(){const m=(3758096384&this._ext)>>29;return m<0?4294967288^m:m}set underlineVariantOffset(m){this._ext&=536870911,this._ext|=m<<29&3758096384}constructor(m=0,g=0){this._ext=0,this._urlId=0,this._ext=m,this._urlId=g}clone(){return new h(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}c.ExtendedAttrs=h},9092:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.Buffer=c.MAX_BUFFER_SIZE=void 0;const h=d(6349),p=d(7226),m=d(3734),g=d(8437),y=d(4634),w=d(511),C=d(643),_=d(4863),S=d(7116);c.MAX_BUFFER_SIZE=4294967295,c.Buffer=class{constructor(b,v,k){this._hasScrollback=b,this._optionsService=v,this._bufferService=k,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=g.DEFAULT_ATTR_DATA.clone(),this.savedCharset=S.DEFAULT_CHARSET,this.markers=[],this._nullCell=w.CellData.fromCharData([0,C.NULL_CELL_CHAR,C.NULL_CELL_WIDTH,C.NULL_CELL_CODE]),this._whitespaceCell=w.CellData.fromCharData([0,C.WHITESPACE_CELL_CHAR,C.WHITESPACE_CELL_WIDTH,C.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new p.IdleTaskQueue,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new h.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(b){return b?(this._nullCell.fg=b.fg,this._nullCell.bg=b.bg,this._nullCell.extended=b.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new m.ExtendedAttrs),this._nullCell}getWhitespaceCell(b){return b?(this._whitespaceCell.fg=b.fg,this._whitespaceCell.bg=b.bg,this._whitespaceCell.extended=b.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new m.ExtendedAttrs),this._whitespaceCell}getBlankLine(b,v){return new g.BufferLine(this._bufferService.cols,this.getNullCell(b),v)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){const b=this.ybase+this.y-this.ydisp;return b>=0&&b<this._rows}_getCorrectBufferLength(b){if(!this._hasScrollback)return b;const v=b+this._optionsService.rawOptions.scrollback;return v>c.MAX_BUFFER_SIZE?c.MAX_BUFFER_SIZE:v}fillViewportRows(b){if(this.lines.length===0){b===void 0&&(b=g.DEFAULT_ATTR_DATA);let v=this._rows;for(;v--;)this.lines.push(this.getBlankLine(b))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new h.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(b,v){const k=this.getNullCell(g.DEFAULT_ATTR_DATA);let T=0;const N=this._getCorrectBufferLength(v);if(N>this.lines.maxLength&&(this.lines.maxLength=N),this.lines.length>0){if(this._cols<b)for(let A=0;A<this.lines.length;A++)T+=+this.lines.get(A).resize(b,k);let R=0;if(this._rows<v)for(let A=this._rows;A<v;A++)this.lines.length<v+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new g.BufferLine(b,k)):this.ybase>0&&this.lines.length<=this.ybase+this.y+R+1?(this.ybase--,R++,this.ydisp>0&&this.ydisp--):this.lines.push(new g.BufferLine(b,k)));else for(let A=this._rows;A>v;A--)this.lines.length>v+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(N<this.lines.maxLength){const A=this.lines.length-N;A>0&&(this.lines.trimStart(A),this.ybase=Math.max(this.ybase-A,0),this.ydisp=Math.max(this.ydisp-A,0),this.savedY=Math.max(this.savedY-A,0)),this.lines.maxLength=N}this.x=Math.min(this.x,b-1),this.y=Math.min(this.y,v-1),R&&(this.y+=R),this.savedX=Math.min(this.savedX,b-1),this.scrollTop=0}if(this.scrollBottom=v-1,this._isReflowEnabled&&(this._reflow(b,v),this._cols>b))for(let R=0;R<this.lines.length;R++)T+=+this.lines.get(R).resize(b,k);this._cols=b,this._rows=v,this._memoryCleanupQueue.clear(),T>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue((()=>this._batchedMemoryCleanup())))}_batchedMemoryCleanup(){let b=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,b=!1);let v=0;for(;this._memoryCleanupPosition<this.lines.length;)if(v+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),v>100)return!0;return b}get _isReflowEnabled(){const b=this._optionsService.rawOptions.windowsPty;return b&&b.buildNumber?this._hasScrollback&&b.backend==="conpty"&&b.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(b,v){this._cols!==b&&(b>this._cols?this._reflowLarger(b,v):this._reflowSmaller(b,v))}_reflowLarger(b,v){const k=(0,y.reflowLargerGetLinesToRemove)(this.lines,this._cols,b,this.ybase+this.y,this.getNullCell(g.DEFAULT_ATTR_DATA));if(k.length>0){const T=(0,y.reflowLargerCreateNewLayout)(this.lines,k);(0,y.reflowLargerApplyNewLayout)(this.lines,T.layout),this._reflowLargerAdjustViewport(b,v,T.countRemoved)}}_reflowLargerAdjustViewport(b,v,k){const T=this.getNullCell(g.DEFAULT_ATTR_DATA);let N=k;for(;N-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<v&&this.lines.push(new g.BufferLine(b,T))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-k,0)}_reflowSmaller(b,v){const k=this.getNullCell(g.DEFAULT_ATTR_DATA),T=[];let N=0;for(let R=this.lines.length-1;R>=0;R--){let A=this.lines.get(R);if(!A||!A.isWrapped&&A.getTrimmedLength()<=b)continue;const O=[A];for(;A.isWrapped&&R>0;)A=this.lines.get(--R),O.unshift(A);const P=this.ybase+this.y;if(P>=R&&P<R+O.length)continue;const V=O[O.length-1].getTrimmedLength(),z=(0,y.reflowSmallerGetNewLineLengths)(O,this._cols,b),W=z.length-O.length;let M;M=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+W):Math.max(0,this.lines.length-this.lines.maxLength+W);const U=[];for(let D=0;D<W;D++){const q=this.getBlankLine(g.DEFAULT_ATTR_DATA,!0);U.push(q)}U.length>0&&(T.push({start:R+O.length+N,newLines:U}),N+=U.length),O.push(...U);let F=z.length-1,Q=z[F];Q===0&&(F--,Q=z[F]);let X=O.length-W-1,H=V;for(;X>=0;){const D=Math.min(H,Q);if(O[F]===void 0)break;if(O[F].copyCellsFrom(O[X],H-D,Q-D,D,!0),Q-=D,Q===0&&(F--,Q=z[F]),H-=D,H===0){X--;const q=Math.max(X,0);H=(0,y.getWrappedLineTrimmedLength)(O,q,this._cols)}}for(let D=0;D<O.length;D++)z[D]<b&&O[D].setCell(z[D],k);let I=W-M;for(;I-- >0;)this.ybase===0?this.y<v-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+N)-v&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+W,this.ybase+v-1)}if(T.length>0){const R=[],A=[];for(let F=0;F<this.lines.length;F++)A.push(this.lines.get(F));const O=this.lines.length;let P=O-1,V=0,z=T[V];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+N);let W=0;for(let F=Math.min(this.lines.maxLength-1,O+N-1);F>=0;F--)if(z&&z.start>P+W){for(let Q=z.newLines.length-1;Q>=0;Q--)this.lines.set(F--,z.newLines[Q]);F++,R.push({index:P+1,amount:z.newLines.length}),W+=z.newLines.length,z=T[++V]}else this.lines.set(F,A[P--]);let M=0;for(let F=R.length-1;F>=0;F--)R[F].index+=M,this.lines.onInsertEmitter.fire(R[F]),M+=R[F].amount;const U=Math.max(0,O+N-this.lines.maxLength);U>0&&this.lines.onTrimEmitter.fire(U)}}translateBufferLineToString(b,v,k=0,T){const N=this.lines.get(b);return N?N.translateToString(v,k,T):""}getWrappedRangeForLine(b){let v=b,k=b;for(;v>0&&this.lines.get(v).isWrapped;)v--;for(;k+1<this.lines.length&&this.lines.get(k+1).isWrapped;)k++;return{first:v,last:k}}setupTabStops(b){for(b!=null?this.tabs[b]||(b=this.prevStop(b)):(this.tabs={},b=0);b<this._cols;b+=this._optionsService.rawOptions.tabStopWidth)this.tabs[b]=!0}prevStop(b){for(b==null&&(b=this.x);!this.tabs[--b]&&b>0;);return b>=this._cols?this._cols-1:b<0?0:b}nextStop(b){for(b==null&&(b=this.x);!this.tabs[++b]&&b<this._cols;);return b>=this._cols?this._cols-1:b<0?0:b}clearMarkers(b){this._isClearing=!0;for(let v=0;v<this.markers.length;v++)this.markers[v].line===b&&(this.markers[v].dispose(),this.markers.splice(v--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let b=0;b<this.markers.length;b++)this.markers[b].dispose(),this.markers.splice(b--,1);this._isClearing=!1}addMarker(b){const v=new _.Marker(b);return this.markers.push(v),v.register(this.lines.onTrim((k=>{v.line-=k,v.line<0&&v.dispose()}))),v.register(this.lines.onInsert((k=>{v.line>=k.index&&(v.line+=k.amount)}))),v.register(this.lines.onDelete((k=>{v.line>=k.index&&v.line<k.index+k.amount&&v.dispose(),v.line>k.index&&(v.line-=k.amount)}))),v.register(v.onDispose((()=>this._removeMarker(v)))),v}_removeMarker(b){this._isClearing||this.markers.splice(this.markers.indexOf(b),1)}}},8437:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.BufferLine=c.DEFAULT_ATTR_DATA=void 0;const h=d(3734),p=d(511),m=d(643),g=d(482);c.DEFAULT_ATTR_DATA=Object.freeze(new h.AttributeData);let y=0;class w{constructor(_,S,b=!1){this.isWrapped=b,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*_);const v=S||p.CellData.fromCharData([0,m.NULL_CELL_CHAR,m.NULL_CELL_WIDTH,m.NULL_CELL_CODE]);for(let k=0;k<_;++k)this.setCell(k,v);this.length=_}get(_){const S=this._data[3*_+0],b=2097151&S;return[this._data[3*_+1],2097152&S?this._combined[_]:b?(0,g.stringFromCodePoint)(b):"",S>>22,2097152&S?this._combined[_].charCodeAt(this._combined[_].length-1):b]}set(_,S){this._data[3*_+1]=S[m.CHAR_DATA_ATTR_INDEX],S[m.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[_]=S[1],this._data[3*_+0]=2097152|_|S[m.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*_+0]=S[m.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|S[m.CHAR_DATA_WIDTH_INDEX]<<22}getWidth(_){return this._data[3*_+0]>>22}hasWidth(_){return 12582912&this._data[3*_+0]}getFg(_){return this._data[3*_+1]}getBg(_){return this._data[3*_+2]}hasContent(_){return 4194303&this._data[3*_+0]}getCodePoint(_){const S=this._data[3*_+0];return 2097152&S?this._combined[_].charCodeAt(this._combined[_].length-1):2097151&S}isCombined(_){return 2097152&this._data[3*_+0]}getString(_){const S=this._data[3*_+0];return 2097152&S?this._combined[_]:2097151&S?(0,g.stringFromCodePoint)(2097151&S):""}isProtected(_){return 536870912&this._data[3*_+2]}loadCell(_,S){return y=3*_,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[_]),268435456&S.bg&&(S.extended=this._extendedAttrs[_]),S}setCell(_,S){2097152&S.content&&(this._combined[_]=S.combinedData),268435456&S.bg&&(this._extendedAttrs[_]=S.extended),this._data[3*_+0]=S.content,this._data[3*_+1]=S.fg,this._data[3*_+2]=S.bg}setCellFromCodepoint(_,S,b,v){268435456&v.bg&&(this._extendedAttrs[_]=v.extended),this._data[3*_+0]=S|b<<22,this._data[3*_+1]=v.fg,this._data[3*_+2]=v.bg}addCodepointToCell(_,S,b){let v=this._data[3*_+0];2097152&v?this._combined[_]+=(0,g.stringFromCodePoint)(S):2097151&v?(this._combined[_]=(0,g.stringFromCodePoint)(2097151&v)+(0,g.stringFromCodePoint)(S),v&=-2097152,v|=2097152):v=S|4194304,b&&(v&=-12582913,v|=b<<22),this._data[3*_+0]=v}insertCells(_,S,b){if((_%=this.length)&&this.getWidth(_-1)===2&&this.setCellFromCodepoint(_-1,0,1,b),S<this.length-_){const v=new p.CellData;for(let k=this.length-_-S-1;k>=0;--k)this.setCell(_+S+k,this.loadCell(_+k,v));for(let k=0;k<S;++k)this.setCell(_+k,b)}else for(let v=_;v<this.length;++v)this.setCell(v,b);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,b)}deleteCells(_,S,b){if(_%=this.length,S<this.length-_){const v=new p.CellData;for(let k=0;k<this.length-_-S;++k)this.setCell(_+k,this.loadCell(_+S+k,v));for(let k=this.length-S;k<this.length;++k)this.setCell(k,b)}else for(let v=_;v<this.length;++v)this.setCell(v,b);_&&this.getWidth(_-1)===2&&this.setCellFromCodepoint(_-1,0,1,b),this.getWidth(_)!==0||this.hasContent(_)||this.setCellFromCodepoint(_,0,1,b)}replaceCells(_,S,b,v=!1){if(v)for(_&&this.getWidth(_-1)===2&&!this.isProtected(_-1)&&this.setCellFromCodepoint(_-1,0,1,b),S<this.length&&this.getWidth(S-1)===2&&!this.isProtected(S)&&this.setCellFromCodepoint(S,0,1,b);_<S&&_<this.length;)this.isProtected(_)||this.setCell(_,b),_++;else for(_&&this.getWidth(_-1)===2&&this.setCellFromCodepoint(_-1,0,1,b),S<this.length&&this.getWidth(S-1)===2&&this.setCellFromCodepoint(S,0,1,b);_<S&&_<this.length;)this.setCell(_++,b)}resize(_,S){if(_===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;const b=3*_;if(_>this.length){if(this._data.buffer.byteLength>=4*b)this._data=new Uint32Array(this._data.buffer,0,b);else{const v=new Uint32Array(b);v.set(this._data),this._data=v}for(let v=this.length;v<_;++v)this.setCell(v,S)}else{this._data=this._data.subarray(0,b);const v=Object.keys(this._combined);for(let T=0;T<v.length;T++){const N=parseInt(v[T],10);N>=_&&delete this._combined[N]}const k=Object.keys(this._extendedAttrs);for(let T=0;T<k.length;T++){const N=parseInt(k[T],10);N>=_&&delete this._extendedAttrs[N]}}return this.length=_,4*b*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){const _=new Uint32Array(this._data.length);return _.set(this._data),this._data=_,1}return 0}fill(_,S=!1){if(S)for(let b=0;b<this.length;++b)this.isProtected(b)||this.setCell(b,_);else{this._combined={},this._extendedAttrs={};for(let b=0;b<this.length;++b)this.setCell(b,_)}}copyFrom(_){this.length!==_.length?this._data=new Uint32Array(_._data):this._data.set(_._data),this.length=_.length,this._combined={};for(const S in _._combined)this._combined[S]=_._combined[S];this._extendedAttrs={};for(const S in _._extendedAttrs)this._extendedAttrs[S]=_._extendedAttrs[S];this.isWrapped=_.isWrapped}clone(){const _=new w(0);_._data=new Uint32Array(this._data),_.length=this.length;for(const S in this._combined)_._combined[S]=this._combined[S];for(const S in this._extendedAttrs)_._extendedAttrs[S]=this._extendedAttrs[S];return _.isWrapped=this.isWrapped,_}getTrimmedLength(){for(let _=this.length-1;_>=0;--_)if(4194303&this._data[3*_+0])return _+(this._data[3*_+0]>>22);return 0}getNoBgTrimmedLength(){for(let _=this.length-1;_>=0;--_)if(4194303&this._data[3*_+0]||50331648&this._data[3*_+2])return _+(this._data[3*_+0]>>22);return 0}copyCellsFrom(_,S,b,v,k){const T=_._data;if(k)for(let R=v-1;R>=0;R--){for(let A=0;A<3;A++)this._data[3*(b+R)+A]=T[3*(S+R)+A];268435456&T[3*(S+R)+2]&&(this._extendedAttrs[b+R]=_._extendedAttrs[S+R])}else for(let R=0;R<v;R++){for(let A=0;A<3;A++)this._data[3*(b+R)+A]=T[3*(S+R)+A];268435456&T[3*(S+R)+2]&&(this._extendedAttrs[b+R]=_._extendedAttrs[S+R])}const N=Object.keys(_._combined);for(let R=0;R<N.length;R++){const A=parseInt(N[R],10);A>=S&&(this._combined[A-S+b]=_._combined[A])}}translateToString(_,S,b,v){S=S??0,b=b??this.length,_&&(b=Math.min(b,this.getTrimmedLength())),v&&(v.length=0);let k="";for(;S<b;){const T=this._data[3*S+0],N=2097151&T,R=2097152&T?this._combined[S]:N?(0,g.stringFromCodePoint)(N):m.WHITESPACE_CELL_CHAR;if(k+=R,v)for(let A=0;A<R.length;++A)v.push(S);S+=T>>22||1}return v&&v.push(S),k}}c.BufferLine=w},4841:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.getRangeLength=void 0,c.getRangeLength=function(d,h){if(d.start.y>d.end.y)throw new Error(`Buffer range end (${d.end.x}, ${d.end.y}) cannot be before start (${d.start.x}, ${d.start.y})`);return h*(d.end.y-d.start.y)+(d.end.x-d.start.x+1)}},4634:(u,c)=>{function d(h,p,m){if(p===h.length-1)return h[p].getTrimmedLength();const g=!h[p].hasContent(m-1)&&h[p].getWidth(m-1)===1,y=h[p+1].getWidth(0)===2;return g&&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(h,p,m,g,y){const w=[];for(let C=0;C<h.length-1;C++){let _=C,S=h.get(++_);if(!S.isWrapped)continue;const b=[h.get(C)];for(;_<h.length&&S.isWrapped;)b.push(S),S=h.get(++_);if(g>=C&&g<_){C+=b.length-1;continue}let v=0,k=d(b,v,p),T=1,N=0;for(;T<b.length;){const A=d(b,T,p),O=A-N,P=m-k,V=Math.min(O,P);b[v].copyCellsFrom(b[T],N,k,V,!1),k+=V,k===m&&(v++,k=0),N+=V,N===A&&(T++,N=0),k===0&&v!==0&&b[v-1].getWidth(m-1)===2&&(b[v].copyCellsFrom(b[v-1],m-1,k++,1,!1),b[v-1].setCell(m-1,y))}b[v].replaceCells(k,m,y);let R=0;for(let A=b.length-1;A>0&&(A>v||b[A].getTrimmedLength()===0);A--)R++;R>0&&(w.push(C+b.length-R),w.push(R)),C+=b.length-1}return w},c.reflowLargerCreateNewLayout=function(h,p){const m=[];let g=0,y=p[g],w=0;for(let C=0;C<h.length;C++)if(y===C){const _=p[++g];h.onDeleteEmitter.fire({index:C-w,amount:_}),C+=_-1,w+=_,y=p[++g]}else m.push(C);return{layout:m,countRemoved:w}},c.reflowLargerApplyNewLayout=function(h,p){const m=[];for(let g=0;g<p.length;g++)m.push(h.get(p[g]));for(let g=0;g<m.length;g++)h.set(g,m[g]);h.length=p.length},c.reflowSmallerGetNewLineLengths=function(h,p,m){const g=[],y=h.map(((S,b)=>d(h,b,p))).reduce(((S,b)=>S+b));let w=0,C=0,_=0;for(;_<y;){if(y-_<m){g.push(y-_);break}w+=m;const S=d(h,C,p);w>S&&(w-=S,C++);const b=h[C].getWidth(w-1)===2;b&&w--;const v=b?m-1:m;g.push(v),_+=v}return g},c.getWrappedLineTrimmedLength=d},5295:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.BufferSet=void 0;const h=d(8460),p=d(844),m=d(9092);class g extends p.Disposable{constructor(w,C){super(),this._optionsService=w,this._bufferService=C,this._onBufferActivate=this.register(new h.EventEmitter),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.resize(this._bufferService.cols,this._bufferService.rows)))),this.register(this._optionsService.onSpecificOptionChange("tabStopWidth",(()=>this.setupTabStops())))}reset(){this._normal=new m.Buffer(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new m.Buffer(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(w){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(w),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(w,C){this._normal.resize(w,C),this._alt.resize(w,C),this.setupTabStops(w)}setupTabStops(w){this._normal.setupTabStops(w),this._alt.setupTabStops(w)}}c.BufferSet=g},511:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.CellData=void 0;const h=d(482),p=d(643),m=d(3734);class g extends m.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new m.ExtendedAttrs,this.combinedData=""}static fromCharData(w){const C=new g;return C.setFromCharData(w),C}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?(0,h.stringFromCodePoint)(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(w){this.fg=w[p.CHAR_DATA_ATTR_INDEX],this.bg=0;let C=!1;if(w[p.CHAR_DATA_CHAR_INDEX].length>2)C=!0;else if(w[p.CHAR_DATA_CHAR_INDEX].length===2){const _=w[p.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=_&&_<=56319){const S=w[p.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=S&&S<=57343?this.content=1024*(_-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=g},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 h=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 h.EventEmitter),this.onDispose=this._onDispose.event}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),(0,p.disposeArray)(this._disposables),this._disposables.length=0)}register(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,h,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=`
260
+ `,m.VT="\v",m.FF="\f",m.CR="\r",m.SO="",m.SI="",m.DLE="",m.DC1="",m.DC2="",m.DC3="",m.DC4="",m.NAK="",m.SYN="",m.ETB="",m.CAN="",m.EM="",m.SUB="",m.ESC="\x1B",m.FS="",m.GS="",m.RS="",m.US="",m.SP=" ",m.DEL=""})(d||(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="Ÿ"})(h||(c.C1=h={})),(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 h=d(2584),p={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};c.evaluateKeyboardEvent=function(m,g,y,w){const C={type:0,cancel:!1,key:void 0},_=(m.shiftKey?1:0)|(m.altKey?2:0)|(m.ctrlKey?4:0)|(m.metaKey?8:0);switch(m.keyCode){case 0:m.key==="UIKeyInputUpArrow"?C.key=g?h.C0.ESC+"OA":h.C0.ESC+"[A":m.key==="UIKeyInputLeftArrow"?C.key=g?h.C0.ESC+"OD":h.C0.ESC+"[D":m.key==="UIKeyInputRightArrow"?C.key=g?h.C0.ESC+"OC":h.C0.ESC+"[C":m.key==="UIKeyInputDownArrow"&&(C.key=g?h.C0.ESC+"OB":h.C0.ESC+"[B");break;case 8:C.key=m.ctrlKey?"\b":h.C0.DEL,m.altKey&&(C.key=h.C0.ESC+C.key);break;case 9:if(m.shiftKey){C.key=h.C0.ESC+"[Z";break}C.key=h.C0.HT,C.cancel=!0;break;case 13:C.key=m.altKey?h.C0.ESC+h.C0.CR:h.C0.CR,C.cancel=!0;break;case 27:C.key=h.C0.ESC,m.altKey&&(C.key=h.C0.ESC+h.C0.ESC),C.cancel=!0;break;case 37:if(m.metaKey)break;_?(C.key=h.C0.ESC+"[1;"+(_+1)+"D",C.key===h.C0.ESC+"[1;3D"&&(C.key=h.C0.ESC+(y?"b":"[1;5D"))):C.key=g?h.C0.ESC+"OD":h.C0.ESC+"[D";break;case 39:if(m.metaKey)break;_?(C.key=h.C0.ESC+"[1;"+(_+1)+"C",C.key===h.C0.ESC+"[1;3C"&&(C.key=h.C0.ESC+(y?"f":"[1;5C"))):C.key=g?h.C0.ESC+"OC":h.C0.ESC+"[C";break;case 38:if(m.metaKey)break;_?(C.key=h.C0.ESC+"[1;"+(_+1)+"A",y||C.key!==h.C0.ESC+"[1;3A"||(C.key=h.C0.ESC+"[1;5A")):C.key=g?h.C0.ESC+"OA":h.C0.ESC+"[A";break;case 40:if(m.metaKey)break;_?(C.key=h.C0.ESC+"[1;"+(_+1)+"B",y||C.key!==h.C0.ESC+"[1;3B"||(C.key=h.C0.ESC+"[1;5B")):C.key=g?h.C0.ESC+"OB":h.C0.ESC+"[B";break;case 45:m.shiftKey||m.ctrlKey||(C.key=h.C0.ESC+"[2~");break;case 46:C.key=_?h.C0.ESC+"[3;"+(_+1)+"~":h.C0.ESC+"[3~";break;case 36:C.key=_?h.C0.ESC+"[1;"+(_+1)+"H":g?h.C0.ESC+"OH":h.C0.ESC+"[H";break;case 35:C.key=_?h.C0.ESC+"[1;"+(_+1)+"F":g?h.C0.ESC+"OF":h.C0.ESC+"[F";break;case 33:m.shiftKey?C.type=2:m.ctrlKey?C.key=h.C0.ESC+"[5;"+(_+1)+"~":C.key=h.C0.ESC+"[5~";break;case 34:m.shiftKey?C.type=3:m.ctrlKey?C.key=h.C0.ESC+"[6;"+(_+1)+"~":C.key=h.C0.ESC+"[6~";break;case 112:C.key=_?h.C0.ESC+"[1;"+(_+1)+"P":h.C0.ESC+"OP";break;case 113:C.key=_?h.C0.ESC+"[1;"+(_+1)+"Q":h.C0.ESC+"OQ";break;case 114:C.key=_?h.C0.ESC+"[1;"+(_+1)+"R":h.C0.ESC+"OR";break;case 115:C.key=_?h.C0.ESC+"[1;"+(_+1)+"S":h.C0.ESC+"OS";break;case 116:C.key=_?h.C0.ESC+"[15;"+(_+1)+"~":h.C0.ESC+"[15~";break;case 117:C.key=_?h.C0.ESC+"[17;"+(_+1)+"~":h.C0.ESC+"[17~";break;case 118:C.key=_?h.C0.ESC+"[18;"+(_+1)+"~":h.C0.ESC+"[18~";break;case 119:C.key=_?h.C0.ESC+"[19;"+(_+1)+"~":h.C0.ESC+"[19~";break;case 120:C.key=_?h.C0.ESC+"[20;"+(_+1)+"~":h.C0.ESC+"[20~";break;case 121:C.key=_?h.C0.ESC+"[21;"+(_+1)+"~":h.C0.ESC+"[21~";break;case 122:C.key=_?h.C0.ESC+"[23;"+(_+1)+"~":h.C0.ESC+"[23~";break;case 123:C.key=_?h.C0.ESC+"[24;"+(_+1)+"~":h.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=h.C0.US),m.key==="@"&&(C.key=h.C0.NUL)):m.keyCode===65&&(C.type=1);else{const S=p[m.keyCode],b=S==null?void 0:S[m.shiftKey?1:0];if(b)C.key=h.C0.ESC+b;else if(m.keyCode>=65&&m.keyCode<=90){const v=m.ctrlKey?m.keyCode-64:m.keyCode+32;let k=String.fromCharCode(v);m.shiftKey&&(k=k.toUpperCase()),C.key=h.C0.ESC+k}else if(m.keyCode===32)C.key=h.C0.ESC+(m.ctrlKey?h.C0.NUL:" ");else if(m.key==="Dead"&&m.code.startsWith("Key")){let v=m.code.slice(3,4);m.shiftKey||(v=v.toLowerCase()),C.key=h.C0.ESC+v,C.cancel=!0}}else m.keyCode>=65&&m.keyCode<=90?C.key=String.fromCharCode(m.keyCode-64):m.keyCode===32?C.key=h.C0.NUL:m.keyCode>=51&&m.keyCode<=55?C.key=String.fromCharCode(m.keyCode-51+27):m.keyCode===56?C.key=h.C0.DEL:m.keyCode===219?C.key=h.C0.ESC:m.keyCode===220?C.key=h.C0.FS:m.keyCode===221&&(C.key=h.C0.GS)}return C}},482:(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,h=0,p=d.length){let m="";for(let g=h;g<p;++g){let y=d[g];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,h){const p=d.length;if(!p)return 0;let m=0,g=0;if(this._interim){const y=d.charCodeAt(g++);56320<=y&&y<=57343?h[m++]=1024*(this._interim-55296)+y-56320+65536:(h[m++]=this._interim,h[m++]=y),this._interim=0}for(let y=g;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?h[m++]=1024*(w-55296)+C-56320+65536:(h[m++]=w,h[m++]=C)}else w!==65279&&(h[m++]=w)}return m}},c.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(d,h){const p=d.length;if(!p)return 0;let m,g,y,w,C=0,_=0,S=0;if(this.interim[0]){let k=!1,T=this.interim[0];T&=(224&T)==192?31:(240&T)==224?15:7;let N,R=0;for(;(N=63&this.interim[++R])&&R<4;)T<<=6,T|=N;const A=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,O=A-R;for(;S<O;){if(S>=p)return 0;if(N=d[S++],(192&N)!=128){S--,k=!0;break}this.interim[R++]=N,T<<=6,T|=63&N}k||(A===2?T<128?S--:h[C++]=T:A===3?T<2048||T>=55296&&T<=57343||T===65279||(h[C++]=T):T<65536||T>1114111||(h[C++]=T)),this.interim.fill(0)}const b=p-4;let v=S;for(;v<p;){for(;!(!(v<b)||128&(m=d[v])||128&(g=d[v+1])||128&(y=d[v+2])||128&(w=d[v+3]));)h[C++]=m,h[C++]=g,h[C++]=y,h[C++]=w,v+=4;if(m=d[v++],m<128)h[C++]=m;else if((224&m)==192){if(v>=p)return this.interim[0]=m,C;if(g=d[v++],(192&g)!=128){v--;continue}if(_=(31&m)<<6|63&g,_<128){v--;continue}h[C++]=_}else if((240&m)==224){if(v>=p)return this.interim[0]=m,C;if(g=d[v++],(192&g)!=128){v--;continue}if(v>=p)return this.interim[0]=m,this.interim[1]=g,C;if(y=d[v++],(192&y)!=128){v--;continue}if(_=(15&m)<<12|(63&g)<<6|63&y,_<2048||_>=55296&&_<=57343||_===65279)continue;h[C++]=_}else if((248&m)==240){if(v>=p)return this.interim[0]=m,C;if(g=d[v++],(192&g)!=128){v--;continue}if(v>=p)return this.interim[0]=m,this.interim[1]=g,C;if(y=d[v++],(192&y)!=128){v--;continue}if(v>=p)return this.interim[0]=m,this.interim[1]=g,this.interim[2]=y,C;if(w=d[v++],(192&w)!=128){v--;continue}if(_=(7&m)<<18|(63&g)<<12|(63&y)<<6|63&w,_<65536||_>1114111)continue;h[C++]=_}}return C}}},225:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.UnicodeV6=void 0;const h=d(1480),p=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],m=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]];let g;c.UnicodeV6=class{constructor(){if(this.version="6",!g){g=new Uint8Array(65536),g.fill(1),g[0]=0,g.fill(0,1,32),g.fill(0,127,160),g.fill(2,4352,4448),g[9001]=2,g[9002]=2,g.fill(2,11904,42192),g[12351]=1,g.fill(2,44032,55204),g.fill(2,63744,64256),g.fill(2,65040,65050),g.fill(2,65072,65136),g.fill(2,65280,65377),g.fill(2,65504,65511);for(let y=0;y<p.length;++y)g.fill(0,p[y][0],p[y][1]+1)}}wcwidth(y){return y<32?0:y<127?1:y<65536?g[y]:(function(w,C){let _,S=0,b=C.length-1;if(w<C[0][0]||w>C[b][1])return!1;for(;b>=S;)if(_=S+b>>1,w>C[_][1])S=_+1;else{if(!(w<C[_][0]))return!0;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),_=C===0&&w!==0;if(_){const S=h.UnicodeService.extractWidth(w);S===0?_=!1:S>C&&(C=S)}return h.UnicodeService.createPropertyValue(0,C,_)}}},5981:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.WriteBuffer=void 0;const h=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 h.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 _=this._callbacks.shift();_&&_()}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 _=this._writeBuffer[this._bufferOffset],S=this._action(_,w);if(S){const v=k=>Date.now()-C>=12?setTimeout((()=>this._innerWrite(0,k))):this._innerWrite(C,k);return void S.catch((k=>(queueMicrotask((()=>{throw k})),Promise.resolve(!1)))).then(v)}const b=this._callbacks[this._bufferOffset];if(b&&b(),this._bufferOffset++,this._pendingData-=_.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})$/,h=/^[\da-f]+$/;function p(m,g){const y=m.toString(16),w=y.length<2?"0"+y:y;switch(g){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 g=m.toLowerCase();if(g.indexOf("rgb:")===0){g=g.slice(4);const y=d.exec(g);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(g.indexOf("#")===0&&(g=g.slice(1),h.exec(g)&&[3,6,9,12].includes(g.length))){const y=g.length/3,w=[0,0,0];for(let C=0;C<3;++C){const _=parseInt(g.slice(y*C,y*C+y),16);w[C]=y===1?_<<4:y===2?_:y===3?_>>4:_>>8}return w}},c.toRgbString=function(m,g=16){const[y,w,C]=m;return`rgb:${p(y,g)}/${p(w,g)}/${p(C,g)}`}},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 h=d(482),p=d(8742),m=d(5770),g=[];c.DcsParser=class{constructor(){this._handlers=Object.create(null),this._active=g,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=g}registerHandler(w,C){this._handlers[w]===void 0&&(this._handlers[w]=[]);const _=this._handlers[w];return _.push(C),{dispose:()=>{const S=_.indexOf(C);S!==-1&&_.splice(S,1)}}}clearHandler(w){this._handlers[w]&&delete this._handlers[w]}setHandlerFallback(w){this._handlerFb=w}reset(){if(this._active.length)for(let w=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;w>=0;--w)this._active[w].unhook(!1);this._stack.paused=!1,this._active=g,this._ident=0}hook(w,C){if(this.reset(),this._ident=w,this._active=this._handlers[w]||g,this._active.length)for(let _=this._active.length-1;_>=0;_--)this._active[_].hook(C);else this._handlerFb(this._ident,"HOOK",C)}put(w,C,_){if(this._active.length)for(let S=this._active.length-1;S>=0;S--)this._active[S].put(w,C,_);else this._handlerFb(this._ident,"PUT",(0,h.utf32ToString)(w,C,_))}unhook(w,C=!0){if(this._active.length){let _=!1,S=this._active.length-1,b=!1;if(this._stack.paused&&(S=this._stack.loopPosition-1,_=C,b=this._stack.fallThrough,this._stack.paused=!1),!b&&_===!1){for(;S>=0&&(_=this._active[S].unhook(w),_!==!0);S--)if(_ instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=S,this._stack.fallThrough=!1,_;S--}for(;S>=0;S--)if(_=this._active[S].unhook(!1),_ instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=S,this._stack.fallThrough=!0,_}else this._handlerFb(this._ident,"UNHOOK",w);this._active=g,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,_){this._hitLimit||(this._data+=(0,h.utf32ToString)(w,C,_),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((_=>(this._params=y,this._data="",this._hitLimit=!1,_)));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 h=d(844),p=d(8742),m=d(6242),g=d(6351);class y{constructor(S){this.table=new Uint8Array(S)}setDefault(S,b){this.table.fill(S<<4|b)}add(S,b,v,k){this.table[b<<8|S]=v<<4|k}addMany(S,b,v,k){for(let T=0;T<S.length;T++)this.table[b<<8|S[T]]=v<<4|k}}c.TransitionTable=y;const w=160;c.VT500_TRANSITION_TABLE=(function(){const _=new y(4095),S=Array.apply(null,Array(256)).map(((R,A)=>A)),b=(R,A)=>S.slice(R,A),v=b(32,127),k=b(0,24);k.push(25),k.push.apply(k,b(28,32));const T=b(0,14);let N;for(N in _.setDefault(1,0),_.addMany(v,0,2,0),T)_.addMany([24,26,153,154],N,3,0),_.addMany(b(128,144),N,3,0),_.addMany(b(144,152),N,3,0),_.add(156,N,0,0),_.add(27,N,11,1),_.add(157,N,4,8),_.addMany([152,158,159],N,0,7),_.add(155,N,11,3),_.add(144,N,11,9);return _.addMany(k,0,3,0),_.addMany(k,1,3,1),_.add(127,1,0,1),_.addMany(k,8,0,8),_.addMany(k,3,3,3),_.add(127,3,0,3),_.addMany(k,4,3,4),_.add(127,4,0,4),_.addMany(k,6,3,6),_.addMany(k,5,3,5),_.add(127,5,0,5),_.addMany(k,2,3,2),_.add(127,2,0,2),_.add(93,1,4,8),_.addMany(v,8,5,8),_.add(127,8,5,8),_.addMany([156,27,24,26,7],8,6,0),_.addMany(b(28,32),8,0,8),_.addMany([88,94,95],1,0,7),_.addMany(v,7,0,7),_.addMany(k,7,0,7),_.add(156,7,0,0),_.add(127,7,0,7),_.add(91,1,11,3),_.addMany(b(64,127),3,7,0),_.addMany(b(48,60),3,8,4),_.addMany([60,61,62,63],3,9,4),_.addMany(b(48,60),4,8,4),_.addMany(b(64,127),4,7,0),_.addMany([60,61,62,63],4,0,6),_.addMany(b(32,64),6,0,6),_.add(127,6,0,6),_.addMany(b(64,127),6,0,0),_.addMany(b(32,48),3,9,5),_.addMany(b(32,48),5,9,5),_.addMany(b(48,64),5,0,6),_.addMany(b(64,127),5,7,0),_.addMany(b(32,48),4,9,5),_.addMany(b(32,48),1,9,2),_.addMany(b(32,48),2,9,2),_.addMany(b(48,127),2,10,0),_.addMany(b(48,80),1,10,0),_.addMany(b(81,88),1,10,0),_.addMany([89,90,92],1,10,0),_.addMany(b(96,127),1,10,0),_.add(80,1,11,9),_.addMany(k,9,0,9),_.add(127,9,0,9),_.addMany(b(28,32),9,0,9),_.addMany(b(32,48),9,9,12),_.addMany(b(48,60),9,8,10),_.addMany([60,61,62,63],9,9,10),_.addMany(k,11,0,11),_.addMany(b(32,128),11,0,11),_.addMany(b(28,32),11,0,11),_.addMany(k,10,0,10),_.add(127,10,0,10),_.addMany(b(28,32),10,0,10),_.addMany(b(48,60),10,8,10),_.addMany([60,61,62,63],10,0,11),_.addMany(b(32,48),10,9,12),_.addMany(k,12,0,12),_.add(127,12,0,12),_.addMany(b(28,32),12,0,12),_.addMany(b(32,48),12,9,12),_.addMany(b(48,64),12,0,11),_.addMany(b(64,127),12,12,13),_.addMany(b(64,127),10,12,13),_.addMany(b(64,127),9,12,13),_.addMany(k,13,13,13),_.addMany(v,13,13,13),_.add(127,13,0,13),_.addMany([27,156,24,26],13,14,0),_.add(w,0,2,0),_.add(w,8,5,8),_.add(w,6,0,6),_.add(w,11,0,11),_.add(w,13,13,13),_})();class C extends h.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=(b,v,k)=>{},this._executeHandlerFb=b=>{},this._csiHandlerFb=(b,v)=>{},this._escHandlerFb=b=>{},this._errorHandlerFb=b=>b,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this.register((0,h.toDisposable)((()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)}))),this._oscParser=this.register(new m.OscParser),this._dcsParser=this.register(new g.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},(()=>!0))}_identifier(S,b=[64,126]){let v=0;if(S.prefix){if(S.prefix.length>1)throw new Error("only one byte as prefix supported");if(v=S.prefix.charCodeAt(0),v&&60>v||v>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(S.intermediates){if(S.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let T=0;T<S.intermediates.length;++T){const N=S.intermediates.charCodeAt(T);if(32>N||N>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");v<<=8,v|=N}}if(S.final.length!==1)throw new Error("final must be a single byte");const k=S.final.charCodeAt(0);if(b[0]>k||k>b[1])throw new Error(`final must be in range ${b[0]} .. ${b[1]}`);return v<<=8,v|=k,v}identToString(S){const b=[];for(;S;)b.push(String.fromCharCode(255&S)),S>>=8;return b.reverse().join("")}setPrintHandler(S){this._printHandler=S}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(S,b){const v=this._identifier(S,[48,126]);this._escHandlers[v]===void 0&&(this._escHandlers[v]=[]);const k=this._escHandlers[v];return k.push(b),{dispose:()=>{const T=k.indexOf(b);T!==-1&&k.splice(T,1)}}}clearEscHandler(S){this._escHandlers[this._identifier(S,[48,126])]&&delete this._escHandlers[this._identifier(S,[48,126])]}setEscHandlerFallback(S){this._escHandlerFb=S}setExecuteHandler(S,b){this._executeHandlers[S.charCodeAt(0)]=b}clearExecuteHandler(S){this._executeHandlers[S.charCodeAt(0)]&&delete this._executeHandlers[S.charCodeAt(0)]}setExecuteHandlerFallback(S){this._executeHandlerFb=S}registerCsiHandler(S,b){const v=this._identifier(S);this._csiHandlers[v]===void 0&&(this._csiHandlers[v]=[]);const k=this._csiHandlers[v];return k.push(b),{dispose:()=>{const T=k.indexOf(b);T!==-1&&k.splice(T,1)}}}clearCsiHandler(S){this._csiHandlers[this._identifier(S)]&&delete this._csiHandlers[this._identifier(S)]}setCsiHandlerFallback(S){this._csiHandlerFb=S}registerDcsHandler(S,b){return this._dcsParser.registerHandler(this._identifier(S),b)}clearDcsHandler(S){this._dcsParser.clearHandler(this._identifier(S))}setDcsHandlerFallback(S){this._dcsParser.setHandlerFallback(S)}registerOscHandler(S,b){return this._oscParser.registerHandler(S,b)}clearOscHandler(S){this._oscParser.clearHandler(S)}setOscHandlerFallback(S){this._oscParser.setHandlerFallback(S)}setErrorHandler(S){this._errorHandler=S}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(S,b,v,k,T){this._parseStack.state=S,this._parseStack.handlers=b,this._parseStack.handlerPos=v,this._parseStack.transition=k,this._parseStack.chunkPos=T}parse(S,b,v){let k,T=0,N=0,R=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,R=this._parseStack.chunkPos+1;else{if(v===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");const A=this._parseStack.handlers;let O=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(v===!1&&O>-1){for(;O>=0&&(k=A[O](this._params),k!==!0);O--)if(k instanceof Promise)return this._parseStack.handlerPos=O,k}this._parseStack.handlers=[];break;case 4:if(v===!1&&O>-1){for(;O>=0&&(k=A[O](),k!==!0);O--)if(k instanceof Promise)return this._parseStack.handlerPos=O,k}this._parseStack.handlers=[];break;case 6:if(T=S[this._parseStack.chunkPos],k=this._dcsParser.unhook(T!==24&&T!==26,v),k)return k;T===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(T=S[this._parseStack.chunkPos],k=this._oscParser.end(T!==24&&T!==26,v),k)return k;T===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<b;++A){switch(T=S[A],N=this._transitions.table[this.currentState<<8|(T<160?T:w)],N>>4){case 2:for(let W=A+1;;++W){if(W>=b||(T=S[W])<32||T>126&&T<w){this._printHandler(S,A,W),A=W-1;break}if(++W>=b||(T=S[W])<32||T>126&&T<w){this._printHandler(S,A,W),A=W-1;break}if(++W>=b||(T=S[W])<32||T>126&&T<w){this._printHandler(S,A,W),A=W-1;break}if(++W>=b||(T=S[W])<32||T>126&&T<w){this._printHandler(S,A,W),A=W-1;break}}break;case 3:this._executeHandlers[T]?this._executeHandlers[T]():this._executeHandlerFb(T),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:A,code:T,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:const O=this._csiHandlers[this._collect<<8|T];let P=O?O.length-1:-1;for(;P>=0&&(k=O[P](this._params),k!==!0);P--)if(k instanceof Promise)return this._preserveStack(3,O,P,N,A),k;P<0&&this._csiHandlerFb(this._collect<<8|T,this._params),this.precedingJoinState=0;break;case 8:do switch(T){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(T-48)}while(++A<b&&(T=S[A])>47&&T<60);A--;break;case 9:this._collect<<=8,this._collect|=T;break;case 10:const V=this._escHandlers[this._collect<<8|T];let z=V?V.length-1:-1;for(;z>=0&&(k=V[z](),k!==!0);z--)if(k instanceof Promise)return this._preserveStack(4,V,z,N,A),k;z<0&&this._escHandlerFb(this._collect<<8|T),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|T,this._params);break;case 13:for(let W=A+1;;++W)if(W>=b||(T=S[W])===24||T===26||T===27||T>127&&T<w){this._dcsParser.put(S,A,W),A=W-1;break}break;case 14:if(k=this._dcsParser.unhook(T!==24&&T!==26),k)return this._preserveStack(6,[],0,N,A),k;T===27&&(N|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let W=A+1;;W++)if(W>=b||(T=S[W])<32||T>127&&T<w){this._oscParser.put(S,A,W),A=W-1;break}break;case 6:if(k=this._oscParser.end(T!==24&&T!==26),k)return this._preserveStack(5,[],0,N,A),k;T===27&&(N|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0}this.currentState=15&N}}}c.EscapeSequenceParser=C},6242:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.OscHandler=c.OscParser=void 0;const h=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(g,y){this._handlers[g]===void 0&&(this._handlers[g]=[]);const w=this._handlers[g];return w.push(y),{dispose:()=>{const C=w.indexOf(y);C!==-1&&w.splice(C,1)}}}clearHandler(g){this._handlers[g]&&delete this._handlers[g]}setHandlerFallback(g){this._handlerFb=g}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=m}reset(){if(this._state===2)for(let g=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;g>=0;--g)this._active[g].end(!1);this._stack.paused=!1,this._active=m,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||m,this._active.length)for(let g=this._active.length-1;g>=0;g--)this._active[g].start();else this._handlerFb(this._id,"START")}_put(g,y,w){if(this._active.length)for(let C=this._active.length-1;C>=0;C--)this._active[C].put(g,y,w);else this._handlerFb(this._id,"PUT",(0,p.utf32ToString)(g,y,w))}start(){this.reset(),this._state=1}put(g,y,w){if(this._state!==3){if(this._state===1)for(;y<w;){const C=g[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(g,y,w)}}end(g,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,_=!1;if(this._stack.paused&&(C=this._stack.loopPosition-1,w=y,_=this._stack.fallThrough,this._stack.paused=!1),!_&&w===!1){for(;C>=0&&(w=this._active[C].end(g),w!==!0);C--)if(w instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=C,this._stack.fallThrough=!1,w;C--}for(;C>=0;C--)if(w=this._active[C].end(!1),w instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=C,this._stack.fallThrough=!0,w}else this._handlerFb(this._id,"END",g);this._active=m,this._id=-1,this._state=0}}},c.OscHandler=class{constructor(g){this._handler=g,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(g,y,w){this._hitLimit||(this._data+=(0,p.utf32ToString)(g,y,w),this._data.length>h.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(g){let y=!1;if(this._hitLimit)y=!1;else if(g&&(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 h{static fromArray(m){const g=new h;if(!m.length)return g;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)g.addSubParam(w[C]);else g.addParam(w)}return g}constructor(m=32,g=32){if(this.maxLength=m,this.maxSubParamsLength=g,g>256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(m),this.length=0,this._subParams=new Int32Array(g),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(m),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}clone(){const m=new h(this.maxLength,this.maxSubParamsLength);return m.params.set(this.params),m.length=this.length,m._subParams.set(this._subParams),m._subParamsLength=this._subParamsLength,m._subParamsIdx.set(this._subParamsIdx),m._rejectDigits=this._rejectDigits,m._rejectSubDigits=this._rejectSubDigits,m._digitIsSub=this._digitIsSub,m}toArray(){const m=[];for(let g=0;g<this.length;++g){m.push(this.params[g]);const y=this._subParamsIdx[g]>>8,w=255&this._subParamsIdx[g];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 g=this._subParamsIdx[m]>>8,y=255&this._subParamsIdx[m];return y-g>0?this._subParams.subarray(g,y):null}getSubParamsAll(){const m={};for(let g=0;g<this.length;++g){const y=this._subParamsIdx[g]>>8,w=255&this._subParamsIdx[g];w-y>0&&(m[g]=this._subParams.slice(y,w))}return m}addDigit(m){let g;if(this._rejectDigits||!(g=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;const y=this._digitIsSub?this._subParams:this.params,w=y[g-1];y[g-1]=~w?Math.min(10*w+m,d):m}}c.Params=h},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,h){const p={instance:h,dispose:h.dispose,isDisposed:!1};this._addons.push(p),h.dispose=()=>this._wrappedAddonDispose(p),h.activate(d)}_wrappedAddonDispose(d){if(d.isDisposed)return;let h=-1;for(let p=0;p<this._addons.length;p++)if(this._addons[p]===d){h=p;break}if(h===-1)throw new Error("Could not dispose an addon that has not been loaded");d.isDisposed=!0,d.dispose.apply(d.instance),this._addons.splice(h,1)}}},8771:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.BufferApiView=void 0;const h=d(3785),p=d(511);c.BufferApiView=class{constructor(m,g){this._buffer=m,this.type=g}init(m){return this._buffer=m,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(m){const g=this._buffer.lines.get(m);if(g)return new h.BufferLineApiView(g)}getNullCell(){return new p.CellData}}},3785:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.BufferLineApiView=void 0;const h=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 h.CellData)}translateToString(p,m,g){return this._line.translateToString(p,m,g)}}},8285:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.BufferNamespaceApi=void 0;const h=d(8771),p=d(8460),m=d(844);class g extends m.Disposable{constructor(w){super(),this._core=w,this._onBufferChange=this.register(new p.EventEmitter),this.onBufferChange=this._onBufferChange.event,this._normal=new h.BufferApiView(this._core.buffers.normal,"normal"),this._alternate=new h.BufferApiView(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate((()=>this._onBufferChange.fire(this.active)))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}}c.BufferNamespaceApi=g},7975:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.ParserApi=void 0,c.ParserApi=class{constructor(d){this._core=d}registerCsiHandler(d,h){return this._core.registerCsiHandler(d,(p=>h(p.toArray())))}addCsiHandler(d,h){return this.registerCsiHandler(d,h)}registerDcsHandler(d,h){return this._core.registerDcsHandler(d,((p,m)=>h(p,m.toArray())))}addDcsHandler(d,h){return this.registerDcsHandler(d,h)}registerEscHandler(d,h){return this._core.registerEscHandler(d,h)}addEscHandler(d,h){return this.registerEscHandler(d,h)}registerOscHandler(d,h){return this._core.registerOscHandler(d,h)}addOscHandler(d,h){return this.registerOscHandler(d,h)}}},7090:(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 h=this&&this.__decorate||function(_,S,b,v){var k,T=arguments.length,N=T<3?S:v===null?v=Object.getOwnPropertyDescriptor(S,b):v;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")N=Reflect.decorate(_,S,b,v);else for(var R=_.length-1;R>=0;R--)(k=_[R])&&(N=(T<3?k(N):T>3?k(S,b,N):k(S,b))||N);return T>3&&N&&Object.defineProperty(S,b,N),N},p=this&&this.__param||function(_,S){return function(b,v){S(b,v,_)}};Object.defineProperty(c,"__esModule",{value:!0}),c.BufferService=c.MINIMUM_ROWS=c.MINIMUM_COLS=void 0;const m=d(8460),g=d(844),y=d(5295),w=d(2585);c.MINIMUM_COLS=2,c.MINIMUM_ROWS=1;let C=c.BufferService=class extends g.Disposable{get buffer(){return this.buffers.active}constructor(_){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(_.rawOptions.cols||0,c.MINIMUM_COLS),this.rows=Math.max(_.rawOptions.rows||0,c.MINIMUM_ROWS),this.buffers=this.register(new y.BufferSet(_,this))}resize(_,S){this.cols=_,this.rows=S,this.buffers.resize(_,S),this._onResize.fire({cols:_,rows:S})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(_,S=!1){const b=this.buffer;let v;v=this._cachedBlankLine,v&&v.length===this.cols&&v.getFg(0)===_.fg&&v.getBg(0)===_.bg||(v=b.getBlankLine(_,S),this._cachedBlankLine=v),v.isWrapped=S;const k=b.ybase+b.scrollTop,T=b.ybase+b.scrollBottom;if(b.scrollTop===0){const N=b.lines.isFull;T===b.lines.length-1?N?b.lines.recycle().copyFrom(v):b.lines.push(v.clone()):b.lines.splice(T+1,0,v.clone()),N?this.isUserScrolling&&(b.ydisp=Math.max(b.ydisp-1,0)):(b.ybase++,this.isUserScrolling||b.ydisp++)}else{const N=T-k+1;b.lines.shiftElements(k+1,N-1,-1),b.lines.set(T,v.clone())}this.isUserScrolling||(b.ydisp=b.ybase),this._onScroll.fire(b.ydisp)}scrollLines(_,S,b){const v=this.buffer;if(_<0){if(v.ydisp===0)return;this.isUserScrolling=!0}else _+v.ydisp>=v.ybase&&(this.isUserScrolling=!1);const k=v.ydisp;v.ydisp=Math.max(Math.min(v.ydisp+_,v.ybase),0),k!==v.ydisp&&(S||this._onScroll.fire(v.ydisp))}};c.BufferService=C=h([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,h){this._charsets[d]=h,this.glevel===d&&(this.charset=h)}}},1753:function(u,c,d){var h=this&&this.__decorate||function(v,k,T,N){var R,A=arguments.length,O=A<3?k:N===null?N=Object.getOwnPropertyDescriptor(k,T):N;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")O=Reflect.decorate(v,k,T,N);else for(var P=v.length-1;P>=0;P--)(R=v[P])&&(O=(A<3?R(O):A>3?R(k,T,O):R(k,T))||O);return A>3&&O&&Object.defineProperty(k,T,O),O},p=this&&this.__param||function(v,k){return function(T,N){k(T,N,v)}};Object.defineProperty(c,"__esModule",{value:!0}),c.CoreMouseService=void 0;const m=d(2585),g=d(8460),y=d(844),w={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:v=>v.button!==4&&v.action===1&&(v.ctrl=!1,v.alt=!1,v.shift=!1,!0)},VT200:{events:19,restrict:v=>v.action!==32},DRAG:{events:23,restrict:v=>v.action!==32||v.button!==3},ANY:{events:31,restrict:v=>!0}};function C(v,k){let T=(v.ctrl?16:0)|(v.shift?4:0)|(v.alt?8:0);return v.button===4?(T|=64,T|=v.action):(T|=3&v.button,4&v.button&&(T|=64),8&v.button&&(T|=128),v.action===32?T|=32:v.action!==0||k||(T|=3)),T}const _=String.fromCharCode,S={DEFAULT:v=>{const k=[C(v,!1)+32,v.col+32,v.row+32];return k[0]>255||k[1]>255||k[2]>255?"":`\x1B[M${_(k[0])}${_(k[1])}${_(k[2])}`},SGR:v=>{const k=v.action===0&&v.button!==4?"m":"M";return`\x1B[<${C(v,!0)};${v.col};${v.row}${k}`},SGR_PIXELS:v=>{const k=v.action===0&&v.button!==4?"m":"M";return`\x1B[<${C(v,!0)};${v.x};${v.y}${k}`}};let b=c.CoreMouseService=class extends y.Disposable{constructor(v,k){super(),this._bufferService=v,this._coreService=k,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._onProtocolChange=this.register(new g.EventEmitter),this.onProtocolChange=this._onProtocolChange.event;for(const T of Object.keys(w))this.addProtocol(T,w[T]);for(const T of Object.keys(S))this.addEncoding(T,S[T]);this.reset()}addProtocol(v,k){this._protocols[v]=k}addEncoding(v,k){this._encodings[v]=k}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(v){if(!this._protocols[v])throw new Error(`unknown protocol "${v}"`);this._activeProtocol=v,this._onProtocolChange.fire(this._protocols[v].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(v){if(!this._encodings[v])throw new Error(`unknown encoding "${v}"`);this._activeEncoding=v}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null}triggerMouseEvent(v){if(v.col<0||v.col>=this._bufferService.cols||v.row<0||v.row>=this._bufferService.rows||v.button===4&&v.action===32||v.button===3&&v.action!==32||v.button!==4&&(v.action===2||v.action===3)||(v.col++,v.row++,v.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,v,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(v))return!1;const k=this._encodings[this._activeEncoding](v);return k&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(k):this._coreService.triggerDataEvent(k,!0)),this._lastEvent=v,!0}explainEvents(v){return{down:!!(1&v),up:!!(2&v),drag:!!(4&v),move:!!(8&v),wheel:!!(16&v)}}_equalEvents(v,k,T){if(T){if(v.x!==k.x||v.y!==k.y)return!1}else if(v.col!==k.col||v.row!==k.row)return!1;return v.button===k.button&&v.action===k.action&&v.ctrl===k.ctrl&&v.alt===k.alt&&v.shift===k.shift}};c.CoreMouseService=b=h([p(0,m.IBufferService),p(1,m.ICoreService)],b)},6975:function(u,c,d){var h=this&&this.__decorate||function(b,v,k,T){var N,R=arguments.length,A=R<3?v:T===null?T=Object.getOwnPropertyDescriptor(v,k):T;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(b,v,k,T);else for(var O=b.length-1;O>=0;O--)(N=b[O])&&(A=(R<3?N(A):R>3?N(v,k,A):N(v,k))||A);return R>3&&A&&Object.defineProperty(v,k,A),A},p=this&&this.__param||function(b,v){return function(k,T){v(k,T,b)}};Object.defineProperty(c,"__esModule",{value:!0}),c.CoreService=void 0;const m=d(1439),g=d(8460),y=d(844),w=d(2585),C=Object.freeze({insertMode:!1}),_=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(b,v,k){super(),this._bufferService=b,this._logService=v,this._optionsService=k,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this.register(new g.EventEmitter),this.onData=this._onData.event,this._onUserInput=this.register(new g.EventEmitter),this.onUserInput=this._onUserInput.event,this._onBinary=this.register(new g.EventEmitter),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this.register(new g.EventEmitter),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=(0,m.clone)(C),this.decPrivateModes=(0,m.clone)(_)}reset(){this.modes=(0,m.clone)(C),this.decPrivateModes=(0,m.clone)(_)}triggerDataEvent(b,v=!1){if(this._optionsService.rawOptions.disableStdin)return;const k=this._bufferService.buffer;v&&this._optionsService.rawOptions.scrollOnUserInput&&k.ybase!==k.ydisp&&this._onRequestScrollToBottom.fire(),v&&this._onUserInput.fire(),this._logService.debug(`sending data "${b}"`,(()=>b.split("").map((T=>T.charCodeAt(0))))),this._onData.fire(b)}triggerBinaryEvent(b){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${b}"`,(()=>b.split("").map((v=>v.charCodeAt(0))))),this._onBinary.fire(b))}};c.CoreService=S=h([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 h=d(8055),p=d(8460),m=d(844),g=d(6106);let y=0,w=0;class C extends m.Disposable{get decorations(){return this._decorations.values()}constructor(){super(),this._decorations=new g.SortedList((b=>b==null?void 0:b.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(b){if(b.marker.isDisposed)return;const v=new _(b);if(v){const k=v.marker.onDispose((()=>v.dispose()));v.onDispose((()=>{v&&(this._decorations.delete(v)&&this._onDecorationRemoved.fire(v),k.dispose())})),this._decorations.insert(v),this._onDecorationRegistered.fire(v)}return v}reset(){for(const b of this._decorations.values())b.dispose();this._decorations.clear()}*getDecorationsAtCell(b,v,k){let T=0,N=0;for(const R of this._decorations.getKeyIterator(v))T=R.options.x??0,N=T+(R.options.width??1),b>=T&&b<N&&(!k||(R.options.layer??"bottom")===k)&&(yield R)}forEachDecorationAtCell(b,v,k,T){this._decorations.forEachByKey(v,(N=>{y=N.options.x??0,w=y+(N.options.width??1),b>=y&&b<w&&(!k||(N.options.layer??"bottom")===k)&&T(N)}))}}c.DecorationService=C;class _ extends m.Disposable{get isDisposed(){return this._isDisposed}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=h.css.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=h.css.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}constructor(b){super(),this.options=b,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=b.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}dispose(){this._onDispose.fire(),super.dispose()}}},4348:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.InstantiationService=c.ServiceCollection=void 0;const h=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(h.IInstantiationService,this)}setService(g,y){this._services.set(g,y)}getService(g){return this._services.get(g)}createInstance(g,...y){const w=(0,p.getServiceDependencies)(g).sort(((S,b)=>S.index-b.index)),C=[];for(const S of w){const b=this._services.get(S.id);if(!b)throw new Error(`[createInstance] ${g.name} depends on UNKNOWN service ${S.id}.`);C.push(b)}const _=w.length>0?w[0].index:y.length;if(y.length!==_)throw new Error(`[createInstance] First service dependency of ${g.name} at position ${_+1} conflicts with ${y.length} static arguments`);return new g(...y,...C)}}},7866:function(u,c,d){var h=this&&this.__decorate||function(_,S,b,v){var k,T=arguments.length,N=T<3?S:v===null?v=Object.getOwnPropertyDescriptor(S,b):v;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")N=Reflect.decorate(_,S,b,v);else for(var R=_.length-1;R>=0;R--)(k=_[R])&&(N=(T<3?k(N):T>3?k(S,b,N):k(S,b))||N);return T>3&&N&&Object.defineProperty(S,b,N),N},p=this&&this.__param||function(_,S){return function(b,v){S(b,v,_)}};Object.defineProperty(c,"__esModule",{value:!0}),c.traceCall=c.setTraceLogger=c.LogService=void 0;const m=d(844),g=d(2585),y={trace:g.LogLevelEnum.TRACE,debug:g.LogLevelEnum.DEBUG,info:g.LogLevelEnum.INFO,warn:g.LogLevelEnum.WARN,error:g.LogLevelEnum.ERROR,off:g.LogLevelEnum.OFF};let w,C=c.LogService=class extends m.Disposable{get logLevel(){return this._logLevel}constructor(_){super(),this._optionsService=_,this._logLevel=g.LogLevelEnum.OFF,this._updateLogLevel(),this.register(this._optionsService.onSpecificOptionChange("logLevel",(()=>this._updateLogLevel()))),w=this}_updateLogLevel(){this._logLevel=y[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(_){for(let S=0;S<_.length;S++)typeof _[S]=="function"&&(_[S]=_[S]())}_log(_,S,b){this._evalLazyOptionalParams(b),_.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+S,...b)}trace(_,...S){var b;this._logLevel<=g.LogLevelEnum.TRACE&&this._log(((b=this._optionsService.options.logger)==null?void 0:b.trace.bind(this._optionsService.options.logger))??console.log,_,S)}debug(_,...S){var b;this._logLevel<=g.LogLevelEnum.DEBUG&&this._log(((b=this._optionsService.options.logger)==null?void 0:b.debug.bind(this._optionsService.options.logger))??console.log,_,S)}info(_,...S){var b;this._logLevel<=g.LogLevelEnum.INFO&&this._log(((b=this._optionsService.options.logger)==null?void 0:b.info.bind(this._optionsService.options.logger))??console.info,_,S)}warn(_,...S){var b;this._logLevel<=g.LogLevelEnum.WARN&&this._log(((b=this._optionsService.options.logger)==null?void 0:b.warn.bind(this._optionsService.options.logger))??console.warn,_,S)}error(_,...S){var b;this._logLevel<=g.LogLevelEnum.ERROR&&this._log(((b=this._optionsService.options.logger)==null?void 0:b.error.bind(this._optionsService.options.logger))??console.error,_,S)}};c.LogService=C=h([p(0,g.IOptionsService)],C),c.setTraceLogger=function(_){w=_},c.traceCall=function(_,S,b){if(typeof b.value!="function")throw new Error("not supported");const v=b.value;b.value=function(...k){if(w.logLevel!==g.LogLevelEnum.TRACE)return v.apply(this,k);w.trace(`GlyphRenderer#${v.name}(${k.map((N=>JSON.stringify(N))).join(", ")})`);const T=v.apply(this,k);return w.trace(`GlyphRenderer#${v.name} return`,T),T}}},7302:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.OptionsService=c.DEFAULT_OPTIONS=void 0;const h=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 g=["normal","bold","100","200","300","400","500","600","700","800","900"];class y extends p.Disposable{constructor(C){super(),this._onOptionChange=this.register(new h.EventEmitter),this.onOptionChange=this._onOptionChange.event;const _={...c.DEFAULT_OPTIONS};for(const S in C)if(S in _)try{const b=C[S];_[S]=this._sanitizeAndValidateOption(S,b)}catch(b){console.error(b)}this.rawOptions=_,this.options={..._},this._setupOptions(),this.register((0,p.toDisposable)((()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null})))}onSpecificOptionChange(C,_){return this.onOptionChange((S=>{S===C&&_(this.rawOptions[C])}))}onMultipleOptionChange(C,_){return this.onOptionChange((S=>{C.indexOf(S)!==-1&&_()}))}_setupOptions(){const C=S=>{if(!(S in c.DEFAULT_OPTIONS))throw new Error(`No option with key "${S}"`);return this.rawOptions[S]},_=(S,b)=>{if(!(S in c.DEFAULT_OPTIONS))throw new Error(`No option with key "${S}"`);b=this._sanitizeAndValidateOption(S,b),this.rawOptions[S]!==b&&(this.rawOptions[S]=b,this._onOptionChange.fire(S))};for(const S in this.rawOptions){const b={get:C.bind(this,S),set:_.bind(this,S)};Object.defineProperty(this.options,S,b)}}_sanitizeAndValidateOption(C,_){switch(C){case"cursorStyle":if(_||(_=c.DEFAULT_OPTIONS[C]),!(function(S){return S==="block"||S==="underline"||S==="bar"})(_))throw new Error(`"${_}" is not a valid value for ${C}`);break;case"wordSeparator":_||(_=c.DEFAULT_OPTIONS[C]);break;case"fontWeight":case"fontWeightBold":if(typeof _=="number"&&1<=_&&_<=1e3)break;_=g.includes(_)?_:c.DEFAULT_OPTIONS[C];break;case"cursorWidth":_=Math.floor(_);case"lineHeight":case"tabStopWidth":if(_<1)throw new Error(`${C} cannot be less than 1, value: ${_}`);break;case"minimumContrastRatio":_=Math.max(1,Math.min(21,Math.round(10*_)/10));break;case"scrollback":if((_=Math.min(_,4294967295))<0)throw new Error(`${C} cannot be less than 0, value: ${_}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(_<=0)throw new Error(`${C} cannot be less than or equal to 0, value: ${_}`);break;case"rows":case"cols":if(!_&&_!==0)throw new Error(`${C} must be numeric, value: ${_}`);break;case"windowsPty":_=_??{}}return _}}c.OptionsService=y},2660:function(u,c,d){var h=this&&this.__decorate||function(y,w,C,_){var S,b=arguments.length,v=b<3?w:_===null?_=Object.getOwnPropertyDescriptor(w,C):_;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")v=Reflect.decorate(y,w,C,_);else for(var k=y.length-1;k>=0;k--)(S=y[k])&&(v=(b<3?S(v):b>3?S(w,C,v):S(w,C))||v);return b>3&&v&&Object.defineProperty(w,C,v),v},p=this&&this.__param||function(y,w){return function(C,_){w(C,_,y)}};Object.defineProperty(c,"__esModule",{value:!0}),c.OscLinkService=void 0;const m=d(2585);let g=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 k=w.addMarker(w.ybase+w.y),T={data:y,id:this._nextId++,lines:[k]};return k.onDispose((()=>this._removeMarkerFromLink(T,k))),this._dataByLinkId.set(T.id,T),T.id}const C=y,_=this._getEntryIdKey(C),S=this._entriesWithId.get(_);if(S)return this.addLineToLink(S.id,w.ybase+w.y),S.id;const b=w.addMarker(w.ybase+w.y),v={id:this._nextId++,key:this._getEntryIdKey(C),data:C,lines:[b]};return b.onDispose((()=>this._removeMarkerFromLink(v,b))),this._entriesWithId.set(v.key,v),this._dataByLinkId.set(v.id,v),v.id}addLineToLink(y,w){const C=this._dataByLinkId.get(y);if(C&&C.lines.every((_=>_.line!==w))){const _=this._bufferService.buffer.addMarker(w);C.lines.push(_),_.onDispose((()=>this._removeMarkerFromLink(C,_)))}}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=g=h([p(0,m.IBufferService)],g)},8343:(u,c)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.createDecorator=c.getServiceDependencies=c.serviceRegistry=void 0;const d="di$target",h="di$dependencies";c.serviceRegistry=new Map,c.getServiceDependencies=function(p){return p[h]||[]},c.createDecorator=function(p){if(c.serviceRegistry.has(p))return c.serviceRegistry.get(p);const m=function(g,y,w){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(C,_,S){_[d]===_?_[h].push({id:C,index:S}):(_[h]=[{id:C,index:S}],_[d]=_)})(m,g,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 h=d(8343);var p;c.IBufferService=(0,h.createDecorator)("BufferService"),c.ICoreMouseService=(0,h.createDecorator)("CoreMouseService"),c.ICoreService=(0,h.createDecorator)("CoreService"),c.ICharsetService=(0,h.createDecorator)("CharsetService"),c.IInstantiationService=(0,h.createDecorator)("InstantiationService"),(function(m){m[m.TRACE=0]="TRACE",m[m.DEBUG=1]="DEBUG",m[m.INFO=2]="INFO",m[m.WARN=3]="WARN",m[m.ERROR=4]="ERROR",m[m.OFF=5]="OFF"})(p||(c.LogLevelEnum=p={})),c.ILogService=(0,h.createDecorator)("LogService"),c.IOptionsService=(0,h.createDecorator)("OptionsService"),c.IOscLinkService=(0,h.createDecorator)("OscLinkService"),c.IUnicodeService=(0,h.createDecorator)("UnicodeService"),c.IDecorationService=(0,h.createDecorator)("DecorationService")},1480:(u,c,d)=>{Object.defineProperty(c,"__esModule",{value:!0}),c.UnicodeService=void 0;const h=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 h.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 _=y.length;for(let S=0;S<_;++S){let b=y.charCodeAt(S);if(55296<=b&&b<=56319){if(++S>=_)return w+this.wcwidth(b);const T=y.charCodeAt(S);56320<=T&&T<=57343?b=1024*(b-55296)+T-56320+65536:w+=this.wcwidth(T)}const v=this.charProperties(b,C);let k=m.extractWidth(v);m.extractShouldJoin(v)&&(k-=m.extractWidth(C)),w+=k,C=v}return w}charProperties(y,w){return this._activeProvider.charProperties(y,w)}}c.UnicodeService=m}},r={};function a(u){var c=r[u];if(c!==void 0)return c.exports;var d=r[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),h=a(844),p=a(5741),m=a(8285),g=a(7975),y=a(7090),w=["cols","rows"];class C extends h.Disposable{constructor(S){super(),this._core=this.register(new d.Terminal(S)),this._addonManager=this.register(new p.AddonManager),this._publicOptions={...this._core.options};const b=k=>this._core.options[k],v=(k,T)=>{this._checkReadonlyOptions(k),this._core.options[k]=T};for(const k in this._core.options){const T={get:b.bind(this,k),set:v.bind(this,k)};Object.defineProperty(this._publicOptions,k,T)}}_checkReadonlyOptions(S){if(w.includes(S))throw new Error(`Option "${S}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new g.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 b="none";switch(this._core.coreMouseService.activeProtocol){case"X10":b="x10";break;case"VT200":b="vt200";break;case"DRAG":b="drag";break;case"ANY":b="any"}return{applicationCursorKeysMode:S.applicationCursorKeys,applicationKeypadMode:S.applicationKeypad,bracketedPasteMode:S.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:b,originMode:S.origin,reverseWraparoundMode:S.reverseWraparound,sendFocusMode:S.sendFocus,wraparoundMode:S.wraparound}}get options(){return this._publicOptions}set options(S){for(const b in S)this._publicOptions[b]=S[b]}blur(){this._core.blur()}focus(){this._core.focus()}input(S,b=!0){this._core.input(S,b)}resize(S,b){this._verifyIntegers(S,b),this._core.resize(S,b)}open(S){this._core.open(S)}attachCustomKeyEventHandler(S){this._core.attachCustomKeyEventHandler(S)}attachCustomWheelEventHandler(S){this._core.attachCustomWheelEventHandler(S)}registerLinkProvider(S){return this._core.registerLinkProvider(S)}registerCharacterJoiner(S){return this._checkProposedApi(),this._core.registerCharacterJoiner(S)}deregisterCharacterJoiner(S){this._checkProposedApi(),this._core.deregisterCharacterJoiner(S)}registerMarker(S=0){return this._verifyIntegers(S),this._core.registerMarker(S)}registerDecoration(S){return this._checkProposedApi(),this._verifyPositiveIntegers(S.x??0,S.width??0,S.height??0),this._core.registerDecoration(S)}hasSelection(){return this._core.hasSelection()}select(S,b,v){this._verifyIntegers(S,b,v),this._core.select(S,b,v)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(S,b){this._verifyIntegers(S,b),this._core.selectLines(S,b)}dispose(){super.dispose()}scrollLines(S){this._verifyIntegers(S),this._core.scrollLines(S)}scrollPages(S){this._verifyIntegers(S),this._core.scrollPages(S)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(S){this._verifyIntegers(S),this._core.scrollToLine(S)}clear(){this._core.clear()}write(S,b){this._core.write(S,b)}writeln(S,b){this._core.write(S),this._core.write(`\r
261
+ `,b)}paste(S){this._core.paste(S)}refresh(S,b){this._verifyIntegers(S,b),this._core.refresh(S,b)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(S){this._addonManager.loadAddon(this,S)}static get strings(){return c}_verifyIntegers(...S){for(const b of S)if(b===1/0||isNaN(b)||b%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...S){for(const b of S)if(b&&(b===1/0||isNaN(b)||b%1!=0||b<0))throw new Error("This API only accepts positive integers")}}u.Terminal=C})(),l})()))})(ax)),ax.exports}var zF=$F();/**
262
+ * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
263
+ * @license MIT
264
+ *
265
+ * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
266
+ * @license MIT
267
+ *
268
+ * Originally forked from (with the author's permission):
269
+ * Fabrice Bellard's javascript vt100 for jslinux:
270
+ * http://bellard.org/jslinux/
271
+ * Copyright (c) 2011 Fabrice Bellard
272
+ */var HF=2,FF=1,UF=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){var m;if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:((m=this._terminal.options.overviewRuler)==null?void 0:m.width)||14,n=window.getComputedStyle(this._terminal.element.parentElement),r=parseInt(n.getPropertyValue("height")),a=Math.max(0,parseInt(n.getPropertyValue("width"))),l=window.getComputedStyle(this._terminal.element),u={top:parseInt(l.getPropertyValue("padding-top")),bottom:parseInt(l.getPropertyValue("padding-bottom")),right:parseInt(l.getPropertyValue("padding-right")),left:parseInt(l.getPropertyValue("padding-left"))},c=u.top+u.bottom,d=u.right+u.left,h=r-c,p=a-d-t;return{cols:Math.max(HF,Math.floor(p/e.css.cell.width)),rows:Math.max(FF,Math.floor(h/e.css.cell.height))}}};function VF({sessionId:e,onClose:t,onEscape:n,autoFocus:r}){const a=E.useRef(null),l=E.useRef(e),u=E.useRef(null),c=E.useRef(null),d=is(m=>m.writeSession),h=is(m=>m.resizeSession),p=Lt(m=>m.settings[je.DISPLAY_TERMINAL_FONT]??xh);return E.useEffect(()=>{l.current=e},[e]),E.useEffect(()=>{Lt.getState().getSetting(je.DISPLAY_TERMINAL_FONT)},[]),E.useEffect(()=>{if(!n)return;const m=g=>{g.key==="Escape"&&(g.preventDefault(),g.stopPropagation(),n())};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[n]),E.useEffect(()=>{if(!a.current)return;const m=new zF.Terminal({fontFamily:p,fontSize:13,theme:{background:"#1a1a1a",foreground:"#e0e0e0",cursor:"#ffffff",cursorAccent:"#1a1a1a"},cursorBlink:!0,cursorStyle:"bar",convertEol:!0}),g=new UF;m.loadAddon(g),u.current={term:m,fitAddon:g},a.current.addEventListener("keydown",_=>{_.key==="Escape"&&n&&(_.preventDefault(),_.stopPropagation(),n())}),m.open(a.current);const y=a.current.querySelector(".xterm");y&&(y.style.padding="8px"),g.fit(),r&&setTimeout(()=>{m.focus()},150);const w=new ResizeObserver(()=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{requestAnimationFrame(()=>{var S;g.fit&&g.fit();const _=(S=u.current)==null?void 0:S.term;_&&_.cols>0&&_.rows>0&&h(l.current,_.cols,_.rows)})},100)});w.observe(a.current),m.onData(_=>{if(_==="\x1B"&&n){n();return}d(l.current,_)}),m.onKey(_=>{_.key==="\x1B"&&n&&(_.domEvent.stopPropagation(),n())});const C=Pt.subscribe(_=>{const S=_.payload;if(_.type==="terminal.output"&&(S==null?void 0:S.sessionId)===l.current){const b=S==null?void 0:S.data;b&&m.write(b)}});return()=>{C(),w.disconnect(),c.current&&clearTimeout(c.current),m.dispose(),u.current=null}},[e,d,h]),E.useEffect(()=>{const m=u.current;if(!m)return;m.term.options.fontFamily=p,m.fitAddon.fit();const{cols:g,rows:y}=m.term;g>0&&y>0&&h(l.current,g,y)},[p,h]),s.jsxs("div",{className:"flex flex-col h-full bg-[#1a1a1a]",children:[s.jsxs("div",{className:"flex-shrink-0 flex items-center justify-between px-2 py-1 bg-[#252525] border-b border-[#333]",children:[s.jsx("div",{}),s.jsx("button",{onClick:t,className:"p-1 rounded hover:bg-[#333] text-[#888] hover:text-[#ccc] transition-colors",title:"Close terminal",children:s.jsx($y,{})})]}),s.jsx("div",{ref:a,className:"flex-1 relative overflow-hidden",tabIndex:0,onKeyDown:m=>{m.key==="Escape"&&n&&(m.preventDefault(),m.stopPropagation(),n())}})]})}const LN="openfox-chat-textarea";function ou(e){if(!Bt())return;const t=document.getElementById(LN);t&&(e===void 0?t.focus():t.focus({preventScroll:e}))}function WF(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 GF({isOpen:e,onClose:t}){const n=is(C=>C.createSession),r=is(C=>C.killSession),a=is(C=>C.sessions),l=is(C=>C.setWorkdir),u=is(C=>C.fetchSessions),c=tn(C=>C.currentProject),d=De(C=>C.currentSession),[h,p]=E.useState(!0),m=E.useRef(null),g=E.useRef(!1),y=E.useRef(!1),w=E.useCallback(()=>{t()},[t]);return E.useEffect(()=>{const C=(d==null?void 0:d.workspace)??(c==null?void 0:c.workdir);C&&l(C)},[d==null?void 0:d.workspace,c==null?void 0:c.workdir,l]),E.useEffect(()=>{e?(p(!0),u(c==null?void 0:c.id).finally(()=>p(!1))):ou()},[e,u,c==null?void 0:c.id]),E.useEffect(()=>{e&&a.length===0&&!h&&!y.current&&(y.current=!0,n(void 0,(d==null?void 0:d.projectId)??(c==null?void 0:c.id)))},[e,a.length,h,n,d==null?void 0:d.projectId,c==null?void 0:c.id]),E.useEffect(()=>{e?(g.current=!0,setTimeout(()=>{var C;Bt()&&((C=m.current)==null||C.focus()),setTimeout(()=>{g.current=!1},200)},100)):y.current=!1},[e]),E.useEffect(()=>{if(!e)return;const C=_=>{g.current||_.key==="Escape"&&(_.preventDefault(),t())};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[e,t]),e?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-x-0 top-[50vh] bottom-0 z-[100] bg-black/40",style:{pointerEvents:"auto"},onClick:w}),s.jsxs("div",{ref:m,tabIndex:-1,className:"fixed inset-x-0 top-0 z-[100] h-[50vh] bg-bg-primary border-b border-border flex flex-col animate-slide-down outline-none",onClick:C=>C.stopPropagation(),onKeyDown:C=>{C.key==="Escape"&&(C.preventDefault(),w())},children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border",children:[s.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:"Terminal"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:()=>n(void 0,(d==null?void 0:d.projectId)??(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:s.jsx(M3,{})}),s.jsx("button",{onClick:t,className:"p-2 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Close (Esc)",children:s.jsx(Ji,{})})]})]}),s.jsx(ct,{className:"flex-1 min-h-0 p-2",children:h?s.jsx("div",{className:"flex items-center justify-center h-full text-text-muted",children:"Loading..."}):a.length===0?s.jsx("div",{className:"flex items-center justify-center h-full text-text-muted",children:s.jsxs("div",{className:"text-center",children:[s.jsx("p",{className:"mb-4",children:"No terminal sessions"}),s.jsx("button",{onClick:()=>n(void 0,(d==null?void 0:d.projectId)??(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"})]})}):s.jsx("div",{className:`grid ${WF(a.length)} gap-2 h-full auto-rows-fr`,children:a.map(C=>s.jsx(VF,{sessionId:C.id,onClose:()=>r(C.id),onEscape:w,autoFocus:a.length===1&&Bt()},C.id))})})]})]}):null}function bu({items:e,footerItems:t=[],trigger:n,minWidth:r="120px",isOpen:a,onOpenChange:l,labelActionClassName:u}){const[c,d]=E.useState(!1),h=a!==void 0,p=h?a:c,m=M=>{if(h){const U=typeof M=="function"?M(c):M;l==null||l(U)}else d(M)},[g,y]=E.useState(null),w=E.useRef(null),C=E.useRef(null),[_,S]=E.useState(0),b=E.useRef(0),v=E.useMemo(()=>[...e,...t],[e,t]),k=E.useRef(v),T=E.useCallback(()=>{if(!w.current)return;const M=w.current.getBoundingClientRect(),U=200,Q=window.innerHeight-M.bottom<U;y({top:Q?M.top-U-4:M.bottom+4,left:M.left,alignToTop:Q})},[]);E.useEffect(()=>{k.current=v},[v]),E.useEffect(()=>{function M(U){if(C.current){const F=U.target;C.current.contains(F)||m(!1)}}return p&&document.addEventListener("mousedown",M),()=>{document.removeEventListener("mousedown",M)}},[p]),E.useEffect(()=>{p&&T()},[p,T]),E.useEffect(()=>{if(!p)return;setTimeout(()=>{var U;(U=C.current)==null||U.focus()},0);function M(U){const F=k.current,Q=F.filter(H=>!N(H)),X=R(b.current,F);switch(U.key){case"ArrowDown":if(U.preventDefault(),U.stopPropagation(),X<Q.length-1){const H=A(b.current+1,F);b.current=H,S(H)}break;case"ArrowUp":if(U.preventDefault(),U.stopPropagation(),X>0){const H=O(b.current-1,F);b.current=H,S(H)}break;case"Enter":U.preventDefault(),U.stopPropagation(),P(b.current,F);break;case"Escape":U.preventDefault(),U.stopPropagation(),m(!1);break}}return window.addEventListener("keydown",M,!0),()=>window.removeEventListener("keydown",M,!0)},[p,v]);function N(M){var Q;const U=M.label;return U?String(((Q=U.props)==null?void 0:Q.className)??"").includes("cursor-default"):!1}function R(M,U){let F=0;for(let Q=0;Q<M;Q++){const X=U[Q];X&&!N(X)&&F++}return F}function A(M,U){for(let F=M;F<U.length;F++){const Q=U[F];if(Q&&!N(Q))return F}return M}function O(M,U){for(let F=M;F>=0;F--){const Q=U[F];if(Q&&!N(Q))return F}return M}function P(M,U){var Q;const F=U[M];!F||N(F)||((Q=F.onClick)==null||Q.call(F),F.href&&(window.history.pushState(null,"",F.href),window.dispatchEvent(new PopStateEvent("popstate"))),m(!1))}E.useEffect(()=>{p&&(S(v.findIndex(M=>!N(M))),b.current=v.findIndex(M=>!N(M)))},[p,v]);const V=M=>{M.stopPropagation(),p||T(),m(!p)};function z(M,U,F,Q){const H=!N(M)&&Q===_,I=s.jsxs(s.Fragment,{children:[M.icon&&s.jsx("span",{className:"w-4 h-4 flex-shrink-0",children:M.icon}),s.jsx("span",{className:"min-w-0",children:M.label})]}),q=U!==F-1?"border-b border-border":"",J=`px-3 py-2 text-left text-sm flex items-center gap-2 transition-colors ${M.danger?"text-accent-error hover:bg-accent-error/10":H?"bg-accent-primary/20 text-text-primary":"hover:bg-bg-tertiary text-text-primary"}`,Y=M.href?s.jsx(xr,{href:M.href,onClick:Z=>{var K;(K=M.onClick)==null||K.call(M,Z),m(!1)},onAuxClick:()=>m(!1),className:`w-full ${J}`,children:I}):s.jsx("button",{onClick:Z=>{var K;(K=M.onClick)==null||K.call(M,Z),M.closeOnClick!==!1&&m(!1)},className:`w-full ${J}`,children:I});return M.labelAction?s.jsxs("div",{className:`flex items-center gap-1 pr-1 ${q} ${u??""}`,children:[Y,s.jsx("span",{className:"flex-shrink-0",children:M.labelAction})]},Q):s.jsx("div",{className:q,children:Y},Q)}const W=g&&s.jsxs("div",{ref:C,"data-testid":"session-dropdown-menu",className:`fixed bg-bg-secondary border border-border rounded shadow-lg z-50 ${g.alignToTop?"mb-1":"mt-1"}`,style:{top:g.top,left:g.left,minWidth:r},tabIndex:-1,children:[s.jsx(ct,{className:"max-h-[60vh]",children:e.map((M,U)=>z(M,U,e.length,U))}),t.length>0&&s.jsx("div",{className:"border-t border-border",children:t.map((M,U)=>z(M,U,t.length,e.length+U))})]});return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"relative",children:s.jsx("div",{ref:w,onClick:V,children:n})}),p&&ui.createPortal(W,document.body)]})}function qF(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 RN({isOpen:e,onClose:t,path:n,onRetry:r}){const[a,l]=E.useState(!1),[u,c]=E.useState(null),[d,h]=E.useState(null);E.useEffect(()=>{e&&p()},[e]);const p=async()=>{try{const k=await(await we("/api/projects/check-permissions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n})})).json();h({sudoAvailable:k.sudoAvailable,userInGroup:k.userInGroup,groupHasWrite:k.groupHasWrite,groupName:k.groupName||null})}catch{h({sudoAvailable:!1,userInGroup:!1,groupHasWrite:!1,groupName:null})}},m=E.useCallback(async v=>{l(!0),c(null);try{const T=await(await we("/api/projects/fix-permissions",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:n,action:v})})).json();T.success?(r(),t()):T.sudoAvailable?c("Failed to fix permissions: "+(T.error||"Unknown error")):c(`Passwordless sudo is not available. Please fix permissions manually:
273
+
274
+ `+(v==="group"?`sudo chmod g+w "${n}"`:"sudo usermod -aG <group> $USER"))}catch(k){c("Failed to fix permissions: "+(k instanceof Error?k.message:"Unknown error"))}finally{l(!1)}},[n,r,t]),g=(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)??"",_=g&&!y,S=!g&&y,b=!g&&!y;return s.jsx(jt,{isOpen:e,onClose:t,title:"Permission Denied",size:"sm",children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"text-sm text-text-secondary",children:[s.jsx("p",{children:_?s.jsxs(s.Fragment,{children:["The group ",s.jsx("strong",{children:C})," doesn't have write access:"]}):S?s.jsxs(s.Fragment,{children:["You're not a member of group ",s.jsx("strong",{children:C}),":"]}):s.jsxs(s.Fragment,{children:["You're not a member of group ",s.jsx("strong",{children:C})," and it doesn't have write access:"]})}),s.jsx("p",{className:"mt-2 font-mono text-xs bg-bg-tertiary p-2 rounded break-all",children:n})]}),u?s.jsx("div",{className:"p-3 bg-accent-error/10 border border-accent-error/30 rounded text-sm text-accent-error whitespace-pre-wrap",children:u}):d?s.jsxs("div",{className:"flex flex-col gap-2",children:[_&&s.jsxs(s.Fragment,{children:[s.jsx(dt,{type:"button",variant:"primary",onClick:()=>m("group"),disabled:a||!w,className:"w-full",children:a?"Granting access...":"Extend group permissions"}),s.jsx("div",{className:"text-xs text-text-secondary",children:"Or manually execute:"}),s.jsxs("code",{className:"text-xs text-text-muted p-2 bg-bg-tertiary rounded break-all",children:['sudo chmod g+w "',n,'"']})]}),S&&s.jsxs(s.Fragment,{children:[s.jsx(dt,{type:"button",variant:"primary",onClick:()=>m("join_group"),disabled:a||!w,className:"w-full",children:a?"Joining group...":"Join group"}),s.jsx("div",{className:"text-xs text-text-secondary",children:"Or manually execute:"}),s.jsxs("code",{className:"text-xs text-text-muted p-2 bg-bg-tertiary rounded break-all",children:["sudo usermod -aG ",C," $USER"]})]}),b&&s.jsxs(s.Fragment,{children:[s.jsx(dt,{type:"button",variant:"primary",onClick:()=>m("join_group_and_group"),disabled:a||!w,className:"w-full",children:a?"Joining group...":"Join group & grant write permissions"}),s.jsx("div",{className:"text-xs text-text-secondary",children:"Or manually execute:"}),s.jsxs("code",{className:"text-xs text-text-muted p-2 bg-bg-tertiary rounded break-all",children:["sudo usermod -aG ",C," $USER",s.jsx("br",{}),'sudo chmod g+w "',n,'"']})]}),!w&&!u&&s.jsxs("div",{className:"text-xs text-text-secondary",children:[s.jsx("p",{children:"Passwordless sudo is not available. Please fix permissions manually:"}),s.jsxs("code",{className:"block mt-1 p-2 bg-bg-tertiary rounded break-all",children:['sudo chmod g+w "',n,'"']})]}),s.jsx("div",{className:"flex justify-end",children:s.jsx(dt,{type:"button",variant:"secondary",onClick:t,disabled:a,children:"Cancel"})})]}):null]})})}function DN({isOpen:e,onClose:t}){const[,n]=Gn(),r=tn(T=>T.listProjects),[a,l]=E.useState(""),[u,c]=E.useState(null),[d,h]=E.useState(!1),[p,m]=E.useState(""),[g,y]=E.useState(null),w=E.useRef(null);E.useEffect(()=>{e&&(we("/api/config").then(T=>T.json()).then(T=>{T.workdir&&m(T.workdir)}),l(""),c(null),h(!1),y(null),setTimeout(()=>{var T;Bt()&&((T=w.current)==null||T.focus())},100))},[e]);const C=E.useCallback(async T=>{T.preventDefault();const N=qF(a);if(!N.valid){c(N.error);return}const R=`${p}/${a}`;await b(R)},[a,n,t,p]),_=E.useCallback(()=>{y(null)},[]),S=E.useCallback(async()=>{const T=`${p}/${a}`;await b(T)},[p,a,n,t,y,c,h]);async function b(T){h(!0),c(null),y(null);try{const N=await we("/api/projects",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:a,workdir:T})});if(!N.ok){const O=await N.json().catch(()=>({}));if(O.code==="EACCES"){y(T),h(!1);return}throw new Error(O.error||"Failed to create project")}const A=(await N.json()).project;t(),await r(),n(`/p/${A.id}`)}catch(N){c(N instanceof Error?N.message:"Failed to create project"),h(!1)}}const v=E.useCallback(()=>{l(""),c(null),t()},[t]),k=a?`${p}/${a}`:"";return s.jsxs(s.Fragment,{children:[s.jsx(jt,{isOpen:e,onClose:v,title:"Create New Project",size:"sm",children:s.jsxs("form",{onSubmit:C,className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{htmlFor:"project-name",className:"block text-sm font-medium text-text-secondary mb-2",children:"Project Name"}),s.jsx(Gi,{ref:w,id:"project-name",value:a,onChange:T=>{l(T.target.value),c(null)},placeholder:"my-project",disabled:d,"data-testid":"create-project-name-input",className:"w-full"}),a&&s.jsxs("div",{className:"mt-2 text-xs text-text-muted",children:["Full path: ",s.jsx("span",{className:"font-mono",children:k})]}),u&&s.jsx("div",{className:"mt-3 p-3 bg-accent-error/10 border border-accent-error/30 rounded text-sm text-accent-error",children:u})]}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(dt,{type:"button",variant:"secondary",onClick:v,disabled:d,children:"Cancel"}),s.jsx(dt,{type:"submit",variant:"primary",disabled:d||!a.trim(),"data-testid":"create-project-submit-button",className:"min-w-[100px]",children:d?s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx(Ns,{className:"h-4 w-4"}),"Creating..."]}):"Create"})]})]})}),g&&s.jsx(RN,{isOpen:!!g,onClose:_,path:g,onRetry:S})]})}function ON(){return Zt(e=>e.workdir)}function kC({projects:e,currentProject:t}){const[,n]=Gn(),r=tn(_=>_.loadProject),a=tn(_=>_.toggleStar),l=tn(_=>_.createProject),u=tn(_=>_.listProjects),[c,d]=E.useState(!1),[h,p]=E.useState(!1),m=ON(),g=E.useCallback(async _=>{const S=hu(_),b=await l(S,_);return b&&"id"in b?(await u(),p(!1),n(`/p/${b.id}`),!0):!1},[l,u,n]),w=E.useMemo(()=>{const _=e.filter(b=>b.isStarred).sort((b,v)=>b.name.localeCompare(v.name)),S=e.filter(b=>!b.isStarred).sort((b,v)=>b.name.localeCompare(v.name));return[..._,...S]},[e]).map(_=>({label:s.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[s.jsx("span",{className:"truncate flex-1",children:_.name}),s.jsx("button",{onClick:S=>{S.stopPropagation(),S.preventDefault(),S.nativeEvent.stopImmediatePropagation(),a(_.id,!_.isStarred)},className:"flex-shrink-0 p-1 hover:bg-bg-tertiary rounded transition-colors",title:_.isStarred?"Unstar project":"Star project",children:_.isStarred?s.jsx(Xc,{className:"w-3.5 h-3.5 text-yellow-500"}):s.jsx(yf,{className:"w-3.5 h-3.5 text-text-muted hover:text-yellow-500"})})]}),icon:_.id===(t==null?void 0:t.id)?s.jsx(Ls,{}):void 0,href:`/p/${_.id}`,closeOnClick:!0,onClick:()=>{r(_.id)}})),C=[{label:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Qr,{className:"w-4 h-4"}),s.jsx("span",{children:"Open Project"})]}),onClick:()=>p(!0)},{label:s.jsxs("div",{className:"flex items-center gap-2 text-accent-primary",children:[s.jsx(Ns,{className:"w-4 h-4"}),s.jsx("span",{children:"New Project"})]}),onClick:()=>d(!0)}];return s.jsxs(s.Fragment,{children:[s.jsx(bu,{items:w,footerItems:C,trigger:s.jsxs("button",{className:`text-text-secondary hover:text-text-primary text-sm truncate flex items-center gap-1 ${t?"hover:underline":""}`,title:(t==null?void 0:t.name)??"Select project",children:[(t==null?void 0:t.name)??s.jsx("span",{className:"text-text-muted",children:"Select project..."}),s.jsx(vn,{})]}),minWidth:"250px"}),c&&s.jsx(DN,{isOpen:c,onClose:()=>d(!1)}),h&&s.jsx(_f,{initialPath:m??void 0,onSelect:g,onClose:()=>p(!1)})]})}function IN(e){const t=new Date(e),r=["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`${r} ${a}/${l}/${u}`}function Ff(e){const t=new Date(e),n=String(t.getHours()).padStart(2,"0"),r=String(t.getMinutes()).padStart(2,"0");return`${n}:${r}`}function KF(e){const t=new Date(e),n=new Date,r=new Date(n.getFullYear(),n.getMonth(),n.getDate()),a=new Date(t.getFullYear(),t.getMonth(),t.getDate()),l=Math.floor((r.getTime()-a.getTime())/(1e3*60*60*24)),u=Ff(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"),h=String(t.getDate()).padStart(2,"0");return`${c}/${d}/${h} ${u}`}}function MN(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 YF(e){const{year:t,month:n,day:r}=MN(e);return`${t}-${n}-${r}`}function PN(e){const t=new Map;for(const a of e){const l=YF(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)),r=new Map;for(const a of n)r.set(a,t.get(a));return r}function XF(e){const{year:t,month:n,day:r}=MN(e);return`${t}/${n}/${r} ${Ff(e)}`}function Kh(e,t){return e.length<=t?e:e.substring(0,t)+"..."}function QF({sessions:e,currentProject:t,currentSession:n,isOpen:r,onOpenChange:a}){var w;const l=De(C=>C.loadSession),u=De(C=>C.toggleFavorite),c=50,d=e.filter(C=>C.projectId===t.id).slice(0,15),h=d.filter(C=>C.isFavorite),p=d.filter(C=>!C.isFavorite),m=E.useMemo(()=>{const C=[];C.push({label:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Ns,{className:"w-4 h-4 text-accent-primary"}),s.jsx("span",{className:"text-sm",children:"New session"})]}),href:`/p/${t.id}/new`,onClick:()=>{}});const _=(b,v)=>{C.push({label:s.jsxs("div",{className:"min-w-[160px]",children:[s.jsx("div",{className:"truncate text-sm",children:Kh(b.title??b.id.slice(0,8),c)}),v&&s.jsx("div",{className:"text-text-muted text-xs",children:Ff(b.updatedAt)})]}),icon:b.id===(n==null?void 0:n.id)?s.jsx(Ls,{}):void 0,href:`/p/${t.id}/s/${b.id}`,onClick:()=>{l(b.id)},labelAction:s.jsx("button",{onClick:()=>u(b.id,!b.isFavorite),className:"flex-shrink-0 p-1 hover:bg-bg-tertiary rounded transition-colors",title:b.isFavorite?"Unfavorite session":"Favorite session",children:b.isFavorite?s.jsx(Xc,{className:"w-3.5 h-3.5 text-yellow-500"}):s.jsx(yf,{className:"w-3.5 h-3.5 text-text-muted hover:text-yellow-500"})})})},S=b=>{const v=PN(b);for(const[k,T]of v){const N=T[0];if(N){C.push({label:s.jsx("div",{className:"px-3 py-2 text-text-muted text-xs font-medium cursor-default",children:IN(N.updatedAt)}),onClick:()=>{}});for(const R of T)_(R,!0)}}};if(h.length>0)for(const b of h)_(b,!1);return S(p),C},[t.id,h,p,n==null?void 0:n.id]),g=((w=n==null?void 0:n.metadata)==null?void 0:w.title)??(n?n.id.slice(0,8):null),y=g?Kh(g,c):"No session selected";return s.jsx(bu,{items:m,isOpen:r,onOpenChange:a,trigger:s.jsxs("button",{className:"text-text-secondary hover:text-text-primary hover:underline text-sm truncate flex items-center gap-1",title:g??"","data-testid":"header-session-dropdown",children:[y,s.jsx(vn,{})]}),minWidth:"280px",labelActionClassName:"pr-3"})}function JF({items:e,trigger:t,isActive:n=!1}){const[r,a]=E.useState(!1),l=E.useRef(null);return E.useEffect(()=>{function u(c){l.current&&!l.current.contains(c.target)&&a(!1)}if(r)return document.addEventListener("mousedown",u),()=>document.removeEventListener("mousedown",u)},[r]),s.jsxs("div",{className:"relative",ref:l,children:[s.jsxs("button",{type:"button",onClick:()=>a(!r),className:`flex items-center gap-1 px-1.5 py-0.5 rounded transition-colors ${n?"bg-bg-tertiary":"hover:bg-bg-tertiary"}`,children:[typeof t=="string"?s.jsx("span",{className:"text-sm text-text-secondary font-medium",children:t}):t,s.jsx(vn,{className:"w-3 h-3 text-text-muted flex-shrink-0 transition-transform",rotate:r?180:0})]}),r&&e.length>0&&s.jsx("div",{className:"absolute top-full left-0 mt-1 w-56 bg-bg-secondary border border-border rounded-lg shadow-lg overflow-hidden z-50",children:e.map((u,c)=>{const d=u.label&&typeof u.label=="object"&&u.label.type===xr?u.label:null;if(d){const h=d.props.href||"";return s.jsxs(xr,{href:h,className:"flex items-center gap-2 px-3 py-2 text-sm border-b border-border hover:bg-bg-tertiary transition-colors",children:[u.icon,d.props.children]},c)}return u.href?s.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):s.jsxs("button",{type:"button",onClick:()=>{var h;(h=u.onClick)==null||h.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 ZF({currentProject:e,sessions:t,currentSession:n,projectIdFromUrl:r}){if(!(e!=null&&e.id)||e.id!==r)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:s.jsxs(xr,{href:`/p/${e.id}/new`,className:"flex items-center gap-2",children:[s.jsx(Ns,{className:"w-3 h-3 text-accent-primary"}),s.jsx("span",{className:"text-sm",children:"New Session"})]})},...a.map(u=>({label:s.jsx(xr,{href:`/p/${e.id}/s/${u.id}`,className:"flex items-center gap-2 truncate text-sm",children:s.jsx("span",{children:Kh(u.title??u.id.slice(0,8),50)})}),icon:u.id===(n==null?void 0:n.id)?s.jsx(Ls,{className:"w-3 h-3"}):void 0})),{label:s.jsxs(xr,{href:"/",className:"flex items-center gap-2 text-text-muted hover:text-text-primary",children:[s.jsx(T3,{className:"w-3 h-3"}),s.jsx("span",{className:"text-sm",children:"Projects"})]})}];return s.jsx(JF,{items:l,trigger:s.jsx("span",{className:"text-sm text-text-secondary font-medium",children:e.name})})}function e7({onMenuClick:e,onCriteriaToggle:t}){const[n,r]=E.useState(!1),[a,l]=E.useState(!1),[u,c]=E.useState(!!document.fullscreenElement),[d,h]=Gn();E.useEffect(()=>{const R=()=>c(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",R),()=>document.removeEventListener("fullscreenchange",R)},[]);const p=d.startsWith("/p/"),m=/^\/p\/[^/]+\/s\/[^/]+$/.test(d),g=De(R=>R.currentSession),y=De(R=>R.sessions),w=tn(R=>R.currentProject),C=tn(R=>R.projects),_=Zt(R=>R.startAutoRefresh),S=Zt(R=>R.stopAutoRefresh),b=is(R=>R.setOpen),v=is(R=>R.isOpen),k=li(R=>R.status==="available"),T=li(R=>R.check);E.useEffect(()=>{li.getState().status==="idle"&&T()},[T]),E.useEffect(()=>{const R=()=>l(!0);return window.addEventListener("open-session-dropdown",R),()=>window.removeEventListener("open-session-dropdown",R)},[]);const N=uu();return Qc(N.terminalToggle,()=>{is.getState().toggleOpen()},{capture:!0}),E.useEffect(()=>(_(),()=>S()),[_,S]),s.jsxs("header",{className:"h-8 bg-secondary border-b border-border flex items-center justify-between px-2",children:[s.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[e&&m&&s.jsx("button",{onClick:e,className:"flex-shrink-0 p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:N.sessionSearch?`Toggle session list (${Th(N.sessionSearch)})`:"Toggle session list",children:s.jsx(T1,{})}),s.jsx(xr,{href:"/",className:"text-accent-primary font-semibold text-sm hover:underline flex-shrink-0 hidden md:inline",children:"OpenFox"}),w&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"hidden md:inline text-text-muted flex-shrink-0",children:"/"}),s.jsx("span",{className:"hidden md:inline",children:s.jsx(kC,{projects:C,currentProject:w})}),s.jsx("span",{className:"md:hidden",children:s.jsx(ZF,{currentProject:w,sessions:y,currentSession:g,projectIdFromUrl:p&&d.split("/")[2]||null},w==null?void 0:w.id)}),s.jsx("span",{className:"hidden md:inline text-text-muted flex-shrink-0",children:"/"}),s.jsx("span",{className:"hidden md:inline",children:s.jsx(QF,{sessions:y,currentProject:w,currentSession:g,isOpen:a,onOpenChange:l})})]}),!w&&s.jsx("span",{className:"hidden md:inline",children:s.jsx(kC,{projects:C})})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[m&&s.jsx("button",{onClick:()=>{var R,A,O;document.fullscreenElement?(R=document.exitFullscreen)==null||R.call(document):(O=(A=document.documentElement).requestFullscreen)==null||O.call(A)},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?s.jsx(R3,{}):s.jsx(D3,{})}),p&&s.jsx("button",{onClick:()=>b(!v),className:`p-2.5 rounded hover:bg-bg-tertiary transition-colors ${v?"text-accent-primary":"text-text-muted hover:text-text-primary"}`,title:"Toggle terminal (double Ctrl)",children:s.jsx($3,{})}),p&&w&&s.jsx("button",{onClick:()=>we(`/api/projects/${w.id}/open-folder`).catch(()=>{}),className:"p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Open project folder",children:s.jsx(Qr,{className:"w-4 h-4"})}),s.jsxs("button",{onClick:()=>r(!0),className:"relative p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:k?"Settings — update available":"Settings",children:[s.jsx(AE,{}),k&&s.jsx("span",{className:"absolute top-1 right-1 w-1.5 h-1.5 rounded-full bg-accent-primary"})]}),s.jsx("button",{onClick:()=>{localStorage.removeItem("openfox_token"),h("/")},className:"p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Logout",children:s.jsx(I3,{})}),t&&m&&s.jsx("button",{onClick:t,className:"p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:N.criteriaSidebar?`Toggle criteria sidebar (${Th(N.criteriaSidebar)})`:"Toggle criteria sidebar",children:s.jsx(T1,{})})]}),s.jsx(BF,{isOpen:n,onClose:()=>r(!1)}),s.jsx(GF,{isOpen:v,onClose:()=>b(!1)})]})}function BN({onCancel:e,onSave:t,saving:n,saveDisabled:r,cancelLabel:a="Cancel",saveLabel:l=n?"Saving...":"Save"}){return s.jsxs("div",{className:"flex justify-end gap-2 flex-shrink-0",children:[s.jsx(dt,{variant:"secondary",onClick:e,children:a}),s.jsx(dt,{variant:"primary",onClick:t,disabled:r??n,children:l})]})}const eh=Jn()(e=>({config:null,loading:!1,fetchConfig:async t=>{e({loading:!0});try{const r=await(await we(`/api/workspace/config?workdir=${encodeURIComponent(t)}`)).json();e({config:r.config??null,loading:!1})}catch{e({loading:!1})}},saveConfig:async(t,n)=>{const r=await we(`/api/workspace/config?workdir=${encodeURIComponent(t)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!r.ok)throw new Error("Failed to save workspace config");const a=await r.json();e({config:a.config??n})}})),t7=["/","/etc","/bin","/sbin","/lib","/lib64","/usr","/var","/opt","/root","/run","/tmp","/home","/mnt","/media"],n7=["/proc/","/sys/","/dev/","/boot/","/etc/","/lost+found/"],$N=/^[a-zA-Z]:$/;function r7(e,t=t7,n=n7){if(!e)return null;const r=e.replace(/[\\/]+$/,"")||"/";if($N.test(r)||t.includes(r))return"exact";for(const a of n)if(r.startsWith(a))return"virtual_fs";return null}function zN(e){const t=e.replace(/[\\/]+$/,"");return t?$N.test(t)?`${t}\\`:t:"/"}function s7(e,t){const n=zN(e);return/[\\/]$/.test(n)?`${n}${t}`:`${n}/${t}`}function i7({isOpen:e,onClose:t,project:n}){const r=tn(ie=>ie.updateProject),a=eh(ie=>ie.config),l=eh(ie=>ie.loading),u=eh(ie=>ie.fetchConfig),c=eh(ie=>ie.saveConfig),d=()=>{try{Pt.send("context.checkDynamic",{})}catch{}t()},[h,p]=E.useState(n.customInstructions??""),[m,g]=E.useState(n.dangerLevel??""),[y,w]=E.useState(!1),[C,_]=E.useState(!1),[S,b]=E.useState(!1),[v,k]=E.useState(null),[T,N]=E.useState(""),[R,A]=E.useState(!1),[O,P]=E.useState(""),[V,z]=E.useState(!1),[W,M]=E.useState(""),[U,F]=E.useState(!1),[Q,X]=E.useState(!1),[H,I]=E.useState([]),[D,q]=E.useState(""),[$,J]=E.useState({}),[Y,Z]=E.useState(!1),[K,B]=E.useState(new Set),ne=y||C||R||V||Y;E.useEffect(()=>{e&&(p(n.customInstructions??""),g(n.dangerLevel??""),w(!1),_(!1),A(!1),z(!1),Z(!1),B(new Set),u(n.workdir))},[e,n,u]),E.useEffect(()=>{a!=null&&a.setup&&a.setup.length>0?N(a.setup.join(" && ")):N(""),P((a==null?void 0:a.rootDir)??""),J((a==null?void 0:a.mcpOverrides)??{})},[a]);const se=Kc(ie=>ie.servers),re=ie=>$[ie]??{},oe=ie=>{var ue;const ye=re(ie);if(ye.disabled!==void 0)return ye.disabled;const Le=se.find(de=>de.name===ie);return!!((ue=Le==null?void 0:Le.config)!=null&&ue.disabled)},ve=(ie,ye)=>{var ue;return((ue=re(ie).disabledTools)==null?void 0:ue.includes(ye))??!1},Se=ie=>{J(ye=>({...ye,[ie]:{...ye[ie],disabled:!oe(ie)}})),Z(!0)},$e=(ie,ye)=>{J(Le=>{const ue=Le[ie]??{},de=ue.disabledTools??[],Fe=de.includes(ye)?de.filter(Ue=>Ue!==ye):[...de,ye];return{...Le,[ie]:{...ue,disabledTools:Fe.length>0?Fe:void 0}}}),Z(!0)},ze=ie=>{B(ye=>{if(ye.has(ie)){const ue=new Set(ye);return ue.delete(ie),ue}const Le=new Set(ye);return Le.add(ie),Le})},ke=ie=>{p(ie.target.value),w(!0)},Ge=ie=>{g(ie),_(!0)},Je=ie=>{N(ie.target.value),A(!0)},Ce=ie=>{P(ie.target.value),z(!0)},me=E.useCallback(async()=>{const ie=m===""?null:m;if(await r(n.id,{customInstructions:h||null,dangerLevel:ie}),R||V||Y){const ye=T.trim()?T.split("&&").map(ue=>ue.trim()).filter(Boolean):[],Le={};R&&(Le.setup=ye),V&&(Le.rootDir=O.trim()),Object.keys($).length>0&&(Le.mcpOverrides=$),await c(n.workdir,Le)}w(!1),_(!1),A(!1),z(!1),Z(!1),d()},[n.id,m,h,T,O,$,R,V,Y,r,c,n.workdir,d]),We=async()=>{const ie=O.trim(),ye=(a==null?void 0:a.rootDir)??"";if(ie){const Le=r7(ie);if(Le==="exact"){const ue=zN(ie);k(`Cannot use "${ue}" directly as workspace root. Use a subdirectory like "${s7(ie,n.name)}" instead.`);return}if(Le==="virtual_fs"){k(`Cannot use paths under "${ie}" for workspaces.`);return}}if(!V||!ie||ie===ye){b(!0),k(null);try{await me()}catch(Le){k(Le instanceof Error?Le.message:"Failed to save settings")}finally{b(!1)}return}M(ie),b(!0),k(null);try{const Le=await we(`/api/workspace/config/validate?workdir=${encodeURIComponent(n.workdir)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({rootDir:ie,workdir:n.workdir,projectName:n.name})});if(!Le.ok){const de=await Le.json().catch(()=>({}));k((de==null?void 0:de.error)??"Failed to validate workspace root directory");return}const ue=await Le.json();if(!ue.exists){q(ue.resolvedPath),F(!0);return}if(ue.workspaces&&ue.workspaces.length>0){I(ue.workspaces),X(!0);return}k(null),await me()}catch(Le){k(Le instanceof Error?Le.message:"Failed to validate settings")}finally{b(!1)}},he=async()=>{F(!1),b(!0);try{const ie=await we(`/api/workspace/config/validate?workdir=${encodeURIComponent(n.workdir)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({rootDir:W,workdir:n.workdir,projectName:n.name,createIfMissing:!0})});if(!ie.ok){const Le=await ie.json().catch(()=>({}));k((Le==null?void 0:Le.error)??"Failed to create directory"),b(!1);return}const ye=await ie.json();if(ye.workspaces&&ye.workspaces.length>0){I(ye.workspaces),X(!0),b(!1);return}await me()}catch(ie){k(ie instanceof Error?ie.message:"Failed to create directory")}finally{b(!1)}},Ve=async()=>{X(!1),b(!0),k(null);try{await me()}catch(ie){k(ie instanceof Error?ie.message:"Failed to save settings")}finally{b(!1)}},He=()=>{F(!1),X(!1),p(n.customInstructions??""),g(n.dangerLevel??""),w(!1),_(!1),A(!1),z(!1),d()};return s.jsxs(jt,{isOpen:e,onClose:He,title:`${n.name} Settings`,size:"lg",footer:s.jsx(BN,{onCancel:He,onSave:We,saving:S,saveDisabled:!ne||S}),children:[s.jsxs("div",{className:"flex flex-col gap-5 -mt-1",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"Default Danger Level"}),s.jsx("p",{className:"text-sm text-text-muted mb-3",children:"Default danger level for new sessions in this project. Existing sessions are not affected."}),s.jsxs("div",{className:"flex items-center gap-1 px-1.5 py-1 rounded bg-bg-tertiary/50 w-fit",children:[s.jsx("button",{type:"button",onClick:()=>Ge(""),className:`px-3 py-1 text-sm font-medium rounded transition-colors ${m===""?"bg-bg-tertiary text-text-primary border border-border":"text-text-muted hover:text-text-primary hover:bg-bg-tertiary"}`,title:"Use global default (Normal)",children:"Default"}),s.jsx("button",{type:"button",onClick:()=>Ge("normal"),className:`px-3 py-1 text-sm font-medium rounded transition-colors ${m==="normal"?"bg-accent-success/20 text-accent-success border border-accent-success/30":"text-text-muted hover:text-text-primary hover:bg-bg-tertiary"}`,title:"Normal mode - requires path confirmation",children:"Normal"}),s.jsx("button",{type:"button",onClick:()=>Ge("dangerous"),className:`px-3 py-1 text-sm font-medium rounded transition-colors ${m==="dangerous"?"bg-red-500/20 text-red-400 border border-red-500/30":"text-text-muted hover:text-text-primary hover:bg-bg-tertiary"}`,title:"Dangerous mode - bypasses all confirmations",children:"Dangerous"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"Project Path"}),s.jsx("p",{className:"text-sm text-text-muted font-mono",children:n.workdir})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"Project Instructions"}),s.jsx("p",{className:"text-sm text-text-muted mb-3 flex-shrink-0",children:"These instructions are injected into prompts when working in this project. They are applied after global instructions but before AGENTS.md files."}),s.jsx("textarea",{value:h,onChange:ke,placeholder:"Enter project-specific instructions...",className:"w-full h-32 px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono resize-none focus:outline-none focus:ring-1 focus:ring-accent-primary",disabled:S})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"Workspace Setup Command"}),s.jsxs("p",{className:"text-sm text-text-muted mb-3",children:["Command(s) to run after creating a workspace (shared clone). Use"," ",s.jsx("code",{className:"text-xs bg-bg-tertiary px-1 rounded",children:"&&"})," to chain multiple commands. Example:"," ",s.jsx("code",{className:"text-xs bg-bg-tertiary px-1 rounded",children:"npm install --prefer-offline"})]}),l&&s.jsx("div",{className:"text-xs text-text-muted mb-2",children:"Loading config..."}),s.jsx("input",{type:"text",value:T,onChange:Je,placeholder:"npm install --prefer-offline",className:"w-full px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono focus:outline-none focus:ring-1 focus:ring-accent-primary",disabled:l||S})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"Workspace Root Directory"}),s.jsxs("p",{className:"text-sm text-text-muted mb-3",children:["Override the default workspace location. Leave empty to use the global directory"," ",s.jsx("code",{className:"text-xs bg-bg-tertiary px-1 rounded",children:"~/.local/share/openfox/workspaces/"}),". Supports absolute paths or paths relative to the project."]}),s.jsx("input",{type:"text",value:O,onChange:Ce,placeholder:"/absolute/or/relative/path",className:"w-full px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono focus:outline-none focus:ring-1 focus:ring-accent-primary",disabled:l||S})]}),se.length>0&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-text-primary mb-1 flex-shrink-0",children:"MCP Servers"}),s.jsx("p",{className:"text-sm text-text-muted mb-3",children:"Override MCP server availability for this project. These overrides apply to new conversations in this project and can be further overridden per conversation from the chat MCP selector."}),s.jsx("div",{className:"space-y-2",children:se.map(ie=>{const ye=oe(ie.name);return s.jsx(NN,{server:ie,expanded:K.has(ie.name),onToggleExpand:ze,serverToggleEnabled:!ye,onServerToggle:()=>Se(ie.name),tools:ie.tools.map(Le=>({...Le,enabled:!ve(ie.name,Le.name)})),onToolToggle:Le=>$e(ie.name,Le),statusDot:Eb(ye?"disabled":ie.status),statusColor:kb(ye?"disabled":ie.status)},ie.name)})})]}),v&&s.jsx("div",{className:"text-sm text-red-400 bg-red-500/10 border border-red-500/20 rounded px-3 py-2",children:v})]}),U&&s.jsxs(jt,{isOpen:U,onClose:()=>F(!1),title:"Directory not found",size:"md",footer:s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx("button",{type:"button",onClick:()=>F(!1),className:"px-4 py-2 text-sm font-medium rounded bg-bg-tertiary text-text-primary hover:bg-border transition-colors",children:"Cancel"}),s.jsx("button",{type:"button",onClick:he,className:"px-4 py-2 text-sm font-medium rounded bg-accent-primary text-white hover:opacity-90 transition-colors",children:"Create"})]}),children:[s.jsxs("p",{className:"text-sm text-text-primary",children:["The directory ",s.jsx("code",{className:"text-xs bg-bg-tertiary px-1 rounded",children:D})," does not exist."]}),s.jsx("p",{className:"text-sm text-text-muted mt-2",children:"Would you like to create it?"})]}),Q&&s.jsxs(jt,{isOpen:Q,onClose:()=>X(!1),title:"Orphaned workspaces",size:"md",footer:s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx("button",{type:"button",onClick:()=>X(!1),className:"px-4 py-2 text-sm font-medium rounded bg-bg-tertiary text-text-primary hover:bg-border transition-colors",children:"Cancel"}),s.jsx("button",{type:"button",onClick:Ve,className:"px-4 py-2 text-sm font-medium rounded bg-red-500 text-white hover:opacity-90 transition-colors",children:"Confirm change"})]}),children:[s.jsxs("p",{className:"text-sm text-text-primary",children:[H.length," existing workspace(s) will not be migrated and will become inaccessible:"]}),s.jsx("ul",{className:"mt-2 space-y-1",children:H.map(ie=>s.jsx("li",{className:"text-sm font-mono text-text-muted",children:ie.name},ie.name))}),s.jsx("p",{className:"text-sm text-text-muted mt-3",children:"Existing workspaces will remain in the old location but will no longer be accessible from this project."})]})]})}const a7={sm:"w-3 h-3",md:"w-4 h-4",lg:"w-5 h-5",xl:"w-6 h-6"},o7="M6 18L18 6M6 6l12 12";function vu({onClick:e,className:t="",size:n="md",variant:r="default","aria-label":a,title:l="Close"}){const u=r==="overlay"?"bg-accent-error text-white rounded-full flex items-center justify-center hover:bg-accent-error/80 transition-colors":r==="sidebar"?"flex-shrink-0 p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors":r==="modal"?"text-text-muted hover:text-text-primary transition-colors":"hover:text-white transition-colors";return s.jsx(bf,{onClick:e,icon:o7,iconSize:a7[n],className:`${u} ${t}`,title:l,...a!==void 0?{"aria-label":a}:{}})}function fr(e,t){const n=new Set(t.map(r=>r.id));return[...e.filter(r=>!n.has(r.id)),...t]}function cy(e,t){if(!t)return e;const n=e.toLowerCase(),r=t.toLowerCase(),a=new Array(e.length).fill(!1),l=n.indexOf(r);if(l>=0)for(let p=l;p<l+r.length;p++)a[p]=!0;else{let p=0;for(let m=0;m<e.length&&p<r.length;m++)n[m]===r[p]&&(a[m]=!0,p++)}const u=Array.from(e),c=[];let d="",h=a[0]??!1;for(let p=0;p<u.length;p++){const m=u[p]??"";a[p]===h?d+=m:(c.push(h?s.jsx("span",{className:"font-semibold text-accent-primary",children:d},c.length):d),d=m,h=a[p]??!1)}return c.push(h?s.jsx("span",{className:"font-semibold text-accent-primary",children:d},c.length):d),s.jsx(s.Fragment,{children:c})}function Ui(e,t){if(!t)return!0;const n=t.toLowerCase().split(/\s+/),r=e.toLowerCase().split(/\s+/);return n.every(a=>{for(const l of r){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 HN(e,t,n,r,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(),r();break;case"Escape":e.preventDefault(),a();break}}function FN({initialWidth:e,minWidth:t,maxWidth:n,direction:r}){const[a,l]=E.useState(e),[u,c]=E.useState(!1),d=E.useRef({startX:0,startWidth:e}),h=E.useCallback(p=>{p.preventDefault(),p.stopPropagation(),d.current={startX:p.clientX,startWidth:a},c(!0)},[a]);return E.useEffect(()=>{if(!u)return;const p=w=>{const{startX:C,startWidth:_}=d.current,S=w.clientX-C,b=r==="left"?_+S:_-S;l(Math.max(t,Math.min(n,b)))},m=()=>{c(!1)};document.addEventListener("mousemove",p),document.addEventListener("mouseup",m);const g=document.body.style.userSelect,y=document.body.style.cursor;return document.body.style.userSelect="none",document.body.style.cursor="col-resize",()=>{document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",m),document.body.style.userSelect=g,document.body.style.cursor=y}},[u,r,t,n]),{width:a,isResizing:u,handleMouseDown:h}}function UN({side:e,onMouseDown:t,className:n=""}){return s.jsx("div",{role:"separator","aria-orientation":"vertical",onMouseDown:t,className:`absolute top-0 bottom-0 w-1 z-20 cursor-col-resize hover:bg-accent-primary/30 transition-colors ${e==="left"?"left-0 -ml-0.5":"right-0 -mr-0.5"} ${n}`})}function VN({projectId:e,isOpen:t=!0,onClose:n}){const[,r]=Gn(),[a,l]=E.useState(!1),[u,c]=E.useState(null),[d,h]=E.useState(null),[p,m]=E.useState(""),[g,y]=E.useState(!1),w=De(me=>me.sessions),C=De(me=>me.currentSession),_=De(me=>me.unreadSessionIds),S=De(me=>me.deleteSession),b=De(me=>me.deleteAllSessions),v=De(me=>me.loadMoreSessions),k=De(me=>me.sessionsHasMore),T=De(me=>me.sessionsPaginationLoading),N=De(me=>me.sessionsWithPendingConfirmations),R=De(me=>me.pendingPathConfirmations),A=De(me=>me.toggleFavorite),O=tn(me=>me.currentProject),[P,V]=E.useState(""),[z,W]=E.useState(-1),M=E.useRef(null),U=E.useRef(null),{width:F,handleMouseDown:Q}=FN({initialWidth:300,minWidth:200,maxWidth:600,direction:"left"}),X=E.useRef(!1),H=uu();Qc(H.sessionSearch,()=>{var me;if(t&&document.activeElement===M.current){n==null||n();return}t||(X.current=!0,n==null||n()),Bt()&&((me=M.current)==null||me.focus())});const I=E.useRef(null),D=E.useCallback(()=>{k&&!T&&O&&v(O.id)},[k,T,O,v]);E.useEffect(()=>{if(!I.current||!k)return;const me=new IntersectionObserver(We=>{const he=We[0];he&&he.isIntersecting&&D()},{threshold:.1});return me.observe(I.current),()=>me.disconnect()},[k,D]);const q=w.filter(me=>me.projectId===(O==null?void 0:O.id)),[$,J]=E.useMemo(()=>{const me=[],We=[];for(const he of q)he.isFavorite?me.push(he):We.push(he);return[me,We]},[q]),Y=me=>P?me.filter(We=>{var He;const he=We.title??"",Ve=(((He=We.recentUserPrompts)==null?void 0:He.map(ie=>ie.content))??[]).join(" ");return Ui(he,P)||Ui(Ve,P)}):me,Z=E.useMemo(()=>Y($),[$,P]),K=E.useMemo(()=>Y(J),[J,P]),B=[...Z,...K],ne=P.length>0,se=ne&&B.length===0;E.useEffect(()=>{W(B.length>0?0:-1)},[B.length]),E.useEffect(()=>{var We;if(z<0)return;const me=(We=U.current)==null?void 0:We.querySelector(`[data-sidx="${z}"]`);me==null||me.scrollIntoView({block:"nearest"})},[z]);const re=(me,We)=>{We==null||We.stopPropagation(),c(me)},oe=()=>{u&&(S(u),(C==null?void 0:C.id)===u&&r(`/p/${e}`),c(null))},ve=(me,We)=>{We==null||We.stopPropagation();const he=w.find(He=>He.id===me),Ve=(he==null?void 0:he.title)??me.slice(0,6);m(Ve),h(me)},Se=()=>{if(!d||p.trim()==="")return;const me=De.getState().renameSession;me(d,p.trim()),h(null),m("")},$e=()=>{y(!0)},ze=()=>{b(e),r(`/p/${e}`),y(!1)},ke=(me,We)=>{A(me,!We)},Ge=me=>{if(!X.current)return;me.target.closest('a[href*="/s/"]')&&(X.current=!1,n==null||n())},Je=()=>{var me;V(""),Bt()&&((me=M.current)==null||me.focus())},Ce=me=>{var We;switch(me.key){case"Escape":V(""),(We=M.current)==null||We.blur();break;case"ArrowDown":me.preventDefault(),W(he=>he<B.length-1?he+1:he);break;case"ArrowUp":me.preventDefault(),W(he=>he>0?he-1:0);break;case"Enter":{me.preventDefault();const he=B[z];he&&(r(`/p/${e}/s/${he.id}`),X.current&&(X.current=!1,n==null||n()));break}}};return s.jsxs(s.Fragment,{children:[t&&n&&s.jsx("div",{className:"md:hidden fixed inset-0 bg-black/50 z-40",onClick:n}),(()=>{const me=s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"p-4 border-b border-border flex gap-2",children:[s.jsx(xr,{href:`/p/${e}/new`,className:"flex-1 block text-center rounded font-medium transition-colors bg-accent-primary/25 text-text-primary hover:bg-accent-primary/40 px-3 py-1.5 text-sm","data-testid":"sidebar-new-session-button",children:"+ New Session"}),s.jsx(bu,{items:[{label:"Edit project settings",onClick:()=>l(!0)},{label:"Delete all sessions",onClick:$e,danger:!0}],trigger:s.jsx("button",{className:"flex-shrink-0 p-2.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Options",children:s.jsx(EE,{})})}),n&&s.jsx(vu,{onClick:n,className:"md:hidden",variant:"sidebar",size:"md"})]}),s.jsxs("div",{className:"px-4 py-2 border-b border-border",children:[s.jsxs("div",{className:"relative flex items-center",children:[s.jsx(Xi,{className:"absolute left-2.5 w-3.5 h-3.5 text-text-muted pointer-events-none"}),s.jsx("input",{ref:M,type:"text",value:P,onChange:We=>V(We.target.value),onKeyDown:Ce,placeholder:"Search sessions...",className:"w-full bg-bg-tertiary border border-border rounded pl-8 pr-8 py-1.5 text-sm text-text-primary placeholder-text-muted focus:outline-none focus:ring-1 focus:ring-accent-primary/50 focus:border-accent-primary transition-colors"}),P&&s.jsx("button",{type:"button",onClick:Je,className:"absolute right-1.5 p-0.5 rounded text-text-muted hover:text-text-primary hover:bg-bg-tertiary transition-colors","aria-label":"Clear search",children:s.jsx(Ji,{className:"w-3.5 h-3.5"})})]}),ne&&!se&&s.jsxs("div",{className:"mt-1 text-xs text-text-muted px-1",children:[B.length," ",B.length===1?"match":"matches"]})]}),O&&s.jsx(i7,{isOpen:a,onClose:()=>l(!1),project:O}),s.jsx(Zc,{isOpen:u!==null,onClose:()=>c(null),onConfirm:oe,title:"Delete session?",message:"This session will be permanently deleted.",confirmLabel:"Delete session",confirmVariant:"danger"}),s.jsx(Zc,{isOpen:g,onClose:()=>y(!1),onConfirm:ze,title:"Delete all sessions?",message:"Delete all sessions in this project? This cannot be undone.",confirmLabel:"Delete all",confirmVariant:"danger"}),s.jsx(jt,{isOpen:d!==null,onClose:()=>{h(null),m("")},title:"Rename session",size:"sm",footer:s.jsx(BN,{onCancel:()=>{h(null),m("")},onSave:Se,saving:!1,saveDisabled:p.trim()==="",saveLabel:"Rename"}),children:s.jsx("input",{type:"text",value:p,onChange:We=>m(We.target.value),onKeyDown:We=>{We.key==="Enter"&&Se()},onFocus:We=>We.target.select(),className:"w-full px-3 py-2 text-sm text-text-primary bg-bg-tertiary border border-border rounded focus:outline-none focus:ring-1 focus:ring-accent-primary",autoFocus:Bt()})}),s.jsx(ct,{className:"flex-1",children:B.length===0?s.jsx("div",{className:"p-4 text-center text-text-muted text-xs",children:ne?"No matching sessions":"No sessions"}):s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"divide-y divide-border",ref:U,onClick:Ge,children:l7(Z,K,C,_,re,ve,ke,e,N,R,P,z)}),T&&s.jsx("div",{className:"p-4 text-center text-text-muted text-xs",children:"Loading more..."}),s.jsx("div",{ref:I,className:"h-px"})]})})]});return s.jsxs("aside",{className:`
275
+ ${t?"md:w-[var(--sidebar-w)] md:shrink-0":"md:w-0 md:shrink-0 md:overflow-hidden md:border-r-0"}
276
+ md:relative md:h-auto md:translate-x-0
277
+
278
+ fixed z-50 h-[calc(100vh-32px)]
279
+ w-[300px] bg-secondary border-r border-border flex flex-col
280
+ transition-transform duration-300 ease-in-out
281
+ ${t?"translate-x-0":"-translate-x-full"}
282
+ `,style:{"--sidebar-w":`${F}px`},children:[me,t&&s.jsx(UN,{side:"right",onMouseDown:Q,className:"hidden md:block"})]})})()]})}function l7(e,t,n,r,a,l,u,c,d,h,p,m){let g=0;const y=C=>{const _=g++,S=(n==null?void 0:n.id)===C.id,b=_===m,v=r.includes(C.id),k=C.isRunning,T=C.isFavorite,N=d.includes(C.id)||S&&h.length>0;return s.jsx("div",{"data-sidx":_,className:`w-full px-4 py-3 text-left hover:bg-bg-tertiary/50 transition-colors group ${S?"bg-bg-tertiary":""} ${b?"bg-accent-primary/10":""}`,children:s.jsxs(xr,{href:`/p/${c}/s/${C.id}`,className:`block ${S?"text-accent-primary":"text-text-primary"} hover:text-accent-primary`,children:[s.jsxs("div",{className:"flex justify-between items-center mb-1",children:[s.jsx("span",{className:`font-medium truncate text-sm ${S?"text-accent-primary":"text-text-primary"}`,children:p?cy(C.title??C.id.slice(0,6),p):C.title??C.id.slice(0,6)}),s.jsx("div",{className:"flex items-center gap-1",children:s.jsx(bu,{items:[{label:T?"Remove from favorites":"Add to favorites",icon:T?s.jsx(Xc,{className:"w-3.5 h-3.5 text-amber-400"}):s.jsx(yf,{className:"w-3.5 h-3.5"}),onClick:()=>u(C.id,T)},{label:"Rename session",onClick:R=>l(C.id,R)},{label:"Delete session",onClick:R=>a(C.id,R),danger:!0}],trigger:s.jsx("button",{onClick:R=>{R.preventDefault()},className:"p-1.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-all",title:"Options",children:s.jsx(EE,{})})})})]}),s.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[N?s.jsx("span",{title:"Awaiting confirmation",children:s.jsx(By,{className:"w-3 h-3 text-red-400 flex-shrink-0"})}):k?s.jsx(P3,{}):v&&!S?s.jsx("span",{"aria-label":"Unread activity",title:"Unread activity",className:"w-2 h-2 rounded-full bg-amber-400 flex-shrink-0"}):null,!T&&s.jsx("span",{className:"text-text-muted text-xs flex-shrink-0",children:Ff(C.updatedAt)}),s.jsxs("span",{className:"text-text-muted text-xs flex-shrink-0",children:[C.messageCount," messages"]})]})]})},C.id)},w=C=>{const _=PN(C);return Array.from(_).map(([S,b])=>{const v=b[0];return v?s.jsxs("div",{children:[s.jsx("div",{className:"px-4 py-2 bg-bg-tertiary/30 text-text-muted text-xs font-medium",children:IN(v.updatedAt)}),b.map(k=>y(k))]},S):null})};return s.jsxs(s.Fragment,{children:[e.length>0&&s.jsxs("div",{children:[s.jsxs("div",{className:"px-4 py-2 bg-bg-tertiary/50 text-text-primary text-xs font-semibold flex items-center gap-1",children:[s.jsx(Xc,{className:"w-3 h-3 text-amber-400"}),"Favorites"]}),e.map(C=>y(C))]}),t.length>0&&w(t)]})}const EC=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧"];function c7(){var u;const e=tn(c=>c.currentProject),t=De(c=>c.currentSession),n=gf(),r=E.useRef(0),a=E.useRef(null);E.useEffect(()=>(n?(a.current||(r.current=0),a.current=window.setInterval(()=>{r.current=(r.current+1)%EC.length,l()},150),l()):(a.current&&(clearInterval(a.current),a.current=null),l()),()=>{a.current&&(clearInterval(a.current),a.current=null)}),[n,e,t]);const l=()=>{var p;const d=(p=t==null?void 0:t.metadata)==null?void 0:p.title,h=n?`${EC[r.current]} `:"";e&&d?document.title=`${h}${e.name} - ${d} | OpenFox`:e?document.title=`${h}${e.name} | OpenFox`:document.title=`${h}OpenFox`};return typeof window<"u"&&((u=t==null?void 0:t.metadata)!=null&&u.title)&&window.document.documentElement.setAttribute("data-session-title",t.metadata.title),null}function WN({isOpen:e,onClose:t,projectName:n,onConfirm:r}){const a=()=>{r(),t()};return s.jsx(Zc,{isOpen:e,onClose:t,onConfirm:a,title:"Delete Project",confirmLabel:"Delete",confirmVariant:"danger",message:s.jsxs(s.Fragment,{children:["This will permanently delete the project"," ",s.jsx("span",{className:"font-semibold text-text-primary",children:n})," and all its sessions from OpenFox. The project files on disk will remain untouched."]})})}function u7({isOpen:e,onClose:t}){const[,n]=Gn(),[r,a]=E.useState(!1),l=ON(),[u,c]=E.useState(!1),d=tn(A=>A.projects),h=tn(A=>A.createProject),p=tn(A=>A.listProjects),m=tn(A=>A.deleteProject),[g,y]=E.useState(null),[w,C]=E.useState(null);E.useEffect(()=>{e&&p()},[e,p]);const _=A=>{n(`/p/${A}`),t()},S=(A,O)=>{O.stopPropagation(),y(A)},b=()=>{g&&(m(g.id),y(null))},v=async A=>T(A);function k(A){return A!=null&&typeof A=="object"&&"error"in A&&A.error!=null&&typeof A.error=="object"&&"code"in A.error&&A.error.code==="EACCES"}async function T(A){const O=hu(A),P=await h(O,A);return p(),k(P)?(C(P.error.path||A),!1):P&&"id"in P?(n(`/p/${P.id}`),t(),!0):!1}const N=E.useCallback(()=>{C(null)},[]),R=E.useCallback(async()=>{const A=w;C(null),A&&await T(A)},[w]);return e?s.jsxs(jt,{isOpen:e,onClose:t,title:"Open Project",size:"xl",footer:s.jsx("div",{className:"flex justify-end gap-2",children:s.jsx(dt,{variant:"secondary",onClick:t,children:"Close"})}),children:[s.jsxs("div",{className:"flex flex-col sm:flex-row flex-1 -m-4",children:[s.jsxs("div",{className:"w-full sm:w-1/2 border-b sm:border-b-0 sm:border-r border-border flex flex-col max-h-[40vh] sm:max-h-[50vh]",children:[s.jsx("div",{className:"p-3 border-b border-border bg-bg-tertiary/30 shrink-0",children:s.jsx("h3",{className:"font-medium text-sm text-text-secondary",children:"Recent Projects"})}),s.jsx(ct,{className:"flex-1",children:d.length===0?s.jsxs("div",{className:"p-6 text-center text-text-muted text-sm",children:[s.jsx("p",{className:"mb-2",children:"No recent projects"}),s.jsx("p",{className:"text-xs",children:'Click "Create new project" to add one'})]}):s.jsx("div",{className:"divide-y divide-border",children:d.map(A=>s.jsxs("div",{className:"group flex items-center gap-3 p-3 hover:bg-bg-tertiary/50 transition-colors",children:[s.jsxs("button",{onClick:()=>_(A.id),className:"flex-1 flex items-center gap-3 text-left",children:[s.jsx(Qr,{className:"w-5 h-5 text-accent-primary"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"font-medium truncate",children:A.name}),s.jsx("div",{className:"text-xs text-text-muted truncate",children:$E(A.workdir,32)})]})]}),s.jsx("button",{onClick:O=>S(A,O),className:"text-accent-error/70 hover:text-accent-error p-1",title:"Delete project",children:s.jsx(Ya,{className:"w-4 h-4"})})]},A.id))})})]}),s.jsx("div",{className:"w-full sm:w-1/2 flex flex-col items-center justify-center p-6 sm:p-8 text-center",children:s.jsxs("div",{className:"flex flex-col gap-3 w-full max-w-sm",children:[s.jsx(dt,{variant:"primary",onClick:()=>c(!0),children:"Select existing project"}),s.jsx(dt,{variant:"secondary",onClick:()=>a(!0),"data-testid":"open-project-create-button",children:"Create new project"})]})})]}),r&&s.jsx(DN,{isOpen:r,onClose:()=>a(!1)}),g&&s.jsx(WN,{isOpen:!0,onClose:()=>y(null),projectName:g.name,onConfirm:b}),u&&s.jsx(_f,{initialPath:l??void 0,onSelect:A=>{v(A)},onClose:()=>c(!1)}),w&&s.jsx(RN,{isOpen:!0,onClose:N,path:w,onRetry:R})]}):null}function d7(){const[e,t]=E.useState(!1),[n,r]=E.useState(null),[a,l]=E.useState(""),[u,c]=E.useState(""),d=E.useRef(null),h=De(F=>F.searchSessions??F.sessions),p=De(F=>F.searchSessions!==null),m=tn(F=>F.projects),g=tn(F=>F.loading),y=tn(F=>F.listProjects),w=De(F=>F.listHomeSessions),C=De(F=>F.ensureFullSessionList),_=tn(F=>F.deleteProject),S=De(F=>F.connectionStatus);E.useEffect(()=>{S==="connected"&&(y(),w())},[S,y,w]),E.useEffect(()=>{const F=setTimeout(()=>c(a),150);return()=>clearTimeout(F)},[a]),E.useEffect(()=>{u&&!p&&C()},[u,p,C]);const{matchCount:b,filteredSessionIds:v,relevanceScores:k,matchTypes:T,promptSnippets:N}=E.useMemo(()=>{if(!u)return{matchCount:0,filteredSessionIds:null,relevanceScores:null,matchTypes:null,promptSnippets:null};const F=new Map(m.map(D=>[D.id,D])),Q=new Map,X=new Map,H=new Map,I=h.filter(D=>{var ne;const q=F.get(D.projectId),$=(q==null?void 0:q.name)??"",J=D.title??"",Y=((ne=D.recentUserPrompts)==null?void 0:ne.map(se=>se.content))??[],Z=Y.join(" ");let K=0,B="";if(Ui(J,u)&&(K+=10,B="title"),Ui(Z,u)){K+=3,B=B==="title"?"title":"prompts";const se=Y.find(re=>Ui(re,u));if(se){const re=se.toLowerCase().indexOf(u.toLowerCase());if(re>=0){const oe=Math.max(0,re-30),ve=Math.min(se.length,re+u.length+30);H.set(D.id,(oe>0?"…":"")+se.slice(oe,ve)+(ve<se.length?"…":""))}else H.set(D.id,se.slice(0,80)+(se.length>80?"…":""))}}return Ui($,u)&&(K+=1,B=B||"project"),Q.set(D.id,K),X.set(D.id,B),K>0});return{matchCount:I.length,filteredSessionIds:new Set(I.map(D=>D.id)),relevanceScores:Q,matchTypes:X,promptSnippets:H}},[h,u,m]),R=E.useMemo(()=>{const F=new Map;for(const Q of h){const X=new Date(Q.updatedAt).getTime(),H=F.get(Q.projectId)??0;X>H&&F.set(Q.projectId,X)}return F},[h]),A=E.useMemo(()=>{const F=new Map;for(const Q of h){const X=F.get(Q.projectId);X?X.push(Q):F.set(Q.projectId,[Q])}for(const[,Q]of F)Q.sort((X,H)=>new Date(H.updatedAt).getTime()-new Date(X.updatedAt).getTime());return F},[h]),O=E.useMemo(()=>{let F=m;return u&&v&&(F=m.filter(Q=>{const X=A.get(Q.id);return X==null?void 0:X.some(H=>v.has(H.id))})),[...F].sort((Q,X)=>{const H=R.get(Q.id)??new Date(Q.updatedAt).getTime();return(R.get(X.id)??new Date(X.updatedAt).getTime())-H})},[m,A,u,v,R]),P=E.useCallback(F=>{const Q=A.get(F);return Q?u&&v&&k?Q.filter(X=>v.has(X.id)).sort((X,H)=>{const I=(k.get(H.id)??0)-(k.get(X.id)??0);return I!==0?I:new Date(H.updatedAt).getTime()-new Date(X.updatedAt).getTime()}):Q.slice(0,5):[]},[A,u,v,k]),V=()=>{t(!0)},z=()=>{var F;l(""),c(""),Bt()&&((F=d.current)==null||F.focus())},W=F=>{var Q;F.key==="Escape"&&(z(),(Q=d.current)==null||Q.blur())},M=u.length>0,U=M&&b===0;return s.jsxs(ct,{className:"flex-1 flex flex-col bg-primary",children:[s.jsxs("div",{className:"max-w-5xl mx-auto w-full p-4 md:p-8",children:[s.jsxs("div",{className:"mb-6 md:mb-8 flex items-center justify-between",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-3xl font-bold text-accent-primary",children:"OpenFox"}),s.jsx("p",{className:"text-text-secondary",children:"Local LLM-powered coding assistant with contract-driven execution"})]}),s.jsx(dt,{variant:"primary",onClick:V,children:"Open Project"})]}),h.length>0&&s.jsxs("div",{className:"mb-4 md:mb-6 relative",children:[s.jsxs("div",{className:"relative flex items-center",children:[s.jsx(Xi,{className:"absolute left-3 w-4 h-4 text-text-muted pointer-events-none"}),s.jsx("input",{ref:d,type:"text",value:a,onChange:F=>l(F.target.value),onKeyDown:W,placeholder:"Search sessions by title or keyword...",className:"w-full bg-bg-secondary border border-border rounded-lg pl-10 pr-10 py-2.5 text-sm text-text-primary placeholder-text-muted focus:outline-none focus:ring-2 focus:ring-accent-primary/50 focus:border-accent-primary transition-colors"}),a&&s.jsx("button",{type:"button",onClick:z,className:"absolute right-3 p-0.5 rounded text-text-muted hover:text-text-primary hover:bg-bg-tertiary transition-colors","aria-label":"Clear search",children:s.jsx(Ji,{className:"w-4 h-4"})})]}),M&&!U&&s.jsxs("div",{className:"mt-1.5 text-xs text-text-muted px-1",children:[b," ",b===1?"match":"matches"]})]}),U?s.jsxs("div",{className:"text-center py-16 text-text-muted",children:[s.jsx(Xi,{className:"w-10 h-10 mx-auto mb-4 opacity-40"}),s.jsxs("p",{className:"text-lg",children:["No sessions matching ",s.jsxs("span",{className:"text-text-primary font-medium",children:["“",u,"”"]})]}),s.jsx("p",{className:"mt-2 text-sm",children:"Try a different keyword or clear the search"})]}):O.map(F=>{const Q=P(F.id);return s.jsx("div",{className:"mb-6 md:mb-8",children:s.jsxs("div",{className:"bg-bg-secondary border border-border rounded-lg overflow-hidden",children:[s.jsxs("div",{className:"p-3 md:p-4 border-b border-border flex items-center justify-between gap-2",children:[s.jsxs(xr,{href:`/p/${F.id}`,className:"flex items-center gap-2 cursor-pointer hover:opacity-80 transition-opacity flex-1",children:[s.jsx(Qr,{className:"w-5 h-5 text-accent-primary flex-shrink-0"}),s.jsx("span",{className:"text-text-primary font-semibold",children:F.name})]}),s.jsx(xr,{href:`/p/${F.id}/new`,className:"rounded font-medium transition-colors bg-accent-primary/25 text-text-primary hover:bg-accent-primary/40 px-1.5 py-1 text-xs",children:"+ New Session"}),s.jsx("button",{type:"button",onClick:()=>r({id:F.id,name:F.name}),className:"p-1.5 rounded text-text-muted hover:text-accent-error hover:bg-accent-error/10 transition-colors",title:"Delete project",children:s.jsx(Ya,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"divide-y divide-border",children:Q.length>0?Q.map(X=>{const H=m.find($=>X.projectId===$.id),I=H?`/p/${H.id}/s/${X.id}`:"#",D=X.title??X.id.slice(0,8),q=T==null?void 0:T.get(X.id);return s.jsx(xr,{href:I,className:"block p-3 md:p-4 hover:bg-bg-tertiary/50 cursor-pointer transition-colors",children:s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm text-text-muted truncate",children:M&&q==="title"?cy(D,u):D}),M&&q&&q!=="title"&&s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 mt-1",children:[s.jsx("span",{className:"text-[10px] font-medium text-accent-primary border border-accent-primary/30 bg-accent-primary/8 rounded px-1 py-0.5 leading-none",children:q==="prompts"?"prompts":"project"}),q==="prompts"&&(N==null?void 0:N.get(X.id))&&s.jsx("span",{className:"text-[11px] text-text-muted truncate max-w-[250px]",children:cy(N.get(X.id),u)})]})]})}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.jsx("span",{className:"text-text-muted text-xs",children:KF(X.updatedAt)}),s.jsxs("span",{className:"text-text-muted text-xs",children:[X.messageCount," msgs"]})]})]})},X.id)}):s.jsx("div",{className:"p-3 md:p-4 text-text-muted text-sm",children:"No sessions yet"})})]})},F.id)}),!M&&O.length===0&&!g&&s.jsx("div",{className:"text-center py-12 text-text-muted",children:"No projects yet. Open a project to get started."}),g&&s.jsx("div",{className:"flex justify-center py-12",children:s.jsx(Zi,{})})]}),e&&s.jsx(u7,{isOpen:e,onClose:()=>t(!1)}),n&&s.jsx(WN,{isOpen:!0,onClose:()=>r(null),projectName:n.name,onConfirm:()=>_(n.id)})]})}function h7(){const[,e]=ml("/p/:projectId/new"),[,t]=Gn(),n=e==null?void 0:e.projectId,r=De(u=>u.createSession),a=De(u=>u.resetPendingSessionCreate),l=E.useCallback(async()=>{if(!n)return;const u=await r(n);u?(t(`/p/${n}/s/${u.id}`),a()):(t(`/p/${n}`),a())},[n,r,t,a]);return E.useEffect(()=>{l()},[l]),s.jsx("div",{className:"flex-1 flex items-center justify-center",children:s.jsx(Zi,{})})}function f7(){const e=tn(t=>t.currentProject);return s.jsx("div",{className:"h-full flex flex-col items-center justify-center p-8 text-center",children:s.jsxs("div",{className:"max-w-md",children:[s.jsx("h2",{className:"text-xl font-semibold text-text-primary mb-2",children:(e==null?void 0:e.name)??"Project"}),s.jsx("p",{className:"text-text-secondary mb-6",children:"No session selected"}),s.jsxs("div",{className:"flex flex-col gap-3",children:[e&&s.jsx(xr,{href:`/p/${e.id}/new`,"data-testid":"create-new-session-button",className:"block w-full rounded font-medium transition-colors bg-accent-primary/25 text-text-primary hover:bg-accent-primary/40 px-3 py-2 text-center",children:"Create New Session"}),s.jsx("p",{className:"text-sm text-text-muted",children:"Or select an existing session from the sidebar"})]})]})})}const Ec=e=>Math.round(e*10)/10;function m7(e){return typeof e.totalTime=="number"&&!Number.isNaN(e.totalTime)}function uy(e){return{providerId:e.providerId,providerName:e.providerName,backend:e.backend,model:e.model}}function p7(e){return`${e.providerId}::${e.model}`}function g7(e){return`${e.providerName} > ${e.model}`}function jC(e){let t=0,n=0,r=0,a=0,l=0,u=0;const c=[],d=[];let h=0;for(const[g,y]of e.entries()){const w=y.stats,C=uy(w);t+=w.totalTime,n+=w.toolTime,r+=w.prefillTokens,a+=w.generationTokens;const _=w.prefillSpeed>0?w.prefillTokens/w.prefillSpeed:0,S=w.generationSpeed>0?w.generationTokens/w.generationSpeed:0;l+=_,u+=S,c.push({messageId:y.id,timestamp:y.timestamp,...C,mode:w.mode,responseIndex:g+1,prefillTokens:w.prefillTokens,generationTokens:w.generationTokens,prefillSpeed:w.prefillSpeed,generationSpeed:w.generationSpeed,totalTime:w.totalTime,aiTime:w.totalTime-w.toolTime,toolTime:w.toolTime});const b=w.llmCalls??[];for(const v of b)h+=1,d.push({messageId:y.id,timestamp:v.timestamp??y.timestamp,providerId:v.providerId,providerName:v.providerName,backend:v.backend,model:v.model,mode:w.mode,responseIndex:g+1,sessionCallIndex:h,callIndex:v.callIndex,promptTokens:v.promptTokens,completionTokens:v.completionTokens,ttft:v.ttft,completionTime:v.completionTime,prefillSpeed:v.prefillSpeed,generationSpeed:v.generationSpeed,totalTime:v.totalTime,...v.temperature!==void 0&&{temperature:v.temperature},...v.topP!==void 0&&{topP:v.topP},...v.topK!==void 0&&{topK:v.topK},...v.maxTokens!==void 0&&{maxTokens:v.maxTokens}})}const p=l>0?Ec(r/l):0,m=u>0?Ec(a/u):0;return{totalTime:Ec(t),aiTime:Ec(t-n),toolTime:Ec(n),prefillTokens:r,generationTokens:a,avgPrefillSpeed:p,avgGenerationSpeed:m,responseCount:e.length,llmCallCount:d.length,dataPoints:c,callDataPoints:d}}function x7(e){const t=e.filter(a=>a.stats!==void 0&&a.stats!==null&&m7(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=p7(uy(a.stats)),u=n.get(l)??[];n.set(l,[...u,a])}const r=Array.from(n.entries()).map(([a,l])=>{const u=uy(l[0].stats),c=jC(l);return{...u,key:a,label:g7(u),...c}});return{...jC(t),modelGroups:r}}function y7(e){return E.useMemo(()=>x7(e),[e])}function jb(){var a;const e=De(l=>l.gitStatus),t=De(l=>l.currentSession),[n,r]=E.useState(!0);return E.useEffect(()=>{t!=null&&t.workdir&&r(!1)},[t==null?void 0:t.workdir]),{branch:(e==null?void 0:e.branch)??null,diff:{files:((a=e==null?void 0:e.diff)==null?void 0:a.files)??[],loading:n,error:null}}}function dl(e){return e.toLocaleString("en-US").replace(/,/g," ")}function NC(e){return Number.isFinite(e)?e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toFixed(1):"0"}function Es(e){if(!Number.isFinite(e))return"0s";if(e<10)return`${e.toFixed(1)}s`;const t=Math.round(e);if(t<60)return`${t}s`;if(t<3600){const u=Math.floor(t/60),c=t%60;return`${u}m ${c}s`}const n=Math.floor(t/3600),r=t%3600,a=Math.floor(r/60),l=r%60;return`${n}h ${a}m ${l}s`}const TC=Object.assign(Object.create(null),{criteria:"Acceptance Criteria",review_findings:"Review Findings",todos:"Tasks"}),AC=Object.assign(Object.create(null),{criteria:"criteria",review_findings:"review findings",todos:"tasks"});function sl(e){return Object.hasOwn(TC,e)?TC[e]:e.split("_").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function b7(e){return Object.hasOwn(AC,e)?AC[e]:e.replace(/_/g," ")}const LC=["▁","▂","▃","▄","▅","▆","▇","█"];function v7(e,t,n){if(n===t)return 4;const r=(e-t)/(n-t);return Math.min(7,Math.max(0,Math.round(r*7)))}function _7(e,t){if(e===t){const a=Math.max(Math.abs(e)*.05,1);return{minY:e-a,maxY:t+a}}const n=t-e,r=Math.max(n*.1,.1);return{minY:e-r,maxY:t+r}}function S7(e,t){if(e.length===0||t<=0)return{blocks:"",minX:0,maxX:0,minY:0,maxY:0};const n=[...e].sort((g,y)=>g.x-y.x),r=n[0].x,a=n[n.length-1].x,l=Math.min(...n.map(g=>g.y)),u=Math.max(...n.map(g=>g.y)),{minY:c,maxY:d}=_7(l,u),h=Math.max(0,c),p=Array.from({length:t},()=>" "),m=new Map;for(const g of n){const y=a===r?0:Math.round((g.x-r)/(a-r)*(t-1)),w=m.get(y)??[];m.set(y,[...w,g.y])}for(const[g,y]of m){const w=Math.max(...y);p[g]=LC[v7(w,c,d)]??LC[0]}return{blocks:p.join(""),minX:r,maxX:a,minY:h,maxY:d}}function RC(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toFixed(1)}function DC({data:e,width:t=60,height:n=78,label:r,xLabel:a,yLabel:l,showAxes:u=!0,formatY:c=RC,formatX:d=RC}){const h=E.useMemo(()=>{const p=S7(e,t),m=Math.max(t*6,240),g=10,y=8,C=[...e].sort((v,k)=>v.x-k.x).map(v=>{const k=p.maxX===p.minX?m/2:g+(v.x-p.minX)/(p.maxX-p.minX)*(m-g*2),T=p.maxY===p.minY?n/2:y+(p.maxY-v.y)/(p.maxY-p.minY)*(n-y*2);return{...v,cx:k,cy:T,leftPercent:k/m*100,topPercent:T/n*100}}),_=C.map((v,k)=>`${k===0?"M":"L"} ${v.cx.toFixed(1)} ${v.cy.toFixed(1)}`).join(" "),b=[p.maxY,(p.maxY+p.minY)/2,p.minY].map(v=>({value:v,y:p.maxY===p.minY?n/2:y+(p.maxY-v)/(p.maxY-p.minY)*(n-y*2)}));return{...p,chartWidth:m,points:C,path:_,gridLines:b}},[e,n,t]);return e.length===0?s.jsxs("div",{className:"font-mono text-text-muted text-xs",children:[r&&s.jsx("div",{className:"mb-1",children:r}),s.jsx("div",{children:"No data"})]}):s.jsxs("div",{className:"font-mono text-xs",children:[r&&s.jsx("div",{className:"text-text-secondary mb-2",children:r}),s.jsxs("div",{className:"flex gap-3",children:[u&&s.jsx("div",{className:"w-12 h-[78px] flex flex-col justify-between text-right text-text-muted",children:h.gridLines.map(p=>s.jsx("span",{children:c(p.value)},`${p.value}-${p.y}`))}),s.jsx("div",{className:"flex-1 min-w-0",children:s.jsxs("div",{className:"relative h-[78px]",children:[s.jsxs("svg",{viewBox:`0 0 ${h.chartWidth} ${n}`,className:"w-full h-[78px] overflow-visible",preserveAspectRatio:"none","aria-hidden":"true",children:[h.gridLines.map(p=>s.jsx("line",{x1:"0",x2:h.chartWidth,y1:p.y,y2:p.y,stroke:"currentColor",strokeDasharray:"3 4",className:"text-border/60"},`grid-${p.y}`)),h.points.map(p=>s.jsx("line",{x1:p.cx,x2:p.cx,y1:n-4,y2:p.cy,stroke:"currentColor",className:"text-border/40"},`guide-${p.cx}-${p.cy}`)),h.points.length>1&&s.jsx("path",{d:h.path,fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-accent-primary/45"})]}),h.points.map(p=>s.jsx("div",{className:"absolute -translate-x-1/2 -translate-y-1/2",style:{left:`${p.leftPercent}%`,top:`${p.topPercent}%`},title:`${d(p.x)} -> ${c(p.y)}`,children:s.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-accent-primary/20 flex items-center justify-center",children:s.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-accent-primary"})})},`point-${p.x}-${p.y}`))]})})]}),u&&s.jsxs("div",{className:"flex items-start gap-3 text-text-muted mt-1",children:[s.jsx("span",{className:"w-12"}),s.jsxs("span",{className:"flex-1 flex justify-between",children:[s.jsx("span",{children:d(h.minX)}),s.jsx("span",{children:a}),s.jsx("span",{children:d(h.maxX)})]})]}),l&&u&&s.jsx("div",{className:"text-text-muted mt-1 text-center",children:l})]})}function w7({data:e,prefillLabel:t="Prefill Speed (tok/s) by Response",generationLabel:n="Generation Speed (tok/s) by Response",xLabel:r="response",width:a=60}){const l=e.map(c=>({x:c.x,y:c.ppSpeed})),u=e.map(c=>({x:c.x,y:c.tgSpeed}));return s.jsxs("div",{className:"space-y-5",children:[s.jsx(DC,{data:l,width:a,label:t,xLabel:r}),s.jsx(DC,{data:u,width:a,label:n,xLabel:r})]})}function C7(e){const t=new Map;for(const n of e.callDataPoints){const r=t.get(n.messageId)??[];t.set(n.messageId,[...r,n])}return e.dataPoints.map(n=>{const r=[...t.get(n.messageId)??[]].sort((a,l)=>a.callIndex-l.callIndex);return{...n,callCount:r.length,calls:r,isExpandable:r.length>1}})}function k7(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 E7(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 j7(e){return e.callDataPoints.length>0?E7(e):k7(e)}function Ga(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toString()}function Mc(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:e.toFixed(1)}function N7(e){if(e.length===0)return"0 ctx";const t=Math.min(...e),n=Math.max(...e);return t===n?`${Ga(t)} ctx`:`${Ga(t)}-${Ga(n)} ctx`}function Yh(e){return`${Mc(e)} t/s`}function GN(e){try{return new Date(e).toLocaleTimeString("en-US",{hour12:!1})}catch{return e}}function T7(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 A7({isOpen:e,onClose:t,stats:n}){const r=E.useRef(null),[a,l]=E.useState({}),[u,c]=E.useState(()=>{var w;return((w=n.modelGroups[0])==null?void 0:w.key)??""});E.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=E.useMemo(()=>n.modelGroups.find(w=>w.key===u)??n.modelGroups[0],[u,n.modelGroups]),h=E.useMemo(()=>d?C7(d):[],[d]),p=E.useMemo(()=>d?j7(d):{mode:"responses",xLabel:"response",prefillLabel:"",generationLabel:"",points:[]},[d]),m=E.useCallback(w=>{l(C=>({...C,[w]:!C[w]}))},[]),g=E.useCallback(()=>{if(!d)return;const w=T7(d);navigator.clipboard.writeText(JSON.stringify(w,null,2)).catch(C=>console.error("Failed to copy:",C))},[d]),y=E.useCallback(async()=>{if(r.current)try{const w=(await te(async()=>{const{default:S}=await import("./html2canvas.esm-QH1iLAAe.js");return{default:S}},[])).default,C=await w(r.current,{backgroundColor:"#1a1a1a",scale:2}),_=document.createElement("a");_.download=`openfox-stats-${new Date().toISOString().slice(0,10)}.png`,_.href=C.toDataURL("image/png"),_.click()}catch(w){console.error("Failed to export PNG:",w),g()}},[g]);return s.jsx(jt,{isOpen:e,onClose:t,title:"Session Stats",size:"lg",children:s.jsxs("div",{ref:r,className:"space-y-6",children:[s.jsx("section",{children:s.jsx("div",{className:"flex flex-wrap gap-2",children:n.modelGroups.map(w=>s.jsx("button",{onClick:()=>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&&s.jsxs("section",{children:[s.jsx("h3",{className:"text-sm font-semibold text-text-secondary mb-3 uppercase tracking-wide",children:"Summary"}),s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-4",children:[s.jsx(Zs,{label:"AI Time",value:Es(d.aiTime)}),s.jsx(Zs,{label:"Total Time",value:Es(d.totalTime)}),s.jsx(Zs,{label:"Tool Time",value:Es(d.toolTime)}),s.jsx(Zs,{label:"Responses",value:d.responseCount.toString()}),s.jsx(Zs,{label:"LLM Calls",value:d.llmCallCount.toString()})]}),s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mt-3",children:[s.jsx(Zs,{label:"Prefill Tokens",value:Ga(d.prefillTokens),subValue:`@ ${Mc(d.avgPrefillSpeed)} tok/s`}),s.jsx(Zs,{label:"Gen Tokens",value:Ga(d.generationTokens),subValue:`@ ${Mc(d.avgGenerationSpeed)} tok/s`}),s.jsx(Zs,{label:"Avg PP Speed",value:`${Mc(d.avgPrefillSpeed)}`,subValue:"tok/s"}),s.jsx(Zs,{label:"Avg TG Speed",value:`${Mc(d.avgGenerationSpeed)}`,subValue:"tok/s"})]})]}),d&&p.points.length>1&&s.jsxs("section",{children:[s.jsxs("div",{className:"flex items-center justify-between mb-3",children:[s.jsx("h3",{className:"text-sm font-semibold text-text-secondary uppercase tracking-wide",children:"Performance Progression"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:g,className:"px-2 py-1 text-xs text-text-muted hover:text-text-primary hover:bg-bg-tertiary rounded transition-colors",children:"Copy JSON"}),s.jsx("button",{onClick: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"})]})]}),s.jsx("div",{className:"bg-bg-tertiary/50 rounded p-4",children:s.jsx(w7,{data:p.points,width:50,prefillLabel:p.prefillLabel,generationLabel:p.generationLabel,xLabel:p.xLabel})})]}),d&&s.jsxs("section",{children:[s.jsxs("h3",{className:"text-sm font-semibold text-text-secondary mb-3 uppercase tracking-wide",children:["Response Log (",d.responseCount," responses)"]}),s.jsx(ct,{className:"bg-bg-tertiary/30 rounded",children:s.jsxs("table",{className:"w-full table-fixed border-separate border-spacing-0 text-xs",children:[s.jsxs("colgroup",{children:[s.jsx("col",{className:"w-[7%]"}),s.jsx("col",{className:"w-[14%]"}),s.jsx("col",{className:"w-[10%]"}),s.jsx("col",{className:"w-[14%]"}),s.jsx("col",{className:"w-[14%]"}),s.jsx("col",{className:"w-[14%]"}),s.jsx("col",{className:"w-[11%]"}),s.jsx("col",{className:"w-[2%]"})]}),s.jsx("thead",{children:s.jsxs("tr",{className:"text-[10px] uppercase tracking-wide text-text-muted/80",children:[s.jsx("th",{className:"px-3 py-2 text-center font-medium",children:"#"}),s.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"At"}),s.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"Time"}),s.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"Context"}),s.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"PP t/s"}),s.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"TG t/s"}),s.jsx("th",{className:"px-2 py-2 text-center font-medium",children:"Calls"}),s.jsx("th",{className:"px-2 py-2"})]})}),s.jsx("tbody",{children:h.map((w,C)=>s.jsxs(E.Fragment,{children:[s.jsx(L7,{row:w,index:C,isExpanded:a[w.messageId]??!1,onToggle:w.isExpandable?()=>m(w.messageId):void 0}),(a[w.messageId]??!1)&&w.calls.map((_,S)=>s.jsx(R7,{dataPoint:_,index:S},`${_.messageId}-${_.callIndex}`))]},w.messageId))})]})})]})]})})}function Zs({label:e,value:t,subValue:n}){return s.jsxs("div",{className:"bg-bg-tertiary/50 rounded p-3",children:[s.jsx("div",{className:"text-text-muted text-xs mb-1",children:e}),s.jsx("div",{className:"text-text-primary text-lg font-semibold",children:t}),n&&s.jsx("div",{className:"text-text-muted text-xs",children:n})]})}function L7({row:e,index:t,isExpanded:n,onToggle:r}){const a=e.calls.length>0?N7(e.calls.map(l=>l.promptTokens)):`${Ga(e.prefillTokens)} ctx`;return s.jsxs("tr",{onClick:r,className:`${t%2===0?"bg-bg-tertiary/20":""} ${r?"cursor-pointer hover:bg-bg-tertiary/35 transition-colors":""}`,children:[s.jsx("td",{className:"px-3 py-2 text-center text-text-muted align-middle",children:e.responseIndex}),s.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:GN(e.timestamp)}),s.jsx("td",{className:"px-2 py-2 text-center text-text-muted align-middle whitespace-nowrap",children:Es(e.totalTime)}),s.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:a.replace(/ ctx$/,"")}),s.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:Yh(e.prefillSpeed)}),s.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:Yh(e.generationSpeed)}),s.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:e.callCount}),s.jsx("td",{className:"px-2 py-2 text-center text-text-muted align-middle whitespace-nowrap",children:e.isExpandable?n?"v":">":""})]})}function R7({dataPoint:e,index:t}){const n=e.temperature!==void 0||e.topP!==void 0||e.topK!==void 0||e.maxTokens!==void 0;return s.jsxs(s.Fragment,{children:[s.jsxs("tr",{className:`${t%2===0?"bg-bg-tertiary/10":"bg-bg-tertiary/5"}`,children:[s.jsxs("td",{className:"px-3 py-2 pl-6 text-center text-text-muted align-middle border-l border-border/60",children:["c",e.callIndex]}),s.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:GN(e.timestamp)}),s.jsx("td",{className:"px-2 py-2 text-center text-text-muted align-middle whitespace-nowrap",children:Es(e.totalTime)}),s.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:Ga(e.promptTokens)}),s.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:Yh(e.prefillSpeed)}),s.jsx("td",{className:"px-2 py-2 text-center text-text-primary font-mono align-middle whitespace-nowrap",children:Yh(e.generationSpeed)}),s.jsx("td",{className:"px-2 py-2 text-center text-text-muted font-mono align-middle whitespace-nowrap",children:e.callIndex}),s.jsx("td",{className:"px-2 py-2"})]}),n&&s.jsx("tr",{className:`${t%2===0?"bg-bg-tertiary/5":"bg-bg-tertiary/[2.5%]"}`,children:s.jsx("td",{colSpan:8,className:"px-6 py-1.5 border-l border-border/60",children:s.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1 text-[10px] text-text-muted",children:[e.temperature!==void 0&&s.jsxs("span",{children:["temp: ",e.temperature.toFixed(2)]}),e.topP!==void 0&&s.jsxs("span",{children:["topP: ",e.topP.toFixed(2)]}),e.topK!==void 0&&s.jsxs("span",{children:["topK: ",e.topK]}),e.maxTokens!==void 0&&s.jsxs("span",{children:["maxTok: ",e.maxTokens]})]})})})]})}const D7={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"}},qN=["open","in_progress","pending","completed","resolved","dismissed","passed","failed"];function O7(e){return D7[e]??{icon:"○",color:"text-text-muted"}}function Nb(e){const t=document.createElement("textarea");return t.innerHTML=e,t.value}const wl=E.memo(function({status:t,className:n="text-xs leading-tight flex-shrink-0"}){const{icon:r,color:a}=O7(t);return s.jsx("span",{className:`${a} ${n}`,children:r})});function Xh({entries:e,title:t}){const n=E.useMemo(()=>e.reduce((r,a)=>(r[a.status]=(r[a.status]??0)+1,r),{}),[e]);return s.jsxs("h3",{className:"text-sm font-semibold text-text-primary mb-2 flex items-center justify-between",children:[s.jsx("span",{children:t}),Object.keys(n).length>0&&s.jsx("span",{className:"font-normal text-xs flex items-center gap-1.5",children:qN.map(r=>{const a=n[r];return a?s.jsxs("span",{className:"flex items-center gap-0.5",children:[s.jsx(wl,{status:r}),s.jsx("span",{children:a})]},r):null})})]})}const KN=E.memo(function({entries:t,title:n,onClearAll:r}){const[a,l]=E.useState(!1),u=E.useCallback(()=>{l(!1),r==null||r()},[r]);return t.length===0?null:s.jsxs("div",{className:"my-1 rounded border border-border bg-secondary overflow-hidden",children:[n&&s.jsx("div",{className:"px-1.5 py-1 border-b border-border bg-secondary",children:s.jsx("span",{className:"text-xs font-medium text-text-muted",children:n})}),s.jsx("div",{className:"bg-primary",children:t.map((c,d)=>s.jsxs("div",{className:`flex items-start gap-1 px-1.5 py-1 ${d>0?"border-t border-border":""}`,children:[s.jsx(wl,{status:c.status}),s.jsxs("div",{className:"flex-1 min-w-0 text-xs truncate",children:[s.jsxs("span",{className:"text-text-muted",children:["[",c.id,"]"]})," ",Nb(c.description)]})]},c.id??d))}),r&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-1.5 py-1 border-t border-border bg-secondary flex items-center gap-2",children:s.jsxs("button",{onClick:()=>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:[s.jsx(Ya,{className:"w-3 h-3"}),"Clear all"]})}),a&&s.jsx("div",{className:"px-1.5 py-1 border-t border-border bg-secondary",children:s.jsxs("div",{className:"flex items-center gap-2 justify-between",children:[s.jsx("span",{className:"text-xs text-accent-error",children:"Clear all?"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:u,className:"text-xs text-accent-error hover:text-accent-error/70 transition-colors cursor-pointer",children:"Yes"}),s.jsx("button",{onClick:()=>l(!1),className:"text-xs text-text-muted hover:text-text-primary transition-colors cursor-pointer",children:"No"})]})]})})]})]})}),I7={criteria:["pending","completed","passed","failed"],todos:["pending","in_progress","completed"],review_findings:["open","resolved","dismissed"]},M7=["pending","completed","failed","dismissed"];function P7(e){return I7[e]??M7}function B7(e,t){const n=t.indexOf(e);return n===-1?t[0]??"pending":t[(n+1)%t.length]??"pending"}function YN({entries:e,sessionId:t,metadataKey:n,title:r,isOpen:a,onClose:l}){const[u,c]=E.useState(e),[d,h]=E.useState(null),[p,m]=E.useState(""),[g,y]=E.useState(!1),[w,C]=E.useState(""),_=E.useRef(null),S=E.useRef(null),b=E.useCallback(()=>{const z=S.current;z&&(z.style.height="auto",z.style.height=z.scrollHeight+"px")},[]);E.useEffect(()=>{c(e)},[e]),E.useEffect(()=>{var z;d&&(b(),Bt()&&((z=S.current)==null||z.focus()))},[d,b]),E.useEffect(()=>{var z;g&&Bt()&&((z=_.current)==null||z.focus())},[g]);const v=E.useCallback(z=>{c(z),we(`/api/sessions/${t}/metadata/${n}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({entries:z})}).catch(W=>console.error(`Failed to sync ${n}:`,W))},[t,n]),k=E.useCallback(z=>{const W=P7(n),M=u.map(U=>U.id===z?{...U,status:B7(U.status,W)}:U);v(M)},[u,n,v]),T=E.useCallback((z,W)=>{h(z),m(W)},[]),N=E.useCallback((z,W,M)=>{var Q;const U=(W.trim()||((Q=M.find(X=>X.id===z))==null?void 0:Q.description))??"",F=M.map(X=>X.id===z?{...X,description:U}:X);v(F)},[v]),R=E.useCallback(()=>{d&&(N(d,p,u),h(null))},[d,p,u,N]),A=E.useCallback(z=>{z.key==="Enter"&&R(),z.key==="Escape"&&(z.stopPropagation(),h(null))},[R]),O=E.useCallback(z=>{v(u.filter(W=>W.id!==z))},[u,v]),P=E.useCallback(()=>{const z=w.trim();if(!z)return;const W=u.map(U=>Number(U.id)).filter(U=>Number.isInteger(U)&&U>=0),M=String(Math.max(-1,...W)+1);v([...u,{id:M,description:z,status:"pending"}]),C("")},[w,u,v]),V=E.useCallback(z=>{z.key==="Enter"&&(z.preventDefault(),P()),z.key==="Escape"&&(y(!1),C(""))},[P]);return s.jsxs(jt,{isOpen:a,onClose:l,title:r,size:"full",showCloseButton:!0,closeOnEscape:!0,children:[s.jsxs("ul",{className:"space-y-1",children:[u.map((z,W)=>{const M=d===z.id,U=s.jsxs("button",{onClick:()=>T(z.id,z.description),className:"text-sm text-text-primary text-left hover:text-accent-primary transition-colors w-full cursor-pointer",title:"Click to edit",children:[s.jsxs("span",{className:"text-text-muted",children:["[",z.id,"]"]})," ",s.jsx("span",{children:Nb(z.description)})]}),F=M?s.jsx("textarea",{ref:S,value:p,onChange:Q=>{m(Q.target.value),b()},onBlur:R,onKeyDown:A,className:"w-full bg-bg-tertiary text-text-primary text-sm px-2 py-1 rounded border border-border focus:outline-none focus:border-accent-primary resize-none",rows:1}):U;return s.jsxs("li",{className:`flex items-start gap-2 px-2 py-1.5 ${W>0?"border-t border-border":""}`,children:[s.jsx("button",{onClick:()=>k(z.id),className:"flex-shrink-0 cursor-pointer hover:opacity-70 transition-opacity mt-0.5",title:"Click to cycle status",children:s.jsx(wl,{status:z.status})}),s.jsx("div",{className:"flex-1 min-w-0",children:F}),s.jsx("button",{onClick:()=>O(z.id),className:"flex-shrink-0 text-text-muted hover:text-accent-error transition-colors cursor-pointer mt-0.5 ml-auto",title:"Delete entry",children:s.jsx("span",{className:"flex",children:s.jsx(Ji,{className:"w-4 h-4"})})})]},z.id)}),u.length===0&&s.jsx("p",{className:"text-sm text-text-muted italic text-center py-4",children:"No entries yet."})]}),s.jsx("div",{className:"mt-4 pt-3 border-t border-border",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-text-muted text-sm leading-tight",children:"○"}),s.jsx("input",{ref:_,value:w,onChange:z=>C(z.target.value),onKeyDown:V,placeholder:"New entry...",className:"flex-1 bg-bg-tertiary text-text-primary text-sm px-2 py-1 rounded border border-border focus:outline-none focus:border-accent-primary placeholder-text-muted"}),s.jsxs("button",{onClick:P,className:"flex items-center gap-1 text-sm text-accent-primary hover:text-accent-primary/70 transition-colors cursor-pointer",title:"Add entry",children:[s.jsx(Ns,{className:"w-4 h-4"}),"Add"]})]})})]})}const OC=e=>Symbol.iterator in e,IC=e=>"entries"in e,MC=(e,t)=>{const n=e instanceof Map?e:new Map(e.entries()),r=t instanceof Map?t:new Map(t.entries());if(n.size!==r.size)return!1;for(const[a,l]of n)if(!r.has(a)||!Object.is(l,r.get(a)))return!1;return!0},$7=(e,t)=>{const n=e[Symbol.iterator](),r=t[Symbol.iterator]();let a=n.next(),l=r.next();for(;!a.done&&!l.done;){if(!Object.is(a.value,l.value))return!1;a=n.next(),l=r.next()}return!!a.done&&!!l.done};function z7(e,t){return Object.is(e,t)?!0:typeof e!="object"||e===null||typeof t!="object"||t===null||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:OC(e)&&OC(t)?IC(e)&&IC(t)?MC(e,t):$7(e,t):MC({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function H7(e){const t=os.useRef(void 0);return n=>{const r=e(n);return z7(t.current,r)?t.current:t.current=r}}const ka=e=>e?`?workdir=${encodeURIComponent(e)}`:"",ox=e=>e?`&scope=${e}`:"",il=e=>[...e.defaults,...e.userItems,...e.projectItems],Uf=()=>Ft(H7(il)),Ft=Jn((e,t)=>({defaults:[],userItems:[],projectItems:[],activeWorkflowId:"default",loading:!1,templateVariables:[],setWorkdir:n=>e({workdir:n}),fetchTemplateVariables:async()=>{try{const r=await(await we("/api/workflows/template-variables")).json();e({templateVariables:r.variables??[]})}catch{}},fetchWorkflows:async n=>{e({loading:!0});try{const a=await(await we(`/api/workflows${ka(n??t().workdir)}`)).json();e({defaults:a.defaults??[],userItems:a.userItems??[],projectItems:a.projectItems??[],activeWorkflowId:a.activeWorkflowId??"default",loading:!1})}catch{e({loading:!1})}},fetchWorkflow:async(n,r,a)=>{try{const l=await we(`/api/workflows/${n}${ka(r??t().workdir)}${ox(a)}`);return l.ok?await l.json():null}catch{return null}},fetchDefaultContent:async(n,r)=>{try{const a=await we(`/api/workflows/defaults/${n}${ka(r??t().workdir)}`);return a.ok?await a.json():null}catch{return null}},createWorkflow:async(n,r,a)=>{const l=a??t().workdir,u=await Yi("POST",`/api/workflows${ka(l)}`,{...n,destination:r});return u.success&&await t().fetchWorkflows(l),u},updateWorkflow:async(n,r,a,l)=>{const u=a??t().workdir,c=await Yi("PUT",`/api/workflows/${n}${ka(u)}${ox(l)}`,r);return c.success&&await t().fetchWorkflows(u),c},deleteWorkflow:async(n,r,a)=>{try{const l=await we(`/api/workflows/${n}${ka(a??t().workdir)}${ox(r)}`,{method:"DELETE"}),u=await l.json();return l.ok?(e(c=>({...r==="user"?{userItems:c.userItems.filter(d=>d.id!==n)}:{},...r==="project"?{projectItems:c.projectItems.filter(d=>d.id!==n)}:{}})),{success:!0}):{success:!1,error:u.error??"Failed to delete"}}catch{return{success:!1,error:"Network error"}}},duplicateWorkflow:async(n,r,a)=>{const l=a??t().workdir;return pf(`/api/workflows/${n}/duplicate${ka(l)}`,()=>t().fetchWorkflows(l),r)}})),F7={pending:"completed",completed:"passed",passed:"failed",failed:"pending"};async function U7(e,t){await we(`/api/sessions/${e}/criteria`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({criteria:t})})}function th({id:e,agents:t}){const n=ul(t,e),r=t.find(a=>a.id===e);return s.jsx("span",{className:"font-medium rounded px-1",style:{backgroundColor:`${n}20`,color:n},children:(r==null?void 0:r.name)??e})}function V7({id:e}){const t=Ft(u=>u.defaults),n=Ft(u=>u.userItems),a=E.useMemo(()=>[...t,...n],[t,n]).find(u=>u.id===e),l=(a==null?void 0:a.color)??"#3b82f6";return s.jsx("span",{className:"font-medium rounded px-1",style:{backgroundColor:`${l}20`,color:l},children:(a==null?void 0:a.name)??e})}function XN({entries:e,sessionId:t}){const[n,r]=E.useState(e),[a,l]=E.useState(!1),[u,c]=E.useState(null),[d,h]=E.useState(""),[p,m]=E.useState(""),[g,y]=E.useState(!1),[w,C]=E.useState(!1),_=ft(X=>X.defaults),S=ft(X=>X.userItems),b=ft(X=>X.projectItems),v=E.useMemo(()=>[..._,...S,...b],[_,S,b]),k=E.useRef(null),T=E.useRef(null);E.useEffect(()=>{r(e)},[e]),E.useEffect(()=>{var X;a&&Bt()&&((X=k.current)==null||X.focus())},[a]),E.useEffect(()=>{var X;u&&Bt()&&((X=T.current)==null||X.focus())},[u]);const N=E.useCallback(X=>{r(X),U7(t,X)},[t]),R=E.useCallback(X=>{var $;const H=X.map(J=>J.trim()).filter(Boolean);if(H.length===0)return;const I=n.map(J=>Number(J.id)).filter(J=>Number.isInteger(J)&&J>=0),D=Math.max(-1,...I)+1,q=H.map((J,Y)=>({id:String(D+Y),description:J,status:"pending"}));N([...n,...q]),h(""),Bt()&&(($=k.current)==null||$.focus())},[n,N]),A=E.useCallback(()=>{R([d])},[R,d]),O=E.useCallback(X=>{const H=X.clipboardData.getData("text/plain").split(/\r\n|\r|\n/);H.length<2||(X.preventDefault(),R(H))},[R]),P=E.useCallback(()=>{l(!1),h("")},[]),V=E.useCallback((X,H)=>{c(X),m(H)},[]),z=E.useCallback(()=>{if(!u)return;const X=p.trim(),H=n.map(I=>I.id===u?{...I,description:X||I.description}:I);N(H),c(null)},[u,p,n,N]),W=E.useCallback(X=>{const H=n.map(I=>I.id===X?{...I,status:F7[I.status]??"pending"}:I);N(H)},[n,N]),M=E.useCallback(X=>{N(n.filter(H=>H.id!==X))},[n,N]),U=E.useCallback(()=>{N([]),y(!1)},[N]),F=E.useCallback(X=>{X.key==="Enter"&&(X.preventDefault(),A()),X.key==="Escape"&&P()},[A,P]),Q=E.useCallback(X=>{X.key==="Enter"&&z(),X.key==="Escape"&&c(null)},[z]);return s.jsxs("div",{className:"my-1 rounded border border-border bg-secondary overflow-hidden",children:[s.jsxs("div",{className:"bg-primary",children:[n.length===0&&!a&&s.jsxs("div",{className:"px-1.5 py-2 text-xs text-text-muted italic text-center",children:["No criteria yet."," ",s.jsx("button",{onClick:()=>C(!0),className:"text-accent-primary hover:underline not-italic cursor-pointer",children:"Learn more"})]}),n.map((X,H)=>{const I=X.status,D=u===X.id;return s.jsxs("div",{className:`flex items-start gap-1 px-1.5 py-1 group ${H>0?"border-t border-border":""}`,children:[s.jsx("button",{onClick:()=>W(X.id),className:"text-xs leading-tight flex-shrink-0 cursor-pointer hover:opacity-70 transition-opacity",title:`Status: ${X.status} (click to cycle)`,children:s.jsx(wl,{status:I})}),s.jsx("div",{className:"flex-1 min-w-0",children:D?s.jsx("input",{ref:T,value:p,onChange:q=>m(q.target.value),onBlur:z,onKeyDown:Q,className:"w-full bg-bg-tertiary text-text-primary text-xs px-1.5 py-0.5 rounded border border-border focus:outline-none focus:border-accent-primary"}):s.jsxs("button",{onClick:()=>V(X.id,X.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:["[",X.id,"] ",Nb(X.description)]})}),s.jsx("button",{onClick:()=>M(X.id),className:"flex-shrink-0 opacity-0 group-hover:opacity-100 text-text-muted hover:text-accent-error transition-all ml-0.5 cursor-pointer flex items-center self-center",title:"Delete criterion",children:s.jsx(Ji,{className:"w-4 h-4"})})]},X.id)})]}),a&&s.jsx("div",{className:"px-1.5 py-1 border-t border-border bg-secondary",children:s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"text-text-muted text-xs leading-tight flex-shrink-0",children:"○"}),s.jsx("input",{ref:k,value:d,onChange:X=>h(X.target.value),onKeyDown:F,onPaste:O,placeholder:"New criterion...",className:"flex-1 bg-bg-tertiary text-text-primary text-xs px-1.5 py-0.5 rounded border border-border focus:outline-none focus:border-accent-primary placeholder-text-muted"})]})}),s.jsxs("div",{className:"px-1.5 py-1 border-t border-border bg-secondary flex items-center gap-2",children:[a?s.jsxs(s.Fragment,{children:[s.jsxs("button",{onClick:A,className:"flex items-center gap-1 text-xs text-accent-primary hover:text-accent-primary/70 transition-colors cursor-pointer",title:"Add criterion",children:[s.jsx(Ns,{className:"w-3 h-3"}),"Add"]}),s.jsx("button",{onClick:P,className:"flex items-center gap-1 text-xs text-text-muted hover:text-text-primary transition-colors cursor-pointer",title:"Cancel",children:"Cancel"})]}):s.jsxs("button",{onClick:()=>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:[s.jsx(Ns,{className:"w-3 h-3"}),"Add"]}),n.length>0&&(g?s.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[s.jsx("span",{className:"text-xs text-accent-error",children:"Clear all criteria?"}),s.jsx("button",{onClick:U,className:"text-xs text-accent-error hover:text-accent-error/70 transition-colors cursor-pointer",children:"Yes"}),s.jsx("button",{onClick:()=>y(!1),className:"text-xs text-text-muted hover:text-text-primary transition-colors cursor-pointer",children:"No"})]}):s.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:[s.jsx(Ya,{className:"w-3 h-3"}),"Clear all"]})),s.jsx("button",{onClick:()=>C(!0),className:"flex items-center gap-1 text-xs text-text-muted hover:text-accent-primary transition-colors cursor-pointer",title:"About criteria",children:s.jsx(Py,{className:"w-3 h-3"})})]}),s.jsx(jt,{isOpen:w,onClose:()=>C(!1),title:"About Acceptance Criteria",size:"md",children:s.jsxs("div",{className:"space-y-3 text-sm text-text-secondary",children:[s.jsx("p",{children:"Each criterion defines a specific requirement that needs to be met."}),s.jsxs("p",{children:["To use this feature, start in ",s.jsx(th,{id:"planner",agents:v})," mode and",s.jsxs("strong",{className:"text-text-primary",children:[" ","ask the agent to define acceptance criteria that matches your goal"]}),". Then launch the ",s.jsx(V7,{id:"default"})," builtin workflow to launch the automation part."]}),s.jsx("p",{children:"This workflow will automatically:"}),s.jsxs("ol",{className:"list-decimal list-inside space-y-1",children:[s.jsxs("li",{children:["Launch the ",s.jsx(th,{id:"builder",agents:v}),' agent, that will be forced to continue until it marks all criteria as "completed"']}),s.jsxs("li",{children:["Then launch the ",s.jsx(th,{id:"verifier",agents:v})," subagent, that will verify each criterion. If every criterion is fulfilled, then it goes to the next step, otherwise, it gives feedback to the main agent until 100% of the criteria are met."]}),s.jsxs("li",{children:["Launch a ",s.jsx(th,{id:"code_reviewer",agents:v})," subagent, that will analyze the code to provide actionable feedback to the main agent."]})]}),s.jsx("div",{className:"bg-bg-tertiary rounded p-3 space-y-1.5",children:s.jsx("p",{children:"This lets smaller models follow complex plans to completion and improves the chances that nothing from your plan is missed."})})]})})]})}function QN({isOpen:e,onClose:t}){const n=Yn(C=>C.config),r=Yn(C=>C.saveConfig),[a,l]=E.useState(""),[u,c]=E.useState(""),[d,h]=E.useState(!1),[p,m]=E.useState(!1),[g,y]=E.useState(!1);E.useEffect(()=>{e&&(l((n==null?void 0:n.command)??""),c((n==null?void 0:n.url)??""),h((n==null?void 0:n.hotReload)??!1),m((n==null?void 0:n.disableInspect)??!1))},[e,n]);const w=async()=>{!a.trim()||!u.trim()||(y(!0),await r({command:a.trim(),url:u.trim(),hotReload:d,disableInspect:p}),y(!1),t())};return s.jsx(jt,{isOpen:e,onClose:t,title:"Dev Server Config",size:"sm",children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Command"}),s.jsx("input",{className:"input w-full",type:"text",value:a,onChange:C=>l(C.target.value),placeholder:"npm run dev"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Dev URL"}),s.jsx("input",{className:"input w-full",type:"text",value:u,onChange:C=>c(C.target.value),placeholder:"http://localhost:3000"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",id:"hotReload",checked:d,onChange:C=>h(C.target.checked),className:"rounded border-border bg-bg-tertiary"}),s.jsx("label",{htmlFor:"hotReload",className:"text-xs text-text-secondary",children:"Hot Reload"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{type:"checkbox",id:"disableInspect",checked:p,onChange:C=>m(C.target.checked),className:"rounded border-border bg-bg-tertiary"}),s.jsx("label",{htmlFor:"disableInspect",className:"text-xs text-text-secondary",children:"Disable inspect feedback"})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[s.jsx("button",{className:"btn btn-secondary",onClick:t,children:"Cancel"}),s.jsx("button",{className:"btn btn-primary",onClick:w,disabled:g||!a.trim()||!u.trim(),children:g?"Saving...":"Save"})]})]})})}const PC={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"},W7={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"},BC={1:"font-bold",2:"opacity-75",4:"underline",7:"bg-bg-secondary"},G7="text-text-primary";function q7(e){const t=[],n=new RegExp("\x1B\\[([0-9;]+)m","g");let r=0,a="text-text-primary",l;try{for(;(l=n.exec(e))!==null;){if(l.index>r){const h=e.slice(r,l.index);h&&t.push({text:h,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 h of c)if(h>=30&&h<=37){const p=PC[h];p&&d.push(p)}else if(h>=40&&h<=47){const p=W7[h];p&&d.push(p)}else if(h>=90&&h<=97){const p=PC[h];p&&d.push(p)}else if(h in BC){const p=BC[h];p&&d.push(p)}else h===39?d.push(G7):h===49&&(a=a.split(" ").filter(p=>!p.startsWith("bg-")).join(" "));d.length>0&&(a=d.join(" ")),r=n.lastIndex}if(r<e.length){const u=e.slice(r);u&&t.push({text:u,className:a})}return t}catch(u){return console.warn("ANSI parsing failed, stripping codes:",u),[{text:K7(e),className:"text-text-primary"}]}}function K7(e){return e.replace(new RegExp("\x1B\\[([0-9;]+)m","g"),"")}function Qh(e){const t=q7(e),n=[];return t.forEach((r,a)=>{const l=r.text.split(`
283
+ `);l.forEach((u,c)=>{n.push(os.createElement("span",{key:`${a}-${c}`,className:r.className,style:{display:"inline-block",whiteSpace:"pre-wrap"}},u)),c<l.length-1&&n.push(os.createElement("br",{key:`${a}-${c}-br`}))})}),n.length===1?n[0]:n}function JN({logs:e,preRef:t,preClassName:n="text-sm font-mono",scrollAreaRef:r,onScrollbarGesture:a}){return s.jsx(ct,{ref:r,options:{overflow:{x:"scroll",y:"scroll"}},className:n,onScrollbarGesture:a,children:s.jsx("pre",{ref:t,className:"contents",children:e.length===0?s.jsx("span",{className:"text-text-muted",children:"No output yet"}):e.map((l,u)=>l.type==="marker"?s.jsx(E.Fragment,{children:s.jsx("hr",{className:"border-t border-border my-1"})},u):s.jsx("span",{className:l.stream==="stderr"?"text-accent-warning":"",children:Qh(l.content)},u))})})}function Tb({isActive:e,onToggle:t,className:n,style:r}){return s.jsxs("button",{type:"button",onClick:()=>t(!e),className:n,style:r,children:[e?s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-accent-success"}):s.jsx(vn,{className:"w-3 h-3"}),e?"live":"scroll to bottom"]})}const Y7=2,X7=100,Q7=6,J7=1500,ZN=(e,t)=>e==="down"?!1:t!==null&&t<=Q7,_u=(e,t,n)=>{const r=E.useRef(!0),a=E.useRef(null),l=E.useRef(!1),u=E.useRef(0),c=E.useRef(!1),[d,h]=E.useState(!0),p=E.useCallback(()=>{if(n)return n();const b=e.current;return b instanceof HTMLElement?b:null},[n,e]),m=E.useCallback(b=>{r.current=b,h(b)},[]),g=E.useCallback(()=>{m(!1)},[m]),y=E.useCallback(()=>{if(!r.current)return;const b=p();b&&(c.current=!0,b.scrollTop=b.scrollHeight,requestAnimationFrame(()=>{requestAnimationFrame(()=>{c.current=!1})}),u.current=Date.now())},[p]),w=E.useCallback((b,v)=>{b==="down"&&(l.current=!0);const k=ZN(b,v);m(k),k&&(u.current=Date.now()),b==="up"&&(l.current=!1)},[m]),C=E.useRef(null);E.useEffect(()=>{if(t!=null&&t.id)return C.current!==null&&(cancelAnimationFrame(C.current),C.current=null),m(!0),u.current=Date.now(),C.current=requestAnimationFrame(()=>{requestAnimationFrame(()=>{y(),C.current=null})}),()=>{C.current!==null&&(cancelAnimationFrame(C.current),C.current=null)}},[t==null?void 0:t.id,m,y]),E.useEffect(()=>{const b=p();if(!b)return;const v=()=>{b.scrollHeight-b.scrollTop-b.offsetHeight<X7&&(u.current=Date.now(),m(!0))},k=V=>{if(V.deltaY>0){requestAnimationFrame(()=>requestAnimationFrame(v));return}g()},T=V=>{V.touches[0]&&(a.current=V.touches[0].clientY)},N=V=>{if(a.current===null)return;const z=V.touches[0];if(!z)return;if(z.clientY-a.current>0){g();return}requestAnimationFrame(()=>requestAnimationFrame(v))},R=()=>{if(l.current||c.current)return;if(b.scrollHeight-b.scrollTop-b.offsetHeight<Y7){u.current=Date.now(),m(!0);return}Date.now()-u.current<=J7||m(!1)},A=V=>{if(!(V.ctrlKey||V.metaKey||V.altKey)){if(V.key==="ArrowUp"||V.key==="PageUp"||V.key==="Home"){g();return}(V.key==="ArrowDown"||V.key==="PageDown"||V.key==="End")&&requestAnimationFrame(()=>requestAnimationFrame(v))}},O=new MutationObserver(()=>{r.current&&requestAnimationFrame(y)}),P=setInterval(()=>{r.current&&y()},1e3);return b.addEventListener("wheel",k,{passive:!0}),b.addEventListener("touchstart",T,{passive:!0}),b.addEventListener("touchmove",N,{passive:!0}),b.addEventListener("scroll",R,{passive:!0}),b.addEventListener("keydown",A),b.tabIndex=-1,O.observe(b,{childList:!0,subtree:!0,characterData:!0}),()=>{b.removeEventListener("wheel",k),b.removeEventListener("touchstart",T),b.removeEventListener("touchmove",N),b.removeEventListener("scroll",R),b.removeEventListener("keydown",A),O.disconnect(),clearInterval(P)}},[t==null?void 0:t.id,p,y,m,g]);const _=E.useCallback(()=>{m(!0),y()},[m,y]),S=E.useCallback(b=>{m(b),b&&y()},[m,y]);return{force_scroll_to_bottom:_,isAutoScrollActive:d,setAutoScroll:S,handleScrollbarGesture:w}},Su=e=>E.useCallback(()=>{var t,n;return((n=(t=e.current)==null?void 0:t.osInstance())==null?void 0:n.elements().viewport)??null},[e]),Ab=E.memo(function({title:t,subtitle:n,logs:r,onClose:a,onClear:l,onInsertMarker:u,preClassName:c}){const d=E.useRef(null),h=Su(d),{isAutoScrollActive:p,setAutoScroll:m,handleScrollbarGesture:g}=_u(d,null,h);return s.jsxs(jt,{isOpen:!0,onClose:a,title:t,size:"full",scrollable:!1,headerRight:s.jsx(Tb,{isActive:p,onToggle:m,className:"text-xs text-text-muted hover:text-text-primary flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors"}),footer:s.jsxs("div",{className:"flex items-center gap-2",children:[u&&s.jsxs("button",{onClick:u,className:"text-xs text-text-muted hover:text-text-primary flex items-center gap-1 px-2 py-1 rounded hover:bg-bg-tertiary transition-colors",title:"Insert marker",children:[s.jsx(Ns,{className:"w-3.5 h-3.5"}),"Marker"]}),l&&s.jsxs("button",{onClick:l,className:"text-xs text-text-muted hover:text-accent-error flex items-center gap-1 px-2 py-1 rounded hover:bg-bg-tertiary transition-colors",title:"Clear logs",children:[s.jsx(Ya,{className:"w-3.5 h-3.5"}),"Clear"]})]}),children:[n&&s.jsxs("div",{className:"subtitle-strip flex items-start gap-2 px-2 py-1.5 mb-2 bg-bg-tertiary rounded text-[11px] font-mono text-text-secondary whitespace-pre-wrap break-all border border-border",children:[s.jsx("span",{className:"text-text-muted flex-shrink-0 select-none",children:"Command:"}),s.jsx("span",{children:n})]}),s.jsx(ct,{ref:d,className:"flex-1 -m-4 p-4",onScrollbarGesture:g,children:s.jsx(JN,{logs:r,preClassName:c})})]})}),Z7=E.memo(function({logs:t,anchorRef:n,isHiding:r,isAutoScrollActive:a,onSetAutoScroll:l}){const[u,c]=E.useState(null),d=E.useRef(null),h=E.useRef(l);h.current=l;const p=E.useCallback((g,y)=>{l(ZN(g,y))},[l]),m=E.useCallback(()=>{var g,y;return((y=(g=d.current)==null?void 0:g.osInstance())==null?void 0:y.elements().viewport)??null},[]);return E.useEffect(()=>{var y;const g=(y=n.current)==null?void 0:y.getBoundingClientRect();g&&c({bottom:window.innerHeight-g.bottom,right:window.innerWidth-g.right,width:g.width,height:g.height})},[n]),E.useEffect(()=>{const g=m();if(!g)return;const y=w=>{if(w.deltaY<0){h.current(!1);return}w.deltaY>0&&requestAnimationFrame(()=>requestAnimationFrame(()=>{g.scrollHeight-g.scrollTop-g.offsetHeight<100&&h.current(!0)}))};return g.addEventListener("wheel",y,{passive:!0}),()=>g.removeEventListener("wheel",y)},[m]),E.useEffect(()=>{const g=m();g&&a&&(g.scrollTop=g.scrollHeight)},[t,a,u,m]),s.jsx("div",{className:`relative ${u?"":"hidden"}`,children:s.jsx(ct,{ref:d,className:"fixed z-40 text-sm font-mono text-text-primary bg-bg-primary p-2 rounded border border-border transition-all duration-150 ease-out select-text",onScrollbarGesture:p,style:u?{bottom:u.bottom,right:u.right,width:u.width*2,maxHeight:u.height*3,transformOrigin:"bottom right",transform:r?"scale(0.01)":"scale(1)",opacity:r?0:1}:void 0,children:s.jsx("pre",{className:"text-sm font-mono",children:t.map((g,y)=>s.jsx("span",{className:g.stream==="stderr"?"text-accent-warning":"",children:Qh(g.content)},y))})})})}),eT=E.memo(function({workdir:t,compact:n,onExpand:r,onConfigure:a}){const l=Yn(D=>D.setWorkdir),u=Yn(D=>D.status),c=Yn(D=>D.config),d=Yn(D=>D.logs),h=Yn(D=>D.start),p=Yn(D=>D.stop),m=Yn(D=>D.fetchLogs),g=Yn(D=>D.clearLogs),y=Yn(D=>D.insertMarker),w=()=>{window.confirm("Clear all dev server logs?")&&g()},[C,_]=E.useState(!1),[S,b]=E.useState(!1),[v,k]=E.useState(!1),[T,N]=E.useState(!1),R=E.useRef(null),A=E.useRef(null),O=E.useCallback(()=>{var D,q;return((q=(D=A.current)==null?void 0:D.osInstance())==null?void 0:q.elements().viewport)??null},[]),{isAutoScrollActive:P,setAutoScroll:V,handleScrollbarGesture:z}=_u(A,null,O),W=E.useRef(null),M=E.useRef(null),U=E.useRef(null),F=()=>{const D=u==null?void 0:u.inspectProxyPort;if(!D){u!=null&&u.url&&window.open(u.url,"_blank");return}const q=`${window.location.protocol}//${window.location.hostname}:${D}`;window.open(q,"_blank")},Q=(u==null?void 0:u.state)??"off",X=c!==null,H=Q==="running"||Q==="warning";E.useEffect(()=>{l(t??null)},[t,l]),E.useEffect(()=>{H&&m()},[H,m]);const I=()=>{H?p():h()};return s.jsxs("div",{className:`space-y-3 ${n?"":"mt-2 pt-3 border-t border-border"}`,children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`inline-block w-2.5 h-2.5 rounded-full flex-shrink-0 ${Q==="running"?"bg-accent-success":Q==="warning"?"bg-accent-warning":Q==="error"?"bg-accent-error":"bg-text-muted"}`}),s.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:"Dev Server"})]}),s.jsx("button",{onClick:()=>{a?a():_(!0)},className:"p-1.5 rounded hover:bg-bg-tertiary transition-colors text-text-muted",title:"Configure dev server",children:s.jsx(O3,{})})]}),X?s.jsx(s.Fragment,{children:Q==="running"||Q==="warning"?s.jsxs("div",{className:"flex gap-2",children:[s.jsxs("button",{onClick:I,className:"flex-1 flex items-center justify-center gap-1.5 rounded font-medium text-sm px-3 py-1.5 bg-bg-tertiary text-text-primary hover:bg-border transition-colors",children:[s.jsx(By,{}),"Stop"]}),(u==null?void 0:u.url)&&s.jsxs("button",{onClick:()=>F(),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:u.url,children:[s.jsx(NE,{}),"Open"]})]}):s.jsx("button",{onClick:I,className:"w-full rounded font-medium text-sm px-3 py-1.5 bg-accent-primary/25 text-text-primary hover:bg-accent-primary/40 transition-colors",children:"Start"})}):s.jsx("button",{onClick:()=>{a?a():_(!0)},className:"w-full rounded font-medium text-sm px-3 py-1.5 bg-bg-tertiary text-text-muted hover:bg-border transition-colors",children:"Configure"}),s.jsxs("div",{ref:U,className:`relative ${X&&H?"":"hidden"}`,onMouseEnter:()=>{!X||!H||n||(M.current&&clearTimeout(M.current),W.current=setTimeout(()=>{k(!0),N(!1)},500))},onMouseLeave:()=>{W.current&&clearTimeout(W.current),N(!0),M.current=setTimeout(()=>k(!1),150)},children:[s.jsx(JN,{logs:d,preRef:R,preClassName:"text-sm bg-bg-primary p-2 rounded max-h-[200px] border border-border",scrollAreaRef:A,onScrollbarGesture:z}),X&&H&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"absolute bottom-1 right-1 z-50 flex items-center gap-1",children:[!n&&(v||T)&&s.jsx(Tb,{isActive:P,onToggle:V,className:"text-xs text-text-muted hover:text-text-primary flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors"}),s.jsx("button",{onClick:()=>n?r==null?void 0:r():b(!0),className:"px-2 py-0.5 rounded text-xs font-medium bg-accent-primary/30 text-text-primary hover:bg-accent-primary/50 transition-colors",children:"Expand"})]}),!n&&(v||T)&&U.current&&ui.createPortal(s.jsx(Z7,{logs:d,anchorRef:U,isHiding:T,isAutoScrollActive:P,onSetAutoScroll:V}),document.body)]})]}),!a&&s.jsx(QN,{isOpen:C,onClose:()=>_(!1)}),S&&s.jsx(Ab,{title:"Dev Server Logs",logs:d,onClose:()=>b(!1),onClear:w,onInsertMarker:y})]})}),e9=E.memo(function({sessionId:t}){const n=Pc(y=>y.processes),r=Pc(y=>y.stopProcess),[a,l]=E.useState(null),[u,c]=E.useState([]),d=n.filter(y=>y.status!=="exited"),h=d.filter(y=>y.status==="running").length;if(n.length===0)return null;const p=y=>{switch(y){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=y=>{const w=Pc.getState().logs[y]??[];c(w.map(C=>({content:C.content,stream:C.stream}))),l(y)},g=y=>{t&&r(y,t)};return s.jsxs("div",{className:"mt-2 pt-3 border-t border-border space-y-3",children:[s.jsx("div",{className:"flex items-center justify-between",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"inline-block w-2.5 h-2.5 rounded-full flex-shrink-0 bg-accent-primary"}),s.jsx("h3",{className:"text-sm font-semibold text-text-primary",children:"Background"}),s.jsxs("span",{className:"text-xs text-text-muted",children:["(",h," running)"]})]})}),s.jsx("div",{className:"space-y-2",children:d.map(y=>s.jsx("div",{className:"border border-border rounded p-2",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[s.jsx("span",{className:`inline-block w-2 h-2 rounded-full flex-shrink-0 ${p(y.status)}`}),s.jsx("span",{className:"text-sm text-text-primary truncate",title:y.name,children:y.name}),s.jsxs("span",{className:"text-xs text-text-muted",children:["[",y.status,"]"]})]}),s.jsxs("div",{className:"flex gap-1 ml-2",children:[s.jsx("button",{onClick:()=>m(y.id),className:"px-2 py-1 text-xs rounded bg-bg-tertiary hover:bg-border text-text-secondary transition-colors",title:"View logs",children:"Logs"}),s.jsx("button",{onClick:()=>g(y.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"})]})]})},y.id))}),a&&(()=>{const y=d.find(w=>w.id===a);return s.jsx(Ab,{title:(y==null?void 0:y.name)??"",subtitle:y==null?void 0:y.command,logs:u,onClose:()=>{l(null),c([])}})})()]})});function tT(){return Zt.getState().platform??null}function nT(e){const t=e.replace(/\\/g,"/");return encodeURI(t).replace(/#/g,"%23").replace(/\?/g,"%3F")}function rT(e,t,n){const r=tT(),a=e.startsWith("/")||e.match(/^[a-zA-Z]:[/\\]/)?e:n?`${n.replace(/\\/g,"/").replace(/\/$/,"")}/${e}`:e,l=nT(a);if(r!=null&&r.isWSL&&r.wslDistro)return`${`vscode://vscode-remote/wsl+${r.wslDistro}${l}`}:${t??1}`;const u=`vscode://file/${l}`;return t?`${u}:${t}`:u}function t9(e){const t=tT(),n=nT(e.replace(/\\/g,"/"));return t!=null&&t.isWSL&&t.wslDistro?`vscode://vscode-remote/wsl+${t.wslDistro}${n}`:`vscode://file/${n}`}function n9({file:e,showEditorLink:t,workdir:n}){const r=$E(e.path,28),a=e.status==="added"?"text-accent-success":e.status==="deleted"?"text-accent-error":"text-accent-primary",l=e.status==="added"?`+${e.additions}`:e.status==="deleted"?`-${e.deletions}`:e.additions>0||e.deletions>0?`+${e.additions}, -${e.deletions}`:"",u=t&&n?rT(e.path,void 0,n):void 0,c=s.jsxs(s.Fragment,{children:[s.jsx("span",{className:`truncate ${a}`,title:e.path,children:r}),l&&s.jsx("span",{className:`shrink-0 font-mono${e.status==="added"?" text-accent-success":e.status==="deleted"?" text-accent-error":" text-text-muted"}`,children:l})]});return u?s.jsx("a",{href:u,className:"flex items-center justify-between gap-1 py-0.5 text-xs min-w-0 hover:bg-bg-tertiary rounded px-1 transition-colors no-underline",title:`Open ${e.path} in VSCode`,children:c}):s.jsx("div",{className:"flex items-center justify-between gap-1 py-0.5 text-xs min-w-0",children:c})}function r9(){const{diff:e}=jb(),t=Lt(a=>a.settings[je.DISPLAY_SHOW_OPEN_IN_EDITOR])==="true",n=De(a=>a.currentSession),r=(n==null?void 0:n.workspace)??(n==null?void 0:n.workdir);return e.loading?s.jsx("div",{className:"mt-3",children:s.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-text-muted",children:[s.jsx("span",{className:"w-3 h-3 border border-border border-t-accent-primary rounded-full animate-spin"}),s.jsx("span",{children:"Checking changes..."})]})}):e.files.length===0?s.jsx("div",{className:"mt-3",children:s.jsx("p",{className:"text-xs text-text-muted text-center",children:"No changes"})}):s.jsx(ct,{className:"mt-3 max-h-[150px]",children:s.jsx("div",{className:"pr-1",children:e.files.map((a,l)=>s.jsx(n9,{file:a,showEditorLink:t,workdir:r},l))})})}function sT(e){const[t,n]=E.useState(!1),[r,a]=E.useState(null),[l,u]=E.useState(!1),[c,d]=E.useState(""),h=E.useCallback(()=>{t||e()},[t,e]),p=c.trim().length>0&&!t,m=E.useCallback(()=>{a(null),n(!1),d(""),u(!0)},[]);return{busy:t,setBusy:n,error:r,setError:a,loading:l,setLoading:u,newName:c,setNewName:d,handleClose:h,canCreate:p,resetState:m}}function iT({isOpen:e,onClose:t,title:n,busy:r,loading:a,children:l}){const u=s.jsx("div",{className:"flex gap-2 justify-end",children:s.jsx("button",{onClick:t,className:"px-4 py-2 text-sm rounded bg-bg-tertiary text-text-secondary hover:bg-bg-secondary transition-colors",children:"Cancel"})});return s.jsx(jt,{isOpen:e,onClose:t,title:n,size:"md",footer:u,children:a||r?s.jsx("div",{className:"flex items-center justify-center py-8",children:s.jsx(Zi,{})}):l})}function aT({icon:e,title:t,placeholder:n,buttonLabel:r,value:a,onChange:l,onCreate:u,canCreate:c,busy:d}){return s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-text-primary mb-2",children:t}),s.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded border border-border bg-bg-primary focus-within:border-accent-primary mb-3",children:[s.jsx("span",{className:"w-4 h-4 shrink-0 text-text-muted flex items-center",children:e}),s.jsx("input",{type:"text",value:a,onChange:h=>l(h.target.value),onKeyDown:h=>{h.key==="Enter"&&c&&u()},placeholder:n,className:"flex-1 bg-transparent text-sm text-text-primary outline-none font-mono placeholder-text-muted"})]}),s.jsx("button",{onClick:u,disabled:!c||d,className:"w-full px-4 py-2 text-sm rounded bg-accent-primary text-white hover:opacity-90 transition-colors disabled:opacity-50",children:r})]})}function oT({isOpen:e,onClose:t,projectId:n,sessionId:r,currentWorkspace:a,currentBranch:l}){const u=De(W=>W.loadSession),{busy:c,setBusy:d,error:h,setError:p,loading:m,setLoading:g,newName:y,setNewName:w,handleClose:C,canCreate:_,resetState:S}=sT(t),[b,v]=E.useState([]),[k,T]=E.useState(null),[N,R]=E.useState(null),[A,O]=E.useState(!1);E.useEffect(()=>{e&&(S(),T(null),R(null),O(!1),we(`/api/projects/${n}/workspaces`).then(W=>W.json()).then(W=>{v(W.workspaces),g(!1)}).catch(()=>{v([]),g(!1)}))},[e,n,S,g]);const P=E.useCallback(async W=>{p(null),d(!0);try{const M=await we(`/api/sessions/${r}/switch-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({target:W})});if(!M.ok){const U=await M.json().catch(()=>({error:"Failed to switch workspace"}));p(U.error),d(!1);return}await u(r,!0),t()}catch(M){p(M instanceof Error?M.message:"Failed to switch workspace"),d(!1)}},[r,u,t,p,d]),V=E.useCallback(async(W,M)=>{p(null),R(null),O((M==null?void 0:M.force)===!0),d(!0);try{const U=await we(`/api/sessions/${r}/delete-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({target:W,force:(M==null?void 0:M.force)===!0})});if(!U.ok){const X=await U.json().catch(()=>({error:"Failed to delete workspace"}));p(X.error),X.conflictingSessionIds&&R(X.conflictingSessionIds),O(!1),d(!1);return}T(null),O(!1),await u(r,!0);const Q=await(await we(`/api/projects/${n}/workspaces`)).json();v(Q.workspaces),d(!1),g(!1)}catch(U){p(U instanceof Error?U.message:"Failed to delete workspace"),O(!1),d(!1)}},[r,n,u,p,d]),z=E.useCallback(async()=>{p(null),d(!0);try{const W=await we(`/api/sessions/${r}/switch-workspace`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({target:y.trim()})});if(!W.ok){const M=await W.json().catch(()=>({error:"Failed to create workspace"}));p(M.error),d(!1);return}await u(r),t()}catch(W){p(W instanceof Error?W.message:"Failed to create workspace"),d(!1)}},[y,r,u,t,p,d]);return s.jsx(iT,{isOpen:e,onClose:C,title:"Switch Workspace",busy:c,loading:m,children:s.jsxs("div",{children:[s.jsx("p",{className:"text-sm font-medium text-text-primary mb-2",children:"Workspaces"}),s.jsxs(ct,{className:"max-h-48 space-y-0.5 bg-bg-tertiary/30 rounded p-2 mb-4",children:[s.jsxs("button",{onClick:()=>P("original"),disabled:c,className:`w-full text-left px-3 py-1.5 text-sm rounded transition-colors flex items-center gap-2 ${a?"hover:bg-bg-tertiary text-text-secondary":"bg-accent-primary/10 text-accent-primary cursor-default"}`,children:[s.jsx(Qr,{className:"w-4 h-4 shrink-0"}),s.jsx("span",{className:"font-mono truncate",children:"original"}),s.jsx("span",{className:"text-xs text-text-muted ml-auto",children:l??"unknown"}),!a&&s.jsx("span",{className:"text-[10px] text-accent-primary ml-1",children:"(current)"})]}),b.slice().sort((W,M)=>W.name===a?-1:M.name===a?1:W.name.localeCompare(M.name)).map(W=>s.jsx("div",{className:"group relative",children:k===W.name?s.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 text-sm rounded bg-accent-error/10",children:[s.jsxs("span",{className:"text-xs text-accent-error",children:["Delete ",W.name,"?"]}),s.jsx("button",{onClick:()=>V(W.name),disabled:c,className:"ml-auto text-xs px-2 py-0.5 rounded bg-accent-error text-white hover:opacity-90",children:"Confirm"}),s.jsx("button",{onClick:()=>T(null),disabled:c,className:"text-xs px-2 py-0.5 rounded bg-bg-tertiary text-text-secondary hover:bg-bg-secondary",children:"Cancel"})]}):s.jsxs("div",{className:"relative",children:[s.jsxs("button",{onClick:()=>{!c&&W.name!==a&&P(W.name)},disabled:c||W.name===a,className:`w-full text-left px-3 py-1.5 text-sm rounded transition-colors flex items-center gap-2 ${W.name===a?"bg-accent-primary/10 text-accent-primary cursor-default":"hover:bg-bg-tertiary text-text-secondary"} ${c?"opacity-70":""}`,children:[s.jsx(Qr,{className:"w-4 h-4 shrink-0"}),s.jsx("span",{className:"font-mono truncate",children:W.name}),s.jsx("span",{className:"text-xs text-text-muted ml-auto",children:W.branch??"unknown"}),W.name===a&&s.jsx("span",{className:"text-[10px] text-accent-primary ml-1",children:"(current)"})]}),W.name!==a&&!c&&s.jsx("button",{onClick:M=>{M.stopPropagation(),p(null),R(null),T(W.name)},className:"absolute right-1 top-1/2 -translate-y-1/2 opacity-0 group-hover:opacity-100 text-xs text-text-muted hover:text-accent-error transition-opacity px-1 py-0.5 rounded",title:"Delete workspace",children:"✕"})]})},W.path))]}),s.jsx(aT,{icon:s.jsx(Qr,{}),title:"Create new workspace",placeholder:"workspace name",buttonLabel:"Create Workspace",value:y,onChange:w,onCreate:z,canCreate:_,busy:c}),h&&s.jsxs("div",{className:"mt-3 text-sm bg-accent-error/10 p-2 rounded",role:"alert",children:[s.jsx("p",{className:"text-accent-error",children:h}),N&&N.length>0&&s.jsxs("div",{className:"mt-2 space-y-1",children:[s.jsx("p",{className:"text-xs text-text-muted",children:"Conflicting sessions:"}),s.jsx("ul",{className:"space-y-0.5",children:N.map(W=>s.jsx("li",{children:s.jsx(xr,{href:`/p/${n}/s/${W}`,className:"text-xs font-mono text-accent-primary hover:underline break-all",children:W})},W))}),s.jsx("button",{onClick:()=>V(k??"",{force:!0}),disabled:c||!k,className:"mt-2 text-xs px-2 py-1 rounded bg-accent-warning text-black hover:opacity-90 disabled:opacity-50","aria-label":"Force delete workspace, switching other sessions to original",children:A?"Processing...":"Force Delete (switch other sessions to original)"})]})]})]})})}function lT({isOpen:e,onClose:t,sessionId:n}){const r=De(R=>R.loadSession),{busy:a,setBusy:l,error:u,setError:c,loading:d,setLoading:h,newName:p,setNewName:m,handleClose:g,canCreate:y,resetState:w}=sT(t),[C,_]=E.useState([]),[S,b]=E.useState(""),[v,k]=E.useState("");E.useEffect(()=>{e&&(w(),b(""),_([]),k(""),we(`/api/sessions/${n}/branches`).then(R=>R.json()).then(R=>{_(R.branches),k(R.defaultBranch??""),h(!1)}).catch(()=>{_([]),h(!1)}))},[e,n,w,h]);const T=E.useCallback(async R=>{c(null),l(!0);try{const A=await we(`/api/sessions/${n}/checkout`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({branch:R})});if(!A.ok){const O=await A.json().catch(()=>({error:"Failed to switch branch"}));c(O.error),l(!1);return}await r(n,!0),t()}catch(A){c(A instanceof Error?A.message:"Failed to switch branch"),l(!1)}},[n,r,t,c,l]),N=E.useCallback(async()=>{c(null),l(!0);try{const R={name:p.trim()};S&&(R.sourceBranch=S);const A=await we(`/api/sessions/${n}/checkout-new`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(R)});if(!A.ok){const O=await A.json().catch(()=>({error:"Failed to create branch"}));c(O.error),l(!1);return}await r(n),t()}catch(R){c(R instanceof Error?R.message:"Failed to create branch"),l(!1)}},[p,S,n,r,t,c,l]);return s.jsx(iT,{isOpen:e,onClose:g,title:"Switch Branch",busy:a,loading:d,children:s.jsxs("div",{children:[C.length>0&&s.jsxs("div",{className:"mb-4",children:[s.jsx("p",{className:"text-sm font-medium text-text-primary mb-2",children:"Branches"}),s.jsx(ct,{className:"max-h-48 space-y-0.5 bg-bg-tertiary/30 rounded p-2",children:C.map(R=>s.jsxs("button",{onClick:()=>{R.current||T(R.name)},disabled:a,className:`w-full text-left px-3 py-1.5 text-sm rounded transition-colors flex items-center gap-2 ${R.current?"bg-accent-primary/10 text-accent-primary cursor-default":"hover:bg-bg-tertiary text-text-secondary"}`,children:[s.jsx(Fa,{className:"w-3.5 h-3.5 shrink-0"}),s.jsx("span",{className:"font-mono truncate",children:R.name}),R.current&&s.jsx("span",{className:"ml-auto text-xs text-text-muted",children:"(current)"}),!R.current&&s.jsx("span",{className:"ml-auto text-xs text-accent-primary",children:"Switch"})]},R.name))})]}),s.jsx(aT,{icon:s.jsx(Fa,{}),title:"Create new branch",placeholder:"feature/my-branch",buttonLabel:"Create Branch",value:p,onChange:m,onCreate:N,canCreate:y,busy:a}),p.trim()&&s.jsxs("div",{className:"mt-2",children:[s.jsxs("label",{className:"text-xs text-text-muted mb-1 block",children:["From branch (optional — defaults to ",v||"project default",")"]}),s.jsxs("div",{className:"relative",children:[s.jsx(Fa,{className:"absolute left-2 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-text-muted pointer-events-none"}),s.jsx("input",{type:"text",value:S,onChange:R=>b(R.target.value),placeholder:v||"main",className:"w-full text-sm bg-bg-primary border border-border-default rounded pl-8 pr-2 py-1.5 text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"})]})]}),u&&s.jsx("p",{className:"mt-3 text-sm text-accent-error bg-accent-error/10 p-2 rounded",children:u})]})})}function cT({workspaceName:e,branch:t,workdir:n,showEditorLink:r,sessionId:a,projectId:l,onEditWorkspace:u,onEditBranch:c}){const[d,h]=E.useState(!1),[p,m]=E.useState(!1);return t===null?null:s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[r&&n?s.jsxs("a",{href:t9(n),className:"flex items-center gap-2 min-w-0 flex-1 no-underline group",title:"Open workspace in VSCode",children:[s.jsx(Qr,{className:"w-4 h-4 text-text-muted flex-shrink-0"}),s.jsx("span",{className:"truncate text-text-secondary group-hover:text-accent-primary transition-colors",children:e})]}):s.jsxs(s.Fragment,{children:[s.jsx(Qr,{className:"w-4 h-4 text-text-muted flex-shrink-0"}),s.jsx("span",{className:"truncate text-text-secondary",children:e})]}),s.jsx("button",{onClick:()=>{u?u():h(!0)},className:"ml-auto px-2 py-0.5 text-xs rounded bg-bg-tertiary text-text-secondary hover:bg-bg-secondary transition-colors",children:"Edit"})]}),s.jsx("div",{className:"h-px bg-border"}),s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx(Fa,{}),s.jsx("span",{className:"truncate text-text-secondary",children:t}),s.jsx("button",{onClick:()=>{c?c():m(!0)},className:"ml-auto px-2 py-0.5 text-xs rounded bg-bg-tertiary text-text-secondary hover:bg-bg-secondary transition-colors",children:"Edit"})]})]}),s.jsx(r9,{}),!u&&s.jsx(oT,{isOpen:d,onClose:()=>h(!1),projectId:l,sessionId:a,currentWorkspace:e,currentBranch:t}),!c&&s.jsx(lT,{isOpen:p,onClose:()=>m(!1),sessionId:a})]})}function s9(e,t){return t||e>85?"text-accent-error":e>60?"text-accent-warning":"text-text-muted"}function i9(e,t){return t||e>85?"bg-accent-error":e>60?"bg-accent-warning":"bg-accent-success"}function Lb({percent:e,dangerZone:t=!1,size:n="md",className:r=""}){const a=n==="sm"?"w-12":"w-20",l=n==="sm"?"h-1":"h-1.5";return s.jsx("div",{className:`${l} bg-bg-tertiary rounded-full overflow-hidden ${a} ${r}`,children:s.jsx("div",{className:`h-full transition-all duration-300 ${i9(e,t)}`,style:{width:`${Math.min(e,100)}%`}})})}function a9({dangerZone:e,size:t="md"}){return e?s.jsx("span",{className:"text-accent-error animate-pulse text-[10px] font-medium",children:"Low!"}):null}function o9({code:e,variant:t}){const n=t==="inline"?"span":t==="block-nowrap"?"div":"pre";return s.jsx(n,{className:"language-",children:s.jsx("code",{className:"language-",children:e})})}const hl=E.memo(function({code:t,language:n,variant:r,showLineNumbers:a=!1,startLine:l=1}){const{showSyntaxHighlighting:u}=As(),[c,d]=E.useState(null),h=wN(),p=E.useRef(t);if(E.useEffect(()=>{u&&(p.current=t,SN(t,n,h).then(g=>{p.current===t&&d(g)}))},[t,n,h,u]),!u||!c)return s.jsx(o9,{code:t,variant:r});if(r==="inline")return s.jsx("span",{dangerouslySetInnerHTML:{__html:c}});const m=a?"":"shiki-plain";return s.jsx("div",{className:m,style:{"--shiki-start":l},dangerouslySetInnerHTML:{__html:c}})});function uT({src:e,alt:t,isOpen:n,onClose:r}){return n?s.jsx(jt,{isOpen:n,onClose:r,title:"",size:"full",children:s.jsx("div",{className:"flex items-center justify-center h-full",children:s.jsx("img",{src:e,alt:t,className:"max-w-full max-h-[80vh] object-contain rounded-lg shadow-2xl"})})}):null}const Jh=E.memo(function({type:t,children:n}){const r=t==="removed"?"diff-removed-bg diff-removed-border":"diff-added-bg diff-added-border",a=t==="removed"?"line-through decoration-red-400/30":"";return s.jsx("div",{className:`border-l-[3px] ${r}`,children:s.jsx("div",{className:`min-w-0 py-3 ${a}`,children:s.jsx("div",{className:"shiki-compact shiki-transparent-bg",children:n})})})}),l9=E.memo(function({oldString:t,newString:n,filePath:r}){const a=E.useMemo(()=>Hf(r),[r]),l=t.length>0,u=n.length>0;return!l&&!u?s.jsx("div",{className:"text-xs text-text-muted italic p-2",children:"No changes"}):s.jsxs("div",{className:"rounded overflow-hidden border border-border",children:[l&&s.jsx(Jh,{type:"removed",children:s.jsx(hl,{code:t,language:a,variant:"block",showLineNumbers:!0})}),u&&s.jsx(Jh,{type:"added",children:s.jsx(hl,{code:n,language:a,variant:"block",showLineNumbers:!0})})]})}),c9=E.memo(function({content:t,filePath:n}){const r=E.useMemo(()=>Hf(n),[n]);return s.jsx(bn,{className:"rounded border border-border max-h-[45vh]",children:s.jsx(Jh,{type:"added",children:s.jsx(hl,{code:t,language:r,variant:"block",showLineNumbers:!0})})})}),u9=E.memo(function({regions:t,filePath:n}){const r=E.useMemo(()=>Hf(n),[n]);return t.length===0?s.jsx("div",{className:"text-xs text-text-muted italic p-2",children:"No changes"}):s.jsx("div",{className:"space-y-2",children:t.map((a,l)=>s.jsx(h9,{region:a,language:r},l))})});function d9(e){const t=[];function n(r,a,l){const u=t[t.length-1];u&&u.type===r&&u.startLine+u.lines.length===a?u.lines.push(l):t.push({type:r,startLine:a,lines:[l]})}for(const r of e.beforeContext)n("context",r.lineNumber,r.content);for(const r of e.edits){const a=r.oldContent.split(`
284
+ `);for(let u=0;u<a.length;u++)n("removed",r.startLine+u,a[u]);const l=r.newContent.split(`
285
+ `);for(let u=0;u<l.length;u++)n("added",r.startLine+u,l[u])}for(const r of e.afterContext)n("context",r.lineNumber,r.content);return t}const h9=E.memo(function({region:t,language:n}){const r=d9(t);return s.jsx("div",{className:"rounded overflow-hidden border border-border font-mono text-sm",children:r.map((a,l)=>s.jsx(f9,{section:a,language:n},l))})}),f9=E.memo(function({section:t,language:n}){const r=t.lines.join(`
286
+ `);return t.type==="context"?s.jsx("div",{children:s.jsx("div",{className:"min-w-0 py-3",children:s.jsx("div",{className:"shiki-compact shiki-transparent-bg",children:s.jsx(hl,{code:r,language:n,variant:"block",showLineNumbers:!0,startLine:t.startLine})})})}):s.jsx(Jh,{type:t.type,children:s.jsx(hl,{code:r,language:n,variant:"block",showLineNumbers:!0,startLine:t.startLine})})});function $C(e){return e.split(`
287
+ `).filter(t=>!t.startsWith(`
288
+ [`)&&!t.startsWith("[")).map(t=>t.replace(/^\d+\|/,"")).join(`
289
+ `)}const m9=E.memo(function({result:t,metadata:n,filePath:r}){const[a,l]=E.useState(!1),u=E.useMemo(()=>Hf(r),[r]),c=n==null?void 0:n.mimeType,d=n==null?void 0:n.base64Data;if(c!=null&&c.startsWith("image/")&&d){const w=`data:${c};base64,${d}`;return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"rounded overflow-hidden border border-border max-h-[45vh] flex items-center justify-center cursor-pointer hover:border-accent-primary transition-colors",onClick:()=>l(!0),children:s.jsx("img",{src:w,alt:r,className:"max-w-full max-h-[45vh] object-contain"})}),s.jsx(uT,{src:w,alt:r,isOpen:a,onClose:()=>l(!1)})]})}if(!t)return s.jsx("div",{className:"text-xs text-text-muted italic p-2",children:"Empty file"});const h=t;if(u==="markdown"){const w=$C(h);return s.jsx(bn,{className:"rounded border border-border max-h-[45vh] p-2",children:s.jsx(sr,{content:w})})}const p=$C(h),m=h.split(`
290
+ `)[0],g=m==null?void 0:m.match(/^(\d+)\|/),y=g?parseInt(g[1],10):1;return s.jsx(bn,{className:"rounded border border-border max-h-[45vh]",children:s.jsx(hl,{code:p,language:u,variant:"block",showLineNumbers:!0,startLine:y})})});function p9({type:e,content:t}){const n=e==="added"?"diff-added-bg":e==="removed"?"diff-removed-bg":"bg-transparent",r=e==="added"?"+":e==="removed"?"-":" ";return s.jsxs("div",{className:`${n} px-2`,children:[s.jsx("span",{className:"select-none text-text-muted w-6 inline-block",children:r}),s.jsx("span",{className:"whitespace-pre-wrap break-words",children:t||" "})]})}function g9({diff:e}){const t=[];let n=0;for(;n<e.length;){const r=e[n];if(!r||r.type==="unchanged"){n++;continue}if(r.type==="removed"){for(;n<e.length;){const a=e[n];if(!a||a.type!=="removed")break;t.push({type:"removed",content:a.content}),n++}for(;n<e.length;){const a=e[n];if(!a||a.type!=="added")break;t.push({type:"added",content:a.content}),n++}}else if(r.type==="added")for(;n<e.length;){const a=e[n];if(!a||a.type!=="added")break;t.push({type:"added",content:a.content}),n++}}return t.length===0?s.jsx("div",{className:"py-8 text-center text-text-muted",children:"No changes detected."}):s.jsxs("div",{children:[s.jsx("div",{className:"px-2 py-1 text-xs font-semibold text-text-muted uppercase tracking-wide",children:"Changes:"}),s.jsx("div",{className:"font-mono text-xs leading-5",children:t.map((r,a)=>s.jsx(p9,{type:r.type,content:r.content},a))})]})}function Rb({isOpen:e,onClose:t,isRunning:n,onApply:r}){const[a,l]=E.useState(null),[u,c]=E.useState(!1),d=E.useRef(null),h=E.useCallback(()=>{c(!0);const p=Pt.send("context.applyDynamic.preview",{});d.current=p;const m=Pt.subscribe(g=>{if(g.id===p&&g.type==="context.preview"){const y=g.payload;l(y.diff??[]),c(!1),d.current=null,m()}});setTimeout(()=>{d.current===p&&(c(!1),d.current=null,m())},5e3)},[]);return E.useEffect(()=>{e&&(l(null),c(!0),h())},[e,h]),s.jsxs(jt,{isOpen:e,onClose:t,title:"Update system prompt",size:"lg",children:[s.jsxs("p",{className:"text-sm text-text-secondary mb-4",children:["Applying the new system prompt will rebuild the cached prompt, which may cause the next response to take longer while the LLM reprocesses the prefix.",n&&s.jsxs(s.Fragment,{children:[" ","Since the session is currently running, the update will be queued and applied at the start of the next turn."]})]}),u?s.jsx("div",{className:"py-8 text-center text-text-muted",children:"Loading diff..."}):a&&a.length>0?s.jsx(ct,{className:"max-h-[60vh] border border-border rounded-lg",children:s.jsx(g9,{diff:a})}):s.jsx("p",{className:"text-sm text-text-tertiary mb-4",children:"The system prompt hash has changed (e.g., due to tool or skill changes), but the actual prompt text appears identical. Applying the update will still rebuild the cached prompt to ensure consistency."}),s.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[s.jsx("button",{onClick:t,className:"px-3 py-1.5 text-sm rounded bg-bg-tertiary text-text-primary hover:bg-border transition-colors",children:"Cancel"}),s.jsx("button",{onClick:r,className:"px-3 py-1.5 text-sm rounded bg-accent-primary text-white hover:opacity-90 transition-colors",children:n?"Queue update":"Update"})]})]})}function dT({variant:e="popover",onUpdateSystemPrompt:t}){const n=De(R=>R.contextState),r=De(R=>R.currentSession),a=De(R=>R.compactContext),l=De(R=>R.queueUpdate),[u,c]=E.useState(!1),[d,h]=E.useState(!1);if(!n||!r)return null;const{currentTokens:p,maxTokens:m,compactionCount:g,dangerZone:y,dynamicContextChanged:w}=n,C=Math.round(p/m*100),_=r.isRunning,S=()=>{_?l():Pt.send("context.applyDynamic",{}),c(!1)},b=e==="sidebar",v=s.jsxs("span",{className:s9(C,y),children:[dl(p)," / ",dl(m)," (",C,"%)"]}),k=s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Lb,{percent:C,dangerZone:y,className:"flex-1"}),s.jsx(a9,{dangerZone:y}),g>0&&s.jsxs("span",{className:"text-[10px] text-text-muted bg-bg-tertiary px-1 py-0.5 rounded",children:[g,"x"]})]}),T=s.jsxs("div",{className:"relative",children:[s.jsx("button",{onClick:()=>h(!d),className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"More options",children:s.jsx(jE,{})}),d&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-40",onClick:()=>h(!1)}),s.jsxs("div",{className:"absolute right-0 top-full mt-1.5 z-50 bg-bg-secondary border border-border rounded-lg shadow-xl py-1 min-w-[160px]",children:[s.jsx("button",{onClick:()=>{_||a(),h(!1)},disabled:_,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:_?"Cannot compact while running":"Compact context",children:s.jsx("span",{className:y?"text-accent-error":"",children:"Compact"})}),w&&s.jsx("button",{onClick:()=>{h(!1),t?t():c(!0)},className:"w-full px-3 py-1.5 text-left text-sm hover:bg-bg-tertiary transition-colors",title:"Preview and apply system prompt changes",children:s.jsx("span",{className:"text-accent-warning",children:"Update system prompt"})})]})]})]}),N=t?null:s.jsx(Rb,{isOpen:u,onClose:()=>c(!1),isRunning:_,onApply:S});return b?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-start gap-2 mb-4",children:[s.jsxs("div",{className:"flex-1 min-w-0 space-y-1",children:[s.jsx("div",{className:"text-sm",children:v}),k]}),s.jsx("div",{className:"shrink-0 pt-0.5",children:T})]}),N]}):s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("div",{className:"flex items-center justify-between text-sm",children:v}),k]}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("button",{onClick:()=>{_||a()},disabled:_,className:"w-full px-3 py-1.5 text-left text-sm hover:bg-bg-tertiary transition-colors disabled:opacity-40 disabled:cursor-not-allowed rounded",title:_?"Cannot compact while running":"Compact context",children:s.jsx("span",{className:y?"text-accent-error":"",children:"Compact"})}),w&&s.jsx("button",{onClick:()=>{t?t():c(!0)},className:"w-full px-3 py-1.5 text-left text-sm hover:bg-bg-tertiary transition-colors rounded",title:"Preview and apply system prompt changes",children:s.jsx("span",{className:"text-accent-warning",children:"Update system prompt"})})]}),N]})}function zC({messages:e,workdir:t}){var b,v,k;const[n,r]=E.useState(!1),[a,l]=E.useState(!1),[u,c]=E.useState(null),d=y7(e),{branch:h}=jb(),p=Zt(T=>T.version),m=De(T=>T.currentSession),g=hu((m==null?void 0:m.workspace)??"")||null,y=Lt(T=>T.settings[je.DISPLAY_SHOW_OPEN_IN_EDITOR])==="true",w=li(T=>T.status),C=li(T=>T.check),[_,S]=E.useState(!1);return s.jsxs("div",{className:"flex flex-col h-full",children:[s.jsx(dT,{variant:"sidebar"}),d&&s.jsxs("div",{className:"mb-4",children:[s.jsx("button",{onClick:()=>r(!0),className:"w-full flex items-center justify-center px-3 py-2 rounded bg-bg-tertiary hover:bg-bg-secondary transition-colors",title:"View detailed response and call-level stats",children:s.jsxs("div",{className:"flex items-center gap-2 text-sm text-text-muted",children:[s.jsx("span",{className:"text-text-secondary",children:Es(d.aiTime)}),s.jsx("span",{className:"w-px h-3 bg-border"}),s.jsx("span",{className:"text-text-secondary",children:NC(d.avgPrefillSpeed)}),s.jsx("span",{children:"pp"}),s.jsx("span",{className:"w-px h-3 bg-border"}),s.jsx("span",{className:"text-text-secondary",children:NC(d.avgGenerationSpeed)}),s.jsx("span",{children:"tg"})]})}),s.jsx(A7,{isOpen:n,onClose:()=>r(!1),stats:d})]}),s.jsx(ct,{className:"flex flex-col flex-1 px-4 -mx-4 pb-4",children:s.jsxs("div",{children:[s.jsx("button",{onClick:()=>c("criteria"),className:"w-full text-left cursor-pointer hover:[&_h3]:text-accent-primary transition-colors",children:s.jsx(Xh,{entries:((b=m==null?void 0:m.metadataEntries)==null?void 0:b.criteria)??[],title:"Acceptance Criteria"})}),m&&s.jsx(XN,{entries:((v=m==null?void 0:m.metadataEntries)==null?void 0:v.criteria)??[],sessionId:m.id}),m&&(()=>{const T=["review_findings","todos"],N=m.metadataEntries??{},R=T.filter(O=>O in N),A=Object.keys(N).filter(O=>O!=="criteria"&&!T.includes(O)).sort();return[...R,...A].filter(O=>{var P;return(((P=N[O])==null?void 0:P.length)??0)>0}).map(O=>s.jsxs("div",{className:"mt-6",children:[s.jsx("button",{onClick:()=>c(O),className:"w-full text-left cursor-pointer hover:[&_h3]:text-accent-primary transition-colors",children:s.jsx(Xh,{entries:N[O],title:sl(O)})}),s.jsx(KN,{entries:N[O],onClearAll:async()=>{try{await we(`/api/sessions/${m.id}/metadata/${O}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({entries:[]})})}catch(P){console.error(`Failed to clear ${O}:`,P)}}})]},O))})()]})}),s.jsx(cT,{workspaceName:g??"original",branch:h,workdir:t,showEditorLink:y,sessionId:(m==null?void 0:m.id)??"",projectId:(m==null?void 0:m.projectId)??""}),s.jsx(eT,{workdir:t}),s.jsx(e9,{sessionId:m==null?void 0:m.id}),p&&s.jsxs("div",{className:"mt-4 pt-4 border-t border-border text-center text-xs text-text-muted",children:[s.jsxs("div",{className:"flex items-center justify-center gap-1",children:[s.jsx("a",{href:"https://github.com/co-l/openfox",target:"_blank",rel:"noopener noreferrer",className:"hover:text-accent-primary transition-colors",children:"OpenFox"})," - ",s.jsxs("span",{className:"font-mono",children:["v",p]}),s.jsx("button",{onClick:()=>{S(!0),C(!0)},disabled:w==="checking",className:"p-0.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors disabled:opacity-50",title:"Check for updates",children:s.jsx(xf,{className:`w-3 h-3 ${w==="checking"?"animate-spin":""}`})})]}),w==="available"&&s.jsx("button",{onClick:()=>l(!0),className:"text-accent-primary hover:underline mt-1",children:"Update OpenFox →"}),_&&w==="upToDate"&&s.jsx("div",{className:"mt-1",children:"Up to date"}),w==="error"&&s.jsx("div",{className:"mt-1",children:"Update check failed"})]}),s.jsx(WE,{isOpen:a,onClose:()=>l(!1),versionInfo:null}),s.jsx(YN,{isOpen:u!==null,onClose:()=>c(null),entries:((k=m==null?void 0:m.metadataEntries)==null?void 0:k[u??""])??[],sessionId:(m==null?void 0:m.id)??"",metadataKey:u??"",title:sl(u??"")})]})}function x9({children:e,criteriaSidebarOpen:t=!0,onCriteriaSidebarToggle:n,messages:r}){const a=De(c=>c.currentSession),{width:l,handleMouseDown:u}=FN({initialWidth:320,minWidth:240,maxWidth:600,direction:"right"});return s.jsxs("div",{className:"relative h-full overflow-hidden",children:[t&&s.jsx("div",{className:"fixed md:hidden inset-0 bg-secondary/50 z-40",onClick:n}),s.jsxs("div",{className:"flex h-full",children:[s.jsx("div",{className:"flex-1 min-w-0 flex flex-col overflow-hidden bg-secondary",children:e}),t?s.jsxs("aside",{className:"hidden md:block shrink-0 border-l border-border bg-secondary relative",style:{width:l},children:[s.jsx(UN,{side:"left",onMouseDown:u}),s.jsx(ct,{className:"h-full p-4",children:s.jsx(zC,{messages:r,workdir:(a==null?void 0:a.workspace)??(a==null?void 0:a.workdir)})})]}):s.jsx("aside",{className:"hidden md:block w-0 shrink-0 overflow-hidden border-l-0"}),s.jsx("aside",{className:`
291
+ md:hidden
292
+ bg-secondary
293
+ transition-all duration-300 ease-in-out
294
+ fixed right-0 top-[32px] h-[calc(100vh-32px)] z-50
295
+ ${t?"w-[320px] translate-x-0 border-l border-border":"w-[320px] translate-x-full"}
296
+ `,children:s.jsx("div",{className:"h-full p-4",children:s.jsx(ct,{className:"h-full",children:s.jsx(zC,{messages:r,workdir:(a==null?void 0:a.workspace)??(a==null?void 0:a.workdir)})})})})]})]})}function y9(){const e=De(w=>w.contextState),t=De(w=>w.currentSession),n=De(w=>w.pendingUpdate),r=De(w=>w.triggerPendingUpdate),a=De(w=>w.queueUpdate),[l,u]=E.useState(!1),[c,d]=E.useState(!1),h=E.useRef(!1),p=E.useRef(!1);if(E.useEffect(()=>{e!=null&&e.dynamicContextChanged&&!h.current&&u(!1),h.current=(e==null?void 0:e.dynamicContextChanged)??!1},[e==null?void 0:e.dynamicContextChanged]),E.useEffect(()=>{const w=(t==null?void 0:t.isRunning)??!1;p.current&&!w&&n&&r(),p.current=w},[t==null?void 0:t.isRunning,n,r]),!e||!t)return null;const{dynamicContextChanged:m}=e,g=t.isRunning,y=()=>{g?a():Pt.send("context.applyDynamic",{}),u(!0),d(!1)};return s.jsxs(s.Fragment,{children:[m&&!l&&s.jsx("div",{className:"flex-shrink-0 px-4 py-2 bg-accent-warning/10 border-b border-accent-warning/30",children:s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex-1 flex items-center justify-center gap-1 text-sm text-text-secondary",children:[s.jsx("span",{children:"System prompt has changed —"}),s.jsx("button",{onClick:()=>d(!0),className:"underline hover:text-text-primary transition-colors",children:"click here to update it"})]}),s.jsx("button",{onClick:()=>u(!0),className:"flex-shrink-0 p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors",title:"Dismiss",children:s.jsx(Ji,{})})]})}),s.jsx(Rb,{isOpen:c,onClose:()=>d(!1),isRunning:g,onApply:y})]})}function b9({stats:e,onClose:t}){var c;const n=ft(d=>d.defaults),r=ft(d=>d.userItems),l=[...n,...r].find(d=>d.id===e.mode),u=(l==null?void 0:l.name)??e.mode;return s.jsx(jt,{isOpen:!0,onClose:t,title:"Turn Stats",size:"md",children:s.jsxs("div",{className:"space-y-4",children:[s.jsx("div",{className:"flex items-center gap-3",children:s.jsxs("p",{className:"text-xs text-text-muted",children:[e.model," · ",u]})}),s.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[s.jsx(nh,{label:"Total Time",value:Es(e.totalTime)}),s.jsx(nh,{label:"Prefill",value:e.prefillTokens>=1e3?`${(e.prefillTokens/1e3).toFixed(1)}k`:String(e.prefillTokens)}),s.jsx(nh,{label:"Generated",value:e.generationTokens>=1e3?`${(e.generationTokens/1e3).toFixed(1)}k`:String(e.generationTokens)}),s.jsx(nh,{label:"LLM Calls",value:String(((c=e.llmCalls)==null?void 0:c.length)??1)})]}),e.llmCalls&&e.llmCalls.length>0&&s.jsxs("div",{children:[s.jsx("h4",{className:"text-sm font-medium text-text-secondary mb-2",children:"LLM Calls"}),e.llmCalls.map((d,h)=>s.jsxs("div",{className:"bg-bg-tertiary/30 rounded p-3 mb-2",children:[s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsxs("span",{className:"text-xs text-text-muted",children:["Call ",h+1]}),s.jsxs("span",{className:"text-xs text-text-muted",children:[d.ttft.toFixed(2),"s TTFT · ",d.completionTime.toFixed(2),"s gen"]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[s.jsxs("div",{children:[s.jsx("span",{className:"text-text-muted",children:"Tokens:"})," ",s.jsxs("span",{className:"text-text-primary",children:[d.promptTokens," → ",d.completionTokens]})]}),s.jsxs("div",{className:"flex flex-wrap gap-x-2 gap-y-1",children:[d.temperature!==void 0&&s.jsx(rh,{label:"temp",value:d.temperature.toFixed(2)}),d.topP!==void 0&&s.jsx(rh,{label:"topP",value:d.topP.toFixed(2)}),d.topK!==void 0&&s.jsx(rh,{label:"topK",value:String(d.topK)}),d.maxTokens!==void 0&&s.jsx(rh,{label:"maxTok",value:String(d.maxTokens)})]})]})]},h))]})]})})}function nh({label:e,value:t}){return s.jsxs("div",{className:"bg-bg-tertiary/50 rounded p-3",children:[s.jsx("div",{className:"text-xs text-text-muted",children:e}),s.jsx("div",{className:"text-lg font-semibold text-text-primary",children:t})]})}function rh({label:e,value:t}){return s.jsxs("span",{className:"bg-bg-tertiary px-1.5 py-0.5 rounded text-text-primary",children:[s.jsxs("span",{className:"text-text-muted",children:[e,":"]})," ",t]})}const Db={builtin:"Built-in",user:"Global",project:"Project"};function Zh(e,t){const n=e.filter(r=>r.id===t);if(n.length!==0)return n.find(r=>r.scope==="project")??n.find(r=>r.scope==="user")??n.find(r=>r.scope==="builtin")}function dy(e,t,n){return n!=="auto"?e.find(r=>r.id===t&&r.scope===n)??Zh(e,t):Zh(e,t)}const v9=E.memo(function({content:t,variant:n="default"}){return n==="labeled"?s.jsxs("div",{className:"text-text-muted text-sm italic feed-item",children:[s.jsx("span",{className:"text-text-thinking",children:"thinking:"}),s.jsx(bn,{horizontal:!0,className:"ml-1.5 mt-0.5",children:s.jsx(sr,{content:t})})]}):s.jsx(bn,{horizontal:!0,className:"text-text-muted text-sm italic bg-secondary rounded p-1.5 feed-item",children:s.jsx(sr,{content:t,muted:!0})})});function hT({tool:e,className:t="w-4 h-4 text-text-muted flex-shrink-0"}){return e==="glob"||e==="grep"?s.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"})}):e==="run_command"||e==="bash"?s.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 9l3 3-3 3m5 0h3M5 20h14a2 2 0 002-2V6a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"})}):e==="workspace"?s.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M8 7h12m0 0l-4-4m4 4l-4 4m0 6H4m0 0l4 4m-4-4l4-4"})}):s.jsx("svg",{className:t,fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"})})}const _9={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"}},HC=E.memo(function({diagnostics:t}){if(t.length===0)return null;const n=t.filter(l=>l.severity==="error"),r=t.filter(l=>l.severity==="warning"),a=t.filter(l=>l.severity==="info"||l.severity==="hint");return s.jsxs("div",{className:"rounded border border-border overflow-hidden mt-2",children:[s.jsxs("div",{className:"flex items-center gap-3 px-2 py-1.5 bg-bg-tertiary border-b border-border",children:[s.jsx("span",{className:"text-xs font-medium text-text-secondary",children:"LSP Diagnostics"}),n.length>0&&s.jsxs("span",{className:"text-xs text-accent-error font-medium",children:[n.length," error",n.length!==1?"s":""]}),r.length>0&&s.jsxs("span",{className:"text-xs text-accent-warning font-medium",children:[r.length," warning",r.length!==1?"s":""]}),a.length>0&&s.jsxs("span",{className:"text-xs text-text-muted",children:[a.length," info"]})]}),s.jsx(bn,{className:"max-h-48",children:t.map((l,u)=>{const c=_9[l.severity];return s.jsxs("div",{className:`flex items-start gap-2 px-2 py-1.5 ${c.bg} border-b border-border last:border-b-0`,children:[s.jsx("span",{className:`${c.color} text-xs flex-shrink-0 w-4 text-center`,children:c.icon}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"text-[10px] text-text-muted font-mono",children:["Ln ",l.range.start.line+1,":",l.range.start.character+1]}),l.code&&s.jsxs("span",{className:"text-[10px] text-text-muted font-mono",children:["[",l.code,"]"]})]}),s.jsx("div",{className:"text-xs text-text-primary break-words",children:l.message})]})]},u)})})]})}),S9=E.memo(function({command:t,timeout:n,startedAt:r,streamingOutput:a,status:l,result:u,error:c,durationMs:d}){const h=E.useRef(null),[p,m]=E.useState(0),g=Su(h),{setAutoScroll:y,force_scroll_to_bottom:w,handleScrollbarGesture:C}=_u(h,null,g);E.useEffect(()=>{l==="pending"?y(!0):(w(),y(!1))},[l,y,w]),E.useEffect(()=>{if(l!=="pending"||!r)return;const v=setInterval(()=>{m(Date.now()-r)},100);return()=>clearInterval(v)},[l,r]);const _=n/1e3,S=l==="pending"?p/1e3:(d??0)/1e3,b=l==="pending"?(a==null?void 0:a.map(v=>v.content).join(""))??"":u??"";return s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between gap-4",children:[s.jsxs("div",{className:"flex items-center gap-2 text-xs flex-1 min-w-0",children:[s.jsx("span",{className:"text-text-muted flex-shrink-0",children:"$"}),s.jsx("code",{className:"text-text-primary break-all",children:t})]}),s.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-muted flex-shrink-0",children:[l==="pending"&&s.jsx("span",{className:"animate-pulse text-accent-warning",children:"running"}),l==="interrupted"&&s.jsx("span",{className:"text-red-400",children:"interrupted"}),s.jsxs("span",{className:l==="pending"?"text-text-secondary":"text-text-muted",children:[S.toFixed(1),"s / ",_,"s"]})]})]}),l==="pending"&&s.jsx("div",{className:"h-1 bg-bg-tertiary rounded overflow-hidden",children:s.jsx("div",{className:"h-full bg-accent-warning transition-all duration-100",style:{width:`${Math.min(100,p/n*100)}%`}})}),(b||l==="pending")&&s.jsx(ct,{ref:h,onScrollbarGesture:C,className:`text-xs bg-bg-primary p-2 rounded max-h-64 ${l==="pending"?"border border-accent-warning/30":""}`,style:{overflowX:"hidden",whiteSpace:"normal"},children:l==="pending"&&a?a.map((v,k)=>s.jsx("span",{className:v.stream==="stderr"?"text-accent-warning":"",children:Qh(v.content)},k)):Qh(b)}),l==="error"&&c&&s.jsx("div",{className:"text-xs text-accent-error bg-accent-error/10 p-2 rounded",children:c})]})}),jc=E.memo(function({className:t=""}){return s.jsx("div",{className:`text-[10px] text-accent-warning ${t}`,children:"Output truncated"})});function fT(e,t){try{return{success:!0,parsed:JSON.parse(e)}}catch{return console.warn(`${t}: failed to parse result JSON`,e.slice(0,200)),{success:!1,error:s.jsx(ct,{horizontal:!0,className:"max-h-[60vh]",children:s.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded break-words",children:e})})}}}const w9=E.memo(function({result:t,action:n}){const r=fT(t,"DevServerView");if(!r.success)return r.error;const a=r.parsed;return n==="logs"?C9(a):k9(a)});function C9(e){if(!e.logs)return s.jsx("div",{className:"text-xs text-text-muted italic",children:"No log output"});const t=e.logs.split(`
297
+ `);return s.jsxs("div",{className:"space-y-2",children:[s.jsx(bn,{className:"text-xs font-mono whitespace-pre-wrap bg-bg-primary p-2 rounded max-h-[60vh] break-words",children:t.map((n,r)=>{const a=n.startsWith("[stderr] ");return s.jsx("div",{className:a?"text-accent-warning":"",children:a?n.slice(9):n},r)})}),e.hasMore&&s.jsxs("div",{className:"text-[10px] text-text-muted",children:["Showing ",e.limit," of ",e.total," lines"]})]})}function k9(e){const t=String(e.state??""),n=String(e.url??""),r=e.error?String(e.error):void 0,a=t==="running"?"text-accent-success":t==="stopped"?"text-text-muted":t==="error"?"text-accent-error":"text-text-muted";return s.jsxs("div",{className:"space-y-2 text-xs",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-text-muted",children:"State:"}),s.jsx("span",{className:`font-medium ${a}`,children:t})]}),n&&n!=="undefined"&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-text-muted",children:"URL:"}),s.jsx("a",{href:n,className:"text-accent-primary hover:underline",target:"_blank",rel:"noopener noreferrer",children:n})]}),r&&s.jsx("div",{className:"text-accent-error bg-accent-error/10 p-2 rounded",children:r})]})}const E9=E.memo(function({result:t,action:n}){const r=fT(t,"BackgroundProcessView");if(!r.success)return r.error;const a=r.parsed;return n==="logs"?j9(a):n==="list"?N9(a):n==="status"?T9(a):n==="start"||n==="stop"?A9(a):s.jsxs("div",{className:"space-y-2 text-xs",children:[s.jsxs("div",{className:"text-accent-warning",children:["Unknown action: ",n]}),s.jsx(bn,{horizontal:!0,className:"max-h-[60vh]",children:s.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded break-words",children:t})})]})});function j9(e){const t=e.lines,n=e.hasMore,r=e.totalLines;return!t||t.length===0?s.jsx("div",{className:"text-xs text-text-muted italic",children:"No log output"}):s.jsxs("div",{className:"space-y-2",children:[s.jsx(bn,{className:"text-xs font-mono whitespace-pre-wrap bg-bg-primary p-2 rounded max-h-[60vh] break-words",children:t.map((a,l)=>s.jsx("div",{className:a.stream==="stderr"?"text-accent-warning":"",children:a.content},l))}),n&&r!=null&&s.jsxs("div",{className:"text-[10px] text-text-muted",children:["Showing ",t.length," of ",r," lines"]})]})}function N9(e){const t=e.processes,n=e.currentCount,r=e.maxPerSession;return!t||t.length===0?s.jsx("div",{className:"text-xs text-text-muted italic",children:"No background processes"}):s.jsxs("div",{className:"space-y-2",children:[t.map(a=>s.jsx(mT,{process:a},a.id)),n!=null&&r!=null&&s.jsxs("div",{className:"text-[10px] text-text-muted",children:[n," of ",r," slots used"]})]})}function T9(e){const t=e.process,n=e.uptime;return t?s.jsxs("div",{className:"space-y-2",children:[s.jsx(mT,{process:t}),n!=null&&s.jsxs("div",{className:"text-[10px] text-text-muted",children:["Uptime: ",L9(n)]})]}):s.jsx("div",{className:"text-xs text-text-muted italic",children:"Process not found"})}function A9(e){const t=e.processId,n=e.name,r=e.pid,a=e.status,l=a==="running"?"text-accent-success":"text-text-muted";return s.jsxs("div",{className:"space-y-2 text-xs",children:[n&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-text-muted",children:"Name:"}),s.jsx("span",{className:"font-medium",children:n})]}),t&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-text-muted",children:"ID:"}),s.jsx("span",{className:"font-mono",children:t})]}),r!=null&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-text-muted",children:"PID:"}),s.jsx("span",{className:"font-mono",children:r})]}),a&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-text-muted",children:"Status:"}),s.jsx("span",{className:`font-medium ${l}`,children:a})]})]})}function mT({process:e}){const t=e.status==="running"?"text-accent-success":(e.status==="exited","text-text-muted");return s.jsxs("div",{className:"border border-border rounded p-2 space-y-1 text-xs",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"font-medium",children:e.name}),s.jsx("span",{className:`${t}`,children:e.status})]}),e.pid!=null&&s.jsxs("div",{className:"text-text-muted",children:["PID: ",s.jsx("span",{className:"font-mono",children:e.pid})]}),e.command&&s.jsx("div",{className:"text-text-muted font-mono truncate",children:e.command})]})}function L9(e){const t=Math.floor(e/1e3),n=Math.floor(t/60),r=Math.floor(n/60);return r>0?`${r}h ${n%60}m`:n>0?`${n}m ${t%60}s`:`${t}s`}const R9=E.memo(function({result:t,action:n}){let r;try{r=JSON.parse(t)}catch{return s.jsx(bn,{horizontal:!0,className:"max-h-[60vh]",children:s.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded break-words",children:t})})}switch(n){case"list":return D9(r);case"switch":case"delete":return O9(r);default:return s.jsx(bn,{horizontal:!0,className:"max-h-[60vh]",children:s.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded break-words",children:t})})}});function D9(e){const t=e.workspaces??[];return t.length===0?s.jsx("div",{className:"text-xs text-text-muted italic",children:"No workspaces found"}):s.jsxs("div",{className:"space-y-1 text-xs",children:[s.jsx("div",{className:"text-text-muted mb-1",children:"Workspaces:"}),t.map(n=>s.jsxs("div",{className:"flex items-center gap-2 font-mono",children:[s.jsx("span",{className:n.active?"text-accent-success":"text-text-muted",children:n.active?"●":"○"}),s.jsx("span",{className:n.active?"text-text-primary font-medium":"text-text-secondary",children:n.name}),n.branch&&s.jsxs("span",{className:"text-text-muted",children:["· ",n.branch]}),n.active&&s.jsx("span",{className:"text-[10px] text-accent-primary",children:"(current)"})]},n.name))]})}function lx({label:e,value:t,mono:n}){return s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"text-text-muted",children:[e,":"]}),s.jsx("span",{className:n?"font-mono text-accent-primary":"text-text-primary",children:t})]})}function O9(e){return s.jsxs("div",{className:"space-y-2 text-xs",children:[e.message&&s.jsx("div",{className:"text-text-primary",children:e.message}),e.workspace&&s.jsx(lx,{label:"Name",value:e.workspace,mono:!0}),e.path&&s.jsx(lx,{label:"Path",value:e.path,mono:!0}),e.branch&&s.jsx(lx,{label:"Branch",value:e.branch,mono:!0})]})}function I9(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 M9({confirmation:e}){const t=De(m=>m.confirmPath),n=De(m=>m.currentSession),r=De(m=>m.switchDangerLevel),{title:a,description:l}=I9(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",h=e.reason==="git_no_verify",p=()=>{n!=null&&n.id&&r("dangerous"),t(e.callId,!0,!1)};return s.jsxs("div",{className:`border ${c} ${d} rounded p-3 my-2`,children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx(Tx,{}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:`text-sm font-medium ${u?"text-red-400":"text-amber-400"}`,children:a}),s.jsx("div",{className:"text-xs text-text-muted",children:l})]})]}),s.jsxs("div",{className:"text-xs text-text-muted mb-2",children:[s.jsx("span",{className:"font-medium",children:e.tool})," wants to access:"]}),s.jsx(ct,{className:"bg-bg-primary rounded p-2 mb-3 max-h-24",children:s.jsx("ul",{className:"space-y-0.5",children:e.paths.map((m,g)=>s.jsx("li",{className:`text-xs font-mono ${u?"text-red-300":"text-amber-300"} break-all`,children:m},g))})}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{onClick:()=>t(e.callId,!1),className:"flex-1 px-3 py-1.5 text-xs font-medium rounded bg-bg-tertiary hover:bg-bg-tertiary/80 text-text-secondary border border-border transition-colors",children:"Deny"}),s.jsx("button",{onClick:()=>t(e.callId,!0,!1),className:"flex-1 px-3 py-1.5 text-xs font-medium rounded bg-accent-primary hover:bg-accent-primary/80 text-text-primary transition-colors",children:"Allow"}),s.jsx("button",{onClick:p,className:`flex-1 px-3 py-1.5 text-xs font-medium rounded transition-colors ${h?"hidden":"bg-red-600 hover:bg-red-700 text-white"}`,title:"Enable dangerous mode and allow this request",children:"Allow Everything"})]})]})}function P9(e,t){if(e==="read_file"){const r=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?`${r} [${u.join(", ")}]`:r}if(e==="write_file"||e==="edit_file")return String(t.path??"");if(e==="run_command"||e==="bash")return String(t.command??"");if(e==="return_value"){const r=String(t.content??"");return r.length>60?r.slice(0,60)+"...":r}if(e==="call_sub_agent")return String(t.subAgentType??"");if(e==="load_skill")return String(t.skillId??"");if(e==="web_fetch")return String(t.url??"");if(e==="web_search"){const r=String(t.query??"");return r.length>60?r.slice(0,57)+"...":r}if(e==="dev_server")return String(t.action??"");if(e==="background_process"){const r=String(t.action??""),a=t.name?String(t.name):"";return a?`${r}: ${a}`:r}if(e==="mcp_config")return String(t.action??"");const n=JSON.stringify(t);return n.length>50?n.slice(0,50)+"...":n}function FC(e,t,n){var a;const r=P9(e,t);if(e==="read_file"&&n){const l=n.format,u=n.pageCount;if(l==="pdf"&&u!=null)return`${r} (PDF, ${u}p)`;if(l==="image")return`${r} (image)`}if(e==="web_fetch"&&n){const l=n.contentType;if(l){const u=((a=l.split(";")[0])==null?void 0:a.trim())??"";if(u&&u!=="text/html")return`${r} (${u})`}}return r}function B9(e){return JSON.stringify(e,null,2)}const UC={ssh:"SSH",scp:"SCP",sftp:"SFTP",mosh:"MOSH"},$9=new Set(["-C","--close-from","-D","--chdir","-g","--group","-h","--host","-p","--prompt","-R","--chroot","-T","--command-timeout","-u","--user"]),z9=new Set(["-C","--chdir","-S","--split-string","-u","--unset"]),H9=new Set(["-p","-f","-d","-P"]);function VC(e){return e.split(/[\\/]/).pop()??e}function F9(e){const t=[];let n=null,r=!1;for(let a=0;a<e.length;a+=1){const l=e[a];if(r){r=!1;continue}if(l==="\\"&&n!=="'"){r=!0;continue}if(l==="'"||l==='"'){n=n===l?null:n===null?l:n;continue}if(n)continue;if(l==="#"&&(a===0||/\s|[;&|(){}]/.test(e[a-1])))break;if(l!=="<"||e[a-1]==="<"||e[a+1]!=="<"||e[a+2]==="<")continue;let u=a+2;const c=e[u]==="-";for(c&&(u+=1);/\s/.test(e[u]??"");)u+=1;let d="",h=null,p=!1,m=!0;for(;u<e.length;){const g=e[u];if(!h&&/\s|[;&|(){}<>]/.test(g))break;if(g==="'"||g==='"'){m=!1,h===g?(h=null,p=!1):h===null&&(h=g),u+=1;continue}if(!h&&g==="$"&&e[u+1]==="'"){m=!1,p=!0,h="'",u+=2;continue}if(g==="\\"&&u+1<e.length){if(m=!1,p){const y=e.slice(u).match(/^\\(?:x([0-9A-Fa-f]{1,2})|([0-7]{1,3})|([abefnrtv\\'"?]))/);if(y){y[1]?d+=String.fromCharCode(Number.parseInt(y[1],16)):y[2]?d+=String.fromCharCode(Number.parseInt(y[2],8)):d+={a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
298
+ `,r:"\r",t:" ",v:"\v"}[y[3]]??y[3],u+=y[0].length;continue}}(h!=='"'||["$","`",'"',"\\",`
299
+ `].includes(e[u+1]))&&(u+=1)}d+=e[u],u+=1}d&&t.push({delimiter:d,stripTabs:c,expandable:m}),a=u}return t}function U9(e){const t=e.split(`
300
+ `),n=[],r=[],a=[];for(const l of t){if(a.length>0){const u=a[0],c=u.stripTabs?l.replace(/^\t+/,""):l;c===u.delimiter?a.shift():u.expandable&&r.push(c);continue}n.push(l),a.push(...F9(l))}return{command:n.join(`
301
+ `),expandableBodies:r}}function WC(e,t=!0){const n=[];let r=null,a=!1,l=!1,u=!1;for(let c=0;c<e.length;c+=1){const d=e[c];if(l){(d===`
302
+ `||d==="\r")&&(l=!1);continue}if(a){a=!1;continue}if(d==="\\"&&r!=="'"){u=!0,a=!0;continue}if(d==="'"){u=!0,r=r==="'"?null:r===null?"'":r;continue}if(d==='"'){u=!0,r=r==='"'?null:r===null?'"':r;continue}if(r!=="'"){if(!r&&/\s|[;&|(){}]/.test(d)?u=!1:d!=="#"&&(u=!0),t&&d==="#"&&!u){l=!0;continue}if(d==="`"){const h=e.indexOf("`",c+1);h!==-1&&(n.push(e.slice(c+1,h)),c=h);continue}if(d==="$"&&e[c+1]==="("&&e[c+2]!=="("){let h=1,p=null,m=!1;for(let g=c+2;g<e.length;g+=1){const y=e[g];if(m){m=!1;continue}if(y==="\\"&&p!=="'"){m=!0;continue}if(y==="'"||y==='"'){p=p===y?null:p===null?y:p;continue}if(!p&&(y==="("&&(h+=1),y===")"&&(h-=1),h===0)){n.push(e.slice(c+2,g)),c=g;break}}}}}return n}function V9(e){const t=[];let n="",r=!1,a=null,l=!1,u=!1;const c=()=>{r&&t.push(n),n="",r=!1};for(let d=0;d<e.length;d+=1){const h=e[d];if(u){(h===`
303
+ `||h==="\r")&&(u=!1,t.at(-1)!==";"&&t.push(";"));continue}if(l){r=!0,n+=h,l=!1;continue}if(h==="\\"&&a!=="'"){l=!0;continue}if(a){h===a?a=null:n+=h;continue}if(h==="'"||h==='"'){r=!0,a=h;continue}if(h==="$"&&e.slice(d,d+3)==="$(("){let p=1;const m=d;for(let g=d+3;g<e.length-1;g+=1)if(e.slice(g,g+2)==="(("&&(p+=1),e.slice(g,g+2)==="))"&&(p-=1),p===0){r=!0,n+=e.slice(m,g+2),d=g+1;break}continue}if(h==="#"&&!r){u=!0;continue}if(/\s/.test(h)){c(),(h===`
304
+ `||h==="\r")&&t.push(";");continue}if(h===";"||h==="|"||h==="&"||h==="("||h===")"||h==="{"||h==="}"){c(),e[d+1]===h&&(d+=1),t.push(h);continue}r=!0,n+=h}return l&&(n+="\\"),c(),t}function zo(e,t,n){for(;t<e.length;){const r=e[t];if(r==="--")return t+1;if(!r.startsWith("-")||r==="-")return t;t+=1,!r.includes("=")&&n.has(r)&&(t+=1)}return t}function Gr(e,t=0){if(t>8)return null;let n=0;for(;n<e.length&&/^[A-Za-z_][A-Za-z0-9_]*=/.test(e[n]);)n+=1;const r=VC(e[n]??"").toLowerCase();if(r==="env"){for(let u=n+1;u<e.length;u+=1){const c=e[u];if(c==="-S"||c==="--split-string"){const h=e[u+1];return h?Ma(h,t+1):null}const d=c.match(/^--split-string=(.*)$/s);if(d)return Ma(d[1],t+1)}for(n=zo(e,n+1,z9);n<e.length&&/^[A-Za-z_][A-Za-z0-9_]*=/.test(e[n]);)n+=1;return Gr(e.slice(n),t+1)}if(r==="sudo")return n=zo(e,n+1,$9),Gr(e.slice(n),t+1);if(r==="sshpass")return n=zo(e,n+1,H9),Gr(e.slice(n),t+1);if(r==="nix"){const u=e[n+1];if(u==="shell"||u==="develop"){for(let c=n+2;c<e.length;c+=1)if(e[c]==="-c"||e[c]==="--command")return Ma(e.slice(c+1).join(" "),t+1);return null}if(u==="run"){for(let c=n+2;c<e.length;c+=1)if(e[c]==="--"){for(let d=n+2;d<c;d+=1){const h=e[d],p=h.indexOf("#");if(p!==-1){const m=VC(h.slice(p+1).split("@")[0]),g=UC[m.toLowerCase()];if(g)return g}}return null}return null}return null}const a=r,l=UC[a];if(l)return l;if(a==="command"){if(e.slice(n+1).some(c=>c==="-v"||c==="-V"))return null;const u=zo(e,n+1,new Set);return Gr(e.slice(u),t+1)}if(a==="setsid"||a==="nohup"){const u=zo(e,n+1,new Set);return Gr(e.slice(u),t+1)}if(a==="timeout"){const u=zo(e,n+1,new Set(["-k","--kill-after","-s","--signal"]));return Gr(e.slice(u+1),t+1)}if(a==="bash"||a==="sh"||a==="zsh"||a==="fish")for(let u=n+1;u<e.length;u+=1){const c=e[u];if(c!=="--"){if(/^-[^-]*n/.test(c))return null;if(/^-[^-]*c/.test(c)){const d=e[u+1]==="--"?2:1,h=e[u+d];return h?Ma(h,t+1):null}if(!c.startsWith("-"))break}}return null}function Ma(e,t=0){if(t>8)return null;const{command:n,expandableBodies:r}=U9(e),a=[...WC(n),...r.flatMap(m=>WC(m,!1))];for(const m of a){const g=Ma(m,t+1);if(g)return g}const l=V9(n);let u=[];const c=new Set([";","|","&","(",")","{","}"]),d=new Set(["then","do","else","elif","if","while","until"]);let h=!1,p=!1;for(const m of l){if(m==="for"||m==="select"){const g=Gr(u,t);if(g)return g;u=[],h=!0;continue}if(m==="case"){const g=Gr(u,t);if(g)return g;u=[],p=!0;continue}if(h){m==="do"&&(h=!1);continue}if(p&&m===")"){u=[];continue}if(c.has(m)){const g=Gr(u,t);if(g)return g;u=[]}else if(d.has(m)){const g=Gr(u,t);if(g)return g;u=[]}else if(m==="fi"||m==="done"||m==="esac"){const g=Gr(u,t);if(g)return g;u=[],m==="esac"&&(p=!1)}else u.push(m)}return Gr(u,t)}function W9(e,t){return e!=="run_command"||typeof t.command!="string"?null:Ma(t.command)}const G9=600;function q9(e,t,n){let r=(e==null?void 0:e.length)??0;if(t)for(const l of t)r+=l.content.length;const a=n.content;return typeof a=="string"&&(r+=a.length),r}const K9={pending:{icon:"●",color:"text-accent-warning",animate:!0},success:{icon:"✓",color:"text-accent-success",animate:!1},error:{icon:"✗",color:"text-accent-error",animate:!1},interrupted:{icon:"✗",color:"text-text-tool-error",animate:!1}},Y9=E.memo(function({tool:t,args:n,status:r,variant:a="compact",forceCompact:l,result:u,error:c,durationMs:d,diagnostics:h,editContext:p,startedAt:m,streamingOutput:g,metadata:y,truncated:w,callId:C}){var P;const{collapseLargeToolCalls:_}=As(),S=!l&&(!_||r==="pending"||q9(u,g,n)<G9),[b,v]=E.useState(S),k=K9[r],T=W9(t,n),N=Lt(V=>V.settings[je.DISPLAY_SHOW_OPEN_IN_EDITOR])==="true",R=t==="edit_file"?(P=p==null?void 0:p.regions[0])==null?void 0:P.startLine:t==="read_file"?(()=>{const V=u==null?void 0:u.split(`
305
+ `)[0],z=V==null?void 0:V.match(/^(\d+): /);return z?parseInt(z[1],10):void 0})():void 0,A=De(V=>V.pendingPathConfirmations),O=C?A.find(V=>V.callId===C||V.callId.startsWith(C+"-"))??null:null;return t==="step_done"?s.jsxs("div",{className:"flex items-center gap-1.5 text-xs bg-secondary border border-border rounded px-2 py-1.5 my-1",children:[s.jsx("span",{className:`${k.color} ${k.animate?"animate-pulse":""}`,children:k.icon}),s.jsx("span",{className:"font-mono text-accent-primary text-sm",children:t})]}):a==="compact"?s.jsxs("div",{className:`flex items-center gap-1.5 text-xs rounded px-2 py-1.5 border ${T?"border-text-thinking/60 bg-text-thinking/10":"border-transparent bg-secondary"}`,children:[s.jsx(hT,{tool:t}),s.jsx("span",{className:"text-accent-primary font-medium",children:t}),s.jsx("span",{className:"text-text-muted truncate flex-1",children:FC(t,n,y)}),s.jsx("span",{className:`${k.color} ${k.animate?"animate-pulse":""}`,children:r==="pending"?"...":"done"})]}):s.jsxs("div",{className:`border rounded overflow-hidden my-1 min-w-0 ${T?"border-text-thinking/60 shadow-[0_0_0_1px_rgb(var(--color-text-thinking)_/_0.12)]":"border-border"}`,children:[s.jsxs("button",{className:`w-full flex items-center gap-1.5 p-2 text-left ${T?"bg-text-thinking/10 hover:bg-text-thinking/15":"bg-secondary hover:bg-secondary/80"}`,onClick:()=>v(!b),children:[s.jsx("span",{className:`${k.color} ${k.animate?"animate-pulse":""}`,children:k.icon}),s.jsx("span",{className:"font-mono text-accent-primary text-sm",children:t}),s.jsx("span",{className:"text-text-muted text-xs flex-1 truncate",children:FC(t,n,y)}),s.jsx("span",{className:"text-text-muted text-xs",children:b?"▼":"▶"})]}),b&&s.jsxs("div",{className:`p-2 border-t space-y-2 min-w-0 ${T?"border-text-thinking/40 bg-text-thinking/5":"border-border bg-primary"}`,children:[t==="run_command"&&s.jsx(S9,{command:String(n.command??""),timeout:n.timeout??12e4,startedAt:m,streamingOutput:g,status:r,result:u,error:c,durationMs:d}),t==="edit_file"&&r==="success"&&s.jsxs(s.Fragment,{children:[p&&p.regions.length>0?s.jsx(u9,{regions:p.regions,filePath:String(n.path??"")}):s.jsx(l9,{oldString:String(n.old_string??""),newString:String(n.new_string??""),filePath:String(n.path??"")}),h&&h.length>0&&s.jsx(HC,{diagnostics:h})]}),t==="write_file"&&r==="success"&&s.jsxs(s.Fragment,{children:[s.jsx(c9,{content:String(n.content??""),filePath:String(n.path??"")}),h&&h.length>0&&s.jsx(HC,{diagnostics:h})]}),t==="read_file"&&r==="success"&&s.jsx(m9,{result:u,metadata:y,filePath:String(n.path??"")}),t==="return_value"&&(()=>{const V=(g==null?void 0:g.map(W=>W.content).join(""))??"",z=r==="pending"&&V?V:String(n.content??"");return s.jsxs("div",{children:[s.jsx("div",{className:"text-[10px] text-accent-primary font-medium mb-1 uppercase tracking-wide",children:"Sub-Agent Summary"}),s.jsx("div",{className:"text-xs prose prose-invert prose-sm max-w-none",children:s.jsx(sr,{content:z})})]})})(),t==="call_sub_agent"&&s.jsxs("div",{children:[s.jsxs("div",{className:"text-[10px] text-accent-primary font-medium mb-1 uppercase tracking-wide",children:[String(n.subAgentType??"Sub-Agent")," Prompt"]}),s.jsx(bn,{className:"text-xs prose prose-invert prose-sm max-w-none max-h-[60vh]",children:s.jsx(sr,{content:String(n.prompt??"")})})]}),t==="web_search"&&r==="success"&&s.jsxs("div",{children:[s.jsx(bn,{className:"text-xs prose prose-invert prose-sm max-w-none max-h-[60vh]",children:s.jsx(sr,{content:u??""})}),w&&s.jsx(jc,{className:"mt-1"})]}),t==="load_skill"&&r==="success"&&s.jsxs("div",{children:[s.jsxs("div",{className:"text-[10px] text-accent-primary font-medium mb-1 uppercase tracking-wide",children:["Skill: ",String(n.skillId??"")]}),s.jsx(bn,{className:"text-xs prose prose-invert prose-sm max-w-none max-h-[60vh]",children:s.jsx(sr,{content:u??""})}),w&&s.jsx(jc,{className:"mt-1"})]}),t==="web_fetch"&&r==="success"&&s.jsxs("div",{className:"space-y-2",children:[!!(y!=null&&y.url)&&s.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-muted",children:[s.jsx("span",{children:"Source:"}),s.jsx("a",{href:String(y.url),className:"text-accent-primary hover:underline truncate",target:"_blank",rel:"noopener noreferrer",children:String(y.url)}),!!(y!=null&&y.contentType)&&s.jsxs("span",{className:"text-text-muted flex-shrink-0",children:["(",String(y.contentType),")"]}),(y==null?void 0:y.pageCount)!=null&&s.jsxs("span",{className:"text-text-muted flex-shrink-0",children:["· ",String(y.pageCount)," pages"]})]}),s.jsx(bn,{className:"text-xs prose prose-invert prose-sm max-w-none max-h-[60vh]",children:s.jsx(sr,{content:u??""})}),w&&s.jsx(jc,{})]}),t==="dev_server"&&r==="success"&&u&&s.jsx(w9,{result:u,action:String(n.action??"")}),t==="workspace"&&r==="success"&&u&&s.jsx(R9,{result:u,action:String(n.action??"")}),t==="background_process"&&r==="success"&&u&&s.jsx(E9,{result:u,action:String(n.action??"")}),t==="mcp_config"&&r==="success"&&s.jsxs("div",{children:[s.jsx(bn,{className:"text-xs prose prose-invert prose-sm max-w-none max-h-[60vh]",children:s.jsx(sr,{content:u??""})}),w&&s.jsx(jc,{className:"mt-1"})]}),t==="step_done"&&null,t!=="edit_file"&&t!=="write_file"&&t!=="run_command"&&t!=="read_file"&&t!=="return_value"&&t!=="call_sub_agent"&&t!=="web_search"&&t!=="load_skill"&&t!=="web_fetch"&&t!=="dev_server"&&t!=="workspace"&&t!=="background_process"&&t!=="mcp_config"&&t!=="step_done"&&s.jsxs(s.Fragment,{children:[Object.keys(n).length>0&&s.jsxs("div",{children:[s.jsx("div",{className:"text-[10px] text-text-muted mb-0.5",children:"Arguments:"}),s.jsx(bn,{horizontal:!0,children:s.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded break-words",children:B9(n)})})]}),r==="success"&&u!==void 0&&s.jsxs("div",{children:[s.jsxs("div",{className:"text-[10px] text-text-muted mb-0.5",children:["Result",d!==void 0&&` (${d}ms)`,":"]}),s.jsx(bn,{horizontal:!0,className:"max-h-[60vh]",children:s.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded break-words",children:u||"No output"})}),w&&s.jsx(jc,{className:"mt-1"})]})]}),(T||r==="success"&&d!==void 0&&(t==="run_command"||t==="edit_file"||t==="write_file"||t==="read_file"))&&s.jsxs("div",{className:"text-[10px] text-text-muted flex items-center gap-2",children:[r==="success"&&d!==void 0&&(t==="run_command"||t==="edit_file"||t==="write_file"||t==="read_file")&&s.jsxs("span",{children:["Completed in ",(d/1e3).toFixed(2),"s"]}),s.jsx("span",{className:"flex-1"}),N&&(t==="read_file"||t==="write_file"||t==="edit_file")&&String((y==null?void 0:y.path)??n.path??"")&&s.jsx("a",{href:rT(String((y==null?void 0:y.path)??n.path),R),className:"text-accent-primary hover:underline",children:"Open in VSCode"}),T&&s.jsxs("span",{className:"shrink-0 rounded border border-text-thinking/50 bg-text-thinking/15 px-1.5 py-0.5 font-semibold tracking-wide text-text-thinking",children:["REMOTE · ",T]})]}),r==="error"&&c&&t!=="run_command"&&s.jsxs("div",{children:[s.jsx("div",{className:"text-[10px] text-accent-error mb-0.5",children:"Error:"}),s.jsx("pre",{className:"text-xs bg-bg-primary p-1.5 rounded text-accent-error break-words",children:c})]}),O&&s.jsx(M9,{confirmation:O})]})]})}),X9={read_file:"Reading file",write_file:"Writing file",edit_file:"Editing file",run_command:"Running command",glob:"Searching files",grep:"Searching content",ask_user:"Asking user",criterion:"Managing criterion",session_metadata:"Managing",todo_write:"Updating tasks"};function Q9(e,t){const n=X9[e];if(!n)return`Preparing ${e}`;if(e==="session_metadata"&&t)try{const a=JSON.parse(t).key;if(a){const l=b7(a);return`${n} ${l}`}}catch{}return n}function J9(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 Z9=E.memo(function({name:t,arguments:n}){let a=Q9(t,n)+"...",l=null;if(t==="run_command"&&n){const u=J9(n);u&&(a=u,l=Ma(u))}return s.jsx("div",{className:`border rounded overflow-hidden my-1 min-w-0 animate-pulse ${l?"border-text-thinking/60 shadow-[0_0_0_1px_rgb(var(--color-text-thinking)_/_0.12)]":"border-border"}`,children:s.jsxs("div",{className:`flex items-center gap-1.5 p-2 ${l?"bg-text-thinking/10":"bg-bg-tertiary"}`,children:[s.jsx("span",{className:"text-accent-warning animate-pulse",children:"..."}),s.jsx(hT,{tool:t}),s.jsx("span",{className:"font-mono text-accent-primary text-sm",children:t}),t==="run_command"&&n?s.jsx("code",{className:"text-text-muted text-xs flex-1 truncate",children:a}):s.jsx("span",{className:"text-text-muted text-xs flex-1",children:a})]})})}),eU={pending:{icon:"○",color:"text-text-muted"},in_progress:{icon:"●",color:"text-accent-warning",animate:!0},completed:{icon:"✓",color:"text-accent-success"}},tU=E.memo(function({todos:t}){return Array.isArray(t)?t.length===0?s.jsx("div",{className:"text-xs text-text-muted italic my-1",children:"No tasks"}):s.jsxs("div",{className:"my-1 rounded border border-border bg-bg-tertiary overflow-hidden",children:[s.jsx("div",{className:"px-2 py-1.5 border-b border-border bg-bg-secondary",children:s.jsx("span",{className:"text-xs font-medium text-text-muted",children:"Tasks"})}),s.jsx("div",{children:t.map((n,r)=>{const a=eU[n.status];return s.jsxs("div",{className:`flex items-start gap-2 px-2 py-1.5 ${r>0?"border-t border-border":""}`,children:[s.jsx("span",{className:`${(a==null?void 0:a.color)??"text-text-muted"} ${a!=null&&a.animate?"animate-pulse":""} text-sm leading-tight`,children:(a==null?void 0:a.icon)??"○"}),s.jsx("span",{className:`text-sm leading-tight ${n.status==="completed"?"text-text-muted":"text-text-primary"}`,children:n.content})]},r)})})]}):s.jsx("div",{className:"text-xs text-accent-warning italic my-1",children:"⚠️ Invalid todos data"})});function nU(e){if(e==null)return;if(typeof e=="string"){const n=e.split(",").map(r=>r.trim()).filter(r=>r.length>0);return n.length>0?n.map(r=>({value:r,label:r})):void 0}if(!Array.isArray(e))return;const t=[];for(const n of e){if(typeof n=="string"){const r=n.trim();r.length>0&&t.push({value:r,label:r});continue}if(n!=null&&typeof n=="object"){const r=n,a=r.label,l=r.value;if(typeof a=="string"&&a.trim().length>0){const u=a.trim(),c=typeof l=="string"&&l.length>0?l:u,d=r.description,h={value:c,label:u};typeof d=="string"&&d.length>0&&(h.description=d),t.push(h)}}}return t.length>0?t:void 0}function rU({toolCall:e}){var T;const t=De(N=>N.pendingQuestions),n=De(N=>N.answerQuestion),[r,a]=E.useState(""),l=E.useRef(null),u=E.useRef(null),c=t.find(N=>N.callId===e.id),d=e.arguments.question??(c==null?void 0:c.question)??"",h=e.arguments.type??(c==null?void 0:c.type)??"text",p=e.arguments.options??(c==null?void 0:c.options)??void 0,m=nU(p),g=e.result!==void 0,y=c!==void 0&&!g,w=((T=e.result)==null?void 0:T.output)??"",C=w==="[user skipped]";E.useEffect(()=>{y&&Bt()&&l.current&&l.current.focus()},[y]),E.useEffect(()=>{y&&u.current&&u.current.scrollIntoView({behavior:"smooth",block:"nearest"})},[y]);const _=E.useCallback(()=>{c&&n(c.callId,r)},[c,r,n]),S=E.useCallback(()=>{c&&n(c.callId,"",!0)},[c,n]),b=E.useCallback(N=>{N.key==="Enter"&&!N.shiftKey&&(N.preventDefault(),_()),N.key==="Escape"&&!N.shiftKey&&(N.preventDefault(),S())},[_,S]),v=E.useCallback(N=>{c&&n(c.callId,N)},[c,n]),k="px-3 py-1.5 text-xs font-medium rounded transition-colors";return s.jsxs("div",{ref:u,className:"my-1",children:[s.jsx("div",{className:"text-sm text-text-primary",children:d}),y&&s.jsx("div",{className:"mt-2 border border-border rounded overflow-hidden",children:s.jsx("div",{className:"p-3 bg-primary space-y-2",children:h==="confirm"?s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{onClick:()=>v("yes"),className:`${k} flex-1 bg-accent-success/20 hover:bg-accent-success/30 text-accent-success border border-accent-success/30`,children:"Yes"}),s.jsx("button",{onClick:()=>v("no"),className:`${k} flex-1 bg-accent-error/20 hover:bg-accent-error/30 text-accent-error border border-accent-error/30`,children:"No"}),s.jsx("button",{onClick:S,className:`${k} bg-bg-tertiary hover:bg-bg-tertiary/80 text-text-secondary border border-border`,children:"Skip"})]}):h==="choice"&&m!==void 0&&m.length>0?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"flex flex-col gap-1.5",children:m.map((N,R)=>s.jsxs("button",{onClick:()=>v(N.value),className:`${k} text-left w-full bg-bg-tertiary hover:bg-accent-primary/20 text-text-primary border border-border hover:border-accent-primary/50`,children:[s.jsx("span",{className:"block font-medium",children:N.label}),N.description!==void 0&&s.jsx("span",{className:"block text-xs text-text-muted mt-0.5",children:N.description})]},R))}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("textarea",{ref:l,value:r,onChange:N=>a(N.target.value),onKeyDown:b,placeholder:"Or type your own answer... (Enter to submit)",className:"flex-1 min-h-[36px] max-h-[80px] px-2 py-1.5 bg-bg-tertiary border border-border rounded text-xs text-text-primary placeholder:text-text-muted focus:outline-none focus:ring-2 focus:ring-accent-primary/50 resize-y",rows:1}),s.jsx("button",{onClick:_,disabled:!r.trim(),className:`${k} bg-accent-primary/25 hover:bg-accent-primary/40 text-text-primary disabled:opacity-50 disabled:cursor-not-allowed`,children:"Send"}),s.jsx("button",{onClick:S,className:`${k} bg-bg-tertiary hover:bg-bg-tertiary/80 text-text-secondary border border-border`,children:"Skip"})]})]}):s.jsxs(s.Fragment,{children:[s.jsx("textarea",{ref:l,value:r,onChange:N=>a(N.target.value),onKeyDown:b,placeholder:"Type your answer here... (Enter to submit, Shift+Enter for new line)",className:"w-full min-h-[80px] px-3 py-2 bg-bg-tertiary border border-border rounded text-sm text-text-primary placeholder:text-text-muted focus:outline-none focus:ring-2 focus:ring-accent-primary/50 resize-y",autoFocus:Bt()}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx("button",{onClick:S,className:`${k} bg-bg-tertiary hover:bg-bg-tertiary/80 text-text-secondary border border-border`,children:"Skip"}),s.jsx("button",{onClick:_,disabled:!r.trim(),className:`${k} bg-accent-primary/25 hover:bg-accent-primary/40 text-text-primary disabled:opacity-50 disabled:cursor-not-allowed`,children:"Send Answer"})]})]})})}),g&&s.jsx("div",{className:"mt-1 flex items-center gap-2",children:s.jsx("span",{className:`text-xs ${C?"text-amber-400":"text-accent-success"}`,children:C?"Skipped":`Answered: ${w}`})})]})}const GC={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"}},sU=E.memo(function({toolCalls:t,criteria:n}){if(t.length===0)return null;const r=new Map((n==null?void 0:n.map(c=>[c.id,c]))??[]),a=t.find(c=>{var d,h;return c.arguments.action==="get"&&((d=c.result)==null?void 0:d.success)&&((h=c.result)==null?void 0:h.output)}),l=t.some(c=>c.name==="session_metadata"),u=(()=>{if(!l)return"Acceptance Criteria";const c=new Set(t.map(d=>d.arguments.key).filter(Boolean));if(c.size===1){const d=c.values().next().value;return d?sl(d):"Session Data"}return"Session Data"})();return s.jsxs("div",{className:"my-1 rounded border border-border bg-secondary overflow-hidden",children:[s.jsx("div",{className:"px-2 py-1.5 border-b border-border bg-secondary",children:s.jsx("span",{className:"text-xs font-medium text-text-muted",children:u})}),s.jsx("div",{className:"bg-primary",children:a?(()=>{const c=a.result.output;if(c==="No criteria defined yet.")return s.jsxs("div",{className:"flex items-start gap-2 px-2 py-1.5",children:[s.jsx("span",{className:"text-text-muted text-sm leading-tight flex-shrink-0",children:"○"}),s.jsx("div",{className:"flex-1 min-w-0 text-text-muted text-sm",children:"No criteria defined yet."})]});try{return JSON.parse(c).map((h,p)=>s.jsxs("div",{className:`flex items-start gap-2 px-2 py-1.5 ${p>0?"border-t border-border":""}`,children:[s.jsx("span",{className:"text-text-muted text-sm leading-tight flex-shrink-0",children:"○"}),s.jsx("div",{className:"flex-1 min-w-0",children:s.jsx(sr,{content:`[${h.id}] ${h.description}`})})]},h.id??p))}catch{return t.map((d,h)=>s.jsx(qC,{tc:d,index:h,criteriaMap:r},d.id??h))}})():t.map((c,d)=>s.jsx(qC,{tc:c,index:d,criteriaMap:r},c.id??d))})]})});function qC({tc:e,index:t,criteriaMap:n}){const r=e.arguments.action,a=e.arguments,l=e.name==="session_metadata",u=r==="remove",c=a.id,d=a.description,h=c?n.get(c):void 0,p=d??(h==null?void 0:h.description)??(u&&c?`[${c}]`:"Criterion updated"),m=a.reason,g=r==="fail";return s.jsxs("div",{className:`flex items-start gap-2 px-2 py-1.5 ${t>0?"border-t border-border":""}`,children:[l?s.jsx(wl,{status:a.status,className:"text-sm leading-tight flex-shrink-0"}):(()=>{const y=r&&GC[r]?GC[r]:{icon:"○",color:"text-text-muted"};return s.jsx("span",{className:`${y.color} text-sm leading-tight flex-shrink-0`,children:y.icon})})(),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:u?"line-through text-text-muted":"",children:s.jsx(sr,{content:p})}),m&&s.jsxs("div",{className:`mt-1 text-sm ${g?"text-accent-error":"text-text-muted"}`,children:[s.jsx("span",{className:"text-text-muted",children:"└ "}),'"',m,'"']})]})]})}function iU(e){return e==="criterion"||e==="session_metadata"}const aU="[interrupted by user]";function oU(e){if(!e)return"pending";const t=e.output??"";return!e.success&&t.trimEnd().endsWith(aU)?"interrupted":e.success?"success":"error"}async function pT(e){if(navigator.clipboard){await navigator.clipboard.writeText(e);return}const t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.left="-999999px",document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)}function lU({items:e,position:t,onClose:n}){const r=E.useRef(null),[a,l]=E.useState(-1);if(E.useEffect(()=>{t&&l(-1)},[t]),E.useEffect(()=>{var p;if(!t)return;function d(m){r.current&&!r.current.contains(m.target)&&n()}function h(m){var g;switch(m.key){case"Escape":m.preventDefault(),n();break;case"ArrowDown":m.preventDefault(),l(y=>y<e.length-1?y+1:0);break;case"ArrowUp":m.preventDefault(),l(y=>y>0?y-1:e.length-1);break;case"Enter":m.preventDefault(),(g=e[a])==null||g.onClick(),n();break}}return document.addEventListener("mousedown",d),window.addEventListener("keydown",h,!0),window.addEventListener("blur",n),(p=r.current)==null||p.focus(),()=>{document.removeEventListener("mousedown",d),window.removeEventListener("keydown",h,!0),window.removeEventListener("blur",n)}},[t,e,a,n]),!t)return null;let u=Math.min(t.x,window.innerWidth-190),c=Math.min(t.y,window.innerHeight-100);return u=Math.max(8,u),c=Math.max(8,c),ui.createPortal(s.jsx("div",{ref:r,tabIndex:-1,className:"fixed bg-bg-secondary border border-border rounded shadow-lg z-50 min-w-[160px] outline-none",style:{left:u,top:c},children:s.jsx(ct,{className:"max-h-[60vh]",onMouseLeave:()=>l(-1),children:e.map((d,h)=>s.jsxs("button",{onClick:()=>{d.onClick(),n()},onMouseEnter:()=>l(h),className:`w-full px-3 py-2 text-left text-sm flex items-center gap-2 transition-colors ${h<e.length-1?"border-b border-border":""} ${d.danger?"text-accent-error hover:bg-accent-error/10":h===a?"bg-accent-primary/20 text-text-primary":"hover:bg-bg-tertiary text-text-primary"}`,children:[d.icon&&s.jsx("span",{className:"w-4 h-4 flex-shrink-0",children:d.icon}),d.label]},h))})}),document.body)}function gT(){const[e,t]=E.useState(null);return{onContextMenu:E.useCallback((a,l)=>{var c;if(!l||(c=window.getSelection())!=null&&c.toString())return;const u=a.target instanceof Element?a.target:null;u!=null&&u.closest("a")||(a.preventDefault(),t({x:a.clientX,y:a.clientY}))},[]),contextMenu:a=>s.jsx(lU,{position:e,onClose:()=>t(null),items:a})}}function cU(e){const t=[];let n=[];const r=()=>{n.length>0&&(t.push({type:"criteria_group",toolCalls:n}),n=[])};for(const a of e)a.type==="tool_call"&&iU(a.toolCall.name)?n.push(a.toolCall):(r(),t.push(a));return r(),t}function uU(e,t){if(e.segments&&e.segments.length>0)return dU(e.segments,e.toolCalls??[],e.preparingToolCalls??[],e.stats,t);const n=[];if(e.thinkingContent&&n.push({type:"thinking",content:e.thinkingContent}),e.content&&n.push({type:"text",content:e.content}),e.toolCalls)for(const r of e.toolCalls)n.push({type:"tool_call",toolCall:r});if(e.preparingToolCalls)for(const r of e.preparingToolCalls)n.push({type:"preparing_tool_call",preparing:r});return t&&e.stats&&n.push({type:"stats",stats:e.stats}),n}function dU(e,t,n,r,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&&r&&l.push({type:"stats",stats:r}),l}const Ob=E.memo(function({message:t,showStats:n=!0,showThinking:r=!0,showVerboseToolOutput:a=!0,sessionId:l}){const u=De(N=>{var R,A;return(A=(R=N.currentSession)==null?void 0:R.metadataEntries)==null?void 0:A.criteria}),c=ft(N=>N.defaults),d=ft(N=>N.userItems),h=[...c,...d],p=uU(t,n),m=r?p:p.filter(N=>N.type!=="thinking"),g=cU(m),[y,w]=E.useState(!1),[C,_]=E.useState(null),[,S]=Gn(),{onContextMenu:b,contextMenu:v}=gT();if(g.length===0)return null;const k=()=>{pT(t.content)},T=async()=>{if(!l||y)return;w(!0),_(null);const N=await mE(l,t.id);w(!1),N!=null&&N.session?S(`/p/${N.session.projectId}/s/${N.session.id}`):_("Failed to fork session")};return s.jsxs("div",{className:"feed-item",onContextMenu:N=>b(N,!!l),children:[s.jsxs("div",{className:"min-w-0",children:[C&&s.jsx("p",{className:"text-xs text-accent-error mb-1 ml-0.5",children:C}),g.map((N,R)=>{switch(N.type){case"thinking":return s.jsx(v9,{content:N.content},R);case"text":return s.jsx("div",{className:"prose prose-sm prose-invert max-w-none feed-item",children:s.jsx(sr,{content:N.content,isStreaming:t.isStreaming})},R);case"preparing_tool_call":return s.jsx(Z9,{name:N.preparing.name,arguments:N.preparing.arguments},`preparing-${N.preparing.index}`);case"tool_call":{const A=N.toolCall,O=A.result;if(A.name==="ask_user")return s.jsx(rU,{toolCall:A},R);if(A.name==="todo_write"){const V=A.arguments.todos,z=Array.isArray(V)?V:[];return s.jsx(tU,{todos:z},R)}const P=oU(O);return s.jsx(Y9,{tool:A.name,args:A.arguments,status:P,variant:"expandable",forceCompact:!a,result:O==null?void 0:O.output,error:O==null?void 0:O.error,durationMs:O==null?void 0:O.durationMs,diagnostics:O==null?void 0:O.diagnostics,editContext:O==null?void 0:O.editContext,startedAt:A.startedAt,streamingOutput:A.streamingOutput,metadata:O==null?void 0:O.metadata,truncated:(O==null?void 0:O.truncated)??!1,callId:A.id},R)}case"criteria_group":return s.jsx(sU,{toolCalls:N.toolCalls,criteria:u},R);case"stats":{const A=N.stats;if(!A||"error"in A)return null;const O=A.model.split("/").pop()??A.model,P=ul(h,A.mode),V=h.find(U=>U.id===A.mode),z=(V==null?void 0:V.name)??A.mode,W=U=>U>=1e3?`${(U/1e3).toFixed(1)}k`:U.toString(),M=U=>U>=1e3?`${(U/1e3).toFixed(1)}k`:U.toFixed(1);return s.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-[10px] text-text-muted",children:[s.jsx("span",{className:"flex-1 h-px bg-border"}),s.jsx("span",{className:"text-text-secondary",children:O}),s.jsx("span",{className:"text-text-muted",children:"·"}),s.jsx("span",{style:{color:P},children:z}),s.jsx("span",{className:"text-text-muted",children:"·"}),s.jsx("span",{children:Es(A.totalTime)}),A.toolTime>0&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-text-muted",children:"·"}),s.jsxs("span",{children:[Es(A.toolTime)," tools"]})]}),s.jsx("span",{className:"text-text-muted",children:"·"}),s.jsxs("span",{children:[W(A.prefillTokens)," @ ",M(A.prefillSpeed)," pp"]}),s.jsx("span",{className:"text-text-muted",children:"·"}),s.jsxs("span",{children:[W(A.generationTokens)," @ ",M(A.generationSpeed)," tg"]}),s.jsx("span",{className:"text-text-muted",children:"·"}),s.jsx("button",{type:"button",className:"text-text-muted hover:text-text-secondary transition-colors",title:"View detailed stats",onClick:()=>{const U=new CustomEvent("open-turn-stats",{detail:{stats:A}});window.dispatchEvent(U)},children:s.jsx(Py,{className:"w-3 h-3"})}),s.jsx("span",{className:"flex-1 h-px bg-border"})]},R)}}}),t.partial&&s.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-accent-warning mt-1",children:[s.jsx(Tx,{}),s.jsx("span",{children:"Aborted"})]}),t.completeReason==="truncated"&&s.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-text-truncated mt-1",children:[s.jsx(Tx,{}),s.jsx("span",{children:"Response was truncated — the model ran out of output tokens."})]})]}),v([{label:"Copy",icon:s.jsx(Yc,{className:"w-4 h-4"}),onClick:()=>k()},{label:"Fork session from here",icon:s.jsx(Fa,{className:"w-4 h-4"}),onClick:()=>void T()}])]})});function ef(e,t){const n=parseInt(e.slice(1,3),16),r=parseInt(e.slice(3,5),16),a=parseInt(e.slice(5,7),16);return`rgba(${n},${r},${a},${t})`}function hU(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}const fU=E.memo(function({data:t}){var a;const n=Uf(),r=(t.workflowId?(a=Zh(n,t.workflowId))==null?void 0:a.color:void 0)??t.workflowColor??"#8b949e";return s.jsxs("div",{"data-testid":"task-completed-card",className:"feed-item rounded p-3 border",style:{borderColor:ef(r,.3),backgroundColor:ef(r,.08)},children:[s.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[s.jsx(B3,{color:r}),s.jsx("span",{className:"text-sm font-medium",style:{color:r},children:t.workflowName??"Task Completed"})]}),s.jsxs("div",{className:"grid grid-cols-3 sm:grid-cols-5 gap-2",children:[s.jsx(Nc,{label:"Iterations",value:String(t.iterations)}),s.jsx(Nc,{label:"Total time",value:Es(t.totalTimeSeconds)}),s.jsx(Nc,{label:"Tool calls",value:String(t.totalToolCalls)}),s.jsx(Nc,{label:"Tokens",value:hU(t.totalTokensGenerated)}),s.jsx(Nc,{label:"Speed",value:t.avgGenerationSpeed>0?`${t.avgGenerationSpeed} tok/s`:"-"})]})]})});function Nc({label:e,value:t}){return s.jsxs("div",{className:"bg-bg-primary/50 rounded px-2 py-1",children:[s.jsx("div",{className:"text-sm text-text-muted",children:e}),s.jsx("div",{className:"text-sm text-text-primary font-medium",children:t})]})}const mU=E.memo(function({data:t}){var a;const n=Uf(),r=((a=Zh(n,t.workflowId))==null?void 0:a.color)??t.workflowColor??"#6b7280";return s.jsxs("div",{className:"feed-item flex items-center gap-2 px-3 py-2 rounded border",style:{borderColor:ef(r,.3),backgroundColor:ef(r,.08)},children:[s.jsx(TE,{className:"w-3 h-3 shrink-0",color:r}),s.jsx("span",{className:"text-sm font-medium",style:{color:r},children:t.workflowName}),s.jsx("span",{className:"text-text-muted text-sm",children:"started"})]})}),pU=["text/"],gU=["application/json","application/xml","application/yaml","application/x-yaml","application/javascript","application/xhtml+xml","application/x-sh","image/svg+xml"];function Sh(e){return e.startsWith("image/")}function xT(e){return e.startsWith("image/")&&e!=="image/svg+xml"}function Ib(e){return gU.includes(e)||pU.some(t=>e.startsWith(t))}function Jo(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function yT(e){const t=e.lastIndexOf(".");return t<=0||t>=e.length-1?"FILE":e.slice(t+1).toUpperCase()}const xU={"text/plain":"txt","text/csv":"csv","text/html":"html","text/markdown":"md","text/javascript":"js","text/xml":"xml","text/x-yaml":"yaml","text/x-sh":"sh","text/tab-separated-values":"tsv","text/x-python":"py","text/x-java-source":"java","text/x-json":"json","text/x-typescript":"ts","text/css":"css","application/json":"json","application/xml":"xml","application/yaml":"yaml","application/x-yaml":"yaml","application/javascript":"js","application/xhtml+xml":"xhtml","application/x-sh":"sh","application/pdf":"pdf","image/png":"png","image/jpeg":"jpg","image/gif":"gif","image/webp":"webp","image/bmp":"bmp","image/svg+xml":"svg"};function yU(e){var t;return xU[e]||((t=e.split("/")[1])==null?void 0:t.split("+")[0])||"file"}function bU(e){return Sh(e)||Ib(e)||e==="application/pdf"}function vU({attachments:e,messageId:t}){const[n,r]=E.useState(null),a=De(p=>p.visionFallbackByMessage),l=De(p=>p.messages),u=E.useMemo(()=>{const p=l.findIndex(m=>m.id===t);if(p===-1)return null;for(let m=p+1;m<l.length;m++){const g=l[m];if(g&&g.role==="assistant")return g.id}return null},[l,t]),c=p=>{r(p)},d=()=>{r(null)},h=p=>{const m=`${t}-${p}`;if(a[m])return a[m];if(u){const g=`${u}-${p}`;return a[g]}return null};return e.length===0?null:s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"mt-3 flex flex-wrap gap-3",children:e.map(p=>{const m=h(p.id);return xT(p.mimeType)?s.jsxs("div",{className:"relative inline-block",children:[s.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:[s.jsx("img",{src:p.data,alt:(m==null?void 0:m.type)==="done"&&m.description||p.description||p.filename,className:"max-w-[256px] max-h-[256px] object-contain rounded-lg border border-border hover:border-accent-primary transition-colors cursor-pointer"}),(m==null?void 0:m.type)==="start"&&s.jsx("div",{className:"absolute inset-0 bg-black/60 flex items-center justify-center rounded-lg",children:s.jsx("span",{className:"text-xs text-text-primary animate-pulse",children:"Describing image..."})})]}),(m==null?void 0:m.type)==="done"&&m.description&&s.jsxs("div",{className:"mt-2 p-2 bg-bg-tertiary rounded text-xs text-text-secondary max-w-[256px]",children:[m.description.slice(0,200),m.description.length>200?"...":""]})]},p.id):s.jsxs("div",{className:"inline-flex items-start gap-3 p-3 bg-bg-tertiary rounded-lg border border-border max-w-[300px]",children:[s.jsx("div",{className:"w-10 h-10 flex items-center justify-center rounded-md bg-bg-secondary text-sm font-bold text-text-muted shrink-0",children:yT(p.filename)}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"text-xs text-text-primary truncate font-medium",title:p.filename,children:p.filename}),s.jsx("div",{className:"text-[10px] text-text-muted",children:Jo(p.size)}),Ib(p.mimeType)&&p.data&&s.jsxs("div",{className:"mt-1.5 text-[10px] text-text-muted leading-relaxed line-clamp-3 font-mono break-all",children:[p.data.slice(0,200),p.data.length>200?"...":""]})]})]},p.id)})}),n&&s.jsx(uT,{src:n,alt:"Attached image",isOpen:!0,onClose:d})]})}function bT({attachment:e,onRemove:t}){const n=yT(e.filename);return s.jsxs("div",{className:"relative inline-flex flex-col items-center p-2 bg-bg-tertiary rounded-lg border border-border",children:[s.jsx(vu,{onClick:()=>t(e.id),className:"absolute -top-2 -right-2",size:"sm",variant:"overlay","aria-label":`Remove ${e.filename}`}),xT(e.mimeType)?s.jsx("img",{src:e.data,alt:e.description||e.filename,className:"w-16 h-16 object-cover rounded-md bg-bg-secondary"}):s.jsx("div",{className:"w-16 h-16 flex items-center justify-center rounded-md bg-bg-secondary text-xs font-bold text-text-muted",children:n}),s.jsx("div",{className:"mt-1 text-xs text-text-muted text-center max-w-16 truncate",title:e.filename,children:e.filename}),s.jsx("div",{className:"text-[10px] text-text-muted",children:Jo(e.size)})]})}function _U({message:e}){const[t,n]=E.useState(!1);if(e.messageKind!=="auto-prompt")return null;const r=e.metadata,a=(r==null?void 0:r.color)??"#6b7280",l=(r==null?void 0:r.type)??"agent",u=l==="workspace"?"Workspace":(r==null?void 0:r.name)??"Agent",d={agent:(r==null?void 0:r.kind)==="reminder"?"reminder":"definition injected",workflow:"instructions",compaction:"prompt injected",subagent:"instructions",workspace:`${(r==null?void 0:r.workspaceName)??""} · ${(r==null?void 0:r.branchName)??""}`,branch:`🌿 ${(r==null?void 0:r.branchName)??""}`}[l]??"injected",h=l==="workflow"||l==="subagent";return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-center gap-1.5 text-[10px] text-text-muted font-mono mt-3 mb-4",children:[s.jsx("span",{className:"flex-1 h-px bg-border"}),s.jsx("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${h?"":"cursor-pointer"}`,style:{backgroundColor:a},onClick:()=>!h&&n(!0)}),s.jsx("span",{className:h?"":"cursor-pointer hover:text-text-secondary transition-colors",style:{color:a},onClick:()=>!h&&n(!0),children:u}),s.jsx("span",{children:"·"}),s.jsx("span",{className:h?"":"cursor-pointer hover:text-text-secondary transition-colors",onClick:()=>!h&&n(!0),children:d}),s.jsx("span",{className:"flex-1 h-px bg-border"})]}),h&&s.jsx("div",{className:"flex justify-center feed-item mb-4",children:s.jsx(ct,{horizontal:!0,className:"max-w-[75%] rounded p-3 bg-bg-tertiary/50 text-text-secondary text-sm",style:{borderLeft:`3px solid ${a}`},children:s.jsx("pre",{className:"whitespace-pre-wrap break-words font-mono text-xs",children:e.content})})}),s.jsx(jt,{isOpen:t,onClose:()=>n(!1),title:`${u} Prompt`,size:"lg",children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"w-3 h-3 rounded-full",style:{backgroundColor:a}}),s.jsx("span",{className:"text-sm text-text-primary font-medium",children:u}),s.jsxs("span",{className:"text-xs text-text-muted",children:["(",l,")"]})]}),s.jsx("div",{className:"h-full min-h-96",children:s.jsx(ct,{horizontal:!0,className:"h-full min-h-96",children:s.jsx("pre",{className:"text-sm text-text-secondary whitespace-pre-wrap break-words bg-bg-tertiary rounded p-4 h-full min-h-96 font-mono",children:e.content})})})]})})]})}const hy="openfox:feed-reveal",tf="openfox:autoscroll-rearm";function SU({message:e,messageId:t,sessionId:n}){const r=e.messageKind==="auto-prompt",a=e.messageKind==="command",l=e.isSystemGenerated,u=De(D=>D.loadSession),[,c]=Gn(),[d,h]=E.useState(!1),[p,m]=E.useState(!1),[g,y]=E.useState(!1),[w,C]=E.useState(e.content),[_,S]=E.useState(e.attachments??[]),[b,v]=E.useState(!1),[k,T]=E.useState(!1),[N,R]=E.useState(null),[A,O]=E.useState(null),P=E.useRef(null),{onContextMenu:V,contextMenu:z}=gT(),W=E.useCallback(()=>{const D=P.current;D&&(D.style.height="auto",D.style.height=`${D.scrollHeight}px`)},[]),M=async()=>{try{await pT(e.content),m(!0),window.setTimeout(()=>m(!1),1500)}catch{}},U=async()=>{if(!n||!t||k)return;T(!0),R(null);const D=await mE(n,t);if(T(!1),D!=null&&D.session){const q=D.session.projectId;c(`/p/${q}/s/${D.session.id}`)}else R("Failed to fork session")},F=async()=>{if(!n||!t||b)return;v(!0),O(null);const D=await m1(n,t);v(!1),D?(window.dispatchEvent(new CustomEvent(tf)),u(n,!0)):O("Failed to replay")},Q=async()=>{if(!n||!t||!w.trim()||b)return;v(!0),O(null);const D=await m1(n,t,w,_);v(!1),D?(window.dispatchEvent(new CustomEvent(tf)),u(n,!0),y(!1)):O("Failed to send")},X=()=>{C(e.content),S(e.attachments??[]),y(!1),O(null)},I=`flex items-center gap-0.5 self-end transition-[visibility,opacity] focus-within:visible focus-within:opacity-100 ${d&&!g&&!b?"visible opacity-100":"invisible opacity-0"}`;return s.jsxs("div",{className:"flex justify-end items-start gap-1.5 feed-item",onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),onContextMenu:D=>V(D,!!n&&!!t),children:[!l&&s.jsxs("div",{className:I,children:[s.jsx("button",{onClick:()=>{M()},title:"Copy",disabled:b,className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary disabled:opacity-50",children:p?s.jsx(Ls,{className:"w-3.5 h-3.5 text-accent-success"}):s.jsx(Yc,{className:"w-3.5 h-3.5"})}),n&&t&&s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:()=>{O(null),C(e.content),S(e.attachments??[]),y(!0)},title:"Edit & resend",disabled:b,className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary disabled:opacity-50",children:s.jsx(kE,{className:"w-3.5 h-3.5"})}),s.jsx("button",{onClick:()=>{F()},title:"Replay",disabled:b,className:"p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary disabled:opacity-50",children:s.jsx(xf,{className:"w-3.5 h-3.5"})})]})]}),s.jsxs("div",{className:`max-w-[75%] ${g?"w-full":""} rounded p-2 ${l?"bg-bg-system border border-border-system":"bg-accent-primary/15 text-text-primary"}`,children:[l&&s.jsx("span",{className:"text-[10px] block mb-0.5 text-text-system",children:a?"Command":r?"Auto":"System"}),g?s.jsxs("div",{className:"flex flex-col gap-1.5",children:[s.jsx("textarea",{ref:D=>{P.current=D,D&&(D.style.height="auto",D.style.height=`${D.scrollHeight}px`)},className:"w-full bg-bg-primary border border-border rounded p-1.5 text-sm text-text-primary resize-none focus:outline-none focus:border-accent-primary min-h-[60px] overflow-hidden disabled:opacity-50",value:w,onChange:D=>{C(D.target.value),W()},onKeyDown:D=>{D.key==="Enter"&&!D.shiftKey&&(D.preventDefault(),Q()),D.key==="Escape"&&X()},disabled:b,autoFocus:Bt()}),_.length>0&&s.jsx("div",{className:"flex flex-wrap gap-2",children:_.map(D=>s.jsx(bT,{attachment:D,onRemove:q=>S($=>$.filter(J=>J.id!==q))},D.id))}),A&&s.jsx("p",{className:"text-xs text-accent-error",children:A}),s.jsxs("div",{className:"flex justify-end gap-1.5",children:[s.jsx("button",{onClick:X,disabled:b,className:"px-4 py-1.5 rounded text-sm bg-bg-tertiary/50 text-text-muted hover:bg-bg-tertiary hover:text-text-primary transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:"Cancel"}),s.jsx("button",{onClick:()=>{Q()},disabled:b||!w.trim(),className:"px-4 py-1.5 rounded text-sm bg-accent-primary/20 text-accent-primary font-medium hover:bg-accent-primary/30 transition-colors disabled:opacity-30 disabled:cursor-not-allowed",children:"Send"})]})]}):s.jsxs(s.Fragment,{children:[(A||N)&&s.jsx("p",{className:"text-xs text-accent-error mb-1",children:A??N}),s.jsx("div",{className:`whitespace-pre-wrap break-words text-sm ${l?"text-text-system":""}`,children:e.content}),e.attachments&&e.attachments.length>0&&s.jsx(vU,{attachments:e.attachments,messageId:e.id})]})]}),z([{label:"Copy",icon:s.jsx(Yc,{className:"w-4 h-4"}),onClick:()=>void M()},{label:"Fork session from here",icon:s.jsx(Fa,{className:"w-4 h-4"}),onClick:()=>void U()}])]})}const vT=E.memo(function({message:t,isLastAssistantMessage:n=!1,messageId:r,sessionId:a}){const l=t.role==="user",u=t.role==="assistant",c=t.role==="system",d=t.role==="tool";if(u)return s.jsx(Ob,{message:t,showStats:n});if(c&&t.isCompacted)return s.jsxs("div",{className:"feed-item bg-bg-tertiary/50 border border-border rounded p-2",children:[s.jsx("div",{className:"text-text-muted text-xs mb-0.5",children:"[Compacted]"}),s.jsx("div",{className:"text-text-secondary text-xs whitespace-pre-wrap",children:t.content.replace(`[COMPACTED HISTORY]
306
+ `,"")})]});if(d)return s.jsxs("div",{className:"feed-item bg-bg-tertiary/30 border-l-2 border-accent-primary rounded-r p-2",children:[s.jsxs("div",{className:"text-accent-primary text-xs mb-0.5",children:["Tool: ",t.toolName]}),s.jsx(bn,{horizontal:!0,className:"max-h-32",children:s.jsxs("pre",{className:"text-text-secondary text-xs whitespace-pre-wrap break-words",children:[t.content.slice(0,500),t.content.length>500&&"..."]})})]});if(t.messageKind==="workflow-started")try{const h=JSON.parse(t.content);return s.jsx(mU,{data:h})}catch{}if(t.messageKind==="task-completed")try{const h=JSON.parse(t.content);return s.jsx(fU,{data:h})}catch{}return t.messageKind==="context-reset"?s.jsxs("div",{className:"flex items-center gap-4 mb-6 text-text-muted text-xs uppercase tracking-wide",children:[s.jsx("div",{className:"flex-1 border-t border-border"}),s.jsx("span",{children:t.content}),s.jsx("div",{className:"flex-1 border-t border-border"})]}):t.messageKind==="auto-prompt"&&t.isSystemGenerated?s.jsx(_U,{message:t}):t.messageKind==="correction"&&t.isSystemGenerated?s.jsx("div",{className:"flex justify-end feed-item",children:s.jsxs("div",{className:"max-w-[75%] rounded p-2 bg-bg-system border border-border-system",children:[s.jsx("span",{className:"text-[10px] block mb-0.5 text-text-system",children:"System"}),s.jsx("div",{className:"whitespace-pre-wrap break-words text-sm text-text-system italic",children:t.content})]})}):l?s.jsx(SU,{message:t,messageId:r,sessionId:a}):s.jsx("div",{className:"flex justify-start feed-item",children:s.jsx("div",{className:"max-w-[75%] rounded p-2 bg-bg-tertiary text-text-primary",children:s.jsx(sr,{content:t.content})})})}),wU={verifier:"Verification",code_reviewer:"Code Review",test_generator:"Test Generation",debugger:"Debug"};function CU(e){return{backgroundColor:`${e}20`,color:e,borderColor:`${e}4d`}}function KC(e,t){return t||e>85?"text-accent-error":e>60?"text-accent-warning":"text-text-muted"}function kU({contextState:e}){const{currentTokens:t,maxTokens:n,compactionCount:r,dangerZone:a}=e,l=Math.round(t/n*100);return s.jsxs("div",{className:"flex items-center gap-1.5 text-[10px]",children:[s.jsxs("span",{className:KC(l,a),children:[dl(t),"/",dl(n)]}),s.jsxs("span",{className:KC(l,a),children:["(",l,"%)"]}),s.jsx(Lb,{percent:l,dangerZone:a,size:"sm"}),a&&s.jsx("span",{className:"text-accent-error animate-pulse",children:"Low!"}),r>0&&s.jsxs("span",{className:"text-text-muted bg-bg-tertiary px-1 rounded",children:[r,"x"]})]})}const EU=E.memo(function({messages:t,subAgentType:n,subAgentId:r,isStreaming:a}){const l=E.useRef(null),u=E.useRef(null),[c,d]=E.useState(!1),h=ft(O=>O.defaults),p=ft(O=>O.userItems),m=[...h,...p],g=De(O=>O.subAgentContextStates[r]),{showThinking:y,showVerboseToolOutput:w}=As(),C=Su(u),{isAutoScrollActive:_,setAutoScroll:S,handleScrollbarGesture:b}=_u(u,null,C),v=E.useCallback(()=>{const O=!c;d(O),O&&setTimeout(()=>{var P;(P=l.current)==null||P.scrollIntoView({block:"start",behavior:"smooth"})},220)},[c]),k=m.find(O=>O.id===n),T=(k==null?void 0:k.name)??wU[n]??n,N=ul(m,n),R=CU(N),A=t.filter(O=>O.role!=="tool");return s.jsxs("div",{ref:l,className:"feed-item border border-border rounded overflow-hidden bg-secondary",children:[s.jsxs("div",{className:"w-full flex items-center justify-between px-2 py-1 border-b relative",style:R,children:[s.jsx("span",{className:"text-xs font-medium",children:T}),s.jsx("div",{className:"absolute left-1/2 -translate-x-1/2",children:g&&s.jsx(kU,{contextState:g})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{type:"button",className:"text-sm text-text-muted hover:text-text-primary flex items-center gap-1.5",onClick:()=>S(!_),children:[s.jsx("span",{className:`w-1 h-1 rounded-full ${_?"bg-accent-success":"border border-text-muted"}`}),"live"]}),s.jsxs("button",{type:"button",className:"text-[10px] px-1.5 py-0.5 rounded bg-bg-tertiary",onClick:v,children:[c?"▼":"▶"," Expand"]})]})]}),s.jsx(ct,{ref:u,className:`${c?"max-h-[calc(100vh-10rem)]":"max-h-80"} p-2 transition-[max-height] duration-200`,onScrollbarGesture:b,children:A.map(O=>O.role==="assistant"?s.jsx(Ob,{message:O,showStats:!0,showThinking:y,showVerboseToolOutput:w},O.id):s.jsx(vT,{message:O,isLastAssistantMessage:!1},O.id))})]})}),jU={contentVisibility:"auto",containIntrinsicSize:"auto 200px"},NU={contentVisibility:"auto",containIntrinsicSize:"160px",minHeight:"160px"},sh=30,cx=20,TU=10,AU=5;function ih(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 _T=E.memo(function({displayItems:t,highlightedMessageId:n=null,sessionId:r,scrollContainerRef:a,showThinking:l=!0,showVerboseToolOutput:u=!0,showStats:c=!0,showAgentDefinitions:d=!0,showWorkflowBars:h=!0}){const p=t.length,{feedVirtualization:m}=As(),[g,y]=E.useState(()=>Math.max(0,p-sh)),w=E.useRef(null),C=E.useRef(t.length),_=E.useRef(!1),S=m?g:0,b=m?jU:void 0;E.useEffect(()=>{m&&(y(Math.max(0,t.length-sh)),_.current=!1)},[r]),E.useEffect(()=>{const T=C.current;C.current=t.length,m&&t.length-T>=AU&&!_.current&&y(Math.max(0,t.length-sh))},[t.length,m]),E.useEffect(()=>{m&&g>0&&g>=t.length&&y(Math.max(0,t.length-sh))},[t.length,g,m]),E.useEffect(()=>{if(!m||g<=0||typeof IntersectionObserver>"u")return;const T=w.current;if(!T)return;const N=new IntersectionObserver(R=>{R.some(A=>A.isIntersecting)&&y(A=>Math.max(0,A-cx))},{rootMargin:"0px 0px 300px 0px"});return N.observe(T),()=>N.disconnect()},[g,m]);const v=E.useRef(g);v.current=g,E.useEffect(()=>{var A,O;if(!m)return;const T=a==null?void 0:a.current;if(!T)return;const N=(O=(A=T.osInstance)==null?void 0:A.call(T))==null?void 0:O.elements().viewport;if(!N)return;const R=()=>{if(N.scrollTop>4){_.current=!0;return}v.current>0&&y(P=>Math.max(0,P-cx))};return N.addEventListener("scroll",R,{passive:!0}),()=>N.removeEventListener("scroll",R)},[a,m]),E.useEffect(()=>{var R,A;if(!m||g<=0||!_.current)return;const T=a==null?void 0:a.current,N=(A=(R=T==null?void 0:T.osInstance)==null?void 0:R.call(T))==null?void 0:A.elements().viewport;N&&N.scrollTop<=4&&y(O=>Math.max(0,O-cx))},[g,a,m]),E.useEffect(()=>{if(!m)return;const T=N=>{var A;const R=(A=N.detail)==null?void 0:A.index;typeof R=="number"&&y(O=>Math.min(O,Math.max(0,R-TU)))};return window.addEventListener(hy,T),()=>window.removeEventListener(hy,T)},[m]);const k=t.slice(S);return s.jsxs(s.Fragment,{children:[S>0&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-center gap-2 py-3 text-xs text-text-muted","data-testid":"feed-unmounted-hint",children:["Scroll up to load ",S," older item",S!==1?"s":""]}),Array.from({length:S},(T,N)=>s.jsx("div",{"data-item-index":N,"data-placeholder":!0,style:NU},`ph-${N}`)),s.jsx("div",{ref:w,"data-testid":"feed-sentinel",style:{height:1}})]}),k.map((T,N)=>{const R=S+N;if(T.type==="context-divider")return s.jsxs("div",{"data-item-index":R,className:"flex items-center gap-2 feed-item px-2 md:px-4",children:[s.jsx("div",{className:"flex-1 border-t border-border"}),s.jsx("span",{className:"text-[10px] text-text-muted font-medium px-2",children:"Earlier context summarized"}),s.jsx("div",{className:"flex-1 border-t border-border"})]},ih(T));if(T.type==="subagent"){const V=T.messages.some(z=>z.isStreaming);return s.jsx("div",{"data-item-index":R,className:"px-2 md:px-4",style:b,children:s.jsx(EU,{messages:T.messages,subAgentType:T.subAgentType,subAgentId:T.subAgentId,isStreaming:V})},ih(T))}const A=T.message;if(A.role==="assistant")return s.jsx("div",{"data-item-index":R,className:"px-2 md:px-4",style:b,children:s.jsx(Ob,{message:A,showStats:c,showThinking:l,showVerboseToolOutput:u,sessionId:r??void 0})},ih(T));const O=!d&&A.messageKind==="auto-prompt",P=!h&&(A.messageKind==="workflow-started"||A.messageKind==="task-completed");return O||P?null:s.jsx("div",{"data-item-index":R,className:"px-2 md:px-4",style:b,children:s.jsx("div",{"data-message-id":A.id,className:n===A.id?"rounded animate-highlight-fade":void 0,children:s.jsx(vT,{message:A,messageId:A.id,sessionId:r??void 0,isLastAssistantMessage:!1})})},ih(T))})]})});function Vf(e,t,n=!0){E.useEffect(()=>{if(!n)return;const r=a=>{var l;(l=e.current)!=null&&l.contains(a.target)||t()};return document.addEventListener("mousedown",r),()=>document.removeEventListener("mousedown",r)},[e,t,n])}const LU=[],RU=E.memo(function({displayItems:t,scrollContainerRef:n,highlightedMessageId:r,onLaunchWorkflow:a,onScrollToTop:l,hiddenCount:u=0,onScrollbarGesture:c}){const d=De(Y=>{var Z,K;return((K=(Z=Y.currentSession)==null?void 0:Z.metadataEntries)==null?void 0:K.criteria)??LU}),h=De(Y=>{var Z;return(Z=Y.currentSession)==null?void 0:Z.id}),p=De(Y=>{var Z;return(Z=Y.currentSession)==null?void 0:Z.phase}),m=De(Y=>Y.error),g=De(Y=>Y.clearError),y=gf(),w=De(Y=>Y.activeWorkflowExecution),C=De(Y=>Y.continueWorkflow),{showThinking:_,showVerboseToolOutput:S,showStats:b,showAgentDefinitions:v,showWorkflowBars:k}=As(),T=Uf(),N=d.some(Y=>Y.status==="pending"),R=p==="done",A=t.some(Y=>Y.type==="message"&&Y.message.role==="assistant"),O=(w==null?void 0:w.status)==="running"||(w==null?void 0:w.status)==="waiting",P=N&&!y&&A&&!R&&!O,V=(w==null?void 0:w.status)==="waiting"&&!y,z=De(Y=>{var Z;return(Z=Y.currentSession)==null?void 0:Z.projectId}),[W,M]=E.useState(!1),[U,F]=E.useState(!1),[Q,X]=E.useState(!1),H=Su(n);E.useLayoutEffect(()=>{const Y=H();Y&&F(Y.scrollHeight>Y.clientHeight+1)},[H,t]),E.useEffect(()=>{const Y=H();if(!Y)return;const Z=()=>X(Y.scrollTop>4);return Z(),Y.addEventListener("scroll",Z,{passive:!0}),()=>Y.removeEventListener("scroll",Z)},[H]);const I=()=>{if(!z||!h)return;M(!1),window.open(`/p/${z}/s/${h}/readonly`,"_blank")||M(!0)},[D,q]=E.useState(!1),$=E.useCallback(Y=>{D||(q(!0),C(Y),setTimeout(()=>q(!1),5e3))},[D,C]),J=E.useCallback(()=>{var Y;l==null||l(),(Y=H())==null||Y.scrollTo({top:0,behavior:"smooth"})},[H,l]);return s.jsxs("div",{className:"relative flex-1 min-w-0 group",children:[s.jsxs(ct,{ref:n,"data-testid":"chat-scroll-container",className:"absolute inset-0 bg-primary",onScrollbarGesture:c,children:[s.jsxs("div",{className:"pt-4",children:[u>0&&s.jsxs("div",{className:"px-2 md:px-4 pb-2 space-y-1",children:[s.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:[u," older item",u!==1?"s":""," hidden — View full history"]}),W&&s.jsxs("p",{className:"text-xs text-text-muted text-center",children:["Popup blocked."," ",s.jsx("a",{href:z&&h?`/p/${z}/s/${h}/readonly`:"#",target:"_blank",rel:"noopener noreferrer",className:"underline hover:text-text-primary",children:"Open manually"})]})]}),s.jsx(_T,{displayItems:t,highlightedMessageId:r,sessionId:h,scrollContainerRef:n,showThinking:_,showVerboseToolOutput:S,showStats:b,showAgentDefinitions:v,showWorkflowBars:k})]}),s.jsxs("div",{className:"px-2 md:px-4 pb-4",children:[m&&s.jsx("div",{className:"feed-item bg-text-tool-error/10 border border-text-tool-error/50 rounded p-2",children:s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-text-tool-error text-sm font-medium",children:m.code}),s.jsx("div",{className:"text-text-tool-error/80 text-xs mt-0.5",children:m.message})]}),s.jsx(vu,{onClick:g,className:"text-text-tool-error hover:text-text-tool-error/80 p-0.5",size:"sm"})]})}),V&&w&&s.jsx("div",{className:"flex justify-center gap-2 feed-item flex-wrap",children:(w.pendingChoices&&w.pendingChoices.length>0?w.pendingChoices:[{id:void 0,label:`▶ Continue ${w.workflowName} (${w.currentStepName??"..."})`,goto:"",nextStepName:void 0}]).map(Y=>s.jsx("button",{onClick:()=>$(Y.id),disabled:D,className:"px-4 py-1.5 text-sm font-medium rounded bg-accent-primary/15 text-accent-primary border border-accent-primary/25 hover:bg-accent-primary/25 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:D?"⏳ Continuing...":Y.id==="continue"?`▶ Continue ${w.workflowName} (${Y.nextStepName??w.currentStepName??"..."})`:Y.label},Y.id??"continue"))}),P&&s.jsx("div",{className:"flex justify-center gap-2 feed-item flex-wrap",children:T.map(Y=>{const Z=Y.color??"#3b82f6",K=parseInt(Z.slice(1,3),16),B=parseInt(Z.slice(3,5),16),ne=parseInt(Z.slice(5,7),16),se=`rgba(${K},${B},${ne},0.12)`,re=`rgba(${K},${B},${ne},0.22)`,oe=`rgba(${K},${B},${ne},0.25)`;return s.jsx(DU,{workflowName:Y.name,scope:Y.scope,color:Z,bg:se,bgHover:re,border:oe,subGroups:Y.subGroups,onLaunch:ve=>a(Y.id,ve,void 0,Y.scope)},`${Y.id}-${Y.scope}`)})})]})]}),U&&Q&&s.jsx("div",{className:"absolute top-2 left-1/2 -translate-x-1/2 z-10 pointer-events-none opacity-0 group-hover:opacity-100 transition-opacity duration-200",children:s.jsxs("button",{type:"button",onClick:J,className:"pointer-events-auto text-sm text-text-muted hover:text-text-primary flex items-center gap-1.5 px-2 py-0.5 rounded hover:bg-bg-tertiary transition-colors backdrop-blur-sm bg-bg-secondary/60",children:[s.jsx(A3,{className:"w-3 h-3"}),"scroll to top"]})})]})});function DU({workflowName:e,scope:t,color:n,bg:r,bgHover:a,border:l,subGroups:u,onLaunch:c}){const[d,h]=E.useState(!1),p=E.useRef(null);Vf(p,()=>h(!1),d);const m=u&&u.length>0;return s.jsxs("div",{className:"relative flex",children:[s.jsxs("button",{onClick:()=>c(),"data-testid":"workflow-run-button",className:`px-4 py-1.5 text-sm font-medium transition-colors ${m?"rounded-l":"rounded"}`,style:{backgroundColor:r,color:n,border:`1px solid ${l}`,...m?{borderRight:"none"}:{}},onMouseEnter:g=>{g.currentTarget.style.backgroundColor=a},onMouseLeave:g=>{g.currentTarget.style.backgroundColor=r},children:["▶ ",e," ",s.jsx("span",{className:"text-[10px] font-normal opacity-70 whitespace-nowrap",children:Db[t]})]}),m&&s.jsxs("div",{ref:p,className:"relative",children:[s.jsx("button",{onClick:()=>h(!d),className:"px-2.5 py-1.5 rounded-r text-sm font-medium transition-colors",style:{backgroundColor:r,color:n,border:`1px solid ${l}`},onMouseEnter:g=>{g.currentTarget.style.backgroundColor=a},onMouseLeave:g=>{g.currentTarget.style.backgroundColor=r},children:"⋮"}),d&&s.jsxs("div",{className:"absolute top-full right-0 mt-1 w-40 bg-bg-secondary border border-border rounded-lg shadow-xl z-50 overflow-hidden",children:[s.jsx("button",{onClick:()=>{c(),h(!1)},className:"w-full text-left px-3 py-2 text-sm text-text-primary hover:bg-bg-tertiary transition-colors",children:"Full workflow"}),s.jsx("div",{className:"border-t border-border/50"}),u.map(g=>s.jsx("button",{onClick:()=>{c(g),h(!1)},className:"w-full text-left px-3 py-2 text-sm text-text-primary hover:bg-bg-tertiary transition-colors",children:g},g))]})]})]})}function OU(){const e=De(r=>r.connectionStatus),t=De(r=>r.reconnect);if(e==="connected")return null;const n=e==="reconnecting";return s.jsxs("div",{className:`
307
+ flex items-center justify-between px-4 py-2
308
+ text-sm font-medium
309
+ ${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"}
310
+ `,children:[s.jsx("div",{className:"flex items-center gap-2",children:n?s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"flex gap-1",children:[s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 animate-pulse"}),s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 animate-pulse",style:{animationDelay:"150ms"}}),s.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-amber-400 animate-pulse",style:{animationDelay:"300ms"}})]}),s.jsx("span",{children:"Reconnecting to server..."})]}):s.jsxs(s.Fragment,{children:[s.jsx(z3,{}),s.jsx("span",{children:"Connection lost"})]})}),s.jsx("button",{onClick:()=>t(),disabled:n,className:`
311
+ px-3 py-1 rounded text-xs font-medium
312
+ transition-colors
313
+ ${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"}
314
+ `,children:n?"Reconnecting...":"Reconnect"})]})}async function IU(e,t,n){t({loading:!0});try{const a=await(await we(e)).json();t({defaults:a.defaults??[],userItems:a.userItems??[],...n?{projectItems:a.projectItems??[]}:{},loading:!1})}catch{t({loading:!1})}}const ln=Jn((e,t)=>({defaults:[],userItems:[],projectItems:[],loading:!1,fetchCommands:async()=>{await IU("/api/commands",e,!0)},fetchCommand:async n=>{try{const r=await we(`/api/commands/${n}`);return r.ok?await r.json():null}catch{return null}},fetchDefaultContent:async n=>{try{const r=await we(`/api/commands/defaults/${n}`);return r.ok?await r.json():null}catch{return null}},createCommand:async(n,r)=>{const a=await Yi("POST","/api/commands",{...n,destination:r});return a.success&&await t().fetchCommands(),a},updateCommand:async(n,r)=>{const a=await Yi("PUT",`/api/commands/${n}`,r);return a.success&&await t().fetchCommands(),a},deleteCommand:async n=>{try{const r=await we(`/api/commands/${n}`,{method:"DELETE"}),a=await r.json();return r.ok?(e(l=>({userItems:l.userItems.filter(u=>u.id!==n),projectItems:l.projectItems.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,r)=>pf(`/api/commands/${n}/duplicate`,()=>t().fetchCommands(),r)}));function MU(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function PU({onClick:e}){return s.jsx("button",{type:"button",onClick:e,className:"p-1.5 rounded text-text-muted hover:text-text-primary hover:bg-bg-primary transition-colors",title:"View",children:s.jsx(My,{})})}function ST({isOpen:e,onClose:t,initialEditId:n}){const r=ln(Ce=>Ce.defaults),a=ln(Ce=>Ce.userItems),l=ln(Ce=>Ce.projectItems),u=ln(Ce=>Ce.loading),c=ln(Ce=>Ce.fetchCommands),d=ln(Ce=>Ce.fetchCommand),h=ln(Ce=>Ce.fetchDefaultContent),p=ln(Ce=>Ce.createCommand),m=ln(Ce=>Ce.updateCommand),g=ln(Ce=>Ce.deleteCommand),[y,w]=E.useState(null),[C,_]=E.useState(null),{view:S,editingId:b,formError:v,saving:k,formData:T,setView:N,setEditingId:R,setFormError:A,setFormData:O,setSaving:P}=BE(),{requestDelete:V,clearConfirm:z,isConfirming:W}=du(),M=E.useRef(!1),U=ft(Ce=>Ce.defaults),F=ft(Ce=>Ce.userItems),Q=ft(Ce=>Ce.fetchAgents),H=[...U,...F].filter(Ce=>!Ce.subagent),I=E.useRef(c),D=E.useRef(Q),q=E.useRef(d),$=E.useRef(h),J=E.useRef(n),Y=E.useRef(N),Z=E.useRef(R),K=E.useRef(A),B=E.useRef(z);E.useEffect(()=>{I.current=c,D.current=Q,q.current=d,$.current=h,J.current=n,Y.current=N,Z.current=R,K.current=A,B.current=z}),E.useEffect(()=>{if(e)if(I.current(),D.current(),M.current||(B.current(),M.current=!0),J.current){const Ce=r.some(me=>me.id===J.current);Y.current("edit"),Z.current(J.current),K.current(""),Ce?$.current(J.current).then(me=>{me&&O({name:me.metadata.name+" (copy)",id:`${J.current}-copy-${Date.now()}`,prompt:me.prompt,agentMode:me.metadata.agentMode??"",isDefault:!0,destination:"user"})}):q.current(J.current).then(me=>{me&&O({name:me.metadata.name,id:me.metadata.id,prompt:me.prompt,agentMode:me.metadata.agentMode??"",isDefault:!1,destination:"user"})})}else Y.current("list"),Z.current(null);else M.current=!1},[e]);const ne=async Ce=>{w(Ce);const me=await h(Ce);_((me==null?void 0:me.prompt)??null)},se=async Ce=>{if(r.some(We=>We.id===Ce)){const We=await h(Ce);We&&(R(null),O({name:`${We.metadata.name} (copy)`,id:`${Ce}-copy-${Date.now()}`,prompt:We.prompt,agentMode:We.metadata.agentMode??"",isDefault:!0,destination:"user"}),A(""),N("edit"))}else{const We=await d(Ce);We&&(R(null),O({name:`${We.metadata.name} (copy)`,id:`${Ce}-copy-${Date.now()}`,prompt:We.prompt,agentMode:We.metadata.agentMode??"",isDefault:!1,destination:"user"}),A(""),N("edit"))}},re=()=>{O({name:"",id:"",prompt:"",agentMode:"",isDefault:!1,destination:"user"}),R(null),N("edit")},oe=async Ce=>{const me=await d(Ce);me&&(R(Ce),O({name:me.metadata.name,id:me.metadata.id,prompt:me.prompt,agentMode:me.metadata.agentMode??"",isDefault:!1,destination:"user"}),A(""),N("edit"))},ve=async Ce=>{await g(Ce),z()},Se=async()=>{const Ce=b??T.id;if(!Ce||!T.name||!T.prompt){A("Name and message are required.");return}P(!0),A("");const me={metadata:{id:Ce,name:T.name,...T.agentMode?{agentMode:T.agentMode}:{}},prompt:T.prompt},We=b?await m(b,me):await p(me,T.destination);if(P(!1),!We.success){A(We.error??"Failed to save command.");return}n?t():N("list")},$e=()=>{n?t():(N("list"),w(null),_(null))},ze=Ce=>{O(me=>({...me,name:Ce})),(!b||T.isDefault)&&O(me=>({...me,id:MU(Ce)}))},ke=()=>{w(null),_(null),N("list")},Ge=()=>{y&&(w(null),N("edit"),R(y),h(y).then(Ce=>{Ce&&O({name:`${Ce.metadata.name} (copy)`,id:`${y}-copy-${Date.now()}`,prompt:Ce.prompt,agentMode:Ce.metadata.agentMode??"",isDefault:!0,destination:"user"})}))};if(y){const Ce=r.find(me=>me.id===y);return s.jsx(jt,{isOpen:e,onClose:ke,title:`Default: ${(Ce==null?void 0:Ce.name)??y}`,size:"xl",children:s.jsxs("div",{className:"flex flex-col h-full",children:[s.jsxs("div",{className:"space-y-3 mb-3",children:[s.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-muted",children:[s.jsx("span",{className:"px-1.5 py-0.5 rounded bg-bg-tertiary text-text-secondary",children:"Built-in"}),s.jsx("span",{className:"font-mono",children:y})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Name"}),s.jsx("div",{className:"px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm",children:Ce==null?void 0:Ce.name})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Agent Mode"}),s.jsx("div",{className:"px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm text-text-muted",children:(Ce==null?void 0:Ce.agentMode)||"None"})]})]}),s.jsxs("div",{className:"flex-1 min-h-[120px] border-t border-border pt-3 flex flex-col",children:[s.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Message"}),s.jsx("textarea",{value: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"})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-3 mt-3 border-t border-border flex-shrink-0",children:[s.jsx(dt,{variant:"secondary",onClick:ke,children:"Close"}),s.jsx(dt,{variant:"primary",onClick:Ge,children:"Duplicate & Customize"})]})]})})}if(S==="edit")return s.jsx(jt,{isOpen:e,onClose:$e,title:b?"Edit Command":"New Command",size:"xl",footer:s.jsx(DE,{onCancel:$e,onSave:Se,saving:k,saveDisabled:!T.name||!T.prompt}),children:s.jsxs("div",{className:"flex flex-col h-full",children:[v&&s.jsx(nl,{message:v}),s.jsxs("div",{className:"space-y-3 mb-3",children:[s.jsx(PE,{name:T.name,id:T.id,nameLabel:"Name",idLabel:"ID",namePlaceholder:"My Command",idPlaceholder:"my-command",readOnlyId:!!b&&!T.isDefault,onNameChange:ze,onIdChange:Ce=>O(me=>({...me,id:Ce}))}),s.jsxs("div",{children:[s.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:["Agent Mode ",s.jsx("span",{className:"text-text-muted",children:"(optional)"})]}),s.jsxs("select",{value:T.agentMode,onChange:Ce=>O(me=>({...me,agentMode:Ce.target.value})),className:"w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary",children:[s.jsx("option",{value:"",children:"None (keep current mode)"}),H.map(Ce=>s.jsx("option",{value:Ce.id,children:Ce.name},Ce.id))]})]}),!b&&s.jsx(vf,{value:T.destination,onChange:Ce=>O(me=>({...me,destination:Ce}))})]}),s.jsxs("div",{className:"flex-1 min-h-[120px] border-t border-border pt-3 flex flex-col",children:[s.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Message"}),s.jsx("textarea",{value:T.prompt,onChange:Ce=>O(me=>({...me,prompt:Ce.target.value})),placeholder:"The message that will be sent when this command is triggered...",className:"h-80 w-full px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono resize-y focus:outline-none focus:ring-1 focus:ring-accent-primary"})]})]})});const Je=Ce=>Ce.map(me=>s.jsxs("div",{className:"flex items-center justify-between p-3 rounded border border-border bg-bg-tertiary",children:[s.jsx("div",{className:"min-w-0 flex-1 mr-3",children:s.jsx("div",{className:"flex items-center gap-2",children:s.jsx("span",{className:"text-text-primary text-sm font-medium",children:me.name})})}),s.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[s.jsx(ci,{onClick:()=>oe(me.id)}),s.jsx(Jc,{onClick:()=>se(me.id)}),W(me.id,"delete")?s.jsx(Ah,{onConfirm:()=>ve(me.id),onCancel:z}):s.jsx(Lh,{onClick:()=>V(me.id)})]})]},me.id));return s.jsxs(jt,{isOpen:e,onClose:t,title:"Commands",size:"lg",children:[s.jsx(ME,{description:"Commands are pre-defined messages you can send with a single click.",onNew:re}),s.jsxs(Hy,{loading:u,hasItems:r.length>0||a.length>0||l.length>0,loadingLabel:"Loading commands...",emptyLabel:"No commands created yet.",children:[r.length>0&&s.jsxs("div",{children:[s.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Built-in"}),s.jsx("div",{className:"space-y-2",children:r.map(Ce=>s.jsxs("div",{className:"flex items-center justify-between p-3 rounded border border-border bg-bg-tertiary",children:[s.jsx("div",{className:"min-w-0 flex-1 mr-3",children:s.jsx("span",{className:"text-text-primary text-sm font-medium",children:Ce.name})}),s.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[s.jsx(PU,{onClick:()=>ne(Ce.id)}),s.jsx(Jc,{onClick:()=>se(Ce.id)})]})]},Ce.id))})]}),a.length>0&&s.jsx(IE,{children:Je(a)}),l.length>0&&s.jsxs("div",{className:"mt-4",children:[s.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Project"}),s.jsx("div",{className:"space-y-2",children:Je(l)})]})]})]})}function BU({title:e,defaultOpen:t=!1,children:n,className:r=""}){return s.jsxs("details",{className:`group ${r}`,open:t,children:[s.jsxs("summary",{className:"text-[11px] text-text-secondary uppercase tracking-wider font-medium cursor-pointer select-none hover:text-text-primary transition-colors list-none flex items-center gap-1",children:[s.jsx(vn,{className:"w-3 h-3 transition-transform group-open:rotate-180"}),e]}),s.jsx("div",{className:"mt-2 space-y-2",children:n})]})}const Ea=150,ei=54,ah=80,rs=30,Ho=70,YC=100,ja=50,oh=50,XC=4,wT={step_result:"Result",metadata_all_match:"Metadata match",metadata_all_in:"Metadata in",always:"otherwise"},CT=[{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)"}],$U=[{value:"agent",label:"Agent"},{value:"sub_agent",label:"Sub-Agent"},{value:"shell",label:"Shell"},{value:"user",label:"User (pause)"}];function Mb(e,t){if(e.type==="agent"){const n=t.find(r=>r.id===e.agentId);return{name:(n==null?void 0:n.name)??(e.agentId||"Agent"),color:(n==null?void 0:n.color)||"#3b82f6"}}if(e.type==="sub_agent"){const n=t.find(r=>r.id===e.subAgentType);return{name:(n==null?void 0:n.name)??(e.subAgentType||"Sub-Agent"),color:(n==null?void 0:n.color)||"#a855f7"}}return e.type==="user"?{name:"User",color:"#f59e0b"}:{name:"Shell",color:"#22c55e"}}function zU(e,t,n,r){const a=oh+ja+Ea+YC+Ea+ja+oh,l=a/2,u=oh+ja+Ea/2,c=oh+ja+Ea+YC+Ea/2,d=[],h=[],p=new Map,m=e.filter(U=>U.type==="agent"||U.type==="shell"||U.type==="user"),g=e.filter(U=>U.type==="sub_agent"),y=g.length>0,w=y?u:l,C=m.length>0?c:l,_=ja+rs/2;d.push({id:"$start",type:"terminal",label:"Start",cx:w,cy:_,w:ah,h:rs}),p.set("$start",{cx:w,cy:_,w:ah,h:rs});const S=U=>{d.push({id:"$done",type:"terminal",label:"Done",cx:w,cy:U,w:ah,h:rs}),p.set("$done",{cx:w,cy:U,w:ah,h:rs})};if(e.length===0){const U=_+rs/2+Ho*2+rs/2;return S(U),{nodes:d,edges:h,width:a,height:U+rs/2+ja,posMap:p}}const b=_+rs/2+Ho,v=(U,F)=>{U.forEach((Q,X)=>{const H=b+X*(ei+Ho)+ei/2,{name:I,color:D}=Mb(Q,r);d.push({id:Q.id,type:"step",label:I,color:D,cx:F,cy:H,w:Ea,h:ei}),p.set(Q.id,{cx:F,cy:H,w:Ea,h:ei})})};v(m,w),v(g,C);const k=m.length>0?b+(m.length-1)*(ei+Ho)+ei/2:_,T=y?b+(g.length-1)*(ei+Ho)+ei/2:_,N=Math.max(k,T)+ei/2+Ho+rs/2;S(N);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 U of e)U.transitions.forEach((F,Q)=>{var $;if(!F.goto||!p.has(F.goto))return;const X=p.get(U.id),H=p.get(F.goto),I=F.when.type==="step_result"?`${F.when.result}`:F.when.type==="metadata_all_match"?`${F.when.key??"?"}=${F.when.value??"?"}`:F.when.type==="metadata_all_in"?`${F.when.key??"?"} in [${(($=F.when.values)==null?void 0:$.join(","))??"?"}]`:wT[F.when.type]??F.when.type,D=U.id===F.goto;let q;D?q="back":H.cy>X.cy+1?q="down":H.cy<X.cy-1?q="back":q="same",R.push({from:U.id,to:F.goto,label:I,edgeKey:`${U.id}:${Q}`,direction:q,backEdgeIndex:q==="back"?A++:0})});const O=new Map,P=new Map,V=new Map,z=new Map;for(const U of R)U.direction==="down"&&(O.set(U.from,(O.get(U.from)??0)+1),P.set(U.to,(P.get(U.to)??0)+1));const W=new Map,M=new Map;for(const U of R){if(U.direction!=="same")continue;const F=[U.from,U.to].sort().join("|");W.set(F,(W.get(F)??0)+1)}for(const U of R){if(U.direction==="back"||U.direction==="same"){let q=0;if(U.direction==="same"){const $=[U.from,U.to].sort().join("|");q=M.get($)??0,M.set($,q+1)}h.push({...U,fromPort:0,toPort:0,sameEdgeIndex:q});continue}const F=O.get(U.from)??1,Q=P.get(U.to)??1,X=V.get(U.from)??0,H=z.get(U.to)??0;V.set(U.from,X+1),z.set(U.to,H+1);const I=F===1?0:-.6+1.2*X/(F-1),D=Q===1?0:-.6+1.2*H/(Q-1);h.push({...U,fromPort:I,toPort:D,sameEdgeIndex:0})}return{nodes:d,edges:h,width:a,height:N+rs/2+ja,posMap:p}}function HU({steps:e,entryStep:t,selectedNodeId:n,selectedEdgeKey:r,startConditionLabel:a,agentTypes:l,isReadOnly:u,onSelectNode:c,onSelectEdge:d,onRemoveStep:h,onCreateTransition:p,onReconnectTo:m,onReconnectFrom:g,onDeleteTransition:y}){const w=E.useRef(null),C=E.useRef(!1),[_,S]=E.useState(null),[b,v]=E.useState(null),[k,T]=E.useState(null),{nodes:N,edges:R,width:A,height:O,posMap:P}=E.useMemo(()=>zU(e,t,a,l),[e,t,a,l]),V=E.useCallback(Y=>{var se;const Z=w.current;if(!Z)return{x:0,y:0};const K=Z.createSVGPoint();K.x=Y.clientX,K.y=Y.clientY;const B=(se=Z.getScreenCTM())==null?void 0:se.inverse();if(!B)return{x:0,y:0};const ne=K.matrixTransform(B);return{x:ne.x,y:ne.y}},[]),z=E.useCallback(Y=>!Y||!b||Y==="$start"?!1:b.type==="reconnect-from"?Y!=="$done":!0,[b]),W=E.useCallback((Y,Z)=>{if(u)return;Y.stopPropagation(),Y.preventDefault();const K=V(Y);v({type:"new",fromNodeId:Z,mouseX:K.x,mouseY:K.y})},[V,u]),M=E.useCallback((Y,Z)=>{if(u)return;Y.stopPropagation(),Y.preventDefault();const K=V(Y);v({type:"reconnect-to",fromNodeId:Z.from,edgeKey:Z.edgeKey,mouseX:K.x,mouseY:K.y})},[V,u]),U=E.useCallback((Y,Z)=>{if(u)return;Y.stopPropagation(),Y.preventDefault();const K=V(Y);v({type:"reconnect-from",fromNodeId:Z.from,fixedTargetId:Z.to,edgeKey:Z.edgeKey,mouseX:K.x,mouseY:K.y})},[V,u]),F=E.useCallback(Y=>{if(!b)return;const Z=V(Y);v(K=>K?{...K,mouseX:Z.x,mouseY:Z.y}:null)},[b,V]),Q=E.useCallback(()=>{b&&(C.current=!0,k&&z(k)&&(b.type==="new"?p(b.fromNodeId,k):b.type==="reconnect-to"?m(b.edgeKey,k):b.type==="reconnect-from"&&g(b.edgeKey,k)),v(null),T(null))},[b,k,z,p,m,g]),X=E.useCallback(()=>{if(C.current){C.current=!1;return}c(null),d(null)},[c,d]);E.useEffect(()=>{if(u)return;const Y=Z=>{Z.target instanceof HTMLInputElement||Z.target instanceof HTMLTextAreaElement||Z.target instanceof HTMLSelectElement||(Z.key==="Delete"||Z.key==="Backspace")&&r&&r!=="start"&&(Z.preventDefault(),y(r),d(null))};return document.addEventListener("keydown",Y),()=>document.removeEventListener("keydown",Y)},[u,r,y,d]);const H=Y=>{const Z=P.get(Y.from),K=P.get(Y.to);if(!Z||!K)return null;let B,ne,se,re="middle",oe,ve;if(Y.direction==="down"){const Se=Z.cx+Y.fromPort*(Z.w/2-10),$e=Z.cy+Z.h/2,ze=K.cx+Y.toPort*(K.w/2-10),ke=K.cy-K.h/2,Ge=ke-$e,Je=ze-Se;B=`M ${Se} ${$e} C ${Se} ${$e+Ge*.4}, ${ze-Je*.2} ${ke-Ge*.1}, ${ze} ${ke}`,ne=Se+(ze-Se)*.5,se=$e+Ge*.6,oe={x:Se,y:$e},ve={x:ze,y:ke}}else if(Y.direction==="back"){const Se=Y.from===Y.to,$e=Z.cx>=A/2,ze=Y.backEdgeIndex*16,ke=$e?A-20-ze:20+ze;if(Se){const Ge=Z.cx>=A/2,Je=30+Y.backEdgeIndex*14,Ce=Z.cy-Z.h/2,me=Ge?Z.cx+Z.w/2:Z.cx-Z.w/2,We=Ge?me+Je:me-Je,he=Z.cx+(Ge?Z.w/4:-Z.w/4),Ve=Ce-20-Y.backEdgeIndex*10;B=`M ${me} ${Z.cy} C ${We} ${Z.cy}, ${We} ${Ve}, ${he} ${Ce}`,ne=We+10,se=Ve+4,re="middle",oe={x:me,y:Z.cy},ve={x:he,y:Ce}}else{const Ge=$e?Z.cx+Z.w/2:Z.cx-Z.w/2,Je=K.cx+($e?K.w/4:-K.w/4),Ce=Math.min(Z.cy,K.cy)-K.h/2-18-Y.backEdgeIndex*14;B=`M ${Ge} ${Z.cy} L ${ke} ${Z.cy} L ${ke} ${Ce} L ${Je} ${Ce} L ${Je} ${K.cy-K.h/2}`,ne=ke,se=(Z.cy+Ce)/2,re=$e?"start":"end",oe={x:Ge,y:Z.cy},ve={x:Je,y:K.cy-K.h/2}}}else{const Se=K.cx>Z.cx,$e=Y.sameEdgeIndex===0?-12:12,ze=Se?Z.cx+Z.w/2:Z.cx-Z.w/2,ke=Se?K.cx-K.w/2:K.cx+K.w/2,Ge=Z.cy+$e,Je=K.cy+$e,Ce=(ze+ke)/2;B=`M ${ze} ${Ge} C ${Ce} ${Ge}, ${Ce} ${Je}, ${ke} ${Je}`,ne=Ce,se=(Ge+Je)/2-6,oe={x:ze,y:Ge},ve={x:ke,y:Je}}return{path:B,labelX:ne,labelY:se,labelAnchor:re,fromPt:oe,toPt:ve}},I=(Y,Z)=>{const K=H(Y);if(!K)return null;const{path:B,labelX:ne,labelY:se,labelAnchor:re}=K,oe=r===Y.edgeKey,ve=Y.label&&Y.label!=="otherwise";return s.jsxs("g",{children:[s.jsx("path",{d:B,fill:"none",stroke:"transparent",strokeWidth:14,className:"cursor-pointer",onClick:Se=>{Se.stopPropagation(),u||d(oe?null:Y.edgeKey)}}),s.jsx("path",{d:B,fill:"none",stroke:oe?"#58a6ff":"#484f58",strokeWidth:oe?2.2:1.2,markerEnd:oe?"url(#arrow-selected)":"url(#arrow)",pointerEvents:"none"}),ve&&s.jsx("text",{x:ne+(re==="start"?5:re==="end"?-5:0),y:se+3,textAnchor:re,className:"text-[8px]",fill:oe?"#79c0ff":"#8b949e",style:{paintOrder:"stroke",stroke:"#0d1117",strokeWidth:3,strokeLinejoin:"round"},pointerEvents:"none",children:Y.label})]},Z)},D=()=>{if(!r||b)return null;const Y=R.find(se=>se.edgeKey===r);if(!Y)return null;const Z=H(Y);if(!Z)return null;const{fromPt:K,toPt:B}=Z,ne=6;return s.jsxs(s.Fragment,{children:[Y.edgeKey!=="start"&&s.jsx("circle",{cx:K.x,cy:K.y,r:ne,fill:"#58a6ff",fillOpacity:.25,stroke:"#58a6ff",strokeWidth:2,strokeOpacity:.8,className:"cursor-grab",onMouseDown:se=>U(se,Y)}),s.jsx("circle",{cx:B.x,cy:B.y,r:ne,fill:"#58a6ff",fillOpacity:.25,stroke:"#58a6ff",strokeWidth:2,strokeOpacity:.8,className:"cursor-grab",onMouseDown:se=>M(se,Y)})]})},q=()=>{if(!b)return null;let Y,Z,K,B;if(b.type==="reconnect-from"){const re=P.get(b.fixedTargetId);if(!re)return null;Y=b.mouseX,Z=b.mouseY,K=re.cx,B=re.cy-re.h/2}else{const re=P.get(b.fromNodeId);if(!re)return null;Y=re.cx,Z=re.cy+re.h/2,K=b.mouseX,B=b.mouseY}const ne=B-Z,se=Math.abs(ne)>10?`M ${Y} ${Z} C ${Y} ${Z+ne*.4}, ${K} ${B-ne*.4}, ${K} ${B}`:`M ${Y} ${Z} L ${K} ${B}`;return s.jsx("path",{d:se,fill:"none",stroke:"#58a6ff",strokeWidth:2,strokeDasharray:"6 3",strokeOpacity:.7,pointerEvents:"none"})},$=Y=>{const Z=Y.cy+Y.h/2,K=(b==null?void 0:b.fromNodeId)===Y.id;return s.jsx("circle",{cx:Y.cx,cy:Z,r:XC,fill:K?"#58a6ff":"#1c2128",stroke:K?"#58a6ff":"#484f58",strokeWidth:1.5,strokeOpacity:K?1:.5,className:"cursor-crosshair",onMouseDown:B=>W(B,Y.id)})},J=Y=>{const Z=Y.cy-Y.h/2,K=b&&k===Y.id&&z(Y.id);return s.jsx("circle",{cx:Y.cx,cy:Z,r:XC,fill:K?"#3fb950":"#1c2128",stroke:K?"#3fb950":"#484f58",strokeWidth:1.5,strokeOpacity:K?1:.5})};return s.jsxs("svg",{ref:w,viewBox:`0 0 ${A} ${O}`,className:"block w-full",preserveAspectRatio:"xMidYMin meet",onMouseMove:F,onMouseUp:Q,onClick:X,children:[s.jsxs("defs",{children:[s.jsx("marker",{id:"arrow",viewBox:"0 0 10 7",refX:"10",refY:"3.5",markerWidth:"7",markerHeight:"5",orient:"auto",children:s.jsx("polygon",{points:"0 0, 10 3.5, 0 7",fill:"#484f58"})}),s.jsx("marker",{id:"arrow-selected",viewBox:"0 0 10 7",refX:"10",refY:"3.5",markerWidth:"7",markerHeight:"5",orient:"auto",children:s.jsx("polygon",{points:"0 0, 10 3.5, 0 7",fill:"#58a6ff"})})]}),R.map((Y,Z)=>I(Y,Z)),N.map(Y=>{const Z=n===Y.id,K=Y.cx-Y.w/2,B=Y.cy-Y.h/2,ne=_===Y.id,se=b&&k===Y.id&&z(Y.id);if(Y.type==="terminal"){const oe=Y.id==="$start",ve=oe?"#58a6ff":"#3fb950",Se=oe,$e=!oe;return s.jsxs("g",{onClick:ze=>{ze.stopPropagation(),oe&&!u&&d("start")},className:oe&&!u?"cursor-pointer":void 0,children:[se&&s.jsx("rect",{x:K-3,y:B-3,width:Y.w+6,height:Y.h+6,rx:Y.h/2+3,fill:"none",stroke:"#3fb950",strokeOpacity:.6,strokeWidth:2}),oe&&r==="start"&&s.jsx("rect",{x:K-3,y:B-3,width:Y.w+6,height:Y.h+6,rx:Y.h/2+3,fill:"none",stroke:"#58a6ff",strokeOpacity:.5,strokeWidth:2}),s.jsx("rect",{x:K,y:B,width:Y.w,height:Y.h,rx:Y.h/2,fill:ve,fillOpacity:.08,stroke:ve,strokeOpacity:.4,strokeWidth:1.5}),s.jsx("text",{x:Y.cx,y:Y.cy+4,textAnchor:"middle",fill:ve,className:"text-[10px] font-medium",pointerEvents:"none",children:Y.label}),Se&&$(Y),$e&&J(Y)]},Y.id)}const re=Y.color??"#6b7280";return s.jsxs("g",{onClick:oe=>{oe.stopPropagation(),u||c(Z?null:Y.id)},onMouseEnter:()=>S(Y.id),onMouseLeave:()=>S(null),className:u?void 0:"cursor-pointer",children:[se&&s.jsx("rect",{x:K-3,y:B-3,width:Y.w+6,height:Y.h+6,rx:12,fill:"none",stroke:"#3fb950",strokeOpacity:.6,strokeWidth:2}),Z&&s.jsx("rect",{x:K-3,y:B-3,width:Y.w+6,height:Y.h+6,rx:12,fill:"none",stroke:"#58a6ff",strokeOpacity:.5,strokeWidth:2}),s.jsx("rect",{x:K,y:B,width:Y.w,height:Y.h,rx:10,fill:re,fillOpacity:.08,stroke:re,strokeOpacity:.6,strokeWidth:Z?2:1.5}),s.jsx("text",{x:Y.cx,y:Y.cy+4,textAnchor:"middle",fill:"#c9d1d9",className:"text-[11px] font-medium",pointerEvents:"none",children:Y.label}),!u&&$(Y),!u&&J(Y),ne&&!b&&!u&&s.jsxs("g",{onClick:oe=>{oe.stopPropagation(),h(Y.id)},className:"cursor-pointer",children:[s.jsx("circle",{cx:K+Y.w-2,cy:B+2,r:8,fill:"#0d1117",fillOpacity:.9,stroke:"#f85149",strokeOpacity:.5,strokeWidth:1}),s.jsx("line",{x1:K+Y.w-5,y1:B-1,x2:K+Y.w+1,y2:B+5,stroke:"#f85149",strokeWidth:1.5,strokeLinecap:"round"}),s.jsx("line",{x1:K+Y.w+1,y1:B-1,x2:K+Y.w-5,y2:B+5,stroke:"#f85149",strokeWidth:1.5,strokeLinecap:"round"})]})]},Y.id)}),b&&N.map(Y=>z(Y.id)?s.jsx("rect",{x:Y.cx-Y.w/2-8,y:Y.cy-Y.h/2-8,width:Y.w+16,height:Y.h+16,fill:"transparent",rx:12,onMouseEnter:()=>T(Y.id),onMouseLeave:()=>T(null),onMouseUp:Z=>{Z.stopPropagation(),Q()}},`drop-${Y.id}`):null),q(),D()]})}const lh="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",Tc="block text-[11px] text-text-secondary mb-0.5";function FU({formName:e,formId:t,formDescription:n,formMaxIterations:r,formColor:a,isReadOnly:l,onNameChange:u,onDescriptionChange:c,onMaxIterationsChange:d,onColorChange:h}){return s.jsxs("div",{className:"flex items-end gap-3 mb-3 pb-3 border-b border-border flex-wrap",children:[s.jsxs("div",{className:"min-w-[140px]",children:[s.jsx("label",{className:Tc,children:"Name"}),s.jsx("input",{value:e,onChange:p=>u(p.target.value),placeholder:"Workflow name",className:`${lh} ${l?"opacity-50":""}`,readOnly:l})]}),s.jsxs("div",{className:"min-w-[100px]",children:[s.jsx("label",{className:Tc,children:"ID"}),s.jsx("input",{value:t,readOnly:!0,className:`${lh} font-mono opacity-50`})]}),s.jsxs("div",{className:"flex-1 min-w-[140px]",children:[s.jsx("label",{className:Tc,children:"Description"}),s.jsx("input",{value:n,onChange:p=>!l&&c(p.target.value),readOnly:l,placeholder:"What does this workflow do?",className:`${lh} ${l?"opacity-50":""}`})]}),s.jsxs("div",{className:"w-20",children:[s.jsx("label",{className:Tc,children:"Max Iter."}),s.jsx("input",{type:"number",value:r,onChange:p=>!l&&d(Number(p.target.value)),readOnly:l,className:`${lh} font-mono ${l?"opacity-50":""}`})]}),s.jsxs("div",{children:[s.jsx("label",{className:Tc,children:"Color"}),s.jsx("input",{type:"color",value:a,onChange:p=>!l&&h(p.target.value),disabled:l,className:`w-8 h-8 rounded border border-border bg-transparent ${l?"opacity-50":"cursor-pointer"}`})]})]})}function UU({name:e,id:t,color:n,description:r,isBuiltIn:a,actions:l}){return s.jsxs("div",{className:"flex items-center justify-between bg-bg-secondary rounded-lg p-4 border border-border",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0",style:{backgroundColor:n}}),s.jsx("span",{className:"text-text-primary text-sm font-medium",children:e}),s.jsx("span",{className:"text-text-muted text-xs font-mono",children:t}),a&&s.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-medium bg-bg-primary text-text-muted",children:"Built-in"})]}),r&&s.jsx("p",{className:"text-text-secondary text-xs mt-0.5 truncate",children:r})]}),s.jsx("div",{className:"flex items-center gap-1 flex-shrink-0 ml-3",children:l})]})}function ux({title:e,items:t,renderActions:n}){return t.length===0?null:s.jsxs("div",{children:[s.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:e}),s.jsx("div",{className:"space-y-2",children:t.map(r=>s.jsx(UU,{name:r.name,id:r.id,color:r.color??"#3b82f6",description:r.description,actions:n(r)},r.id))})]})}const Na="w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary",dx="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",bs="block text-[11px] text-text-secondary mb-0.5";function hx({variables:e,onInsert:t}){return e.length===0?null:s.jsx("div",{className:"flex flex-wrap gap-1 mt-1",children:e.map(n=>s.jsx("button",{type:"button",onClick:()=>t(n.name),title:n.description,className:"px-1.5 py-0.5 rounded text-[10px] font-mono bg-bg-primary border border-border text-text-secondary hover:text-accent-primary hover:border-accent-primary/40 transition-colors",children:`{{${n.name}}}`},n.name))})}function VU({step:e,isEntry:t,agentTypes:n,transitionCount:r,templateVariables:a,onUpdate:l,onRemove:u,onSetEntry:c}){const{color:d,name:h}=Mb(e,n);return s.jsxs("div",{className:"space-y-3 text-sm",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold",style:{backgroundColor:d+"20",color:d},children:h}),t&&s.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold bg-accent-primary/15 text-accent-primary",children:"Entry"})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[!t&&s.jsx("button",{onClick:c,className:"p-1 rounded text-text-muted hover:text-accent-primary text-xs",children:"Set entry"}),s.jsx("button",{onClick:u,className:"p-1 rounded text-text-muted hover:text-accent-error text-xs",children:"Delete"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:bs,children:"Name"}),s.jsx("input",{value:e.name,onChange:p=>l({...e,name:p.target.value}),placeholder:"Step name",className:Na})]}),s.jsxs("div",{children:[s.jsx("label",{className:bs,children:"Type"}),s.jsx("select",{value:e.type,onChange:p=>{const m=p.target.value,g=m==="sub_agent"?"verification":"build";if(m==="agent"){const y=n.find(w=>!w.subagent);l({...e,type:m,phase:g,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:g,subAgentType:(y==null?void 0:y.id)??"",name:(y==null?void 0:y.name)??"Sub-Agent"})}else l(m==="user"?{...e,type:m,phase:g,name:"User"}:{...e,type:m,phase:g,name:"Shell"})},className:dx,children:$U.map(p=>s.jsx("option",{value:p.value,children:p.label},p.value))})]}),e.type==="agent"&&s.jsxs("div",{children:[s.jsx("label",{className:bs,children:"Agent Type"}),s.jsx("select",{value:e.agentId??"builder",onChange:p=>{const m=n.find(g=>g.id===p.target.value);l({...e,agentId:p.target.value,name:(m==null?void 0:m.name)??p.target.value})},className:dx,children:n.filter(p=>!p.subagent).map(p=>s.jsx("option",{value:p.id,children:p.name},p.id))})]}),e.type==="sub_agent"&&s.jsxs("div",{children:[s.jsx("label",{className:bs,children:"Sub-Agent Type"}),s.jsxs("select",{value:e.subAgentType??"",onChange:p=>{const m=n.find(g=>g.id===p.target.value);l({...e,subAgentType:p.target.value,name:(m==null?void 0:m.name)??p.target.value})},className:dx,children:[s.jsx("option",{value:"",children:"— select —"}),n.filter(p=>p.subagent).map(p=>s.jsx("option",{value:p.id,children:p.name},p.id))]})]}),(e.type==="agent"||e.type==="sub_agent")&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("label",{className:bs,children:"Prompt"}),s.jsx("textarea",{value:e.prompt??"",onChange:p=>l({...e,prompt:p.target.value||void 0}),rows:6,className:`${Na} resize-y text-xs`,placeholder:"Injected on first entry..."}),s.jsx(hx,{variables:a,onInsert:p=>l({...e,prompt:(e.prompt??"")+`{{${p}}}`})})]}),s.jsxs("div",{children:[s.jsx("label",{className:bs,children:"Nudge Prompt"}),s.jsx("textarea",{value:e.nudgePrompt??"",onChange:p=>l({...e,nudgePrompt:p.target.value||void 0}),rows:6,className:`${Na} resize-y text-xs`,placeholder:"Injected on re-entry..."}),s.jsx(hx,{variables:a,onInsert:p=>l({...e,nudgePrompt:(e.nudgePrompt??"")+`{{${p}}}`})})]})]}),e.type==="shell"&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("label",{className:bs,children:"Command"}),s.jsx("textarea",{value:e.command??"",onChange:p=>l({...e,command:p.target.value}),rows:3,className:`${Na} font-mono text-xs resize-y`,placeholder:"cd {{workdir}} && npm run lint"}),s.jsx(hx,{variables:a,onInsert:p=>l({...e,command:(e.command??"")+`{{${p}}}`})})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:bs,children:"Timeout (ms)"}),s.jsx("input",{type:"number",value:e.timeout??6e4,onChange:p=>l({...e,timeout:Number(p.target.value)}),className:`${Na} font-mono text-xs`})]}),s.jsxs("div",{children:[s.jsx("label",{className:bs,children:"Success Codes"}),s.jsx("input",{value:(e.successExitCodes??[0]).join(", "),onChange:p=>l({...e,successExitCodes:p.target.value.split(",").map(m=>Number(m.trim())).filter(m=>!isNaN(m))}),className:`${Na} font-mono text-xs`})]})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:bs,children:"Sub-group"}),s.jsx("input",{value:e.subGroup??"",onChange:p=>l({...e,subGroup:p.target.value||void 0}),placeholder:"e.g. build, verify, review",className:Na})]}),s.jsx("div",{className:"pt-1 border-t border-border/50",children:s.jsxs("p",{className:"text-text-muted text-[10px]",children:[r," outgoing transition",r!==1?"s":""," — drag from the bottom port to connect."]})})]})}const Fo="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",QC="w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary",Ta="block text-[11px] text-text-secondary mb-0.5";function WU({fromLabel:e,toLabel:t,condition:n,subGroup:r,fromStep:a,agentTypes:l,transitionIndex:u,totalTransitions:c,onUpdateCondition:d,onUpdateSubGroup:h,onDelete:p,onMoveUp:m,onMoveDown:g}){var C;const y=a&&(a.type==="sub_agent"||a.type==="agent")?l.find(_=>_.id===(a.type==="sub_agent"?a.subAgentType:a.agentId)):void 0,w=(y==null?void 0:y.results)&&y.results.length>0;return s.jsxs("div",{className:"space-y-3 text-sm",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsxs("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold bg-blue-500/15 text-blue-300",children:["#",u+1]}),c>1&&s.jsxs("div",{className:"flex items-center gap-0.5",children:[s.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:s.jsx(vn,{className:"w-3 h-3",rotate:180})}),s.jsx("button",{onClick:g,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:s.jsx(vn,{className:"w-3 h-3"})})]})]}),s.jsx("button",{onClick:p,className:"p-1 rounded text-text-muted hover:text-accent-error text-xs",children:"Delete"})]}),s.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-text-secondary",children:[s.jsx("span",{className:"font-medium text-text-primary",children:e}),s.jsx(wE,{}),s.jsx("span",{className:"font-medium text-text-primary",children:t})]}),s.jsxs("div",{children:[s.jsx("label",{className:Ta,children:"Condition"}),s.jsx("select",{value:n.type,onChange:_=>{d(_.target.value==="step_result"?{type:"step_result",result:"success"}:{type:_.target.value})},className:QC,children:CT.map(_=>s.jsx("option",{value:_.value,children:_.label},_.value))})]}),n.type==="step_result"&&s.jsxs("div",{children:[s.jsx("label",{className:Ta,children:"Result"}),w?s.jsx("select",{value:n.result??y.results[0],onChange:_=>{d({type:"step_result",result:_.target.value})},className:QC,children:y.results.map(_=>s.jsx("option",{value:_,children:_},_))}):s.jsx("input",{type:"text",value:n.result??"success",onChange:_=>d({type:"step_result",result:_.target.value}),placeholder:"e.g. success, passed, failed",className:Fo})]}),(n.type==="metadata_all_match"||n.type==="metadata_all_in")&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("label",{className:Ta,children:"Metadata Key"}),s.jsx("input",{type:"text",value:n.key??"",onChange:_=>d({...n,key:_.target.value}),placeholder:"e.g. criteria, todos, review_findings",className:Fo})]}),s.jsxs("div",{children:[s.jsx("label",{className:Ta,children:"Field"}),s.jsx("input",{type:"text",value:n.field??"",onChange:_=>d({...n,field:_.target.value}),placeholder:"e.g. status",className:Fo})]}),n.type==="metadata_all_match"?s.jsxs("div",{children:[s.jsx("label",{className:Ta,children:"Value"}),s.jsx("input",{type:"text",value:n.value??"",onChange:_=>d({...n,value:_.target.value}),placeholder:"e.g. passed, resolved",className:Fo})]}):s.jsxs("div",{children:[s.jsx("label",{className:Ta,children:"Values (comma-separated)"}),s.jsx("input",{type:"text",value:((C=n.values)==null?void 0:C.join(", "))??"",onChange:_=>d({...n,values:_.target.value.split(",").map(S=>S.trim()).filter(Boolean)}),placeholder:"e.g. resolved, dismissed",className:Fo})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:Ta,children:"Sub-group"}),s.jsx("input",{type:"text",value:r??"",onChange:_=>h(_.target.value||void 0),placeholder:"e.g. build, verify",className:Fo})]}),(a==null?void 0:a.type)==="user"&&s.jsxs("div",{className:"pt-1 border-t border-border/50 space-y-1",children:[s.jsx("p",{className:"text-text-muted text-[10px]",children:'On a user step, each "Step result is..." transition becomes a choice button; "Always" becomes a Continue button.'}),n.type==="step_result"&&a.transitions.filter(_=>_.when.type==="step_result"&&_.when.result===n.result).length>1&&s.jsxs("p",{className:"text-accent-warning text-[10px]",children:['Duplicate result "',n.result,'" — only the first matching transition is reachable.']}),n.type==="step_result"&&n.result==="continue"&&s.jsx("p",{className:"text-accent-warning text-[10px]",children:'"continue" is reserved for the "Always" Continue button — rename this result.'}),n.type==="always"&&a.transitions.some((_,S)=>S>u&&_.when.type==="step_result")&&s.jsx("p",{className:"text-accent-warning text-[10px]",children:'This "Always" transition comes before one or more choice transitions — those choice buttons are unreachable. Move it to the end.'}),n.type==="always"&&a.transitions.filter(_=>_.when.type==="always").length>1&&s.jsx("p",{className:"text-accent-warning text-[10px]",children:'Multiple "Always" transitions — only the first is reachable.'})]}),s.jsx("p",{className:"text-text-muted text-[10px]",children:"Drag handles to reconnect. Order determines evaluation priority. Press Delete to remove."})]})}function GU(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"")}function qU(e){let t=1;for(;e.some(n=>n.id===`s${t}`);)t++;return`s${t}`}const Ac="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",JC="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",Uo="block text-[11px] text-text-secondary mb-0.5",ZC=[];function kT({isOpen:e,onClose:t,initialEditId:n,projectDir:r}){var Rt,nn;const a=Ft(Ne=>Ne.defaults),l=Ft(Ne=>Ne.userItems),u=Ft(Ne=>Ne.projectItems),c=Ft(Ne=>Ne.loading),d=Ft(Ne=>Ne.templateVariables),h=Ft(Ne=>Ne.fetchWorkflows),p=Ft(Ne=>Ne.fetchWorkflow),m=Ft(Ne=>Ne.fetchDefaultContent),g=Ft(Ne=>Ne.fetchTemplateVariables),y=Ft(Ne=>Ne.createWorkflow),w=Ft(Ne=>Ne.updateWorkflow),C=Ft(Ne=>Ne.deleteWorkflow),{requestDelete:_,clearConfirm:S,isConfirming:b}=du(),[v,k]=E.useState("list"),[T,N]=E.useState(null),[R,A]=E.useState(void 0),[O,P]=E.useState(!1),[V,z]=E.useState(null),[W,M]=E.useState(null),[U,F]=E.useState(""),[Q,X]=E.useState(""),[H,I]=E.useState(""),[D,q]=E.useState("1.0.0"),[$,J]=E.useState("#3b82f6"),[Y,Z]=E.useState(""),[K,B]=E.useState(50),[ne,se]=E.useState(ZC),[re,oe]=E.useState({type:"always"}),[ve,Se]=E.useState([]),[$e,ze]=E.useState("user"),[ke,Ge]=E.useState(""),[Je,Ce]=E.useState(!1),me=ft(Ne=>Ne.defaults),We=ft(Ne=>Ne.userItems),he=ft(Ne=>Ne.projectItems),Ve=E.useMemo(()=>[...me,...We,...he],[me,We,he]),He=ft(Ne=>Ne.fetchAgents),[ie]=E.useState(null);E.useEffect(()=>{e&&(h(r),g(),He(),z(null),M(null),n?a.some(Te=>Te.id===n)?m(n,r).then(Te=>{Te&&ye({...Te,metadata:{...Te.metadata,name:Te.metadata.name+" (copy)",id:`${n}-copy-${Date.now()}`}},{editingId:null,isReadOnly:!1})}):p(n,r).then(Te=>{Te&&ye(Te,{editingId:n,isReadOnly:!1})}):(k("list"),N(null),P(!1)))},[e,h,p,m,g,n,r]);const ye=(Ne,Te)=>{F(Ne.metadata.name),X(Ne.metadata.id),I(Ne.metadata.description),q(Ne.metadata.version),J(Ne.metadata.color??"#3b82f6"),Z(Ne.entryStep),B(Ne.settings.maxIterations),se(Ne.steps),oe(Ne.startCondition??{type:"always"}),Se(Ne.metadata.parameters??[]),Ge(""),(Te==null?void 0:Te.editingId)!==void 0&&N(Te.editingId),(Te==null?void 0:Te.isReadOnly)!==void 0&&P(Te.isReadOnly),(Te==null?void 0:Te.selectedNodeKey)!==void 0&&z(null),(Te==null?void 0:Te.selectedEdgeKey)!==void 0&&M(null),k("edit")},Le=async(Ne,Te)=>{A(Te);const Pe=await p(Ne,r,Te);Pe&&ye(Pe,{editingId:Ne,isReadOnly:!1,selectedNodeKey:null,selectedEdgeKey:null})},ue=async()=>{var mt;const Ne=T??Q;if(!Ne||!U)return Ge("Name is required."),!1;if(ne.length===0)return Ge("Add at least one step."),!1;const Te=ve.find(_t=>!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(_t.id));if(Te)return Ge(`Invalid parameter ID "${Te.id}". Use letters, digits, and underscores only.`),!1;let Pe=Y;if(!Pe||!ne.some(_t=>_t.id===Pe)){if(Pe=((mt=ne.find(_t=>_t.id))==null?void 0:mt.id)??"",!Pe)return Ge("All steps need an ID."),!1;Z(Pe)}Ce(!0),Ge("");const Xe={metadata:{id:Ne,name:U,description:H,version:D||"1.0.0",color:$,...ve.length>0?{parameters:ve}:{}},entryStep:Pe,settings:{maxIterations:K},steps:ne,startCondition:re},tt=T?await w(T,Xe,r,R):await y(Xe,$e,r);return Ce(!1),tt.success?(T||N(Ne),!0):(Ge(tt.error??"Failed to save."),!1)},de=async()=>{await ue()},Fe=async()=>{await ue()&&(n?t():k("list"))},Ue=()=>{n?t():k("list")},Qe=Ne=>{F(Ne),T||X(GU(Ne))},rt=async(Ne,Te)=>a.some(Xe=>Xe.id===Ne)?await m(Ne,r):await p(Ne,r,Te),pe=async(Ne,Te)=>{const Pe=await rt(Ne,Te);Pe&&ye({...Pe,metadata:{...Pe.metadata,name:Pe.metadata.name+" (copy)",id:`${Ne}-copy-${Date.now()}`}},{editingId:null,isReadOnly:!1})},Ie=()=>{N(null),A(void 0),F(""),X(""),I(""),q("1.0.0"),J("#3b82f6"),Z(""),B(50),se(structuredClone(ZC)),oe({type:"always"}),Se([]),ze("user"),Ge(""),z(null),M(null),P(!1),k("edit")},it=async(Ne,Te)=>{await C(Ne,Te,r),S()},ut=E.useCallback(Ne=>{z(Ne),M(null)},[]),$t=E.useCallback(Ne=>{M(Ne),z(null)},[]),Ut=V!==null?Number(V):-1,At=Ut>=0?ne[Ut]??null:null,Mn=E.useCallback(Ne=>{se(Te=>Te.map((Pe,Xe)=>Xe===Ut?Ne:Pe))},[Ut]),_n=re.type==="step_result"?`${re.result}`:re.type==="metadata_all_match"?`${re.key??"?"}=${re.value??"?"}`:re.type==="metadata_all_in"?`${re.key??"?"} in [${((Rt=re.values)==null?void 0:Rt.join(","))??"?"}]`:wT[re.type]??re.type,dn=()=>{const Ne=ne.length,Te=qU(ne),Pe=Ve.find(Xe=>!Xe.subagent);se([...ne,{id:Te,name:(Pe==null?void 0:Pe.name)??"Agent",type:"agent",phase:"build",agentId:(Pe==null?void 0:Pe.id)??"builder",transitions:[]}]),Y||Z(Te),ut(String(Ne))},An=E.useCallback((Ne,Te)=>{Ne==="$start"?(Z(Te),$t("start")):se(Pe=>{const Xe=Pe.find(mt=>mt.id===Ne),tt=Xe?Xe.transitions.length:0;return $t(`${Ne}:${tt}`),Pe.map(mt=>mt.id===Ne?{...mt,transitions:[...mt.transitions,{when:{type:"always"},goto:Te}]}:mt)})},[$t]),Sn=Ne=>{if(Ne==="start")return null;const Te=Ne.lastIndexOf(":"),Pe=Ne.slice(0,Te),Xe=parseInt(Ne.slice(Te+1));return{stepId:Pe,transIdx:Xe}},cn=E.useCallback((Ne,Te)=>{const Pe=Sn(Ne);Pe&&se(Xe=>Xe.map(tt=>tt.id===Pe.stepId?{...tt,transitions:tt.transitions.map((mt,_t)=>_t===Pe.transIdx?Te(mt):mt)}:tt))},[]),er=E.useCallback((Ne,Te)=>{if(Ne==="start"){Z(Te);return}cn(Ne,Pe=>({...Pe,goto:Te}))},[cn]),be=E.useCallback((Ne,Te)=>{const Pe=Sn(Ne);Pe&&(se(Xe=>{const tt=Xe.find(_t=>_t.id===Pe.stepId);if(!tt)return Xe;const mt=tt.transitions[Pe.transIdx];return mt?Xe.map(_t=>_t.id===Pe.stepId?{..._t,transitions:_t.transitions.filter((Ln,mn)=>mn!==Pe.transIdx)}:_t.id===Te?{..._t,transitions:[..._t.transitions,mt]}:_t):Xe}),M(null))},[]),et=E.useCallback(Ne=>{if(Ne==="start"){Z(""),M(null);return}const Te=Sn(Ne);Te&&(se(Pe=>Pe.map(Xe=>Xe.id===Te.stepId?{...Xe,transitions:Xe.transitions.filter((tt,mt)=>mt!==Te.transIdx)}:Xe)),M(null))},[]),Ye=E.useCallback((Ne,Te)=>{if(Ne==="start"){oe(Te);return}cn(Ne,Pe=>({...Pe,when:Te}))},[cn]),ae=E.useCallback((Ne,Te)=>{Ne!=="start"&&cn(Ne,Pe=>({...Pe,subGroup:Te||void 0}))},[cn]),Me=Ne=>Mb(Ne,Ve).name,Ze=()=>{if(!W)return null;if(W==="start"){const Ln=ne.find(mn=>mn.id===Y);return{type:"start",fromLabel:"Start",toLabel:Ln?Me(Ln):"(none)",condition:re}}const Ne=W.lastIndexOf(":"),Te=W.slice(0,Ne),Pe=parseInt(W.slice(Ne+1)),Xe=ne.find(Ln=>Ln.id===Te);if(!Xe)return null;const tt=Xe.transitions[Pe];if(!tt)return null;const mt=ne.find(Ln=>Ln.id===tt.goto),_t=tt.goto==="$done"?"Done":mt?Me(mt):tt.goto;return{type:"step",fromLabel:Me(Xe),toLabel:_t,condition:tt.when,subGroup:tt.subGroup}};if(v==="edit"){const Ne=Ze();return s.jsxs(jt,{isOpen:e,onClose:Ue,title:O?U:T?"Edit Workflow":"New Workflow",size:"full",children:[ke&&s.jsx("div",{className:"text-accent-error text-sm px-3 py-2 bg-accent-error/10 rounded mb-3",children:ke}),s.jsx(FU,{formName:U,formId:Q,formDescription:H,formMaxIterations:K,formColor:$,isReadOnly:O,onNameChange:Qe,onDescriptionChange:I,onMaxIterationsChange:B,onColorChange:J}),!O&&s.jsx("div",{className:"mb-3 pb-3 border-b border-border",children:s.jsxs(BU,{title:`Parameters (${ve.length})`,children:[ve.map((Te,Pe)=>s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx("input",{value:Te.id,onChange:Xe=>{const tt=[...ve];tt[Pe]={...Te,id:Xe.target.value},Se(tt)},placeholder:"ID",className:"w-28 px-2 py-1 bg-bg-tertiary border border-border rounded text-xs font-mono focus:outline-none focus:ring-1 focus:ring-accent-primary"}),s.jsx("input",{value:Te.label,onChange:Xe=>{const tt=[...ve];tt[Pe]={...Te,label:Xe.target.value},Se(tt)},placeholder:"Label",className:"w-36 px-2 py-1 bg-bg-tertiary border border-border rounded text-xs focus:outline-none focus:ring-1 focus:ring-accent-primary"}),s.jsx("input",{value:Te.description??"",onChange:Xe=>{const tt=[...ve];tt[Pe]={...Te,description:Xe.target.value||void 0},Se(tt)},placeholder:"Description",className:"flex-1 px-2 py-1 bg-bg-tertiary border border-border rounded text-xs focus:outline-none focus:ring-1 focus:ring-accent-primary"}),s.jsxs("label",{className:"flex items-center gap-1 text-[10px] text-text-muted whitespace-nowrap",children:[s.jsx("input",{type:"checkbox",checked:Te.required??!1,onChange:Xe=>{const tt=[...ve];tt[Pe]={...Te,required:Xe.target.checked||void 0},Se(tt)},className:"rounded border-border"}),"Req."]}),s.jsxs("div",{className:"flex gap-0.5",children:[s.jsx("button",{onClick:()=>{Pe!==0&&Se(ve.map((Xe,tt)=>tt===Pe?{...ve[Pe-1],position:tt}:tt===Pe-1?{...ve[Pe],position:tt}:{...Xe,position:tt}))},disabled:Pe===0,className:"p-1 text-text-muted hover:text-text-primary disabled:opacity-30 transition-colors",title:"Move up","aria-label":`Move ${Te.label||Te.id} up`,children:"▲"}),s.jsx("button",{onClick:()=>{Pe!==ve.length-1&&Se(ve.map((Xe,tt)=>tt===Pe?{...ve[Pe+1],position:tt}:tt===Pe+1?{...ve[Pe],position:tt}:{...Xe,position:tt}))},disabled:Pe===ve.length-1,className:"p-1 text-text-muted hover:text-text-primary disabled:opacity-30 transition-colors",title:"Move down","aria-label":`Move ${Te.label||Te.id} down`,children:"▼"})]}),s.jsx("button",{onClick:()=>Se(ve.filter((Xe,tt)=>tt!==Pe)),className:"p-1 text-text-muted hover:text-accent-error transition-colors",title:"Remove parameter",children:"✕"})]},Te.id)),s.jsx("button",{onClick:()=>{const Te=`param_${ve.length+1}`;Se([...ve,{id:Te,label:"",description:"",required:!1}])},className:"text-xs text-accent-primary hover:text-accent-primary/80 transition-colors",children:"+ Add parameter"})]})}),!T&&!O&&s.jsx(vf,{value:$e,onChange:ze}),s.jsxs("div",{className:"flex gap-3",style:{height:"calc(90vh - 220px)",minHeight:300},children:[s.jsxs("div",{className:"flex-1 min-w-0 bg-bg-primary/50 border border-border rounded-lg flex flex-col overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-border/50 shrink-0",children:[s.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-wider font-medium",children:"Flow"}),!O&&s.jsx("button",{onClick:dn,className:"text-[11px] text-accent-primary hover:text-accent-primary/80",children:"+ Add Step"})]}),s.jsxs(ct,{className:"flex-1 min-h-0 p-2",children:[s.jsx(HU,{steps:ne,entryStep:Y,selectedNodeId:(At==null?void 0:At.id)??null,selectedEdgeKey:W,startConditionLabel:_n,agentTypes:Ve,isReadOnly:O,onSelectNode:Te=>{if(Te===null){ut(null);return}const Pe=ne.findIndex(Xe=>Xe.id===Te);ut(Pe>=0?String(Pe):null)},onSelectEdge:$t,onRemoveStep:Te=>{var Xe;const Pe=ne.findIndex(tt=>tt.id===Te);if(se(tt=>tt.filter(mt=>mt.id!==Te)),Ut===Pe&&ut(null),Y===Te){const tt=ne.filter(mt=>mt.id!==Te);Z(((Xe=tt[0])==null?void 0:Xe.id)??"")}},onCreateTransition:An,onReconnectTo:er,onReconnectFrom:be,onDeleteTransition:et}),ne.length===0&&s.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-text-muted",children:[s.jsx("p",{className:"text-xs mb-2",children:"No steps yet"}),s.jsx("button",{onClick:dn,className:"px-3 py-1.5 rounded bg-accent-primary/10 text-accent-primary text-xs hover:bg-accent-primary/20",children:"+ Add your first step"})]})]})]}),s.jsxs("div",{className:"w-[300px] shrink-0 border border-border rounded-lg bg-bg-secondary flex flex-col overflow-hidden",children:[s.jsx("div",{className:"px-3 py-1.5 border-b border-border shrink-0",children:s.jsx("span",{className:"text-[10px] text-text-muted uppercase tracking-wider font-medium",children:"Properties"})}),s.jsx(ct,{className:"p-3 flex-1 min-h-0",children:O&&(Ne||At)?s.jsx("p",{className:"text-text-muted text-xs text-center py-8",children:'View only — click "Duplicate & Customize" to edit.'}):Ne?Ne.type==="start"?s.jsxs("div",{className:"space-y-3 text-sm",children:[s.jsx("div",{className:"flex items-center gap-2",children:s.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-semibold bg-blue-500/20 text-blue-300",children:"Start"})}),Y&&s.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-text-secondary",children:[s.jsx("span",{className:"text-text-primary font-medium",children:"Start"}),s.jsx(wE,{}),s.jsx("span",{className:"text-text-primary font-medium",children:Ne.toLabel})]}),s.jsxs("div",{children:[s.jsx("label",{className:Uo,children:"Activation Condition"}),s.jsx("select",{value:re.type,onChange:Te=>oe(Te.target.value==="step_result"?{type:"step_result",result:"success"}:Te.target.value==="metadata_all_match"?{type:"metadata_all_match",key:"",field:"",value:""}:Te.target.value==="metadata_all_in"?{type:"metadata_all_in",key:"",field:"",values:[]}:{type:Te.target.value}),className:JC,children:CT.map(Te=>s.jsx("option",{value:Te.value,children:Te.label},Te.value))})]}),re.type==="step_result"&&s.jsxs("div",{children:[s.jsx("label",{className:Uo,children:"Result"}),Y&&(()=>{const Te=ne.find(mt=>mt.id===Y),Pe=Te&&(Te.type==="sub_agent"||Te.type==="agent")?Ve.find(mt=>mt.id===(Te.type==="sub_agent"?Te.subAgentType:Te.agentId)):void 0,Xe=(Pe==null?void 0:Pe.results)&&Pe.results.length>0,tt=(Pe==null?void 0:Pe.results)??[];return Xe?s.jsx("select",{value:re.result??tt[0],onChange:mt=>oe({type:"step_result",result:mt.target.value}),className:JC,children:tt.map(mt=>s.jsx("option",{value:mt,children:mt},mt))}):s.jsx("input",{type:"text",value:re.result??"success",onChange:mt=>oe({type:"step_result",result:mt.target.value}),placeholder:"e.g. success, passed, failed",className:Ac})})()]}),(re.type==="metadata_all_match"||re.type==="metadata_all_in")&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("label",{className:Uo,children:"Metadata Key"}),s.jsx("input",{type:"text",value:re.key??"",onChange:Te=>oe({...re,key:Te.target.value}),placeholder:"e.g. criteria, todos, review_findings",className:Ac})]}),s.jsxs("div",{children:[s.jsx("label",{className:Uo,children:"Field"}),s.jsx("input",{type:"text",value:re.field??"",onChange:Te=>oe({...re,field:Te.target.value}),placeholder:"e.g. status",className:Ac})]}),re.type==="metadata_all_match"?s.jsxs("div",{children:[s.jsx("label",{className:Uo,children:"Value"}),s.jsx("input",{type:"text",value:re.value??"",onChange:Te=>oe({...re,value:Te.target.value}),placeholder:"e.g. passed, resolved",className:Ac})]}):s.jsxs("div",{children:[s.jsx("label",{className:Uo,children:"Values (comma-separated)"}),s.jsx("input",{type:"text",value:((nn=re.values)==null?void 0:nn.join(", "))??"",onChange:Te=>oe({...re,values:Te.target.value.split(",").map(Pe=>Pe.trim()).filter(Boolean)}),placeholder:"e.g. resolved, dismissed",className:Ac})]})]}),s.jsx("p",{className:"text-text-muted text-[10px]",children:"Workflow only proceeds when this condition is met. Drag the target handle to change entry step."})]}):(()=>{const Te=Sn(W),Pe=Te==null?void 0:Te.stepId,Xe=(Te==null?void 0:Te.transIdx)??0,tt=Pe?ne.find(_t=>_t.id===Pe):void 0,mt=(tt==null?void 0:tt.transitions.length)??0;return s.jsx(WU,{fromLabel:Ne.fromLabel,toLabel:Ne.toLabel,condition:Ne.condition,subGroup:"subGroup"in Ne?Ne.subGroup:void 0,fromStep:Ne.type==="step"?ne.find(_t=>_t.id===Ne.fromLabel):void 0,agentTypes:Ve,transitionIndex:Xe,totalTransitions:mt,onUpdateCondition:_t=>Ye(W,_t),onUpdateSubGroup:_t=>ae(W,_t),onDelete:()=>et(W),onMoveUp:()=>{se(_t=>{const Ln=_t.find(wn=>wn.id===Pe);if(!Ln||Xe===0)return _t;const mn=[...Ln.transitions];return[mn[Xe-1],mn[Xe]]=[mn[Xe],mn[Xe-1]],_t.map(wn=>wn.id===Pe?{...wn,transitions:mn}:wn)}),M(`${Pe}:${Xe-1}`)},onMoveDown:()=>{se(_t=>{const Ln=_t.find(wn=>wn.id===Pe);if(!Ln||Xe===Ln.transitions.length-1)return _t;const mn=[...Ln.transitions];return[mn[Xe],mn[Xe+1]]=[mn[Xe+1],mn[Xe]],_t.map(wn=>wn.id===Pe?{...wn,transitions:mn}:wn)}),M(`${Pe}:${Xe+1}`)}})})():At?s.jsx(VU,{step:At,isEntry:At.id===Y,agentTypes:Ve,transitionCount:At.transitions.length,templateVariables:d,onUpdate:Mn,onRemove:()=>{var Te;if(At&&(se(ne.filter((Pe,Xe)=>Xe!==Ut)),ut(null),Y===At.id)){const Pe=ne.filter((Xe,tt)=>tt!==Ut);Z(((Te=Pe[0])==null?void 0:Te.id)??"")}},onSetEntry:()=>Z(At.id)}):s.jsxs("p",{className:"text-text-muted text-xs text-center py-8",children:["Click a node or edge to edit.",s.jsx("br",{}),"Drag from a port to connect."]})})]})]}),s.jsxs("div",{className:"flex justify-end gap-2 pt-3 mt-3 border-t border-border",children:[s.jsx(dt,{variant:"secondary",onClick:Ue,children:"Close"}),O?s.jsx(dt,{variant:"primary",onClick:()=>{F(U+" (copy)"),X(`${T}-copy-${Date.now()}`),N(null),P(!1)},children:"Duplicate & Customize"}):s.jsxs(s.Fragment,{children:[s.jsx(dt,{variant:"primary",onClick:de,children:"Save"}),s.jsx(dt,{variant:"primary",onClick:Fe,children:"Save & Close"})]})]})]})}return s.jsx(jt,{isOpen:e,onClose:t,title:"Workflows",size:"lg",children:s.jsx(OE,{description:"Workflows define multi-step agentic processes with branching transitions.",onNew:Ie,loading:c,hasItems:a.length>0||l.length>0||u.length>0,children:s.jsxs("div",{className:"space-y-4",children:[s.jsx(ux,{title:"Built-in",items:a,renderActions:Ne=>s.jsx(s.Fragment,{children:s.jsx(ci,{onClick:()=>pe(Ne.id),children:s.jsx(My,{})})})}),s.jsx(ux,{title:"Custom",items:l,renderActions:Ne=>s.jsxs(s.Fragment,{children:[s.jsx(ci,{onClick:()=>Le(Ne.id,"user"),children:s.jsx("span",{className:"text-[10px]",children:"Edit"})}),s.jsx(Jc,{onClick:()=>pe(Ne.id,"user")}),b(`user:${Ne.id}`,"delete")?s.jsx(Ah,{onConfirm:()=>it(Ne.id,"user"),onCancel:S}):s.jsx(Lh,{onClick:()=>_(`user:${Ne.id}`)})]})}),u.length>0&&s.jsx(ux,{title:"Project",items:u,renderActions:Ne=>s.jsxs(s.Fragment,{children:[s.jsx(ci,{onClick:()=>Le(Ne.id,"project"),children:s.jsx("span",{className:"text-[10px]",children:"Edit"})}),s.jsx(Jc,{onClick:()=>pe(Ne.id,"project")}),b(`project:${Ne.id}`,"delete")?s.jsx(Ah,{onConfirm:()=>it(Ne.id,"project"),onCancel:S}):s.jsx(Lh,{onClick:()=>_(`project:${Ne.id}`)})]})})]})})})}function KU(e){const t=e.match(/^\/p\/([^/]+)/);return t==null?void 0:t[1]}function YU({isOpen:e,onClose:t,onCloseComplete:n,onSelectCommand:r,onSelectWorkflow:a,onCloseCompleteAction:l,textareaContent:u,onSearchMessages:c,onToggleAutoScroll:d,isAutoScrollActive:h}){const[,p]=Gn(),m=ln($=>$.fetchCommands),g=Ft($=>$.fetchWorkflows),y=ft($=>$.fetchAgents),w=ln($=>$.defaults),C=ln($=>$.userItems),_=ln($=>$.projectItems),S=Ft($=>$.defaults),b=Ft($=>$.userItems),v=Ft($=>$.projectItems),k=ft($=>$.defaults),T=ft($=>$.userItems),N=ft($=>$.projectItems),R=De($=>{var J;return(J=$.currentSession)==null?void 0:J.mode}),A=De($=>{var J;return((J=$.currentSession)==null?void 0:J.dangerLevel)??"normal"}),O=De($=>$.switchMode),P=De($=>$.switchDangerLevel),V=De($=>{var J;return(J=$.currentSession)==null?void 0:J.projectId}),z=E.useRef(void 0),[W,M]=E.useState(""),[U,F]=E.useState(0),Q=E.useRef(null),X=E.useRef(!1);E.useEffect(()=>{e&&(X.current=!0)},[e]),E.useEffect(()=>{if(e){m(),g(),y(),M(""),F(0);const $=setTimeout(()=>{var J;Bt()&&((J=Q.current)==null||J.focus())},50);return()=>clearTimeout($)}},[e,m,g,y]),E.useEffect(()=>{var $;!e&&X.current&&(n==null||n(),($=z.current)==null||$.call(z),z.current=void 0)},[e,n]);const I=[{id:"create-session",name:"New Session",prefix:"Action > Create",action:()=>{const $=V??KU(window.location.pathname);$&&p(`/p/${$}/new`)}},{id:"navigate-session",name:"Another Session",prefix:"Action > Navigate to",action:()=>{z.current=l,t()}},{id:"search-messages",name:"Messages",prefix:"Action > Search",action:()=>{t(),c==null||c()}},{id:"toggle-autoscroll",name:h?"Auto-scroll Off":"Auto-scroll On",prefix:"Action > Toggle",action:()=>{t(),d==null||d(!h)}},...fr(fr(k,T),N).filter($=>!$.subagent&&$.id!==R).map($=>({id:$.id,name:$.name,prefix:"Agent > Switch to",action:()=>O($.id)})),...fr(fr(w,C),_).map($=>({id:$.id,name:$.name,prefix:"Command > Launch",action:()=>r($.id,u)})),...fr(fr(S,b),v).map($=>({id:$.id,name:$.name,prefix:"Workflow > Run",action:()=>a($.id,$.scope)})),...["normal","dangerous"].filter($=>$!==A).map($=>({id:$,name:$.charAt(0).toUpperCase()+$.slice(1),prefix:"Mode > Switch to",action:()=>P($)}))].filter($=>Ui(`${$.prefix} ${$.name}`,W)),D=I.length-1,q=$=>{HN($,D,F,()=>{var J;(J=I[U])==null||J.action(),t()},t)};return e?ui.createPortal(s.jsxs("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[15vh] p-4",children:[s.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:t}),s.jsxs("div",{className:"relative w-full max-w-md bg-bg-secondary border border-border rounded shadow-xl",children:[s.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-border",children:[s.jsx("input",{ref:Q,type:"text",value:W,onChange:$=>{M($.target.value),F(0)},onKeyDown:q,placeholder:"Search...",className:"flex-1 bg-transparent text-sm focus:outline-none placeholder:text-text-muted"}),s.jsx(zy,{onClick:t,className:"shrink-0","aria-label":"Close"})]}),s.jsx(ct,{className:"max-h-[60vh] p-2",children:I.length===0?s.jsx("div",{className:"px-3 py-4 text-center text-text-muted text-sm",children:w.length+C.length+S.length+b.length>0?"No matches":"No agents, commands, or workflows yet"}):I.map(($,J)=>s.jsxs("button",{type:"button",onClick:()=>{$.action(),t()},className:`w-full text-left px-3 py-2 rounded text-sm transition-colors ${J===U?"bg-accent-primary/20 text-text-primary":"text-text-secondary hover:bg-bg-tertiary hover:text-text-primary"}`,children:[s.jsxs("span",{className:"text-text-muted font-normal",children:[$.prefix," "]}),s.jsx("span",{children:$.name})]},$.id))})]})]}),document.body):null}const ET="openfox-message-search-filters",XU=[{key:"user",label:"User prompts"},{key:"thinking",label:"Thinking"},{key:"response",label:"Responses"}];function QU(){try{const e=localStorage.getItem(ET);if(e){const t=JSON.parse(e);return new Set(t)}}catch{}return new Set(["user","thinking","response"])}function JU(e){localStorage.setItem(ET,JSON.stringify([...e]))}function ZU(e){var n,r;if(e.type!=="message")return null;const t=e.message;if(t.role==="user")return"user";if(t.role==="assistant"){if((n=t.content)!=null&&n.trim())return"response";if((r=t.thinkingContent)!=null&&r.trim())return"thinking"}return null}function eV(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 tV(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 nV(e){var t,n;if(e.type==="message"){const r=e.message;if(r.role==="assistant"){const a=(t=r.content)==null?void 0:t.trim();return((n=r.thinkingContent)==null?void 0:n.trim())&&!a?"italic text-text-muted":""}if(r.role==="user")return"font-bold"}return""}function rV(e){var n,r;if(e.type!=="message")return s.jsx(A1,{className:"w-3.5 h-3.5"});const t=e.message;return t.role==="assistant"?(n=t.thinkingContent)!=null&&n.trim()&&!((r=t.content)!=null&&r.trim())?s.jsx(F3,{className:"w-3.5 h-3.5"}):s.jsx(A1,{className:"w-3.5 h-3.5"}):s.jsx(H3,{className:"w-3.5 h-3.5"})}function ek(e){var t;if(e.type==="message"){const n=e.message,r=n.content||"",a=r.replace(/<[^>]+>/g,"").replace(/\s+/g," ").trim();if(n.messageKind==="workflow-started")try{return`Workflow: ${JSON.parse(r).workflowName}`}catch{return"Workflow started"}if(n.messageKind==="task-completed")return"Task completed";if(n.messageKind==="auto-prompt")return"Auto-prompt";if(n.messageKind==="correction")return"Correction";if(n.messageKind==="context-reset")return"Context reset";if(n.messageKind==="command")return"Command executed";if(n.role==="assistant")return a?a.slice(0,200):(t=n.thinkingContent)!=null&&t.trim()?n.thinkingContent.slice(0,200):"";const l=a.slice(0,200);return l.length<a.length?`${l}...`:l}return e.type==="subagent"?`Sub-agent: ${e.subAgentType}`:""}function sV({isOpen:e,onClose:t,displayItems:n,onNavigate:r}){const[a,l]=E.useState(""),[u,c]=E.useState(0),[d,h]=E.useState(QU),p=E.useRef(null),m=E.useRef(null),g=E.useRef(null),y=T=>{h(N=>{const R=new Set(N);return R.has(T)?R.delete(T):R.add(T),JU(R),R})},w=E.useMemo(()=>n.filter(T=>{var N,R;return!(T.type==="context-divider"||T.type==="message"&&(T.message.messageKind==="auto-prompt"||T.message.role==="assistant"&&!((N=T.message.content)!=null&&N.trim())&&!((R=T.message.thinkingContent)!=null&&R.trim())))}),[n]),C=E.useMemo(()=>w.filter(T=>{const N=ZU(T);return!(N&&!d.has(N))}),[w,d]),_=E.useMemo(()=>a?w.filter(T=>{const N=ek(T);return Ui(N,a)}):C,[C,a]),S=_.length-1;E.useEffect(()=>{if(e){l(""),c(0);const T=setTimeout(()=>{var N;Bt()&&((N=p.current)==null||N.focus())},50);return()=>clearTimeout(T)}},[e]),E.useEffect(()=>{var T;if(e&&m.current){const N=(T=m.current.osInstance())==null?void 0:T.elements().viewport;N&&(N.scrollTop=N.scrollHeight)}},[e]),E.useEffect(()=>{g.current&&g.current.scrollIntoView({block:"nearest",behavior:"smooth"})},[u]);const b=T=>{HN(T,S,c,()=>{const N=_[u];if(N){const R=n.indexOf(N);R>=0&&r(R),t()}},t)},v=T=>{const N=n.indexOf(T);N>=0&&r(N),t()},k=T=>n.indexOf(T);return e?ui.createPortal(s.jsxs("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[15vh] p-4",children:[s.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm",onClick:t}),s.jsxs("div",{className:"relative w-full max-w-lg bg-bg-secondary border border-border rounded shadow-xl",children:[s.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-border",children:[s.jsx(Xi,{}),s.jsx("input",{ref:p,type:"text",value:a,onChange:T=>{l(T.target.value),c(0)},onKeyDown:b,placeholder:"Search timeline...",className:"flex-1 bg-transparent text-sm focus:outline-none placeholder:text-text-muted"}),s.jsx("button",{type:"button",onClick:t,className:"p-0.5 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors","aria-label":"Close",children:s.jsx(Ji,{className:"w-4 h-4"})})]}),s.jsx("div",{className:"flex gap-1.5 px-4 py-2 border-b border-border",children:XU.map(T=>{const N=d.has(T.key);return s.jsx("button",{type:"button",onClick:()=>y(T.key),className:`px-2 py-0.5 rounded text-xs font-medium transition-colors ${N?"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:T.label},T.key)})}),s.jsx(ct,{ref:m,className:"max-h-[60vh] p-2",children:_.length===0?s.jsx("div",{className:"px-3 py-4 text-center text-text-muted text-sm",children:C.length>0?"No matches":"No messages yet"}):_.map((T,N)=>{const R=k(T),A=rV(T),O=ek(T),P=nV(T),V=tV(T),z=T.type==="message"&&T.message.role==="user";return s.jsx("button",{ref:N===u?g:null,type:"button",onClick:()=>v(T),className:`w-full text-left px-3 py-2 rounded text-sm transition-colors ${N===u?"bg-accent-primary/20 text-text-primary":z?"bg-accent-primary/5 text-text-secondary hover:bg-accent-primary/10 hover:text-text-primary":"text-text-secondary hover:bg-bg-tertiary hover:text-text-primary"}`,children:s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 flex-1",children:[s.jsx("span",{className:"flex-shrink-0",children:A}),s.jsx("span",{className:`truncate flex-1 ${P}`,children:O})]}),V&&s.jsx("span",{className:"text-text-muted text-xs shrink-0",children:eV(V)})]})},`${R}-${T.type}`)})})]})]}),document.body):null}function jT(e){const t=new Set,n=[],r=/\{\{(\w+)\}\}/g;let a;for(;(a=r.exec(e))!==null;){const l=a[1];t.has(l)||(t.add(l),n.push(l))}return n}function iV(e,t,n){const r=e.trim();if(!r.startsWith("/"))return null;const a=r.slice(1).split(/\s+/),l=a[0];if(!l)return null;const u=a.slice(1),c={},d=t.find(h=>h.id===l);return d?(d.parameters&&d.parameters.length>0?[...d.parameters].sort((p,m)=>(p.position??0)-(m.position??0)).forEach((p,m)=>{u[m]!==void 0&&(c[p.id]=u[m])}):u.forEach((h,p)=>{c[String(p)]=h}),{workflowId:l,params:c}):n&&n.find(p=>p.id===l)?(u.forEach((p,m)=>{c[String(m)]=p}),{commandId:l,params:c}):null}function aV({history:e,selectedIndex:t,onSelect:n,onEscape:r,onNavigate:a}){const l=E.useRef(null),u=E.useRef(null);E.useEffect(()=>{var h;u.current&&((h=l.current)!=null&&h.getElement())&&u.current.scrollIntoView({block:"nearest",behavior:"smooth"})},[t]);const c=h=>{switch(h.key){case"Enter":h.preventDefault(),e[t]&&n(e[t].content);break;case"Escape":h.preventDefault(),r();break;case"ArrowUp":h.preventDefault(),a("up");break;case"ArrowDown":h.preventDefault(),a("down");break}},d=h=>{n(h)};return s.jsx(ct,{ref:l,role:"list",className:"mb-2 p-2 bg-bg-secondary border border-border rounded-lg max-h-64",onKeyDown:c,children:e.map((h,p)=>s.jsxs("div",{ref:p===t?u:null,role:"listitem",onClick:()=>d(h.content),className:`
315
+ p-2 rounded cursor-pointer transition-colors
316
+ ${p===t?"bg-accent-primary/20 border border-accent-primary":"hover:bg-bg-tertiary"}
317
+ `,children:[s.jsxs("div",{className:"text-xs text-text-muted font-mono",children:[h.formattedTimestamp,h.sessionName&&s.jsxs(s.Fragment,{children:[" | ",s.jsx("span",{className:"text-accent-primary font-medium",children:h.sessionName})]})]}),s.jsx("div",{className:"text-sm text-text-primary mt-1",children:h.trimmedContent})]},h.id))})}function oV(){const e=y3(),t=e?"bg-amber-400":"bg-accent-primary";return s.jsxs("div",{className:"flex items-center gap-3 text-xs text-text-muted py-2",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsxs("span",{className:"flex gap-0.5",children:[s.jsx("span",{className:`w-1 h-1 rounded-full animate-bounce ${t}`,style:{animationDelay:"0ms"}}),s.jsx("span",{className:`w-1 h-1 rounded-full animate-bounce ${t}`,style:{animationDelay:"150ms"}}),s.jsx("span",{className:`w-1 h-1 rounded-full animate-bounce ${t}`,style:{animationDelay:"300ms"}})]}),s.jsx("span",{className:"text-text-secondary",children:e?"Running... (abort in progress)":"Running"})]}),!e&&s.jsx("span",{className:"text-text-muted hidden sm:inline",children:"esc to interrupt"})]})}function lV(){const e=De(u=>u.activeWorkflowExecution),t=De(u=>u.exitWorkflow),[n,r]=E.useState(!1);E.useEffect(()=>{r(!1)},[e==null?void 0:e.id]);const a=E.useCallback(()=>{n||(r(!0),t())},[n,t]);if(!e||e.status!=="running"&&e.status!=="waiting")return null;const l=e.workflowColor&&/^#[0-9a-fA-F]{6}$/.test(e.workflowColor)?e.workflowColor:"#3b82f6";return s.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 text-xs border-b border-border",children:[s.jsx("span",{className:"w-2 h-2 rounded-full shrink-0",style:{backgroundColor:l}}),s.jsx("span",{className:"font-medium text-text-primary truncate",children:e.workflowName}),e.currentStepName&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-text-muted",children:"·"}),s.jsx("span",{className:"text-text-muted truncate",children:e.currentStepName})]}),s.jsx("div",{className:"ml-auto shrink-0",children:s.jsx("button",{onClick:a,disabled:n,className:"text-xs px-2 py-0.5 rounded text-text-tool-error hover:bg-text-tool-error/10 transition-colors disabled:opacity-50",children:n?"Exiting...":"✕ Exit"})})]})}const cV={maxWidth:1920,maxHeight:1920,quality:.85,maxSizeBytes:1048576};async function uV(e,t={}){const n={...cV,...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=xV(a),u=`data:${e.type};base64,${l}`,c=await NT(u);return{dataUrl:u,mimeType:e.type,size:e.size,width:c.width,height:c.height}}return await dV(e,n)}async function dV(e,t){const n=await fV(e),r=await NT(n),{width:a,height:l}=hV(r.width,r.height,t.maxWidth,t.maxHeight),u=mV();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(r,0,0,a,l);let d=t.quality,h="";for(let m=0;m<10&&(h=u.toDataURL(e.type.startsWith("image/gif")?"image/png":e.type,d),!(tk(h)<=t.maxSizeBytes||d<=.3));m++)d-=.1;const p=tk(h);return{dataUrl:h,mimeType:e.type.startsWith("image/gif")?"image/png":e.type,size:p,width:a,height:l}}function hV(e,t,n,r){const a=e/t;return e>t&&e>n?{width:n,height:Math.round(n/a)}:t>e&&t>r?{width:Math.round(r*a),height:r}:{width:e,height:t}}function fV(e){return new Promise((t,n)=>{const r=gV(),a=new r;a.onload=()=>t(a.result),a.onerror=()=>n(new Error("Failed to read file")),a.readAsDataURL(e)})}function NT(e){return new Promise((t,n)=>{const r=pV(),a=new r;a.onload=()=>t(a),a.onerror=()=>n(new Error("Failed to load image")),a.src=e})}function mV(){var t;const e=Pb();if(!((t=e.document)!=null&&t.createElement))throw new Error("Image compression requires browser canvas APIs");return e.document.createElement("canvas")}function pV(){const e=Pb();if(!e.Image)throw new Error("Image compression requires browser image APIs");return e.Image}function gV(){const e=Pb();if(!e.FileReader)throw new Error("Image compression requires browser file APIs");return e.FileReader}function Pb(){return globalThis}function xV(e){const t=new Uint8Array(e);let n="";for(let r=0;r<t.byteLength;r++){const a=t[r];a!==void 0&&(n+=String.fromCharCode(a))}return btoa(n)}function tk(e){const n=e.split(",")[1];return n?Math.round(n.length*3/4):0}const nk=50*1024*1024,rk=1024*1024,yV=["image/png","image/jpeg","image/gif"];function bV(e){return e==="application/pdf"}function vV(e){return yV.includes(e.type)}async function _V(e){return await new Promise((t,n)=>{const r=new FileReader;r.onload=()=>t(r.result),r.onerror=()=>n(new Error("Failed to read file")),r.readAsDataURL(e)})}async function sk(e,t,n){try{if(Ib(e.type)){if(e.size>rk){n(`Text file too large (${Jo(e.size)}). Maximum is ${Jo(rk)}.`);return}const r=await e.text(),a={id:ph(),filename:e.name||"unnamed-file",mimeType:e.type,size:e.size,data:r};t(a)}else if(Sh(e.type)||bV(e.type)){if(e.size>nk){const r=Sh(e.type)?"Image":"PDF";n(`${r} file too large (${Jo(e.size)}). Maximum is ${Jo(nk)}.`);return}if(Sh(e.type)&&vV(e)){const r=await uV(e,{maxWidth:1920,maxHeight:1920,quality:.85,maxSizeBytes:1048576}),a={id:ph(),filename:e.name||"unnamed-file",mimeType:r.mimeType,size:r.size,data:r.dataUrl};t(a)}else{const r=await _V(e),a={id:ph(),filename:e.name||"unnamed-file",mimeType:e.type,size:e.size,data:r};t(a)}}else n(`Unsupported file type: ${e.type}. Supported types: images (PNG, JPG, GIF, WebP, BMP, SVG), PDF, text files, JSON, XML, YAML, and other common text-based formats.`)}catch(r){const a=r instanceof Error?r.message??"Failed to process file":"Failed to process file";n(a)}}function TT(e){const t=De(l=>l.sendMessage),n=De(l=>l.launchWorkflow),r=E.useCallback((l,u,c)=>{e(!0),t(l,u,c)},[e,t]),a=E.useCallback((l,u,c,d,h,p="auto")=>{e(!0),n(l,u,c,d,h,p)},[e,n]);return{sendMessage:r,launchWorkflow:a}}function SV({children:e}){return ui.createPortal(e,document.body)}function wV(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 CV({onSendCommand:e,onSelectWorkflow:t,onSelectWorkflowWithSubGroup:n,onOpenCommandsManager:r,onOpenWorkflowsManager:a,onAttach:l,textareaContent:u,attachments:c}){const[d,h]=E.useState(!1),[p,m]=E.useState("commands"),[g,y]=E.useState(""),[w,C]=E.useState(0),[_,S]=E.useState(null),[b,v]=E.useState(null),k=E.useRef(null),T=E.useRef(null),N=ln(D=>D.defaults),R=ln(D=>D.userItems),A=ln(D=>D.projectItems),O=ln(D=>D.fetchCommands),P=Ft(D=>D.fetchWorkflows),V=fr(fr(N,R),A),z=Uf();E.useEffect(()=>{d&&(p==="commands"?O():p==="workflows"&&P())},[d,p,O,P]),E.useEffect(()=>{d&&(y(""),C(0),requestAnimationFrame(()=>{var D;Bt()&&((D=k.current)==null||D.focus())}))},[d,p]),E.useEffect(()=>{if(!d)return;const D=q=>{var $;($=T.current)!=null&&$.contains(q.target)||h(!1)};return document.addEventListener("mousedown",D),()=>document.removeEventListener("mousedown",D)},[d]);const W=D=>{switch(D.key){case"ArrowDown":D.preventDefault(),C(q=>{const J=(p==="commands"?V:z).filter(Y=>{const Z=g.toLowerCase();return!Z||Y.name.toLowerCase().includes(Z)});return Math.min(q+1,J.length-1)});break;case"ArrowUp":D.preventDefault(),C(q=>Math.max(q-1,0));break;case"Enter":D.preventDefault();break;case"Escape":D.preventDefault(),h(!1);break}},M=D=>{y(D),C(0)},U=V.filter(D=>!g||D.name.toLowerCase().includes(g.toLowerCase())),F=z.filter(D=>!g||D.name.toLowerCase().includes(g.toLowerCase())),Q=async D=>{const q=await ln.getState().fetchCommand(D);q&&e(q.prompt,q.metadata.agentMode,u,c),h(!1)},X=(D,q)=>{t(D,q),h(!1)},H=(D,q)=>{q.stopPropagation(),h(!1),S(D)},I=(D,q)=>{q.stopPropagation(),h(!1),v(D)};return s.jsxs("div",{ref:T,className:"relative",children:[s.jsx("button",{type:"button",onClick:()=>h(!d),className:"px-1.5 py-2 rounded-r bg-bg-secondary text-text-muted hover:text-text-primary hover:bg-bg-tertiary transition-colors border-l border-border/50",title:"More options",children:s.jsx(jE,{className:"w-4 h-4"})}),d&&s.jsxs("div",{className:"absolute bottom-full right-0 mb-1 w-80 max-w-[calc(100vw-2rem)] bg-bg-secondary border border-border rounded-lg shadow-xl z-50 overflow-hidden",children:[s.jsxs("div",{className:"flex border-b border-border",children:[s.jsx("button",{type:"button",onClick:()=>{m("commands"),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"}),s.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"}),s.jsx("button",{type:"button",onClick:()=>m("attach"),className:`flex-1 px-4 py-2 text-sm font-medium transition-colors ${p==="attach"?"text-accent-primary border-b-2 border-accent-primary":"text-text-muted hover:text-text-primary"}`,children:"Attach"})]}),p!=="attach"&&s.jsx("div",{className:"p-2 border-b border-border",children:s.jsx("input",{ref:k,value:g,onChange:D=>M(D.target.value),onKeyDown:W,placeholder:p==="commands"?"Search commands...":"Search workflows...",className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-sm focus:outline-none focus:ring-1 focus:ring-accent-primary"})}),s.jsx(ct,{className:"max-h-64 p-1",children:p==="commands"?U.length===0?s.jsx("div",{className:"px-3 py-2 text-text-muted text-sm",children:V.length===0?"No commands yet":"No matches"}):U.map((D,q)=>s.jsxs("div",{className:`flex items-center gap-1 px-3 py-2 rounded transition-colors group ${q===w?"bg-accent-primary/20":"hover:bg-bg-tertiary"}`,children:[s.jsx("button",{type:"button",onClick:()=>Q(D.id),className:"flex-1 text-left",children:s.jsx("div",{className:"text-sm text-text-primary font-medium",children:D.name})}),s.jsx(ci,{className:"opacity-0 group-hover:opacity-100",onClick:$=>H(D.id,$)})]},D.id)):p==="workflows"?F.length===0?s.jsx("div",{className:"px-3 py-2 text-text-muted text-sm",children:z.length===0?"No workflows yet":"No matches"}):F.map((D,q)=>{const $=wV(D),J=D.color??"#3b82f6";return s.jsxs("div",{className:`flex items-center gap-2 px-3 py-2 rounded transition-colors group ${q===w?"bg-accent-primary/20":"hover:bg-bg-tertiary"}`,children:[s.jsxs("button",{type:"button",onClick:()=>X(D.id,D.scope),className:"flex-1 text-left flex items-center gap-2",children:[s.jsx("span",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{backgroundColor:J}}),s.jsx("span",{className:"text-sm text-text-primary font-medium flex-1",children:D.name}),s.jsx("span",{className:"text-[10px] text-text-muted bg-bg-tertiary px-1.5 py-0.5 rounded whitespace-nowrap",children:Db[D.scope]}),$!==null&&s.jsx("span",{className:"w-1.5 h-1.5 rounded-full flex-shrink-0",style:{backgroundColor:$?"#22c55e":"#6b7280"},title:$?"Entry condition met":"Entry condition not met"})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[D.subGroups&&D.subGroups.length>0&&s.jsx(kV,{subGroups:D.subGroups,onSelect:Y=>{h(!1),n(D.id,Y,D.scope)}}),s.jsx(ci,{className:"opacity-0 group-hover:opacity-100",onClick:Y=>I(D.id,Y)})]})]},`${D.id}-${D.scope}`)}):s.jsxs("div",{className:"p-4 flex flex-col items-center gap-3",children:[s.jsxs("button",{type:"button",onClick:()=>{l(),h(!1)},className:"flex items-center gap-2 px-4 py-2 rounded bg-bg-tertiary hover:bg-accent-primary/20 text-text-primary transition-colors",children:[s.jsx(N3,{className:"w-4 h-4"}),s.jsx("span",{className:"text-sm font-medium",children:"Attach file"})]}),s.jsx("span",{className:"text-xs text-text-muted",children:"or drag & drop into chat"})]})}),p!=="attach"&&s.jsx("div",{className:"border-t border-border p-1",children:s.jsx("button",{type:"button",onClick:()=>{h(!1),p==="commands"?r():a()},className:"w-full text-left px-3 py-1.5 rounded text-sm text-text-muted hover:text-text-primary hover:bg-bg-tertiary transition-colors",children:p==="commands"?"Manage Commands...":"Manage Workflows..."})})]}),s.jsx(ST,{isOpen:!!_,onClose:()=>S(null),initialEditId:_}),s.jsx(kT,{isOpen:!!b,onClose:()=>v(null),initialEditId:b})]})}function kV({subGroups:e,onSelect:t}){const[n,r]=E.useState(!1),[a,l]=E.useState({top:0,right:0}),u=E.useRef(null),c=E.useRef(null);Vf(c,()=>r(!1),n);const d=h=>{if(h.stopPropagation(),!n&&u.current){const p=u.current.getBoundingClientRect();l({top:p.bottom+4,right:window.innerWidth-p.right})}r(!n)};return s.jsxs(s.Fragment,{children:[s.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&&s.jsx(SV,{children:s.jsx("div",{ref:c,onMouseDown:h=>h.stopPropagation(),className:"fixed w-40 bg-bg-secondary border border-border rounded-lg shadow-xl z-[100] overflow-hidden",style:{top:a.top,right:a.right},children:e.map(h=>s.jsx("button",{type:"button",onClick:p=>{p.stopPropagation(),t(h)},className:"w-full text-left px-3 py-2 text-sm text-text-primary hover:bg-bg-tertiary transition-colors",children:h},h))})})]})}function EV({messages:e,onCancel:t}){return e.length===0?null:s.jsx("div",{className:"mb-2 flex flex-wrap gap-1.5",children:e.map(n=>s.jsxs("div",{className:`inline-flex items-center gap-1.5 px-2 py-1 rounded text-xs ${n.mode==="asap"?"bg-amber-500/15 text-amber-300 border border-amber-500/30":"bg-blue-500/15 text-blue-300 border border-blue-500/30"}`,children:[s.jsxs("span",{className:"font-medium",children:[n.mode==="asap"?"ASAP":"Queue",":"]}),s.jsx("span",{className:"truncate max-w-[200px]",children:n.content}),s.jsx(vu,{onClick:()=>t(n.queueId),size:"sm"})]},n.queueId))})}function jV({agent:e,isBuiltIn:t,isConfirmingDelete:n,alwaysAllowedNames:r,model:a,onView:l,onEdit:u,onDuplicate:c,onDelete:d,onCancelDelete:h}){var g;const p=e.allowedTools.filter(y=>!(r!=null&&r.has(y))),m=a?(g=a.split("/").pop())==null?void 0:g.replace(/-/g," "):void 0;return s.jsxs(FE,{isBuiltIn:t,isConfirmingDelete:n,onView:l,onEdit:u,onDuplicate:c,onDelete:d,onCancelDelete:h,children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0",style:{backgroundColor:e.color??"#6b7280"}}),s.jsx("span",{className:"text-text-primary text-sm font-medium",children:e.name}),s.jsx("span",{className:"text-text-muted text-xs font-mono",children:e.id}),t&&s.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-medium bg-bg-primary text-text-muted",children:"Built-in"}),m&&s.jsx("span",{className:"px-1.5 py-0.5 rounded text-[10px] font-medium bg-accent-primary/10 text-accent-primary",children:m})]}),e.description&&s.jsx("p",{className:"text-text-secondary text-xs mt-0.5 truncate",children:e.description}),s.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[p.slice(0,5).map(y=>s.jsx("span",{className:"text-[10px] font-mono text-text-muted bg-bg-primary px-1 py-0.5 rounded",children:y},y)),p.length>5&&s.jsxs("span",{className:"text-[10px] text-text-muted",children:["+",p.length-5," more"]})]})]})}function ik({title:e,agentTitle:t="Agents",subagentTitle:n="Sub-agents",agents:r,subagents:a,isBuiltIn:l,alwaysAllowedNames:u,modelOverrides:c,onView:d,onDuplicate:h,onEdit:p,onDelete:m,onCancelDelete:g,isConfirmingDelete:y}){if(r.length===0&&a.length===0)return null;const w=C=>s.jsx(jV,{agent:C,model:c==null?void 0:c[C.id],isBuiltIn:l,isConfirmingDelete:(y==null?void 0:y(C.id))??!1,alwaysAllowedNames:u,onView:()=>d(C.id),onEdit:p?()=>p(C.id):void 0,onDuplicate:()=>h(C.id),onDelete:l?void 0:()=>m==null?void 0:m(C.id),onCancelDelete:l?void 0:()=>g==null?void 0:g(C.id)},C.id);return s.jsxs("div",{children:[s.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:e}),r.length>0&&s.jsx("div",{className:"text-xs text-text-muted uppercase tracking-wider mb-1.5",children:t}),s.jsxs("div",{className:"space-y-2",children:[r.map(w),a.length>0&&s.jsxs("div",{className:"mt-3",children:[s.jsx("div",{className:"text-xs text-text-muted uppercase tracking-wider mb-1.5",children:n}),s.jsx("div",{className:"space-y-2",children:a.map(w)})]})]})]})}function NV(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(0)}K`:`${e}`}function TV(e,t){const n=t.toLowerCase(),r=(e.name??"").toLowerCase(),a=e.id.toLowerCase(),l=a.replace(/-/g," ");return r.includes(n)||a.includes(n)||l.includes(n)}function ak(e){return e.models.some(n=>n.selected)?e.models.filter(n=>n.selected):e.models}function AT({providerId:e,modelConfig:t,isActive:n,isDefault:r,disabled:a,hasSession:l,settingDefault:u,highlighted:c,onModelClick:d,onSetDefault:h,onEditModel:p}){var m;return s.jsxs("div",{className:`flex items-center px-4 py-1.5 text-sm transition-colors group ${c?"bg-bg-tertiary":"hover:bg-bg-tertiary"} ${a?"opacity-50 cursor-wait":""} ${n?"text-accent-primary":"text-text-secondary"}`,children:[s.jsx("button",{type:"button",onClick:()=>d(e,t.id),disabled:a,className:"flex-1 truncate text-left",children:t.name??((m=t.id.split("/").pop())==null?void 0:m.replace(/-/g," "))??t.id}),s.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0 ml-2",children:[s.jsx("span",{className:"text-xs text-text-muted",children:NV(t.contextWindow)}),l&&h&&s.jsx("button",{type:"button",onClick:g=>h(g,e,t.id),disabled:u,className:"p-0.5 hover:bg-bg-tertiary rounded transition-colors disabled:opacity-40",title:r?"Default model":"Set as default model",children:r?s.jsx(Xc,{className:"w-3.5 h-3.5 text-accent-warning"}):s.jsx(yf,{className:"w-3.5 h-3.5 text-text-muted hover:text-accent-warning"})}),p&&s.jsx("button",{type:"button",onClick:g=>{g.stopPropagation(),p(e,t)},className:"opacity-0 group-hover:opacity-100 p-0.5 hover:bg-bg-tertiary rounded transition-opacity",title:"Edit model context",children:s.jsx(kE,{className:"w-3 h-3 text-text-muted"})}),n&&s.jsx("span",{className:"text-accent-success flex-shrink-0",title:"Session model",children:s.jsx(Ls,{className:"w-3.5 h-3.5"})})]})]})}function LT({providers:e,onSelect:t,onEscape:n,extraItemCount:r=0}){const[a,l]=E.useState(""),[u,c]=E.useState(-1),d=E.useRef(null),h=E.useRef(null),p=E.useMemo(()=>a.trim()?e.map(w=>({provider:w,models:ak(w).filter(C=>TV(C,a))})).filter(w=>w.models.length>0):e.map(w=>({provider:w,models:ak(w)})),[e,a]),m=E.useMemo(()=>p.flatMap(w=>w.models.map(C=>({providerId:w.provider.id,modelConfig:C}))),[p]),g=m.length+r;return E.useEffect(()=>{g<=1?c(-1):u>=g?c(g-1):u<0&&a.trim()&&c(0)},[g,u,a]),E.useEffect(()=>{u>=0&&d.current&&d.current.scrollIntoView({block:"nearest"})},[u]),{searchQuery:a,setSearchQuery:l,highlightedIndex:u,setHighlightedIndex:c,visibleGroups:p,flatItems:m,totalNavItems:g,handleSearchKeyDown:w=>{switch(w.key){case"Escape":w.preventDefault(),n==null||n();break;case"ArrowDown":w.preventDefault(),g>0&&c(C=>C<g-1?C+1:0);break;case"ArrowUp":w.preventDefault(),g>0&&c(C=>C>0?C-1:g-1);break;case"Home":w.preventDefault(),c(0);break;case"End":w.preventDefault(),c(g-1);break;case"Enter":if(w.preventDefault(),u>=0&&u<m.length){const C=m[u];C&&t(C.providerId,C.modelConfig.id)}break}},highlightedRef:d,inputRef:h}}function RT({providers:e,value:t,onChange:n,defaultLabel:r="Default (global model)"}){var N;const[a,l]=E.useState(!1),u=E.useRef(null),c=E.useRef(null),[d,h]=E.useState({}),p=t==null?void 0:t.split("/").slice(1).join("/"),m=p?((N=p.split("/").pop())==null?void 0:N.replace(/-/g," "))??p:void 0,{searchQuery:g,setSearchQuery:y,highlightedIndex:w,setHighlightedIndex:C,visibleGroups:_,flatItems:S,handleSearchKeyDown:b,highlightedRef:v,inputRef:k}=LT({providers:e,onSelect:(R,A)=>{n(`${R}/${A}`),l(!1)},onEscape:()=>l(!1)}),T=E.useCallback(()=>{if(!a||!c.current)return;const R=c.current.getBoundingClientRect();h({position:"fixed",top:`${R.bottom+4}px`,left:`${R.left}px`,width:`${Math.max(R.width,288)}px`})},[a]);return E.useEffect(()=>(T(),window.addEventListener("scroll",T,!0),window.addEventListener("resize",T),()=>{window.removeEventListener("scroll",T,!0),window.removeEventListener("resize",T)}),[T]),E.useEffect(()=>{if(!a)return;function R(O){var P;u.current&&!u.current.contains(O.target)&&!((P=O.target)!=null&&P.closest("[data-model-picker-dropdown]"))&&(l(!1),y(""),C(-1))}const A=setTimeout(()=>{document.addEventListener("mousedown",R)},0);return()=>{clearTimeout(A),document.removeEventListener("mousedown",R)}},[a,y,C]),E.useEffect(()=>{var R;a?(T(),Bt()&&((R=k.current)==null||R.focus())):(y(""),C(-1))},[a,y,C,k,T]),s.jsxs("div",{className:"relative",ref:u,children:[s.jsxs("button",{ref:c,type:"button",onClick:()=>l(!a),className:"w-full flex items-center justify-between gap-2 px-3 py-1.5 bg-bg-tertiary border border-border rounded text-sm text-text-primary hover:bg-bg-secondary transition-colors",children:[s.jsx("span",{className:m?"text-text-primary":"text-text-muted",children:m??r}),s.jsx(vn,{className:`w-3 h-3 text-text-muted transition-transform ${a?"rotate-180":""}`})]}),a&&typeof document<"u"&&ui.createPortal(s.jsx("div",{"data-model-picker-dropdown":!0,className:"z-50",style:d,children:s.jsxs("div",{className:"bg-bg-secondary border border-border rounded-lg shadow-lg flex flex-col max-h-80",children:[s.jsxs("div",{className:"flex items-center gap-1 px-3 py-2 border-b border-border flex-shrink-0",children:[s.jsx(Xi,{className:"w-3.5 h-3.5 text-text-muted flex-shrink-0"}),s.jsx("input",{ref:k,type:"text",value:g,onInput:R=>{y(R.currentTarget.value),C(-1)},onKeyDown:b,placeholder:"Search models...",className:"bg-transparent border-none outline-none text-sm text-text-primary w-full placeholder:text-text-muted"})]}),s.jsxs(ct,{className:"flex-1",children:[s.jsx("button",{type:"button",onClick:()=>{n(void 0),l(!1)},className:`w-full text-left px-4 py-2 text-sm transition-colors hover:bg-bg-tertiary ${t?"text-text-muted":"text-accent-primary bg-accent-primary/5"}`,children:r}),_.map(R=>s.jsxs("div",{children:[s.jsx("div",{className:"px-4 py-1.5 text-xs font-medium text-text-muted uppercase tracking-wider bg-bg-tertiary/50",children:R.provider.name}),R.models.map(A=>{const P=S.findIndex(z=>z.providerId===R.provider.id&&z.modelConfig.id===A.id)===w,V=t===`${R.provider.id}/${A.id}`;return s.jsx("div",{ref:P?v:void 0,children:s.jsx(AT,{providerId:R.provider.id,modelConfig:A,isActive:V,highlighted:P,onModelClick:(z,W)=>{n(`${z}/${W}`),l(!1)}})},`${R.provider.id}/${A.id}`)})]},R.provider.id)),_.length===0&&g.trim()&&s.jsx("div",{className:"px-4 py-3 text-sm text-text-muted text-center",children:"No models match your search"})]})]})}),document.body)]})}function AV(e){const t=new Map;for(const n of e){const r=n.indexOf(":");if(r===-1)t.set(n,new Set);else{const a=n.slice(0,r),u=n.slice(r+1).split(",").filter(Boolean);t.set(a,new Set(u))}}return t}function ch(e){const t=[];for(const[n,r]of e)r.size===0?t.push(n):t.push(`${n}:${[...r].join(",")}`);return t}function LV({formName:e,formId:t,formDescription:n,formSubagent:r,formTools:a,formColor:l,formModel:u,formPrompt:c,formError:d,isReadOnly:h,availableTools:p,providers:m,onNameChange:g,onIdChange:y,onDescriptionChange:w,onSubagentChange:C,onToolsChange:_,onColorChange:S,onModelChange:b,onPromptChange:v}){const k=AV(a),T=p.filter(P=>!(r&&P.topLevelOnly)&&!P.isMcp),N=p.filter(P=>P.isMcp&&!(r&&P.topLevelOnly)),R=new Map;for(const P of N){const V=P.mcpServer??P.name,z=R.get(V)??[];z.push(P),R.set(V,z)}const A=(P,V)=>{const z=new Map(k),W=z.get(P)||new Set,M=new Set(W);M.has(V)?M.delete(V):M.add(V),M.size===0?z.set(P,new Set):z.set(P,M),_(ch(z))},O=P=>{const V=new Map(k);V.has(P)?V.delete(P):V.set(P,new Set),_(ch(V))};return s.jsxs("div",{className:"flex flex-col h-full",children:[s.jsxs("div",{className:"space-y-3",children:[d&&s.jsx(nl,{message:d}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsx(Yr,{label:"Name",value:e,onChange:g,placeholder:"My Agent",readOnly:h}),s.jsx(Yr,{label:"ID",value:t,onChange:y,readOnly:!0,placeholder:"my_agent",hint:"(read-only)",mono:!0})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.jsx(Yr,{label:"Description",value:n,onChange:w,placeholder:"What this agent does",readOnly:h}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Type"}),s.jsxs("div",{className:"flex items-center gap-3 h-[34px]",children:[s.jsx("button",{onClick:()=>!h&&C(!1),className:`px-2.5 py-1 rounded text-xs font-medium transition-colors ${r?"bg-bg-tertiary text-text-muted hover:text-text-secondary":"bg-accent-primary/25 text-accent-primary"} ${h?"pointer-events-none opacity-60":""}`,children:"Agent"}),s.jsx("button",{onClick:()=>!h&&C(!0),className:`px-2.5 py-1 rounded text-xs font-medium transition-colors ${r?"bg-accent-primary/25 text-accent-primary":"bg-bg-tertiary text-text-muted hover:text-text-secondary"} ${h?"pointer-events-none opacity-60":""}`,children:"Sub-agent"}),s.jsxs("div",{className:"flex items-center gap-1.5 ml-auto",children:[s.jsx("label",{className:"text-xs text-text-secondary",children:"Color"}),s.jsx("input",{type:"color",value:l,onChange:P=>!h&&S(P.target.value),disabled:h,className:"w-6 h-6 rounded cursor-pointer border border-border bg-transparent"})]})]})]})]}),!h&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Model override"}),s.jsx(RT,{providers:m,value:u,onChange:b,defaultLabel:"Default (global model)"}),s.jsx("p",{className:"text-[10px] text-text-muted mt-0.5",children:"When set, this model will be used when this agent is active (overrides the session model)."})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Tools"}),s.jsx(ct,{className:"flex flex-wrap gap-1.5 p-2 bg-bg-tertiary border border-border rounded max-h-32",children:T.map(P=>{const V=k.has(P.name),z=P.actions.length>0,W=k.get(P.name)||new Set;return z?h?s.jsxs("button",{className:"px-1.5 py-0.5 rounded text-xs font-mono flex items-center gap-1 bg-bg-primary text-text-muted pointer-events-none opacity-60",children:[s.jsx("span",{children:P.name}),s.jsx("span",{className:"text-[10px]",children:"*"})]},P.name):s.jsx(bu,{trigger:s.jsxs("button",{className:`px-1.5 py-0.5 rounded text-xs font-mono transition-colors flex items-center gap-1 ${V?"bg-accent-primary/25 text-accent-primary":"bg-bg-primary text-text-muted hover:text-text-secondary"} cursor-pointer`,children:[s.jsx("span",{children:P.name}),W.size>0&&s.jsx("span",{className:"text-[10px]",children:"*"})]}),minWidth:"160px",items:[...P.actions.map(M=>({label:s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",htmlFor:`${P.name}-${M}`,children:[s.jsx("input",{type:"checkbox",id:`${P.name}-${M}`,checked:W.has(M),onChange:()=>A(P.name,M),disabled:h,className:"w-3 h-3 rounded accent-accent-primary"}),s.jsx("span",{children:M})]}),closeOnClick:!1})),{label:V?"Deselect all":"Select all",closeOnClick:!1,onClick:()=>{if(V)O(P.name);else{const M=new Map(k);M.set(P.name,new Set(P.actions)),_(ch(M))}}}]},P.name):s.jsx("button",{onClick:()=>!h&&O(P.name),className:`px-1.5 py-0.5 rounded text-xs font-mono transition-colors flex items-center gap-1 ${V?"bg-accent-primary/25 text-accent-primary":"bg-bg-primary text-text-muted hover:text-text-secondary"} ${h?"pointer-events-none":"cursor-pointer"}`,children:s.jsx("span",{children:P.name})},P.name)})})]}),R.size>0&&(()=>{const P=new Set(N.map(U=>U.name)),V=k.has("__mcp_none__"),z=[...k.keys()].some(U=>P.has(U)),W=V?"none":z?"partial":"all",M=U=>{const F=new Map(k);for(const Q of F.keys())(Q==="__mcp_none__"||P.has(Q))&&F.delete(Q);if(U==="none"&&F.set("__mcp_none__",new Set),U==="partial")for(const Q of P)F.set(Q,new Set);_(ch(F))};return s.jsxs("div",{children:[s.jsxs("label",{className:"block text-xs text-text-secondary mb-1",children:["MCP Tools ",s.jsx("span",{className:"text-text-muted font-normal",children:"— from connected MCP servers"})]}),s.jsxs("div",{className:"bg-bg-tertiary border border-border rounded overflow-hidden",children:[s.jsx("div",{className:"flex items-center gap-4 px-3 py-1.5",children:["all","none","partial"].map(U=>s.jsxs("label",{className:`flex items-center gap-1.5 text-xs cursor-pointer ${h?"pointer-events-none opacity-60":""}`,children:[s.jsx("input",{type:"radio",name:"mcp-mode",checked:W===U,onChange:()=>M(U),disabled:h,className:"w-3 h-3 accent-accent-primary"}),s.jsxs("span",{className:W===U?"text-text-primary font-medium":"text-text-muted",children:[U.charAt(0).toUpperCase()+U.slice(1),U==="partial"&&P.size>0&&s.jsxs("span",{className:"ml-1 text-text-muted font-normal",children:["(",[...k.keys()].filter(F=>P.has(F)).length,"/",P.size,")"]})]})]},U))}),W==="partial"&&(()=>{const[U,F]=E.useState(""),[Q,X]=E.useState(0),H=E.useRef(null),I=$=>{var Y;const J=(Y=H.current)==null?void 0:Y.querySelector(`[data-idx="${$}"]`);J==null||J.scrollIntoView({block:"nearest"})};E.useEffect(()=>{I(Q)},[Q]);const D=U?N.filter($=>$.name.toLowerCase().includes(U.toLowerCase())):N,q=$=>{$.key==="ArrowDown"?($.preventDefault(),X(J=>Math.min(J+1,D.length-1))):$.key==="ArrowUp"?($.preventDefault(),X(J=>Math.max(J-1,0))):$.key==="Enter"&&D[Q]&&($.preventDefault(),O(D[Q].name))};return s.jsxs("div",{children:[s.jsx("div",{className:"px-3 py-2 border-b border-border",children:s.jsx("input",{type:"text",value:U,onChange:$=>{F($.target.value),X(0)},onKeyDown:q,placeholder:"Search MCP tools...",className:"w-full px-2 py-1 text-xs bg-bg-primary border border-border rounded font-mono focus:outline-none focus:ring-1 focus:ring-accent-primary"})}),s.jsx(ct,{className:"max-h-60",children:s.jsxs("div",{ref:H,children:[D.map(($,J)=>{const Y=k.has($.name),Z=J===Q;return s.jsxs("div",{"data-idx":J,className:`flex items-center justify-between px-3 py-1.5 transition-colors ${Z?"bg-bg-primary":"hover:bg-bg-primary/30"}`,onMouseEnter:()=>X(J),children:[s.jsx("span",{className:`text-xs font-mono ${Y?"text-text-primary":"text-text-muted"}`,children:$.name}),s.jsx(cs,{enabled:Y,onClick:()=>O($.name),label:$.name})]},$.name)}),D.length===0&&s.jsx("div",{className:"px-3 py-2 text-xs text-text-muted",children:"No MCP tools match your search."})]})})]})})()]})]})})()]}),s.jsxs("div",{className:"flex-1 min-h-[150px] pt-3 flex flex-col",children:[s.jsx("label",{className:"block text-xs text-text-secondary mb-1",children:"Prompt"}),s.jsx("textarea",{value:c,onChange:P=>!h&&v(P.target.value),readOnly:h,placeholder:"Instructions for this agent...",className:`h-80 w-full px-3 py-2 bg-bg-tertiary border border-border rounded text-sm font-mono resize-y focus:outline-none focus:ring-1 focus:ring-accent-primary ${h?"opacity-60":""}`})]})]})}function RV(e){const t=e.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_|_$/g,"");return t?`custom-${t}`:""}function DV({isOpen:e,onClose:t,initialEditId:n}){const r=ft(pe=>pe.defaults),a=ft(pe=>pe.userItems),l=ft(pe=>pe.projectItems),u=ft(pe=>pe.loading),c=ft(pe=>pe.fetchAgents),d=ft(pe=>pe.fetchAgent),h=ft(pe=>pe.fetchDefaultContent),p=ft(pe=>pe.createAgent),m=ft(pe=>pe.updateAgent),g=ft(pe=>pe.deleteAgent),[y,w]=E.useState("list"),[C,_]=E.useState(null),[S,b]=E.useState(!1),[v,k]=E.useState(""),[T,N]=E.useState(""),[R,A]=E.useState(""),[O,P]=E.useState(!0),[V,z]=E.useState([]),[W,M]=E.useState("#6b7280"),[U,F]=E.useState(void 0),[Q,X]=E.useState(""),[H,I]=E.useState("user"),[D,q]=E.useState(""),[$,J]=E.useState(!1),[Y,Z]=E.useState(!1),[K,B]=E.useState(null),[ne,se]=E.useState([]),[re,oe]=E.useState(new Set),{requestDelete:ve,clearConfirm:Se,isConfirming:$e}=du(),ze=pe=>{k(pe.metadata.name),N(pe.metadata.id),A(pe.metadata.description),P(pe.metadata.subagent),z(pe.metadata.allowedTools),M(pe.metadata.color??"#6b7280"),X(pe.prompt),q(""),Z(!0),we(`/api/agents/${pe.metadata.id}/model`).then(Ie=>Ie.json()).then(Ie=>{Ie.providerId&&Ie.model?F(`${Ie.providerId}/${Ie.model}`):F(void 0)}).catch(()=>F(void 0)).finally(()=>Z(!1))},ke=(pe,Ie,it)=>{k(pe.metadata.name+" (copy)"),N(`${Ie}-copy-${Date.now()}`),A(pe.metadata.description),P(pe.metadata.subagent),z(pe.metadata.allowedTools),M(pe.metadata.color??"#6b7280"),X(pe.prompt),q(""),_(null),b(!1),w("edit")},Ge=(pe,Ie)=>{ze(pe),_(Ie),b(!0),w("edit")};E.useEffect(()=>{e&&(c(),we("/api/tools").then(pe=>pe.json()).then(pe=>{const Ie=pe.tools||[];oe(new Set(Ie.filter(it=>it.alwaysAllowed).map(it=>it.name))),se(Ie.filter(it=>!it.alwaysAllowed))}).catch(()=>{se([]),oe(new Set)}),n?r.some(Ie=>Ie.id===n)?h(n).then(Ie=>{Ie&&ke(Ie,n)}):d(n).then(Ie=>{Ie&&(ze(Ie),_(n),b(!1),w("edit"))}):(w("list"),_(null),b(!1)))},[e,c,d,h,n]);const Je=async pe=>{if(r.some(it=>it.id===pe)){const it=await h(pe);if(!it)return;Ge(it,pe)}else{const it=await d(pe);if(!it)return;Ge(it,pe)}},Ce=async pe=>{let Ie=await h(pe);Ie||(Ie=await d(pe)),Ie&&ke(Ie,pe)},me=()=>{_(null),k(""),N(""),A(""),P(!0),z(["read_file"]),M("#6b7280"),X(""),I("user"),q(""),b(!1),w("edit")},We=async pe=>{const Ie=await d(pe);Ie&&(ze(Ie),_(pe),b(!1),w("edit"))},he=pe=>{B(pe)},Ve=async pe=>{await g(pe)},He=async()=>{const pe=C??T;if(!pe||!v||!Q){q("Name and prompt are required.");return}J(!0),q("");const Ie={metadata:{id:pe,name:v,description:R,subagent:O,allowedTools:V.filter(Ut=>!re.has(Ut)),color:W},prompt:Q},it=C?await m(C,Ie):await p(Ie,H);if(!it.success){J(!1),q(it.error??"Failed to save agent.");return}await DT(C??T,U),await c();const ut=C??T,$t=De.getState().currentSession;if(($t==null?void 0:$t.mode)===ut&&U){const{providerId:Ut,model:At}=Bb(U);De.getState().setSessionProvider(Ut,At)}J(!1),n?t():w("list")},ie=()=>{n?t():(w("list"),b(!1))},ye=pe=>{k(pe),C||N(RV(pe))},Le=ft(pe=>pe.modelOverrides),ue=r.filter(pe=>pe.subagent),de=r.filter(pe=>!pe.subagent),Fe=a.filter(pe=>pe.subagent),Ue=a.filter(pe=>!pe.subagent),Qe=l.filter(pe=>pe.subagent),rt=l.filter(pe=>!pe.subagent);return y==="edit"?s.jsxs(s.Fragment,{children:[s.jsxs(jt,{isOpen:e,onClose:ie,title:S?`${v}`:C?"Edit Agent":"New Agent",size:"xl",footer:S?s.jsx("div",{className:"flex justify-end",children:s.jsx("button",{onClick:()=>{k(v+" (copy)"),N(`${C}-copy-${Date.now()}`),_(null),b(!1)},className:"px-3 py-1.5 rounded bg-accent-primary/20 text-sm text-accent-primary font-medium hover:bg-accent-primary/30 transition-colors",children:"Duplicate & Customize"})}):s.jsx(DE,{onCancel:ie,onSave:He,saving:$,saveDisabled:!v||!Q||Y}),children:[!C&&!S&&s.jsx(vf,{value:H,onChange:I}),s.jsx(LV,{formName:v,formId:T,formDescription:R,formSubagent:O,formTools:V,formColor:W,formModel:U,formPrompt:Q,formError:D,isReadOnly:S,availableTools:ne,providers:Zt.getState().providers,onNameChange:ye,onIdChange:N,onDescriptionChange:A,onSubagentChange:pe=>{P(pe),pe&&z(Ie=>Ie.filter(it=>{var ut;return!((ut=ne.find($t=>$t.name===it))!=null&&ut.topLevelOnly)}))},onToolsChange:z,onColorChange:M,onModelChange:F,onPromptChange:X})]}),s.jsx(ok,{agentId:K,onClose:()=>B(null),onSaved:()=>c()})]}):s.jsxs(s.Fragment,{children:[s.jsx(jt,{isOpen:e,onClose:t,title:"Agents",size:"lg",children:s.jsx(OE,{description:"Agents define behavior, tools, and prompts for top-level modes and sub-agents.",onNew:me,loading:u,hasItems:r.length>0||a.length>0||l.length>0,children:s.jsxs("div",{className:"space-y-4",children:[r.length>0&&s.jsx(ik,{title:"Built-in",agents:de,subagents:ue,isBuiltIn:!0,alwaysAllowedNames:re,modelOverrides:Le,onView:Je,onEdit:he,onDuplicate:Ce}),(Ue.length>0||Fe.length>0||rt.length>0||Qe.length>0)&&s.jsxs("div",{children:[s.jsx("h3",{className:"text-xs font-medium text-text-secondary mb-2 uppercase tracking-wide",children:"Custom"}),s.jsx("div",{className:"ml-3 space-y-3",children:[{title:"Global",agents:Ue,subagents:Fe},{title:"Project",agents:rt,subagents:Qe}].map(pe=>(pe.agents.length>0||pe.subagents.length>0)&&s.jsx(ik,{title:pe.title,agents:pe.agents,subagents:pe.subagents,isBuiltIn:!1,alwaysAllowedNames:re,modelOverrides:Le,isConfirmingDelete:Ie=>$e(Ie,"delete"),onView:Je,onDuplicate:Ce,onEdit:We,onDelete:Ie=>{$e(Ie,"delete")?(Ve(Ie),Se()):ve(Ie)},onCancelDelete:Se},pe.title))})]})]})})}),s.jsx(ok,{agentId:K,onClose:()=>B(null),onSaved:()=>c()})]})}function Bb(e){const t=e.indexOf("/");return t>0?{providerId:e.substring(0,t),model:e.substring(t+1)}:{providerId:e,model:e}}async function DT(e,t){if(t){const{providerId:n,model:r}=Bb(t);await we(`/api/agents/${e}/model`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({providerId:n,model:r})})}else await we(`/api/agents/${e}/model`,{method:"DELETE"})}function ok({agentId:e,onClose:t,onSaved:n}){const[r,a]=E.useState(void 0),[l,u]=E.useState(!1),[c,d]=E.useState(!1),[h,p]=E.useState(null),m=ft(b=>b.defaults),g=ft(b=>b.userItems),y=ft(b=>b.projectItems),w=[...m,...g,...y],C=e?w.find(b=>b.id===e):void 0,_=Zt(b=>b.providers);E.useEffect(()=>{e&&(u(!0),we(`/api/agents/${e}/model`).then(b=>b.json()).then(b=>{a(b.providerId&&b.model?`${b.providerId}/${b.model}`:void 0)}).catch(()=>a(void 0)).finally(()=>u(!1)))},[e]);const S=async()=>{if(e){d(!0),p(null);try{await DT(e,r);const b=De.getState().currentSession;if((b==null?void 0:b.mode)===e&&r){const{providerId:v,model:k}=Bb(r);De.getState().setSessionProvider(v,k)}n(),t()}catch{p("Failed to save. Please try again.")}d(!1)}};return s.jsx(jt,{isOpen:!!e,onClose:t,title:`Model — ${(C==null?void 0:C.name)??e??""}`,size:"md",children:s.jsxs("div",{className:"space-y-4 p-2",children:[s.jsx("p",{className:"text-xs text-text-muted",children:"Choose which model to use when this agent is active. This overrides the session/global model."}),l?s.jsx("div",{className:"text-sm text-text-muted py-2",children:"Loading..."}):s.jsx(RT,{providers:_,value:r,onChange:a,defaultLabel:"Default (global model)"}),h&&s.jsx("p",{className:"text-xs text-red-500",children:h}),s.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[s.jsx("button",{onClick:t,className:"px-4 py-1.5 text-sm text-text-muted hover:text-text-secondary transition-colors",children:"Cancel"}),s.jsx("button",{onClick:S,disabled:c,className:"px-4 py-1.5 rounded bg-accent-primary/20 text-sm text-accent-primary font-medium hover:bg-accent-primary/30 disabled:opacity-50 transition-colors",children:c?"Saving...":"Save"})]})]})})}function OV(){const e=De(v=>{var k;return(k=v.currentSession)==null?void 0:k.mode}),t=De(v=>v.switchMode),n=ft(v=>v.defaults),r=ft(v=>v.userItems),a=ft(v=>v.projectItems),l=ft(v=>v.fetchAgents),u=[...n,...r,...a],[c,d]=E.useState(!1),[h,p]=E.useState(!1),[m,g]=E.useState(null),y=E.useRef(null);E.useEffect(()=>{l()},[l]),Vf(y,()=>d(!1));const w=uu();if(!e)return null;const C=u.filter(v=>!v.subagent),_=C.find(v=>v.id===e),S=(_==null?void 0:_.name)??e,b=ul(u,e);return s.jsxs("div",{className:"relative",ref:y,children:[s.jsxs("button",{type:"button",onClick:()=>d(!c),className:"flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors",title:"Switch agent",children:[s.jsx("span",{className:"text-sm font-medium",style:{color:b},children:S}),s.jsx(vn,{className:`w-3 h-3 text-text-muted transition-transform ${c?"rotate-180":""}`})]}),c&&C.length>0&&s.jsxs("div",{className:"absolute bottom-full left-0 mb-1 w-56 bg-bg-secondary border border-border rounded-lg shadow-lg overflow-hidden z-50",children:[C.map((v,k)=>{const T=v.id===e,N=ul(u,v.id),R=w.agentSwitching[k],A=R?Th(R):null;return s.jsxs("div",{className:`flex items-center gap-2 px-3 py-2 text-sm transition-colors group ${T?"bg-bg-tertiary":"hover:bg-bg-tertiary cursor-pointer"}`,children:[s.jsxs("button",{type:"button",onClick:()=>{T||t(v.id),d(!1)},className:"flex-1 text-left flex items-center gap-2 min-w-0",children:[s.jsx("span",{className:"font-medium truncate",style:{color:N},children:v.name}),T&&s.jsx(Ls,{className:"w-3.5 h-3.5 text-text-muted shrink-0"})]}),A&&s.jsx("span",{className:"shrink-0 px-1.5 py-0.5 text-[10px] bg-bg-tertiary text-text-muted rounded",children:A})]},v.id)}),s.jsx("div",{className:"border-t border-border p-1",children:s.jsx("button",{type:"button",onClick:()=>{d(!1),p(!0)},className:"w-full text-left px-3 py-1.5 rounded text-sm text-text-muted hover:text-text-primary hover:bg-bg-tertiary transition-colors",children:"Manage Agents..."})})]}),s.jsx(DV,{isOpen:h,onClose:()=>{p(!1),g(null)},initialEditId:m})]})}function IV(){const e=De(r=>r.currentSession),t=De(r=>r.switchDangerLevel);if(!e)return null;const n=e.dangerLevel??"normal";return s.jsxs("div",{className:"flex items-center gap-1 px-1.5 py-0.5 rounded bg-bg-tertiary/50",children:[s.jsx("button",{type:"button",onClick:()=>t("normal"),className:`px-2 py-0.5 text-xs font-medium rounded transition-colors ${n==="normal"?"bg-accent-success/20 text-accent-success":"text-text-muted hover:text-text-primary hover:bg-bg-tertiary"}`,title:"Normal mode - requires path confirmation",children:"Normal"}),s.jsx("button",{type:"button",onClick:()=>t("dangerous"),className:`px-2 py-0.5 text-xs font-medium rounded transition-colors ${n==="dangerous"?"bg-red-500/20 text-red-400":"text-text-muted hover:text-text-primary hover:bg-bg-tertiary"}`,title:"Dangerous mode - bypasses all confirmations",children:"Dangerous"})]})}function lk({value:e,onChange:t}){return s.jsxs("div",{children:[s.jsxs("label",{className:"text-xs text-text-secondary block mb-1",children:["Query params ",s.jsx("span",{className:"text-text-muted",children:"(optional JSON)"})]}),s.jsx("input",{type:"text",value:e??"",onChange:n=>t(n.target.value),className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary font-mono"})]})}const MV=[8080,11434,8e3,1234];function fy(e){if(e!=null&&e.length)return e.includes("medium")?"medium":e[0]}function OT(e){return{name:e.name,url:e.url,backend:e.backend,apiKey:e.apiKey,isLocal:e.isLocal,thinkingField:e.thinkingField,sendReasoningInMessages:e.sendReasoningInMessages,authAdapter:e.authAdapter,transportAdapter:e.transportAdapter,models:e.models}}function PV({model:e,modelConfigs:t,autoConfigState:n,testResults:r,onUpdateConfig:a,onRunAutoConfig:l,onTestParams:u,onShowRaw:c}){var d,h,p,m,g,y,w,C,_,S,b,v,k,T,N,R,A,O,P,V,z,W,M,U,F,Q,X,H,I,D,q,$,J,Y,Z,K,B,ne,se,re,oe,ve,Se,$e,ze;return s.jsxs("div",{className:"px-4 pb-4 border-t border-border pt-3 space-y-3",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("button",{onClick:()=>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"&&s.jsx("span",{className:"text-sm text-accent-success font-medium",children:"Configured ✓"}),n.progress[e.id]==="error"&&s.jsx("span",{className:"text-sm text-red-500 font-medium",children:"Failed ✗"})]}),s.jsxs("div",{className:"flex gap-3 items-end",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-text-secondary block mb-1",children:"Context window (tokens)"}),s.jsx("input",{type:"number",value:((d=t[e.id])==null?void 0:d.contextWindow)??e.contextWindow,onChange:ke=>a(e.id,{contextWindow:parseInt(ke.target.value)||e.contextWindow}),className:"w-32 px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary"})]}),s.jsxs("label",{className:"flex items-center gap-1.5 text-xs text-text-secondary pb-1",children:[s.jsx("input",{type:"checkbox",checked:((h=t[e.id])==null?void 0:h.supportsVision)??!1,onChange:ke=>a(e.id,{supportsVision:ke.target.checked}),className:"accent-accent-primary"})," ","Supports vision"]})]}),s.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:()=>u(e.id,"thinking"),disabled:(p=r[e.id+"-thinking"])==null?void 0:p.loading,className:"px-3 py-1.5 bg-bg-tertiary border border-border rounded text-xs font-medium hover:bg-bg-secondary disabled:opacity-50 transition-colors",children:(m=r[e.id+"-thinking"])!=null&&m.loading?"Testing...":"Test thinking"}),((g=r[e.id+"-thinking"])==null?void 0:g.result)&&s.jsx("span",{className:"text-xs text-accent-success",children:"OK"}),((y=r[e.id+"-thinking"])==null?void 0:y.error)&&s.jsx("span",{className:"text-xs text-red-500",title:(w=r[e.id+"-thinking"])==null?void 0:w.error,children:"Fail"}),((C=r[e.id+"-thinking"])==null?void 0:C.result)&&s.jsx("button",{onClick:()=>c(r[e.id+"-thinking"].result),className:"text-xs text-accent-primary hover:underline",children:"raw"})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:()=>u(e.id,"non-thinking"),disabled:(_=r[e.id+"-non-thinking"])==null?void 0:_.loading,className:"px-3 py-1.5 bg-bg-tertiary border border-border rounded text-xs font-medium hover:bg-bg-secondary disabled:opacity-50 transition-colors",children:(S=r[e.id+"-non-thinking"])!=null&&S.loading?"Testing...":"Test non-thinking"}),((b=r[e.id+"-non-thinking"])==null?void 0:b.result)&&s.jsx("span",{className:"text-xs text-accent-success",children:"OK"}),((v=r[e.id+"-non-thinking"])==null?void 0:v.error)&&s.jsx("span",{className:"text-xs text-red-500",title:(k=r[e.id+"-non-thinking"])==null?void 0:k.error,children:"Fail"}),((T=r[e.id+"-non-thinking"])==null?void 0:T.result)&&s.jsx("button",{onClick:()=>c(r[e.id+"-non-thinking"].result),className:"text-xs text-accent-primary hover:underline",children:"raw"})]})]}),s.jsxs("details",{className:"group",children:[s.jsxs("summary",{className:"text-xs text-text-muted cursor-pointer hover:text-text-secondary list-none flex items-center gap-1 select-none",children:[s.jsx(vn,{className:"w-3 h-3 transition-transform group-open:rotate-180"}),"Advanced: thinking & non-thinking params"]}),s.jsxs("div",{className:"mt-3 space-y-2",children:[s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:((N=t[e.id])==null?void 0:N.thinkingEnabled)??!1,onChange:ke=>a(e.id,{thinkingEnabled:ke.target.checked}),className:"w-4 h-4 rounded border-border bg-bg-tertiary accent-accent-primary"}),s.jsx("span",{className:"text-xs font-medium text-text-primary",children:"Thinking"})]}),((R=t[e.id])==null?void 0:R.thinkingEnabled)&&s.jsxs("div",{className:"ml-6 space-y-2 pl-3 border-l-2 border-accent-primary/30",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-text-secondary block mb-1",children:"Reasoning effort"}),(A=e.reasoningEfforts)!=null&&A.length?s.jsx("select",{"aria-label":"Reasoning effort",value:((O=t[e.id])==null?void 0:O.thinkingLevel)??fy(e.reasoningEfforts),onChange:ke=>a(e.id,{thinkingLevel:ke.target.value}),className:"w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-xs text-text-primary",children:e.reasoningEfforts.map(ke=>s.jsx("option",{value:ke,children:ke},ke))}):s.jsx("input",{type:"text","aria-label":"Reasoning effort",value:((P=t[e.id])==null?void 0:P.thinkingLevel)??"",onChange:ke=>a(e.id,{thinkingLevel:ke.target.value}),className:"w-full px-2 py-1.5 bg-bg-tertiary border border-border rounded text-xs text-text-primary"})]}),s.jsx(lk,{value:(V=t[e.id])==null?void 0:V.thinkingQueryParams,onChange:ke=>a(e.id,{thinkingQueryParams:ke})})]}),s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:((z=t[e.id])==null?void 0:z.nonThinkingEnabled)??!1,onChange:ke=>a(e.id,{nonThinkingEnabled:ke.target.checked}),className:"w-4 h-4 rounded border-border bg-bg-tertiary accent-accent-primary"}),s.jsx("span",{className:"text-xs font-medium text-text-primary",children:"Non-thinking"})]}),((W=t[e.id])==null?void 0:W.nonThinkingEnabled)&&s.jsx("div",{className:"ml-6 space-y-2 pl-3 border-l-2 border-accent-warning/30",children:s.jsx(lk,{value:(M=t[e.id])==null?void 0:M.nonThinkingQueryParams,onChange:ke=>a(e.id,{nonThinkingQueryParams:ke})})})]}),s.jsxs("div",{className:"border-t border-border pt-3 mt-3",children:[s.jsx("p",{className:"text-xs text-text-muted mb-2",children:"Sampling parameters"}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-text-secondary block mb-0.5",children:"Temperature"}),s.jsx("input",{type:"number",step:"0.1",value:((U=t[e.id])==null?void 0:U.temperature)??"",onChange:ke=>a(e.id,{temperature:ke.target.value?parseFloat(ke.target.value):void 0}),placeholder:((Q=(F=t[e.id])==null?void 0:F.defaultTemperature)==null?void 0:Q.toString())??"Using default",className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary"}),((X=t[e.id])==null?void 0:X.defaultTemperature)!==void 0&&s.jsxs("p",{className:"text-xs text-text-muted mt-0.5",children:["default: ",(H=t[e.id])==null?void 0:H.defaultTemperature]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-text-secondary block mb-0.5",children:"Top P"}),s.jsx("input",{type:"number",step:"0.05",value:((I=t[e.id])==null?void 0:I.topP)??"",onChange:ke=>a(e.id,{topP:ke.target.value?parseFloat(ke.target.value):void 0}),placeholder:((q=(D=t[e.id])==null?void 0:D.defaultTopP)==null?void 0:q.toString())??"Using default",className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary"}),(($=t[e.id])==null?void 0:$.defaultTopP)!==void 0&&s.jsxs("p",{className:"text-xs text-text-muted mt-0.5",children:["default: ",(J=t[e.id])==null?void 0:J.defaultTopP]})]})]}),s.jsxs("div",{className:"grid grid-cols-2 gap-2 mt-2",children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-text-secondary block mb-0.5",children:"Top K"}),s.jsx("input",{type:"number",value:((Y=t[e.id])==null?void 0:Y.topK)??"",onChange:ke=>a(e.id,{topK:ke.target.value?parseInt(ke.target.value):void 0}),placeholder:((K=(Z=t[e.id])==null?void 0:Z.defaultTopK)==null?void 0:K.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.defaultTopK)!==void 0&&s.jsxs("p",{className:"text-xs text-text-muted mt-0.5",children:["default: ",(ne=t[e.id])==null?void 0:ne.defaultTopK]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-text-secondary block mb-0.5",children:"Max tokens"}),s.jsx("input",{type:"number",value:((se=t[e.id])==null?void 0:se.maxTokens)??"",onChange:ke=>a(e.id,{maxTokens:ke.target.value?parseInt(ke.target.value):void 0}),placeholder:((oe=(re=t[e.id])==null?void 0:re.defaultMaxTokens)==null?void 0:oe.toString())??"Using default",className:"w-full px-2 py-1 bg-bg-tertiary border border-border rounded text-xs text-text-primary"}),((ve=t[e.id])==null?void 0:ve.defaultMaxTokens)!==void 0&&s.jsxs("p",{className:"text-xs text-text-muted mt-0.5",children:["default: ",(Se=t[e.id])==null?void 0:Se.defaultMaxTokens]})]})]})]}),s.jsx("div",{className:"pt-3 border-t border-border",children:s.jsx(BV,{value:($e=t[e.id])==null?void 0:$e.compactionThreshold,maxTokens:((ze=t[e.id])==null?void 0:ze.contextWindow)??e.contextWindow,onChange:ke=>a(e.id,{compactionThreshold:ke})})})]})]})}function BV({value:e,maxTokens:t,onChange:n}){const l=Math.min(95,Math.floor((t-5e3)/t*100)),u=Math.min(l,Math.ceil(15e3/t*100)),c=Math.min(e??.85,l/100),[d,h]=E.useState(Math.round(c*100));E.useEffect(()=>{const m=Math.min(e??.85,l/100);h(Math.round(m*100))},[e,l]);const p=Math.floor(t*(d/100));return s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center justify-between gap-3 mb-1",children:[s.jsx("label",{className:"text-xs text-text-secondary",children:"Auto-compaction threshold"}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"font-mono text-xs text-text-primary",children:[d,"% · ",dl(p)]}),s.jsx("button",{type:"button",onClick:()=>{n(void 0),h(Math.round(.85*100))},disabled:e===void 0,className:"text-xs text-accent-primary hover:underline disabled:text-text-muted disabled:no-underline",children:"Default"})]})]}),s.jsx("input",{"aria-label":"Auto-compaction threshold",type:"range",min:u,max:l,step:"1",value:d,onChange:m=>h(Number(m.target.value)),onMouseUp:()=>n(d/100),onTouchEnd:()=>n(d/100),onBlur:()=>n(d/100),onKeyUp:()=>n(d/100),className:"w-full"}),s.jsxs("p",{className:"text-[10px] text-text-muted mt-0.5",children:["Minimum ",dl(15e3)," tokens · maximum ",l,"% · default 85%"]})]})}function IT({isOpen:e,onClose:t,onSave:n,initialStep:r=1,editProvider:a,editModelId:l}){const[u,c]=E.useState(r),[d,h]=E.useState(""),[p,m]=E.useState(""),[g,y]=E.useState("unknown"),[w,C]=E.useState(""),[_,S]=E.useState(!1),[b,v]=E.useState(),[k,T]=E.useState(),[N,R]=E.useState(!1),[A,O]=E.useState(null),[P,V]=E.useState([]),[z,W]=E.useState(null),[M,U]=E.useState(!1),[F,Q]=E.useState(""),[X,H]=E.useState(!0),[I,D]=E.useState({}),[q,$]=E.useState({loading:!1,progress:{}}),[J,Y]=E.useState({}),[Z,K]=E.useState(null),[B,ne]=E.useState(new Set),[se,re]=E.useState(""),[oe,ve]=E.useState(null),[Se,$e]=E.useState("disconnected"),[ze,ke]=E.useState(!1),[Ge,Je]=E.useState(null),[Ce,me]=E.useState([]),[We,he]=E.useState(!1),[Ve,He]=E.useState(!1),[ie,ye]=E.useState(""),[Le,ue]=E.useState(null),de=E.useRef(null),Fe=E.useRef(!1),Ue=E.useRef(null),Qe=E.useRef(null);E.useEffect(()=>{u===1&&e&&requestAnimationFrame(()=>{var be;Bt()&&((be=Ue.current)==null||be.focus())})},[u,e]),E.useEffect(()=>()=>{de.current!==null&&window.clearTimeout(de.current)},[]),E.useEffect(()=>{e&&we("/api/provider-presets").then(async be=>be.ok?await be.json():{presets:[]}).then(be=>me(be.presets)).catch(()=>me([]))},[e]);function rt(be,et){D(Ye=>({...Ye,[be]:{...Ye[be],...et}}))}function pe(be){ne(et=>new Set(et).add(be.id)),D(et=>({...et,[be.id]:{contextWindow:be.contextWindow,...et[be.id]}}))}function Ie(be){if(!be.trim())return P;const et=be.toLowerCase().split(/\s+/).filter(Boolean);return P.filter(Ye=>et.every(ae=>Ye.id.toLowerCase().includes(ae)))}function it(){const be=ie.trim();if(!be){ue("Enter a model name");return}const et=Ze=>Ze.toLowerCase().replace(/[-_\s:.]+/g,""),Ye=et(be),ae=P.find(Ze=>et(Ze.id)===Ye);if(ae){pe(ae),ue(`"${ae.id}" is already in the list`),ye(""),!b&&q.progress[ae.id]!=="probing"&&dn(ae.id);return}const Me={id:be,contextWindow:2e5};V(Ze=>[...Ze,Me]),ne(Ze=>new Set(Ze).add(Me.id)),D(Ze=>({...Ze,[Me.id]:{contextWindow:Me.contextWindow,thinkingEnabled:!0}})),W(Me.id),ye(""),ue(null),O(null)}E.useEffect(()=>{var be,et;if(e)if(c(r),h((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),v(a==null?void 0:a.authAdapter),T(a==null?void 0:a.transportAdapter),O(null),Q((a==null?void 0:a.thinkingField)??""),H((a==null?void 0:a.sendReasoningInMessages)??!0),Y({}),K(null),ve(null),$e("disconnected"),Je(null),he(!1),He(!1),ye(""),ue(null),(be=a==null?void 0:a.models)!=null&&be.length){const Ye={},ae=new Set;for(const Me of a.models)Ye[Me.id]={contextWindow:Me.contextWindow,supportsVision:Me.supportsVision,thinkingEnabled:Me.thinkingEnabled,thinkingLevel:Me.thinkingLevel??fy(Me.reasoningEfforts),nonThinkingEnabled:Me.nonThinkingEnabled,thinkingQueryParams:Me.thinkingQueryParams,nonThinkingQueryParams:Me.nonThinkingQueryParams,defaultTemperature:Me.defaultTemperature,defaultTopP:Me.defaultTopP,defaultTopK:Me.defaultTopK,defaultMaxTokens:Me.defaultMaxTokens,temperature:Me.temperature,topP:Me.topP,topK:Me.topK,maxTokens:Me.maxTokens,compactionThreshold:Me.compactionThreshold},Me.selected&&ae.add(Me.id);if(ae.size===0)for(const Me of a.models)ae.add(Me.id);ne(ae),D(Ye),V(a.models),W(l??((et=a.models[0])==null?void 0:et.id)??null)}else V([]),D({}),W(null),ne(new Set)},[e,r,a==null?void 0:a.id,l]),E.useEffect(()=>{const be=!!b;u===2&&p&&P.length===0&&!N&&!A&&(!be||Se==="connected")&&_n(p)},[u,Se]),E.useEffect(()=>{!e||!b||!(a!=null&&a.id)||$t(a.id)},[e,k,a==null?void 0:a.id]),E.useEffect(()=>{if(!Ge)return;const be=(a==null?void 0:a.id)??oe;if(!be)return;let et=!1;const Ye=async()=>{const Me=await $t(be);et||Me!=="connected"||(Je(null),he(!1),He(!1),await _n(p))};Ye();const ae=window.setInterval(()=>void Ye(),2e3);return()=>{et=!0,window.clearInterval(ae)}},[Ge,oe,a==null?void 0:a.id]);async function ut(){if(a!=null&&a.id)return a.id;if(oe)return oe;const be=await we("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:d||"Provider",url:p,backend:g,authAdapter:b,transportAdapter:k,isLocal:!1,models:[]})});if(!be.ok)throw new Error("Unable to create provider");const et=await be.json();return ve(et.provider.id),et.provider.id}async function $t(be){const et=await we(`/api/provider-auth/${be}/status`);if(!et.ok)return"error";const Ye=await et.json(),ae=Ye.state==="connected"?"connected":Ye.state==="pending"?"pending":Ye.state==="error"?"error":"disconnected";return $e(ae),ae}async function Ut(){ke(!0),$e("pending");try{const be=await ut(),et=await we(`/api/provider-auth/${be}/login`,{method:"POST"});if(!et.ok)throw new Error("Unable to start provider sign-in");const Ye=await et.json();Je(Ye)}catch{$e("error")}finally{ke(!1)}}async function At(){var be;Ge!=null&&Ge.userCode&&(await((be=navigator.clipboard)==null?void 0:be.writeText(Ge.userCode)),de.current!==null&&window.clearTimeout(de.current),He(!1),requestAnimationFrame(()=>He(!0)),de.current=window.setTimeout(()=>{He(!1),de.current=null},1500))}function Mn(){Ge&&(window.open(Ge.directUrl??Ge.verificationUrl,"_blank","noopener,noreferrer"),he(!0))}async function _n(be){var et,Ye;R(!0),O(null),V([]);try{const ae=new URLSearchParams({url:be});w&&ae.set("apiKey",w),g&&ae.set("backend",g);const Me=k?await we(`/api/providers/${await ut()}/models`):await we(`/api/providers/models?${ae.toString()}`);if(Me.ok){const Ze=await Me.json();if((et=Ze.models)!=null&&et.length){V(Ze.models),W(((Ye=Ze.models[0])==null?void 0:Ye.id)??null);const Rt={};for(const nn of Ze.models)Rt[nn.id]={contextWindow:nn.contextWindow,thinkingEnabled:!0,thinkingLevel:fy(nn.reasoningEfforts),defaultTemperature:nn.defaultTemperature,defaultTopP:nn.defaultTopP,defaultTopK:nn.defaultTopK,defaultMaxTokens:nn.defaultMaxTokens};D(Rt),Ze.models.length===1&&(ne(new Set([Ze.models[0].id])),W(Ze.models[0].id),dn(Ze.models[0].id))}}else{const Ze=await Me.json();O(Ze.error??`Failed to fetch models from ${be}`)}}catch(ae){O(`Failed to fetch models from ${be}: ${ae instanceof Error?ae.message:"Unknown error"}`)}R(!1)}async function dn(be){$(et=>({loading:!0,progress:{...et.progress,[be]:"probing"}}));try{const et=await we("/api/providers/auto-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:p,apiKey:w||void 0,backend:g||"unknown",models:[{id:be}]})});if(!et.ok){const ae=await et.json();throw new Error(ae.error??"Auto-config failed")}const Ye=await et.json();for(const ae of Ye.models){const Me={};ae.contextSource!=="default"&&(Me.contextWindow=ae.contextWindow,Me.supportsVision=ae.supportsVision),ae.thinkingConfig&&(Me.thinkingEnabled=!0,Me.thinkingQueryParams=JSON.stringify(ae.thinkingConfig)),ae.nonThinkingConfig&&(Me.nonThinkingEnabled=!0,Me.nonThinkingQueryParams=JSON.stringify(ae.nonThinkingConfig)),rt(ae.id,Me),$(Ze=>({...Ze,progress:{...Ze.progress,[ae.id]:"done"}}))}}catch(et){console.error("Auto-config error:",et),$(Ye=>({...Ye,progress:{...Ye.progress,[be]:"error"}}))}finally{$(et=>({...et,loading:!1}))}}async function An(be,et){const Ye=be+"-"+et;Y(ae=>({...ae,[Ye]:{loading:!0}}));try{const ae=I[be],Me=await we("/api/providers/test-params",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:p,providerId:(a==null?void 0:a.id)??oe??void 0,transportAdapter:k,model:be,apiKey:w||void 0,backend:g||"unknown",thinkingField:F||void 0,mode:et,modelConfig:{temperature:ae==null?void 0:ae.temperature,topP:ae==null?void 0:ae.topP,topK:ae==null?void 0:ae.topK,maxTokens:ae==null?void 0:ae.maxTokens,supportsVision:ae==null?void 0:ae.supportsVision,thinkingEnabled:ae==null?void 0:ae.thinkingEnabled,thinkingLevel:ae==null?void 0:ae.thinkingLevel,nonThinkingEnabled:ae==null?void 0:ae.nonThinkingEnabled,thinkingQueryParams:ae==null?void 0:ae.thinkingQueryParams,nonThinkingQueryParams:ae==null?void 0:ae.nonThinkingQueryParams}})}),Ze=await Me.json();Me.ok?Y(Rt=>({...Rt,[Ye]:{loading:!1,result:JSON.stringify(Ze,null,2),message:Ze.message}})):Y(Rt=>({...Rt,[Ye]:{loading:!1,error:Ze.error??"Test failed"}}))}catch(ae){Y(Me=>({...Me,[Ye]:{loading:!1,error:ae instanceof Error?ae.message:"Request failed"}}))}}function Sn(){V([]),D({}),$({loading:!1,progress:{}}),Y({}),K(null),ne(new Set),re(""),ye(""),ue(null)}function cn(){oe&&!Fe.current&&we(`/api/providers/${oe}`,{method:"DELETE"}).catch(be=>{console.warn("Failed to clean up draft provider",be)}),t()}function er(){const be=d||"Provider",et=(a==null?void 0:a.id)??oe??`temp-${Date.now()}`;n({id:et,name:be,url:p,backend:g||"unknown",apiKey:w||void 0,isLocal:_,thinkingField:F||void 0,sendReasoningInMessages:X,authAdapter:b,transportAdapter:k,models:P.map(Ye=>{var ae,Me,Ze,Rt,nn,Ne,Te,Pe,Xe,tt,mt,_t,Ln,mn,wn,Ja;return{id:Ye.id,name:Ye.name,apiModelId:Ye.apiModelId,requestBody:Ye.requestBody,reasoningEfforts:Ye.reasoningEfforts,contextWindow:((ae=I[Ye.id])==null?void 0:ae.contextWindow)??Ye.contextWindow,selected:B.has(Ye.id)||void 0,supportsVision:(Me=I[Ye.id])==null?void 0:Me.supportsVision,thinkingEnabled:(Ze=I[Ye.id])==null?void 0:Ze.thinkingEnabled,thinkingLevel:(Rt=I[Ye.id])==null?void 0:Rt.thinkingLevel,nonThinkingEnabled:(nn=I[Ye.id])==null?void 0:nn.nonThinkingEnabled,thinkingQueryParams:(Ne=I[Ye.id])==null?void 0:Ne.thinkingQueryParams,nonThinkingQueryParams:(Te=I[Ye.id])==null?void 0:Te.nonThinkingQueryParams,temperature:(Pe=I[Ye.id])==null?void 0:Pe.temperature,topP:(Xe=I[Ye.id])==null?void 0:Xe.topP,topK:(tt=I[Ye.id])==null?void 0:tt.topK,maxTokens:(mt=I[Ye.id])==null?void 0:mt.maxTokens,defaultMaxTokens:(_t=I[Ye.id])==null?void 0:_t.defaultMaxTokens,defaultTemperature:(Ln=I[Ye.id])==null?void 0:Ln.defaultTemperature,defaultTopP:(mn=I[Ye.id])==null?void 0:mn.defaultTopP,defaultTopK:(wn=I[Ye.id])==null?void 0:wn.defaultTopK,compactionThreshold:(Ja=I[Ye.id])==null?void 0:Ja.compactionThreshold}})}),Fe.current=!0,t()}return e?s.jsxs("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-50",children:[s.jsxs(ct,{className:"bg-bg-secondary border border-border rounded-xl w-[640px] max-h-[85vh] shadow-2xl",children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border",children:[s.jsx("h3",{className:"text-lg font-semibold text-text-primary",children:a?"Edit Provider":"Add Provider"}),s.jsx("button",{onClick:cn,className:"text-text-muted hover:text-text-primary text-xl leading-none p-1",children:"×"})]}),s.jsx("div",{className:"flex gap-1.5 px-6 pt-4",children:[1,2].map(be=>s.jsx("div",{className:`h-1 flex-1 rounded-full transition-colors ${be<u?"bg-accent-success":be===u?"bg-accent-primary":"bg-border"}`},be))}),u===1&&s.jsxs("div",{className:"px-6 py-4 space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-text-secondary mb-2",children:"Inference engine"}),s.jsxs("div",{className:"grid grid-cols-5 gap-2",children:[Ce.map(be=>s.jsx("button",{type:"button",onClick:()=>{h(be.defaults.name??be.name),m(be.defaults.url),y(be.defaults.backend),S(!1),C(""),v(be.authAdapter),T(be.transportAdapter),O(null),Sn()},className:`p-2 rounded border text-center text-sm transition-colors ${k&&k===be.transportAdapter?"border-accent-primary bg-accent-primary/10 text-accent-primary":"border-border hover:border-text-muted text-text-secondary"}`,children:be.name},be.id)),s.jsx("button",{type:"button",onClick:()=>{y("unknown"),S(!1),v(void 0),T(void 0),O(null),Sn()},className:`p-2 rounded border text-center text-sm transition-colors ${g==="unknown"?"border-accent-primary bg-accent-primary/10 text-accent-primary":"border-border hover:border-text-muted text-text-secondary"}`,children:"Other"},"other"),MV.map(be=>{const et={8e3:"vllm",11434:"ollama",8080:"llamacpp",1234:"lmstudio"},Ye={8e3:"vLLM",11434:"Ollama",8080:"llama.cpp",1234:"LM Studio"};return s.jsx("button",{type:"button",onClick:()=>{h(ae=>ae||(Ye[be]??"")),m(ae=>ae||`http://localhost:${be}`),y(et[be]??""),S(!0),v(void 0),T(void 0),O(null),Sn()},className:`p-2 rounded border text-center text-sm transition-colors ${g===et[be]?"border-accent-primary bg-accent-primary/10 text-accent-primary":"border-border hover:border-text-muted text-text-secondary"}`,children:Ye[be]??`localhost:${be}`},be)})]})]}),!b&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Provider URL"}),s.jsx("input",{ref:Ue,type:"text",value:p,"data-testid":"provider-modal-url",onChange:be=>{m(be.target.value),O(null),V([]),D({})},placeholder:"http://localhost:8000",className:"w-full px-4 py-2 bg-bg-primary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Provider name"}),s.jsx("input",{type:"text",autoComplete:"off",value:d,onChange:be=>h(be.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"})]}),!b&&s.jsxs("div",{children:[s.jsxs("label",{className:"block text-sm text-text-secondary mb-1",children:["API key ",s.jsx("span",{className:"text-text-muted",children:"(optional)"})]}),s.jsx("input",{type:"text",autoComplete:"off",value:w,onChange:be=>C(be.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"})]}),!b&&s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:_,onChange:be=>S(be.target.checked),className:"w-4 h-4 rounded border-border bg-bg-primary accent-accent-primary"}),s.jsx("span",{className:"text-sm text-text-secondary",children:"This is a local provider"})]})]}),u===2&&s.jsxs("div",{className:"px-6 py-4 space-y-4",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("h4",{className:"text-sm font-medium text-text-primary",children:"Test & Configure Models"}),s.jsx("button",{type:"button",onClick:()=>U(!0),className:"p-1.5 text-text-muted hover:text-text-primary rounded transition-colors",title:"Provider-level defaults",children:s.jsx(AE,{className:"w-4 h-4"})})]}),!!b&&s.jsxs("div",{className:"rounded-lg border border-border bg-bg-primary p-4",children:[s.jsxs("div",{className:"flex items-center justify-between gap-4",children:[s.jsxs("div",{children:[s.jsx("h4",{className:"text-sm font-medium text-text-primary",children:"Connect provider"}),s.jsx("p",{className:"mt-1 text-xs text-text-muted",children:"Connect this provider before choosing available models."})]}),Se==="connected"?s.jsx("span",{className:"text-sm font-medium text-accent-success",children:"Connected ✓"}):s.jsx("button",{type:"button",onClick:()=>void Ut(),disabled:ze||Se==="pending",className:"rounded-lg bg-accent-primary px-4 py-2 text-sm font-medium text-text-primary disabled:opacity-50",children:ze||Se==="pending"?"Connecting...":Se==="error"?"Retry":"Connect"})]}),Ge&&s.jsx("div",{className:"mt-4 border-t border-border pt-4",children:Ge.mode!=="browser"?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-xs text-text-muted",children:"Use this code to complete authorization:"}),s.jsx("button",{type:"button",onClick:()=>void At(),className:"mt-3 w-full rounded-lg border border-accent-primary/40 px-4 py-4 font-mono text-2xl font-semibold tracking-[0.2em] text-accent-primary",children:Ge.userCode??"Continue"}),s.jsxs("div",{className:"mt-3 flex gap-2",children:[s.jsx("button",{type:"button",onClick:()=>void At(),className:"flex-1 rounded-lg border border-border px-3 py-2 text-sm text-text-primary",children:Ve?"Copied":"Copy code"}),s.jsx("button",{type:"button",onClick:Mn,className:"flex-1 rounded-lg bg-accent-primary px-3 py-2 text-sm font-medium text-text-primary",children:We?"Reopen authorization":"Open authorization"})]})]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"text-xs text-text-muted mb-3",children:Ge.instructions}),s.jsx("button",{type:"button",onClick:Mn,className:"w-full rounded-lg bg-accent-primary px-3 py-2 text-sm font-medium text-text-primary",children:We?"Reopen authorization":"Open authorization"})]})})]}),N&&s.jsxs("div",{className:"flex items-center gap-2 text-sm text-text-muted",children:[s.jsx("span",{className:"w-4 h-4 border-2 border-accent-primary border-t-transparent rounded-full animate-spin"}),"Fetching models..."]}),A&&s.jsxs("div",{className:"p-3 rounded-lg text-sm bg-red-500/10 text-red-500 border border-red-500/20",children:[s.jsx("p",{children:A}),s.jsxs("p",{className:"text-xs text-text-muted mt-1",children:["URL: ",p]}),s.jsxs("div",{className:"flex gap-2 mt-2",children:[s.jsx("button",{onClick:()=>_n(p),className:"text-xs text-accent-primary hover:underline",children:"Retry"}),s.jsx("button",{onClick:()=>{Sn(),c(1)},className:"text-xs text-accent-primary hover:underline",children:"Edit URL"}),!b&&s.jsx("button",{onClick:()=>{var be;return(be=Qe.current)==null?void 0:be.focus()},className:"text-xs text-accent-primary hover:underline",children:"Add model manually"})]})]}),g&&(!b||Se==="connected")&&s.jsxs("div",{children:[s.jsx("h4",{className:"text-sm font-medium text-text-primary mb-1",children:"Add model manually"}),s.jsx("p",{className:"text-xs text-text-muted mb-2",children:A?"Can't discover models automatically? Enter the model name to use:":"Enter a model name manually if it does not appear in the list above:"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{ref:Qe,type:"text",value:ie,onChange:be=>{ye(be.target.value),Le&&ue(null)},onKeyDown:be=>{be.key==="Enter"&&(be.preventDefault(),it())},placeholder:"model-name","data-testid":"provider-modal-manual-model-input",className:"flex-1 px-3 py-1.5 bg-bg-primary border border-border rounded-lg text-sm text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"}),s.jsx("button",{type:"button",onClick:it,"data-testid":"provider-modal-manual-model-add",className:"px-3 py-1.5 bg-accent-primary text-text-primary rounded-lg text-sm font-medium hover:bg-accent-primary/90 transition-colors",children:"Add"})]}),Le&&s.jsx("p",{className:"text-xs text-red-500 mt-1",children:Le})]}),P.length>0&&g&&(!b||Se==="connected")&&s.jsxs(s.Fragment,{children:[B.size>0&&s.jsxs("div",{className:"mb-4",children:[s.jsxs("h4",{className:"text-sm font-medium text-text-primary mb-1",children:["Selected Models (",B.size,")"]}),s.jsx("p",{className:"text-xs text-text-muted mb-2",children:"Only selected models will appear in the model selector."}),s.jsx("div",{className:"space-y-2",children:P.filter(be=>B.has(be.id)).map(be=>{var et;return s.jsxs("div",{className:"bg-bg-primary border border-border rounded-lg overflow-hidden",children:[s.jsxs("div",{onClick:()=>W(z===be.id?null:be.id),className:"w-full flex items-center justify-between px-4 py-3 hover:bg-bg-tertiary transition-colors cursor-pointer",children:[s.jsxs("div",{className:"flex items-center gap-3",children:[s.jsx("span",{className:"text-sm font-medium text-text-primary",children:be.name??be.id.split("/").pop()}),s.jsxs("span",{className:"text-xs text-text-muted bg-bg-tertiary px-2 py-0.5 rounded",children:[(((et=I[be.id])==null?void 0:et.contextWindow)??be.contextWindow).toLocaleString()," ctx"]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[q.progress[be.id]==="probing"?s.jsx("span",{className:"w-3 h-3 border-2 border-accent-primary border-t-transparent rounded-full animate-spin"}):q.progress[be.id]==="done"?s.jsx("span",{className:"text-xs text-accent-success font-medium",children:"Configured ✓"}):q.progress[be.id]==="error"?s.jsx("span",{className:"text-xs text-red-500 font-medium",children:"Failed ✗"}):b?null:s.jsx("button",{onClick:Ye=>{Ye.stopPropagation(),dn(be.id)},className:"text-xs text-accent-primary hover:underline",children:"Auto-config"}),P.length>1&&s.jsx("button",{onClick:Ye=>{Ye.stopPropagation();const ae=new Set(B);ae.delete(be.id),ne(ae),z===be.id&&W(null)},className:"text-xs text-red-500 hover:text-red-400 px-2 py-1 rounded hover:bg-red-500/10",children:"Remove"}),s.jsx(vn,{className:`w-4 h-4 text-text-muted transition-transform ${z===be.id?"rotate-180":""}`})]})]}),z===be.id&&s.jsx(PV,{model:be,modelConfigs:I,autoConfigState:q,testResults:J,onUpdateConfig:rt,onRunAutoConfig:dn,onTestParams:An,onShowRaw:K})]},be.id)})})]}),P.length>1&&s.jsxs("div",{children:[s.jsx("h4",{className:"text-sm font-medium text-text-primary mb-1",children:"Available Models"}),B.size===0&&s.jsx("p",{className:"text-xs text-text-muted mb-2",children:"This provider has many models available. Select the ones you want to use below."}),s.jsxs("div",{className:"relative mb-2",children:[s.jsx("input",{type:"text",value:se,onChange:be=>re(be.target.value),placeholder:"Search models...",className:"w-full px-4 py-2 bg-bg-primary border border-border rounded-lg text-sm text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"}),se&&s.jsx("button",{onClick:()=>re(""),className:"absolute right-3 top-1/2 -translate-y-1/2 text-text-muted hover:text-text-primary text-sm",children:"×"})]}),s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsxs("p",{className:"text-xs text-text-muted",children:["Showing ",Ie(se).length," of ",P.length," models"]}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{onClick:()=>{const be=new Set(B),et=Ie(se);for(const Ye of et)be.add(Ye.id);if(ne(be),D(Ye=>{const ae={...Ye};for(const Me of et)ae[Me.id]={contextWindow:Me.contextWindow,...ae[Me.id]};return ae}),!b)for(const Ye of et)q.progress[Ye.id]!=="probing"&&q.progress[Ye.id]!=="done"&&dn(Ye.id)},className:"text-xs text-accent-primary hover:underline",children:"Select all"}),s.jsx("button",{onClick:()=>{const be=new Set(B),et=Ie(se);for(const Ye of et)be.delete(Ye.id);ne(be)},className:"text-xs text-text-muted hover:text-text-secondary",children:"Deselect all"})]})]}),s.jsxs(ct,{className:"space-y-1 max-h-48 border border-border rounded-lg bg-bg-primary",children:[Ie(se).map(be=>{var Ye;const et=B.has(be.id);return s.jsxs("div",{role:"checkbox","aria-checked":et,tabIndex:0,className:`flex items-center gap-3 px-4 py-2 hover:bg-bg-tertiary transition-colors cursor-pointer ${et?"bg-accent-primary/5":""}`,onClick:()=>{if(et){const ae=new Set(B);ae.delete(be.id),ne(ae)}else pe(be),b||dn(be.id)},onKeyDown:ae=>{(ae.key==="Enter"||ae.key===" ")&&(ae.preventDefault(),ae.currentTarget.click())},children:[s.jsx("input",{type:"checkbox",checked:et,onChange:()=>{},className:"w-4 h-4 rounded border-border accent-accent-primary pointer-events-none"}),s.jsx("span",{className:"text-sm text-text-primary flex-1 truncate",children:be.name??be.id.split("/").pop()}),s.jsxs("span",{className:"text-xs text-text-muted flex-shrink-0",children:[(((Ye=I[be.id])==null?void 0:Ye.contextWindow)??be.contextWindow).toLocaleString()," ctx"]}),q.progress[be.id]==="probing"&&s.jsx("span",{className:"w-3 h-3 border-2 border-accent-primary border-t-transparent rounded-full animate-spin flex-shrink-0"}),q.progress[be.id]==="done"&&s.jsx("span",{className:"text-xs text-accent-success flex-shrink-0",children:"✓"}),q.progress[be.id]==="error"&&s.jsx("span",{className:"text-xs text-red-500 flex-shrink-0",children:"✗"})]},be.id)}),Ie(se).length===0&&s.jsxs("div",{className:"px-4 py-6 text-center text-sm text-text-muted",children:["No models match “",se,"”"]})]})]})]})]}),s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-t border-border",children:[s.jsx("div",{children:u>1&&s.jsx("button",{onClick:()=>{u===2&&Sn(),c(u-1)},className:"text-sm text-text-muted hover:text-text-secondary transition-colors",children:"← Back"})}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("button",{onClick:cn,className:"px-4 py-2 text-sm text-text-muted hover:text-text-secondary transition-colors",children:"Cancel"}),u===1?s.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"}):s.jsx("button",{onClick:er,disabled:q.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:q.loading?"Configuring...":"Save Provider"})]})]})]}),M&&s.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[60]",onClick:be=>{be.target===be.currentTarget&&U(!1)},children:s.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl w-[480px] shadow-2xl",children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border",children:[s.jsx("h3",{className:"text-base font-semibold text-text-primary",children:"Provider-Level Defaults"}),s.jsx("button",{onClick:()=>U(!1),className:"text-text-muted hover:text-text-primary text-xl leading-none p-1",children:"×"})]}),s.jsxs("div",{className:"px-6 py-4 space-y-4",children:[s.jsx("p",{className:"text-xs text-text-muted",children:"These apply to all models unless overridden per-model."}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-text-secondary block mb-1",children:"Non-thinking mode params"}),s.jsx("input",{type:"text",defaultValue:'{"chat_template_kwargs":{"enable_thinking":false}}',readOnly:!0,className:"w-full px-3 py-2 bg-bg-primary border border-border rounded text-sm text-text-secondary font-mono"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-xs text-text-secondary block mb-1",children:"Thinking mode params"}),s.jsx("input",{type:"text",defaultValue:'reasoning_effort: "low"',readOnly:!0,className:"w-full px-3 py-2 bg-bg-primary border border-border rounded text-sm text-text-secondary font-mono"})]}),s.jsxs("div",{children:[s.jsxs("label",{className:"text-xs text-text-secondary block mb-1",children:["Thinking response field ",s.jsx("span",{className:"text-text-muted",children:"(override)"})]}),s.jsx("input",{type:"text",value:F,onChange:be=>Q(be.target.value),placeholder:"Leave blank for auto-detect",className:"w-full px-3 py-2 bg-bg-primary border border-border rounded text-sm text-text-primary font-mono"}),s.jsx("p",{className:"text-xs text-text-muted mt-1",children:"Field name the backend uses for reasoning/thinking content (e.g. reasoning, reasoning_content, thinking)."})]}),s.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:X,onChange:be=>H(be.target.checked),className:"rounded border-border bg-bg-primary text-accent-primary focus:ring-accent-primary"}),s.jsx("span",{className:"text-sm text-text-secondary",children:"Send reasoning in messages"}),s.jsx("span",{className:"text-xs text-text-muted ml-auto",children:"When disabled, strips reasoning/thinking content from assistant messages sent to this provider"})]})]}),s.jsx("div",{className:"flex justify-end px-6 py-4 border-t border-border",children:s.jsx("button",{onClick:()=>U(!1),className:"px-5 py-2 bg-accent-primary text-text-primary rounded-lg text-sm font-medium hover:bg-accent-primary/90 transition-colors",children:"Done"})})]})}),Z&&s.jsx("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[60]",onClick:be=>{be.target===be.currentTarget&&K(null)},children:s.jsxs("div",{className:"bg-bg-secondary border border-border rounded-xl w-[640px] max-h-[80vh] shadow-2xl flex flex-col",children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border shrink-0",children:[s.jsx("h3",{className:"text-base font-semibold text-text-primary",children:"Raw Response"}),s.jsx("button",{onClick:()=>K(null),className:"text-text-muted hover:text-text-primary text-xl leading-none p-1",children:"×"})]}),s.jsx(ct,{horizontal:!0,children:s.jsx("pre",{className:"px-6 py-4 text-xs text-text-secondary font-mono whitespace-pre-wrap break-all",children:Z})})]})})]}):null}function ck({activeProvider:e,shortModelName:t,agentOverrideActive:n,agentColor:r,agentName:a}){return s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"text-sm text-accent-primary flex items-center gap-1",children:[n&&s.jsx("span",{className:"w-2.5 h-2.5 rounded-full flex-shrink-0 ring-1 ring-border",style:{backgroundColor:r??"#6b7280"},title:`Model set by agent "${a??"unknown"}". Change it in Settings > Agents.`}),e?s.jsxs(s.Fragment,{children:[s.jsxs("span",{className:"hidden sm:inline",children:[e.name," • "]}),t]}):t]}),s.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded-full ${e!=null&&e.isLocal?"text-accent-success bg-accent-success/10":"text-accent-warning bg-accent-warning/10"}`,children:e!=null&&e.isLocal?"local":"api"})]})}function $V(){var Ye;const[,e]=Gn(),t=De(ae=>ae.currentSession),n=De(ae=>ae.setSessionProvider),[r,a]=E.useState(!1),[l,u]=E.useState([]),[c,d]=E.useState(null),h=E.useRef(null),[p,m]=E.useState(null),[g,y]=E.useState(!1),[w,C]=E.useState({}),[_,S]=E.useState(null),[b,v]=E.useState(null),[k,T]=E.useState(!1),N=E.useRef(null),[R,A]=E.useState(!1),O=E.useRef(new Set),P=Zt(ae=>ae.providers),V=Zt(ae=>ae.activeProviderId),z=Zt(ae=>ae.defaultModelSelection),W=Zt(ae=>ae.activating),M=Zt(ae=>ae.activateProvider),U=Zt(ae=>ae.refreshModel),F=Zt(ae=>ae.refreshProviderModels),Q=Zt(ae=>ae.setDefaultModel),X=Zt(ae=>ae.fetchConfig),H=uu();Qc(H.modelSelector,()=>a(ae=>!ae));const I=(t==null?void 0:t.providerId)??null,D=(t==null?void 0:t.providerModel)??null,q=(z==null?void 0:z.split("/")[0])??null,$=(z==null?void 0:z.split("/").slice(1).join("/"))??null,J=ft(ae=>ae.defaults),Y=ft(ae=>ae.userItems),Z=ft(ae=>ae.modelOverrides),K=t==null?void 0:t.mode,B=K?J.find(ae=>ae.id===K)??Y.find(ae=>ae.id===K):void 0,ne=K?Z[K]??void 0:void 0,se=ne?ne.split("/")[0]??null:null,re=ne?ne.split("/").slice(1).join("/")??null:null,oe=K?ul([...J,...Y],K):void 0,ve=!!ne,Se=se??I??q,$e=re??D??$,ze=$e?((Ye=$e.split("/").pop())==null?void 0:Ye.replace(/-/g," "))??$e:"No model",[ke,Ge]=E.useState(!1);E.useEffect(()=>{function ae(Me){h.current&&!h.current.contains(Me.target)&&(a(!1),u([]),O.current=new Set)}return document.addEventListener("mousedown",ae),()=>document.removeEventListener("mousedown",ae)},[]),E.useEffect(()=>()=>{N.current!==null&&window.clearTimeout(N.current)},[]),E.useEffect(()=>{r||(At(""),_n(-1))},[r]),E.useEffect(()=>{var ae;r&&Bt()&&((ae=er.current)==null||ae.focus())},[r]),E.useEffect(()=>{if(r){const ae=P.map(Me=>Me.id);u(ae),P.filter(Me=>!!Me.authAdapter).forEach(Me=>void Le(Me.id)),ae.forEach(Me=>{O.current.has(Me)||(O.current.add(Me),he(Me))})}},[r,P]),E.useEffect(()=>{if(!b)return;let ae=!1;const Me=async()=>{const Rt=await Le(b.providerId);ae||Rt==="connected"&&(v(null),T(!1),A(!1),await X(),O.current.delete(b.providerId),await he(b.providerId))};Me();const Ze=window.setInterval(()=>void Me(),2e3);return()=>{ae=!0,window.clearInterval(Ze)}},[b]);const Je=P.find(ae=>ae.id===Se),Ce=(Je==null?void 0:Je.status)==="disconnected",me=(ae,Me)=>t?t.providerId===ae&&t.providerModel===Me:!1,We=(ae,Me)=>z?z===`${ae}/${Me}`:!1,he=async ae=>{d(ae);try{await F(ae)}catch{}finally{d(null)}},Ve=ae=>{l.includes(ae.id)?u(l.filter(Me=>Me!==ae.id)):(u([...l,ae.id]),he(ae.id))},He=async ae=>{if(ae.id===V){Ve(ae);return}t?(n(ae.id,void 0),a(!1),u([])):await M(ae.id)&&(a(!1),u([]))},ie=ae=>{Ve(ae)},ye=async(ae,Me)=>{ae.stopPropagation(),O.current.delete(Me),await he(Me)},Le=async ae=>{const Me=await we(`/api/provider-auth/${ae}/status`);if(!Me.ok)return"error";const Ze=await Me.json();return C(Rt=>({...Rt,[ae]:Ze.state})),Ze.state},ue=async(ae,Me)=>{ae.stopPropagation(),S(Me),C(Ze=>({...Ze,[Me]:"pending"})),T(!1),A(!1);try{const Ze=await we(`/api/provider-auth/${Me}/login`,{method:"POST"});if(!Ze.ok)throw new Error("Unable to start provider sign-in");const Rt=await Ze.json();v({providerId:Me,...Rt})}catch{C(Ze=>({...Ze,[Me]:"error"}))}finally{S(null)}},de=async()=>{var ae;b!=null&&b.userCode&&(await((ae=navigator.clipboard)==null?void 0:ae.writeText(b.userCode)),N.current!==null&&window.clearTimeout(N.current),T(!1),requestAnimationFrame(()=>T(!0)),N.current=window.setTimeout(()=>{T(!1),N.current=null},1500))},Fe=()=>{b&&(window.open(b.directUrl??b.verificationUrl,"_blank","noopener,noreferrer"),A(!0))},Ue=()=>{v(null),T(!1),A(!1)},Qe=async(ae,Me)=>{ae.stopPropagation(),S(Me);try{if(!(await we(`/api/provider-auth/${Me}/logout`,{method:"POST"})).ok)throw new Error("Unable to disconnect provider account");C(Rt=>({...Rt,[Me]:"disconnected"})),await X()}finally{S(null)}},rt=(ae,Me)=>{m({providerId:ae,model:Me}),y(!0)},pe=p?P.find(ae=>ae.id===p.providerId):void 0,Ie=()=>{m(null),y(!1)},it=async ae=>{try{if(!(await we(`/api/providers/${ae.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(OT(ae))})).ok)throw new Error("Failed to update provider");await Zt.getState().fetchConfig()}catch{}m(null),y(!1)},ut=async(ae,Me)=>{if(K&&ne&&ne!==`${ae}/${Me}`&&(we(`/api/agents/${K}/model`,{method:"DELETE"}).catch(()=>{}),ft.setState(Rt=>{const nn={...Rt.modelOverrides};return delete nn[K],{modelOverrides:nn}})),t){De.setState(Rt=>({currentSession:Rt.currentSession?{...Rt.currentSession,providerId:ae,providerModel:Me}:null})),n(ae,Me),u([]),a(!1),ou();return}await M(ae)&&(u([]),a(!1),ou())},$t=async(ae,Me,Ze)=>{ae.stopPropagation(),Ge(!0);try{await Q(Me,Ze)}catch{}finally{Ge(!1)}},{searchQuery:Ut,setSearchQuery:At,highlightedIndex:Mn,setHighlightedIndex:_n,visibleGroups:dn,flatItems:An,handleSearchKeyDown:Sn,highlightedRef:cn,inputRef:er}=LT({providers:P,onSelect:ut,onEscape:()=>a(!1),extraItemCount:1}),be=Mn===An.length,et=ae=>{if(ae.key==="Enter"&&Mn===An.length){ae.preventDefault(),e("/onboarding"),a(!1);return}Sn(ae)};return P.length===0?s.jsxs("button",{type:"button",onClick:()=>U(),className:"flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors group",title:Ce?"LLM server is offline. Click to retry.":ze??"Click to refresh model",children:[Ce?s.jsx("span",{className:"text-sm text-accent-error animate-pulse",children:"LLM offline"}):s.jsx(ck,{activeProvider:Je,shortModelName:ze,agentOverrideActive:ve,agentColor:oe,agentName:B==null?void 0:B.name}),s.jsx("span",{className:"text-text-muted opacity-0 group-hover:opacity-100 transition-opacity",children:"↻"})]}):s.jsxs("div",{className:"relative",ref:h,children:[s.jsxs("button",{type:"button",onClick:()=>a(!r),className:"flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors group",title:"Click to switch provider or model",children:[Ce?s.jsx("span",{className:"text-sm text-accent-error animate-pulse",children:"offline"}):s.jsx(ck,{activeProvider:Je,shortModelName:ze,agentOverrideActive:ve,agentColor:oe,agentName:B==null?void 0:B.name}),s.jsx(vn,{className:"w-3 h-3 text-text-muted transition-transform",rotate:r?180:0})]}),r&&s.jsxs("div",{className:"absolute bottom-full right-0 mb-1 min-w-72 max-w-[100vw] bg-bg-secondary border border-border rounded-lg shadow-lg z-50 flex flex-col max-h-[80vh]",children:[s.jsxs("div",{className:"flex items-center gap-1 px-3 py-2 border-b border-border flex-shrink-0",children:[s.jsx(Xi,{className:"w-3.5 h-3.5 text-text-muted flex-shrink-0"}),s.jsx("input",{ref:er,type:"text",value:Ut,onInput:ae=>{At(ae.currentTarget.value),_n(-1)},onKeyDown:et,placeholder:"Search models...",className:"bg-transparent border-none outline-none text-sm text-text-primary w-full placeholder:text-text-muted"})]}),s.jsx(ct,{className:"flex-1 min-h-0",children:s.jsxs("div",{children:[dn.map(ae=>{const Me=Ut.trim().length>0||l.includes(ae.provider.id);return s.jsxs("div",{children:[s.jsxs("div",{className:`px-3 py-2 flex items-center justify-between ${ae.provider.id===Se?"bg-bg-tertiary":"hover:bg-bg-tertiary"} ${W?"opacity-50 cursor-wait":"cursor-pointer"}`,children:[s.jsxs("div",{onClick:()=>!W&&He(ae.provider),className:"flex flex-col min-w-0 flex-1 cursor-pointer",children:[s.jsx("span",{className:`text-sm font-medium truncate ${ae.provider.id===Se?"text-accent-primary":"text-text-primary"}`,children:ae.provider.name}),s.jsx("span",{className:"text-xs text-text-muted truncate",children:ae.provider.backend!=="unknown"&&pE(ae.provider.backend)})]}),s.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[!!ae.provider.authAdapter&&(w[ae.provider.id]==="connected"||ae.provider.credentialRef?s.jsx("button",{type:"button",onClick:Ze=>Qe(Ze,ae.provider.id),disabled:_===ae.provider.id,className:"text-[10px] px-1.5 py-0.5 rounded border border-accent-success/40 text-accent-success hover:bg-accent-success/10 disabled:opacity-50",title:"Disconnect provider account",children:"Connected"}):s.jsx("button",{type:"button",onClick:Ze=>ue(Ze,ae.provider.id),disabled:_===ae.provider.id,className:"text-[10px] px-1.5 py-0.5 rounded border border-accent-primary/40 text-accent-primary hover:bg-accent-primary/10 disabled:opacity-50",title:"Connect provider account",children:_===ae.provider.id?"Starting…":w[ae.provider.id]==="error"||w[ae.provider.id]==="expired"?"Retry":"Connect"})),ae.provider.id===Se?s.jsx("span",{className:"text-accent-success",title:"Active provider",children:s.jsx(Ls,{className:"w-4 h-4"})}):s.jsx("span",{className:"w-4"}),s.jsx("button",{type:"button",onClick:Ze=>{Ze.stopPropagation(),ye(Ze,ae.provider.id)},className:"p-0.5 hover:bg-bg-tertiary rounded transition-colors",title:"Refresh models",children:s.jsx(xf,{className:`w-4 h-4 ${c===ae.provider.id?"animate-spin":""} ${ae.provider.id===V?"text-accent-primary":"text-text-muted"}`})}),s.jsx("button",{type:"button",onClick:Ze=>{Ze.stopPropagation(),ie(ae.provider)},className:"p-0.5 hover:bg-bg-tertiary rounded transition-colors",title:"Show models",children:s.jsx(vn,{className:`w-4 h-4 transition-transform ${Me?"rotate-180":""} ${ae.provider.id===V?"text-accent-primary":"text-text-muted"}`})})]})]}),Me&&s.jsx(ct,{className:"bg-bg-primary border-t border-border max-h-40",children:c===ae.provider.id?s.jsx("div",{className:"px-4 py-2 text-xs text-text-muted",children:"Loading models..."}):ae.models.length>0?ae.models.map(Ze=>{const nn=An.findIndex(Ne=>Ne.providerId===ae.provider.id&&Ne.modelConfig.id===Ze.id)===Mn;return s.jsx("div",{ref:nn?cn:void 0,children:s.jsx(AT,{providerId:ae.provider.id,modelConfig:Ze,isActive:me(ae.provider.id,Ze.id),isDefault:We(ae.provider.id,Ze.id),disabled:c==="activating",hasSession:!!t,settingDefault:ke,highlighted:nn,onModelClick:ut,onSetDefault:$t,onEditModel:rt})},`${ae.provider.id}/${Ze.id}`)}):s.jsx("div",{className:"px-4 py-2 text-xs text-text-muted",children:"No models available"})})]},ae.provider.id)}),dn.length===0&&Ut.trim()&&s.jsx("div",{className:"px-4 py-3 text-sm text-text-muted text-center",children:"No models match your search"})]})}),s.jsx("div",{className:`border-t border-border px-3 py-2 ${be?"bg-bg-tertiary":""} flex-shrink-0`,children:s.jsx("button",{onClick:()=>e("/onboarding"),className:"text-xs text-accent-primary hover:underline",children:"Manage providers"})})]}),b&&s.jsx("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/70 px-4",role:"dialog","aria-modal":"true","aria-labelledby":"provider-device-title",onMouseDown:ae=>{ae.target===ae.currentTarget&&Ue()},children:s.jsxs("div",{className:"w-full max-w-md rounded-xl border border-border bg-bg-secondary p-6 shadow-2xl",children:[s.jsxs("div",{className:"flex items-start justify-between gap-4",children:[s.jsxs("div",{children:[s.jsx("h2",{id:"provider-device-title",className:"text-lg font-semibold text-text-primary",children:"Connect provider"}),s.jsx("p",{className:"mt-1 text-sm text-text-muted",children:"Follow the provider instructions to complete authorization."})]}),s.jsx("button",{type:"button",onClick:Ue,className:"rounded px-2 py-1 text-xl leading-none text-text-muted hover:bg-bg-tertiary hover:text-text-primary","aria-label":"Close",children:"×"})]}),b.mode!=="browser"?s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",onClick:de,className:"mt-6 w-full select-all rounded-lg border border-accent-primary/40 bg-bg-primary px-4 py-5 font-mono text-3xl font-semibold tracking-[0.2em] text-accent-primary hover:bg-bg-tertiary",title:"Copy code",children:b.userCode??"Continue"}),s.jsx("div",{className:"mt-3 text-center text-xs text-text-muted",children:k?"Copied to clipboard":"Click the code to copy it"}),s.jsxs("div",{className:"mt-6 flex gap-3",children:[s.jsx("button",{type:"button",onClick:de,className:"flex-1 rounded-lg border border-border px-4 py-2 text-sm text-text-primary hover:bg-bg-tertiary",children:k?"Copied":"Copy code"}),s.jsx("button",{type:"button",onClick:Fe,className:"flex-1 rounded-lg bg-accent-primary px-4 py-2 text-sm font-medium text-text-primary hover:bg-accent-primary/90",children:R?"Reopen authorization":"Open authorization"})]}),s.jsx("p",{className:"mt-4 text-center text-xs text-text-muted",children:R?"If the browser blocked or closed the tab, reopen authorization.":"OpenFox stays open while you complete authorization in the other tab."})]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"mt-6 text-sm text-text-secondary leading-relaxed bg-bg-primary p-4 rounded-lg border border-border",children:b.instructions}),s.jsx("div",{className:"mt-6 flex gap-3",children:s.jsx("button",{type:"button",onClick:Fe,className:"w-full rounded-lg bg-accent-primary px-4 py-2 text-sm font-medium text-text-primary hover:bg-accent-primary/90",children:R?"Reopen authorization":"Open authorization"})})]})]})}),p&&g&&s.jsx(IT,{isOpen:!0,onClose:Ie,onSave:it,initialStep:2,editProvider:{id:p.providerId,name:(pe==null?void 0:pe.name)??"",url:(pe==null?void 0:pe.url)??"",backend:(pe==null?void 0:pe.backend)??"unknown",apiKey:pe==null?void 0:pe.apiKey,isLocal:pe==null?void 0:pe.isLocal,thinkingField:pe==null?void 0:pe.thinkingField,sendReasoningInMessages:pe==null?void 0:pe.sendReasoningInMessages,authAdapter:pe==null?void 0:pe.authAdapter,transportAdapter:pe==null?void 0:pe.transportAdapter,models:pe==null?void 0:pe.models},editModelId:p.model.id})]})}function zV(){const e=Kc(k=>k.servers),t=Kc(k=>k.fetchServers),n=De(k=>k.currentSession),r=n==null?void 0:n.id,[a,l]=E.useState(!1),[u,c]=E.useState(null),[d,h]=E.useState(new Set),[p,m]=E.useState(new Set),g=E.useRef(null),y=E.useCallback(async()=>{if(r)try{const k=await we(`/api/sessions/${r}/mcp/overrides`);if(k.ok){const T=await k.json();m(new Set(T.disabledServers??[]))}}catch{}},[r]),w=E.useCallback(async()=>{await t(),await y()},[t,y]);E.useEffect(()=>{const k=()=>w();return window.addEventListener("mcp-servers-changed",k),()=>window.removeEventListener("mcp-servers-changed",k)},[w]),E.useEffect(()=>{y()},[y]),E.useEffect(()=>{a&&y()},[a,y]),Vf(g,()=>l(!1));const C=k=>p.has(k.name),_=e.filter(k=>k.status==="connected"&&!C(k)),S=_.length,b=_.reduce((k,T)=>k+T.estimatedTokens,0),v=async(k,T)=>{if(r){c(null),h(N=>new Set(N).add(k));try{const N=new Set(p);T?N.add(k):N.delete(k);const R=await we(`/api/sessions/${r}/mcp/overrides`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({disabledServers:Array.from(N)})});if(!R.ok){const A=await R.json().catch(()=>({}));throw new Error(A.error??"Toggle failed")}m(N),await t()}catch(N){c(N instanceof Error?N.message:String(N))}finally{h(N=>{const R=new Set(N);return R.delete(k),R})}}};return s.jsxs("div",{className:"relative",ref:g,children:[s.jsxs("button",{type:"button",onClick:()=>l(!a),className:"flex items-center gap-1 px-1.5 py-0.5 rounded hover:bg-bg-tertiary transition-colors group",title:S>0?`${S} MCP server(s) active`:"No MCP server active",children:[s.jsx("span",{className:"text-sm text-accent-primary whitespace-nowrap",children:S>0?`● ${S} MCP (${qh(b)})`:"MCP"}),s.jsx(vn,{className:"w-3 h-3 text-text-muted transition-transform",rotate:a?180:0})]}),a&&s.jsxs("div",{className:"absolute bottom-full right-0 mb-1 min-w-72 max-w-[100vw] bg-bg-secondary border border-border rounded-lg shadow-lg z-50 flex flex-col max-h-[80vh]",children:[s.jsx(ct,{className:"flex-1 min-h-0",children:e.length===0?s.jsx("div",{className:"px-4 py-3 text-sm text-text-muted text-center",children:"No MCP servers configured"}):e.map(k=>{const T=C(k),N=d.has(k.name);return s.jsx("div",{children:s.jsxs("div",{className:"px-3 py-2 flex items-center justify-between hover:bg-bg-tertiary",children:[s.jsxs("div",{className:"flex flex-col min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[s.jsx("span",{className:`text-sm ${kb(T?"disabled":k.status)}`,children:Eb(T?"disabled":k.status)}),s.jsx("span",{className:"text-sm font-medium text-text-primary truncate",children:k.name})]}),s.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-muted ml-3.5",children:[s.jsxs("span",{children:[k.tools.length," tools"]}),k.estimatedTokens>0&&s.jsxs("span",{children:[qh(k.estimatedTokens)," tokens"]})]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[N&&s.jsx("span",{className:"text-xs text-text-muted animate-pulse",children:"..."}),s.jsx(cs,{enabled:!T,onClick:()=>v(k.name,!T)})]})]})},k.name)})}),s.jsx("div",{className:"border-t border-border px-3 py-2 flex-shrink-0",children:u?s.jsx("div",{className:"text-xs text-accent-error",children:u}):s.jsxs("span",{className:"text-xs text-text-muted",children:[e.length," server(s) configured"]})})]})]})}function HV(e,t){const n=e.slice(0,t),r=n.lastIndexOf("@");if(r===-1)return null;const a=n.slice(r+1);return a.includes(" ")||a.includes(`
318
+ `)||a.includes(" ")?null:{query:a,startIndex:r}}const FV=E.forwardRef(function({text:t,cursorPos:n,workdir:r,onSelect:a},l){const u=HV(t,n),[c,d]=E.useState([]),[h,p]=E.useState(!1),[m,g]=E.useState(0),y=E.useRef(null),w=E.useRef([]),C=E.useRef(0),_=E.useRef([]);E.useEffect(()=>{C.current=m},[m]),E.useEffect(()=>{_.current=c},[c]),E.useEffect(()=>{if(!u){d([]);return}const v=setTimeout(()=>{S(u.query)},150);return()=>clearTimeout(v)},[u==null?void 0:u.query,r]);const S=async v=>{p(!0);try{const k=new URLSearchParams({q:v});r&&k.set("workdir",r);const N=await(await we(`/api/files?${k.toString()}`)).json();d(N),g(0),C.current=0}catch(k){console.error("File search failed:",k),d([])}finally{p(!1)}},b=E.useCallback(v=>{if(!u)return!1;switch(v.key){case"ArrowDown":return v.preventDefault(),g(k=>{var N;const T=Math.min(k+1,_.current.length-1);return w.current[T]&&((N=w.current[T])==null||N.scrollIntoView({block:"nearest"})),T}),C.current=Math.min(C.current+1,_.current.length-1),!0;case"ArrowUp":return v.preventDefault(),g(k=>{var N;const T=Math.max(k-1,0);return w.current[T]&&((N=w.current[T])==null||N.scrollIntoView({block:"nearest"})),T}),C.current=Math.max(C.current-1,0),!0;case"Enter":case"Tab":{const k=_.current;return k[C.current]?(v.preventDefault(),a(k[C.current],u.startIndex),!0):!1}case"Escape":return v.preventDefault(),d([]),!0}return!1},[u,a]);return E.useImperativeHandle(l,()=>({handleKeyDown:b}),[b]),E.useEffect(()=>{if(!u)return;const v=k=>{y.current&&!y.current.contains(k.target)&&d([])};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[u]),u?h?s.jsx("div",{className:"absolute bottom-full left-0 right-0 mb-2 z-50",children:s.jsx("div",{className:"bg-bg-secondary border border-border rounded-lg shadow-lg",children:s.jsx("div",{className:"p-4 text-center",children:s.jsx(Zi,{size:"sm"})})})}):c.length===0?null:s.jsx("div",{ref:y,className:"absolute bottom-full left-0 right-0 mb-2 z-50",children:s.jsx(ct,{className:"bg-bg-secondary border border-border rounded-lg shadow-lg max-h-64",children:s.jsx("ul",{children:c.map((v,k)=>s.jsxs("li",{ref:T=>{w.current[k]=T},className:`px-3 py-2 cursor-pointer flex items-center gap-2 text-sm ${k===m?"bg-accent-primary/20 text-text-primary":"text-text-muted hover:bg-bg-tertiary"}`,onClick:()=>{u&&a(v,u.startIndex)},children:[v.type==="directory"?s.jsx(Qr,{className:"w-4 h-4 shrink-0"}):s.jsx("span",{className:"w-4 h-4 shrink-0"}),s.jsx("span",{className:"truncate",children:v.path})]},v.path))})})}):null});function UV(e,t){const n=e.slice(0,t);if(n.length===0||n[0]!=="/")return null;const r=n.slice(1);return r.includes(" ")||r.includes(`
319
+ `)||r.includes(" ")?null:{query:r,startIndex:0}}const VV=E.forwardRef(function({text:t,cursorPos:n,workflows:r,commands:a,onSelect:l},u){const c=UV(t,n),[d,h]=E.useState(0),p=E.useRef(null),m=E.useRef([]),g=E.useRef(0),y=E.useRef([]);E.useEffect(()=>{g.current=d},[d]),E.useEffect(()=>{y.current=C});const w=(c==null?void 0:c.query)??"",C=(()=>{if(!c)return[];const S=w.toLowerCase(),b=r.filter(k=>k.id.toLowerCase().includes(S)||k.name.toLowerCase().includes(S)).map(k=>({type:"workflow",id:k.id,name:k.name,scope:k.scope,paramCount:(k.parameters??[]).length})),v=a.filter(k=>k.id.toLowerCase().includes(S)||k.name.toLowerCase().includes(S)).map(k=>({type:"command",id:k.id,name:k.name,paramCount:0}));return[...b,...v]})();E.useEffect(()=>{h(0),g.current=0},[C.length]);const _=E.useCallback(S=>{if(!c||C.length===0)return!1;switch(S.key){case"ArrowDown":return S.preventDefault(),h(b=>{var k;const v=Math.min(b+1,C.length-1);return(k=m.current[v])==null||k.scrollIntoView({block:"nearest"}),v}),!0;case"ArrowUp":return S.preventDefault(),h(b=>{var k;const v=Math.max(b-1,0);return(k=m.current[v])==null||k.scrollIntoView({block:"nearest"}),v}),!0;case"Enter":case"Tab":{const b=C[g.current];return b?(S.preventDefault(),l(b,c.startIndex),!0):!1}case"Escape":return S.preventDefault(),!0}return!1},[c,C,l]);return E.useImperativeHandle(u,()=>({handleKeyDown:_}),[_]),!c||C.length===0?null:s.jsx("div",{ref:p,className:"absolute bottom-full left-0 right-0 mb-2 z-50",role:"listbox",children:s.jsx(ct,{className:"bg-bg-secondary border border-border rounded-lg shadow-lg max-h-64",children:s.jsx("div",{children:C.map((S,b)=>s.jsxs("button",{ref:v=>{m.current[b]=v},role:"option","aria-selected":b===d,className:`w-full text-left px-3 py-2 flex items-center gap-2 text-sm ${b===d?"bg-accent-primary/20 text-text-primary":"text-text-muted hover:bg-bg-tertiary"}`,onClick:()=>{c&&l(S,c.startIndex)},children:[s.jsxs("span",{className:`font-medium ${S.type==="workflow"?"text-accent-primary":"text-accent-warning"}`,children:["/",S.id]}),s.jsx("span",{className:"truncate flex-1",children:S.name}),S.type==="workflow"&&s.jsx("span",{className:"text-[10px] text-text-muted bg-bg-tertiary px-1.5 py-0.5 rounded whitespace-nowrap",children:Db[S.scope]}),S.paramCount>0&&s.jsxs("span",{className:"text-[10px] text-text-muted bg-bg-tertiary px-1.5 py-0.5 rounded",children:[S.paramCount," param",S.paramCount>1?"s":""]})]},`${S.type}-${S.id}-${S.type==="workflow"?S.scope:""}`))})})})});function WV({input:e,setInput:t,attachments:n,setAttachments:r,dragOver:a,setDragOver:l,errorMessage:u,setErrorMessage:c,scrollToBottom:d,sessionId:h,showHistory:p,history:m,selectedIndex:g,openHistory:y,closeHistory:w,navigateUp:C,navigateDown:_,selectCurrent:S,isAutoScrollActive:b,setAutoScroll:v,onOpenMessageSearch:k,onOpenCommandsModal:T,onOpenWorkflowsModal:N,onSelectWorkflow:R,onSelectWorkflowWithSubGroup:A,onSendCommand:O,clearInput:P}){const V=E.useRef(null),z=E.useRef(null),W=E.useRef(0),M=E.useRef(0),U=E.useRef(null),F=E.useRef(null),Q=gf(),X=De(ue=>ue.stopGeneration),H=De(ue=>ue.cancelQueued),I=De(ue=>ue.queuedMessages),D=De(ue=>ue.restoredInput),q=De(ue=>ue.clearRestoredInput),$=De(ue=>{var de;return(de=ue.currentSession)==null?void 0:de.workdir}),J=De(ue=>ue.currentSession),Y=E.useRef(!1),Z=E.useRef(!1),K=E.useRef(!1),[B,ne]=E.useState([]),se=E.useRef(null),{sendMessage:re,launchWorkflow:oe}=TT(v);E.useEffect(()=>{if(Z.current)return;Z.current=!0;const ue=Ft.getState();ue.defaults.length===0&&ue.userItems.length===0&&ue.projectItems.length===0&&ue.fetchWorkflows();const de=ln.getState();de.defaults.length===0&&de.userItems.length===0&&de.projectItems.length===0&&de.fetchCommands()},[]),E.useEffect(()=>{e||ne([])},[e]),E.useEffect(()=>{var ue;D!==null&&(t(D),q(),Bt()&&((ue=V.current)==null||ue.focus()))},[D,t,q]);const ve=E.useCallback(()=>{const ue=V.current;if(!ue)return;const de=e.length>=W.current;W.current=e.length,de||(ue.style.height="auto"),ue.style.height=`${Math.min(200,ue.scrollHeight)}px`},[e]);E.useEffect(()=>{if(!h)return;const ue=`openfox:draft:${h}`,de=localStorage.getItem(ue);de!==null&&t(de)},[h,t]),E.useEffect(()=>{var ue;Bt()&&((ue=V.current)==null||ue.focus()),ve()},[h,ve]),E.useEffect(()=>{if(!h)return;const ue=`openfox:draft:${h}`,de=setTimeout(()=>{e?localStorage.setItem(ue,e):localStorage.removeItem(ue)},500);return()=>clearTimeout(de)},[h,e]),E.useEffect(()=>{ve()},[e,ve]),E.useEffect(()=>{const ue=V.current;if(!ue)return;const de=async Fe=>{var rt;if(document.activeElement!==ue)return;const Ue=(rt=Fe.clipboardData)==null?void 0:rt.items;if(!Ue)return;const Qe=[];for(const pe of Array.from(Ue)){let Ie=pe.getAsFile();if(Ie&&bU(Ie.type)){if(Fe.preventDefault(),!Ie.name){const it=yU(Ie.type);Ie=new File([Ie],`pasted-file.${it}`,{type:Ie.type})}await sk(Ie,it=>Qe.push(it),c)}}Qe.length>0&&r(pe=>[...pe,...Qe])};return ue.addEventListener("paste",de),()=>ue.removeEventListener("paste",de)},[r,c]);const Se=ue=>{ue.preventDefault(),!(!e.trim()&&n.length===0)&&he()},$e=ue=>{var de,Fe;if(!((de=F.current)!=null&&de.handleKeyDown(ue))&&!((Fe=U.current)!=null&&Fe.handleKeyDown(ue))){if(p)switch(ue.key){case"Enter":{ue.preventDefault();const Ue=S();Ue&&(t(Ue),w());return}case"Escape":ue.preventDefault(),w(),Q&&X();return;case"ArrowUp":ue.preventDefault(),C();return;case"ArrowDown":ue.preventDefault(),_();return}if(ue.key==="ArrowUp"&&e.trim()===""&&!p){ue.preventDefault(),y();return}ue.key==="Enter"&&!ue.shiftKey&&(ue.preventDefault(),Se(ue))}};async function ze(ue,de,Fe){const Ue=[];for(const Qe of Array.from(ue))await sk(Qe,rt=>Ue.push(rt),Fe);Ue.length>0&&de(Qe=>[...Qe,...Ue])}const ke=E.useCallback(async ue=>{const de=ue.target.files;!de||de.length===0||(c(null),await ze(de,r,c),z.current&&(z.current.value=""))},[r,c]),Ge=E.useCallback(ue=>{var de;(de=ue.dataTransfer.types)!=null&&de.includes("Files")&&(ue.preventDefault(),ue.stopPropagation(),l(!0))},[l]),Je=E.useCallback(ue=>{ue.preventDefault(),ue.stopPropagation(),l(!1)},[l]),Ce=E.useCallback(async ue=>{ue.preventDefault(),ue.stopPropagation(),l(!1),c(null);const de=ue.dataTransfer.files;!de||de.length===0||await ze(de,r,c)},[r,l,c]),me=E.useCallback(ue=>{r(n.filter(de=>de.id!==ue))},[n,r]),We=E.useCallback(()=>{var ue;(ue=z.current)==null||ue.click()},[]),he=()=>{if(K.current||!e.trim()&&n.length===0)return;if(K.current=!0,d==null||d(),e.trim().startsWith("/")){const de=il(Ft.getState()),Fe=ln.getState(),Ue=fr(fr(Fe.defaults,Fe.userItems),Fe.projectItems),Qe=iV(e,de,Ue);if(Qe!=null&&Qe.workflowId){const rt=se.current,pe=rt&&rt.id===Qe.workflowId?rt.scope:"auto";se.current=null;const Ie=dy(de,Qe.workflowId,pe),it=((Ie==null?void 0:Ie.parameters)??[]).filter(ut=>ut.required&&!(ut.id in Qe.params));if(it.length>0){const ut=it.map($t=>$t.label||$t.id).join(", ");c(`Missing required parameter${it.length>1?"s":""}: ${ut}`),K.current=!1;return}oe(void 0,void 0,Qe.workflowId,void 0,Qe.params,pe),P(),K.current=!1;return}if(Qe!=null&&Qe.commandId){Fe.fetchCommand(Qe.commandId).then(rt=>{if(rt){const pe=jT(rt.prompt),Ie={};for(const[ut,$t]of Object.entries(Qe.params)){const Ut=parseInt(ut,10),At=pe[Ut];At&&(Ie[At]=$t)}let it=rt.prompt;for(const[ut,$t]of Object.entries(Ie))it=it.replaceAll(`{{${ut}}}`,$t);O(it,rt.metadata.agentMode),P()}K.current=!1});return}}re(e,n),P(),K.current=!1},Ve=E.useCallback((ue,de)=>{const Ue=ue.type==="directory"?"/":" ",Qe=e.slice(0,de),rt=e.slice(M.current),pe=`${Qe}@${ue.path}${Ue}${rt}`;t(pe);const Ie=de+ue.path.length+2;M.current=Ie,V.current&&(V.current.selectionStart=Ie,V.current.selectionEnd=Ie,V.current.focus())},[e,t]),He=E.useCallback((ue,de)=>{const Fe=e.slice(0,de),Ue=e.slice(M.current),Qe=`${Fe}/${ue.id} ${Ue}`;t(Qe);const rt=de+ue.id.length+2;if(M.current=rt,V.current&&(V.current.selectionStart=rt,V.current.selectionEnd=rt,V.current.focus()),ue.type==="workflow"){se.current={id:ue.id,scope:ue.scope};const pe=il(Ft.getState()).find(Ie=>Ie.id===ue.id&&Ie.scope===ue.scope);ne(((pe==null?void 0:pe.parameters)??[]).map(Ie=>Ie.id))}else{const pe=ln.getState(),Ie=fr(fr(pe.defaults,pe.userItems),pe.projectItems).find(it=>it.id===ue.id);ne((Ie==null?void 0:Ie.paramNames)??[])}},[e,t]),ie=E.useCallback(ue=>{const de=ue.target.value;t(de),p&&w(),M.current=ue.target.selectionStart;const Fe=se.current;if(Fe){const Ue=de.match(/^\/(\S+)/),Qe=Ue?Ue[1]:void 0;(!Qe||Qe!==Fe.id)&&(se.current=null)}B.length>0&&(!de.startsWith("/")||!de.includes(" "))&&ne([]),!Y.current&&h&&de&&J&&(J.messageCount??0)===0&&(Y.current=!0,we(`/api/sessions/${h}/warmup`,{method:"POST"}).catch(()=>{}))},[t,p,w,h,J,B]),ye=E.useCallback(ue=>{M.current=ue.target.selectionStart},[]),Le=E.useCallback(ue=>{M.current=ue.currentTarget.selectionStart},[]);return s.jsxs("div",{className:"relative",children:[Q&&s.jsx("div",{className:"absolute -top-8 left-2 md:left-4 z-10",children:s.jsx(oV,{})}),s.jsxs("div",{className:`absolute -top-8 right-2 md:right-4 z-10 flex items-center gap-2 border${b?" border-transparent":" rounded backdrop-blur-xl saturate-150 border-border"}`,children:[s.jsx(Tb,{isActive:b,onToggle:v,className:"text-sm text-text-muted hover:text-text-primary flex items-center gap-1.5 px-2 py-0.5 rounded hover:bg-bg-tertiary transition-colors"}),s.jsxs("button",{type:"button",onClick:k,className:"text-sm text-text-muted hover:text-text-primary flex items-center gap-1.5 px-2 py-0.5 rounded hover:bg-bg-tertiary transition-colors","aria-label":"Browse history",children:[s.jsx(Xi,{}),"Browse history"]})]}),s.jsx(lV,{}),s.jsxs("form",{onSubmit:Se,className:"p-2 md:p-4 bg-secondary rounded-lg",children:[s.jsx("input",{ref:z,type:"file",accept:"image/*,text/*,.pdf,.json,.xml,.yaml,.yml,.js,.sh,.xhtml",onChange:ke,className:"hidden",multiple:!0}),u&&s.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&&s.jsx("div",{className:"mb-3 flex flex-wrap gap-2",children:n.map(ue=>s.jsx(bT,{attachment:ue,onRemove:me},ue.id))}),p&&s.jsx(aV,{history:m,selectedIndex:g,onSelect:ue=>{t(ue),w()},onEscape:w,onNavigate:ue=>{ue==="up"?C():_()}}),s.jsx(EV,{messages:I,onCancel:H}),s.jsxs("div",{className:`flex items-end gap-3 p-3 rounded transition-colors ${a?"bg-accent-primary/10":"bg-primary"}`,onDragOver:Ge,onDragLeave:Je,onDrop:Ce,children:[s.jsxs("div",{className:"relative flex-1 min-w-0",children:[s.jsx("textarea",{id:LN,ref:V,value:e,onChange:ie,onKeyDown:$e,onSelect:ye,onKeyUp:Le,placeholder:"What would you like to build?","data-testid":"chat-input-textarea",className:"w-full bg-transparent text-sm placeholder:text-text-muted resize-none overflow-y-auto focus:outline-none",style:{minHeight:"24px",maxHeight:"200px"},spellCheck:!1}),s.jsx(FV,{ref:U,text:e,cursorPos:M.current,workdir:$,onSelect:Ve}),s.jsx(VV,{ref:F,text:e,cursorPos:M.current,workflows:il(Ft.getState()),commands:(()=>{const ue=ln.getState();return fr(fr(ue.defaults,ue.userItems),ue.projectItems)})(),onSelect:He}),B.length>0&&(()=>{const ue=e.match(/\/(\w+)\s+(.*)$/),Fe=(ue?ue[2].trim().split(/\s+/):[]).filter(Boolean).length,Ue=B[Fe];return Ue?s.jsxs("span",{className:"absolute left-3 top-[26px] text-sm text-text-muted/40 pointer-events-none select-none","aria-hidden":!0,children:[Ue,"=?"]}):null})()]}),s.jsxs("div",{className:"flex items-center self-center gap-1.5",children:[Q&&s.jsxs("button",{type:"button",onClick:()=>X(),"data-testid":"chat-stop-button",className:"flex items-center gap-1 px-4 py-1.5 rounded bg-accent-error/20 text-sm text-accent-error font-medium hover:bg-accent-error/30 transition-colors whitespace-nowrap",children:[s.jsx(By,{}),"Abort"]}),s.jsxs("div",{className:"flex items-center",children:[s.jsx("button",{type:"button",onClick:he,disabled:!e.trim()&&n.length===0,"data-testid":"chat-send-button",className:"px-4 py-1.5 rounded-l bg-accent-primary/20 text-sm text-accent-primary font-medium hover:bg-accent-primary/30 disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:"Send"}),s.jsx(CV,{onSendCommand:O,onSelectWorkflow:R,onSelectWorkflowWithSubGroup:A,onOpenCommandsManager:T,onOpenWorkflowsManager:N,onAttach:We,textareaContent:e,attachments:n.length>0?n:void 0})]})]})]}),s.jsxs("div",{className:"mt-3 flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(OV,{}),s.jsx(IV,{})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[Lt(ue=>ue.settings)[je.FEATURES_PER_SESSION_MCP]==="true"&&s.jsx(zV,{}),s.jsx($V,{})]})]})]})]})}function uk({workflowName:e,parameters:t,onConfirm:n,onCancel:r,confirmLabel:a="Run workflow"}){const[l,u]=E.useState({}),c=[...t].sort((p,m)=>(p.position??0)-(m.position??0)),d=()=>{var m;const p={};for(const g of c){const y=(m=l[g.id])==null?void 0:m.trim();y&&(p[g.id]=y)}n(p)},h=c.every(p=>{var m;return!p.required||(((m=l[p.id])==null?void 0:m.trim())??"")!==""});return s.jsxs(jt,{isOpen:!0,onClose:r,title:`Run: ${e}`,size:"sm",closeOnEscape:!0,closeOnBackdropClick:!0,children:[s.jsx("div",{className:"space-y-3 py-2",children:c.map(p=>s.jsxs("label",{className:"block",children:[s.jsxs("span",{className:"text-sm text-text-primary font-medium",children:[p.label||p.id,p.required&&s.jsx("span",{className:"text-accent-error ml-1",children:"*"})]}),p.description&&s.jsx("span",{className:"block text-xs text-text-muted mt-0.5",children:p.description}),s.jsx("input",{value:l[p.id]??"",onChange:m=>u(g=>({...g,[p.id]:m.target.value})),placeholder:p.label||p.id,className:"mt-1 w-full px-3 py-1.5 bg-bg-tertiary border border-border rounded text-sm text-text-primary placeholder:text-text-muted focus:outline-none focus:ring-1 focus:ring-accent-primary",autoFocus:(p.position===0||p===c[0])&&Bt()})]},p.id))}),s.jsxs("div",{className:"flex justify-end gap-2 pt-3 border-t border-border",children:[s.jsx("button",{onClick:r,className:"px-3 py-1.5 text-sm text-text-muted hover:text-text-primary transition-colors",children:"Cancel"}),s.jsx("button",{onClick:d,disabled:!h,className:"px-4 py-1.5 text-sm font-medium rounded bg-accent-primary/20 text-accent-primary hover:bg-accent-primary/30 disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:a})]})]})}const dk=9999,uh=E.forwardRef(function({trigger:t,children:n},r){const[a,l]=E.useState(!1),u=E.useRef(null),c=E.useRef(null),d=E.useRef(null),h=E.useCallback(()=>{l(!1)},[]);E.useImperativeHandle(r,()=>({close:h}),[h]);const p=E.useCallback(m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),a?h():(d.current=document.activeElement,l(!0))),m.key==="Escape"&&a&&h()},[a,h]);return E.useEffect(()=>{var w;if(!a){Bt()&&((w=d.current)==null||w.focus()),d.current=null;return}const m=C=>{c.current&&!c.current.contains(C.target)&&u.current&&!u.current.contains(C.target)&&h()},g=C=>{C.key==="Escape"&&h()},y=()=>h();return document.addEventListener("mousedown",m),document.addEventListener("keydown",g),window.addEventListener("blur",y),()=>{document.removeEventListener("mousedown",m),document.removeEventListener("keydown",g),window.removeEventListener("blur",y)}},[a,h]),s.jsxs(s.Fragment,{children:[s.jsx("span",{ref:u,role:"button",tabIndex:0,"aria-expanded":a,className:"inline-flex cursor-pointer text-text-muted hover:text-text-primary transition-colors outline-none focus-visible:ring-1 focus-visible:ring-accent-primary/50 rounded",onClick:()=>{a||(d.current=document.activeElement),l(m=>!m)},onKeyDown:p,children:t}),a&&ui.createPortal(s.jsx("div",{ref:c,role:"dialog","aria-modal":"true",className:"fixed bg-bg-secondary border border-border rounded-lg shadow-xl p-3 w-[320px] max-w-[calc(100vw-16px)] max-h-[60vh]",style:(()=>{if(!u.current)return{zIndex:dk,top:0,left:0};const m=u.current.getBoundingClientRect(),g=320,y=8;let w=m.left;return w+g>window.innerWidth-y&&(w=m.right-g),w=Math.max(y,Math.min(w,window.innerWidth-g-y)),{zIndex:dk,top:m.bottom+4,left:w}})(),children:s.jsx(ct,{className:"max-h-full",children:n})}),document.body)]})});function GV({entries:e}){const t=new Map;for(const r of e)t.set(r.status,(t.get(r.status)??0)+1);const n=qN.filter(r=>(t.get(r)??0)>0);return n.length===0?s.jsx("span",{className:"text-text-muted text-sm",children:"None"}):s.jsx("span",{className:"flex items-center gap-1.5 text-sm",children:n.map(r=>s.jsxs("span",{className:"flex items-center gap-0.5",children:[s.jsx(wl,{status:r}),s.jsx("span",{className:"text-text-muted",children:t.get(r)})]},r))})}function qV({visible:e}){const t=De(B=>B.currentSession),n=Yn(B=>B.status),r=Yn(B=>B.config),a=Yn(B=>B.start),l=De(B=>B.contextState),u=De(B=>B.queueUpdate),c=Yn(B=>B.logs),{branch:d,diff:h}=jb(),[p,m]=E.useState(!1),[g,y]=E.useState(!1),[w,C]=E.useState(!1),[_,S]=E.useState(null),[b,v]=E.useState(!1),[k,T]=E.useState(!1),N=E.useRef(null),R=E.useRef(null),A=E.useRef(null),O=E.useRef(null),P=Lt(B=>B.settings[je.DISPLAY_SHOW_OPEN_IN_EDITOR])==="true";if(!e||!t)return null;const V=hu(t.workspace??"")||"original",z=t.workspace??t.workdir,W=t.metadataEntries??{},M=W.criteria??[],U=["review_findings","todos"],F=U.filter(B=>{var ne;return B in W&&(((ne=W[B])==null?void 0:ne.length)??0)>0}),Q=Object.keys(W).filter(B=>B!=="criteria"&&!U.includes(B)).filter(B=>{var ne;return(((ne=W[B])==null?void 0:ne.length)??0)>0}),X=[...F,...Q].reduce((B,ne)=>{var se;return B+(((se=W[ne])==null?void 0:se.length)??0)},0),H=[...F,...Q].map(sl),I=h.files,D=I.reduce((B,ne)=>B+ne.additions,0),q=I.reduce((B,ne)=>B+ne.deletions,0),$=(n==null?void 0:n.state)??"off",J=$==="running"||$==="warning",Y=r!==null,Z=B=>{B.stopPropagation(),a()},K=B=>{B.stopPropagation(),n!=null&&n.url&&window.open(n.url,"_blank")};return s.jsxs("div",{className:"flex-shrink-0 px-4 py-1.5 border-b border-border bg-secondary",children:[s.jsxs("div",{className:"grid grid-cols-2 sm:flex sm:items-center sm:justify-between gap-x-2 gap-y-1 text-sm",children:[s.jsxs("div",{className:"flex items-center gap-1 min-w-0 sm:shrink-0",children:[s.jsx(Qr,{className:"w-3.5 h-3.5 text-text-muted flex-shrink-0"}),s.jsx("span",{className:"truncate text-text-secondary max-w-[120px]",children:V}),s.jsx("span",{className:"text-text-muted",children:"/"}),s.jsx(Fa,{className:"w-3.5 h-3.5 text-text-muted flex-shrink-0"}),s.jsx("span",{className:"truncate text-text-secondary max-w-[120px]",children:d??"-"}),I.length>0?s.jsxs("span",{className:"text-text-muted shrink-0 font-mono",children:["+",D," -",q]}):s.jsx("span",{className:"shrink-0"}),s.jsx(uh,{ref:O,trigger:s.jsx(vn,{className:"w-3 h-3"}),children:s.jsx(cT,{workspaceName:V,branch:d,workdir:z,showEditorLink:P,sessionId:t.id,projectId:t.projectId,onEditWorkspace:()=>{var B;(B=O.current)==null||B.close(),v(!0)},onEditBranch:()=>{var B;(B=O.current)==null||B.close(),T(!0)}})})]}),s.jsx("div",{className:"hidden sm:block w-px bg-border self-stretch mx-1"}),s.jsxs("div",{className:"flex-1 flex items-center sm:justify-center justify-self-end gap-1 min-w-0",children:[s.jsx(GV,{entries:M}),X>0&&s.jsxs("span",{className:"text-text-muted text-xs bg-bg-tertiary px-1 py-0.5 rounded leading-none",title:H.join(", "),children:["+",X]}),s.jsx(uh,{ref:A,trigger:s.jsx(vn,{className:"w-3 h-3"}),children:s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("button",{onClick:()=>{var B;(B=A.current)==null||B.close(),S("criteria")},className:"w-full text-left cursor-pointer hover:[&_h3]:text-accent-primary transition-colors",children:s.jsx(Xh,{entries:M,title:"Acceptance Criteria"})}),s.jsx(XN,{entries:M,sessionId:t.id})]}),[...F,...Q].map(B=>{const ne=W[B];return s.jsxs("div",{children:[s.jsx("button",{onClick:()=>{var se;(se=A.current)==null||se.close(),S(B)},className:"w-full text-left cursor-pointer hover:[&_h3]:text-accent-primary transition-colors",children:s.jsx(Xh,{entries:ne,title:sl(B)})}),s.jsx(KN,{entries:ne})]},B)})]})})]}),s.jsx("div",{className:"hidden sm:block w-px bg-border self-stretch mx-1"}),s.jsx("div",{className:"col-span-2 border-t border-border sm:hidden -mx-4"}),s.jsx("div",{className:"flex items-center gap-1.5 min-w-0 shrink-0",children:l&&s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"text-text-muted text-xs font-mono tabular-nums",children:l.currentTokens>=1e3?`${Math.round(l.currentTokens/1e3)}K`:l.currentTokens}),s.jsx(Lb,{percent:Math.round(l.currentTokens/l.maxTokens*100),dangerZone:l.dangerZone,size:"sm"}),s.jsx(uh,{ref:R,trigger:s.jsx(vn,{className:"w-3 h-3"}),children:s.jsx(dT,{onUpdateSystemPrompt:()=>{var B;(B=R.current)==null||B.close(),C(!0)}})})]})}),s.jsx("div",{className:"hidden sm:block w-px bg-border self-stretch mx-1"}),s.jsxs("div",{className:"flex items-center gap-1.5 min-w-0 shrink-0 justify-self-end",children:[s.jsx("span",{className:`inline-block w-2 h-2 rounded-full flex-shrink-0 ${$==="running"?"bg-accent-success":$==="warning"?"bg-accent-warning":$==="error"?"bg-accent-error":"bg-text-muted"}`}),Y?J?s.jsx("button",{onClick:K,className:"flex items-center justify-center p-1 rounded text-sm font-medium bg-accent-primary/25 text-text-primary hover:bg-accent-primary/40 transition-colors leading-none",title:"Open dev server",children:s.jsx(NE,{className:"w-3.5 h-3.5"})}):s.jsx("button",{onClick:Z,className:"flex items-center justify-center p-1 rounded text-sm font-medium bg-accent-primary/25 text-text-primary hover:bg-accent-primary/40 transition-colors leading-none",title:"Start dev server",children:s.jsx(TE,{className:"w-3.5 h-3.5"})}):s.jsx("span",{className:"text-text-muted text-xs",children:"No config"}),s.jsx(uh,{ref:N,trigger:s.jsx(vn,{className:"w-3 h-3"}),children:s.jsx(eT,{workdir:z,compact:!0,onExpand:()=>m(!0),onConfigure:()=>{var B;(B=N.current)==null||B.close(),y(!0)}})})]})]}),p&&s.jsx(Ab,{title:"Dev Server Logs",logs:c,onClose:()=>m(!1)}),g&&s.jsx(QN,{isOpen:!0,onClose:()=>y(!1)}),_&&t&&s.jsx(YN,{isOpen:!0,onClose:()=>S(null),entries:W[_]??[],sessionId:t.id,metadataKey:_,title:sl(_)}),b&&s.jsx(oT,{isOpen:!0,onClose:()=>v(!1),projectId:t.projectId,sessionId:t.id,currentWorkspace:V,currentBranch:d}),k&&s.jsx(lT,{isOpen:!0,onClose:()=>T(!1),sessionId:t.id}),w&&l&&s.jsx(Rb,{isOpen:!0,onClose:()=>C(!1),isRunning:t.isRunning,onApply:()=>{t.isRunning?u():Pt.send("context.applyDynamic",{}),C(!1)}})]})}function KV(e){return(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()==="f"&&document.querySelector("[data-global-settings]")===null}function MT(e,t=[]){const n=new Map,r=new Map;for(const h of t)h.type==="message"?n.set(h.message.id,h):h.type==="subagent"&&r.set(h.subAgentId,h);const a=[];let l,u=1,c=null;const d=()=>{if(!c||c.size===0)return;const h=new Map;let p=0;for(const g of e)g.role!=="tool"&&g.contextWindowId===l&&(g.subAgentId&&!h.has(g.subAgentId)&&h.set(g.subAgentId,p),p++);const m=[...c.entries()].sort((g,y)=>(h.get(g[0])??0)-(h.get(y[0])??0));for(const[g,y]of m){const w=r.get(g);(w==null?void 0:w.type)==="subagent"&&w.messages.length===y.messages.length&&w.messages.every((_,S)=>_===y.messages[S])?a.push(w):a.push({type:"subagent",subAgentId:g,subAgentType:y.subAgentType,messages:y.messages})}c=null};for(let h=0;h<e.length;h++){const p=e[h];if(p.role!=="tool")if(p.contextWindowId&&l&&p.contextWindowId!==l&&(d(),u++,a.push({type:"context-divider",windowSequence:u})),l=p.contextWindowId,p.subAgentId&&p.subAgentType){c||(c=new Map);let m=c.get(p.subAgentId);m||(m={subAgentType:p.subAgentType,messages:[]},c.set(p.subAgentId,m)),m.messages.push(p)}else{d();const m=n.get(p.id);(m==null?void 0:m.type)==="message"&&m.message===p?a.push(m):a.push({type:"message",message:p})}}return d(),a}const YV=10,XV=150;function QV(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 JV(e){return[...e].sort((r,a)=>new Date(a.timestamp).getTime()-new Date(r.timestamp).getTime()).slice(0,YV).reverse().map(r=>({id:r.id,content:r.content,timestamp:r.timestamp,formattedTimestamp:XF(r.timestamp),trimmedContent:Kh(r.content,XV),sessionId:r.sessionId,sessionName:r.sessionName}))}function ZV(e,t,n){const r=[],a=e.filter(l=>l.role==="user"&&!l.isSystemGenerated&&l.messageKind!=="auto-prompt");for(const l of a)r.push({id:l.id,content:l.content,timestamp:l.timestamp,sessionId:n??"",sessionName:"This session"});for(const l of t)n&&l.id===n||r.push(...QV(l));return JV(r)}function eW(e,t=[],n=null){const[r,a]=E.useState(0),[l,u]=E.useState(!1),c=E.useMemo(()=>ZV(e,t,n),[e,t,n]),d=E.useCallback(()=>{c.length>0&&(a(c.length-1),u(!0))},[c.length]),h=E.useCallback(()=>{u(!1),a(0)},[]),p=E.useCallback(()=>{a(y=>c.length===0?y:y===0?c.length-1:y-1)},[c.length]),m=E.useCallback(()=>{a(y=>c.length===0?y:y===c.length-1?0:y+1)},[c.length]),g=E.useCallback(()=>{if(c.length===0||!l)return null;const y=c[r];return(y==null?void 0:y.content)??null},[c,r,l]);return{history:c,selectedIndex:r,showHistory:l,openHistory:d,closeHistory:h,navigateUp:p,navigateDown:m,selectCurrent:g}}E.memo(function({item:t}){const[n,r]=E.useState(!1);return t.type==="start"?s.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-amber-500/10 border border-amber-500/30 rounded text-amber-300 text-sm",children:[s.jsx("span",{className:"animate-pulse",children:"●"}),s.jsx("span",{children:"Delegating image to fallback vision model..."}),t.filename&&s.jsxs("span",{className:"text-amber-400/70",children:["(",t.filename,")"]})]}):s.jsxs("div",{className:"flex items-start gap-2 px-3 py-2 bg-accent-success/10 border border-accent-success/30 rounded",children:[s.jsx("span",{className:"text-accent-success",children:"✓"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center justify-between gap-2",children:[s.jsx("span",{className:"text-accent-success text-sm",children:"Image description done"}),s.jsx("button",{type:"button",onClick:()=>r(!n),className:"text-xs text-accent-primary hover:text-accent-primary/80 transition-colors",children:n?"Hide":"Show"})]}),n&&t.description&&s.jsx("div",{className:"mt-2 text-xs prose prose-invert prose-sm max-w-none",children:s.jsx(sr,{content:t.description})})]})]})});function tW({criteriaSidebarOpen:e,onCriteriaSidebarToggle:t,rawMessages:n,hiddenCount:r}={}){const a=e??!0,[l,u]=E.useState(""),[c,d]=E.useState([]),[h,p]=E.useState(!1),[m,g]=E.useState(null),[y,w]=E.useState(!1),[C,_]=E.useState(!1),[S,b]=E.useState(!1),[v,k]=E.useState(!1),[T,N]=E.useState(null),R=E.useRef(null),A=Su(R),O=De(de=>de.currentSession),P=De(de=>de.messages),V=De(de=>de.hiddenCount),z=De(de=>de.sessions),W=gf(),M=De(de=>de.stopGeneration),U=n??P,{maxVisibleItems:F}=As(),Q=ft(de=>de.defaults),X=ft(de=>de.userItems),H=[...Q,...X].filter(de=>!de.subagent),{history:I,selectedIndex:D,showHistory:q,openHistory:$,closeHistory:J,navigateUp:Y,navigateDown:Z,selectCurrent:K}=eW(U,z,O==null?void 0:O.id);E.useEffect(()=>{const de=Fe=>{N(Fe.detail.stats)};return window.addEventListener("open-turn-stats",de),()=>window.removeEventListener("open-turn-stats",de)},[]);const B=O==null?void 0:O.workdir;E.useEffect(()=>{Ft.getState().setWorkdir(B),B&&Ft.getState().fetchWorkflows()},[B]),E.useEffect(()=>{Ft.getState().fetchWorkflows()},[]),E.useEffect(()=>{const de=Fe=>{KV(Fe)&&(Fe.preventDefault(),k(!0))};return window.addEventListener("keydown",de),()=>window.removeEventListener("keydown",de)},[]);const ne=E.useRef([]),{displayItems:se,hiddenCount:re}=E.useMemo(()=>{const de=MT(U,ne.current);return ne.current=de,F>0&&de.length>F?{displayItems:de.slice(-F),hiddenCount:de.length-F}:{displayItems:de,hiddenCount:0}},[U,F]),oe=r??V??re,{isAutoScrollActive:ve,setAutoScroll:Se,handleScrollbarGesture:$e}=_u(R,O,A),{sendMessage:ze,launchWorkflow:ke}=TT(Se);E.useEffect(()=>{const de=()=>Se(!0);return window.addEventListener(tf,de),()=>window.removeEventListener(tf,de)},[Se]);const[Ge,Je]=E.useState(null),[Ce,me]=E.useState(null),We=E.useCallback((de,Fe,Ue,Qe="auto")=>{const rt=il(Ft.getState()),pe=dy(rt,de,Qe);((pe==null?void 0:pe.parameters)??[]).filter(it=>it.position!==void 0||it.required).length>0?Je({id:de,name:(pe==null?void 0:pe.name)??de,subGroup:Fe,scope:Qe}):ke(void 0,void 0,de,Fe,Ue,Qe)},[ke]),he=E.useCallback((de,Fe,Ue,Qe)=>{We(de,Fe,Ue,Qe)},[We]),Ve=E.useCallback(de=>{Se(!1);const Fe=document.querySelector(`[data-item-index="${de}"]`);Fe&&(Fe.hasAttribute("data-placeholder")?(window.dispatchEvent(new CustomEvent(hy,{detail:{index:de}})),requestAnimationFrame(()=>requestAnimationFrame(()=>{var Ue;(Ue=document.querySelector(`[data-item-index="${de}"]`))==null||Ue.scrollIntoView({behavior:"smooth",block:"center"})}))):Fe.scrollIntoView({behavior:"smooth",block:"center"}))},[Se]);E.useEffect(()=>{const de=Fe=>{const Ue=S||y||C||v||T;Fe.key==="Escape"&&W&&!Ue&&M(),Fe.key==="ScrollLock"&&Se(!ve)};return window.addEventListener("keydown",de),()=>window.removeEventListener("keydown",de)},[W,M,ve,S,y,C,v,T]);const He=uu();Qc(He.quickAction,()=>{b(!0)}),Qc(He.criteriaSidebar,()=>{t==null||t()}),q3(He.agentSwitching,H,de=>{De.getState().switchMode(de)});const ie=(de,Fe)=>{We(de,void 0,void 0,Fe),Le()},ye=(de,Fe,Ue)=>{We(de,Fe,void 0,Ue),Le()},Le=()=>{u(""),d([]),O!=null&&O.id&&localStorage.removeItem(`openfox:draft:${O.id}`)},ue=E.useCallback(async(de,Fe,Ue,Qe)=>{const rt=jT(de);if(rt.length>0)me({prompt:de,paramKeys:rt,agentMode:Fe,textareaContent:Ue,attachments:Qe});else{Fe&&(O==null?void 0:O.mode)!==Fe&&await De.getState().switchMode(Fe);const pe=Ue&&Ue.trim()?`${Ue.trim()}
320
+
321
+ ${de}`:de;ze(pe,Qe!=null&&Qe.length?Qe:void 0,{messageKind:"command",isSystemGenerated:!0}),Le()}},[ze,Le,O]);return s.jsxs(s.Fragment,{children:[s.jsxs(x9,{criteriaSidebarOpen:a,onCriteriaSidebarToggle:t,messages:U,children:[s.jsx(qV,{visible:!a}),s.jsx(y9,{}),T&&s.jsx(b9,{stats:T,onClose:()=>N(null)}),s.jsx(OU,{}),s.jsx(RU,{displayItems:se,scrollContainerRef:R,highlightedMessageId:null,onLaunchWorkflow:he,onScrollToTop:()=>Se(!1),hiddenCount:oe,onScrollbarGesture:$e}),s.jsx(WV,{input:l,setInput:u,attachments:c,setAttachments:d,dragOver:h,setDragOver:p,errorMessage:m,setErrorMessage:g,scrollToBottom:()=>{var de,Fe;return(Fe=A())==null?void 0:Fe.scrollTo({top:((de=A())==null?void 0:de.scrollHeight)??0,behavior:"smooth"})},sessionId:O==null?void 0:O.id,showHistory:q,history:I,selectedIndex:D,openHistory:$,closeHistory:J,navigateUp:Y,navigateDown:Z,selectCurrent:K,isAutoScrollActive:ve,setAutoScroll:Se,onOpenMessageSearch:()=>k(!0),onOpenCommandsModal:()=>w(!0),onOpenWorkflowsModal:()=>_(!0),onSelectWorkflow:ie,onSelectWorkflowWithSubGroup:ye,onSendCommand:ue,clearInput:Le}),s.jsx(ST,{isOpen:y,onClose:()=>w(!1)}),s.jsx(kT,{isOpen:C,onClose:()=>_(!1),projectDir:O==null?void 0:O.workdir}),s.jsx(YU,{isOpen:S,onClose:()=>b(!1),onSearchMessages:()=>k(!0),isAutoScrollActive:ve,onToggleAutoScroll:Se,textareaContent:l,onCloseComplete:ou,onCloseCompleteAction:()=>window.dispatchEvent(new CustomEvent("open-session-dropdown")),onSelectCommand:async(de,Fe)=>{const Ue=await ln.getState().fetchCommand(de);Ue&&ue(Ue.prompt,Ue.metadata.agentMode,Fe)},onSelectWorkflow:(de,Fe)=>{We(de,void 0,void 0,Fe),Le()}}),Ge&&s.jsx(uk,{workflowName:Ge.name,parameters:(()=>{var Fe;const de=il(Ft.getState());return((Fe=dy(de,Ge.id,Ge.scope))==null?void 0:Fe.parameters)??[]})(),onConfirm:de=>{ke(void 0,void 0,Ge.id,Ge.subGroup,de,Ge.scope),Je(null)},onCancel:()=>Je(null)}),Ce&&s.jsx(uk,{workflowName:"Command",confirmLabel:"Launch command",parameters:Ce.paramKeys.map((de,Fe)=>({id:de,label:de,position:Fe})),onConfirm:de=>{let Fe=Ce.prompt;for(const[Ie,it]of Object.entries(de))Fe=Fe.replaceAll(`{{${Ie}}}`,it);const{agentMode:Ue,textareaContent:Qe,attachments:rt}=Ce;Ue&&(O==null?void 0:O.mode)!==Ue&&De.getState().switchMode(Ue);const pe=Qe&&Qe.trim()?`${Qe.trim()}
322
+
323
+ ${Fe}`:Fe;ze(pe,rt!=null&&rt.length?rt:void 0,{messageKind:"command",isSystemGenerated:!0}),Le(),me(null)},onCancel:()=>me(null)})]}),v&&s.jsx(sV,{isOpen:v,onClose:()=>{k(!1),ou(!0)},displayItems:se,onNavigate:Ve})]})}function nW(){var v;const[,e]=ml("/p/:projectId/s/:sessionId/readonly"),t=e==null?void 0:e.sessionId,[n,r]=E.useState(null),[a,l]=E.useState([]),[u,c]=E.useState(0),[d,h]=E.useState(!0),[p,m]=E.useState(null),g=async()=>{if(t){h(!0),m(null);try{const k=await we(`/api/sessions/${t}?full=true`);if(!k.ok){m(`Failed to load session (${k.status})`),h(!1);return}const T=await k.json();r(T.session??null),l(T.messages??[]),c(T.hiddenCount??0)}catch(k){m(k instanceof Error?k.message:"Unknown error")}finally{h(!1)}}};E.useEffect(()=>{Lt.getState().getSettings([...Oy])},[]),E.useEffect(()=>{g()},[t]);const{showThinking:y,showVerboseToolOutput:w,showStats:C,showAgentDefinitions:_,showWorkflowBars:S}=As(),b=E.useMemo(()=>MT(a),[a]);return d?s.jsx("div",{className:"h-screen flex items-center justify-center bg-primary",children:s.jsx(Zi,{})}):p?s.jsx("div",{className:"h-screen flex items-center justify-center bg-primary",children:s.jsxs("div",{className:"text-center space-y-4",children:[s.jsx("div",{className:"text-red-400 text-sm",children:p}),s.jsx("button",{onClick:g,className:"px-3 py-1.5 text-sm bg-bg-tertiary text-text-primary border border-border rounded hover:bg-bg-tertiary/80 transition-colors",children:"Retry"})]})}):s.jsxs("div",{className:"h-screen print:h-auto flex flex-col bg-primary",children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-border bg-secondary shrink-0 print:hidden",children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[s.jsxs("h1",{className:"text-sm font-medium text-text-primary truncate",children:[((v=n==null?void 0:n.metadata)==null?void 0:v.title)??"Session"," — Read-only view"]}),s.jsxs("span",{className:"text-xs text-text-muted whitespace-nowrap",children:[a.length," messages",u>0?` (${u} older hidden)`:""]})]}),s.jsx("div",{className:"flex items-center gap-2",children:s.jsx("button",{onClick:g,disabled:d,className:"px-3 py-1 text-xs bg-bg-tertiary text-text-primary border border-border rounded hover:bg-bg-tertiary/80 transition-colors disabled:opacity-50",children:d?"Refreshing...":"Refresh"})})]}),s.jsxs(ct,{className:"flex-1 print:overflow-visible",children:[s.jsx("div",{className:"pt-4",children:s.jsx(_T,{displayItems:b,showThinking:y,showVerboseToolOutput:w,showStats:C,showAgentDefinitions:_,showWorkflowBars:S})}),s.jsx("div",{className:"h-8"})]})]})}function hk({isOpen:e,isRetry:t,onSubmit:n,onCancel:r}){const[a,l]=E.useState(""),u=E.useRef(null);E.useEffect(()=>{e&&(l(""),setTimeout(()=>{var d;Bt()&&((d=u.current)==null||d.focus())},100))},[e]);const c=d=>{d.preventDefault(),a.trim()&&n(a)};return s.jsx(jt,{isOpen:e,onClose:r,title:t?"Invalid Password":"Password Required",size:"sm",children:s.jsxs("form",{onSubmit:c,className:"space-y-4",children:[s.jsx("p",{className:"text-text-secondary text-sm",children:t?"The password you entered was incorrect. Please try again.":"This server requires a password to connect."}),s.jsx(Gi,{ref:u,type:"password",value:a,onChange:d=>l(d.target.value),placeholder:"Enter password",autoFocus:Bt()}),s.jsxs("div",{className:"flex justify-end gap-2",children:[s.jsx(dt,{type:"button",variant:"secondary",onClick:r,children:"Cancel"}),s.jsx(dt,{type:"submit",disabled:!a.trim(),children:t?"Try Again":"Connect"})]})]})})}function rW({currentStep:e,totalSteps:t,labels:n,onStepClick:r}){return s.jsx("div",{className:"flex justify-center py-6",children:s.jsx("div",{className:"flex items-center",children:Array.from({length:t},(a,l)=>{const u=l+1,c=u<e,d=u===e;return s.jsxs("div",{className:"flex items-center",children:[s.jsx("button",{onClick:()=>r==null?void 0:r(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}),s.jsx("button",{onClick:()=>r==null?void 0:r(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&&s.jsx("div",{className:`w-12 sm:w-20 h-0.5 mr-4 ${c?"bg-accent-primary":"bg-border"}`})]},l)})})})}function sW({onNext:e}){const[t,n]=E.useState([]),[r,a]=E.useState([]),[l,u]=E.useState(!1),[c,d]=E.useState(null),[h,p]=E.useState(null),[m,g]=E.useState(null);E.useEffect(()=>{y()},[]);async function y(){try{const T=await we("/api/providers");if(T.ok){const R=(await T.json()).providers.map(A=>({id:A.id,name:A.name,url:A.url,backend:A.backend,model:null,apiKey:A.apiKey,isLocal:A.isLocal,thinkingField:A.thinkingField,sendReasoningInMessages:A.sendReasoningInMessages,models:A.models}));n(R),a(R)}}catch{}}async function w(T){const N=T.id.startsWith("temp-"),R=r.some(P=>P.id===T.id),A=r.length===0&&c===null,O=OT(T);try{let P;if(N){const z=await we("/api/providers",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(O)});if(!z.ok)throw new Error("Failed to create provider");const W=await z.json();P={...T,id:W.provider.id,model:null}}else{if(!(await we(`/api/providers/${T.id}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(O)})).ok)throw new Error("Failed to update provider");P={...T,model:null}}const V=z=>z.some(W=>W.id===P.id)?z.map(W=>W.id===P.id?P:W):[...z,P];a(V),n(V),A&&!R&&e({providers:[P]})}catch{if(N){const P={...T,model:null};a(V=>[...V,P])}}}function C(){d(null),u(!0)}function _(T){d(T),u(!0)}function S(){u(!1),d(null)}function b(T){p(T),t.some(R=>R.id===T)?we(`/api/providers/${T}`,{method:"DELETE"}).then(()=>{a(r.filter(R=>R.id!==T)),n(t.filter(R=>R.id!==T)),p(null)}).catch(()=>p(null)):(a(r.filter(R=>R.id!==T)),p(null))}function v(){const T=r.filter(N=>!N.id.startsWith("temp-"));e({providers:T})}const k=r.length>0;return s.jsxs("div",{className:"max-w-xl mx-auto",children:[s.jsx("h2",{className:"text-2xl font-bold text-text-primary mb-2",children:"LLM Providers"}),s.jsx("p",{className:"text-text-secondary mb-8",children:"Manage your LLM server connections"}),s.jsxs("div",{className:"space-y-4",children:[r.length>0?s.jsx("div",{className:"space-y-2",children:r.map(T=>s.jsxs("div",{className:"flex items-center justify-between bg-bg-secondary rounded-lg p-4 border border-border",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"px-2 py-0.5 bg-accent-primary/25 text-accent-primary rounded text-xs font-medium",children:pE(T.backend)}),s.jsx("span",{className:"text-text-primary font-medium",children:T.name}),s.jsx("span",{className:`text-xs px-1.5 py-0.5 rounded-full ${T.isLocal?"text-accent-success bg-accent-success/10":"text-accent-warning bg-accent-warning/10"}`,children:T.isLocal?"local":"api"})]}),s.jsx("p",{className:"text-text-muted text-sm mt-1 truncate",children:T.url}),T.model&&s.jsxs("p",{className:"text-text-secondary text-xs mt-0.5",children:["Model: ",T.model]})]}),s.jsx("div",{className:"flex items-center gap-1",children:m===T.id?s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{onClick:()=>b(T.id),disabled:h===T.id,className:"px-2 py-1 text-xs text-red-500 hover:text-red-400 bg-red-500/10 rounded transition-colors disabled:opacity-50",children:h===T.id?"Deleting...":"Confirm"}),s.jsx("button",{onClick:()=>g(null),className:"px-2 py-1 text-xs text-text-muted hover:text-text-secondary transition-colors",children:"Cancel"})]}):s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:()=>_(T),className:"px-2 py-1 text-xs text-text-muted hover:text-text-secondary border border-border rounded transition-colors",children:"Edit"}),s.jsx("button",{onClick:()=>g(T.id),className:"p-2 text-text-muted hover:text-red-500 transition-colors",title:"Remove provider",children:s.jsx(Ya,{})})]})})]},T.id))}):s.jsx("div",{className:"bg-bg-secondary rounded-lg p-8 text-center border border-border",children:s.jsx("p",{className:"text-text-muted",children:"No providers configured yet"})}),s.jsxs("button",{onClick:C,"data-testid":"onboarding-add-provider-button",className:"w-full flex items-center justify-center gap-2 px-4 py-3 bg-bg-secondary border border-dashed border-border rounded-lg text-text-secondary hover:text-text-primary hover:border-text-muted transition-colors",children:[s.jsx(Ns,{className:"w-4 h-4"}),"Add Provider"]}),s.jsx("button",{onClick:v,disabled:!k,"data-testid":"onboarding-continue-button",className:"w-full mt-6 px-6 py-3 bg-accent-primary text-text-primary rounded-lg font-medium hover:bg-accent-primary/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:"Continue"})]}),s.jsx(IT,{isOpen:l,onClose:S,onSave:w,initialStep:1,editProvider:c??void 0})]})}function iW({onNext:e}){const[t,n]=E.useState(""),[r,a]=E.useState(!1);return E.useEffect(()=>{we("/api/config").then(l=>l.json()).then(l=>{l.workdir?n(l.workdir):fetch(hs("/api/directories?path=")+encodeURIComponent("/home")).then(u=>u.json()).then(u=>{u.current&&n(u.current)}).catch(()=>{})}).catch(()=>{fetch(hs("/api/directories?path=")+encodeURIComponent("/home")).then(l=>l.json()).then(l=>{l.current&&n(l.current)}).catch(()=>{})})},[]),s.jsxs("div",{className:"max-w-xl mx-auto",children:[s.jsx("h2",{className:"text-2xl font-bold text-text-primary mb-2",children:"Your Projects Folder"}),s.jsx("p",{className:"text-text-secondary mb-8",children:"Where should OpenFox create project folders?"}),s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Workspace directory"}),s.jsxs("div",{className:"flex gap-2",children:[s.jsx("input",{type:"text",value:t,onChange: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"}),s.jsx("button",{onClick:()=>a(!0),className:"px-4 py-2 bg-bg-secondary border border-border rounded-lg hover:border-text-muted",children:"Browse"})]})]}),r&&s.jsx(_f,{initialPath:t||void 0,onSelect:l=>{n(l),a(!1)},onClose:()=>a(!1)}),s.jsx("button",{onClick:()=>e({workdir:t}),disabled:!t,"data-testid":"onboarding-workdir-continue-button",className:"w-full mt-6 px-6 py-3 bg-accent-primary text-text-primary rounded-lg font-medium hover:bg-accent-primary/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:"Continue"})]})]})}function aW(e){var t;return((t=e.split("/").pop())==null?void 0:t.replace(/-/g," "))??e}function oW(e){return E.useMemo(()=>{const t=[];for(const n of e)for(const r of n.models)r.supportsVision&&t.push({providerId:n.id,providerName:n.name,modelId:r.id,modelName:r.name??aW(r.id)});return t},[e])}function lW({value:e,options:t,onChange:n,className:r}){return s.jsxs("select",{value:e,onChange:a=>n(a.target.value),className:r??"w-full px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary focus:outline-none focus:border-accent-primary",children:[s.jsx("option",{value:"",children:"Manual configuration..."}),t.map(a=>s.jsxs("option",{value:`${a.providerId}/${a.modelId}`,children:[a.providerName," • ",a.modelName]},`${a.providerId}/${a.modelId}`))]})}function cW({backend:e,url:t,model:n,apiKey:r,onBackendChange:a,onUrlChange:l,onModelChange:u,onApiKeyChange:c}){return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Backend type"}),s.jsxs("select",{value:e,onChange:d=>a(d.target.value),className:"w-full px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary focus:outline-none focus:border-accent-primary",children:[s.jsx("option",{value:"ollama",children:"Ollama"}),s.jsx("option",{value:"openai",children:"OpenAI-compatible (vLLM, sglang, llama.cpp)"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Vision server URL"}),s.jsx("input",{type:"text",value:t,onChange:d=>l(d.target.value),placeholder:e==="ollama"?"http://localhost:11434":"http://localhost:8000/v1",className:"w-full px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Vision model name"}),s.jsx("input",{type:"text",value:n,onChange:d=>u(d.target.value),placeholder:e==="ollama"?"qwen3.5:0.8b":"qwen3.5-27b",className:"w-full px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"})]}),e==="openai"&&s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"API key (optional)"}),s.jsx("input",{type:"password",value:r,onChange:d=>c(d.target.value),placeholder:"Leave empty for a local server that needs no auth",className:"w-full px-4 py-2 bg-bg-secondary border border-border rounded-lg text-text-primary placeholder-text-muted focus:outline-none focus:border-accent-primary"})]})]})}function uW(e,t,n,r){return a=>{e(a),t(""),a==="ollama"?(n("http://localhost:11434"),r("qwen3.5:0.8b")):(n("http://localhost:8000/v1"),r("qwen3.5-27b"))}}function dW(e,t,n){return r=>{e(r),r&&(t(""),n(""))}}function hW({enabled:e,hasOptions:t,selectedRef:n,visionModelOptions:r,onProviderModelSelect:a,noOptionsMessage:l,children:u,...c}){return e?s.jsxs("div",{className:"space-y-4 pl-8",children:[t?s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm text-text-secondary mb-1",children:"Vision model from your providers"}),s.jsx(lW,{value:n,options:r,onChange:a})]}):s.jsx("p",{className:"text-sm text-text-muted italic",children:l}),s.jsx(cW,{...c}),u]}):null}function fW({onNext:e}){const[t,n]=E.useState(!1),[r,a]=E.useState("http://localhost:11434"),[l,u]=E.useState("qwen3.5:0.8b"),[c,d]=E.useState(""),[h,p]=E.useState("ollama"),[m,g]=E.useState([]),[y,w]=E.useState(""),{copied:C,copy:_}=CN();E.useEffect(()=>{we("/api/config").then(R=>R.json()).then(R=>{R.visionFallback&&(n(R.visionFallback.enabled),R.visionFallback.providerModelRef?w(R.visionFallback.providerModelRef):(a(R.visionFallback.url??"http://localhost:11434"),u(R.visionFallback.model??"qwen3.5:0.8b"),d(R.visionFallback.apiKey??""),R.visionFallback.backend&&p(R.visionFallback.backend))),R.providers&&g(R.providers)}).catch(()=>{})},[]);const S=oW(m),b=dW(w,a,u),v=uW(p,w,a,u);function k(R){if(R){e({});return}e(t&&y?{visionFallback:{enabled:t,providerModelRef:y,timeout:120}}:{visionFallback:{enabled:t,url:r,model:l,timeout:120,backend:h,providerModelRef:"",apiKey:h==="openai"?c:""}})}const T=S.length>0;return s.jsxs("div",{className:"max-w-xl mx-auto",children:[s.jsx("h2",{className:"text-2xl font-bold text-text-primary mb-2",children:"Vision (Optional)"}),s.jsx("p",{className:"text-text-secondary mb-8",children:"Configure a vision model for non-vision models"}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs("div",{className:"bg-bg-secondary rounded-lg p-4 border border-border",children:[s.jsx("p",{className:"text-text-secondary text-sm mb-2",children:"You need a server with a vision model. Choose your backend type below."}),s.jsx("p",{className:"text-text-secondary text-sm mb-2",children:"For Ollama:"}),s.jsx("a",{href:"https://ollama.com/download",target:"_blank",rel:"noopener noreferrer",className:"text-accent-primary hover:underline text-sm",children:"Download Ollama"}),s.jsxs("div",{className:"mt-3 p-2 bg-bg-primary rounded border border-border flex items-center justify-between gap-2",children:[s.jsx("code",{className:"text-text-secondary text-xs",children:"ollama pull qwen3.5:0.8b"}),s.jsx("button",{onClick:()=>_("ollama pull qwen3.5:0.8b"),className:"text-text-muted hover:text-text-primary transition-colors",title:"Copy",children:C?s.jsx(Ls,{className:"w-4 h-4 text-accent-primary"}):s.jsx(L3,{className:"w-4 h-4"})})]}),s.jsxs("p",{className:"text-text-secondary text-sm mt-3",children:["For OpenAI-compatible servers (vLLM, sglang, llama.cpp): use the ",s.jsx("strong",{children:"OpenAI"})," backend type."]})]}),s.jsxs("label",{className:"flex items-center gap-3 cursor-pointer",children:[s.jsx("input",{type:"checkbox",checked:t,onChange:R=>n(R.target.checked),className:"w-5 h-5 rounded border-border bg-bg-secondary text-accent-primary focus:ring-accent-primary"}),s.jsx("span",{className:"text-text-primary",children:"Enable vision fallback for non-vision models"})]}),s.jsx(hW,{enabled:t,hasOptions:T,selectedRef:y,visionModelOptions:S,onProviderModelSelect:b,backend:h,url:r,model:l,apiKey:c,onBackendChange:v,onUrlChange:a,onModelChange:u,onApiKeyChange:d,noOptionsMessage:"No vision-capable models found in your providers. You can manually enter a model below."}),s.jsxs("div",{className:"flex items-center justify-between pt-4",children:[s.jsx("button",{onClick:()=>k(!0),"data-testid":"onboarding-skip-button",className:"text-text-muted hover:text-text-secondary text-sm underline",children:"Skip for now"}),s.jsx("button",{onClick:()=>k(!1),className:"px-6 py-3 bg-accent-primary text-text-primary rounded-lg font-medium hover:bg-accent-primary/90 transition-colors",children:"Finish Setup"})]})]})]})}function mW({onComplete:e}){const[t,n]=E.useState(1),[r,a]=E.useState(!1),[l,u]=E.useState({});async function c(m){u(g=>({...g,providers:m.providers})),n(2)}async function d(m){u(g=>({...g,...m})),n(3)}async function h(m){a(!0);try{if(!(await we("/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(g){console.error("Failed to save onboarding data:",g),a(!1)}}const p=m=>{n(m)};return s.jsxs("div",{className:"w-full max-w-xl mx-auto px-6 py-16 relative",children:[s.jsx(vu,{onClick:e,className:"absolute top-4 right-4 p-2",variant:"modal",size:"xl"}),s.jsx(rW,{currentStep:t,totalSteps:3,labels:["LLM Providers","Projects Folder","Vision"],onStepClick:p}),s.jsx("div",{className:"max-w-xl mx-auto",children:r?s.jsxs("div",{className:"text-center",children:[s.jsx(Ns,{className:"w-6 h-6"}),s.jsx("p",{className:"mt-4 text-text-secondary",children:"Saving your settings..."})]}):s.jsxs(s.Fragment,{children:[t===1&&s.jsx(sW,{onNext:c}),t===2&&s.jsx(iW,{onNext:d}),t===3&&s.jsx(fW,{onNext:h})]})})]})}function pW({projectId:e}){var p;const[,t]=Gn(),n=De(m=>m.sessionsWithPendingConfirmations),r=De(m=>{var g;return(g=m.currentSession)==null?void 0:g.id}),a=De(m=>m.crossSessionConfirmations),l=De(m=>m.sessions),u=n.find(m=>m!==r);if(!u)return null;const c=l.find(m=>m.id===u),d=(c==null?void 0:c.title)??u.slice(0,6),h=((p=a[u])==null?void 0:p.length)??0;return s.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-amber-500/15 border-b border-amber-500/30 cursor-pointer hover:bg-amber-500/20 transition-colors",onClick:()=>t(e?`/p/${e}/s/${u}`:`/s/${u}`),role:"button",tabIndex:0,onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&t(e?`/p/${e}/s/${u}`:`/s/${u}`)},children:[s.jsx(Py,{className:"w-4 h-4 text-amber-400 flex-shrink-0"}),s.jsxs("span",{className:"text-sm text-amber-300 flex-1 truncate",children:[h," confirmation",h>1?"s":"",' pending in session "',d,'"']}),s.jsx("span",{className:"text-xs text-amber-400 font-medium flex-shrink-0",children:"View session →"})]})}const fx="openfox_updated_to",mx="update_pending";function gW(){const[e,t]=E.useState(!1),n=localStorage.getItem(fx),r=localStorage.getItem(mx);E.useEffect(()=>{if(!n||!r)return;const l=setTimeout(()=>{localStorage.removeItem(fx),localStorage.removeItem(mx),t(!0)},8e3);return()=>clearTimeout(l)},[n,r]);const a=()=>{localStorage.removeItem(fx),localStorage.removeItem(mx),t(!0)};return e||r!=="true"||!n?null:s.jsxs("div",{className:"fixed bottom-20 left-1/2 -translate-x-1/2 z-[100] flex items-center gap-3 px-4 py-2.5 bg-bg-secondary border border-border rounded-lg shadow-xl animate-slide-down",role:"status","aria-live":"polite",children:[s.jsx("div",{className:"flex items-center justify-center w-5 h-5 rounded-full bg-accent-primary/20",children:s.jsx(Ls,{className:"w-3 h-3 text-accent-primary"})}),s.jsxs("div",{className:"flex flex-col",children:[s.jsx("span",{className:"text-sm font-medium text-text-primary",children:"OpenFox updated successfully"}),s.jsxs("span",{className:"text-xs text-text-muted",children:["Now running ",n]})]}),s.jsx("button",{onClick:a,className:"ml-2 p-1 rounded hover:bg-bg-tertiary text-text-muted hover:text-text-primary transition-colors","aria-label":"Dismiss",children:s.jsx($y,{className:"w-3.5 h-3.5"})})]})}typeof window<"u"&&(qt.getState().loadUserPresets(),qt.getState().applySavedTheme());function $b(){return typeof window>"u"?!1:localStorage.getItem("openfox_token")!==null}function PT(){return s.jsx("div",{className:"flex-1 flex items-center justify-center",children:s.jsx(Zi,{})})}function xW({sidebarOpen:e,onSidebarToggle:t}){const[,n]=ml("/p/:projectId"),r=n==null?void 0:n.projectId,a=De(d=>d.connectionStatus),l=tn(d=>d.currentProject),u=$b();return k3({canLoad:a==="connected"||u,projectId:r,currentProjectId:l==null?void 0:l.id}),!l||l.id!==r?s.jsx(PT,{}):s.jsxs(s.Fragment,{children:[s.jsx(VN,{projectId:r,isOpen:e,onClose:t}),s.jsx("div",{className:"flex-1 min-w-0 bg-primary",children:s.jsx(f7,{})})]})}function yW({sidebarOpen:e,onSidebarToggle:t,rightSidebarOpen:n,onRightSidebarToggle:r}){const[,a]=ml("/p/:projectId/s/:sessionId"),l=a==null?void 0:a.projectId,u=a==null?void 0:a.sessionId,[,c]=Gn(),d=De(C=>C.connectionStatus),h=De(C=>C.currentSession),p=De(C=>C.error),m=De(C=>C.clearError),g=tn(C=>C.currentProject),y=$b();return E3({canLoad:d==="connected"||y,projectId:l,sessionId:u,currentProjectId:g==null?void 0:g.id,currentSessionId:h==null?void 0:h.id}),E.useEffect(()=>{(p==null?void 0:p.code)==="NOT_FOUND"&&l&&(m(),c(`/p/${l}`))},[p,l,m,c]),!g||g.id!==l?s.jsx(PT,{}):s.jsxs(s.Fragment,{children:[s.jsx(VN,{projectId:l,isOpen:e,onClose:t}),s.jsxs("div",{className:"flex-1 min-w-0 bg-primary flex flex-col",children:[s.jsx(pW,{projectId:l}),s.jsx(tW,{criteriaSidebarOpen:n,onCriteriaSidebarToggle:r})]})]})}function bW(){const e=Zt(r=>r.fetchConfig),[,t]=Gn();async function n(){await e(),t("/")}return s.jsx(ct,{className:"flex-1",children:s.jsx(mW,{onComplete:n})})}function vW(){const{connectionStatus:e}=b3(),t=Zt(I=>I.fetchConfig),n=Zt(I=>I.refreshProviderModels),r=Zt(I=>I.providers),a=Zt(I=>I.activeProviderId),[,l]=Gn(),u=$b(),[c,d]=E.useState(!1);E.useEffect(()=>{(e==="connected"||u)&&t().then(()=>{d(!0),Lt.getState().getSettings([...Oy,je.DISPLAY_THEME,je.DISPLAY_USER_PRESETS,je.DISPLAY_CUSTOM_CSS,je.KEYBINDINGS,je.FEATURES_PER_SESSION_MCP]),Kc.getState().fetchServers()})},[e,u,t]),E.useEffect(()=>{c&&a&&n(a).then(()=>{const I=Zt.getState().defaultModelSelection;(I?I.split("/")[0]:null)!==a&&t()})},[c,a,n,t]);const h=Lt(I=>I.settings);E.useEffect(()=>{c&&r.length===0&&l("/onboarding")},[c,r.length]),E.useEffect(()=>{const{applyPreset:I,applyTokens:D,setFollowSystemTheme:q,initSystemThemeListener:$}=qt.getState(),J=h[je.DISPLAY_THEME],Y=h[je.DISPLAY_USER_PRESETS],Z=h[je.DISPLAY_FOLLOW_SYSTEM_THEME];if(Y&&localStorage.setItem("openfox:userPresets",Y),J){localStorage.setItem("openfox:theme",J);try{const B=JSON.parse(J);B.preset&&B.tokens?(I(B.preset),qt.setState({basePreset:B.preset}),D(B.tokens)):B.preset?I(B.preset):B.tokens&&D(B.tokens)}catch{I("dark")}}else I("system");Z!==void 0&&qt.getState().followSystemTheme!==(Z==="true")&&q(Z==="true");const K=$();return()=>K()},[h[je.DISPLAY_THEME],h[je.DISPLAY_USER_PRESETS]]),E.useEffect(()=>{const I=h[je.DISPLAY_CUSTOM_CSS]??"";let D=document.getElementById("custom-css");D||(D=document.createElement("style"),D.id="custom-css",document.head.appendChild(D)),D.textContent=I},[h[je.DISPLAY_CUSTOM_CSS]]);const[p,m]=E.useState(!1);E.useEffect(()=>{const I=Lt.getState().settings[je.DISPLAY_SHOW_CHANGELOG_ON_UPDATE];if(I===void 0||I==="false")return;let D=!1;if(localStorage.getItem("update_pending")==="true"&&(D=!0,localStorage.removeItem("update_pending")),c){const $=Zt.getState().version,J=localStorage.getItem("openfox_last_version");$&&J&&$!==J&&(D=!0),localStorage.setItem("openfox_last_version",$??"")}D&&m(!0)},[h[je.DISPLAY_SHOW_CHANGELOG_ON_UPDATE],c]);const g=()=>{const I=localStorage.getItem("openfox:leftSidebar");return I!==null?I==="true":!0},y=()=>{const I=localStorage.getItem("openfox:rightSidebar");return I!==null?I==="true":!0},[w,C]=E.useState(g),[_,S]=E.useState(y),[b,v]=E.useState(!1),[k,T]=E.useState(!1),[N,R]=E.useState(!1),A=WD();E.useEffect(()=>{const I=()=>{R(window.innerWidth<768)};return I(),window.addEventListener("resize",I),()=>window.removeEventListener("resize",I)},[]);const[O]=Gn(),P=/^\/p\/[^/]+$/.test(O),V=N?b:P?!0:w,z=N?k:_,W=()=>{N?v(!b):C(!w)},M=()=>{N?T(!k):S(!_)};E.useEffect(()=>{N||localStorage.setItem("openfox:leftSidebar",String(w))},[w,N]),E.useEffect(()=>{N||localStorage.setItem("openfox:rightSidebar",String(_))},[_,N]),E.useEffect(()=>{(e==="connected"||u)&&t()},[e,t,u]);const U=De(I=>I.showPasswordModal),F=De(I=>I.passwordModalRetry),Q=De(I=>I.submitPassword),X=De(I=>I.cancelPassword),[H]=ml("/p/:projectId/s/:sessionId/readonly");return!H&&e!=="connected"&&!U&&!u?s.jsxs(s.Fragment,{children:[s.jsx(hk,{isOpen:!0,isRetry:F,onSubmit:Q,onCancel:X}),s.jsx("div",{className:"h-screen flex items-center justify-center",children:s.jsx(e5,{text:"Connecting to server..."})})]}):H?s.jsx(nW,{}):s.jsxs(s.Fragment,{children:[s.jsx(hk,{isOpen:U,isRetry:F,onSubmit:Q,onCancel:X}),s.jsxs("div",{className:"flex flex-col",style:{height:N?`calc(${A.offsetTop}px + ${A.height}px)`:"100vh"},children:[s.jsx(c7,{}),s.jsx(e7,{onMenuClick:W,onCriteriaToggle:M}),s.jsx("div",{className:"flex-1 flex overflow-hidden",children:s.jsxs(TR,{children:[s.jsx(mc,{path:"/onboarding",children:s.jsx(bW,{})}),s.jsx(mc,{path:"/p/:projectId/s/:sessionId",children:s.jsx(yW,{sidebarOpen:V,onSidebarToggle:W,rightSidebarOpen:z,onRightSidebarToggle:M})}),s.jsx(mc,{path:"/p/:projectId/new",children:s.jsx(h7,{})}),s.jsx(mc,{path:"/p/:projectId",children:s.jsx(xW,{sidebarOpen:V,onSidebarToggle:W})}),s.jsx(mc,{path:"/",children:s.jsx(d7,{})})]})})]}),s.jsx(gW,{}),s.jsx(jN,{isOpen:p,onClose:()=>m(!1)})]})}const dh=window.location.pathname.match(/\/p\/[^/]+\/s\/([0-9a-fA-F-]+)/);dh!=null&&dh[1]&&qD(dh[1]);lR.createRoot(document.getElementById("root")).render(s.jsx(os.StrictMode,{children:s.jsx(_k,{base:fE,children:s.jsx(vW,{})})}));