@vibe-forge/client 3.1.4-alpha.0 → 3.1.4

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 (60) hide show
  1. package/dist/assets/{arc-UXP0D9gB.js → arc-DyihFEGh.js} +1 -1
  2. package/dist/assets/{blockDiagram-c4efeb88-CuzBYMH1.js → blockDiagram-c4efeb88-Dl4XEGmG.js} +1 -1
  3. package/dist/assets/{c4Diagram-c83219d4-CGghXRh-.js → c4Diagram-c83219d4-Cqxt8lJj.js} +1 -1
  4. package/dist/assets/channel-BRQzCaAb.js +1 -0
  5. package/dist/assets/{classDiagram-beda092f-BOV0LMAC.js → classDiagram-beda092f-BvT--jUg.js} +1 -1
  6. package/dist/assets/{classDiagram-v2-2358418a-LjEKnA9q.js → classDiagram-v2-2358418a-BK4yKozv.js} +1 -1
  7. package/dist/assets/clone-BinmC9Bs.js +1 -0
  8. package/dist/assets/{createText-1719965b-C6kPgwIy.js → createText-1719965b-BQFK7XFd.js} +1 -1
  9. package/dist/assets/{cssMode-DWNQvDzf.js → cssMode-Ca5YrKlU.js} +1 -1
  10. package/dist/assets/{edges-96097737-BMyTFYHo.js → edges-96097737-D_1jRv6M.js} +1 -1
  11. package/dist/assets/{erDiagram-0228fc6a-B_-9f3Ye.js → erDiagram-0228fc6a-BP7GOT9n.js} +1 -1
  12. package/dist/assets/{flowDb-c6c81e3f-BnNyXGFC.js → flowDb-c6c81e3f-BXNAMySD.js} +1 -1
  13. package/dist/assets/{flowDiagram-50d868cf-M2Ik0dKr.js → flowDiagram-50d868cf-pSn0qGUQ.js} +1 -1
  14. package/dist/assets/flowDiagram-v2-4f6560a1-BwJrJtb7.js +1 -0
  15. package/dist/assets/{flowchart-elk-definition-6af322e1-C0-g_yn9.js → flowchart-elk-definition-6af322e1-pBCmdPFK.js} +1 -1
  16. package/dist/assets/{freemarker2-b_gJmXuF.js → freemarker2-CACU9C35.js} +1 -1
  17. package/dist/assets/{ganttDiagram-a2739b55-B30NyENY.js → ganttDiagram-a2739b55-DG0a-mOU.js} +1 -1
  18. package/dist/assets/{gitGraphDiagram-82fe8481-BvQAFJ4Y.js → gitGraphDiagram-82fe8481-JdHxKbIo.js} +1 -1
  19. package/dist/assets/{graph-DQff5RJf.js → graph-DLLo1q0w.js} +1 -1
  20. package/dist/assets/{handlebars-CWhoL04S.js → handlebars-DHtyM93b.js} +1 -1
  21. package/dist/assets/{html-DyrmcYNn.js → html-DCIlVDn9.js} +1 -1
  22. package/dist/assets/{htmlMode-BsgOVHtb.js → htmlMode-DNwcJ7l2.js} +1 -1
  23. package/dist/assets/{index-5325376f-g9noRfsl.js → index-5325376f-CmK2jyYI.js} +1 -1
  24. package/dist/assets/{index-C2aBBpHu.js → index-noXZcvnG.js} +5 -5
  25. package/dist/assets/{infoDiagram-8eee0895-662VpUUc.js → infoDiagram-8eee0895-LKLe_tVe.js} +1 -1
  26. package/dist/assets/{javascript-BgX3Uy8S.js → javascript-2ieTkVr_.js} +1 -1
  27. package/dist/assets/{journeyDiagram-c64418c1-B1rh1UfN.js → journeyDiagram-c64418c1-B5adzPG5.js} +1 -1
  28. package/dist/assets/{jsonMode-A5VNSpp6.js → jsonMode-C8lI1qS6.js} +1 -1
  29. package/dist/assets/{layout-CAQ1QIX9.js → layout-BQchEw2Q.js} +1 -1
  30. package/dist/assets/{line-7SZ7IAIF.js → line-BgerWI1Z.js} +1 -1
  31. package/dist/assets/{linear-BjryIYg8.js → linear-Co545NWp.js} +1 -1
  32. package/dist/assets/{liquid-BySBA1oH.js → liquid-4HmYxWqB.js} +1 -1
  33. package/dist/assets/{lspLanguageFeatures-B7_JzRak.js → lspLanguageFeatures-Cj6ZiLO4.js} +1 -1
  34. package/dist/assets/{mdx-BQ6MhT52.js → mdx-BSJ29RMi.js} +1 -1
  35. package/dist/assets/{mermaid.core-BG9PyDfl.js → mermaid.core-DgAHGSOR.js} +4 -4
  36. package/dist/assets/{mindmap-definition-8da855dc-DLPuzKV0.js → mindmap-definition-8da855dc-DbPm9paO.js} +1 -1
  37. package/dist/assets/{pieDiagram-a8764435-Jonj7H_n.js → pieDiagram-a8764435-Dm5wXW7P.js} +1 -1
  38. package/dist/assets/{python-C3bCba7U.js → python-BGBkGI4c.js} +1 -1
  39. package/dist/assets/{quadrantDiagram-1e28029f-CDAWaaC6.js → quadrantDiagram-1e28029f-DlWe23vI.js} +1 -1
  40. package/dist/assets/{razor-DWZY4z0v.js → razor-J2LRfvrP.js} +1 -1
  41. package/dist/assets/{requirementDiagram-08caed73-BksrdFek.js → requirementDiagram-08caed73-f2iCt4RO.js} +1 -1
  42. package/dist/assets/{sankeyDiagram-a04cb91d-DFQsc5LS.js → sankeyDiagram-a04cb91d-BuGVRw87.js} +1 -1
  43. package/dist/assets/{sequenceDiagram-c5b8d532-C3kOQptQ.js → sequenceDiagram-c5b8d532-De7v62uG.js} +1 -1
  44. package/dist/assets/{stateDiagram-1ecb1508-B11U7ztj.js → stateDiagram-1ecb1508-Bm1od_wW.js} +1 -1
  45. package/dist/assets/{stateDiagram-v2-c2b004d7-DFj46mT2.js → stateDiagram-v2-c2b004d7-BaFmSqiN.js} +1 -1
  46. package/dist/assets/{styles-b4e223ce-Blm0G0Ew.js → styles-b4e223ce-CrJ3dEhz.js} +1 -1
  47. package/dist/assets/{styles-ca3715f6-CQIMQppj.js → styles-ca3715f6-Brv8CI22.js} +1 -1
  48. package/dist/assets/{styles-d45a18b0-ByQQ3RwV.js → styles-d45a18b0-niARW7m_.js} +1 -1
  49. package/dist/assets/{svgDrawCommon-b86b1483-Wxfmnhgu.js → svgDrawCommon-b86b1483-CNlZXP_O.js} +1 -1
  50. package/dist/assets/{timeline-definition-faaaa080-BT0SEd3p.js → timeline-definition-faaaa080-B57xJx3J.js} +1 -1
  51. package/dist/assets/{tsMode-C5Lv-ixK.js → tsMode-ClzzMo6h.js} +1 -1
  52. package/dist/assets/{typescript-IXjxtali.js → typescript-PTtJjTZB.js} +1 -1
  53. package/dist/assets/{xml-z63Txqyp.js → xml-CFW_XanW.js} +1 -1
  54. package/dist/assets/{xychartDiagram-f5964ef8-D8y3STdn.js → xychartDiagram-f5964ef8-PcJmiNsW.js} +1 -1
  55. package/dist/assets/{yaml-N2kAbToy.js → yaml-CXH4pPqt.js} +1 -1
  56. package/dist/index.html +1 -1
  57. package/package.json +8 -8
  58. package/dist/assets/channel-DGDW1xsW.js +0 -1
  59. package/dist/assets/clone-DeCoUX9l.js +0 -1
  60. package/dist/assets/flowDiagram-v2-4f6560a1-BrxwWVap.js +0 -1
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/angular-html-CU67Zn6k.js","assets/html-GMplVEZG.js","assets/javascript-wDzz0qaB.js","assets/css-DPfMkruS.js","assets/angular-ts-BwZT4LLn.js","assets/scss-OYdSNvt2.js","assets/apl-dKokRX4l.js","assets/xml-sdJ4AIDG.js","assets/java-CylS5w8V.js","assets/json-Cp-IABpG.js","assets/astro-CbQHKStN.js","assets/typescript-BPQ3VLAy.js","assets/postcss-CXtECtnM.js","assets/tsx-COt5Ahok.js","assets/blade-D4QpJJKB.js","assets/html-derivative-BFtXZ54Q.js","assets/sql-BLtJtn59.js","assets/bsl-BO_Y6i37.js","assets/sdbl-DVxCFoDh.js","assets/cairo-KRGpt6FW.js","assets/python-B6aJPvgy.js","assets/cobol-nwyudZeR.js","assets/coffee-Ch7k5sss.js","assets/cpp-CofmeUqb.js","assets/regexp-CDVJQ6XC.js","assets/glsl-DplSGwfg.js","assets/c-BIGW1oBm.js","assets/crystal-tKQVLTB8.js","assets/shellscript-Yzrsuije.js","assets/edge-BkV0erSs.js","assets/elixir-CDX3lj18.js","assets/elm-DbKCFpqz.js","assets/erb-BOJIQeun.js","assets/ruby-BvKwtOVI.js","assets/haml-B8DHNrY2.js","assets/graphql-ChdNCCLP.js","assets/jsx-g9-lgVsj.js","assets/lua-BbnMAYS6.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-B7Tvp0Sc.js","assets/gdshader-DkwncUOv.js","assets/gdscript-DTMYz4Jt.js","assets/git-commit-F4YmCXRG.js","assets/diff-D97Zzqfu.js","assets/git-rebase-r7XF79zn.js","assets/glimmer-js-Rg0-pVw9.js","assets/glimmer-ts-U6CK756n.js","assets/hack-CaT9iCJl.js","assets/handlebars-BL8al0AC.js","assets/http-jrhK8wxY.js","assets/hurl-irOxFIW8.js","assets/csv-fuZLfV_i.js","assets/hxml-Bvhsp5Yf.js","assets/haxe-CzTSHFRz.js","assets/jinja-4LBKfQ-Z.js","assets/jison-wvAkD_A8.js","assets/julia-CxzCAyBv.js","assets/r-Dspwwk_N.js","assets/latex-B4uzh10-.js","assets/tex-CvyZ59Mk.js","assets/liquid-DYVedYrR.js","assets/marko-DZsq8hO1.js","assets/less-B1dDrJ26.js","assets/mdc-DUICxH0z.js","assets/nginx-DknmC5AR.js","assets/nim-CVrawwO9.js","assets/perl-C0TMdlhV.js","assets/php-CDn_0X-4.js","assets/pug-CGlum2m_.js","assets/qml-3beO22l8.js","assets/razor-C1TweQQi.js","assets/csharp-K5feNrxe.js","assets/rst-B0xPkSld.js","assets/cmake-D1j8_8rp.js","assets/sas-cz2c8ADy.js","assets/shaderlab-Dg9Lc6iA.js","assets/hlsl-D3lLCCz7.js","assets/shellsession-BADoaaVG.js","assets/soy-Brmx7dQM.js","assets/sparql-rVzFXLq3.js","assets/turtle-BsS91CYL.js","assets/stata-BH5u7GGu.js","assets/svelte-zxCyuUbr.js","assets/templ-W15q3VgB.js","assets/go-Dn2_MT6a.js","assets/ts-tags-zn1MmPIZ.js","assets/twig-CO9l9SDP.js","assets/vue-DN_0RTcg.js","assets/vue-html-AaS7Mt5G.js","assets/vue-vine-CQOfvN7w.js","assets/stylus-BEDo0Tqx.js","assets/xsl-CtQFsRM5.js","assets/cssMode-DWNQvDzf.js","assets/lspLanguageFeatures-B7_JzRak.js","assets/htmlMode-BsgOVHtb.js","assets/jsonMode-A5VNSpp6.js","assets/javascript-BgX3Uy8S.js","assets/typescript-IXjxtali.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/angular-html-CU67Zn6k.js","assets/html-GMplVEZG.js","assets/javascript-wDzz0qaB.js","assets/css-DPfMkruS.js","assets/angular-ts-BwZT4LLn.js","assets/scss-OYdSNvt2.js","assets/apl-dKokRX4l.js","assets/xml-sdJ4AIDG.js","assets/java-CylS5w8V.js","assets/json-Cp-IABpG.js","assets/astro-CbQHKStN.js","assets/typescript-BPQ3VLAy.js","assets/postcss-CXtECtnM.js","assets/tsx-COt5Ahok.js","assets/blade-D4QpJJKB.js","assets/html-derivative-BFtXZ54Q.js","assets/sql-BLtJtn59.js","assets/bsl-BO_Y6i37.js","assets/sdbl-DVxCFoDh.js","assets/cairo-KRGpt6FW.js","assets/python-B6aJPvgy.js","assets/cobol-nwyudZeR.js","assets/coffee-Ch7k5sss.js","assets/cpp-CofmeUqb.js","assets/regexp-CDVJQ6XC.js","assets/glsl-DplSGwfg.js","assets/c-BIGW1oBm.js","assets/crystal-tKQVLTB8.js","assets/shellscript-Yzrsuije.js","assets/edge-BkV0erSs.js","assets/elixir-CDX3lj18.js","assets/elm-DbKCFpqz.js","assets/erb-BOJIQeun.js","assets/ruby-BvKwtOVI.js","assets/haml-B8DHNrY2.js","assets/graphql-ChdNCCLP.js","assets/jsx-g9-lgVsj.js","assets/lua-BbnMAYS6.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-B7Tvp0Sc.js","assets/gdshader-DkwncUOv.js","assets/gdscript-DTMYz4Jt.js","assets/git-commit-F4YmCXRG.js","assets/diff-D97Zzqfu.js","assets/git-rebase-r7XF79zn.js","assets/glimmer-js-Rg0-pVw9.js","assets/glimmer-ts-U6CK756n.js","assets/hack-CaT9iCJl.js","assets/handlebars-BL8al0AC.js","assets/http-jrhK8wxY.js","assets/hurl-irOxFIW8.js","assets/csv-fuZLfV_i.js","assets/hxml-Bvhsp5Yf.js","assets/haxe-CzTSHFRz.js","assets/jinja-4LBKfQ-Z.js","assets/jison-wvAkD_A8.js","assets/julia-CxzCAyBv.js","assets/r-Dspwwk_N.js","assets/latex-B4uzh10-.js","assets/tex-CvyZ59Mk.js","assets/liquid-DYVedYrR.js","assets/marko-DZsq8hO1.js","assets/less-B1dDrJ26.js","assets/mdc-DUICxH0z.js","assets/nginx-DknmC5AR.js","assets/nim-CVrawwO9.js","assets/perl-C0TMdlhV.js","assets/php-CDn_0X-4.js","assets/pug-CGlum2m_.js","assets/qml-3beO22l8.js","assets/razor-C1TweQQi.js","assets/csharp-K5feNrxe.js","assets/rst-B0xPkSld.js","assets/cmake-D1j8_8rp.js","assets/sas-cz2c8ADy.js","assets/shaderlab-Dg9Lc6iA.js","assets/hlsl-D3lLCCz7.js","assets/shellsession-BADoaaVG.js","assets/soy-Brmx7dQM.js","assets/sparql-rVzFXLq3.js","assets/turtle-BsS91CYL.js","assets/stata-BH5u7GGu.js","assets/svelte-zxCyuUbr.js","assets/templ-W15q3VgB.js","assets/go-Dn2_MT6a.js","assets/ts-tags-zn1MmPIZ.js","assets/twig-CO9l9SDP.js","assets/vue-DN_0RTcg.js","assets/vue-html-AaS7Mt5G.js","assets/vue-vine-CQOfvN7w.js","assets/stylus-BEDo0Tqx.js","assets/xsl-CtQFsRM5.js","assets/cssMode-Ca5YrKlU.js","assets/lspLanguageFeatures-Cj6ZiLO4.js","assets/htmlMode-DNwcJ7l2.js","assets/jsonMode-C8lI1qS6.js","assets/javascript-2ieTkVr_.js","assets/typescript-PTtJjTZB.js"])))=>i.map(i=>d[i]);
2
2
  var FYe=Object.defineProperty;var BYe=(n,e,t)=>e in n?FYe(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var dt=(n,e,t)=>BYe(n,typeof e!="symbol"?e+"":e,t);function wke(n,e){for(var t=0;t<e.length;t++){const i=e[t];if(typeof i!="string"&&!Array.isArray(i)){for(const s in i)if(s!=="default"&&!(s in n)){const r=Object.getOwnPropertyDescriptor(i,s);r&&Object.defineProperty(n,s,r.get?r:{enumerable:!0,get:()=>i[s]})}}}return Object.freeze(Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))i(s);new MutationObserver(s=>{for(const r of s)if(r.type==="childList")for(const o of r.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&i(o)}).observe(document,{childList:!0,subtree:!0});function t(s){const r={};return s.integrity&&(r.integrity=s.integrity),s.referrerPolicy&&(r.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?r.credentials="include":s.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function i(s){if(s.ep)return;s.ep=!0;const r=t(s);fetch(s.href,r)}})();var _k=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function z0(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}function vde(n){if(n.__esModule)return n;var e=n.default;if(typeof e=="function"){var t=function i(){return this instanceof i?Reflect.construct(e,arguments,this.constructor):e.apply(this,arguments)};t.prototype=e.prototype}else t={};return Object.defineProperty(t,"__esModule",{value:!0}),Object.keys(n).forEach(function(i){var s=Object.getOwnPropertyDescriptor(n,i);Object.defineProperty(t,i,s.get?s:{enumerable:!0,get:function(){return n[i]}})}),t}var Ske={exports:{}},yj={},xke={exports:{}},cs={};/**
3
3
  * @license React
4
4
  * react.production.min.js
@@ -457,7 +457,7 @@ html body {
457
457
  * @license MIT
458
458
  */var H5e="popstate";function a4t(n={}){function e(i,s){let{pathname:r,search:o,hash:a}=i.location;return uee("",{pathname:r,search:o,hash:a},s.state&&s.state.usr||null,s.state&&s.state.key||"default")}function t(i,s){return typeof s=="string"?s:tE(s)}return c4t(e,t,null,n)}function Eo(n,e){if(n===!1||n===null||typeof n>"u")throw new Error(e)}function Sh(n,e){if(!n){typeof console<"u"&&console.warn(e);try{throw new Error(e)}catch{}}}function l4t(){return Math.random().toString(36).substring(2,10)}function V5e(n,e){return{usr:n.state,key:n.key,idx:e}}function uee(n,e,t=null,i){return{pathname:typeof n=="string"?n:n.pathname,search:"",hash:"",...typeof e=="string"?Yy(e):e,state:t,key:e&&e.key||i||l4t()}}function tE({pathname:n="/",search:e="",hash:t=""}){return e&&e!=="?"&&(n+=e.charAt(0)==="?"?e:"?"+e),t&&t!=="#"&&(n+=t.charAt(0)==="#"?t:"#"+t),n}function Yy(n){let e={};if(n){let t=n.indexOf("#");t>=0&&(e.hash=n.substring(t),n=n.substring(0,t));let i=n.indexOf("?");i>=0&&(e.search=n.substring(i),n=n.substring(0,i)),n&&(e.pathname=n)}return e}function c4t(n,e,t,i={}){let{window:s=document.defaultView,v5Compat:r=!1}=i,o=s.history,a="POP",l=null,c=d();c==null&&(c=0,o.replaceState({...o.state,idx:c},""));function d(){return(o.state||{idx:null}).idx}function u(){a="POP";let p=d(),_=p==null?null:p-c;c=p,l&&l({action:a,location:m.location,delta:_})}function h(p,_){a="PUSH";let b=uee(m.location,p,_);c=d()+1;let y=V5e(b,c),w=m.createHref(b);try{o.pushState(y,"",w)}catch(S){if(S instanceof DOMException&&S.name==="DataCloneError")throw S;s.location.assign(w)}r&&l&&l({action:a,location:m.location,delta:1})}function f(p,_){a="REPLACE";let b=uee(m.location,p,_);c=d();let y=V5e(b,c),w=m.createHref(b);o.replaceState(y,"",w),r&&l&&l({action:a,location:m.location,delta:0})}function g(p){return d4t(p)}let m={get action(){return a},get location(){return n(s,o)},listen(p){if(l)throw new Error("A history only accepts one active listener");return s.addEventListener(H5e,u),l=p,()=>{s.removeEventListener(H5e,u),l=null}},createHref(p){return e(s,p)},createURL:g,encodeLocation(p){let _=g(p);return{pathname:_.pathname,search:_.search,hash:_.hash}},push:h,replace:f,go(p){return o.go(p)}};return m}function d4t(n,e=!1){let t="http://localhost";typeof window<"u"&&(t=window.location.origin!=="null"?window.location.origin:window.location.href),Eo(t,"No window.location.(origin|href) available to create URL");let i=typeof n=="string"?n:tE(n);return i=i.replace(/ $/,"%20"),!e&&i.startsWith("//")&&(i=t+i),new URL(i,t)}function vPe(n,e,t="/"){return u4t(n,e,t,!1)}function u4t(n,e,t,i){let s=typeof e=="string"?Yy(e):e,r=S0(s.pathname||"/",t);if(r==null)return null;let o=bPe(n);h4t(o);let a=null;for(let l=0;a==null&&l<o.length;++l){let c=S4t(r);a=y4t(o[l],c,i)}return a}function bPe(n,e=[],t=[],i="",s=!1){let r=(o,a,l=s,c)=>{let d={relativePath:c===void 0?o.path||"":c,caseSensitive:o.caseSensitive===!0,childrenIndex:a,route:o};if(d.relativePath.startsWith("/")){if(!d.relativePath.startsWith(i)&&l)return;Eo(d.relativePath.startsWith(i),`Absolute route path "${d.relativePath}" nested under path "${i}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),d.relativePath=d.relativePath.slice(i.length)}let u=s0([i,d.relativePath]),h=t.concat(d);o.children&&o.children.length>0&&(Eo(o.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${u}".`),bPe(o.children,e,h,u,l)),!(o.path==null&&!o.index)&&e.push({path:u,score:v4t(u,o.index),routesMeta:h})};return n.forEach((o,a)=>{var l;if(o.path===""||!((l=o.path)!=null&&l.includes("?")))r(o,a);else for(let c of yPe(o.path))r(o,a,!0,c)}),e}function yPe(n){let e=n.split("/");if(e.length===0)return[];let[t,...i]=e,s=t.endsWith("?"),r=t.replace(/\?$/,"");if(i.length===0)return s?[r,""]:[r];let o=yPe(i.join("/")),a=[];return a.push(...o.map(l=>l===""?r:[r,l].join("/"))),s&&a.push(...o),a.map(l=>n.startsWith("/")&&l===""?"/":l)}function h4t(n){n.sort((e,t)=>e.score!==t.score?t.score-e.score:b4t(e.routesMeta.map(i=>i.childrenIndex),t.routesMeta.map(i=>i.childrenIndex)))}var f4t=/^:[\w-]+$/,g4t=3,m4t=2,p4t=1,C4t=10,_4t=-2,j5e=n=>n==="*";function v4t(n,e){let t=n.split("/"),i=t.length;return t.some(j5e)&&(i+=_4t),e&&(i+=m4t),t.filter(s=>!j5e(s)).reduce((s,r)=>s+(f4t.test(r)?g4t:r===""?p4t:C4t),i)}function b4t(n,e){return n.length===e.length&&n.slice(0,-1).every((i,s)=>i===e[s])?n[n.length-1]-e[e.length-1]:0}function y4t(n,e,t=!1){let{routesMeta:i}=n,s={},r="/",o=[];for(let a=0;a<i.length;++a){let l=i[a],c=a===i.length-1,d=r==="/"?e:e.slice(r.length)||"/",u=sf({path:l.relativePath,caseSensitive:l.caseSensitive,end:c},d),h=l.route;if(!u&&c&&t&&!i[i.length-1].route.index&&(u=sf({path:l.relativePath,caseSensitive:l.caseSensitive,end:!1},d)),!u)return null;Object.assign(s,u.params),o.push({params:s,pathname:s0([r,u.pathname]),pathnameBase:E4t(s0([r,u.pathnameBase])),route:h}),u.pathnameBase!=="/"&&(r=s0([r,u.pathnameBase]))}return o}function sf(n,e){typeof n=="string"&&(n={path:n,caseSensitive:!1,end:!0});let[t,i]=w4t(n.path,n.caseSensitive,n.end),s=e.match(t);if(!s)return null;let r=s[0],o=r.replace(/(.)\/+$/,"$1"),a=s.slice(1);return{params:i.reduce((c,{paramName:d,isOptional:u},h)=>{if(d==="*"){let g=a[h]||"";o=r.slice(0,r.length-g.length).replace(/(.)\/+$/,"$1")}const f=a[h];return u&&!f?c[d]=void 0:c[d]=(f||"").replace(/%2F/g,"/"),c},{}),pathname:r,pathnameBase:o,pattern:n}}function w4t(n,e=!1,t=!0){Sh(n==="*"||!n.endsWith("*")||n.endsWith("/*"),`Route path "${n}" will be treated as if it were "${n.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${n.replace(/\*$/,"/*")}".`);let i=[],s="^"+n.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(o,a,l)=>(i.push({paramName:a,isOptional:l!=null}),l?"/?([^\\/]+)?":"/([^\\/]+)")).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return n.endsWith("*")?(i.push({paramName:"*"}),s+=n==="*"||n==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):t?s+="\\/*$":n!==""&&n!=="/"&&(s+="(?:(?=\\/|$))"),[new RegExp(s,e?void 0:"i"),i]}function S4t(n){try{return n.split("/").map(e=>decodeURIComponent(e).replace(/\//g,"%2F")).join("/")}catch(e){return Sh(!1,`The URL path "${n}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${e}).`),n}}function S0(n,e){if(e==="/")return n;if(!n.toLowerCase().startsWith(e.toLowerCase()))return null;let t=e.endsWith("/")?e.length-1:e.length,i=n.charAt(t);return i&&i!=="/"?null:n.slice(t)||"/"}var wPe=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,x4t=n=>wPe.test(n);function L4t(n,e="/"){let{pathname:t,search:i="",hash:s=""}=typeof n=="string"?Yy(n):n,r;if(t)if(x4t(t))r=t;else{if(t.includes("//")){let o=t;t=t.replace(/\/\/+/g,"/"),Sh(!1,`Pathnames cannot have embedded double slashes - normalizing ${o} -> ${t}`)}t.startsWith("/")?r=W5e(t.substring(1),"/"):r=W5e(t,e)}else r=e;return{pathname:r,search:I4t(i),hash:M4t(s)}}function W5e(n,e){let t=e.replace(/\/+$/,"").split("/");return n.split("/").forEach(s=>{s===".."?t.length>1&&t.pop():s!=="."&&t.push(s)}),t.length>1?t.join("/"):"/"}function KZ(n,e,t,i){return`Cannot include a '${n}' character in a manually specified \`to.${e}\` field [${JSON.stringify(i)}]. Please separate it out to the \`to.${t}\` field. Alternatively you may provide the full path as a string in <Link to="..."> and the router will parse it for you.`}function k4t(n){return n.filter((e,t)=>t===0||e.route.path&&e.route.path.length>0)}function SPe(n){let e=k4t(n);return e.map((t,i)=>i===e.length-1?t.pathname:t.pathnameBase)}function xPe(n,e,t,i=!1){let s;typeof n=="string"?s=Yy(n):(s={...n},Eo(!s.pathname||!s.pathname.includes("?"),KZ("?","pathname","search",s)),Eo(!s.pathname||!s.pathname.includes("#"),KZ("#","pathname","hash",s)),Eo(!s.search||!s.search.includes("#"),KZ("#","search","hash",s)));let r=n===""||s.pathname==="",o=r?"/":s.pathname,a;if(o==null)a=t;else{let u=e.length-1;if(!i&&o.startsWith("..")){let h=o.split("/");for(;h[0]==="..";)h.shift(),u-=1;s.pathname=h.join("/")}a=u>=0?e[u]:"/"}let l=L4t(s,a),c=o&&o!=="/"&&o.endsWith("/"),d=(r||o===".")&&t.endsWith("/");return!l.pathname.endsWith("/")&&(c||d)&&(l.pathname+="/"),l}var s0=n=>n.join("/").replace(/\/\/+/g,"/"),E4t=n=>n.replace(/\/+$/,"").replace(/^\/*/,"/"),I4t=n=>!n||n==="?"?"":n.startsWith("?")?n:"?"+n,M4t=n=>!n||n==="#"?"":n.startsWith("#")?n:"#"+n,N4t=class{constructor(n,e,t,i=!1){this.status=n,this.statusText=e||"",this.internal=i,t instanceof Error?(this.data=t.toString(),this.error=t):this.data=t}};function D4t(n){return n!=null&&typeof n.status=="number"&&typeof n.statusText=="string"&&typeof n.internal=="boolean"&&"data"in n}function T4t(n){return n.map(e=>e.route.path).filter(Boolean).join("/").replace(/\/\/*/g,"/")||"/"}var LPe=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function kPe(n,e){let t=n;if(typeof t!="string"||!wPe.test(t))return{absoluteURL:void 0,isExternal:!1,to:t};let i=t,s=!1;if(LPe)try{let r=new URL(window.location.href),o=t.startsWith("//")?new URL(r.protocol+t):new URL(t),a=S0(o.pathname,e);o.origin===r.origin&&a!=null?t=a+o.search+o.hash:s=!0}catch{Sh(!1,`<Link to="${t}"> contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:i,isExternal:s,to:t}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var EPe=["POST","PUT","PATCH","DELETE"];new Set(EPe);var R4t=["GET",...EPe];new Set(R4t);var Qy=C.createContext(null);Qy.displayName="DataRouter";var UW=C.createContext(null);UW.displayName="DataRouterState";var P4t=C.createContext(!1),IPe=C.createContext({isTransitioning:!1});IPe.displayName="ViewTransition";var A4t=C.createContext(new Map);A4t.displayName="Fetchers";var O4t=C.createContext(null);O4t.displayName="Await";var Dh=C.createContext(null);Dh.displayName="Navigation";var $M=C.createContext(null);$M.displayName="Location";var Tf=C.createContext({outlet:null,matches:[],isDataRoute:!1});Tf.displayName="Route";var F3e=C.createContext(null);F3e.displayName="RouteError";var MPe="REACT_ROUTER_ERROR",F4t="REDIRECT",B4t="ROUTE_ERROR_RESPONSE";function $4t(n){if(n.startsWith(`${MPe}:${F4t}:{`))try{let e=JSON.parse(n.slice(28));if(typeof e=="object"&&e&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.location=="string"&&typeof e.reloadDocument=="boolean"&&typeof e.replace=="boolean")return e}catch{}}function H4t(n){if(n.startsWith(`${MPe}:${B4t}:{`))try{let e=JSON.parse(n.slice(40));if(typeof e=="object"&&e&&typeof e.status=="number"&&typeof e.statusText=="string")return new N4t(e.status,e.statusText,e.data)}catch{}}function V4t(n,{relative:e}={}){Eo(HM(),"useHref() may be used only in the context of a <Router> component.");let{basename:t,navigator:i}=C.useContext(Dh),{hash:s,pathname:r,search:o}=VM(n,{relative:e}),a=r;return t!=="/"&&(a=r==="/"?t:s0([t,r])),i.createHref({pathname:a,search:o,hash:s})}function HM(){return C.useContext($M)!=null}function E3(){return Eo(HM(),"useLocation() may be used only in the context of a <Router> component."),C.useContext($M).location}var NPe="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function DPe(n){C.useContext(Dh).static||C.useLayoutEffect(n)}function Iu(){let{isDataRoute:n}=C.useContext(Tf);return n?eCt():j4t()}function j4t(){Eo(HM(),"useNavigate() may be used only in the context of a <Router> component.");let n=C.useContext(Qy),{basename:e,navigator:t}=C.useContext(Dh),{matches:i}=C.useContext(Tf),{pathname:s}=E3(),r=JSON.stringify(SPe(i)),o=C.useRef(!1);return DPe(()=>{o.current=!0}),C.useCallback((l,c={})=>{if(Sh(o.current,NPe),!o.current)return;if(typeof l=="number"){t.go(l);return}let d=xPe(l,JSON.parse(r),s,c.relative==="path");n==null&&e!=="/"&&(d.pathname=d.pathname==="/"?e:s0([e,d.pathname])),(c.replace?t.replace:t.push)(d,c.state,c)},[e,t,r,s,n])}C.createContext(null);function B3e(){let{matches:n}=C.useContext(Tf),e=n[n.length-1];return e?e.params:{}}function VM(n,{relative:e}={}){let{matches:t}=C.useContext(Tf),{pathname:i}=E3(),s=JSON.stringify(SPe(t));return C.useMemo(()=>xPe(n,JSON.parse(s),i,e==="path"),[n,s,i,e])}function W4t(n,e){return TPe(n,e)}function TPe(n,e,t,i,s){var b;Eo(HM(),"useRoutes() may be used only in the context of a <Router> component.");let{navigator:r}=C.useContext(Dh),{matches:o}=C.useContext(Tf),a=o[o.length-1],l=a?a.params:{},c=a?a.pathname:"/",d=a?a.pathnameBase:"/",u=a&&a.route;{let y=u&&u.path||"";PPe(c,!u||y.endsWith("*")||y.endsWith("*?"),`You rendered descendant <Routes> (or called \`useRoutes()\`) at "${c}" (under <Route path="${y}">) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
459
459
 
460
- Please change the parent <Route path="${y}"> to <Route path="${y==="/"?"*":`${y}/*`}">.`)}let h=E3(),f;if(e){let y=typeof e=="string"?Yy(e):e;Eo(d==="/"||((b=y.pathname)==null?void 0:b.startsWith(d)),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${d}" but pathname "${y.pathname}" was given in the \`location\` prop.`),f=y}else f=h;let g=f.pathname||"/",m=g;if(d!=="/"){let y=d.replace(/^\//,"").split("/");m="/"+g.replace(/^\//,"").split("/").slice(y.length).join("/")}let p=vPe(n,{pathname:m});Sh(u||p!=null,`No routes matched location "${f.pathname}${f.search}${f.hash}" `),Sh(p==null||p[p.length-1].route.element!==void 0||p[p.length-1].route.Component!==void 0||p[p.length-1].route.lazy!==void 0,`Matched leaf route at location "${f.pathname}${f.search}${f.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let _=q4t(p&&p.map(y=>Object.assign({},y,{params:Object.assign({},l,y.params),pathname:s0([d,r.encodeLocation?r.encodeLocation(y.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:y.pathname]),pathnameBase:y.pathnameBase==="/"?d:s0([d,r.encodeLocation?r.encodeLocation(y.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:y.pathnameBase])})),o,t,i,s);return e&&_?C.createElement($M.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...f},navigationType:"POP"}},_):_}function z4t(){let n=J4t(),e=D4t(n)?`${n.status} ${n.statusText}`:n instanceof Error?n.message:JSON.stringify(n),t=n instanceof Error?n.stack:null,i="rgba(200,200,200, 0.5)",s={padding:"0.5rem",backgroundColor:i},r={padding:"2px 4px",backgroundColor:i},o=null;return console.error("Error handled by React Router default ErrorBoundary:",n),o=C.createElement(C.Fragment,null,C.createElement("p",null,"💿 Hey developer 👋"),C.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",C.createElement("code",{style:r},"ErrorBoundary")," or"," ",C.createElement("code",{style:r},"errorElement")," prop on your route.")),C.createElement(C.Fragment,null,C.createElement("h2",null,"Unexpected Application Error!"),C.createElement("h3",{style:{fontStyle:"italic"}},e),t?C.createElement("pre",{style:s},t):null,o)}var U4t=C.createElement(z4t,null),RPe=class extends C.Component{constructor(n){super(n),this.state={location:n.location,revalidation:n.revalidation,error:n.error}}static getDerivedStateFromError(n){return{error:n}}static getDerivedStateFromProps(n,e){return e.location!==n.location||e.revalidation!=="idle"&&n.revalidation==="idle"?{error:n.error,location:n.location,revalidation:n.revalidation}:{error:n.error!==void 0?n.error:e.error,location:e.location,revalidation:n.revalidation||e.revalidation}}componentDidCatch(n,e){this.props.onError?this.props.onError(n,e):console.error("React Router caught the following error during render",n)}render(){let n=this.state.error;if(this.context&&typeof n=="object"&&n&&"digest"in n&&typeof n.digest=="string"){const t=H4t(n.digest);t&&(n=t)}let e=n!==void 0?C.createElement(Tf.Provider,{value:this.props.routeContext},C.createElement(F3e.Provider,{value:n,children:this.props.component})):this.props.children;return this.context?C.createElement(K4t,{error:n},e):e}};RPe.contextType=P4t;var ZZ=new WeakMap;function K4t({children:n,error:e}){let{basename:t}=C.useContext(Dh);if(typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){let i=$4t(e.digest);if(i){let s=ZZ.get(e);if(s)throw s;let r=kPe(i.location,t);if(LPe&&!ZZ.get(e))if(r.isExternal||i.reloadDocument)window.location.href=r.absoluteURL||r.to;else{const o=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(r.to,{replace:i.replace}));throw ZZ.set(e,o),o}return C.createElement("meta",{httpEquiv:"refresh",content:`0;url=${r.absoluteURL||r.to}`})}}return n}function Z4t({routeContext:n,match:e,children:t}){let i=C.useContext(Qy);return i&&i.static&&i.staticContext&&(e.route.errorElement||e.route.ErrorBoundary)&&(i.staticContext._deepestRenderedBoundaryId=e.route.id),C.createElement(Tf.Provider,{value:n},t)}function q4t(n,e=[],t=null,i=null,s=null){if(n==null){if(!t)return null;if(t.errors)n=t.matches;else if(e.length===0&&!t.initialized&&t.matches.length>0)n=t.matches;else return null}let r=n,o=t==null?void 0:t.errors;if(o!=null){let d=r.findIndex(u=>u.route.id&&(o==null?void 0:o[u.route.id])!==void 0);Eo(d>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(o).join(",")}`),r=r.slice(0,Math.min(r.length,d+1))}let a=!1,l=-1;if(t)for(let d=0;d<r.length;d++){let u=r[d];if((u.route.HydrateFallback||u.route.hydrateFallbackElement)&&(l=d),u.route.id){let{loaderData:h,errors:f}=t,g=u.route.loader&&!h.hasOwnProperty(u.route.id)&&(!f||f[u.route.id]===void 0);if(u.route.lazy||g){a=!0,l>=0?r=r.slice(0,l+1):r=[r[0]];break}}}let c=t&&i?(d,u)=>{var h,f;i(d,{location:t.location,params:((f=(h=t.matches)==null?void 0:h[0])==null?void 0:f.params)??{},unstable_pattern:T4t(t.matches),errorInfo:u})}:void 0;return r.reduceRight((d,u,h)=>{let f,g=!1,m=null,p=null;t&&(f=o&&u.route.id?o[u.route.id]:void 0,m=u.route.errorElement||U4t,a&&(l<0&&h===0?(PPe("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),g=!0,p=null):l===h&&(g=!0,p=u.route.hydrateFallbackElement||null)));let _=e.concat(r.slice(0,h+1)),b=()=>{let y;return f?y=m:g?y=p:u.route.Component?y=C.createElement(u.route.Component,null):u.route.element?y=u.route.element:y=d,C.createElement(Z4t,{match:u,routeContext:{outlet:d,matches:_,isDataRoute:t!=null},children:y})};return t&&(u.route.ErrorBoundary||u.route.errorElement||h===0)?C.createElement(RPe,{location:t.location,revalidation:t.revalidation,component:m,error:f,children:b(),routeContext:{outlet:null,matches:_,isDataRoute:!0},onError:c}):b()},null)}function $3e(n){return`${n} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function G4t(n){let e=C.useContext(Qy);return Eo(e,$3e(n)),e}function X4t(n){let e=C.useContext(UW);return Eo(e,$3e(n)),e}function Y4t(n){let e=C.useContext(Tf);return Eo(e,$3e(n)),e}function H3e(n){let e=Y4t(n),t=e.matches[e.matches.length-1];return Eo(t.route.id,`${n} can only be used on routes that contain a unique "id"`),t.route.id}function Q4t(){return H3e("useRouteId")}function J4t(){var i;let n=C.useContext(F3e),e=X4t("useRouteError"),t=H3e("useRouteError");return n!==void 0?n:(i=e.errors)==null?void 0:i[t]}function eCt(){let{router:n}=G4t("useNavigate"),e=H3e("useNavigate"),t=C.useRef(!1);return DPe(()=>{t.current=!0}),C.useCallback(async(s,r={})=>{Sh(t.current,NPe),t.current&&(typeof s=="number"?await n.navigate(s):await n.navigate(s,{fromRouteId:e,...r}))},[n,e])}var z5e={};function PPe(n,e,t){!e&&!z5e[n]&&(z5e[n]=!0,Sh(!1,t))}C.memo(tCt);function tCt({routes:n,future:e,state:t,onError:i}){return TPe(n,void 0,t,i,e)}function l6(n){Eo(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function nCt({basename:n="/",children:e=null,location:t,navigationType:i="POP",navigator:s,static:r=!1,unstable_useTransitions:o}){Eo(!HM(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let a=n.replace(/^\/*/,"/"),l=C.useMemo(()=>({basename:a,navigator:s,static:r,unstable_useTransitions:o,future:{}}),[a,s,r,o]);typeof t=="string"&&(t=Yy(t));let{pathname:c="/",search:d="",hash:u="",state:h=null,key:f="default"}=t,g=C.useMemo(()=>{let m=S0(c,a);return m==null?null:{location:{pathname:m,search:d,hash:u,state:h,key:f},navigationType:i}},[a,c,d,u,h,f,i]);return Sh(g!=null,`<Router basename="${a}"> is not able to match the URL "${c}${d}${u}" because it does not start with the basename, so the <Router> won't render anything.`),g==null?null:C.createElement(Dh.Provider,{value:l},C.createElement($M.Provider,{children:e,value:g}))}function iCt({children:n,location:e}){return W4t(hee(n),e)}function hee(n,e=[]){let t=[];return C.Children.forEach(n,(i,s)=>{if(!C.isValidElement(i))return;let r=[...e,s];if(i.type===C.Fragment){t.push.apply(t,hee(i.props.children,r));return}Eo(i.type===l6,`[${typeof i.type=="string"?i.type:i.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),Eo(!i.props.index||!i.props.children,"An index route cannot have child routes.");let o={id:i.props.id||r.join("-"),caseSensitive:i.props.caseSensitive,element:i.props.element,Component:i.props.Component,index:i.props.index,path:i.props.path,middleware:i.props.middleware,loader:i.props.loader,action:i.props.action,hydrateFallbackElement:i.props.hydrateFallbackElement,HydrateFallback:i.props.HydrateFallback,errorElement:i.props.errorElement,ErrorBoundary:i.props.ErrorBoundary,hasErrorBoundary:i.props.hasErrorBoundary===!0||i.props.ErrorBoundary!=null||i.props.errorElement!=null,shouldRevalidate:i.props.shouldRevalidate,handle:i.props.handle,lazy:i.props.lazy};i.props.children&&(o.children=hee(i.props.children,r)),t.push(o)}),t}var hP="get",fP="application/x-www-form-urlencoded";function KW(n){return typeof HTMLElement<"u"&&n instanceof HTMLElement}function sCt(n){return KW(n)&&n.tagName.toLowerCase()==="button"}function rCt(n){return KW(n)&&n.tagName.toLowerCase()==="form"}function oCt(n){return KW(n)&&n.tagName.toLowerCase()==="input"}function aCt(n){return!!(n.metaKey||n.altKey||n.ctrlKey||n.shiftKey)}function lCt(n,e){return n.button===0&&(!e||e==="_self")&&!aCt(n)}function fee(n=""){return new URLSearchParams(typeof n=="string"||Array.isArray(n)||n instanceof URLSearchParams?n:Object.keys(n).reduce((e,t)=>{let i=n[t];return e.concat(Array.isArray(i)?i.map(s=>[t,s]):[[t,i]])},[]))}function cCt(n,e){let t=fee(n);return e&&e.forEach((i,s)=>{t.has(s)||e.getAll(s).forEach(r=>{t.append(s,r)})}),t}var OD=null;function dCt(){if(OD===null)try{new FormData(document.createElement("form"),0),OD=!1}catch{OD=!0}return OD}var uCt=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function qZ(n){return n!=null&&!uCt.has(n)?(Sh(!1,`"${n}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${fP}"`),null):n}function hCt(n,e){let t,i,s,r,o;if(rCt(n)){let a=n.getAttribute("action");i=a?S0(a,e):null,t=n.getAttribute("method")||hP,s=qZ(n.getAttribute("enctype"))||fP,r=new FormData(n)}else if(sCt(n)||oCt(n)&&(n.type==="submit"||n.type==="image")){let a=n.form;if(a==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let l=n.getAttribute("formaction")||a.getAttribute("action");if(i=l?S0(l,e):null,t=n.getAttribute("formmethod")||a.getAttribute("method")||hP,s=qZ(n.getAttribute("formenctype"))||qZ(a.getAttribute("enctype"))||fP,r=new FormData(a,n),!dCt()){let{name:c,type:d,value:u}=n;if(d==="image"){let h=c?`${c}.`:"";r.append(`${h}x`,"0"),r.append(`${h}y`,"0")}else c&&r.append(c,u)}}else{if(KW(n))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');t=hP,i=null,s=fP,o=n}return r&&s==="text/plain"&&(o=r,r=void 0),{action:i,method:t.toLowerCase(),encType:s,formData:r,body:o}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function V3e(n,e){if(n===!1||n===null||typeof n>"u")throw new Error(e)}function fCt(n,e,t,i){let s=typeof n=="string"?new URL(n,typeof window>"u"?"server://singlefetch/":window.location.origin):n;return t?s.pathname.endsWith("/")?s.pathname=`${s.pathname}_.${i}`:s.pathname=`${s.pathname}.${i}`:s.pathname==="/"?s.pathname=`_root.${i}`:e&&S0(s.pathname,e)==="/"?s.pathname=`${e.replace(/\/$/,"")}/_root.${i}`:s.pathname=`${s.pathname.replace(/\/$/,"")}.${i}`,s}async function gCt(n,e){if(n.id in e)return e[n.id];try{let t=await import(n.module);return e[n.id]=t,t}catch(t){return console.error(`Error loading route module \`${n.module}\`, reloading page...`),console.error(t),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function mCt(n){return n==null?!1:n.href==null?n.rel==="preload"&&typeof n.imageSrcSet=="string"&&typeof n.imageSizes=="string":typeof n.rel=="string"&&typeof n.href=="string"}async function pCt(n,e,t){let i=await Promise.all(n.map(async s=>{let r=e.routes[s.route.id];if(r){let o=await gCt(r,t);return o.links?o.links():[]}return[]}));return bCt(i.flat(1).filter(mCt).filter(s=>s.rel==="stylesheet"||s.rel==="preload").map(s=>s.rel==="stylesheet"?{...s,rel:"prefetch",as:"style"}:{...s,rel:"prefetch"}))}function U5e(n,e,t,i,s,r){let o=(l,c)=>t[c]?l.route.id!==t[c].route.id:!0,a=(l,c)=>{var d;return t[c].pathname!==l.pathname||((d=t[c].route.path)==null?void 0:d.endsWith("*"))&&t[c].params["*"]!==l.params["*"]};return r==="assets"?e.filter((l,c)=>o(l,c)||a(l,c)):r==="data"?e.filter((l,c)=>{var u;let d=i.routes[l.route.id];if(!d||!d.hasLoader)return!1;if(o(l,c)||a(l,c))return!0;if(l.route.shouldRevalidate){let h=l.route.shouldRevalidate({currentUrl:new URL(s.pathname+s.search+s.hash,window.origin),currentParams:((u=t[0])==null?void 0:u.params)||{},nextUrl:new URL(n,window.origin),nextParams:l.params,defaultShouldRevalidate:!0});if(typeof h=="boolean")return h}return!0}):[]}function CCt(n,e,{includeHydrateFallback:t}={}){return _Ct(n.map(i=>{let s=e.routes[i.route.id];if(!s)return[];let r=[s.module];return s.clientActionModule&&(r=r.concat(s.clientActionModule)),s.clientLoaderModule&&(r=r.concat(s.clientLoaderModule)),t&&s.hydrateFallbackModule&&(r=r.concat(s.hydrateFallbackModule)),s.imports&&(r=r.concat(s.imports)),r}).flat(1))}function _Ct(n){return[...new Set(n)]}function vCt(n){let e={},t=Object.keys(n).sort();for(let i of t)e[i]=n[i];return e}function bCt(n,e){let t=new Set;return new Set(e),n.reduce((i,s)=>{let r=JSON.stringify(vCt(s));return t.has(r)||(t.add(r),i.push({key:r,link:s})),i},[])}function APe(){let n=C.useContext(Qy);return V3e(n,"You must render this element inside a <DataRouterContext.Provider> element"),n}function yCt(){let n=C.useContext(UW);return V3e(n,"You must render this element inside a <DataRouterStateContext.Provider> element"),n}var j3e=C.createContext(void 0);j3e.displayName="FrameworkContext";function OPe(){let n=C.useContext(j3e);return V3e(n,"You must render this element inside a <HydratedRouter> element"),n}function wCt(n,e){let t=C.useContext(j3e),[i,s]=C.useState(!1),[r,o]=C.useState(!1),{onFocus:a,onBlur:l,onMouseEnter:c,onMouseLeave:d,onTouchStart:u}=e,h=C.useRef(null);C.useEffect(()=>{if(n==="render"&&o(!0),n==="viewport"){let m=_=>{_.forEach(b=>{o(b.isIntersecting)})},p=new IntersectionObserver(m,{threshold:.5});return h.current&&p.observe(h.current),()=>{p.disconnect()}}},[n]),C.useEffect(()=>{if(i){let m=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(m)}}},[i]);let f=()=>{s(!0)},g=()=>{s(!1),o(!1)};return t?n!=="intent"?[r,h,{}]:[r,h,{onFocus:Xw(a,f),onBlur:Xw(l,g),onMouseEnter:Xw(c,f),onMouseLeave:Xw(d,g),onTouchStart:Xw(u,f)}]:[!1,h,{}]}function Xw(n,e){return t=>{n&&n(t),t.defaultPrevented||e(t)}}function SCt({page:n,...e}){let{router:t}=APe(),i=C.useMemo(()=>vPe(t.routes,n,t.basename),[t.routes,n,t.basename]);return i?C.createElement(LCt,{page:n,matches:i,...e}):null}function xCt(n){let{manifest:e,routeModules:t}=OPe(),[i,s]=C.useState([]);return C.useEffect(()=>{let r=!1;return pCt(n,e,t).then(o=>{r||s(o)}),()=>{r=!0}},[n,e,t]),i}function LCt({page:n,matches:e,...t}){let i=E3(),{future:s,manifest:r,routeModules:o}=OPe(),{basename:a}=APe(),{loaderData:l,matches:c}=yCt(),d=C.useMemo(()=>U5e(n,e,c,r,i,"data"),[n,e,c,r,i]),u=C.useMemo(()=>U5e(n,e,c,r,i,"assets"),[n,e,c,r,i]),h=C.useMemo(()=>{if(n===i.pathname+i.search+i.hash)return[];let m=new Set,p=!1;if(e.forEach(b=>{var w;let y=r.routes[b.route.id];!y||!y.hasLoader||(!d.some(S=>S.route.id===b.route.id)&&b.route.id in l&&((w=o[b.route.id])!=null&&w.shouldRevalidate)||y.hasClientLoader?p=!0:m.add(b.route.id))}),m.size===0)return[];let _=fCt(n,a,s.unstable_trailingSlashAwareDataRequests,"data");return p&&m.size>0&&_.searchParams.set("_routes",e.filter(b=>m.has(b.route.id)).map(b=>b.route.id).join(",")),[_.pathname+_.search]},[a,s.unstable_trailingSlashAwareDataRequests,l,i,r,d,e,n,o]),f=C.useMemo(()=>CCt(u,r),[u,r]),g=xCt(u);return C.createElement(C.Fragment,null,h.map(m=>C.createElement("link",{key:m,rel:"prefetch",as:"fetch",href:m,...t})),f.map(m=>C.createElement("link",{key:m,rel:"modulepreload",href:m,...t})),g.map(({key:m,link:p})=>C.createElement("link",{key:m,nonce:t.nonce,...p})))}function kCt(...n){return e=>{n.forEach(t=>{typeof t=="function"?t(e):t!=null&&(t.current=e)})}}var ECt=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{ECt&&(window.__reactRouterVersion="7.12.0")}catch{}function ICt({basename:n,children:e,unstable_useTransitions:t,window:i}){let s=C.useRef();s.current==null&&(s.current=a4t({window:i,v5Compat:!0}));let r=s.current,[o,a]=C.useState({action:r.action,location:r.location}),l=C.useCallback(c=>{t===!1?a(c):C.startTransition(()=>a(c))},[t]);return C.useLayoutEffect(()=>r.listen(l),[r,l]),C.createElement(nCt,{basename:n,children:e,location:o.location,navigationType:o.action,navigator:r,unstable_useTransitions:t})}var FPe=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,BPe=C.forwardRef(function({onClick:e,discover:t="render",prefetch:i="none",relative:s,reloadDocument:r,replace:o,state:a,target:l,to:c,preventScrollReset:d,viewTransition:u,unstable_defaultShouldRevalidate:h,...f},g){let{basename:m,unstable_useTransitions:p}=C.useContext(Dh),_=typeof c=="string"&&FPe.test(c),b=kPe(c,m);c=b.to;let y=V4t(c,{relative:s}),[w,S,x]=wCt(i,f),L=TCt(c,{replace:o,state:a,target:l,preventScrollReset:d,relative:s,viewTransition:u,unstable_defaultShouldRevalidate:h,unstable_useTransitions:p});function E(M){e&&e(M),M.defaultPrevented||L(M)}let I=C.createElement("a",{...f,...x,href:b.absoluteURL||y,onClick:b.isExternal||r?e:E,ref:kCt(g,S),target:l,"data-discover":!_&&t==="render"?"true":void 0});return w&&!_?C.createElement(C.Fragment,null,I,C.createElement(SCt,{page:y})):I});BPe.displayName="Link";var MCt=C.forwardRef(function({"aria-current":e="page",caseSensitive:t=!1,className:i="",end:s=!1,style:r,to:o,viewTransition:a,children:l,...c},d){let u=VM(o,{relative:c.relative}),h=E3(),f=C.useContext(UW),{navigator:g,basename:m}=C.useContext(Dh),p=f!=null&&FCt(u)&&a===!0,_=g.encodeLocation?g.encodeLocation(u).pathname:u.pathname,b=h.pathname,y=f&&f.navigation&&f.navigation.location?f.navigation.location.pathname:null;t||(b=b.toLowerCase(),y=y?y.toLowerCase():null,_=_.toLowerCase()),y&&m&&(y=S0(y,m)||y);const w=_!=="/"&&_.endsWith("/")?_.length-1:_.length;let S=b===_||!s&&b.startsWith(_)&&b.charAt(w)==="/",x=y!=null&&(y===_||!s&&y.startsWith(_)&&y.charAt(_.length)==="/"),L={isActive:S,isPending:x,isTransitioning:p},E=S?e:void 0,I;typeof i=="function"?I=i(L):I=[i,S?"active":null,x?"pending":null,p?"transitioning":null].filter(Boolean).join(" ");let M=typeof r=="function"?r(L):r;return C.createElement(BPe,{...c,"aria-current":E,className:I,ref:d,style:M,to:o,viewTransition:a},typeof l=="function"?l(L):l)});MCt.displayName="NavLink";var NCt=C.forwardRef(({discover:n="render",fetcherKey:e,navigate:t,reloadDocument:i,replace:s,state:r,method:o=hP,action:a,onSubmit:l,relative:c,preventScrollReset:d,viewTransition:u,unstable_defaultShouldRevalidate:h,...f},g)=>{let{unstable_useTransitions:m}=C.useContext(Dh),p=ACt(),_=OCt(a,{relative:c}),b=o.toLowerCase()==="get"?"get":"post",y=typeof a=="string"&&FPe.test(a),w=S=>{if(l&&l(S),S.defaultPrevented)return;S.preventDefault();let x=S.nativeEvent.submitter,L=(x==null?void 0:x.getAttribute("formmethod"))||o,E=()=>p(x||S.currentTarget,{fetcherKey:e,method:L,navigate:t,replace:s,state:r,relative:c,preventScrollReset:d,viewTransition:u,unstable_defaultShouldRevalidate:h});m&&t!==!1?C.startTransition(()=>E()):E()};return C.createElement("form",{ref:g,method:b,action:_,onSubmit:i?l:w,...f,"data-discover":!y&&n==="render"?"true":void 0})});NCt.displayName="Form";function DCt(n){return`${n} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function $Pe(n){let e=C.useContext(Qy);return Eo(e,DCt(n)),e}function TCt(n,{target:e,replace:t,state:i,preventScrollReset:s,relative:r,viewTransition:o,unstable_defaultShouldRevalidate:a,unstable_useTransitions:l}={}){let c=Iu(),d=E3(),u=VM(n,{relative:r});return C.useCallback(h=>{if(lCt(h,e)){h.preventDefault();let f=t!==void 0?t:tE(d)===tE(u),g=()=>c(n,{replace:f,state:i,preventScrollReset:s,relative:r,viewTransition:o,unstable_defaultShouldRevalidate:a});l?C.startTransition(()=>g()):g()}},[d,c,u,t,i,e,n,s,r,o,a,l])}function qm(n){Sh(typeof URLSearchParams<"u","You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let e=C.useRef(fee(n)),t=C.useRef(!1),i=E3(),s=C.useMemo(()=>cCt(i.search,t.current?null:e.current),[i.search]),r=Iu(),o=C.useCallback((a,l)=>{const c=fee(typeof a=="function"?a(new URLSearchParams(s)):a);t.current=!0,r("?"+c,l)},[r,s]);return[s,o]}var RCt=0,PCt=()=>`__${String(++RCt)}__`;function ACt(){let{router:n}=$Pe("useSubmit"),{basename:e}=C.useContext(Dh),t=Q4t(),i=n.fetch,s=n.navigate;return C.useCallback(async(r,o={})=>{let{action:a,method:l,encType:c,formData:d,body:u}=hCt(r,e);if(o.navigate===!1){let h=o.fetcherKey||PCt();await i(h,t,o.action||a,{unstable_defaultShouldRevalidate:o.unstable_defaultShouldRevalidate,preventScrollReset:o.preventScrollReset,formData:d,body:u,formMethod:o.method||l,formEncType:o.encType||c,flushSync:o.flushSync})}else await s(o.action||a,{unstable_defaultShouldRevalidate:o.unstable_defaultShouldRevalidate,preventScrollReset:o.preventScrollReset,formData:d,body:u,formMethod:o.method||l,formEncType:o.encType||c,replace:o.replace,state:o.state,fromRouteId:t,flushSync:o.flushSync,viewTransition:o.viewTransition})},[i,s,e,t])}function OCt(n,{relative:e}={}){let{basename:t}=C.useContext(Dh),i=C.useContext(Tf);Eo(i,"useFormAction must be used inside a RouteContext");let[s]=i.matches.slice(-1),r={...VM(n||".",{relative:e})},o=E3();if(n==null){r.search=o.search;let a=new URLSearchParams(r.search),l=a.getAll("index");if(l.some(d=>d==="")){a.delete("index"),l.filter(u=>u).forEach(u=>a.append("index",u));let d=a.toString();r.search=d?`?${d}`:""}}return(!n||n===".")&&s.route.index&&(r.search=r.search?r.search.replace(/^\?/,"?index&"):"?index"),t!=="/"&&(r.pathname=r.pathname==="/"?t:s0([t,r.pathname])),tE(r)}function FCt(n,{relative:e}={}){let t=C.useContext(IPe);Eo(t!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:i}=$Pe("useViewTransitionState"),s=VM(n,{relative:e});if(!t.isTransitioning)return!1;let r=S0(t.currentLocation.pathname,i)||t.currentLocation.pathname,o=S0(t.nextLocation.pathname,i)||t.nextLocation.pathname;return sf(s.pathname,o)!=null||sf(s.pathname,r)!=null}const HPe=0,VPe=1,jPe=2,K5e=3;var Z5e=Object.prototype.hasOwnProperty;function gee(n,e){var t,i;if(n===e)return!0;if(n&&e&&(t=n.constructor)===e.constructor){if(t===Date)return n.getTime()===e.getTime();if(t===RegExp)return n.toString()===e.toString();if(t===Array){if((i=n.length)===e.length)for(;i--&&gee(n[i],e[i]););return i===-1}if(!t||typeof n=="object"){i=0;for(t in n)if(Z5e.call(n,t)&&++i&&!Z5e.call(e,t)||!(t in e)||!gee(n[t],e[t]))return!1;return Object.keys(e).length===i}}return n!==n&&e!==e}const k2=new WeakMap,O2=()=>{},Yl=O2(),_O=Object,Fs=n=>n===Yl,u1=n=>typeof n=="function",x0=(n,e)=>({...n,...e}),WPe=n=>u1(n.then),GZ={},FD={},W3e="undefined",jM=typeof window!=W3e,mee=typeof document!=W3e,BCt=jM&&"Deno"in window,$Ct=()=>jM&&typeof window.requestAnimationFrame!=W3e,zPe=(n,e)=>{const t=k2.get(n);return[()=>!Fs(e)&&n.get(e)||GZ,i=>{if(!Fs(e)){const s=n.get(e);e in FD||(FD[e]=s),t[5](e,x0(s,i),s||GZ)}},t[6],()=>!Fs(e)&&e in FD?FD[e]:!Fs(e)&&n.get(e)||GZ]};let pee=!0;const HCt=()=>pee,[Cee,_ee]=jM&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[O2,O2],VCt=()=>{const n=mee&&document.visibilityState;return Fs(n)||n!=="hidden"},jCt=n=>(mee&&document.addEventListener("visibilitychange",n),Cee("focus",n),()=>{mee&&document.removeEventListener("visibilitychange",n),_ee("focus",n)}),WCt=n=>{const e=()=>{pee=!0,n()},t=()=>{pee=!1};return Cee("online",e),Cee("offline",t),()=>{_ee("online",e),_ee("offline",t)}},zCt={isOnline:HCt,isVisible:VCt},UCt={initFocus:jCt,initReconnect:WCt},q5e=!te.useId,pv=!jM||BCt,KCt=n=>$Ct()?window.requestAnimationFrame(n):setTimeout(n,1),gP=pv?C.useEffect:C.useLayoutEffect,XZ=typeof navigator<"u"&&navigator.connection,G5e=!pv&&XZ&&(["slow-2g","2g"].includes(XZ.effectiveType)||XZ.saveData),BD=new WeakMap,ZCt=n=>_O.prototype.toString.call(n),YZ=(n,e)=>n===`[object ${e}]`;let qCt=0;const vee=n=>{const e=typeof n,t=ZCt(n),i=YZ(t,"Date"),s=YZ(t,"RegExp"),r=YZ(t,"Object");let o,a;if(_O(n)===n&&!i&&!s){if(o=BD.get(n),o)return o;if(o=++qCt+"~",BD.set(n,o),Array.isArray(n)){for(o="@",a=0;a<n.length;a++)o+=vee(n[a])+",";BD.set(n,o)}if(r){o="#";const l=_O.keys(n).sort();for(;!Fs(a=l.pop());)Fs(n[a])||(o+=a+":"+vee(n[a])+",");BD.set(n,o)}}else o=i?n.toJSON():e=="symbol"?n.toString():e=="string"?JSON.stringify(n):""+n;return o},z3e=n=>{if(u1(n))try{n=n()}catch{n=""}const e=n;return n=typeof n=="string"?n:(Array.isArray(n)?n.length:n)?vee(n):"",[n,e]};let GCt=0;const bee=()=>++GCt;async function UPe(...n){const[e,t,i,s]=n,r=x0({populateCache:!0,throwOnError:!0},typeof s=="boolean"?{revalidate:s}:s||{});let o=r.populateCache;const a=r.rollbackOnError;let l=r.optimisticData;const c=h=>typeof a=="function"?a(h):a!==!1,d=r.throwOnError;if(u1(t)){const h=t,f=[],g=e.keys();for(const m of g)!/^\$(inf|sub)\$/.test(m)&&h(e.get(m)._k)&&f.push(m);return Promise.all(f.map(u))}return u(t);async function u(h){const[f]=z3e(h);if(!f)return;const[g,m]=zPe(e,f),[p,_,b,y]=k2.get(e),w=()=>{const P=p[f];return(u1(r.revalidate)?r.revalidate(g().data,h):r.revalidate!==!1)&&(delete b[f],delete y[f],P&&P[0])?P[0](jPe).then(()=>g().data):g().data};if(n.length<3)return w();let S=i,x,L=!1;const E=bee();_[f]=[E,0];const I=!Fs(l),M=g(),N=M.data,T=M._c,D=Fs(T)?N:T;if(I&&(l=u1(l)?l(D,N):l,m({data:l,_c:D})),u1(S))try{S=S(D)}catch(P){x=P,L=!0}if(S&&WPe(S))if(S=await S.catch(P=>{x=P,L=!0}),E!==_[f][0]){if(L)throw x;return S}else L&&I&&c(x)&&(o=!0,m({data:D,_c:Yl}));if(o&&!L)if(u1(o)){const P=o(S,D);m({data:P,error:Yl,_c:Yl})}else m({data:S,error:Yl,_c:Yl});if(_[f][1]=bee(),Promise.resolve(w()).then(()=>{m({_c:Yl})}),L){if(d)throw x;return}return S}}const X5e=(n,e)=>{for(const t in n)n[t][0]&&n[t][0](e)},KPe=(n,e)=>{if(!k2.has(n)){const t=x0(UCt,e),i=Object.create(null),s=UPe.bind(Yl,n);let r=O2;const o=Object.create(null),a=(d,u)=>{const h=o[d]||[];return o[d]=h,h.push(u),()=>h.splice(h.indexOf(u),1)},l=(d,u,h)=>{n.set(d,u);const f=o[d];if(f)for(const g of f)g(u,h)},c=()=>{if(!k2.has(n)&&(k2.set(n,[i,Object.create(null),Object.create(null),Object.create(null),s,l,a]),!pv)){const d=t.initFocus(setTimeout.bind(Yl,X5e.bind(Yl,i,HPe))),u=t.initReconnect(setTimeout.bind(Yl,X5e.bind(Yl,i,VPe)));r=()=>{d&&d(),u&&u(),k2.delete(n)}}};return c(),[n,s,c,r]}return[n,k2.get(n)[4]]},XCt=(n,e,t,i,s)=>{const r=t.errorRetryCount,o=s.retryCount,a=~~((Math.random()+.5)*(1<<(o<8?o:8)))*t.errorRetryInterval;!Fs(r)&&o>r||setTimeout(i,a,s)},YCt=gee,[U3e,QCt]=KPe(new Map),ZPe=x0({onLoadingSlow:O2,onSuccess:O2,onError:O2,onErrorRetry:XCt,onDiscarded:O2,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:G5e?1e4:5e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:G5e?5e3:3e3,compare:YCt,isPaused:()=>!1,cache:U3e,mutate:QCt,fallback:{}},zCt),qPe=(n,e)=>{const t=x0(n,e);if(e){const{use:i,fallback:s}=n,{use:r,fallback:o}=e;i&&r&&(t.use=i.concat(r)),s&&o&&(t.fallback=x0(s,o))}return t},yee=C.createContext({}),JCt=n=>{const{value:e}=n,t=C.useContext(yee),i=u1(e),s=C.useMemo(()=>i?e(t):e,[i,t,e]),r=C.useMemo(()=>i?s:qPe(t,s),[i,t,s]),o=s&&s.provider,a=C.useRef(Yl);o&&!a.current&&(a.current=KPe(o(r.cache||U3e),s));const l=a.current;return l&&(r.cache=l[0],r.mutate=l[1]),gP(()=>{if(l)return l[2]&&l[2](),l[3]},[]),C.createElement(yee.Provider,x0(n,{value:r}))},e7t="$inf$",GPe=jM&&window.__SWR_DEVTOOLS_USE__,t7t=GPe?window.__SWR_DEVTOOLS_USE__:[],n7t=()=>{GPe&&(window.__SWR_DEVTOOLS_REACT__=te)},i7t=n=>u1(n[1])?[n[0],n[1],n[2]||{}]:[n[0],null,(n[1]===null?n[2]:n[1])||{}],Jy=()=>{const n=C.useContext(yee);return C.useMemo(()=>x0(ZPe,n),[n])},s7t=n=>(e,t,i)=>n(e,t&&((...r)=>{const[o]=z3e(e),[,,,a]=k2.get(U3e);if(o.startsWith(e7t))return t(...r);const l=a[o];return Fs(l)?t(...r):(delete a[o],l)}),i),r7t=t7t.concat(s7t),o7t=n=>function(...t){const i=Jy(),[s,r,o]=i7t(t),a=qPe(i,o);let l=n;const{use:c}=a,d=(c||[]).concat(r7t);for(let u=d.length;u--;)l=d[u](l);return l(s,r||a.fetcher||null,a)},a7t=(n,e,t)=>{const i=e[n]||(e[n]=[]);return i.push(t),()=>{const s=i.indexOf(t);s>=0&&(i[s]=i[i.length-1],i.pop())}};n7t();const QZ=te.use||(n=>{switch(n.status){case"pending":throw n;case"fulfilled":return n.value;case"rejected":throw n.reason;default:throw n.status="pending",n.then(e=>{n.status="fulfilled",n.value=e},e=>{n.status="rejected",n.reason=e}),n}}),JZ={dedupe:!0},Y5e=Promise.resolve(Yl),l7t=(n,e,t)=>{const{cache:i,compare:s,suspense:r,fallbackData:o,revalidateOnMount:a,revalidateIfStale:l,refreshInterval:c,refreshWhenHidden:d,refreshWhenOffline:u,keepPreviousData:h,strictServerPrefetchWarning:f}=t,[g,m,p,_]=k2.get(i),[b,y]=z3e(n),w=C.useRef(!1),S=C.useRef(!1),x=C.useRef(b),L=C.useRef(e),E=C.useRef(t),I=()=>E.current,M=()=>I().isVisible()&&I().isOnline(),[N,T,D,P]=zPe(i,b),R=C.useRef({}).current,A=Fs(o)?Fs(t.fallback)?Yl:t.fallback[b]:o,O=(ce,oe)=>{for(const he in R){const ye=he;if(ye==="data"){if(!s(ce[ye],oe[ye])&&(!Fs(ce[ye])||!s(G,oe[ye])))return!1}else if(oe[ye]!==ce[ye])return!1}return!0},F=C.useMemo(()=>{const ce=!b||!e?!1:Fs(a)?I().isPaused()||r?!1:l!==!1:a,oe=we=>{const ve=x0(we);return delete ve._k,ce?{isValidating:!0,isLoading:!0,...ve}:ve},he=N(),ye=P(),ke=oe(he),Ce=he===ye?ke:oe(ye);let Se=ke;return[()=>{const we=oe(N());return O(we,Se)?(Se.data=we.data,Se.isLoading=we.isLoading,Se.isValidating=we.isValidating,Se.error=we.error,Se):(Se=we,we)},()=>Ce]},[i,b]),$=JY.useSyncExternalStore(C.useCallback(ce=>D(b,(oe,he)=>{O(he,oe)||ce()}),[i,b]),F[0],F[1]),B=!w.current,V=g[b]&&g[b].length>0,W=$.data,H=Fs(W)?A&&WPe(A)?QZ(A):A:W,U=$.error,Z=C.useRef(H),G=h?Fs(W)?Fs(Z.current)?H:Z.current:W:H,q=b&&Fs(H),K=!pv&&JY.useSyncExternalStore(()=>O2,()=>!1,()=>!0);f&&K&&!r&&q&&console.warn(`Missing pre-initiated data for serialized key "${b}" during server-side rendering. Data fethcing should be initiated on the server and provided to SWR via fallback data. You can set "strictServerPrefetchWarning: false" to disable this warning.`);const X=V&&!Fs(U)?!1:B&&!Fs(a)?a:I().isPaused()?!1:r?Fs(H)?!1:l:Fs(H)||l,ie=!!(b&&e&&B&&X),se=Fs($.isValidating)?ie:$.isValidating,J=Fs($.isLoading)?ie:$.isLoading,le=C.useCallback(async ce=>{const oe=L.current;if(!b||!oe||S.current||I().isPaused())return!1;let he,ye,ke=!0;const Ce=ce||{},Se=!p[b]||!Ce.dedupe,we=()=>q5e?!S.current&&b===x.current&&w.current:b===x.current,ve={isValidating:!1,isLoading:!1},Ee=()=>{T(ve)},me=()=>{const Oe=p[b];Oe&&Oe[1]===ye&&delete p[b]},xe={isValidating:!0};Fs(N().data)&&(xe.isLoading=!0);try{if(Se&&(T(xe),t.loadingTimeout&&Fs(N().data)&&setTimeout(()=>{ke&&we()&&I().onLoadingSlow(b,t)},t.loadingTimeout),p[b]=[oe(y),bee()]),[he,ye]=p[b],he=await he,Se&&setTimeout(me,t.dedupingInterval),!p[b]||p[b][1]!==ye)return Se&&we()&&I().onDiscarded(b),!1;ve.error=Yl;const Oe=m[b];if(!Fs(Oe)&&(ye<=Oe[0]||ye<=Oe[1]||Oe[1]===0))return Ee(),Se&&we()&&I().onDiscarded(b),!1;const We=N().data;ve.data=s(We,he)?We:he,Se&&we()&&I().onSuccess(he,b,t)}catch(Oe){me();const We=I(),{shouldRetryOnError:Ke}=We;We.isPaused()||(ve.error=Oe,Se&&we()&&(We.onError(Oe,b,We),(Ke===!0||u1(Ke)&&Ke(Oe))&&(!I().revalidateOnFocus||!I().revalidateOnReconnect||M())&&We.onErrorRetry(Oe,b,We,ze=>{const Ve=g[b];Ve&&Ve[0]&&Ve[0](K5e,ze)},{retryCount:(Ce.retryCount||0)+1,dedupe:!0})))}return ke=!1,Ee(),!0},[b,i]),be=C.useCallback((...ce)=>UPe(i,x.current,...ce),[]);if(gP(()=>{L.current=e,E.current=t,Fs(W)||(Z.current=W)}),gP(()=>{if(!b)return;const ce=le.bind(Yl,JZ);let oe=0;I().revalidateOnFocus&&(oe=Date.now()+I().focusThrottleInterval);const ye=a7t(b,g,(ke,Ce={})=>{if(ke==HPe){const Se=Date.now();I().revalidateOnFocus&&Se>oe&&M()&&(oe=Se+I().focusThrottleInterval,ce())}else if(ke==VPe)I().revalidateOnReconnect&&M()&&ce();else{if(ke==jPe)return le();if(ke==K5e)return le(Ce)}});return S.current=!1,x.current=b,w.current=!0,T({_k:y}),X&&(p[b]||(Fs(H)||pv?ce():KCt(ce))),()=>{S.current=!0,ye()}},[b]),gP(()=>{let ce;function oe(){const ye=u1(c)?c(N().data):c;ye&&ce!==-1&&(ce=setTimeout(he,ye))}function he(){!N().error&&(d||I().isVisible())&&(u||I().isOnline())?le(JZ).then(oe):oe()}return oe(),()=>{ce&&(clearTimeout(ce),ce=-1)}},[c,d,u,b]),C.useDebugValue(G),r){if(!q5e&&pv&&q)throw new Error("Fallback data is required when using Suspense in SSR.");q&&(L.current=e,E.current=t,S.current=!1);const ce=_[b],oe=!Fs(ce)&&q?be(ce):Y5e;if(QZ(oe),!Fs(U)&&q)throw U;const he=q?le(JZ):Y5e;!Fs(G)&&q&&(he.status="fulfilled",he.value=!0),QZ(he)}return{mutate:be,get data(){return R.data=!0,G},get error(){return R.error=!0,U},get isValidating(){return R.isValidating=!0,se},get isLoading(){return R.isLoading=!0,J}}},c7t=_O.defineProperty(JCt,"defaultValue",{value:ZPe}),Gn=o7t(l7t),K3e="vf_server_base_url",Z3e="vf_server_connection_picker_requested",d7t=(n,e)=>(n.trim()===""?"Vibe Forge Web":n.trim()).replace(/\s+\[[^\]]+\]$/,""),u7t=()=>globalThis.__VF_PROJECT_AI_RUNTIME_ENV__,XPe=(...n)=>n.find(e=>typeof e=="string"&&e.trim()!==""),h7t=n=>{let e=(n==null?void 0:n.trim())??"/ui";return e.startsWith("/")||(e=`/${e}`),e.length>1&&e.endsWith("/")&&(e=e.slice(0,-1)),e},f7t=n=>{let e=(n==null?void 0:n.trim())??"";return e?(e.startsWith("/")||(e=`/${e}`),e):"/ws"},g7t=n=>{const e=n==null?void 0:n.trim();if(!(e==null||e===""||e==="0.0.0.0"||e==="::"||e==="[::]"))return e},m7t=n=>/^[a-z][a-z\d+.-]*:\/\//i.test(n),ew=()=>{try{return globalThis.localStorage}catch{return}},YPe=()=>{var n;return((n=globalThis.location)==null?void 0:n.protocol)==="https:"?"https":"http"},QPe=()=>{var n;return(n=XPe(Gm().__VF_PROJECT_AI_CLIENT_MODE__,void 0,void 0))==null?void 0:n.trim().toLowerCase()},xd=n=>{const e=(n==null?void 0:n.trim())??"";if(e==="")return;const t=m7t(e)?e:`${YPe()}://${e}`;try{const i=new URL(t);return i.protocol!=="http:"&&i.protocol!=="https:"?void 0:(i.hash="",i.search="",i.toString().replace(/\/$/,""))}catch{return}},JPe=(n,e)=>{const t=xd(n);if(t==null)throw new Error("Invalid server base URL");const i=e.replace(/^\/+/,"");return new URL(i,`${t}/`).toString()},eAe=()=>{var n;return xd(((n=ew())==null?void 0:n.getItem(K3e))??void 0)},p7t=n=>{var t;const e=xd(n);if(e!=null)return(t=ew())==null||t.setItem(K3e,e),e},C7t=()=>{var n;(n=ew())==null||n.removeItem(K3e)},_7t=()=>QPe()==="desktop",ZW=()=>{const n=QPe();return n==="standalone"||n==="independent"||n==="desktop"},Gm=()=>u7t()??{},v7t=(...n)=>h7t(XPe(...n)),qW=()=>v7t(Gm().__VF_PROJECT_AI_CLIENT_BASE__,void 0,"/__VF_PROJECT_AI_CLIENT_BASE__/","/ui"),tAe=()=>g7t(Gm().__VF_PROJECT_AI_SERVER_HOST__??void 0),nAe=()=>Gm().__VF_PROJECT_AI_SERVER_PORT__??void 0,iAe=()=>{var i;const n=xd(Gm().__VF_PROJECT_AI_SERVER_BASE_URL__??void 0);if(n!=null)return n;const e=tAe(),t=(i=nAe())==null?void 0:i.trim();if(!(e==null||t==null||t===""))return xd(`${e}:${t}`)},b7t=()=>{var n;return((n=ew())==null?void 0:n.getItem(Z3e))==="true"},sAe=({clearCurrentServer:n=!1}={})=>{var e;n&&C7t(),(e=ew())==null||e.setItem(Z3e,"true")},y7t=()=>{var n;(n=ew())==null||n.removeItem(Z3e)},w7t=()=>f7t(Gm().__VF_PROJECT_AI_SERVER_WS_PATH__??void 0),WM=()=>{var i;if(ZW()){const s=eAe();if(s!=null)return s}const n=iAe();if(n!=null)return n;const e=tAe()??((i=globalThis.location)==null?void 0:i.hostname)??"localhost",t=nAe()??"8787";return xd(`${e}:${t}`)??`${YPe()}://localhost:8787`},rAe=n=>JPe(WM(),n),oAe="vf_server_base_url_history",aAe=()=>{try{return globalThis.localStorage}catch{return}},sg=n=>{const e=typeof n=="string"?n.trim():"";return e===""?void 0:e},S7t=(n,e)=>{if(typeof n=="string"){const d=xd(n);return d==null?void 0:{serverUrl:d,createdAt:e,lastConnectedAt:e}}if(n==null||typeof n!="object"||Array.isArray(n))return;const t=n,i=xd(t.serverUrl);if(i==null)return;const s=typeof t.createdAt=="number"?t.createdAt:e,r=typeof t.lastConnectedAt=="number"?t.lastConnectedAt:s,o=sg(t.alias),a=sg(t.description),l=sg(t.authToken),c=sg(t.serverVersion);return{serverUrl:i,createdAt:s,lastConnectedAt:r,...o!=null?{alias:o}:{},...a!=null?{description:a}:{},...l!=null?{authToken:l}:{},...c!=null?{serverVersion:c}:{}}},lAe=n=>[...n].sort((e,t)=>t.lastConnectedAt-e.lastConnectedAt),zM=n=>{var t;const e=lAe(n);return(t=aAe())==null||t.setItem(oAe,JSON.stringify(e)),e},pf=()=>{var e;const n=(e=aAe())==null?void 0:e.getItem(oAe);if(n==null||n.trim()==="")return[];try{const t=JSON.parse(n);if(!Array.isArray(t))return[];const i=new Map,s=Date.now();for(const r of t){const o=S7t(r,s);o==null||i.has(o.serverUrl)||i.set(o.serverUrl,o)}return lAe(Array.from(i.values()))}catch{return[]}},wee=(n,e={})=>{const t=xd(n);if(t==null)return pf();const i=Date.now(),s=pf(),r=s.find(a=>a.serverUrl===t),o={...r,serverUrl:t,createdAt:(r==null?void 0:r.createdAt)??i,lastConnectedAt:i,...sg(e.serverVersion)!=null?{serverVersion:sg(e.serverVersion)}:{}};return zM([o,...s.filter(a=>a.serverUrl!==t)])},cAe=(n,e)=>{const t=xd(n);if(t==null)return pf();const i=Date.now(),s=pf(),r=s.find(u=>u.serverUrl===t),o=sg(e.alias),a=sg(e.description),{alias:l,description:c,...d}=r??{};return zM([{...d,serverUrl:t,createdAt:(r==null?void 0:r.createdAt)??i,lastConnectedAt:(r==null?void 0:r.lastConnectedAt)??i,...o!=null?{alias:o}:{},...a!=null?{description:a}:{}},...s.filter(u=>u.serverUrl!==t)])},x7t=n=>{const e=xd(n);return e==null?pf():zM(pf().filter(t=>t.serverUrl!==e))},L7t=n=>{var e;return(e=pf().find(t=>t.serverUrl===xd(n)))==null?void 0:e.authToken},dAe=(n,e)=>{const t=e.trim();if(t==="")return;const i=wee(n),s=xd(n);zM(i.map(r=>r.serverUrl===s?{...r,authToken:t}:r))},uAe=n=>{const e=xd(n);return e==null?pf():zM(pf().map(t=>{if(t.serverUrl!==e)return t;const{authToken:i,...s}=t;return s}))},vO="vf_auth_token",bO=()=>{try{return globalThis.localStorage}catch{return}},hAe=()=>{var i,s,r,o;const n=WM(),e=(i=L7t(n))==null?void 0:i.trim();if(e!=null&&e!=="")return e;const t=(r=(s=bO())==null?void 0:s.getItem(vO))==null?void 0:r.trim();if(!(t==null||t===""))return dAe(n,t),(o=bO())==null||o.removeItem(vO),t},k7t=n=>{var t;const e=n.trim();e!==""&&(dAe(WM(),e),(t=bO())==null||t.removeItem(vO))},fAe=()=>{var n;uAe(WM()),(n=bO())==null||n.removeItem(vO)},E7t=n=>{const e=hAe();e==null||n.has("Authorization")||n.set("Authorization",`Bearer ${e}`)},go={"Content-Type":"application/json"},I7t=()=>new URL(gAe()).hostname,M7t=()=>{const{port:n,protocol:e}=new URL(gAe());return n!==""?n:e==="https:"?"443":"80"},gAe=()=>WM(),q3e=n=>n.startsWith("http://")||n.startsWith("https://")?n:rAe(n),Bl=n=>new URL(q3e(n));class I5 extends Error{constructor(t,i){super(i.message);dt(this,"status");dt(this,"code");dt(this,"details");this.name="ApiError",this.status=t,this.code=i.code,this.details=i.details}}const yO=n=>n!=null&&typeof n=="object"&&!Array.isArray(n),N7t=n=>yO(n)&&n.success===!0&&"data"in n,mAe=n=>yO(n)&&n.success===!1&&yO(n.error)&&typeof n.error.message=="string"&&typeof n.error.code=="string",D7t=async n=>{const e=await n.text();if(e.trim()==="")return null;try{return JSON.parse(e)}catch{return e}},T7t=(n,e,t)=>{if(mAe(e))return new I5(n,e.error);if(yO(e)){const i=typeof e.error=="string"?e.error:typeof e.message=="string"?e.message:t,s=typeof e.code=="string"?e.code:"request_failed";return new I5(n,{code:s,message:i,...e.details!==void 0?{details:e.details}:{}})}return typeof e=="string"&&e.trim()!==""?new I5(n,{code:"request_failed",message:e}):new I5(n,{code:"request_failed",message:t})},pAe=async(n,e)=>{const t=await D7t(n);if(!n.ok){const i=e??`Request failed with status ${n.status}`,s=T7t(n.status,t,i);throw console.error(e??"[api] request failed",n.status,s.message,s.details),s}if(mAe(t))throw new I5(n.status,t.error);return N7t(t)?t.data:t},Ii=(n,e)=>n instanceof I5&&n.message.trim()!==""||n instanceof Error&&n.message.trim()!==""?n.message:e,CAe=n=>{const e=new Headers(n==null?void 0:n.headers);return E7t(e),{...n,credentials:(n==null?void 0:n.credentials)??"include",headers:e}};async function Rn(n,e){const t=typeof n=="string"?q3e(n):n.toString(),i=await fetch(t,CAe(e));return pAe(i)}async function UM(n,e,t){const i=typeof n=="string"?q3e(n):n.toString(),s=await fetch(i,CAe(e));return pAe(s,t)}const R7t=n=>{const e=n.trim(),t=e.startsWith("/")?e:`/${e}`;return t.endsWith("/")?t:`${t}/`},P7t=n=>{const e=R7t(n);return{scope:e,url:`${e}sw.js`}},A7t=n=>{if(!("serviceWorker"in navigator))return;const e=P7t(n.clientBase);window.addEventListener("load",()=>{navigator.serviceWorker.register(e.url,{scope:e.scope}).catch(t=>{console.warn("[pwa] service worker registration failed",t)})})},O7t=80,F7t=["input","textarea","select",'[contenteditable="true"]','[role="textbox"]'].join(","),eq=()=>globalThis.visualViewport,_Ae=()=>{const n=document.activeElement;if(n instanceof HTMLElement)return n.matches(F7t)?n:void 0},B7t=()=>{const n=_Ae();n!=null&&n.scrollIntoView({block:"center",inline:"nearest",behavior:"auto"})},$7t=()=>{var i,s;if(typeof window>"u")return;let n=0;const e=()=>{const r=eq(),o=(r==null?void 0:r.height)??window.innerHeight,a=(r==null?void 0:r.offsetTop)??0,l=_Ae(),c=r==null||l==null?0:Math.max(0,window.innerHeight-o-a);document.documentElement.style.setProperty("--vf-visual-viewport-height",`${Math.round(o)}px`),document.documentElement.style.setProperty("--vf-keyboard-inset-bottom",`${Math.round(c)}px`),document.documentElement.classList.toggle("has-mobile-keyboard",c>O7t)},t=()=>{window.cancelAnimationFrame(n),n=window.requestAnimationFrame(()=>{e(),B7t()})};e(),(i=eq())==null||i.addEventListener("resize",t),(s=eq())==null||s.addEventListener("scroll",t),window.addEventListener("resize",t),window.addEventListener("orientationchange",t),document.addEventListener("focusin",t),document.addEventListener("focusout",()=>{window.setTimeout(e,120)})},vAe=()=>Rn("/api/auth/status"),H7t=n=>UM("/api/auth/login",{method:"POST",headers:go,body:JSON.stringify(n)},"[api] login failed:"),V7t=async()=>{const n=await UM("/api/auth/logout",{method:"POST",headers:go},"[api] logout failed:");return fAe(),n};function j7t({children:n}){const{t:e}=ht(),{data:t,error:i,isLoading:s,mutate:r}=Gn("/api/auth/status",vAe),[o,a]=C.useState(null),[l,c]=C.useState(!1),d=(t==null?void 0:t.usernames[0])??"admin",u=ZW(),h=()=>{sAe({clearCurrentServer:!0}),window.location.reload()};if(s)return v.jsx("div",{className:"auth-gate auth-gate--loading",children:v.jsx(el,{size:"large"})});if(i!=null)return v.jsx("div",{className:"auth-gate",children:v.jsxs("div",{className:"auth-gate__panel",children:[v.jsx(nO,{type:"error",showIcon:!0,message:e("auth.statusFailed"),description:Ii(i,e("auth.statusFailed"))}),u&&v.jsx(qe,{className:"auth-gate__secondary-action",htmlType:"button",onClick:h,block:!0,children:e("auth.changeServer")})]})});if(t==null||!t.enabled||t.authenticated)return n;const f=async g=>{var m;c(!0),a(null);try{const p=await H7t({username:((m=g.username)==null?void 0:m.trim())??"",password:g.password??"",rememberDevice:g.rememberDevice===!0,returnToken:u});p.token!=null&&k7t(p.token),await r(p,{revalidate:!1})}catch(p){a(Ii(p,e("auth.loginFailed")))}finally{c(!1)}};return v.jsx("div",{className:"auth-gate",children:v.jsxs("main",{className:"auth-gate__panel","aria-labelledby":"auth-gate-title",children:[v.jsxs("div",{className:"auth-gate__intro",children:[v.jsx("h1",{id:"auth-gate-title",children:e("auth.title")}),v.jsx("p",{children:e("auth.subtitle")})]}),o!=null&&v.jsx(nO,{type:"error",showIcon:!0,className:"auth-gate__notice",message:o}),v.jsxs(zn,{layout:"vertical",requiredMark:!1,initialValues:{username:d,rememberDevice:!0},onFinish:g=>void f(g),children:[v.jsx(zn.Item,{name:"username",label:e("auth.username"),rules:[{required:!0,message:e("auth.usernameRequired")}],children:v.jsx(yn,{autoComplete:"username",size:"large",placeholder:e("auth.usernamePlaceholder")})}),v.jsx(zn.Item,{name:"password",label:e("auth.password"),rules:[{required:!0,message:e("auth.passwordRequired")}],children:v.jsx(yn.Password,{autoComplete:"current-password",size:"large",placeholder:e("auth.passwordPlaceholder")})}),v.jsx(zn.Item,{name:"rememberDevice",valuePropName:"checked",className:"auth-gate__remember",children:v.jsx(P1,{children:e("auth.rememberDevice")})}),t.passwordSource==="generated"&&v.jsx("p",{className:"auth-gate__hint",children:e("auth.generatedPasswordHint",{path:t.passwordFilePath??".data/web-auth-password"})}),v.jsx(qe,{type:"primary",htmlType:"submit",size:"large",loading:l,block:!0,children:e("auth.login")}),u&&v.jsx(qe,{className:"auth-gate__secondary-action",htmlType:"button",onClick:h,block:!0,children:e("auth.changeServer")})]})]})})}const F2={BASE_URL:"/__VF_PROJECT_AI_CLIENT_BASE__/",DEV:!1,MODE:"production",PROD:!0,SSR:!1,__VF_PROJECT_AI_CLIENT_COMMIT_HASH__:"6d420014325992c00757b5423c2ba107904da1f2",__VF_PROJECT_AI_CLIENT_VERSION__:"3.1.4-alpha.0",__VF_PROJECT_AI_DEV_GIT_REF__:""};function bAe(n){return"init"in n}function See(n){return!!n.write}function Q5e(n){return"v"in n||"e"in n}function wO(n){if("e"in n)throw n.e;if((F2?"production":void 0)!=="production"&&!("v"in n))throw new Error("[Bug] atom state is not initialized");return n.v}const SO=new WeakMap;function yAe(n){var e;return xO(n)&&!!((e=SO.get(n))!=null&&e[0])}function W7t(n){const e=SO.get(n);e!=null&&e[0]&&(e[0]=!1,e[1].forEach(t=>t()))}function xee(n,e){let t=SO.get(n);if(!t){t=[!0,new Set],SO.set(n,t);const i=()=>{t[0]=!1};n.then(i,i)}t[1].add(e)}function xO(n){return typeof(n==null?void 0:n.then)=="function"}function wAe(n,e,t){if(!t.p.has(n)){t.p.add(n);const i=()=>t.p.delete(n);e.then(i,i)}}function SAe(n,e,t){var i;const s=new Set;for(const r of((i=t.get(n))==null?void 0:i.t)||[])s.add(r);for(const r of e.p)s.add(r);return s}const z7t=(n,e,...t)=>e.read(...t),U7t=(n,e,...t)=>e.write(...t),K7t=(n,e)=>{if(e.INTERNAL_onInit)return e.INTERNAL_onInit(n);if(e.unstable_onInit)return console.warn("[DEPRECATED] atom.unstable_onInit is renamed to atom.INTERNAL_onInit."),e.unstable_onInit(n)},Z7t=(n,e,t)=>{var i;return(i=e.onMount)==null?void 0:i.call(e,t)},q7t=(n,e)=>{var t;const i=Bc(n),s=i[0],r=i[6],o=i[9];if((F2?"production":void 0)!=="production"&&!e)throw new Error("Atom is undefined or null");let a=s.get(e);return a||(a={d:new Map,p:new Set,n:0},s.set(e,a),(t=r.i)==null||t.call(r,e),o==null||o(n,e)),a},G7t=n=>{const e=Bc(n),t=e[1],i=e[3],s=e[4],r=e[5],o=e[6],a=e[13],l=[],c=d=>{try{d()}catch(u){l.push(u)}};do{o.f&&c(o.f);const d=new Set,u=d.add.bind(d);i.forEach(h=>{var f;return(f=t.get(h))==null?void 0:f.l.forEach(u)}),i.clear(),r.forEach(u),r.clear(),s.forEach(u),s.clear(),d.forEach(c),i.size&&a(n)}while(i.size||r.size||s.size);if(l.length)throw new AggregateError(l)},X7t=n=>{const e=Bc(n),t=e[1],i=e[2],s=e[3],r=e[11],o=e[14],a=e[17],l=[],c=new WeakSet,d=new WeakSet,u=Array.from(s);for(;u.length;){const h=u[u.length-1],f=r(n,h);if(d.has(h)){u.pop();continue}if(c.has(h)){if(i.get(h)===f.n)l.push([h,f]);else if((F2?"production":void 0)!=="production"&&i.has(h))throw new Error("[Bug] invalidated atom exists");d.add(h),u.pop();continue}c.add(h);for(const g of SAe(h,f,t))c.has(g)||u.push(g)}for(let h=l.length-1;h>=0;--h){const[f,g]=l[h];let m=!1;for(const p of g.d.keys())if(p!==f&&s.has(p)){m=!0;break}m&&(o(n,f),a(n,f)),i.delete(f)}},Lee=new WeakSet,Y7t=(n,e)=>{var t,i;const s=Bc(n),r=s[1],o=s[2],a=s[3],l=s[6],c=s[7],d=s[11],u=s[12],h=s[13],f=s[14],g=s[16],m=s[17],p=s[20],_=d(n,e);if(Q5e(_)){if(r.has(e)&&o.get(e)!==_.n)return _;let I=!1;for(const[M,N]of _.d)if(f(n,M).n!==N){I=!0;break}if(!I)return _}_.d.clear();let b=!0;function y(){r.has(e)&&(m(n,e),h(n),u(n))}function w(I){var M;if(I===e){const T=d(n,I);if(!Q5e(T))if(bAe(I))p(n,I,I.init);else throw new Error("no atom init");return wO(T)}const N=f(n,I);try{return wO(N)}finally{_.d.set(I,N.n),yAe(_.v)&&wAe(e,_.v,N),r.has(e)&&((M=r.get(I))==null||M.t.add(e)),b||y()}}let S,x;const L={get signal(){return S||(S=new AbortController),S.signal},get setSelf(){return(F2?"production":void 0)!=="production"&&!See(e)&&console.warn("setSelf function cannot be used with read-only atom"),!x&&See(e)&&(x=(...I)=>{if((F2?"production":void 0)!=="production"&&b&&console.warn("setSelf function cannot be called in sync"),!b)try{return g(n,e,...I)}finally{h(n),u(n)}}),x}},E=_.n;try{(F2?"production":void 0)!=="production"&&Lee.delete(n);const I=c(n,e,w,L);return(F2?"production":void 0)!=="production"&&Lee.has(n)&&console.warn("Detected store mutation during atom read. This is not supported."),p(n,e,I),xO(I)&&(xee(I,()=>S==null?void 0:S.abort()),I.then(y,y)),(t=l.r)==null||t.call(l,e),_}catch(I){return delete _.v,_.e=I,++_.n,_}finally{b=!1,E!==_.n&&o.get(e)===E&&(o.set(e,_.n),a.add(e),(i=l.c)==null||i.call(l,e))}},Q7t=(n,e)=>{const t=Bc(n),i=t[1],s=t[2],r=t[11],o=[e];for(;o.length;){const a=o.pop(),l=r(n,a);for(const c of SAe(a,l,i)){const d=r(n,c);s.set(c,d.n),o.push(c)}}},J7t=(n,e,...t)=>{const i=Bc(n),s=i[3],r=i[6],o=i[8],a=i[11],l=i[12],c=i[13],d=i[14],u=i[15],h=i[16],f=i[17],g=i[20];let m=!0;const p=b=>wO(d(n,b)),_=(b,...y)=>{var w;const S=a(n,b);try{if(b===e){if(!bAe(b))throw new Error("atom not writable");(F2?"production":void 0)!=="production"&&Lee.add(n);const x=S.n,L=y[0];g(n,b,L),f(n,b),x!==S.n&&(s.add(b),u(n,b),(w=r.c)==null||w.call(r,b));return}else return h(n,b,...y)}finally{m||(c(n),l(n))}};try{return o(n,e,p,_,...t)}finally{m=!1}},e_t=(n,e)=>{var t;const i=Bc(n),s=i[1],r=i[3],o=i[6],a=i[11],l=i[15],c=i[18],d=i[19],u=a(n,e),h=s.get(e);if(h&&!yAe(u.v)){for(const[f,g]of u.d)if(!h.d.has(f)){const m=a(n,f);c(n,f).t.add(e),h.d.add(f),g!==m.n&&(r.add(f),l(n,f),(t=o.c)==null||t.call(o,f))}for(const f of h.d)if(!u.d.has(f)){h.d.delete(f);const g=d(n,f);g==null||g.t.delete(e)}}},t_t=(n,e)=>{var t;const i=Bc(n),s=i[1],r=i[4],o=i[6],a=i[10],l=i[11],c=i[12],d=i[13],u=i[14],h=i[16],f=i[18],g=l(n,e);let m=s.get(e);if(!m){u(n,e);for(const p of g.d.keys())f(n,p).t.add(e);if(m={l:new Set,d:new Set(g.d.keys()),t:new Set},s.set(e,m),See(e)){const p=()=>{let _=!0;const b=(...y)=>{try{return h(n,e,...y)}finally{_||(d(n),c(n))}};try{const y=a(n,e,b);y&&(m.u=()=>{_=!0;try{y()}finally{_=!1}})}finally{_=!1}};r.add(p)}(t=o.m)==null||t.call(o,e)}return m},n_t=(n,e)=>{var t,i;const s=Bc(n),r=s[1],o=s[5],a=s[6],l=s[11],c=s[19],d=l(n,e);let u=r.get(e);if(!u||u.l.size)return u;let h=!1;for(const f of u.t)if((t=r.get(f))!=null&&t.d.has(e)){h=!0;break}if(!h){u.u&&o.add(u.u),u=void 0,r.delete(e);for(const f of d.d.keys()){const g=c(n,f);g==null||g.t.delete(e)}(i=a.u)==null||i.call(a,e);return}return u},i_t=(n,e,t)=>{const i=Bc(n)[11],s=i(n,e),r="v"in s,o=s.v;if(xO(t))for(const a of s.d.keys())wAe(e,t,i(n,a));s.v=t,delete s.e,(!r||!Object.is(o,s.v))&&(++s.n,xO(o)&&W7t(o))},s_t=(n,e)=>{const t=Bc(n)[14];return wO(t(n,e))},r_t=(n,e,...t)=>{const i=Bc(n),s=i[12],r=i[13],o=i[16];try{return o(n,e,...t)}finally{r(n),s(n)}},o_t=(n,e,t)=>{const i=Bc(n),s=i[12],r=i[18],o=i[19],l=r(n,e).l;return l.add(t),s(n),()=>{l.delete(t),o(n,e),s(n)}},xAe=new WeakMap,Bc=n=>{const e=xAe.get(n);if((F2?"production":void 0)!=="production"&&!e)throw new Error("Store must be created by buildStore to read its building blocks");return e};function a_t(...n){const e={get(i){const s=Bc(e)[21];return s(e,i)},set(i,...s){const r=Bc(e)[22];return r(e,i,...s)},sub(i,s){const r=Bc(e)[23];return r(e,i,s)}},t=[new WeakMap,new WeakMap,new WeakMap,new Set,new Set,new Set,{},z7t,U7t,K7t,Z7t,q7t,G7t,X7t,Y7t,Q7t,J7t,e_t,t_t,n_t,i_t,s_t,r_t,o_t,void 0].map((i,s)=>n[s]||i);return xAe.set(e,Object.freeze(t)),e}const LAe={};let l_t=0;function wu(n,e){const t=`atom${++l_t}`,i={toString(){return(LAe?"production":void 0)!=="production"&&this.debugLabel?t+":"+this.debugLabel:t}};return typeof n=="function"?i.read=n:(i.init=n,i.read=c_t,i.write=d_t),e&&(i.write=e),i}function c_t(n){return n(this)}function d_t(n,e,t){return e(this,typeof t=="function"?t(n(this)):t)}function u_t(){return a_t()}let Yw;function h_t(){return Yw||(Yw=u_t(),(LAe?"production":void 0)!=="production"&&(globalThis.__JOTAI_DEFAULT_STORE__||(globalThis.__JOTAI_DEFAULT_STORE__=Yw),globalThis.__JOTAI_DEFAULT_STORE__!==Yw&&console.warn("Detected multiple Jotai instances. It may cause unexpected behavior with the default store. https://github.com/pmndrs/jotai/discussions/2044"))),Yw}const f_t={},g_t=C.createContext(void 0);function kAe(n){return C.useContext(g_t)||h_t()}const kee=n=>typeof(n==null?void 0:n.then)=="function",Eee=n=>{n.status||(n.status="pending",n.then(e=>{n.status="fulfilled",n.value=e},e=>{n.status="rejected",n.reason=e}))},m_t=te.use||(n=>{if(n.status==="pending")throw n;if(n.status==="fulfilled")return n.value;throw n.status==="rejected"?n.reason:(Eee(n),n)}),tq=new WeakMap,J5e=(n,e)=>{let t=tq.get(n);return t||(t=new Promise((i,s)=>{let r=n;const o=c=>d=>{r===c&&i(d)},a=c=>d=>{r===c&&s(d)},l=()=>{try{const c=e();kee(c)?(tq.set(c,t),r=c,c.then(o(c),a(c)),xee(c,l)):i(c)}catch(c){s(c)}};n.then(o(n),a(n)),xee(n,l)}),tq.set(n,t)),t};function Su(n,e){const{delay:t,unstable_promiseStatus:i=!te.use}={},s=kAe(),[[r,o,a],l]=C.useReducer(d=>{const u=s.get(n);return Object.is(d[0],u)&&d[1]===s&&d[2]===n?d:[u,s,n]},void 0,()=>[s.get(n),s,n]);let c=r;if((o!==s||a!==n)&&(l(),c=s.get(n)),C.useEffect(()=>{const d=s.sub(n,()=>{if(i)try{const u=s.get(n);kee(u)&&Eee(J5e(u,()=>s.get(n)))}catch{}if(typeof t=="number"){setTimeout(l,t);return}l()});return l(),d},[s,n,t,i]),C.useDebugValue(c),kee(c)){const d=J5e(c,()=>s.get(n));return i&&Eee(d),m_t(d)}return c}function KM(n,e){const t=kAe();return C.useCallback((...s)=>{if((f_t?"production":void 0)!=="production"&&!("write"in n))throw new Error("not writable atom");return t.set(n,...s)},[t,n])}function z9(n,e){return[Su(n),KM(n)]}const EAe="(max-width: 960px)",IAe="(hover: none), (pointer: coarse)",MAe={isCompactLayout:!1,isTouchInteraction:!1},mP=new Set;let Cv=null,_v=null,vv=MAe,nq=!1,nx=null;const e8e=n=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(n).matches,NAe=()=>({isCompactLayout:(Cv==null?void 0:Cv.matches)??e8e(EAe),isTouchInteraction:(_v==null?void 0:_v.matches)??e8e(IAe)}),DAe=(n,e)=>n.isCompactLayout===e.isCompactLayout&&n.isTouchInteraction===e.isTouchInteraction,TAe=()=>{const n=NAe();return DAe(vv,n)||(vv=n),vv},t8e=()=>{const n=NAe();DAe(vv,n)||(vv=n,mP.forEach(e=>e()))},n8e=(n,e)=>typeof n.addEventListener=="function"?(n.addEventListener("change",e),()=>n.removeEventListener("change",e)):(n.addListener(e),()=>n.removeListener(e)),p_t=()=>{if(nq||typeof window>"u"||typeof window.matchMedia!="function")return;Cv=window.matchMedia(EAe),_v=window.matchMedia(IAe),vv=TAe();const n=n8e(Cv,t8e),e=n8e(_v,t8e);nx=()=>{n(),e(),Cv=null,_v=null,nq=!1},nq=!0},C_t=n=>(p_t(),mP.add(n),()=>{mP.delete(n),mP.size===0&&(nx==null||nx(),nx=null)}),__t=()=>TAe();function Mr(){return C.useSyncExternalStore(C_t,__t,()=>MAe)}const v_t=wu(Number(localStorage.getItem("sidebarWidth"))||300),RAe=wu(!1),PAe=wu(!1),AAe=wu(!1);wu(void 0);const OAe="theme",FAe=n=>n==="light"||n==="dark"||n==="system",b_t=()=>{try{const n=localStorage.getItem(OAe);if(n!=null&&FAe(n))return n}catch{}return"system"},i8e=wu(b_t()),GW=wu(n=>n(i8e),(n,e,t)=>{const i=FAe(t)?t:"system";e(i8e,i);try{localStorage.setItem(OAe,i)}catch{}}),y_t=(n,e)=>{try{const t=localStorage.getItem(n);if(t==="true")return!0;if(t==="false")return!1}catch{}return e},BAe=(n,e)=>{const t=wu(y_t(n,e));return wu(i=>i(t),(i,s,r)=>{const o=r===!0;s(t,o);try{localStorage.setItem(n,String(o))}catch{}})},w_t=(n,e)=>{try{const t=localStorage.getItem(n);if(t==null||t.trim()==="")return e;const i=Number(t);if(Number.isInteger(i)&&i>=0)return i}catch{}return e},S_t=(n,e)=>{const t=wu(w_t(n,e));return wu(i=>i(t),(i,s,r)=>{const o=Number.isInteger(r)&&r>=0?r:e;s(t,o);try{localStorage.setItem(n,String(o))}catch{}})},$Ae="vf_sender_header_default_display",HAe=n=>n==="expanded"||n==="collapsed",x_t=()=>{try{const n=localStorage.getItem($Ae);if(n!=null&&HAe(n))return n}catch{}return"expanded"},s8e=wu(x_t()),VAe=wu(n=>n(s8e),(n,e,t)=>{const i=HAe(t)?t:"expanded";e(s8e,i);try{localStorage.setItem($Ae,i)}catch{}}),L_t="vf_show_announcements",k_t="vf_show_new_session_starter_list",E_t="vf_session_list_search_threshold",I_t=5,jAe=BAe(L_t,!0),WAe=BAe(k_t,!0),zAe=S_t(E_t,I_t),M_t=8,r8e=56,N_t=.45,D_t=360,T_t='input,textarea,select,[contenteditable="true"],[role="textbox"]',R_t=n=>n==="touch"||n==="pen",P_t=n=>n instanceof HTMLElement&&n.closest(T_t)!=null;function A_t({isOpen:n,onClose:e,sheetRef:t}){const i=C.useRef(null),s=C.useRef(0),r=()=>{const h=t.current;h!=null&&(h.style.removeProperty("--vf-mobile-bottom-sheet-drag-y"),h.removeAttribute("data-mobile-bottom-sheet-dragging"))};C.useEffect(()=>{n||r()},[n]);const o=(h,f)=>{var w;const g=i.current;if(g==null)return;const m=h-g.startY,p=Math.max(1,f-g.startTime),_=m/p,b=m>r8e||_>N_t,y=g.dragging;if(i.current=null,(w=t.current)==null||w.removeAttribute("data-mobile-bottom-sheet-dragging"),y&&(s.current=Date.now()+D_t),b){e(),window.setTimeout(r,260);return}r()};return{onClickCapture:h=>{Date.now()>s.current||(h.preventDefault(),h.stopPropagation())},onPointerCancel:()=>{const h=i.current;if((h==null?void 0:h.dragging)===!0&&h.lastY-h.startY>r8e){e(),window.setTimeout(r,260),i.current=null;return}i.current=null,r()},onPointerDown:h=>{!n||!R_t(h.pointerType)||P_t(h.target)||(i.current={dragging:!1,lastY:h.clientY,pointerId:h.pointerId,startTime:h.timeStamp,startX:h.clientX,startY:h.clientY},h.currentTarget.setPointerCapture(h.pointerId))},onPointerMove:h=>{const f=i.current;if(f==null||f.pointerId!==h.pointerId)return;const g=h.clientX-f.startX,m=h.clientY-f.startY,p=Math.abs(g),_=Math.abs(m);if(f.lastY=h.clientY,!f.dragging){if(_<M_t||_<=p*1.2)return;f.dragging=!0,h.currentTarget.setAttribute("data-mobile-bottom-sheet-dragging","true")}h.cancelable&&h.preventDefault(),h.currentTarget.style.setProperty("--vf-mobile-bottom-sheet-drag-y",`${Math.round(Math.max(0,m))}px`)},onPointerUp:h=>{o(h.clientY,h.timeStamp)}}}function O_t({actions:n,isOpen:e,languageActions:t,languageLabel:i,moreLabel:s,onClose:r,themeActions:o,themeLabel:a}){var f,g;const l=C.useRef(null),c=A_t({isOpen:e,onClose:r,sheetRef:l}),d=((f=t.find(m=>m.active))==null?void 0:f.key)??((g=t[0])==null?void 0:g.key)??"",u=m=>{m.onSelect(),r()},h=m=>{m.onSelect()};return v.jsxs(v.Fragment,{children:[v.jsx("button",{type:"button",className:`nav-rail-compact-sheet-backdrop ${e?"is-open":""}`,"aria-hidden":!e,tabIndex:-1,onClick:r}),v.jsxs("div",{ref:l,className:`nav-rail-compact-sheet ${e?"is-open":""}`,role:"dialog","aria-modal":e?"true":void 0,"aria-hidden":!e,"aria-label":s,...c,children:[v.jsx("div",{className:"nav-rail-compact-sheet__handle"}),n.length>0&&v.jsxs("div",{className:"nav-rail-compact-sheet__section",children:[v.jsxs("div",{className:"nav-rail-compact-sheet__section-title",children:[v.jsx("span",{className:"material-symbols-rounded nav-rail-compact-sheet__section-title-icon",children:"tune"}),v.jsx("span",{children:s})]}),v.jsx("div",{className:"nav-rail-compact-sheet__actions",children:n.map(m=>v.jsxs("button",{type:"button",className:`nav-rail-compact-sheet__action ${m.active?"is-active":""}`,onClick:()=>u(m),children:[v.jsx("span",{className:"material-symbols-rounded",children:m.icon}),v.jsx("span",{children:m.label})]},m.key))})]}),v.jsxs("div",{className:"nav-rail-compact-sheet__section",children:[v.jsxs("div",{className:"nav-rail-compact-sheet__section-title",children:[v.jsx("span",{className:"material-symbols-rounded nav-rail-compact-sheet__section-title-icon",children:"palette"}),v.jsx("span",{children:a})]}),v.jsx("div",{className:"nav-rail-compact-sheet__segmented",children:o.map(m=>v.jsxs("button",{type:"button",className:`nav-rail-compact-sheet__segment ${m.active?"is-active":""}`,onClick:()=>h(m),children:[m.icon!=null&&v.jsx("span",{className:"material-symbols-rounded nav-rail-compact-sheet__segment-icon",children:m.icon}),v.jsx("span",{children:m.label})]},m.key))})]}),v.jsxs("div",{className:"nav-rail-compact-sheet__section",children:[v.jsxs("div",{className:"nav-rail-compact-sheet__section-title",children:[v.jsx("span",{className:"material-symbols-rounded nav-rail-compact-sheet__section-title-icon",children:"language"}),v.jsx("span",{children:i})]}),v.jsxs("label",{className:"nav-rail-compact-sheet__select-shell",children:[v.jsx("span",{className:"material-symbols-rounded nav-rail-compact-sheet__select-icon",children:"translate"}),v.jsx("select",{className:"nav-rail-compact-sheet__select",value:d,"aria-label":i,onChange:m=>{const p=t.find(_=>_.key===m.target.value);p!=null&&h(p)},children:t.map(m=>v.jsx("option",{value:m.key,children:m.label},m.key))}),v.jsx("span",{className:"material-symbols-rounded nav-rail-compact-sheet__select-chevron",children:"expand_more"})]})]})]})]})}function F_t({ariaHidden:n=!1,currentPath:e,languageActions:t,languageLabel:i,moreLabel:s,moreSheetActions:r,navItems:o,themeActions:a,themeLabel:l,onNavClick:c}){const[d,u]=C.useState(!1);return C.useEffect(()=>{u(!1)},[e]),C.useEffect(()=>{n&&u(!1)},[n]),v.jsxs("div",{className:"nav-rail nav-rail--compact","aria-hidden":n||void 0,children:[v.jsxs("div",{className:"nav-rail-compact-list",children:[o.map(h=>v.jsx(qe,{type:"text",className:`nav-item nav-item--compact ${h.active?"active":""}`,title:h.label,"aria-label":h.label,onClick:()=>{u(!1),c(h.key,h.path)},icon:v.jsx("span",{className:"material-symbols-rounded",children:h.icon})},h.key)),v.jsx(qe,{type:"text",className:`nav-item nav-item--compact ${d||e==="/config"?"active":""}`,title:s,"aria-expanded":d,"aria-haspopup":"dialog","aria-label":s,onClick:()=>u(h=>!h),icon:v.jsx("span",{className:"material-symbols-rounded",children:"more_horiz"})})]}),v.jsx(O_t,{actions:r,isOpen:d,languageActions:t,languageLabel:i,moreLabel:s,onClose:()=>u(!1),themeActions:a,themeLabel:l})]})}function B_t(){const{t:n}=ht(),{message:e}=Vs.useApp(),{mutate:t}=Jy(),{data:i}=Gn("/api/auth/status",vAe),s=ZW(),r=(i==null?void 0:i.enabled)===!0,o=te.useCallback(async()=>{try{await t("/api/auth/status")}catch{}},[t]),a=te.useCallback(()=>{sAe({clearCurrentServer:!0}),window.location.reload()},[]),l=te.useCallback(async()=>{try{await V7t(),await o()}catch(u){fAe(),await o(),e.error(Ii(u,n("auth.logoutFailed")))}},[e,o,n]),c=te.useMemo(()=>{const u=[];return s&&u.push({key:"change-server",label:n("auth.changeServer"),icon:v.jsx("span",{className:"material-symbols-rounded nav-menu-icon",children:"sync_alt"}),onClick:a}),r&&(u.length>0&&u.push({key:"account-divider",type:"divider"}),u.push({key:"logout",label:n("auth.logout"),danger:!0,icon:v.jsx("span",{className:"material-symbols-rounded nav-menu-icon",children:"logout"}),onClick:()=>{l()}})),u},[r,s,a,l,n]),d=te.useMemo(()=>[...s?[{icon:"sync_alt",key:"change-server",label:n("auth.changeServer"),onSelect:a}]:[],...r?[{icon:"logout",key:"logout",label:n("auth.logout"),onSelect:()=>{l()}}]:[]],[r,s,a,l,n]);return{accountItems:c,accountMenuLabel:n("auth.accountMenu"),compactAccountActions:d,showAccountMenu:c.length>0}}function $_t({currentPath:n,navigate:e,onOpenSidebar:t,showSidebar:i,t:s}){const r=[];return i&&t!=null&&r.push({active:n==="/"||n.startsWith("/session/"),icon:"menu",key:"sessions",label:s("common.sessions"),onSelect:t}),r.push({active:n==="/config",icon:"settings",key:"settings",label:s("common.settings"),onSelect:()=>{e("/config")}}),r}function H_t({setThemeMode:n,t:e,themeMode:t}){return[{active:t==="light",icon:"light_mode",key:"light",label:e("common.themeLight"),onSelect:()=>{n("light"),localStorage.setItem("theme","light")}},{active:t==="dark",icon:"dark_mode",key:"dark",label:e("common.themeDark"),onSelect:()=>{n("dark"),localStorage.setItem("theme","dark")}},{active:t==="system",icon:"desktop_windows",key:"system",label:e("common.themeSystem"),onSelect:()=>{n("system"),localStorage.setItem("theme","system")}}]}function V_t({currentLanguage:n,onChangeLanguage:e}){return[{active:n.startsWith("zh"),key:"zh",label:"简体中文",onSelect:()=>{e("zh")}},{active:n.startsWith("en"),key:"en",label:"English",onSelect:()=>{e("en")}}]}function j_t({currentLanguage:n,onChangeLanguage:e}){return[{key:"zh",label:"简体中文",icon:n.startsWith("zh")?v.jsx("span",{className:"material-symbols-rounded nav-menu-icon active",children:"check"}):v.jsx("div",{className:"nav-menu-icon-placeholder"}),onClick:()=>{e("zh")}},{key:"en",label:"English",icon:n.startsWith("en")?v.jsx("span",{className:"material-symbols-rounded nav-menu-icon active",children:"check"}):v.jsx("div",{className:"nav-menu-icon-placeholder"}),onClick:()=>{e("en")}}]}function W_t({setThemeMode:n,t:e,themeMode:t}){return[{key:"light",label:e("common.themeLight"),icon:t==="light"?v.jsx("span",{className:"material-symbols-rounded nav-menu-icon active",children:"check"}):v.jsx("span",{className:"material-symbols-rounded nav-menu-icon",children:"light_mode"}),onClick:()=>{n("light"),localStorage.setItem("theme","light")}},{key:"dark",label:e("common.themeDark"),icon:t==="dark"?v.jsx("span",{className:"material-symbols-rounded nav-menu-icon active",children:"check"}):v.jsx("span",{className:"material-symbols-rounded nav-menu-icon",children:"dark_mode"}),onClick:()=>{n("dark"),localStorage.setItem("theme","dark")}},{key:"system",label:e("common.themeSystem"),icon:t==="system"?v.jsx("span",{className:"material-symbols-rounded nav-menu-icon active",children:"check"}):v.jsx("span",{className:"material-symbols-rounded nav-menu-icon",children:"desktop_windows"}),onClick:()=>{n("system"),localStorage.setItem("theme","system")}}]}function z_t({currentPath:n,t:e}){return[{key:"sessions",icon:"chat_bubble",label:e("common.sessions"),path:"/",active:n==="/"||n.startsWith("/session/")},{key:"knowledge",icon:"library_books",label:e("common.knowledgeBase"),path:"/knowledge",active:n==="/knowledge"},{key:"automation",icon:"schedule",label:e("common.automation"),path:"/automation",active:n==="/automation"},{key:"benchmark",icon:"speed",label:e("common.benchmark"),path:"/benchmark",active:n==="/benchmark"},{key:"archive",icon:"archive",label:e("common.archivedSessions"),path:"/archive",active:n==="/archive"}]}function o8e({ariaHidden:n=!1,isCompactLayout:e=!1,onOpenSidebar:t,showSidebar:i=!1}){const{t:s,i18n:r}=ht(),[o,a]=z9(GW),l=Iu(),c=E3(),{isTouchInteraction:d}=Mr(),{accountItems:u,accountMenuLabel:h,compactAccountActions:f,showAccountMenu:g}=B_t(),m=c.pathname,p=E=>d?void 0:E,_=te.useMemo(()=>j_t({currentLanguage:r.language,onChangeLanguage:E=>r.changeLanguage(E)}),[r.language]),b=te.useMemo(()=>W_t({setThemeMode:a,t:s,themeMode:o}),[a,s,o]),y=te.useMemo(()=>z_t({currentPath:m,t:s}),[m,s]),w=te.useMemo(()=>[...$_t({currentPath:m,navigate:l,onOpenSidebar:t,showSidebar:i,t:s}),...f],[f,m,l,t,i,s]),S=te.useMemo(()=>H_t({setThemeMode:a,t:s,themeMode:o}),[a,s,o]),x=te.useMemo(()=>V_t({currentLanguage:r.language,onChangeLanguage:E=>{r.changeLanguage(E)}}),[r.language]),L=(E,I)=>{l(I)};return e?v.jsx(F_t,{ariaHidden:n,currentPath:m,languageActions:x,languageLabel:s("common.language"),moreLabel:s("common.moreActions"),moreSheetActions:w,navItems:y,themeActions:S,themeLabel:s("common.theme"),onNavClick:L}):v.jsxs("div",{className:"nav-rail","aria-hidden":n||void 0,children:[v.jsx("div",{className:"nav-rail-top",children:y.map(E=>v.jsx(Qe,{title:p(E.label),placement:"right",children:v.jsx("span",{children:v.jsx(qe,{type:"text",className:`nav-item ${E.active?"active":""}`,onClick:()=>L(E.key,E.path),icon:v.jsx("span",{className:"material-symbols-rounded",children:E.icon})})})},E.key))}),v.jsxs("div",{className:"nav-rail-bottom",children:[v.jsx(Qe,{title:p(s("common.theme")),placement:"right",children:v.jsx("span",{children:v.jsx(Wo,{menu:{items:b},placement:"topRight",trigger:["click"],children:v.jsx(qe,{type:"text",className:"nav-item",icon:v.jsx("span",{className:"material-symbols-rounded",children:o==="light"?"light_mode":o==="dark"?"dark_mode":"desktop_windows"})})})})}),v.jsx(Qe,{title:p(s("common.language")),placement:"right",children:v.jsx("span",{children:v.jsx(Wo,{menu:{items:_},placement:"topRight",trigger:["click"],children:v.jsx(qe,{type:"text",className:"nav-item",icon:v.jsx("span",{className:"material-symbols-rounded",children:"language"})})})})}),g&&v.jsx(Qe,{title:p(h),placement:"right",children:v.jsx("span",{children:v.jsx(Wo,{menu:{items:u},placement:"topRight",trigger:["click"],children:v.jsx(qe,{type:"text",className:"nav-item",icon:v.jsx("span",{className:"material-symbols-rounded",children:"account_circle"})})})})}),v.jsx(Qe,{title:p(s("common.settings")),placement:"right",children:v.jsx("span",{children:v.jsx(qe,{type:"text",className:`nav-item ${m==="/config"?"active":""}`,icon:v.jsx("span",{className:"material-symbols-rounded",children:"settings"}),onClick:()=>void l("/config")})})})]})]})}async function G3e(n,e={}){const t=Bl(`/api/adapters/${encodeURIComponent(n)}/accounts`);return e.model!=null&&e.model.trim()!==""&&t.searchParams.set("model",e.model),e.account!=null&&e.account.trim()!==""&&t.searchParams.set("account",e.account),e.refresh===!0&&t.searchParams.set("refresh","true"),Rn(t)}async function a8e(n,e,t={}){const i=Bl(`/api/adapters/${encodeURIComponent(n)}/accounts/${encodeURIComponent(e)}`);return t.model!=null&&t.model.trim()!==""&&i.searchParams.set("model",t.model),t.refresh===!0&&i.searchParams.set("refresh","true"),Rn(i)}async function LO(n,e,t){return Rn(Bl(`/api/adapters/${encodeURIComponent(n)}/accounts/actions`),{method:"POST",headers:go,body:JSON.stringify(e),...t})}async function UAe(){return Rn("/api/agent-rooms")}async function X3e(n){return Rn(`/api/agent-rooms/${encodeURIComponent(n)}`)}async function Iee(n,e){return Rn(`/api/agent-rooms/${encodeURIComponent(n)}`,{method:"PATCH",headers:go,body:JSON.stringify(e)})}async function U_t(n,e){return Rn(`/api/agent-rooms/${encodeURIComponent(n)}/messages`,{method:"POST",headers:go,body:JSON.stringify(e)})}const K_t=U_t;async function Z_t(){return Rn("/api/automation/rules")}async function q_t(n){return Rn("/api/automation/rules",{method:"POST",headers:go,body:JSON.stringify(n)})}async function l8e(n,e){return Rn(`/api/automation/rules/${n}`,{method:"PATCH",headers:go,body:JSON.stringify(e)})}async function G_t(n){return Rn(`/api/automation/rules/${n}`,{method:"DELETE"})}async function X_t(n){return Rn(`/api/automation/rules/${n}/run`,{method:"POST"})}async function Y_t(n,e=50){const t=Bl(`/api/automation/rules/${n}/runs`);return t.searchParams.set("limit",e.toString()),Rn(t)}async function Q_t(){return Rn("/api/benchmark/categories")}async function J_t(n){const e=Bl("/api/benchmark/cases");return Rn(e)}async function evt(n,e){return Rn(`/api/benchmark/results/${encodeURIComponent(n)}/${encodeURIComponent(e)}`)}async function $D(n){return UM("/api/benchmark/run",{method:"POST",headers:go,body:JSON.stringify(n)},"Failed to start benchmark run")}async function tvt(n){return Rn(`/api/benchmark/runs/${encodeURIComponent(n)}`)}async function Z0(){return Rn("/api/config")}async function nvt(){return Rn("/api/config/schema")}async function Y3e(n,e,t){return UM("/api/config",{method:"PATCH",headers:go,body:JSON.stringify({source:n,section:e,value:t})},"[api] update config failed:")}async function KAe(n){return Rn(`/api/sessions/${n}/git`)}async function ZAe(){return Rn("/api/workspace/git")}async function ivt(n){return Rn(`/api/sessions/${n}/git/branches`)}async function svt(){return Rn("/api/workspace/git/branches")}async function rvt(n){return Rn(`/api/sessions/${n}/git/worktrees`)}async function ovt(){return Rn("/api/workspace/git/worktrees")}async function avt(n,e){return Rn(`/api/sessions/${n}/git/checkout`,{method:"POST",headers:go,body:JSON.stringify(e)})}async function lvt(n,e){return Rn(`/api/sessions/${n}/git/branches`,{method:"POST",headers:go,body:JSON.stringify(e)})}async function cvt(n,e){return Rn(`/api/sessions/${n}/git/commit`,{method:"POST",headers:go,body:JSON.stringify(e)})}async function qAe(n,e={}){return Rn(`/api/sessions/${n}/git/push`,{method:"POST",headers:go,body:JSON.stringify(e)})}async function dvt(n){return Rn(`/api/sessions/${n}/git/sync`,{method:"POST"})}async function uvt(){return Rn("/api/ai/skills")}async function hvt(n){return Rn("/api/ai/skills",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})}async function fvt(n){return Rn("/api/ai/skills/import",{method:"POST",headers:{"Content-Type":n.type||"application/octet-stream","x-file-name":encodeURIComponent(n.name)},body:n})}async function gvt(n){const e=Bl("/api/ai/specs/detail");return e.searchParams.set("path",n),Rn(e)}async function mvt(n){const e=Bl("/api/ai/rules/detail");return e.searchParams.set("path",n),Rn(e)}async function pvt(n="active"){return Rn(n==="archived"?"/api/sessions/archived":"/api/sessions")}function XW(n){return`/api/sessions/${encodeURIComponent(n)}`}async function GAe(n){return Rn(XW(n))}async function Cvt(n,e,t,i,s){return Rn("/api/sessions",{method:"POST",headers:go,body:JSON.stringify({title:n,initialMessage:e,initialContent:t,model:i,start:s==null?void 0:s.start,parentSessionId:s==null?void 0:s.parentSessionId,id:s==null?void 0:s.id,promptType:s==null?void 0:s.promptType,promptName:s==null?void 0:s.promptName,effort:s==null?void 0:s.effort,permissionMode:s==null?void 0:s.permissionMode,adapter:s==null?void 0:s.adapter,account:s==null?void 0:s.account,updateSkills:s==null?void 0:s.updateSkills,workspace:s==null?void 0:s.workspace})})}async function _vt(n,e,t,i){return Rn(`/api/sessions/${n}/messages/${e}/branch`,{method:"POST",headers:go,body:JSON.stringify({action:t,content:i==null?void 0:i.content,title:i==null?void 0:i.title})})}async function XAe(n,e){const t=Bl(`/api/sessions/${n}/messages`);return Rn(t)}async function vvt(n){return Rn(`/api/sessions/${n}/workspace`)}async function bvt(n){return Rn(`/api/sessions/${n}/workspace/create-worktree`,{method:"POST"})}async function yvt(n){return Rn(`/api/sessions/${n}/workspace/transfer-local`,{method:"POST"})}async function wvt(n,e){const t=Bl(`/api/sessions/${n}/workspace/tree`);return e!=null&&e.trim()!==""&&t.searchParams.set("path",e),Rn(t)}async function Svt(n,e){const t=Bl(`/api/sessions/${n}/workspace/file`);return t.searchParams.set("path",e),Rn(t)}function xvt(n,e){const t=Bl(`/api/sessions/${n}/workspace/resource`);return t.searchParams.set("path",e),t.toString()}async function Lvt(n,e,t){return Rn(`/api/sessions/${n}/workspace/file`,{method:"PUT",headers:go,body:JSON.stringify({path:e,content:t})})}async function kvt(n,e,t){return Rn(`/api/sessions/${n}/events`,{method:"POST",headers:go,body:JSON.stringify({type:"interaction_response",id:e,data:t})})}async function Ob(n,e={}){const t=Bl(`/api/sessions/${n}`);return e.force===!0&&t.searchParams.set("force","true"),UM(t,{method:"DELETE"},"[api] delete session failed:")}async function f1(n,e){return Rn(`/api/sessions/${n}`,{method:"PATCH",headers:go,body:JSON.stringify(e)})}async function Evt(n,e){return f1(n,{title:e})}async function Ivt(n,e,t){return Rn(`/api/sessions/${n}/queued-messages`,{method:"POST",headers:go,body:JSON.stringify({mode:e,content:t})})}async function Mvt(n,e,t){return Rn(`/api/sessions/${n}/queued-messages/${e}`,{method:"PATCH",headers:go,body:JSON.stringify({content:t})})}async function Nvt(n,e){return Rn(`/api/sessions/${n}/queued-messages/${e}`,{method:"DELETE"})}async function Dvt(n,e,t){return Rn(`/api/sessions/${n}/queued-messages/${e}/move`,{method:"POST",headers:go,body:JSON.stringify({mode:t})})}async function Tvt(n,e,t){return Rn(`/api/sessions/${n}/queued-messages/reorder`,{method:"POST",headers:go,body:JSON.stringify({mode:e,ids:t})})}async function Rvt(n={}){const e=Bl("/api/skill-hub/search");return n.limit!=null&&e.searchParams.set("limit",String(n.limit)),n.registry!=null&&n.registry!==""&&e.searchParams.set("registry",n.registry),n.query!=null&&n.query!==""&&e.searchParams.set("q",n.query),Rn(e)}async function Pvt(n){return Rn("/api/skill-hub/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})}async function Avt(n){const e=Bl("/api/skill-hub/skills-cli/search");return e.searchParams.set("source",n.source),n.limit!=null&&e.searchParams.set("limit",String(n.limit)),n.query!=null&&n.query!==""&&e.searchParams.set("q",n.query),n.registry!=null&&n.registry!==""&&e.searchParams.set("registry",n.registry),Rn(e)}async function Ovt(n){return Rn("/api/skill-hub/skills-cli/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})}async function Fvt(n){const e=Bl("/api/workspace/tree");return n!=null&&n.trim()!==""&&e.searchParams.set("path",n),Rn(e)}async function Bvt(n){const e=Bl("/api/workspace/file");return e.searchParams.set("path",n),Rn(e)}function $vt(n){const e=Bl("/api/workspace/resource");return e.searchParams.set("path",n),e.toString()}async function Hvt(n,e){return Rn("/api/workspace/file",{method:"PUT",headers:go,body:JSON.stringify({path:n,content:e})})}async function Q3e(){return Rn("/api/worktree-environments")}const J3e=n=>n==null?"":`?source=${encodeURIComponent(n)}`;async function Vvt(n,e){return Rn(`/api/worktree-environments/${encodeURIComponent(n)}${J3e(e)}`)}async function YAe(n,e,t){return Rn(`/api/worktree-environments/${encodeURIComponent(n)}${J3e(t)}`,{method:"PUT",headers:go,body:JSON.stringify(e)})}async function jvt(n,e){return Rn(`/api/worktree-environments/${encodeURIComponent(n)}${J3e(e)}`,{method:"DELETE"})}function QAe({children:n,className:e,compact:t=!1,collapsed:i=!1,primaryAction:s,sideAction:r}){const o=["sidebar-list-header",t?"sidebar-list-header--compact":"",i?"sidebar-list-header--collapsed":"",e].filter(Boolean).join(" ");return v.jsxs("div",{className:o,children:[v.jsxs("div",{className:"sidebar-list-header__top",children:[v.jsx("div",{className:"sidebar-list-header__primary",children:s}),r!=null&&v.jsx("div",{className:"sidebar-list-header__side",children:r})]}),!i&&n!=null&&v.jsx("div",{className:"sidebar-list-header__content",children:n})]})}function JAe({children:n,className:e}){return v.jsx("div",{className:["sidebar-list-collapsed-actions",e].filter(Boolean).join(" "),children:n})}function kO({active:n=!1,ariaLabel:e,buttonRef:t,className:i,disabled:s,filled:r=!1,icon:o,tooltip:a,tooltipPlacement:l="bottom",onClick:c}){return v.jsx(Qe,{title:a,placement:l,children:v.jsx(qe,{ref:t,className:["sidebar-list-collapsed-actions__control",n?"active":"",i].filter(Boolean).join(" "),type:"text","aria-label":e,disabled:s,onClick:c,children:v.jsx("span",{className:`material-symbols-rounded ${r?"filled":""}`,children:o})})})}function eOe({allowClear:n=!0,className:e,disabled:t,placeholder:i,suffix:s,value:r,onChange:o}){return v.jsx(yn,{className:["sidebar-list-header__search-input",e].filter(Boolean).join(" "),disabled:t,placeholder:i,value:r,onChange:o,prefix:v.jsx("span",{className:"material-symbols-rounded sidebar-list-header__search-icon",children:"search"}),suffix:s,allowClear:n})}const Fb=wu({}),ehe=new Set,Wvt=n=>{ehe.add(n)},HD=n=>{ehe.delete(n)},c8e=n=>ehe.has(n),d8e=()=>{var n;return((n=globalThis.crypto)==null?void 0:n.randomUUID)!=null?globalThis.crypto.randomUUID():`local-session-${Date.now()}-${Math.random().toString(16).slice(2)}`},zvt=n=>{var s;if(typeof n=="string")return n.trim();const e=n==null?void 0:n.find(r=>r.type==="text"&&r.text.trim()!=="");if(e!=null)return e.text.trim();const t=n==null?void 0:n.find(r=>r.type==="file"&&r.path.trim()!=="");if(t!=null)return t.path.trim();const i=n==null?void 0:n.find(r=>r.type==="image");return i!=null?((s=i.name)==null?void 0:s.trim())??"":""},Uvt=n=>{var t;const e=((t=n.split(`
460
+ Please change the parent <Route path="${y}"> to <Route path="${y==="/"?"*":`${y}/*`}">.`)}let h=E3(),f;if(e){let y=typeof e=="string"?Yy(e):e;Eo(d==="/"||((b=y.pathname)==null?void 0:b.startsWith(d)),`When overriding the location using \`<Routes location>\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${d}" but pathname "${y.pathname}" was given in the \`location\` prop.`),f=y}else f=h;let g=f.pathname||"/",m=g;if(d!=="/"){let y=d.replace(/^\//,"").split("/");m="/"+g.replace(/^\//,"").split("/").slice(y.length).join("/")}let p=vPe(n,{pathname:m});Sh(u||p!=null,`No routes matched location "${f.pathname}${f.search}${f.hash}" `),Sh(p==null||p[p.length-1].route.element!==void 0||p[p.length-1].route.Component!==void 0||p[p.length-1].route.lazy!==void 0,`Matched leaf route at location "${f.pathname}${f.search}${f.hash}" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.`);let _=q4t(p&&p.map(y=>Object.assign({},y,{params:Object.assign({},l,y.params),pathname:s0([d,r.encodeLocation?r.encodeLocation(y.pathname.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:y.pathname]),pathnameBase:y.pathnameBase==="/"?d:s0([d,r.encodeLocation?r.encodeLocation(y.pathnameBase.replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:y.pathnameBase])})),o,t,i,s);return e&&_?C.createElement($M.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",...f},navigationType:"POP"}},_):_}function z4t(){let n=J4t(),e=D4t(n)?`${n.status} ${n.statusText}`:n instanceof Error?n.message:JSON.stringify(n),t=n instanceof Error?n.stack:null,i="rgba(200,200,200, 0.5)",s={padding:"0.5rem",backgroundColor:i},r={padding:"2px 4px",backgroundColor:i},o=null;return console.error("Error handled by React Router default ErrorBoundary:",n),o=C.createElement(C.Fragment,null,C.createElement("p",null,"💿 Hey developer 👋"),C.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",C.createElement("code",{style:r},"ErrorBoundary")," or"," ",C.createElement("code",{style:r},"errorElement")," prop on your route.")),C.createElement(C.Fragment,null,C.createElement("h2",null,"Unexpected Application Error!"),C.createElement("h3",{style:{fontStyle:"italic"}},e),t?C.createElement("pre",{style:s},t):null,o)}var U4t=C.createElement(z4t,null),RPe=class extends C.Component{constructor(n){super(n),this.state={location:n.location,revalidation:n.revalidation,error:n.error}}static getDerivedStateFromError(n){return{error:n}}static getDerivedStateFromProps(n,e){return e.location!==n.location||e.revalidation!=="idle"&&n.revalidation==="idle"?{error:n.error,location:n.location,revalidation:n.revalidation}:{error:n.error!==void 0?n.error:e.error,location:e.location,revalidation:n.revalidation||e.revalidation}}componentDidCatch(n,e){this.props.onError?this.props.onError(n,e):console.error("React Router caught the following error during render",n)}render(){let n=this.state.error;if(this.context&&typeof n=="object"&&n&&"digest"in n&&typeof n.digest=="string"){const t=H4t(n.digest);t&&(n=t)}let e=n!==void 0?C.createElement(Tf.Provider,{value:this.props.routeContext},C.createElement(F3e.Provider,{value:n,children:this.props.component})):this.props.children;return this.context?C.createElement(K4t,{error:n},e):e}};RPe.contextType=P4t;var ZZ=new WeakMap;function K4t({children:n,error:e}){let{basename:t}=C.useContext(Dh);if(typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){let i=$4t(e.digest);if(i){let s=ZZ.get(e);if(s)throw s;let r=kPe(i.location,t);if(LPe&&!ZZ.get(e))if(r.isExternal||i.reloadDocument)window.location.href=r.absoluteURL||r.to;else{const o=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(r.to,{replace:i.replace}));throw ZZ.set(e,o),o}return C.createElement("meta",{httpEquiv:"refresh",content:`0;url=${r.absoluteURL||r.to}`})}}return n}function Z4t({routeContext:n,match:e,children:t}){let i=C.useContext(Qy);return i&&i.static&&i.staticContext&&(e.route.errorElement||e.route.ErrorBoundary)&&(i.staticContext._deepestRenderedBoundaryId=e.route.id),C.createElement(Tf.Provider,{value:n},t)}function q4t(n,e=[],t=null,i=null,s=null){if(n==null){if(!t)return null;if(t.errors)n=t.matches;else if(e.length===0&&!t.initialized&&t.matches.length>0)n=t.matches;else return null}let r=n,o=t==null?void 0:t.errors;if(o!=null){let d=r.findIndex(u=>u.route.id&&(o==null?void 0:o[u.route.id])!==void 0);Eo(d>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(o).join(",")}`),r=r.slice(0,Math.min(r.length,d+1))}let a=!1,l=-1;if(t)for(let d=0;d<r.length;d++){let u=r[d];if((u.route.HydrateFallback||u.route.hydrateFallbackElement)&&(l=d),u.route.id){let{loaderData:h,errors:f}=t,g=u.route.loader&&!h.hasOwnProperty(u.route.id)&&(!f||f[u.route.id]===void 0);if(u.route.lazy||g){a=!0,l>=0?r=r.slice(0,l+1):r=[r[0]];break}}}let c=t&&i?(d,u)=>{var h,f;i(d,{location:t.location,params:((f=(h=t.matches)==null?void 0:h[0])==null?void 0:f.params)??{},unstable_pattern:T4t(t.matches),errorInfo:u})}:void 0;return r.reduceRight((d,u,h)=>{let f,g=!1,m=null,p=null;t&&(f=o&&u.route.id?o[u.route.id]:void 0,m=u.route.errorElement||U4t,a&&(l<0&&h===0?(PPe("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),g=!0,p=null):l===h&&(g=!0,p=u.route.hydrateFallbackElement||null)));let _=e.concat(r.slice(0,h+1)),b=()=>{let y;return f?y=m:g?y=p:u.route.Component?y=C.createElement(u.route.Component,null):u.route.element?y=u.route.element:y=d,C.createElement(Z4t,{match:u,routeContext:{outlet:d,matches:_,isDataRoute:t!=null},children:y})};return t&&(u.route.ErrorBoundary||u.route.errorElement||h===0)?C.createElement(RPe,{location:t.location,revalidation:t.revalidation,component:m,error:f,children:b(),routeContext:{outlet:null,matches:_,isDataRoute:!0},onError:c}):b()},null)}function $3e(n){return`${n} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function G4t(n){let e=C.useContext(Qy);return Eo(e,$3e(n)),e}function X4t(n){let e=C.useContext(UW);return Eo(e,$3e(n)),e}function Y4t(n){let e=C.useContext(Tf);return Eo(e,$3e(n)),e}function H3e(n){let e=Y4t(n),t=e.matches[e.matches.length-1];return Eo(t.route.id,`${n} can only be used on routes that contain a unique "id"`),t.route.id}function Q4t(){return H3e("useRouteId")}function J4t(){var i;let n=C.useContext(F3e),e=X4t("useRouteError"),t=H3e("useRouteError");return n!==void 0?n:(i=e.errors)==null?void 0:i[t]}function eCt(){let{router:n}=G4t("useNavigate"),e=H3e("useNavigate"),t=C.useRef(!1);return DPe(()=>{t.current=!0}),C.useCallback(async(s,r={})=>{Sh(t.current,NPe),t.current&&(typeof s=="number"?await n.navigate(s):await n.navigate(s,{fromRouteId:e,...r}))},[n,e])}var z5e={};function PPe(n,e,t){!e&&!z5e[n]&&(z5e[n]=!0,Sh(!1,t))}C.memo(tCt);function tCt({routes:n,future:e,state:t,onError:i}){return TPe(n,void 0,t,i,e)}function l6(n){Eo(!1,"A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.")}function nCt({basename:n="/",children:e=null,location:t,navigationType:i="POP",navigator:s,static:r=!1,unstable_useTransitions:o}){Eo(!HM(),"You cannot render a <Router> inside another <Router>. You should never have more than one in your app.");let a=n.replace(/^\/*/,"/"),l=C.useMemo(()=>({basename:a,navigator:s,static:r,unstable_useTransitions:o,future:{}}),[a,s,r,o]);typeof t=="string"&&(t=Yy(t));let{pathname:c="/",search:d="",hash:u="",state:h=null,key:f="default"}=t,g=C.useMemo(()=>{let m=S0(c,a);return m==null?null:{location:{pathname:m,search:d,hash:u,state:h,key:f},navigationType:i}},[a,c,d,u,h,f,i]);return Sh(g!=null,`<Router basename="${a}"> is not able to match the URL "${c}${d}${u}" because it does not start with the basename, so the <Router> won't render anything.`),g==null?null:C.createElement(Dh.Provider,{value:l},C.createElement($M.Provider,{children:e,value:g}))}function iCt({children:n,location:e}){return W4t(hee(n),e)}function hee(n,e=[]){let t=[];return C.Children.forEach(n,(i,s)=>{if(!C.isValidElement(i))return;let r=[...e,s];if(i.type===C.Fragment){t.push.apply(t,hee(i.props.children,r));return}Eo(i.type===l6,`[${typeof i.type=="string"?i.type:i.type.name}] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>`),Eo(!i.props.index||!i.props.children,"An index route cannot have child routes.");let o={id:i.props.id||r.join("-"),caseSensitive:i.props.caseSensitive,element:i.props.element,Component:i.props.Component,index:i.props.index,path:i.props.path,middleware:i.props.middleware,loader:i.props.loader,action:i.props.action,hydrateFallbackElement:i.props.hydrateFallbackElement,HydrateFallback:i.props.HydrateFallback,errorElement:i.props.errorElement,ErrorBoundary:i.props.ErrorBoundary,hasErrorBoundary:i.props.hasErrorBoundary===!0||i.props.ErrorBoundary!=null||i.props.errorElement!=null,shouldRevalidate:i.props.shouldRevalidate,handle:i.props.handle,lazy:i.props.lazy};i.props.children&&(o.children=hee(i.props.children,r)),t.push(o)}),t}var hP="get",fP="application/x-www-form-urlencoded";function KW(n){return typeof HTMLElement<"u"&&n instanceof HTMLElement}function sCt(n){return KW(n)&&n.tagName.toLowerCase()==="button"}function rCt(n){return KW(n)&&n.tagName.toLowerCase()==="form"}function oCt(n){return KW(n)&&n.tagName.toLowerCase()==="input"}function aCt(n){return!!(n.metaKey||n.altKey||n.ctrlKey||n.shiftKey)}function lCt(n,e){return n.button===0&&(!e||e==="_self")&&!aCt(n)}function fee(n=""){return new URLSearchParams(typeof n=="string"||Array.isArray(n)||n instanceof URLSearchParams?n:Object.keys(n).reduce((e,t)=>{let i=n[t];return e.concat(Array.isArray(i)?i.map(s=>[t,s]):[[t,i]])},[]))}function cCt(n,e){let t=fee(n);return e&&e.forEach((i,s)=>{t.has(s)||e.getAll(s).forEach(r=>{t.append(s,r)})}),t}var OD=null;function dCt(){if(OD===null)try{new FormData(document.createElement("form"),0),OD=!1}catch{OD=!0}return OD}var uCt=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function qZ(n){return n!=null&&!uCt.has(n)?(Sh(!1,`"${n}" is not a valid \`encType\` for \`<Form>\`/\`<fetcher.Form>\` and will default to "${fP}"`),null):n}function hCt(n,e){let t,i,s,r,o;if(rCt(n)){let a=n.getAttribute("action");i=a?S0(a,e):null,t=n.getAttribute("method")||hP,s=qZ(n.getAttribute("enctype"))||fP,r=new FormData(n)}else if(sCt(n)||oCt(n)&&(n.type==="submit"||n.type==="image")){let a=n.form;if(a==null)throw new Error('Cannot submit a <button> or <input type="submit"> without a <form>');let l=n.getAttribute("formaction")||a.getAttribute("action");if(i=l?S0(l,e):null,t=n.getAttribute("formmethod")||a.getAttribute("method")||hP,s=qZ(n.getAttribute("formenctype"))||qZ(a.getAttribute("enctype"))||fP,r=new FormData(a,n),!dCt()){let{name:c,type:d,value:u}=n;if(d==="image"){let h=c?`${c}.`:"";r.append(`${h}x`,"0"),r.append(`${h}y`,"0")}else c&&r.append(c,u)}}else{if(KW(n))throw new Error('Cannot submit element that is not <form>, <button>, or <input type="submit|image">');t=hP,i=null,s=fP,o=n}return r&&s==="text/plain"&&(o=r,r=void 0),{action:i,method:t.toLowerCase(),encType:s,formData:r,body:o}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");function V3e(n,e){if(n===!1||n===null||typeof n>"u")throw new Error(e)}function fCt(n,e,t,i){let s=typeof n=="string"?new URL(n,typeof window>"u"?"server://singlefetch/":window.location.origin):n;return t?s.pathname.endsWith("/")?s.pathname=`${s.pathname}_.${i}`:s.pathname=`${s.pathname}.${i}`:s.pathname==="/"?s.pathname=`_root.${i}`:e&&S0(s.pathname,e)==="/"?s.pathname=`${e.replace(/\/$/,"")}/_root.${i}`:s.pathname=`${s.pathname.replace(/\/$/,"")}.${i}`,s}async function gCt(n,e){if(n.id in e)return e[n.id];try{let t=await import(n.module);return e[n.id]=t,t}catch(t){return console.error(`Error loading route module \`${n.module}\`, reloading page...`),console.error(t),window.__reactRouterContext&&window.__reactRouterContext.isSpaMode,window.location.reload(),new Promise(()=>{})}}function mCt(n){return n==null?!1:n.href==null?n.rel==="preload"&&typeof n.imageSrcSet=="string"&&typeof n.imageSizes=="string":typeof n.rel=="string"&&typeof n.href=="string"}async function pCt(n,e,t){let i=await Promise.all(n.map(async s=>{let r=e.routes[s.route.id];if(r){let o=await gCt(r,t);return o.links?o.links():[]}return[]}));return bCt(i.flat(1).filter(mCt).filter(s=>s.rel==="stylesheet"||s.rel==="preload").map(s=>s.rel==="stylesheet"?{...s,rel:"prefetch",as:"style"}:{...s,rel:"prefetch"}))}function U5e(n,e,t,i,s,r){let o=(l,c)=>t[c]?l.route.id!==t[c].route.id:!0,a=(l,c)=>{var d;return t[c].pathname!==l.pathname||((d=t[c].route.path)==null?void 0:d.endsWith("*"))&&t[c].params["*"]!==l.params["*"]};return r==="assets"?e.filter((l,c)=>o(l,c)||a(l,c)):r==="data"?e.filter((l,c)=>{var u;let d=i.routes[l.route.id];if(!d||!d.hasLoader)return!1;if(o(l,c)||a(l,c))return!0;if(l.route.shouldRevalidate){let h=l.route.shouldRevalidate({currentUrl:new URL(s.pathname+s.search+s.hash,window.origin),currentParams:((u=t[0])==null?void 0:u.params)||{},nextUrl:new URL(n,window.origin),nextParams:l.params,defaultShouldRevalidate:!0});if(typeof h=="boolean")return h}return!0}):[]}function CCt(n,e,{includeHydrateFallback:t}={}){return _Ct(n.map(i=>{let s=e.routes[i.route.id];if(!s)return[];let r=[s.module];return s.clientActionModule&&(r=r.concat(s.clientActionModule)),s.clientLoaderModule&&(r=r.concat(s.clientLoaderModule)),t&&s.hydrateFallbackModule&&(r=r.concat(s.hydrateFallbackModule)),s.imports&&(r=r.concat(s.imports)),r}).flat(1))}function _Ct(n){return[...new Set(n)]}function vCt(n){let e={},t=Object.keys(n).sort();for(let i of t)e[i]=n[i];return e}function bCt(n,e){let t=new Set;return new Set(e),n.reduce((i,s)=>{let r=JSON.stringify(vCt(s));return t.has(r)||(t.add(r),i.push({key:r,link:s})),i},[])}function APe(){let n=C.useContext(Qy);return V3e(n,"You must render this element inside a <DataRouterContext.Provider> element"),n}function yCt(){let n=C.useContext(UW);return V3e(n,"You must render this element inside a <DataRouterStateContext.Provider> element"),n}var j3e=C.createContext(void 0);j3e.displayName="FrameworkContext";function OPe(){let n=C.useContext(j3e);return V3e(n,"You must render this element inside a <HydratedRouter> element"),n}function wCt(n,e){let t=C.useContext(j3e),[i,s]=C.useState(!1),[r,o]=C.useState(!1),{onFocus:a,onBlur:l,onMouseEnter:c,onMouseLeave:d,onTouchStart:u}=e,h=C.useRef(null);C.useEffect(()=>{if(n==="render"&&o(!0),n==="viewport"){let m=_=>{_.forEach(b=>{o(b.isIntersecting)})},p=new IntersectionObserver(m,{threshold:.5});return h.current&&p.observe(h.current),()=>{p.disconnect()}}},[n]),C.useEffect(()=>{if(i){let m=setTimeout(()=>{o(!0)},100);return()=>{clearTimeout(m)}}},[i]);let f=()=>{s(!0)},g=()=>{s(!1),o(!1)};return t?n!=="intent"?[r,h,{}]:[r,h,{onFocus:Xw(a,f),onBlur:Xw(l,g),onMouseEnter:Xw(c,f),onMouseLeave:Xw(d,g),onTouchStart:Xw(u,f)}]:[!1,h,{}]}function Xw(n,e){return t=>{n&&n(t),t.defaultPrevented||e(t)}}function SCt({page:n,...e}){let{router:t}=APe(),i=C.useMemo(()=>vPe(t.routes,n,t.basename),[t.routes,n,t.basename]);return i?C.createElement(LCt,{page:n,matches:i,...e}):null}function xCt(n){let{manifest:e,routeModules:t}=OPe(),[i,s]=C.useState([]);return C.useEffect(()=>{let r=!1;return pCt(n,e,t).then(o=>{r||s(o)}),()=>{r=!0}},[n,e,t]),i}function LCt({page:n,matches:e,...t}){let i=E3(),{future:s,manifest:r,routeModules:o}=OPe(),{basename:a}=APe(),{loaderData:l,matches:c}=yCt(),d=C.useMemo(()=>U5e(n,e,c,r,i,"data"),[n,e,c,r,i]),u=C.useMemo(()=>U5e(n,e,c,r,i,"assets"),[n,e,c,r,i]),h=C.useMemo(()=>{if(n===i.pathname+i.search+i.hash)return[];let m=new Set,p=!1;if(e.forEach(b=>{var w;let y=r.routes[b.route.id];!y||!y.hasLoader||(!d.some(S=>S.route.id===b.route.id)&&b.route.id in l&&((w=o[b.route.id])!=null&&w.shouldRevalidate)||y.hasClientLoader?p=!0:m.add(b.route.id))}),m.size===0)return[];let _=fCt(n,a,s.unstable_trailingSlashAwareDataRequests,"data");return p&&m.size>0&&_.searchParams.set("_routes",e.filter(b=>m.has(b.route.id)).map(b=>b.route.id).join(",")),[_.pathname+_.search]},[a,s.unstable_trailingSlashAwareDataRequests,l,i,r,d,e,n,o]),f=C.useMemo(()=>CCt(u,r),[u,r]),g=xCt(u);return C.createElement(C.Fragment,null,h.map(m=>C.createElement("link",{key:m,rel:"prefetch",as:"fetch",href:m,...t})),f.map(m=>C.createElement("link",{key:m,rel:"modulepreload",href:m,...t})),g.map(({key:m,link:p})=>C.createElement("link",{key:m,nonce:t.nonce,...p})))}function kCt(...n){return e=>{n.forEach(t=>{typeof t=="function"?t(e):t!=null&&(t.current=e)})}}var ECt=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";try{ECt&&(window.__reactRouterVersion="7.12.0")}catch{}function ICt({basename:n,children:e,unstable_useTransitions:t,window:i}){let s=C.useRef();s.current==null&&(s.current=a4t({window:i,v5Compat:!0}));let r=s.current,[o,a]=C.useState({action:r.action,location:r.location}),l=C.useCallback(c=>{t===!1?a(c):C.startTransition(()=>a(c))},[t]);return C.useLayoutEffect(()=>r.listen(l),[r,l]),C.createElement(nCt,{basename:n,children:e,location:o.location,navigationType:o.action,navigator:r,unstable_useTransitions:t})}var FPe=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,BPe=C.forwardRef(function({onClick:e,discover:t="render",prefetch:i="none",relative:s,reloadDocument:r,replace:o,state:a,target:l,to:c,preventScrollReset:d,viewTransition:u,unstable_defaultShouldRevalidate:h,...f},g){let{basename:m,unstable_useTransitions:p}=C.useContext(Dh),_=typeof c=="string"&&FPe.test(c),b=kPe(c,m);c=b.to;let y=V4t(c,{relative:s}),[w,S,x]=wCt(i,f),L=TCt(c,{replace:o,state:a,target:l,preventScrollReset:d,relative:s,viewTransition:u,unstable_defaultShouldRevalidate:h,unstable_useTransitions:p});function E(M){e&&e(M),M.defaultPrevented||L(M)}let I=C.createElement("a",{...f,...x,href:b.absoluteURL||y,onClick:b.isExternal||r?e:E,ref:kCt(g,S),target:l,"data-discover":!_&&t==="render"?"true":void 0});return w&&!_?C.createElement(C.Fragment,null,I,C.createElement(SCt,{page:y})):I});BPe.displayName="Link";var MCt=C.forwardRef(function({"aria-current":e="page",caseSensitive:t=!1,className:i="",end:s=!1,style:r,to:o,viewTransition:a,children:l,...c},d){let u=VM(o,{relative:c.relative}),h=E3(),f=C.useContext(UW),{navigator:g,basename:m}=C.useContext(Dh),p=f!=null&&FCt(u)&&a===!0,_=g.encodeLocation?g.encodeLocation(u).pathname:u.pathname,b=h.pathname,y=f&&f.navigation&&f.navigation.location?f.navigation.location.pathname:null;t||(b=b.toLowerCase(),y=y?y.toLowerCase():null,_=_.toLowerCase()),y&&m&&(y=S0(y,m)||y);const w=_!=="/"&&_.endsWith("/")?_.length-1:_.length;let S=b===_||!s&&b.startsWith(_)&&b.charAt(w)==="/",x=y!=null&&(y===_||!s&&y.startsWith(_)&&y.charAt(_.length)==="/"),L={isActive:S,isPending:x,isTransitioning:p},E=S?e:void 0,I;typeof i=="function"?I=i(L):I=[i,S?"active":null,x?"pending":null,p?"transitioning":null].filter(Boolean).join(" ");let M=typeof r=="function"?r(L):r;return C.createElement(BPe,{...c,"aria-current":E,className:I,ref:d,style:M,to:o,viewTransition:a},typeof l=="function"?l(L):l)});MCt.displayName="NavLink";var NCt=C.forwardRef(({discover:n="render",fetcherKey:e,navigate:t,reloadDocument:i,replace:s,state:r,method:o=hP,action:a,onSubmit:l,relative:c,preventScrollReset:d,viewTransition:u,unstable_defaultShouldRevalidate:h,...f},g)=>{let{unstable_useTransitions:m}=C.useContext(Dh),p=ACt(),_=OCt(a,{relative:c}),b=o.toLowerCase()==="get"?"get":"post",y=typeof a=="string"&&FPe.test(a),w=S=>{if(l&&l(S),S.defaultPrevented)return;S.preventDefault();let x=S.nativeEvent.submitter,L=(x==null?void 0:x.getAttribute("formmethod"))||o,E=()=>p(x||S.currentTarget,{fetcherKey:e,method:L,navigate:t,replace:s,state:r,relative:c,preventScrollReset:d,viewTransition:u,unstable_defaultShouldRevalidate:h});m&&t!==!1?C.startTransition(()=>E()):E()};return C.createElement("form",{ref:g,method:b,action:_,onSubmit:i?l:w,...f,"data-discover":!y&&n==="render"?"true":void 0})});NCt.displayName="Form";function DCt(n){return`${n} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function $Pe(n){let e=C.useContext(Qy);return Eo(e,DCt(n)),e}function TCt(n,{target:e,replace:t,state:i,preventScrollReset:s,relative:r,viewTransition:o,unstable_defaultShouldRevalidate:a,unstable_useTransitions:l}={}){let c=Iu(),d=E3(),u=VM(n,{relative:r});return C.useCallback(h=>{if(lCt(h,e)){h.preventDefault();let f=t!==void 0?t:tE(d)===tE(u),g=()=>c(n,{replace:f,state:i,preventScrollReset:s,relative:r,viewTransition:o,unstable_defaultShouldRevalidate:a});l?C.startTransition(()=>g()):g()}},[d,c,u,t,i,e,n,s,r,o,a,l])}function qm(n){Sh(typeof URLSearchParams<"u","You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.");let e=C.useRef(fee(n)),t=C.useRef(!1),i=E3(),s=C.useMemo(()=>cCt(i.search,t.current?null:e.current),[i.search]),r=Iu(),o=C.useCallback((a,l)=>{const c=fee(typeof a=="function"?a(new URLSearchParams(s)):a);t.current=!0,r("?"+c,l)},[r,s]);return[s,o]}var RCt=0,PCt=()=>`__${String(++RCt)}__`;function ACt(){let{router:n}=$Pe("useSubmit"),{basename:e}=C.useContext(Dh),t=Q4t(),i=n.fetch,s=n.navigate;return C.useCallback(async(r,o={})=>{let{action:a,method:l,encType:c,formData:d,body:u}=hCt(r,e);if(o.navigate===!1){let h=o.fetcherKey||PCt();await i(h,t,o.action||a,{unstable_defaultShouldRevalidate:o.unstable_defaultShouldRevalidate,preventScrollReset:o.preventScrollReset,formData:d,body:u,formMethod:o.method||l,formEncType:o.encType||c,flushSync:o.flushSync})}else await s(o.action||a,{unstable_defaultShouldRevalidate:o.unstable_defaultShouldRevalidate,preventScrollReset:o.preventScrollReset,formData:d,body:u,formMethod:o.method||l,formEncType:o.encType||c,replace:o.replace,state:o.state,fromRouteId:t,flushSync:o.flushSync,viewTransition:o.viewTransition})},[i,s,e,t])}function OCt(n,{relative:e}={}){let{basename:t}=C.useContext(Dh),i=C.useContext(Tf);Eo(i,"useFormAction must be used inside a RouteContext");let[s]=i.matches.slice(-1),r={...VM(n||".",{relative:e})},o=E3();if(n==null){r.search=o.search;let a=new URLSearchParams(r.search),l=a.getAll("index");if(l.some(d=>d==="")){a.delete("index"),l.filter(u=>u).forEach(u=>a.append("index",u));let d=a.toString();r.search=d?`?${d}`:""}}return(!n||n===".")&&s.route.index&&(r.search=r.search?r.search.replace(/^\?/,"?index&"):"?index"),t!=="/"&&(r.pathname=r.pathname==="/"?t:s0([t,r.pathname])),tE(r)}function FCt(n,{relative:e}={}){let t=C.useContext(IPe);Eo(t!=null,"`useViewTransitionState` must be used within `react-router-dom`'s `RouterProvider`. Did you accidentally import `RouterProvider` from `react-router`?");let{basename:i}=$Pe("useViewTransitionState"),s=VM(n,{relative:e});if(!t.isTransitioning)return!1;let r=S0(t.currentLocation.pathname,i)||t.currentLocation.pathname,o=S0(t.nextLocation.pathname,i)||t.nextLocation.pathname;return sf(s.pathname,o)!=null||sf(s.pathname,r)!=null}const HPe=0,VPe=1,jPe=2,K5e=3;var Z5e=Object.prototype.hasOwnProperty;function gee(n,e){var t,i;if(n===e)return!0;if(n&&e&&(t=n.constructor)===e.constructor){if(t===Date)return n.getTime()===e.getTime();if(t===RegExp)return n.toString()===e.toString();if(t===Array){if((i=n.length)===e.length)for(;i--&&gee(n[i],e[i]););return i===-1}if(!t||typeof n=="object"){i=0;for(t in n)if(Z5e.call(n,t)&&++i&&!Z5e.call(e,t)||!(t in e)||!gee(n[t],e[t]))return!1;return Object.keys(e).length===i}}return n!==n&&e!==e}const k2=new WeakMap,O2=()=>{},Yl=O2(),_O=Object,Fs=n=>n===Yl,u1=n=>typeof n=="function",x0=(n,e)=>({...n,...e}),WPe=n=>u1(n.then),GZ={},FD={},W3e="undefined",jM=typeof window!=W3e,mee=typeof document!=W3e,BCt=jM&&"Deno"in window,$Ct=()=>jM&&typeof window.requestAnimationFrame!=W3e,zPe=(n,e)=>{const t=k2.get(n);return[()=>!Fs(e)&&n.get(e)||GZ,i=>{if(!Fs(e)){const s=n.get(e);e in FD||(FD[e]=s),t[5](e,x0(s,i),s||GZ)}},t[6],()=>!Fs(e)&&e in FD?FD[e]:!Fs(e)&&n.get(e)||GZ]};let pee=!0;const HCt=()=>pee,[Cee,_ee]=jM&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[O2,O2],VCt=()=>{const n=mee&&document.visibilityState;return Fs(n)||n!=="hidden"},jCt=n=>(mee&&document.addEventListener("visibilitychange",n),Cee("focus",n),()=>{mee&&document.removeEventListener("visibilitychange",n),_ee("focus",n)}),WCt=n=>{const e=()=>{pee=!0,n()},t=()=>{pee=!1};return Cee("online",e),Cee("offline",t),()=>{_ee("online",e),_ee("offline",t)}},zCt={isOnline:HCt,isVisible:VCt},UCt={initFocus:jCt,initReconnect:WCt},q5e=!te.useId,pv=!jM||BCt,KCt=n=>$Ct()?window.requestAnimationFrame(n):setTimeout(n,1),gP=pv?C.useEffect:C.useLayoutEffect,XZ=typeof navigator<"u"&&navigator.connection,G5e=!pv&&XZ&&(["slow-2g","2g"].includes(XZ.effectiveType)||XZ.saveData),BD=new WeakMap,ZCt=n=>_O.prototype.toString.call(n),YZ=(n,e)=>n===`[object ${e}]`;let qCt=0;const vee=n=>{const e=typeof n,t=ZCt(n),i=YZ(t,"Date"),s=YZ(t,"RegExp"),r=YZ(t,"Object");let o,a;if(_O(n)===n&&!i&&!s){if(o=BD.get(n),o)return o;if(o=++qCt+"~",BD.set(n,o),Array.isArray(n)){for(o="@",a=0;a<n.length;a++)o+=vee(n[a])+",";BD.set(n,o)}if(r){o="#";const l=_O.keys(n).sort();for(;!Fs(a=l.pop());)Fs(n[a])||(o+=a+":"+vee(n[a])+",");BD.set(n,o)}}else o=i?n.toJSON():e=="symbol"?n.toString():e=="string"?JSON.stringify(n):""+n;return o},z3e=n=>{if(u1(n))try{n=n()}catch{n=""}const e=n;return n=typeof n=="string"?n:(Array.isArray(n)?n.length:n)?vee(n):"",[n,e]};let GCt=0;const bee=()=>++GCt;async function UPe(...n){const[e,t,i,s]=n,r=x0({populateCache:!0,throwOnError:!0},typeof s=="boolean"?{revalidate:s}:s||{});let o=r.populateCache;const a=r.rollbackOnError;let l=r.optimisticData;const c=h=>typeof a=="function"?a(h):a!==!1,d=r.throwOnError;if(u1(t)){const h=t,f=[],g=e.keys();for(const m of g)!/^\$(inf|sub)\$/.test(m)&&h(e.get(m)._k)&&f.push(m);return Promise.all(f.map(u))}return u(t);async function u(h){const[f]=z3e(h);if(!f)return;const[g,m]=zPe(e,f),[p,_,b,y]=k2.get(e),w=()=>{const P=p[f];return(u1(r.revalidate)?r.revalidate(g().data,h):r.revalidate!==!1)&&(delete b[f],delete y[f],P&&P[0])?P[0](jPe).then(()=>g().data):g().data};if(n.length<3)return w();let S=i,x,L=!1;const E=bee();_[f]=[E,0];const I=!Fs(l),M=g(),N=M.data,T=M._c,D=Fs(T)?N:T;if(I&&(l=u1(l)?l(D,N):l,m({data:l,_c:D})),u1(S))try{S=S(D)}catch(P){x=P,L=!0}if(S&&WPe(S))if(S=await S.catch(P=>{x=P,L=!0}),E!==_[f][0]){if(L)throw x;return S}else L&&I&&c(x)&&(o=!0,m({data:D,_c:Yl}));if(o&&!L)if(u1(o)){const P=o(S,D);m({data:P,error:Yl,_c:Yl})}else m({data:S,error:Yl,_c:Yl});if(_[f][1]=bee(),Promise.resolve(w()).then(()=>{m({_c:Yl})}),L){if(d)throw x;return}return S}}const X5e=(n,e)=>{for(const t in n)n[t][0]&&n[t][0](e)},KPe=(n,e)=>{if(!k2.has(n)){const t=x0(UCt,e),i=Object.create(null),s=UPe.bind(Yl,n);let r=O2;const o=Object.create(null),a=(d,u)=>{const h=o[d]||[];return o[d]=h,h.push(u),()=>h.splice(h.indexOf(u),1)},l=(d,u,h)=>{n.set(d,u);const f=o[d];if(f)for(const g of f)g(u,h)},c=()=>{if(!k2.has(n)&&(k2.set(n,[i,Object.create(null),Object.create(null),Object.create(null),s,l,a]),!pv)){const d=t.initFocus(setTimeout.bind(Yl,X5e.bind(Yl,i,HPe))),u=t.initReconnect(setTimeout.bind(Yl,X5e.bind(Yl,i,VPe)));r=()=>{d&&d(),u&&u(),k2.delete(n)}}};return c(),[n,s,c,r]}return[n,k2.get(n)[4]]},XCt=(n,e,t,i,s)=>{const r=t.errorRetryCount,o=s.retryCount,a=~~((Math.random()+.5)*(1<<(o<8?o:8)))*t.errorRetryInterval;!Fs(r)&&o>r||setTimeout(i,a,s)},YCt=gee,[U3e,QCt]=KPe(new Map),ZPe=x0({onLoadingSlow:O2,onSuccess:O2,onError:O2,onErrorRetry:XCt,onDiscarded:O2,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:G5e?1e4:5e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:G5e?5e3:3e3,compare:YCt,isPaused:()=>!1,cache:U3e,mutate:QCt,fallback:{}},zCt),qPe=(n,e)=>{const t=x0(n,e);if(e){const{use:i,fallback:s}=n,{use:r,fallback:o}=e;i&&r&&(t.use=i.concat(r)),s&&o&&(t.fallback=x0(s,o))}return t},yee=C.createContext({}),JCt=n=>{const{value:e}=n,t=C.useContext(yee),i=u1(e),s=C.useMemo(()=>i?e(t):e,[i,t,e]),r=C.useMemo(()=>i?s:qPe(t,s),[i,t,s]),o=s&&s.provider,a=C.useRef(Yl);o&&!a.current&&(a.current=KPe(o(r.cache||U3e),s));const l=a.current;return l&&(r.cache=l[0],r.mutate=l[1]),gP(()=>{if(l)return l[2]&&l[2](),l[3]},[]),C.createElement(yee.Provider,x0(n,{value:r}))},e7t="$inf$",GPe=jM&&window.__SWR_DEVTOOLS_USE__,t7t=GPe?window.__SWR_DEVTOOLS_USE__:[],n7t=()=>{GPe&&(window.__SWR_DEVTOOLS_REACT__=te)},i7t=n=>u1(n[1])?[n[0],n[1],n[2]||{}]:[n[0],null,(n[1]===null?n[2]:n[1])||{}],Jy=()=>{const n=C.useContext(yee);return C.useMemo(()=>x0(ZPe,n),[n])},s7t=n=>(e,t,i)=>n(e,t&&((...r)=>{const[o]=z3e(e),[,,,a]=k2.get(U3e);if(o.startsWith(e7t))return t(...r);const l=a[o];return Fs(l)?t(...r):(delete a[o],l)}),i),r7t=t7t.concat(s7t),o7t=n=>function(...t){const i=Jy(),[s,r,o]=i7t(t),a=qPe(i,o);let l=n;const{use:c}=a,d=(c||[]).concat(r7t);for(let u=d.length;u--;)l=d[u](l);return l(s,r||a.fetcher||null,a)},a7t=(n,e,t)=>{const i=e[n]||(e[n]=[]);return i.push(t),()=>{const s=i.indexOf(t);s>=0&&(i[s]=i[i.length-1],i.pop())}};n7t();const QZ=te.use||(n=>{switch(n.status){case"pending":throw n;case"fulfilled":return n.value;case"rejected":throw n.reason;default:throw n.status="pending",n.then(e=>{n.status="fulfilled",n.value=e},e=>{n.status="rejected",n.reason=e}),n}}),JZ={dedupe:!0},Y5e=Promise.resolve(Yl),l7t=(n,e,t)=>{const{cache:i,compare:s,suspense:r,fallbackData:o,revalidateOnMount:a,revalidateIfStale:l,refreshInterval:c,refreshWhenHidden:d,refreshWhenOffline:u,keepPreviousData:h,strictServerPrefetchWarning:f}=t,[g,m,p,_]=k2.get(i),[b,y]=z3e(n),w=C.useRef(!1),S=C.useRef(!1),x=C.useRef(b),L=C.useRef(e),E=C.useRef(t),I=()=>E.current,M=()=>I().isVisible()&&I().isOnline(),[N,T,D,P]=zPe(i,b),R=C.useRef({}).current,A=Fs(o)?Fs(t.fallback)?Yl:t.fallback[b]:o,O=(ce,oe)=>{for(const he in R){const ye=he;if(ye==="data"){if(!s(ce[ye],oe[ye])&&(!Fs(ce[ye])||!s(G,oe[ye])))return!1}else if(oe[ye]!==ce[ye])return!1}return!0},F=C.useMemo(()=>{const ce=!b||!e?!1:Fs(a)?I().isPaused()||r?!1:l!==!1:a,oe=we=>{const ve=x0(we);return delete ve._k,ce?{isValidating:!0,isLoading:!0,...ve}:ve},he=N(),ye=P(),ke=oe(he),Ce=he===ye?ke:oe(ye);let Se=ke;return[()=>{const we=oe(N());return O(we,Se)?(Se.data=we.data,Se.isLoading=we.isLoading,Se.isValidating=we.isValidating,Se.error=we.error,Se):(Se=we,we)},()=>Ce]},[i,b]),$=JY.useSyncExternalStore(C.useCallback(ce=>D(b,(oe,he)=>{O(he,oe)||ce()}),[i,b]),F[0],F[1]),B=!w.current,V=g[b]&&g[b].length>0,W=$.data,H=Fs(W)?A&&WPe(A)?QZ(A):A:W,U=$.error,Z=C.useRef(H),G=h?Fs(W)?Fs(Z.current)?H:Z.current:W:H,q=b&&Fs(H),K=!pv&&JY.useSyncExternalStore(()=>O2,()=>!1,()=>!0);f&&K&&!r&&q&&console.warn(`Missing pre-initiated data for serialized key "${b}" during server-side rendering. Data fethcing should be initiated on the server and provided to SWR via fallback data. You can set "strictServerPrefetchWarning: false" to disable this warning.`);const X=V&&!Fs(U)?!1:B&&!Fs(a)?a:I().isPaused()?!1:r?Fs(H)?!1:l:Fs(H)||l,ie=!!(b&&e&&B&&X),se=Fs($.isValidating)?ie:$.isValidating,J=Fs($.isLoading)?ie:$.isLoading,le=C.useCallback(async ce=>{const oe=L.current;if(!b||!oe||S.current||I().isPaused())return!1;let he,ye,ke=!0;const Ce=ce||{},Se=!p[b]||!Ce.dedupe,we=()=>q5e?!S.current&&b===x.current&&w.current:b===x.current,ve={isValidating:!1,isLoading:!1},Ee=()=>{T(ve)},me=()=>{const Oe=p[b];Oe&&Oe[1]===ye&&delete p[b]},xe={isValidating:!0};Fs(N().data)&&(xe.isLoading=!0);try{if(Se&&(T(xe),t.loadingTimeout&&Fs(N().data)&&setTimeout(()=>{ke&&we()&&I().onLoadingSlow(b,t)},t.loadingTimeout),p[b]=[oe(y),bee()]),[he,ye]=p[b],he=await he,Se&&setTimeout(me,t.dedupingInterval),!p[b]||p[b][1]!==ye)return Se&&we()&&I().onDiscarded(b),!1;ve.error=Yl;const Oe=m[b];if(!Fs(Oe)&&(ye<=Oe[0]||ye<=Oe[1]||Oe[1]===0))return Ee(),Se&&we()&&I().onDiscarded(b),!1;const We=N().data;ve.data=s(We,he)?We:he,Se&&we()&&I().onSuccess(he,b,t)}catch(Oe){me();const We=I(),{shouldRetryOnError:Ke}=We;We.isPaused()||(ve.error=Oe,Se&&we()&&(We.onError(Oe,b,We),(Ke===!0||u1(Ke)&&Ke(Oe))&&(!I().revalidateOnFocus||!I().revalidateOnReconnect||M())&&We.onErrorRetry(Oe,b,We,ze=>{const Ve=g[b];Ve&&Ve[0]&&Ve[0](K5e,ze)},{retryCount:(Ce.retryCount||0)+1,dedupe:!0})))}return ke=!1,Ee(),!0},[b,i]),be=C.useCallback((...ce)=>UPe(i,x.current,...ce),[]);if(gP(()=>{L.current=e,E.current=t,Fs(W)||(Z.current=W)}),gP(()=>{if(!b)return;const ce=le.bind(Yl,JZ);let oe=0;I().revalidateOnFocus&&(oe=Date.now()+I().focusThrottleInterval);const ye=a7t(b,g,(ke,Ce={})=>{if(ke==HPe){const Se=Date.now();I().revalidateOnFocus&&Se>oe&&M()&&(oe=Se+I().focusThrottleInterval,ce())}else if(ke==VPe)I().revalidateOnReconnect&&M()&&ce();else{if(ke==jPe)return le();if(ke==K5e)return le(Ce)}});return S.current=!1,x.current=b,w.current=!0,T({_k:y}),X&&(p[b]||(Fs(H)||pv?ce():KCt(ce))),()=>{S.current=!0,ye()}},[b]),gP(()=>{let ce;function oe(){const ye=u1(c)?c(N().data):c;ye&&ce!==-1&&(ce=setTimeout(he,ye))}function he(){!N().error&&(d||I().isVisible())&&(u||I().isOnline())?le(JZ).then(oe):oe()}return oe(),()=>{ce&&(clearTimeout(ce),ce=-1)}},[c,d,u,b]),C.useDebugValue(G),r){if(!q5e&&pv&&q)throw new Error("Fallback data is required when using Suspense in SSR.");q&&(L.current=e,E.current=t,S.current=!1);const ce=_[b],oe=!Fs(ce)&&q?be(ce):Y5e;if(QZ(oe),!Fs(U)&&q)throw U;const he=q?le(JZ):Y5e;!Fs(G)&&q&&(he.status="fulfilled",he.value=!0),QZ(he)}return{mutate:be,get data(){return R.data=!0,G},get error(){return R.error=!0,U},get isValidating(){return R.isValidating=!0,se},get isLoading(){return R.isLoading=!0,J}}},c7t=_O.defineProperty(JCt,"defaultValue",{value:ZPe}),Gn=o7t(l7t),K3e="vf_server_base_url",Z3e="vf_server_connection_picker_requested",d7t=(n,e)=>(n.trim()===""?"Vibe Forge Web":n.trim()).replace(/\s+\[[^\]]+\]$/,""),u7t=()=>globalThis.__VF_PROJECT_AI_RUNTIME_ENV__,XPe=(...n)=>n.find(e=>typeof e=="string"&&e.trim()!==""),h7t=n=>{let e=(n==null?void 0:n.trim())??"/ui";return e.startsWith("/")||(e=`/${e}`),e.length>1&&e.endsWith("/")&&(e=e.slice(0,-1)),e},f7t=n=>{let e=(n==null?void 0:n.trim())??"";return e?(e.startsWith("/")||(e=`/${e}`),e):"/ws"},g7t=n=>{const e=n==null?void 0:n.trim();if(!(e==null||e===""||e==="0.0.0.0"||e==="::"||e==="[::]"))return e},m7t=n=>/^[a-z][a-z\d+.-]*:\/\//i.test(n),ew=()=>{try{return globalThis.localStorage}catch{return}},YPe=()=>{var n;return((n=globalThis.location)==null?void 0:n.protocol)==="https:"?"https":"http"},QPe=()=>{var n;return(n=XPe(Gm().__VF_PROJECT_AI_CLIENT_MODE__,void 0,void 0))==null?void 0:n.trim().toLowerCase()},xd=n=>{const e=(n==null?void 0:n.trim())??"";if(e==="")return;const t=m7t(e)?e:`${YPe()}://${e}`;try{const i=new URL(t);return i.protocol!=="http:"&&i.protocol!=="https:"?void 0:(i.hash="",i.search="",i.toString().replace(/\/$/,""))}catch{return}},JPe=(n,e)=>{const t=xd(n);if(t==null)throw new Error("Invalid server base URL");const i=e.replace(/^\/+/,"");return new URL(i,`${t}/`).toString()},eAe=()=>{var n;return xd(((n=ew())==null?void 0:n.getItem(K3e))??void 0)},p7t=n=>{var t;const e=xd(n);if(e!=null)return(t=ew())==null||t.setItem(K3e,e),e},C7t=()=>{var n;(n=ew())==null||n.removeItem(K3e)},_7t=()=>QPe()==="desktop",ZW=()=>{const n=QPe();return n==="standalone"||n==="independent"||n==="desktop"},Gm=()=>u7t()??{},v7t=(...n)=>h7t(XPe(...n)),qW=()=>v7t(Gm().__VF_PROJECT_AI_CLIENT_BASE__,void 0,"/__VF_PROJECT_AI_CLIENT_BASE__/","/ui"),tAe=()=>g7t(Gm().__VF_PROJECT_AI_SERVER_HOST__??void 0),nAe=()=>Gm().__VF_PROJECT_AI_SERVER_PORT__??void 0,iAe=()=>{var i;const n=xd(Gm().__VF_PROJECT_AI_SERVER_BASE_URL__??void 0);if(n!=null)return n;const e=tAe(),t=(i=nAe())==null?void 0:i.trim();if(!(e==null||t==null||t===""))return xd(`${e}:${t}`)},b7t=()=>{var n;return((n=ew())==null?void 0:n.getItem(Z3e))==="true"},sAe=({clearCurrentServer:n=!1}={})=>{var e;n&&C7t(),(e=ew())==null||e.setItem(Z3e,"true")},y7t=()=>{var n;(n=ew())==null||n.removeItem(Z3e)},w7t=()=>f7t(Gm().__VF_PROJECT_AI_SERVER_WS_PATH__??void 0),WM=()=>{var i;if(ZW()){const s=eAe();if(s!=null)return s}const n=iAe();if(n!=null)return n;const e=tAe()??((i=globalThis.location)==null?void 0:i.hostname)??"localhost",t=nAe()??"8787";return xd(`${e}:${t}`)??`${YPe()}://localhost:8787`},rAe=n=>JPe(WM(),n),oAe="vf_server_base_url_history",aAe=()=>{try{return globalThis.localStorage}catch{return}},sg=n=>{const e=typeof n=="string"?n.trim():"";return e===""?void 0:e},S7t=(n,e)=>{if(typeof n=="string"){const d=xd(n);return d==null?void 0:{serverUrl:d,createdAt:e,lastConnectedAt:e}}if(n==null||typeof n!="object"||Array.isArray(n))return;const t=n,i=xd(t.serverUrl);if(i==null)return;const s=typeof t.createdAt=="number"?t.createdAt:e,r=typeof t.lastConnectedAt=="number"?t.lastConnectedAt:s,o=sg(t.alias),a=sg(t.description),l=sg(t.authToken),c=sg(t.serverVersion);return{serverUrl:i,createdAt:s,lastConnectedAt:r,...o!=null?{alias:o}:{},...a!=null?{description:a}:{},...l!=null?{authToken:l}:{},...c!=null?{serverVersion:c}:{}}},lAe=n=>[...n].sort((e,t)=>t.lastConnectedAt-e.lastConnectedAt),zM=n=>{var t;const e=lAe(n);return(t=aAe())==null||t.setItem(oAe,JSON.stringify(e)),e},pf=()=>{var e;const n=(e=aAe())==null?void 0:e.getItem(oAe);if(n==null||n.trim()==="")return[];try{const t=JSON.parse(n);if(!Array.isArray(t))return[];const i=new Map,s=Date.now();for(const r of t){const o=S7t(r,s);o==null||i.has(o.serverUrl)||i.set(o.serverUrl,o)}return lAe(Array.from(i.values()))}catch{return[]}},wee=(n,e={})=>{const t=xd(n);if(t==null)return pf();const i=Date.now(),s=pf(),r=s.find(a=>a.serverUrl===t),o={...r,serverUrl:t,createdAt:(r==null?void 0:r.createdAt)??i,lastConnectedAt:i,...sg(e.serverVersion)!=null?{serverVersion:sg(e.serverVersion)}:{}};return zM([o,...s.filter(a=>a.serverUrl!==t)])},cAe=(n,e)=>{const t=xd(n);if(t==null)return pf();const i=Date.now(),s=pf(),r=s.find(u=>u.serverUrl===t),o=sg(e.alias),a=sg(e.description),{alias:l,description:c,...d}=r??{};return zM([{...d,serverUrl:t,createdAt:(r==null?void 0:r.createdAt)??i,lastConnectedAt:(r==null?void 0:r.lastConnectedAt)??i,...o!=null?{alias:o}:{},...a!=null?{description:a}:{}},...s.filter(u=>u.serverUrl!==t)])},x7t=n=>{const e=xd(n);return e==null?pf():zM(pf().filter(t=>t.serverUrl!==e))},L7t=n=>{var e;return(e=pf().find(t=>t.serverUrl===xd(n)))==null?void 0:e.authToken},dAe=(n,e)=>{const t=e.trim();if(t==="")return;const i=wee(n),s=xd(n);zM(i.map(r=>r.serverUrl===s?{...r,authToken:t}:r))},uAe=n=>{const e=xd(n);return e==null?pf():zM(pf().map(t=>{if(t.serverUrl!==e)return t;const{authToken:i,...s}=t;return s}))},vO="vf_auth_token",bO=()=>{try{return globalThis.localStorage}catch{return}},hAe=()=>{var i,s,r,o;const n=WM(),e=(i=L7t(n))==null?void 0:i.trim();if(e!=null&&e!=="")return e;const t=(r=(s=bO())==null?void 0:s.getItem(vO))==null?void 0:r.trim();if(!(t==null||t===""))return dAe(n,t),(o=bO())==null||o.removeItem(vO),t},k7t=n=>{var t;const e=n.trim();e!==""&&(dAe(WM(),e),(t=bO())==null||t.removeItem(vO))},fAe=()=>{var n;uAe(WM()),(n=bO())==null||n.removeItem(vO)},E7t=n=>{const e=hAe();e==null||n.has("Authorization")||n.set("Authorization",`Bearer ${e}`)},go={"Content-Type":"application/json"},I7t=()=>new URL(gAe()).hostname,M7t=()=>{const{port:n,protocol:e}=new URL(gAe());return n!==""?n:e==="https:"?"443":"80"},gAe=()=>WM(),q3e=n=>n.startsWith("http://")||n.startsWith("https://")?n:rAe(n),Bl=n=>new URL(q3e(n));class I5 extends Error{constructor(t,i){super(i.message);dt(this,"status");dt(this,"code");dt(this,"details");this.name="ApiError",this.status=t,this.code=i.code,this.details=i.details}}const yO=n=>n!=null&&typeof n=="object"&&!Array.isArray(n),N7t=n=>yO(n)&&n.success===!0&&"data"in n,mAe=n=>yO(n)&&n.success===!1&&yO(n.error)&&typeof n.error.message=="string"&&typeof n.error.code=="string",D7t=async n=>{const e=await n.text();if(e.trim()==="")return null;try{return JSON.parse(e)}catch{return e}},T7t=(n,e,t)=>{if(mAe(e))return new I5(n,e.error);if(yO(e)){const i=typeof e.error=="string"?e.error:typeof e.message=="string"?e.message:t,s=typeof e.code=="string"?e.code:"request_failed";return new I5(n,{code:s,message:i,...e.details!==void 0?{details:e.details}:{}})}return typeof e=="string"&&e.trim()!==""?new I5(n,{code:"request_failed",message:e}):new I5(n,{code:"request_failed",message:t})},pAe=async(n,e)=>{const t=await D7t(n);if(!n.ok){const i=e??`Request failed with status ${n.status}`,s=T7t(n.status,t,i);throw console.error(e??"[api] request failed",n.status,s.message,s.details),s}if(mAe(t))throw new I5(n.status,t.error);return N7t(t)?t.data:t},Ii=(n,e)=>n instanceof I5&&n.message.trim()!==""||n instanceof Error&&n.message.trim()!==""?n.message:e,CAe=n=>{const e=new Headers(n==null?void 0:n.headers);return E7t(e),{...n,credentials:(n==null?void 0:n.credentials)??"include",headers:e}};async function Rn(n,e){const t=typeof n=="string"?q3e(n):n.toString(),i=await fetch(t,CAe(e));return pAe(i)}async function UM(n,e,t){const i=typeof n=="string"?q3e(n):n.toString(),s=await fetch(i,CAe(e));return pAe(s,t)}const R7t=n=>{const e=n.trim(),t=e.startsWith("/")?e:`/${e}`;return t.endsWith("/")?t:`${t}/`},P7t=n=>{const e=R7t(n);return{scope:e,url:`${e}sw.js`}},A7t=n=>{if(!("serviceWorker"in navigator))return;const e=P7t(n.clientBase);window.addEventListener("load",()=>{navigator.serviceWorker.register(e.url,{scope:e.scope}).catch(t=>{console.warn("[pwa] service worker registration failed",t)})})},O7t=80,F7t=["input","textarea","select",'[contenteditable="true"]','[role="textbox"]'].join(","),eq=()=>globalThis.visualViewport,_Ae=()=>{const n=document.activeElement;if(n instanceof HTMLElement)return n.matches(F7t)?n:void 0},B7t=()=>{const n=_Ae();n!=null&&n.scrollIntoView({block:"center",inline:"nearest",behavior:"auto"})},$7t=()=>{var i,s;if(typeof window>"u")return;let n=0;const e=()=>{const r=eq(),o=(r==null?void 0:r.height)??window.innerHeight,a=(r==null?void 0:r.offsetTop)??0,l=_Ae(),c=r==null||l==null?0:Math.max(0,window.innerHeight-o-a);document.documentElement.style.setProperty("--vf-visual-viewport-height",`${Math.round(o)}px`),document.documentElement.style.setProperty("--vf-keyboard-inset-bottom",`${Math.round(c)}px`),document.documentElement.classList.toggle("has-mobile-keyboard",c>O7t)},t=()=>{window.cancelAnimationFrame(n),n=window.requestAnimationFrame(()=>{e(),B7t()})};e(),(i=eq())==null||i.addEventListener("resize",t),(s=eq())==null||s.addEventListener("scroll",t),window.addEventListener("resize",t),window.addEventListener("orientationchange",t),document.addEventListener("focusin",t),document.addEventListener("focusout",()=>{window.setTimeout(e,120)})},vAe=()=>Rn("/api/auth/status"),H7t=n=>UM("/api/auth/login",{method:"POST",headers:go,body:JSON.stringify(n)},"[api] login failed:"),V7t=async()=>{const n=await UM("/api/auth/logout",{method:"POST",headers:go},"[api] logout failed:");return fAe(),n};function j7t({children:n}){const{t:e}=ht(),{data:t,error:i,isLoading:s,mutate:r}=Gn("/api/auth/status",vAe),[o,a]=C.useState(null),[l,c]=C.useState(!1),d=(t==null?void 0:t.usernames[0])??"admin",u=ZW(),h=()=>{sAe({clearCurrentServer:!0}),window.location.reload()};if(s)return v.jsx("div",{className:"auth-gate auth-gate--loading",children:v.jsx(el,{size:"large"})});if(i!=null)return v.jsx("div",{className:"auth-gate",children:v.jsxs("div",{className:"auth-gate__panel",children:[v.jsx(nO,{type:"error",showIcon:!0,message:e("auth.statusFailed"),description:Ii(i,e("auth.statusFailed"))}),u&&v.jsx(qe,{className:"auth-gate__secondary-action",htmlType:"button",onClick:h,block:!0,children:e("auth.changeServer")})]})});if(t==null||!t.enabled||t.authenticated)return n;const f=async g=>{var m;c(!0),a(null);try{const p=await H7t({username:((m=g.username)==null?void 0:m.trim())??"",password:g.password??"",rememberDevice:g.rememberDevice===!0,returnToken:u});p.token!=null&&k7t(p.token),await r(p,{revalidate:!1})}catch(p){a(Ii(p,e("auth.loginFailed")))}finally{c(!1)}};return v.jsx("div",{className:"auth-gate",children:v.jsxs("main",{className:"auth-gate__panel","aria-labelledby":"auth-gate-title",children:[v.jsxs("div",{className:"auth-gate__intro",children:[v.jsx("h1",{id:"auth-gate-title",children:e("auth.title")}),v.jsx("p",{children:e("auth.subtitle")})]}),o!=null&&v.jsx(nO,{type:"error",showIcon:!0,className:"auth-gate__notice",message:o}),v.jsxs(zn,{layout:"vertical",requiredMark:!1,initialValues:{username:d,rememberDevice:!0},onFinish:g=>void f(g),children:[v.jsx(zn.Item,{name:"username",label:e("auth.username"),rules:[{required:!0,message:e("auth.usernameRequired")}],children:v.jsx(yn,{autoComplete:"username",size:"large",placeholder:e("auth.usernamePlaceholder")})}),v.jsx(zn.Item,{name:"password",label:e("auth.password"),rules:[{required:!0,message:e("auth.passwordRequired")}],children:v.jsx(yn.Password,{autoComplete:"current-password",size:"large",placeholder:e("auth.passwordPlaceholder")})}),v.jsx(zn.Item,{name:"rememberDevice",valuePropName:"checked",className:"auth-gate__remember",children:v.jsx(P1,{children:e("auth.rememberDevice")})}),t.passwordSource==="generated"&&v.jsx("p",{className:"auth-gate__hint",children:e("auth.generatedPasswordHint",{path:t.passwordFilePath??".data/web-auth-password"})}),v.jsx(qe,{type:"primary",htmlType:"submit",size:"large",loading:l,block:!0,children:e("auth.login")}),u&&v.jsx(qe,{className:"auth-gate__secondary-action",htmlType:"button",onClick:h,block:!0,children:e("auth.changeServer")})]})]})})}const F2={BASE_URL:"/__VF_PROJECT_AI_CLIENT_BASE__/",DEV:!1,MODE:"production",PROD:!0,SSR:!1,__VF_PROJECT_AI_CLIENT_COMMIT_HASH__:"f7859c85f377ef47c87f6e0ef239f6a779b2f0df",__VF_PROJECT_AI_CLIENT_VERSION__:"3.1.4",__VF_PROJECT_AI_DEV_GIT_REF__:""};function bAe(n){return"init"in n}function See(n){return!!n.write}function Q5e(n){return"v"in n||"e"in n}function wO(n){if("e"in n)throw n.e;if((F2?"production":void 0)!=="production"&&!("v"in n))throw new Error("[Bug] atom state is not initialized");return n.v}const SO=new WeakMap;function yAe(n){var e;return xO(n)&&!!((e=SO.get(n))!=null&&e[0])}function W7t(n){const e=SO.get(n);e!=null&&e[0]&&(e[0]=!1,e[1].forEach(t=>t()))}function xee(n,e){let t=SO.get(n);if(!t){t=[!0,new Set],SO.set(n,t);const i=()=>{t[0]=!1};n.then(i,i)}t[1].add(e)}function xO(n){return typeof(n==null?void 0:n.then)=="function"}function wAe(n,e,t){if(!t.p.has(n)){t.p.add(n);const i=()=>t.p.delete(n);e.then(i,i)}}function SAe(n,e,t){var i;const s=new Set;for(const r of((i=t.get(n))==null?void 0:i.t)||[])s.add(r);for(const r of e.p)s.add(r);return s}const z7t=(n,e,...t)=>e.read(...t),U7t=(n,e,...t)=>e.write(...t),K7t=(n,e)=>{if(e.INTERNAL_onInit)return e.INTERNAL_onInit(n);if(e.unstable_onInit)return console.warn("[DEPRECATED] atom.unstable_onInit is renamed to atom.INTERNAL_onInit."),e.unstable_onInit(n)},Z7t=(n,e,t)=>{var i;return(i=e.onMount)==null?void 0:i.call(e,t)},q7t=(n,e)=>{var t;const i=Bc(n),s=i[0],r=i[6],o=i[9];if((F2?"production":void 0)!=="production"&&!e)throw new Error("Atom is undefined or null");let a=s.get(e);return a||(a={d:new Map,p:new Set,n:0},s.set(e,a),(t=r.i)==null||t.call(r,e),o==null||o(n,e)),a},G7t=n=>{const e=Bc(n),t=e[1],i=e[3],s=e[4],r=e[5],o=e[6],a=e[13],l=[],c=d=>{try{d()}catch(u){l.push(u)}};do{o.f&&c(o.f);const d=new Set,u=d.add.bind(d);i.forEach(h=>{var f;return(f=t.get(h))==null?void 0:f.l.forEach(u)}),i.clear(),r.forEach(u),r.clear(),s.forEach(u),s.clear(),d.forEach(c),i.size&&a(n)}while(i.size||r.size||s.size);if(l.length)throw new AggregateError(l)},X7t=n=>{const e=Bc(n),t=e[1],i=e[2],s=e[3],r=e[11],o=e[14],a=e[17],l=[],c=new WeakSet,d=new WeakSet,u=Array.from(s);for(;u.length;){const h=u[u.length-1],f=r(n,h);if(d.has(h)){u.pop();continue}if(c.has(h)){if(i.get(h)===f.n)l.push([h,f]);else if((F2?"production":void 0)!=="production"&&i.has(h))throw new Error("[Bug] invalidated atom exists");d.add(h),u.pop();continue}c.add(h);for(const g of SAe(h,f,t))c.has(g)||u.push(g)}for(let h=l.length-1;h>=0;--h){const[f,g]=l[h];let m=!1;for(const p of g.d.keys())if(p!==f&&s.has(p)){m=!0;break}m&&(o(n,f),a(n,f)),i.delete(f)}},Lee=new WeakSet,Y7t=(n,e)=>{var t,i;const s=Bc(n),r=s[1],o=s[2],a=s[3],l=s[6],c=s[7],d=s[11],u=s[12],h=s[13],f=s[14],g=s[16],m=s[17],p=s[20],_=d(n,e);if(Q5e(_)){if(r.has(e)&&o.get(e)!==_.n)return _;let I=!1;for(const[M,N]of _.d)if(f(n,M).n!==N){I=!0;break}if(!I)return _}_.d.clear();let b=!0;function y(){r.has(e)&&(m(n,e),h(n),u(n))}function w(I){var M;if(I===e){const T=d(n,I);if(!Q5e(T))if(bAe(I))p(n,I,I.init);else throw new Error("no atom init");return wO(T)}const N=f(n,I);try{return wO(N)}finally{_.d.set(I,N.n),yAe(_.v)&&wAe(e,_.v,N),r.has(e)&&((M=r.get(I))==null||M.t.add(e)),b||y()}}let S,x;const L={get signal(){return S||(S=new AbortController),S.signal},get setSelf(){return(F2?"production":void 0)!=="production"&&!See(e)&&console.warn("setSelf function cannot be used with read-only atom"),!x&&See(e)&&(x=(...I)=>{if((F2?"production":void 0)!=="production"&&b&&console.warn("setSelf function cannot be called in sync"),!b)try{return g(n,e,...I)}finally{h(n),u(n)}}),x}},E=_.n;try{(F2?"production":void 0)!=="production"&&Lee.delete(n);const I=c(n,e,w,L);return(F2?"production":void 0)!=="production"&&Lee.has(n)&&console.warn("Detected store mutation during atom read. This is not supported."),p(n,e,I),xO(I)&&(xee(I,()=>S==null?void 0:S.abort()),I.then(y,y)),(t=l.r)==null||t.call(l,e),_}catch(I){return delete _.v,_.e=I,++_.n,_}finally{b=!1,E!==_.n&&o.get(e)===E&&(o.set(e,_.n),a.add(e),(i=l.c)==null||i.call(l,e))}},Q7t=(n,e)=>{const t=Bc(n),i=t[1],s=t[2],r=t[11],o=[e];for(;o.length;){const a=o.pop(),l=r(n,a);for(const c of SAe(a,l,i)){const d=r(n,c);s.set(c,d.n),o.push(c)}}},J7t=(n,e,...t)=>{const i=Bc(n),s=i[3],r=i[6],o=i[8],a=i[11],l=i[12],c=i[13],d=i[14],u=i[15],h=i[16],f=i[17],g=i[20];let m=!0;const p=b=>wO(d(n,b)),_=(b,...y)=>{var w;const S=a(n,b);try{if(b===e){if(!bAe(b))throw new Error("atom not writable");(F2?"production":void 0)!=="production"&&Lee.add(n);const x=S.n,L=y[0];g(n,b,L),f(n,b),x!==S.n&&(s.add(b),u(n,b),(w=r.c)==null||w.call(r,b));return}else return h(n,b,...y)}finally{m||(c(n),l(n))}};try{return o(n,e,p,_,...t)}finally{m=!1}},e_t=(n,e)=>{var t;const i=Bc(n),s=i[1],r=i[3],o=i[6],a=i[11],l=i[15],c=i[18],d=i[19],u=a(n,e),h=s.get(e);if(h&&!yAe(u.v)){for(const[f,g]of u.d)if(!h.d.has(f)){const m=a(n,f);c(n,f).t.add(e),h.d.add(f),g!==m.n&&(r.add(f),l(n,f),(t=o.c)==null||t.call(o,f))}for(const f of h.d)if(!u.d.has(f)){h.d.delete(f);const g=d(n,f);g==null||g.t.delete(e)}}},t_t=(n,e)=>{var t;const i=Bc(n),s=i[1],r=i[4],o=i[6],a=i[10],l=i[11],c=i[12],d=i[13],u=i[14],h=i[16],f=i[18],g=l(n,e);let m=s.get(e);if(!m){u(n,e);for(const p of g.d.keys())f(n,p).t.add(e);if(m={l:new Set,d:new Set(g.d.keys()),t:new Set},s.set(e,m),See(e)){const p=()=>{let _=!0;const b=(...y)=>{try{return h(n,e,...y)}finally{_||(d(n),c(n))}};try{const y=a(n,e,b);y&&(m.u=()=>{_=!0;try{y()}finally{_=!1}})}finally{_=!1}};r.add(p)}(t=o.m)==null||t.call(o,e)}return m},n_t=(n,e)=>{var t,i;const s=Bc(n),r=s[1],o=s[5],a=s[6],l=s[11],c=s[19],d=l(n,e);let u=r.get(e);if(!u||u.l.size)return u;let h=!1;for(const f of u.t)if((t=r.get(f))!=null&&t.d.has(e)){h=!0;break}if(!h){u.u&&o.add(u.u),u=void 0,r.delete(e);for(const f of d.d.keys()){const g=c(n,f);g==null||g.t.delete(e)}(i=a.u)==null||i.call(a,e);return}return u},i_t=(n,e,t)=>{const i=Bc(n)[11],s=i(n,e),r="v"in s,o=s.v;if(xO(t))for(const a of s.d.keys())wAe(e,t,i(n,a));s.v=t,delete s.e,(!r||!Object.is(o,s.v))&&(++s.n,xO(o)&&W7t(o))},s_t=(n,e)=>{const t=Bc(n)[14];return wO(t(n,e))},r_t=(n,e,...t)=>{const i=Bc(n),s=i[12],r=i[13],o=i[16];try{return o(n,e,...t)}finally{r(n),s(n)}},o_t=(n,e,t)=>{const i=Bc(n),s=i[12],r=i[18],o=i[19],l=r(n,e).l;return l.add(t),s(n),()=>{l.delete(t),o(n,e),s(n)}},xAe=new WeakMap,Bc=n=>{const e=xAe.get(n);if((F2?"production":void 0)!=="production"&&!e)throw new Error("Store must be created by buildStore to read its building blocks");return e};function a_t(...n){const e={get(i){const s=Bc(e)[21];return s(e,i)},set(i,...s){const r=Bc(e)[22];return r(e,i,...s)},sub(i,s){const r=Bc(e)[23];return r(e,i,s)}},t=[new WeakMap,new WeakMap,new WeakMap,new Set,new Set,new Set,{},z7t,U7t,K7t,Z7t,q7t,G7t,X7t,Y7t,Q7t,J7t,e_t,t_t,n_t,i_t,s_t,r_t,o_t,void 0].map((i,s)=>n[s]||i);return xAe.set(e,Object.freeze(t)),e}const LAe={};let l_t=0;function wu(n,e){const t=`atom${++l_t}`,i={toString(){return(LAe?"production":void 0)!=="production"&&this.debugLabel?t+":"+this.debugLabel:t}};return typeof n=="function"?i.read=n:(i.init=n,i.read=c_t,i.write=d_t),e&&(i.write=e),i}function c_t(n){return n(this)}function d_t(n,e,t){return e(this,typeof t=="function"?t(n(this)):t)}function u_t(){return a_t()}let Yw;function h_t(){return Yw||(Yw=u_t(),(LAe?"production":void 0)!=="production"&&(globalThis.__JOTAI_DEFAULT_STORE__||(globalThis.__JOTAI_DEFAULT_STORE__=Yw),globalThis.__JOTAI_DEFAULT_STORE__!==Yw&&console.warn("Detected multiple Jotai instances. It may cause unexpected behavior with the default store. https://github.com/pmndrs/jotai/discussions/2044"))),Yw}const f_t={},g_t=C.createContext(void 0);function kAe(n){return C.useContext(g_t)||h_t()}const kee=n=>typeof(n==null?void 0:n.then)=="function",Eee=n=>{n.status||(n.status="pending",n.then(e=>{n.status="fulfilled",n.value=e},e=>{n.status="rejected",n.reason=e}))},m_t=te.use||(n=>{if(n.status==="pending")throw n;if(n.status==="fulfilled")return n.value;throw n.status==="rejected"?n.reason:(Eee(n),n)}),tq=new WeakMap,J5e=(n,e)=>{let t=tq.get(n);return t||(t=new Promise((i,s)=>{let r=n;const o=c=>d=>{r===c&&i(d)},a=c=>d=>{r===c&&s(d)},l=()=>{try{const c=e();kee(c)?(tq.set(c,t),r=c,c.then(o(c),a(c)),xee(c,l)):i(c)}catch(c){s(c)}};n.then(o(n),a(n)),xee(n,l)}),tq.set(n,t)),t};function Su(n,e){const{delay:t,unstable_promiseStatus:i=!te.use}={},s=kAe(),[[r,o,a],l]=C.useReducer(d=>{const u=s.get(n);return Object.is(d[0],u)&&d[1]===s&&d[2]===n?d:[u,s,n]},void 0,()=>[s.get(n),s,n]);let c=r;if((o!==s||a!==n)&&(l(),c=s.get(n)),C.useEffect(()=>{const d=s.sub(n,()=>{if(i)try{const u=s.get(n);kee(u)&&Eee(J5e(u,()=>s.get(n)))}catch{}if(typeof t=="number"){setTimeout(l,t);return}l()});return l(),d},[s,n,t,i]),C.useDebugValue(c),kee(c)){const d=J5e(c,()=>s.get(n));return i&&Eee(d),m_t(d)}return c}function KM(n,e){const t=kAe();return C.useCallback((...s)=>{if((f_t?"production":void 0)!=="production"&&!("write"in n))throw new Error("not writable atom");return t.set(n,...s)},[t,n])}function z9(n,e){return[Su(n),KM(n)]}const EAe="(max-width: 960px)",IAe="(hover: none), (pointer: coarse)",MAe={isCompactLayout:!1,isTouchInteraction:!1},mP=new Set;let Cv=null,_v=null,vv=MAe,nq=!1,nx=null;const e8e=n=>typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia(n).matches,NAe=()=>({isCompactLayout:(Cv==null?void 0:Cv.matches)??e8e(EAe),isTouchInteraction:(_v==null?void 0:_v.matches)??e8e(IAe)}),DAe=(n,e)=>n.isCompactLayout===e.isCompactLayout&&n.isTouchInteraction===e.isTouchInteraction,TAe=()=>{const n=NAe();return DAe(vv,n)||(vv=n),vv},t8e=()=>{const n=NAe();DAe(vv,n)||(vv=n,mP.forEach(e=>e()))},n8e=(n,e)=>typeof n.addEventListener=="function"?(n.addEventListener("change",e),()=>n.removeEventListener("change",e)):(n.addListener(e),()=>n.removeListener(e)),p_t=()=>{if(nq||typeof window>"u"||typeof window.matchMedia!="function")return;Cv=window.matchMedia(EAe),_v=window.matchMedia(IAe),vv=TAe();const n=n8e(Cv,t8e),e=n8e(_v,t8e);nx=()=>{n(),e(),Cv=null,_v=null,nq=!1},nq=!0},C_t=n=>(p_t(),mP.add(n),()=>{mP.delete(n),mP.size===0&&(nx==null||nx(),nx=null)}),__t=()=>TAe();function Mr(){return C.useSyncExternalStore(C_t,__t,()=>MAe)}const v_t=wu(Number(localStorage.getItem("sidebarWidth"))||300),RAe=wu(!1),PAe=wu(!1),AAe=wu(!1);wu(void 0);const OAe="theme",FAe=n=>n==="light"||n==="dark"||n==="system",b_t=()=>{try{const n=localStorage.getItem(OAe);if(n!=null&&FAe(n))return n}catch{}return"system"},i8e=wu(b_t()),GW=wu(n=>n(i8e),(n,e,t)=>{const i=FAe(t)?t:"system";e(i8e,i);try{localStorage.setItem(OAe,i)}catch{}}),y_t=(n,e)=>{try{const t=localStorage.getItem(n);if(t==="true")return!0;if(t==="false")return!1}catch{}return e},BAe=(n,e)=>{const t=wu(y_t(n,e));return wu(i=>i(t),(i,s,r)=>{const o=r===!0;s(t,o);try{localStorage.setItem(n,String(o))}catch{}})},w_t=(n,e)=>{try{const t=localStorage.getItem(n);if(t==null||t.trim()==="")return e;const i=Number(t);if(Number.isInteger(i)&&i>=0)return i}catch{}return e},S_t=(n,e)=>{const t=wu(w_t(n,e));return wu(i=>i(t),(i,s,r)=>{const o=Number.isInteger(r)&&r>=0?r:e;s(t,o);try{localStorage.setItem(n,String(o))}catch{}})},$Ae="vf_sender_header_default_display",HAe=n=>n==="expanded"||n==="collapsed",x_t=()=>{try{const n=localStorage.getItem($Ae);if(n!=null&&HAe(n))return n}catch{}return"expanded"},s8e=wu(x_t()),VAe=wu(n=>n(s8e),(n,e,t)=>{const i=HAe(t)?t:"expanded";e(s8e,i);try{localStorage.setItem($Ae,i)}catch{}}),L_t="vf_show_announcements",k_t="vf_show_new_session_starter_list",E_t="vf_session_list_search_threshold",I_t=5,jAe=BAe(L_t,!0),WAe=BAe(k_t,!0),zAe=S_t(E_t,I_t),M_t=8,r8e=56,N_t=.45,D_t=360,T_t='input,textarea,select,[contenteditable="true"],[role="textbox"]',R_t=n=>n==="touch"||n==="pen",P_t=n=>n instanceof HTMLElement&&n.closest(T_t)!=null;function A_t({isOpen:n,onClose:e,sheetRef:t}){const i=C.useRef(null),s=C.useRef(0),r=()=>{const h=t.current;h!=null&&(h.style.removeProperty("--vf-mobile-bottom-sheet-drag-y"),h.removeAttribute("data-mobile-bottom-sheet-dragging"))};C.useEffect(()=>{n||r()},[n]);const o=(h,f)=>{var w;const g=i.current;if(g==null)return;const m=h-g.startY,p=Math.max(1,f-g.startTime),_=m/p,b=m>r8e||_>N_t,y=g.dragging;if(i.current=null,(w=t.current)==null||w.removeAttribute("data-mobile-bottom-sheet-dragging"),y&&(s.current=Date.now()+D_t),b){e(),window.setTimeout(r,260);return}r()};return{onClickCapture:h=>{Date.now()>s.current||(h.preventDefault(),h.stopPropagation())},onPointerCancel:()=>{const h=i.current;if((h==null?void 0:h.dragging)===!0&&h.lastY-h.startY>r8e){e(),window.setTimeout(r,260),i.current=null;return}i.current=null,r()},onPointerDown:h=>{!n||!R_t(h.pointerType)||P_t(h.target)||(i.current={dragging:!1,lastY:h.clientY,pointerId:h.pointerId,startTime:h.timeStamp,startX:h.clientX,startY:h.clientY},h.currentTarget.setPointerCapture(h.pointerId))},onPointerMove:h=>{const f=i.current;if(f==null||f.pointerId!==h.pointerId)return;const g=h.clientX-f.startX,m=h.clientY-f.startY,p=Math.abs(g),_=Math.abs(m);if(f.lastY=h.clientY,!f.dragging){if(_<M_t||_<=p*1.2)return;f.dragging=!0,h.currentTarget.setAttribute("data-mobile-bottom-sheet-dragging","true")}h.cancelable&&h.preventDefault(),h.currentTarget.style.setProperty("--vf-mobile-bottom-sheet-drag-y",`${Math.round(Math.max(0,m))}px`)},onPointerUp:h=>{o(h.clientY,h.timeStamp)}}}function O_t({actions:n,isOpen:e,languageActions:t,languageLabel:i,moreLabel:s,onClose:r,themeActions:o,themeLabel:a}){var f,g;const l=C.useRef(null),c=A_t({isOpen:e,onClose:r,sheetRef:l}),d=((f=t.find(m=>m.active))==null?void 0:f.key)??((g=t[0])==null?void 0:g.key)??"",u=m=>{m.onSelect(),r()},h=m=>{m.onSelect()};return v.jsxs(v.Fragment,{children:[v.jsx("button",{type:"button",className:`nav-rail-compact-sheet-backdrop ${e?"is-open":""}`,"aria-hidden":!e,tabIndex:-1,onClick:r}),v.jsxs("div",{ref:l,className:`nav-rail-compact-sheet ${e?"is-open":""}`,role:"dialog","aria-modal":e?"true":void 0,"aria-hidden":!e,"aria-label":s,...c,children:[v.jsx("div",{className:"nav-rail-compact-sheet__handle"}),n.length>0&&v.jsxs("div",{className:"nav-rail-compact-sheet__section",children:[v.jsxs("div",{className:"nav-rail-compact-sheet__section-title",children:[v.jsx("span",{className:"material-symbols-rounded nav-rail-compact-sheet__section-title-icon",children:"tune"}),v.jsx("span",{children:s})]}),v.jsx("div",{className:"nav-rail-compact-sheet__actions",children:n.map(m=>v.jsxs("button",{type:"button",className:`nav-rail-compact-sheet__action ${m.active?"is-active":""}`,onClick:()=>u(m),children:[v.jsx("span",{className:"material-symbols-rounded",children:m.icon}),v.jsx("span",{children:m.label})]},m.key))})]}),v.jsxs("div",{className:"nav-rail-compact-sheet__section",children:[v.jsxs("div",{className:"nav-rail-compact-sheet__section-title",children:[v.jsx("span",{className:"material-symbols-rounded nav-rail-compact-sheet__section-title-icon",children:"palette"}),v.jsx("span",{children:a})]}),v.jsx("div",{className:"nav-rail-compact-sheet__segmented",children:o.map(m=>v.jsxs("button",{type:"button",className:`nav-rail-compact-sheet__segment ${m.active?"is-active":""}`,onClick:()=>h(m),children:[m.icon!=null&&v.jsx("span",{className:"material-symbols-rounded nav-rail-compact-sheet__segment-icon",children:m.icon}),v.jsx("span",{children:m.label})]},m.key))})]}),v.jsxs("div",{className:"nav-rail-compact-sheet__section",children:[v.jsxs("div",{className:"nav-rail-compact-sheet__section-title",children:[v.jsx("span",{className:"material-symbols-rounded nav-rail-compact-sheet__section-title-icon",children:"language"}),v.jsx("span",{children:i})]}),v.jsxs("label",{className:"nav-rail-compact-sheet__select-shell",children:[v.jsx("span",{className:"material-symbols-rounded nav-rail-compact-sheet__select-icon",children:"translate"}),v.jsx("select",{className:"nav-rail-compact-sheet__select",value:d,"aria-label":i,onChange:m=>{const p=t.find(_=>_.key===m.target.value);p!=null&&h(p)},children:t.map(m=>v.jsx("option",{value:m.key,children:m.label},m.key))}),v.jsx("span",{className:"material-symbols-rounded nav-rail-compact-sheet__select-chevron",children:"expand_more"})]})]})]})]})}function F_t({ariaHidden:n=!1,currentPath:e,languageActions:t,languageLabel:i,moreLabel:s,moreSheetActions:r,navItems:o,themeActions:a,themeLabel:l,onNavClick:c}){const[d,u]=C.useState(!1);return C.useEffect(()=>{u(!1)},[e]),C.useEffect(()=>{n&&u(!1)},[n]),v.jsxs("div",{className:"nav-rail nav-rail--compact","aria-hidden":n||void 0,children:[v.jsxs("div",{className:"nav-rail-compact-list",children:[o.map(h=>v.jsx(qe,{type:"text",className:`nav-item nav-item--compact ${h.active?"active":""}`,title:h.label,"aria-label":h.label,onClick:()=>{u(!1),c(h.key,h.path)},icon:v.jsx("span",{className:"material-symbols-rounded",children:h.icon})},h.key)),v.jsx(qe,{type:"text",className:`nav-item nav-item--compact ${d||e==="/config"?"active":""}`,title:s,"aria-expanded":d,"aria-haspopup":"dialog","aria-label":s,onClick:()=>u(h=>!h),icon:v.jsx("span",{className:"material-symbols-rounded",children:"more_horiz"})})]}),v.jsx(O_t,{actions:r,isOpen:d,languageActions:t,languageLabel:i,moreLabel:s,onClose:()=>u(!1),themeActions:a,themeLabel:l})]})}function B_t(){const{t:n}=ht(),{message:e}=Vs.useApp(),{mutate:t}=Jy(),{data:i}=Gn("/api/auth/status",vAe),s=ZW(),r=(i==null?void 0:i.enabled)===!0,o=te.useCallback(async()=>{try{await t("/api/auth/status")}catch{}},[t]),a=te.useCallback(()=>{sAe({clearCurrentServer:!0}),window.location.reload()},[]),l=te.useCallback(async()=>{try{await V7t(),await o()}catch(u){fAe(),await o(),e.error(Ii(u,n("auth.logoutFailed")))}},[e,o,n]),c=te.useMemo(()=>{const u=[];return s&&u.push({key:"change-server",label:n("auth.changeServer"),icon:v.jsx("span",{className:"material-symbols-rounded nav-menu-icon",children:"sync_alt"}),onClick:a}),r&&(u.length>0&&u.push({key:"account-divider",type:"divider"}),u.push({key:"logout",label:n("auth.logout"),danger:!0,icon:v.jsx("span",{className:"material-symbols-rounded nav-menu-icon",children:"logout"}),onClick:()=>{l()}})),u},[r,s,a,l,n]),d=te.useMemo(()=>[...s?[{icon:"sync_alt",key:"change-server",label:n("auth.changeServer"),onSelect:a}]:[],...r?[{icon:"logout",key:"logout",label:n("auth.logout"),onSelect:()=>{l()}}]:[]],[r,s,a,l,n]);return{accountItems:c,accountMenuLabel:n("auth.accountMenu"),compactAccountActions:d,showAccountMenu:c.length>0}}function $_t({currentPath:n,navigate:e,onOpenSidebar:t,showSidebar:i,t:s}){const r=[];return i&&t!=null&&r.push({active:n==="/"||n.startsWith("/session/"),icon:"menu",key:"sessions",label:s("common.sessions"),onSelect:t}),r.push({active:n==="/config",icon:"settings",key:"settings",label:s("common.settings"),onSelect:()=>{e("/config")}}),r}function H_t({setThemeMode:n,t:e,themeMode:t}){return[{active:t==="light",icon:"light_mode",key:"light",label:e("common.themeLight"),onSelect:()=>{n("light"),localStorage.setItem("theme","light")}},{active:t==="dark",icon:"dark_mode",key:"dark",label:e("common.themeDark"),onSelect:()=>{n("dark"),localStorage.setItem("theme","dark")}},{active:t==="system",icon:"desktop_windows",key:"system",label:e("common.themeSystem"),onSelect:()=>{n("system"),localStorage.setItem("theme","system")}}]}function V_t({currentLanguage:n,onChangeLanguage:e}){return[{active:n.startsWith("zh"),key:"zh",label:"简体中文",onSelect:()=>{e("zh")}},{active:n.startsWith("en"),key:"en",label:"English",onSelect:()=>{e("en")}}]}function j_t({currentLanguage:n,onChangeLanguage:e}){return[{key:"zh",label:"简体中文",icon:n.startsWith("zh")?v.jsx("span",{className:"material-symbols-rounded nav-menu-icon active",children:"check"}):v.jsx("div",{className:"nav-menu-icon-placeholder"}),onClick:()=>{e("zh")}},{key:"en",label:"English",icon:n.startsWith("en")?v.jsx("span",{className:"material-symbols-rounded nav-menu-icon active",children:"check"}):v.jsx("div",{className:"nav-menu-icon-placeholder"}),onClick:()=>{e("en")}}]}function W_t({setThemeMode:n,t:e,themeMode:t}){return[{key:"light",label:e("common.themeLight"),icon:t==="light"?v.jsx("span",{className:"material-symbols-rounded nav-menu-icon active",children:"check"}):v.jsx("span",{className:"material-symbols-rounded nav-menu-icon",children:"light_mode"}),onClick:()=>{n("light"),localStorage.setItem("theme","light")}},{key:"dark",label:e("common.themeDark"),icon:t==="dark"?v.jsx("span",{className:"material-symbols-rounded nav-menu-icon active",children:"check"}):v.jsx("span",{className:"material-symbols-rounded nav-menu-icon",children:"dark_mode"}),onClick:()=>{n("dark"),localStorage.setItem("theme","dark")}},{key:"system",label:e("common.themeSystem"),icon:t==="system"?v.jsx("span",{className:"material-symbols-rounded nav-menu-icon active",children:"check"}):v.jsx("span",{className:"material-symbols-rounded nav-menu-icon",children:"desktop_windows"}),onClick:()=>{n("system"),localStorage.setItem("theme","system")}}]}function z_t({currentPath:n,t:e}){return[{key:"sessions",icon:"chat_bubble",label:e("common.sessions"),path:"/",active:n==="/"||n.startsWith("/session/")},{key:"knowledge",icon:"library_books",label:e("common.knowledgeBase"),path:"/knowledge",active:n==="/knowledge"},{key:"automation",icon:"schedule",label:e("common.automation"),path:"/automation",active:n==="/automation"},{key:"benchmark",icon:"speed",label:e("common.benchmark"),path:"/benchmark",active:n==="/benchmark"},{key:"archive",icon:"archive",label:e("common.archivedSessions"),path:"/archive",active:n==="/archive"}]}function o8e({ariaHidden:n=!1,isCompactLayout:e=!1,onOpenSidebar:t,showSidebar:i=!1}){const{t:s,i18n:r}=ht(),[o,a]=z9(GW),l=Iu(),c=E3(),{isTouchInteraction:d}=Mr(),{accountItems:u,accountMenuLabel:h,compactAccountActions:f,showAccountMenu:g}=B_t(),m=c.pathname,p=E=>d?void 0:E,_=te.useMemo(()=>j_t({currentLanguage:r.language,onChangeLanguage:E=>r.changeLanguage(E)}),[r.language]),b=te.useMemo(()=>W_t({setThemeMode:a,t:s,themeMode:o}),[a,s,o]),y=te.useMemo(()=>z_t({currentPath:m,t:s}),[m,s]),w=te.useMemo(()=>[...$_t({currentPath:m,navigate:l,onOpenSidebar:t,showSidebar:i,t:s}),...f],[f,m,l,t,i,s]),S=te.useMemo(()=>H_t({setThemeMode:a,t:s,themeMode:o}),[a,s,o]),x=te.useMemo(()=>V_t({currentLanguage:r.language,onChangeLanguage:E=>{r.changeLanguage(E)}}),[r.language]),L=(E,I)=>{l(I)};return e?v.jsx(F_t,{ariaHidden:n,currentPath:m,languageActions:x,languageLabel:s("common.language"),moreLabel:s("common.moreActions"),moreSheetActions:w,navItems:y,themeActions:S,themeLabel:s("common.theme"),onNavClick:L}):v.jsxs("div",{className:"nav-rail","aria-hidden":n||void 0,children:[v.jsx("div",{className:"nav-rail-top",children:y.map(E=>v.jsx(Qe,{title:p(E.label),placement:"right",children:v.jsx("span",{children:v.jsx(qe,{type:"text",className:`nav-item ${E.active?"active":""}`,onClick:()=>L(E.key,E.path),icon:v.jsx("span",{className:"material-symbols-rounded",children:E.icon})})})},E.key))}),v.jsxs("div",{className:"nav-rail-bottom",children:[v.jsx(Qe,{title:p(s("common.theme")),placement:"right",children:v.jsx("span",{children:v.jsx(Wo,{menu:{items:b},placement:"topRight",trigger:["click"],children:v.jsx(qe,{type:"text",className:"nav-item",icon:v.jsx("span",{className:"material-symbols-rounded",children:o==="light"?"light_mode":o==="dark"?"dark_mode":"desktop_windows"})})})})}),v.jsx(Qe,{title:p(s("common.language")),placement:"right",children:v.jsx("span",{children:v.jsx(Wo,{menu:{items:_},placement:"topRight",trigger:["click"],children:v.jsx(qe,{type:"text",className:"nav-item",icon:v.jsx("span",{className:"material-symbols-rounded",children:"language"})})})})}),g&&v.jsx(Qe,{title:p(h),placement:"right",children:v.jsx("span",{children:v.jsx(Wo,{menu:{items:u},placement:"topRight",trigger:["click"],children:v.jsx(qe,{type:"text",className:"nav-item",icon:v.jsx("span",{className:"material-symbols-rounded",children:"account_circle"})})})})}),v.jsx(Qe,{title:p(s("common.settings")),placement:"right",children:v.jsx("span",{children:v.jsx(qe,{type:"text",className:`nav-item ${m==="/config"?"active":""}`,icon:v.jsx("span",{className:"material-symbols-rounded",children:"settings"}),onClick:()=>void l("/config")})})})]})]})}async function G3e(n,e={}){const t=Bl(`/api/adapters/${encodeURIComponent(n)}/accounts`);return e.model!=null&&e.model.trim()!==""&&t.searchParams.set("model",e.model),e.account!=null&&e.account.trim()!==""&&t.searchParams.set("account",e.account),e.refresh===!0&&t.searchParams.set("refresh","true"),Rn(t)}async function a8e(n,e,t={}){const i=Bl(`/api/adapters/${encodeURIComponent(n)}/accounts/${encodeURIComponent(e)}`);return t.model!=null&&t.model.trim()!==""&&i.searchParams.set("model",t.model),t.refresh===!0&&i.searchParams.set("refresh","true"),Rn(i)}async function LO(n,e,t){return Rn(Bl(`/api/adapters/${encodeURIComponent(n)}/accounts/actions`),{method:"POST",headers:go,body:JSON.stringify(e),...t})}async function UAe(){return Rn("/api/agent-rooms")}async function X3e(n){return Rn(`/api/agent-rooms/${encodeURIComponent(n)}`)}async function Iee(n,e){return Rn(`/api/agent-rooms/${encodeURIComponent(n)}`,{method:"PATCH",headers:go,body:JSON.stringify(e)})}async function U_t(n,e){return Rn(`/api/agent-rooms/${encodeURIComponent(n)}/messages`,{method:"POST",headers:go,body:JSON.stringify(e)})}const K_t=U_t;async function Z_t(){return Rn("/api/automation/rules")}async function q_t(n){return Rn("/api/automation/rules",{method:"POST",headers:go,body:JSON.stringify(n)})}async function l8e(n,e){return Rn(`/api/automation/rules/${n}`,{method:"PATCH",headers:go,body:JSON.stringify(e)})}async function G_t(n){return Rn(`/api/automation/rules/${n}`,{method:"DELETE"})}async function X_t(n){return Rn(`/api/automation/rules/${n}/run`,{method:"POST"})}async function Y_t(n,e=50){const t=Bl(`/api/automation/rules/${n}/runs`);return t.searchParams.set("limit",e.toString()),Rn(t)}async function Q_t(){return Rn("/api/benchmark/categories")}async function J_t(n){const e=Bl("/api/benchmark/cases");return Rn(e)}async function evt(n,e){return Rn(`/api/benchmark/results/${encodeURIComponent(n)}/${encodeURIComponent(e)}`)}async function $D(n){return UM("/api/benchmark/run",{method:"POST",headers:go,body:JSON.stringify(n)},"Failed to start benchmark run")}async function tvt(n){return Rn(`/api/benchmark/runs/${encodeURIComponent(n)}`)}async function Z0(){return Rn("/api/config")}async function nvt(){return Rn("/api/config/schema")}async function Y3e(n,e,t){return UM("/api/config",{method:"PATCH",headers:go,body:JSON.stringify({source:n,section:e,value:t})},"[api] update config failed:")}async function KAe(n){return Rn(`/api/sessions/${n}/git`)}async function ZAe(){return Rn("/api/workspace/git")}async function ivt(n){return Rn(`/api/sessions/${n}/git/branches`)}async function svt(){return Rn("/api/workspace/git/branches")}async function rvt(n){return Rn(`/api/sessions/${n}/git/worktrees`)}async function ovt(){return Rn("/api/workspace/git/worktrees")}async function avt(n,e){return Rn(`/api/sessions/${n}/git/checkout`,{method:"POST",headers:go,body:JSON.stringify(e)})}async function lvt(n,e){return Rn(`/api/sessions/${n}/git/branches`,{method:"POST",headers:go,body:JSON.stringify(e)})}async function cvt(n,e){return Rn(`/api/sessions/${n}/git/commit`,{method:"POST",headers:go,body:JSON.stringify(e)})}async function qAe(n,e={}){return Rn(`/api/sessions/${n}/git/push`,{method:"POST",headers:go,body:JSON.stringify(e)})}async function dvt(n){return Rn(`/api/sessions/${n}/git/sync`,{method:"POST"})}async function uvt(){return Rn("/api/ai/skills")}async function hvt(n){return Rn("/api/ai/skills",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})}async function fvt(n){return Rn("/api/ai/skills/import",{method:"POST",headers:{"Content-Type":n.type||"application/octet-stream","x-file-name":encodeURIComponent(n.name)},body:n})}async function gvt(n){const e=Bl("/api/ai/specs/detail");return e.searchParams.set("path",n),Rn(e)}async function mvt(n){const e=Bl("/api/ai/rules/detail");return e.searchParams.set("path",n),Rn(e)}async function pvt(n="active"){return Rn(n==="archived"?"/api/sessions/archived":"/api/sessions")}function XW(n){return`/api/sessions/${encodeURIComponent(n)}`}async function GAe(n){return Rn(XW(n))}async function Cvt(n,e,t,i,s){return Rn("/api/sessions",{method:"POST",headers:go,body:JSON.stringify({title:n,initialMessage:e,initialContent:t,model:i,start:s==null?void 0:s.start,parentSessionId:s==null?void 0:s.parentSessionId,id:s==null?void 0:s.id,promptType:s==null?void 0:s.promptType,promptName:s==null?void 0:s.promptName,effort:s==null?void 0:s.effort,permissionMode:s==null?void 0:s.permissionMode,adapter:s==null?void 0:s.adapter,account:s==null?void 0:s.account,updateSkills:s==null?void 0:s.updateSkills,workspace:s==null?void 0:s.workspace})})}async function _vt(n,e,t,i){return Rn(`/api/sessions/${n}/messages/${e}/branch`,{method:"POST",headers:go,body:JSON.stringify({action:t,content:i==null?void 0:i.content,title:i==null?void 0:i.title})})}async function XAe(n,e){const t=Bl(`/api/sessions/${n}/messages`);return Rn(t)}async function vvt(n){return Rn(`/api/sessions/${n}/workspace`)}async function bvt(n){return Rn(`/api/sessions/${n}/workspace/create-worktree`,{method:"POST"})}async function yvt(n){return Rn(`/api/sessions/${n}/workspace/transfer-local`,{method:"POST"})}async function wvt(n,e){const t=Bl(`/api/sessions/${n}/workspace/tree`);return e!=null&&e.trim()!==""&&t.searchParams.set("path",e),Rn(t)}async function Svt(n,e){const t=Bl(`/api/sessions/${n}/workspace/file`);return t.searchParams.set("path",e),Rn(t)}function xvt(n,e){const t=Bl(`/api/sessions/${n}/workspace/resource`);return t.searchParams.set("path",e),t.toString()}async function Lvt(n,e,t){return Rn(`/api/sessions/${n}/workspace/file`,{method:"PUT",headers:go,body:JSON.stringify({path:e,content:t})})}async function kvt(n,e,t){return Rn(`/api/sessions/${n}/events`,{method:"POST",headers:go,body:JSON.stringify({type:"interaction_response",id:e,data:t})})}async function Ob(n,e={}){const t=Bl(`/api/sessions/${n}`);return e.force===!0&&t.searchParams.set("force","true"),UM(t,{method:"DELETE"},"[api] delete session failed:")}async function f1(n,e){return Rn(`/api/sessions/${n}`,{method:"PATCH",headers:go,body:JSON.stringify(e)})}async function Evt(n,e){return f1(n,{title:e})}async function Ivt(n,e,t){return Rn(`/api/sessions/${n}/queued-messages`,{method:"POST",headers:go,body:JSON.stringify({mode:e,content:t})})}async function Mvt(n,e,t){return Rn(`/api/sessions/${n}/queued-messages/${e}`,{method:"PATCH",headers:go,body:JSON.stringify({content:t})})}async function Nvt(n,e){return Rn(`/api/sessions/${n}/queued-messages/${e}`,{method:"DELETE"})}async function Dvt(n,e,t){return Rn(`/api/sessions/${n}/queued-messages/${e}/move`,{method:"POST",headers:go,body:JSON.stringify({mode:t})})}async function Tvt(n,e,t){return Rn(`/api/sessions/${n}/queued-messages/reorder`,{method:"POST",headers:go,body:JSON.stringify({mode:e,ids:t})})}async function Rvt(n={}){const e=Bl("/api/skill-hub/search");return n.limit!=null&&e.searchParams.set("limit",String(n.limit)),n.registry!=null&&n.registry!==""&&e.searchParams.set("registry",n.registry),n.query!=null&&n.query!==""&&e.searchParams.set("q",n.query),Rn(e)}async function Pvt(n){return Rn("/api/skill-hub/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})}async function Avt(n){const e=Bl("/api/skill-hub/skills-cli/search");return e.searchParams.set("source",n.source),n.limit!=null&&e.searchParams.set("limit",String(n.limit)),n.query!=null&&n.query!==""&&e.searchParams.set("q",n.query),n.registry!=null&&n.registry!==""&&e.searchParams.set("registry",n.registry),Rn(e)}async function Ovt(n){return Rn("/api/skill-hub/skills-cli/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)})}async function Fvt(n){const e=Bl("/api/workspace/tree");return n!=null&&n.trim()!==""&&e.searchParams.set("path",n),Rn(e)}async function Bvt(n){const e=Bl("/api/workspace/file");return e.searchParams.set("path",n),Rn(e)}function $vt(n){const e=Bl("/api/workspace/resource");return e.searchParams.set("path",n),e.toString()}async function Hvt(n,e){return Rn("/api/workspace/file",{method:"PUT",headers:go,body:JSON.stringify({path:n,content:e})})}async function Q3e(){return Rn("/api/worktree-environments")}const J3e=n=>n==null?"":`?source=${encodeURIComponent(n)}`;async function Vvt(n,e){return Rn(`/api/worktree-environments/${encodeURIComponent(n)}${J3e(e)}`)}async function YAe(n,e,t){return Rn(`/api/worktree-environments/${encodeURIComponent(n)}${J3e(t)}`,{method:"PUT",headers:go,body:JSON.stringify(e)})}async function jvt(n,e){return Rn(`/api/worktree-environments/${encodeURIComponent(n)}${J3e(e)}`,{method:"DELETE"})}function QAe({children:n,className:e,compact:t=!1,collapsed:i=!1,primaryAction:s,sideAction:r}){const o=["sidebar-list-header",t?"sidebar-list-header--compact":"",i?"sidebar-list-header--collapsed":"",e].filter(Boolean).join(" ");return v.jsxs("div",{className:o,children:[v.jsxs("div",{className:"sidebar-list-header__top",children:[v.jsx("div",{className:"sidebar-list-header__primary",children:s}),r!=null&&v.jsx("div",{className:"sidebar-list-header__side",children:r})]}),!i&&n!=null&&v.jsx("div",{className:"sidebar-list-header__content",children:n})]})}function JAe({children:n,className:e}){return v.jsx("div",{className:["sidebar-list-collapsed-actions",e].filter(Boolean).join(" "),children:n})}function kO({active:n=!1,ariaLabel:e,buttonRef:t,className:i,disabled:s,filled:r=!1,icon:o,tooltip:a,tooltipPlacement:l="bottom",onClick:c}){return v.jsx(Qe,{title:a,placement:l,children:v.jsx(qe,{ref:t,className:["sidebar-list-collapsed-actions__control",n?"active":"",i].filter(Boolean).join(" "),type:"text","aria-label":e,disabled:s,onClick:c,children:v.jsx("span",{className:`material-symbols-rounded ${r?"filled":""}`,children:o})})})}function eOe({allowClear:n=!0,className:e,disabled:t,placeholder:i,suffix:s,value:r,onChange:o}){return v.jsx(yn,{className:["sidebar-list-header__search-input",e].filter(Boolean).join(" "),disabled:t,placeholder:i,value:r,onChange:o,prefix:v.jsx("span",{className:"material-symbols-rounded sidebar-list-header__search-icon",children:"search"}),suffix:s,allowClear:n})}const Fb=wu({}),ehe=new Set,Wvt=n=>{ehe.add(n)},HD=n=>{ehe.delete(n)},c8e=n=>ehe.has(n),d8e=()=>{var n;return((n=globalThis.crypto)==null?void 0:n.randomUUID)!=null?globalThis.crypto.randomUUID():`local-session-${Date.now()}-${Math.random().toString(16).slice(2)}`},zvt=n=>{var s;if(typeof n=="string")return n.trim();const e=n==null?void 0:n.find(r=>r.type==="text"&&r.text.trim()!=="");if(e!=null)return e.text.trim();const t=n==null?void 0:n.find(r=>r.type==="file"&&r.path.trim()!=="");if(t!=null)return t.path.trim();const i=n==null?void 0:n.find(r=>r.type==="image");return i!=null?((s=i.name)==null?void 0:s.trim())??"":""},Uvt=n=>{var t;const e=((t=n.split(`
461
461
  `)[0])==null?void 0:t.trim())??"";if(e!=="")return e.length>50?`${e.slice(0,50)}...`:e},Kvt=(n,e=Date.now())=>{const t=n.initialContent??n.initialMessage??"",i=zvt(t),s=n.title??Uvt(i);return{message:{id:`${n.id}:optimistic-user-message`,role:"user",content:t,createdAt:e},request:n,session:{id:n.id,title:s,createdAt:e,messageCount:1,lastMessage:i===""?void 0:i,lastUserMessage:i===""?void 0:i,isArchived:!1,isStarred:!1,tags:[],status:"running",model:n.model,adapter:n.options.adapter,account:n.options.account,permissionMode:n.options.permissionMode,effort:n.options.effort,promptType:n.options.promptType,promptName:n.options.promptName},status:"creating"}},Zvt=n=>({...n,errorMessage:void 0,session:{...n.session,status:"running"},status:"creating"}),qvt=(n,e)=>({...n,errorMessage:e,session:{...n.session,status:"failed"},status:"failed"}),Gvt=(n,e)=>{const t=new Set(n.map(r=>r.id)),i=n.map(r=>{var o;return((o=e[r.id])==null?void 0:o.session)??r}),s=Object.values(e).map(r=>r.session).filter(r=>r.isArchived!==!0&&!t.has(r.id));return[...i,...s]},Mee=(n,e)=>n.filter(t=>t.id!==e),Xvt=(n,e)=>{if(!n.startsWith(e))return n===""?"/":n;const t=n.slice(e.length);return t===""?"/":t.startsWith("/")?t:`/${t}`},Yvt=({clientBase:n,currentHash:e,currentPathname:t,currentSearch:i,defaults:s,keySet:r,keys:o,omit:a,patch:l})=>{const c=new URLSearchParams(i),d=new URLSearchParams,u=o.reduce((h,f)=>{const g=c.get(f),m=(s==null?void 0:s[f])??"";return h[f]=g??m,h},{});Object.assign(u,l),o.forEach(h=>{const f=u[h]??"";f===""||(a!=null&&a[h]?a[h](f):!1)||d.set(h,f)});for(const[h,f]of c.entries())r.has(h)||d.append(h,f);return d.toString()===c.toString()?null:{pathname:Xvt(t,n),search:d.toString()===""?"":`?${d.toString()}`,hash:e}},Rf=({keys:n,defaults:e,omit:t})=>{const i=Iu(),[s]=qm(),r=C.useMemo(()=>new Set(n),[n]),o=C.useMemo(()=>n.reduce((l,c)=>{const d=s.get(c),u=(e==null?void 0:e[c])??"";return l[c]=d??u,l},{}),[e,n,s]),a=C.useCallback(l=>{const c=typeof window>"u"?{hash:"",pathname:"/",search:s.toString()===""?"":`?${s.toString()}`}:window.location,d=Yvt({clientBase:qW(),currentHash:c.hash,currentPathname:c.pathname,currentSearch:c.search,defaults:e,keySet:r,keys:n,omit:t,patch:l});d!=null&&i(d,{replace:!0})},[e,r,n,i,t,s]);return{values:o,update:a,searchParams:s}},u8e=n=>Array.from(new Set(n.split(",").map(e=>e.trim()).filter(Boolean))),h8e=n=>Array.from(new Set(n.map(e=>e.trim()).filter(Boolean))).join(",");function tOe(){const{values:n,update:e}=Rf({keys:["sidebar","search","tag","adapter","sort"],defaults:{sidebar:"",search:"",tag:"",adapter:"",sort:""},omit:{sidebar:d=>d==="",search:d=>d==="",tag:d=>d==="",adapter:d=>d==="",sort:d=>d===""}}),t=C.useMemo(()=>u8e(n.tag),[n.tag]),i=C.useMemo(()=>u8e(n.adapter),[n.adapter]),s=n.search,r=n.sort==="asc"||n.sort==="desc"?n.sort:void 0,o=r??"desc",a=n.sidebar==="collapsed",l=s.trim()!==""||t.length>0||i.length>0,c=l||r!=null;return{adapterFilters:i,hasActiveFilterConditions:l,hasActiveSearchControls:c,isSidebarCollapsed:a,searchQuery:s,setSortOrder:d=>e({sort:d??""}),setAdapterFilters:d=>e({adapter:h8e(d)}),setSearchQuery:d=>e({search:d}),setSidebarCollapsed:d=>e({sidebar:d?"collapsed":""}),setTagFilters:d=>e({tag:h8e(d)}),sortOrder:o,sortSelection:r,tagFilters:t}}const Qvt="cmd+enter",f8e="enter",the=n=>n===" "?"space":n.toLowerCase(),nOe=(n,e)=>{if(n==null||n.trim()==="")return null;const t=n.split("+").map(s=>s.trim()).filter(Boolean);if(t.length===0)return null;const i={key:"",metaKey:!1,ctrlKey:!1,altKey:!1,shiftKey:!1};for(const s of t){const r=s.toLowerCase();r==="cmd"||r==="command"||r==="meta"?i.metaKey=!0:r==="ctrl"||r==="control"?i.ctrlKey=!0:r==="alt"||r==="option"?i.altKey=!0:r==="shift"?i.shiftKey=!0:r==="mod"?e?i.metaKey=!0:i.ctrlKey=!0:i.key=the(r)}return i.key===""?null:i},nhe=(n,e)=>n==null||n.trim()===""?"":n.split("+").map(i=>i.trim()).filter(Boolean).map(i=>{const s=i.toLowerCase();return s==="mod"?e?"⌘":"Ctrl":s==="cmd"||s==="command"||s==="meta"?"⌘":s==="ctrl"||s==="control"?"Ctrl":s==="alt"||s==="option"?"Alt":s==="shift"?"Shift":s==="space"?"Space":s==="enter"?"Enter":s==="escape"||s==="esc"?"Esc":s==="tab"?"Tab":s==="backspace"?"Backspace":s==="delete"||s==="del"?"Delete":s==="arrowup"?"Up":s==="arrowdown"?"Down":s==="arrowleft"?"Left":s==="arrowright"?"Right":i.length===1?i.toUpperCase():i.charAt(0).toUpperCase()+i.slice(1)}).join("+"),Jvt=(n,e)=>n==null||n.trim()===""?[]:n.split("+").map(i=>i.trim()).filter(Boolean).map(i=>{const s=i.toLowerCase();return s==="mod"?{value:e?"⌘":"Ctrl",compact:e}:s==="cmd"||s==="command"||s==="meta"?{value:"⌘",compact:!0}:s==="ctrl"||s==="control"?{value:e?"⌃":"Ctrl",compact:e}:s==="alt"||s==="option"?{value:e?"⌥":"Alt",compact:e}:s==="shift"?{value:e?"⇧":"Shift",compact:e}:s==="space"?{value:"Space",compact:!1}:s==="enter"?{value:"Enter",compact:!1}:s==="escape"||s==="esc"?{value:e?"⎋":"Esc",compact:e}:s==="tab"?{value:e?"⇥":"Tab",compact:e}:s==="backspace"?{value:e?"⌫":"Backspace",compact:e}:s==="delete"||s==="del"?{value:e?"⌦":"Delete",compact:e}:s==="arrowup"?{value:"↑",compact:!0}:s==="arrowdown"?{value:"↓",compact:!0}:s==="arrowleft"?{value:"←",compact:!0}:s==="arrowright"?{value:"→",compact:!0}:i.length===1?{value:i.toUpperCase(),compact:!0}:{value:i.charAt(0).toUpperCase()+i.slice(1),compact:!1}}),EO=(n,e,t)=>{const i=nOe(e,t);return i==null||n.metaKey!==i.metaKey||n.ctrlKey!==i.ctrlKey||n.altKey!==i.altKey||n.shiftKey!==i.shiftKey?!1:the(n.key)===i.key},ebt=n=>{const e=the(n.key);if(["meta","control","shift","alt"].includes(e))return null;const t=[];return(n.metaKey||n.ctrlKey)&&t.push("mod"),n.shiftKey&&t.push("shift"),n.altKey&&t.push("alt"),t.push(e),t.join("+")},iOe=(n,e)=>{const t=nOe(n,e);return t==null||t.key!=="enter"||t.altKey||t.ctrlKey?null:!t.metaKey&&!t.shiftKey?"enter":!e||!t.metaKey?null:t.shiftKey?"cmd+shift+enter":"cmd+enter"},sOe=(n,e)=>n==null||n.trim()===""?e?Qvt:f8e:iOe(n,e)??f8e,pP=({shortcut:n,enabled:e=!0,isMac:t,onTrigger:i})=>{C.useEffect(()=>{if(!e)return;const s=r=>{EO(r,n,t)&&i(r)};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[e,t,i,n])},tbt=`
462
462
  <svg width="64" height="64" viewBox="0 0 64 64" fill="none" xmlns="http://www.w3.org/2000/svg">
463
463
  <g fill="#D97957">
@@ -521,7 +521,7 @@ Please change the parent <Route path="${y}"> to <Route path="${y==="/"?"*":`${y}
521
521
  </clipPath>
522
522
  </defs>
523
523
  </svg>
524
- `.trim(),Cbt=`data:image/svg+xml;utf8,${encodeURIComponent(pbt)}`,_bt="OpenCode",vbt={"claude-code":{title:ibt,icon:nbt},codex:{title:obt,icon:rbt},copilot:{title:cbt,icon:lbt},gemini:{title:hbt,icon:ubt},kimi:{title:mbt,icon:gbt},opencode:{title:_bt,icon:Cbt}},tw=n=>vbt[n]??{title:n,icon:void 0};var bbt={exports:{}};(function(n,e){(function(t,i){n.exports=i(RTe)})(_k,function(t){function i(o){return o&&typeof o=="object"&&"default"in o?o:{default:o}}var s=i(t),r={name:"zh-cn",weekdays:"星期日_星期一_星期二_星期三_星期四_星期五_星期六".split("_"),weekdaysShort:"周日_周一_周二_周三_周四_周五_周六".split("_"),weekdaysMin:"日_一_二_三_四_五_六".split("_"),months:"一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split("_"),monthsShort:"1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),ordinal:function(o,a){return a==="W"?o+"周":o+"日"},weekStart:1,yearStart:4,formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY/MM/DD",LL:"YYYY年M月D日",LLL:"YYYY年M月D日Ah点mm分",LLLL:"YYYY年M月D日ddddAh点mm分",l:"YYYY/M/D",ll:"YYYY年M月D日",lll:"YYYY年M月D日 HH:mm",llll:"YYYY年M月D日dddd HH:mm"},relativeTime:{future:"%s内",past:"%s前",s:"几秒",m:"1 分钟",mm:"%d 分钟",h:"1 小时",hh:"%d 小时",d:"1 天",dd:"%d 天",M:"1 个月",MM:"%d 个月",y:"1 年",yy:"%d 年"},meridiem:function(o,a){var l=100*o+a;return l<600?"凌晨":l<900?"早上":l<1100?"上午":l<1300?"中午":l<1800?"下午":"晚上"}};return s.default.locale(r,null,!0),r})})(bbt);var rOe={exports:{}};(function(n,e){(function(t,i){n.exports=i()})(_k,function(){return function(t,i,s){t=t||{};var r=i.prototype,o={future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"};function a(c,d,u,h){return r.fromToBase(c,d,u,h)}s.en.relativeTime=o,r.fromToBase=function(c,d,u,h,f){for(var g,m,p,_=u.$locale().relativeTime||o,b=t.thresholds||[{l:"s",r:44,d:"second"},{l:"m",r:89},{l:"mm",r:44,d:"minute"},{l:"h",r:89},{l:"hh",r:21,d:"hour"},{l:"d",r:35},{l:"dd",r:25,d:"day"},{l:"M",r:45},{l:"MM",r:10,d:"month"},{l:"y",r:17},{l:"yy",d:"year"}],y=b.length,w=0;w<y;w+=1){var S=b[w];S.d&&(g=h?s(c).diff(u,S.d,!0):u.diff(c,S.d,!0));var x=(t.rounding||Math.round)(Math.abs(g));if(p=g>0,x<=S.r||!S.r){x<=1&&w>0&&(S=b[w-1]);var L=_[S.l];f&&(x=f(""+x)),m=typeof L=="string"?L.replace("%d",x):L(x,d,S.l,p);break}}if(d)return m;var E=p?_.future:_.past;return typeof E=="function"?E(m):E.replace("%s",m)},r.to=function(c,d){return a(c,d,this,!0)},r.from=function(c,d){return a(c,d,this)};var l=function(c){return c.$u?s.utc():s()};r.toNow=function(c){return this.to(l(this),c)},r.fromNow=function(c){return this.from(l(this),c)}}})})(rOe);var ybt=rOe.exports;const oOe=z0(ybt),wbt=5,VD=[["#0f766e","#14b8a6"],["#1d4ed8","#60a5fa"],["#b45309","#f59e0b"],["#be123c","#fb7185"],["#4338ca","#818cf8"],["#15803d","#4ade80"],["#0e7490","#22d3ee"]],Sbt=n=>{let e=2166136261;for(let t=0;t<n.length;t+=1)e^=n.charCodeAt(t),e=Math.imul(e,16777619);return e>>>0},xbt=n=>{const e=Sbt(n),t=[];for(let i=0;i<wbt;i+=1){const s=[];for(let r=0;r<3;r+=1){const o=(e>>(i*3+r)%24&1)===1;s.push(o)}t.push(s[0],s[1],s[2],s[1],s[0])}return{accent:VD[e%VD.length][0],accentSoft:VD[(e>>>4)%VD.length][1],pixels:t}};function aOe({className:n,label:e,seed:t}){const i=C.useMemo(()=>xbt(t),[t]),s={"--room-pixel-avatar-accent":i.accent,"--room-pixel-avatar-accent-soft":i.accentSoft};return v.jsx("span",{className:["room-pixel-avatar",n].filter(Boolean).join(" "),"aria-label":e,"aria-hidden":e==null?!0:void 0,style:s,children:i.pixels.map((r,o)=>v.jsx("span",{className:["room-pixel-avatar__pixel",r?"room-pixel-avatar__pixel--filled":""].filter(Boolean).join(" ")},o))})}async function rf(n){try{return await navigator.clipboard.writeText(n.text),n.messageApi.success(n.successMessage),!0}catch{return n.messageApi.error(n.failureMessage),!1}}function lOe({entries:n,pendingAction:e,onCancelConfirm:t}){return v.jsx("div",{className:"session-context-menu",onContextMenu:i=>i.preventDefault(),children:n.map(i=>{if(i.type==="divider")return v.jsx("div",{className:"session-context-menu__divider"},i.key);const s=e===i.key;return v.jsxs("div",{role:"button",tabIndex:0,className:`session-context-menu__item session-context-menu__item--${i.key} ${i.danger?"is-danger":""} ${s?"is-confirming":""}`,onClick:r=>{r.preventDefault(),r.stopPropagation(),i.onClick()},onKeyDown:r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),i.onClick())},children:[v.jsxs("div",{className:"session-context-menu__meta",children:[v.jsx("span",{className:"material-symbols-rounded session-context-menu__icon",children:i.icon}),v.jsx("span",{className:"session-context-menu__label",children:s?i.confirmLabel??i.label:i.label})]}),s&&v.jsxs("div",{className:"session-context-menu__confirm-actions",children:[v.jsx("button",{type:"button",className:"session-context-menu__confirm-btn is-accept",onClick:r=>{r.preventDefault(),r.stopPropagation(),i.onClick()},children:v.jsx("span",{className:"material-symbols-rounded",children:"check"})}),v.jsx("button",{type:"button",className:"session-context-menu__confirm-btn is-cancel",onClick:r=>{r.preventDefault(),r.stopPropagation(),t()},children:v.jsx("span",{className:"material-symbols-rounded",children:"close"})})]})]},i.key)})})}const cOe=n=>{const e=new URL(globalThis.location.origin),t=qW().replace(/\/+$/,""),i=t===""?"":t;return e.pathname=`${i}/rooms/${encodeURIComponent(n)}`,e.search="",e.hash="",e.toString()},bv=n=>n.archivedAt!=null,Pg=n=>n.favoritedAt!=null;function Lbt({handlers:n,labels:e,room:t}){const i=Pg(t),s=bv(t);return[{key:"open-room",label:e.openRoom,icon:"open_in_new",onClick:n.onOpen},{key:"divider-metadata",type:"divider",label:"",icon:"",onClick:()=>{}},{key:"favorite-room",label:e.favoriteRoom,icon:i?"star":"star_border",onClick:n.onFavorite},{key:"archive-room",label:e.archiveRoom,confirmLabel:e.confirmArchiveRoom,icon:s?"unarchive":"archive",onClick:n.onArchive},{key:"divider-copy",type:"divider",label:"",icon:"",onClick:()=>{}},{key:"copy-room-link",label:e.copyRoomLink,icon:"link",onClick:n.onCopyLink},{key:"copy-room-id",label:e.copyRoomId,icon:"fingerprint",onClick:n.onCopyId}]}function dOe({children:n,onArchive:e,onFavorite:t,onSelect:i,room:s,trigger:r=["contextMenu"]}){const{t:o}=ht(),{message:a}=Vs.useApp(),[l,c]=C.useState(!1),[d,u]=C.useState(null),h=()=>{c(!1),u(null)},f=bv(s)?o("agentRoom.sidebar.unarchiveRoom"):o("agentRoom.sidebar.archiveRoom"),g=()=>{if(d==="archive-room"){h(),e(s.id,!bv(s));return}u("archive-room")},m=Lbt({room:s,labels:{openRoom:o("agentRoom.sidebar.openRoom"),favoriteRoom:Pg(s)?o("agentRoom.sidebar.unfavoriteRoom"):o("agentRoom.sidebar.favoriteRoom"),archiveRoom:f,confirmArchiveRoom:o("common.confirmAction",{action:f}),copyRoomLink:o("agentRoom.sidebar.copyRoomLink"),copyRoomId:o("agentRoom.sidebar.copyRoomId")},handlers:{onOpen:()=>{h(),i(s)},onFavorite:()=>{h(),t(s.id,!Pg(s))},onArchive:g,onCopyLink:()=>{h(),rf({text:cOe(s.id),messageApi:a,successMessage:o("agentRoom.sidebar.roomLinkCopied"),failureMessage:o("common.copyFailed")})},onCopyId:()=>{h(),rf({text:s.id,messageApi:a,successMessage:o("agentRoom.sidebar.roomIdCopied"),failureMessage:o("common.copyFailed")})}}});return v.jsx(Wo,{trigger:r,open:l,onOpenChange:p=>{c(p),p||u(null)},popupRender:()=>v.jsx(lOe,{entries:m,pendingAction:d,onCancelConfirm:()=>u(null)}),children:n})}function kbt({isTouchInteraction:n,onArchive:e,onFavorite:t,onSelect:i,room:s,showCompactActionMenu:r}){const{t:o}=ht(),a=C.useRef(null),[l,c]=C.useState(null),d=m=>n?void 0:m;C.useEffect(()=>{if(l==null)return;const m=p=>{var b;const _=p.target;if(!(_ instanceof Node)){c(null);return}(b=a.current)!=null&&b.contains(_)||c(null)};return document.addEventListener("pointerdown",m,!0),()=>{document.removeEventListener("pointerdown",m,!0)}},[l]);const u=bv(s)?o("agentRoom.sidebar.unarchiveRoom"):o("agentRoom.sidebar.archiveRoom"),h=o("common.confirmAction",{action:u}),f=()=>{if(l==="archive"){c(null),e(s.id,!bv(s));return}c("archive")},g=v.jsx(dOe,{room:s,trigger:["click"],onArchive:e,onFavorite:t,onSelect:i,children:v.jsx(qe,{type:"text",size:"small",className:"room-item__action-btn room-item__action-btn--more",title:o("common.moreActions"),"aria-label":o("common.moreActions"),onClick:m=>{m.stopPropagation()},icon:v.jsx("span",{className:"material-symbols-rounded",children:"more_horiz"})})});return r?v.jsx("div",{ref:a,className:"room-item__actions",children:g}):v.jsxs("div",{ref:a,className:"room-item__actions",onMouseLeave:()=>c(null),children:[v.jsx(Qe,{title:d(Pg(s)?o("agentRoom.sidebar.unfavoriteRoom"):o("agentRoom.sidebar.favoriteRoom")),children:v.jsx(qe,{type:"text",size:"small",className:`room-item__action-btn room-item__action-btn--favorite ${Pg(s)?"is-favorited":""}`,onClick:m=>{m.stopPropagation(),c(null),t(s.id,!Pg(s))},icon:v.jsx("span",{className:"material-symbols-rounded",children:"star"})})}),v.jsx(Qe,{title:d(l==="archive"?h:u),children:v.jsxs(qe,{type:"text",size:"small",className:`room-item__action-btn room-item__action-btn--archive ${l==="archive"?"is-confirming":""}`,onClick:m=>{m.stopPropagation(),f()},children:[v.jsx("span",{className:"material-symbols-rounded",children:bv(s)?"unarchive":"archive"}),l==="archive"&&v.jsx("span",{className:"room-item__action-label",children:h})]})})]})}nf.extend(oOe);function Ebt({isActive:n,isCompactLayout:e,isTouchInteraction:t,onArchive:i,onFavorite:s,onSelect:r,room:o}){const{t:a,i18n:l}=ht(),c=e||t,d=g=>t?void 0:g,u=C.useMemo(()=>{const g=nf(o.updatedAt??o.createdAt);return l.language==="zh"?g.locale("zh-cn"):g.locale("en"),{relative:g.fromNow(),full:g.format("YYYY-MM-DD HH:mm:ss")}},[l.language,o.createdAt,o.updatedAt]),h=C.useMemo(()=>o.lastMessage==null||o.lastMessage===""?null:o.lastMessage.length>60?`${o.lastMessage.slice(0,60)}...`:o.lastMessage,[o.lastMessage]),f=v.jsx(Wc.Item,{onClick:()=>r(o),className:`room-item ${n?"active":""} ${Pg(o)?"room-item--favorited":""} ${e?"room-item--compact":""} ${c?"room-item--touch":""}`,children:v.jsxs("div",{className:"room-item__content",children:[v.jsx("div",{className:`room-item__leading room-item__leading--${o.status}`,children:v.jsx(aOe,{className:"room-item__avatar",seed:o.id})}),v.jsxs("div",{className:"room-item__info",children:[v.jsxs("div",{className:"room-item__header",children:[v.jsxs("div",{className:"room-item__title",children:[v.jsx("span",{className:"room-item__title-text",children:o.title}),Pg(o)&&v.jsx("span",{className:"material-symbols-rounded room-item__favorite-icon","aria-label":a("agentRoom.sidebar.favoritedRoom"),title:a("agentRoom.sidebar.favoritedRoom"),children:"star"})]}),v.jsxs("div",{className:"room-item__header-side",children:[!e&&v.jsx(Qe,{title:d(u.full),children:v.jsx("span",{className:"room-item__time",children:u.relative})}),v.jsx(kbt,{room:o,isTouchInteraction:t,showCompactActionMenu:c,onArchive:i,onFavorite:s,onSelect:r})]})]}),!e&&h!=null&&v.jsx("div",{className:"room-item__last-message",children:h})]})]})});return v.jsx(dOe,{room:o,onArchive:i,onFavorite:s,onSelect:r,children:f})}function uOe({as:n="list-item",className:e,contentRef:t,dataSessionCardSource:i,dataSessionId:s,headerSide:r,infoClassName:o,lastMessage:a,leading:l,onClick:c,onDoubleClick:d,onMouseLeave:u,style:h,tags:f,title:g}){const m=v.jsxs("div",{ref:t,className:"session-item-content",children:[l,v.jsxs("div",{className:`session-info ${o??""}`.trim(),children:[v.jsxs("div",{className:"session-header",children:[v.jsx("div",{className:"session-title",children:g}),r!=null&&v.jsx("div",{className:"session-header-side",children:r})]}),a,f]})]});return n==="article"?v.jsx("article",{className:e,"data-session-card-source":i,"data-session-id":s,onClick:c,onDoubleClick:d,onMouseLeave:u,style:h,children:m}):v.jsx(Wc.Item,{className:e,"data-session-card-source":i,"data-session-id":s,onClick:c,onDoubleClick:d,onMouseLeave:u,style:h,children:m})}const Ibt=n=>`${qW()}/session/${n}`,Qw=(n,e)=>{const t=e==null?void 0:e.trim();return t!=null&&t!==""?`message-${n}-${t}`:`message-${n}`},hOe=(n,e)=>{const t=new URL(globalThis.location.origin);return t.pathname=Ibt(n),t.search="",t.hash=(e==null?void 0:e.anchorId)!=null&&e.anchorId!==""?`#${e.anchorId}`:"",t.toString()};function g8e({children:n,session:e,trigger:t=["contextMenu"],onArchive:i,onDelete:s,onRename:r,onStar:o}){const{t:a}=ht(),{message:l,modal:c}=Vs.useApp(),[d,u]=C.useState(!1),[h,f]=C.useState(null),g=()=>{u(!1),f(null)},m=_=>{if(h===_){if(g(),_==="archive"){i(e.id);return}s(e.id);return}f(_)},p=C.useMemo(()=>[{key:"star",label:e.isStarred?a("common.unstar"):a("common.star"),icon:e.isStarred?"star":"star_border",onClick:()=>{g(),o(e.id,!e.isStarred)}},{key:"rename",label:a("common.rename"),icon:"edit",onClick:()=>{g();let _=e.title??"";c.confirm({title:a("common.renameSession"),okText:a("common.confirm"),cancelText:a("common.cancel"),content:v.jsx(yn,{autoFocus:!0,defaultValue:e.title??"",placeholder:a("chat.enterTitle"),onChange:b=>{_=b.target.value}}),onOk:async()=>{const b=_.trim();if(b!==(e.title??"").trim())try{await r(e.id,b),l.success(a("chat.titleUpdated"))}catch{throw l.error(a("common.operationFailed")),new Error("rename-session-failed")}}})}},{key:"archive",label:e.isArchived?a("common.restore"):a("common.archive"),confirmLabel:a("common.confirmAction",{action:e.isArchived?a("common.restore"):a("common.archive")}),icon:e.isArchived?"unarchive":"archive",onClick:()=>{m("archive")}},{key:"delete",label:a("common.delete"),confirmLabel:a("common.confirmAction",{action:a("common.delete")}),icon:"delete",danger:!0,onClick:()=>{m("delete")}},{key:"divider-main",type:"divider",label:"",icon:"",onClick:()=>{}},{key:"copy-session-link",label:a("common.copySessionLink"),icon:"link",onClick:()=>{g(),rf({text:hOe(e.id),messageApi:l,successMessage:a("common.sessionLinkCopied"),failureMessage:a("common.copyFailed")})}},{key:"copy-session-id",label:a("common.copySessionId"),icon:"fingerprint",onClick:()=>{g(),rf({text:e.id,messageApi:l,successMessage:a("common.sessionIdCopied"),failureMessage:a("common.copyFailed")})}},{key:"copy-resume-command",label:a("common.copyResumeCommand"),icon:"terminal",onClick:()=>{g(),rf({text:`vf --resume ${e.id}`,messageApi:l,successMessage:a("common.resumeCommandCopied"),failureMessage:a("common.copyFailed")})}}],[l,c,i,s,r,o,h,e,a]);return v.jsx(Wo,{trigger:t,open:d,onOpenChange:_=>{u(_),_||f(null)},popupRender:()=>v.jsx(lOe,{entries:p,pendingAction:h,onCancelConfirm:()=>f(null)}),children:n})}nf.extend(oOe);function Mbt({session:n,isActive:e,isBatchMode:t,isCompactLayout:i,isSelected:s,isTouchInteraction:r,onSelect:o,onArchive:a,onDelete:l,onRename:c,onStar:d,onToggleSelect:u}){const{t:h,i18n:f}=ht(),g="automation:",m=C.useRef(null),[p,_]=C.useState(null),b=i||r,y=A=>r?void 0:A;C.useEffect(()=>{if(p==null)return;const A=O=>{var $;const F=O.target;if(!(F instanceof Node)){_(null);return}($=m.current)!=null&&$.contains(F)||_(null)};return document.addEventListener("pointerdown",A,!0),()=>{document.removeEventListener("pointerdown",A,!0)}},[p]);const w=C.useMemo(()=>{const A=nf(n.createdAt);return f.language==="zh"?A.locale("zh-cn"):A.locale("en"),{relative:A.fromNow(),full:A.format("YYYY-MM-DD HH:mm:ss")}},[n.createdAt,f.language]),S=n.isArchived?h("common.restore"):h("common.archive"),x=h("common.confirmAction",{action:S}),L=n.tags??[],E=i?L.slice(0,1):L,I=Math.max(L.length-E.length,0),M=n.title!=null&&n.title!==""?n.title:n.lastUserMessage!=null&&n.lastUserMessage!==""?n.lastUserMessage:h("common.newChat"),N=n.adapter!=null&&n.adapter!==""?tw(n.adapter):void 0,T=C.useMemo(()=>n.lastMessage==null||n.lastMessage===""?null:n.lastMessage.length>60?`${n.lastMessage.slice(0,60)}...`:n.lastMessage,[n.lastMessage]),D=C.useMemo(()=>A=>{if(!A.startsWith(g))return null;const O=A.split(":");return O.length<3?null:{ruleId:O[1],ruleTitle:O.slice(2).join(":")}},[g]),P=A=>{if(!A)return v.jsx("div",{className:`status-dot ${e?"active":""}`});let O="",F="";const $=h(`common.status.${A}`);switch(A){case"completed":O="check_circle",F="#52c41a";break;case"terminated":O="remove_circle",F="#bfbfbf";break;case"failed":O="cancel",F="#ff4d4f";break;case"running":O="sync",F="#1890ff";break;case"waiting_input":return v.jsx(Qe,{title:y($),children:v.jsx("div",{className:"waiting-input-indicator"})});default:return v.jsx("div",{className:`status-dot ${e?"active":""}`})}return v.jsx(Qe,{title:y($),children:v.jsx("span",{className:`material-symbols-rounded status-icon ${A==="running"?"spin":""}`,style:{color:F,fontSize:"16px",lineHeight:"16px",display:"flex",alignItems:"center",justifyContent:"center"},children:O})})},R=A=>{if(p===A){_(null),a(n.id);return}_(A)};return v.jsx(g8e,{session:n,onArchive:a,onDelete:l,onRename:c,onStar:d,children:v.jsx(uOe,{onClick:()=>t?u(n.id):o(n),onMouseLeave:()=>_(null),onDoubleClick:()=>{console.log("Session Details:",n)},className:`session-item ${e?"active":""} ${s?"selected":""} ${n.isStarred?"starred":""} ${i?"session-item--compact":""} ${b?"session-item--touch":""}`,contentRef:m,leading:v.jsxs("div",{className:`session-leading ${(N==null?void 0:N.icon)!=null?"has-adapter":""}`,children:[(N==null?void 0:N.icon)!=null&&v.jsx("img",{className:"session-adapter-icon",src:N.icon,alt:"","aria-hidden":"true"}),v.jsx("div",{className:`status-indicator ${(N==null?void 0:N.icon)!=null?"is-overlay":""}`,children:P(n.status)})]}),title:v.jsx("span",{className:"session-title-text",children:M}),headerSide:!t&&v.jsxs(v.Fragment,{children:[!i&&v.jsx(Qe,{title:y(w.full),children:v.jsx("span",{className:"time-display",children:w.relative})}),b?v.jsx(g8e,{session:n,trigger:["click"],onArchive:a,onDelete:l,onRename:c,onStar:d,children:v.jsx(qe,{type:"text",size:"small",className:"action-btn action-btn--more",title:h("common.moreActions"),"aria-label":h("common.moreActions"),onClick:A=>{A.stopPropagation()},icon:v.jsx("span",{className:"material-symbols-rounded",children:"more_horiz"})})}):v.jsxs("div",{className:"session-item-actions",children:[v.jsx(Qe,{title:y(n.isStarred?h("common.unstar"):h("common.star")),children:v.jsx(qe,{type:"text",size:"small",className:`action-btn star-btn ${n.isStarred?"starred":""}`,onClick:A=>{A.stopPropagation(),_(null),d(n.id,!n.isStarred)},icon:v.jsx("span",{className:`material-symbols-rounded ${n.isStarred?"filled":""}`,children:"star"})})}),v.jsx(Qe,{title:y(p==="archive"?x:S),children:v.jsxs(qe,{type:"text",size:"small",className:`action-btn archive-btn ${p==="archive"?"is-confirming":""}`,onClick:A=>{A.stopPropagation(),R("archive")},children:[v.jsx("span",{className:"material-symbols-rounded",children:n.isArchived?"unarchive":"archive"}),p==="archive"&&v.jsx("span",{className:"action-btn__label",children:x})]})})]})]}),infoClassName:t?"":"with-actions",lastMessage:!i&&T!=null&&v.jsx("div",{className:"last-message",children:T}),tags:E.length>0&&v.jsxs("div",{className:"tags-container",children:[E.map(A=>{const O=D(A);if(O){const F=`/automation?rule=${encodeURIComponent(O.ruleId)}`;return v.jsx(Qe,{title:y(O.ruleTitle),children:v.jsx(Ml,{className:"session-tag session-tag--automation",onClick:$=>$.stopPropagation(),children:v.jsx("a",{className:"session-tag__link",href:F,onClick:$=>$.stopPropagation(),children:O.ruleTitle})})},A)}return v.jsx(Qe,{title:y(A),children:v.jsx(Ml,{className:"session-tag",children:v.jsx("span",{className:"session-tag__text",children:A})})},A)}),I>0&&v.jsxs(Ml,{className:"session-tag session-tag--count",children:["+",I]})]})})})}const Nbt="room:",IO=n=>`${Nbt}${n}`,Dbt=(n,e)=>{const t=(e==null?void 0:e.runs.map(i=>i.sessionId))??[];return{...n,activeRunCount:(e==null?void 0:e.members.reduce((i,s)=>i+s.activeRunCount,0))??0,pendingCount:(e==null?void 0:e.members.reduce((i,s)=>i+s.pendingCount,0))??0,sessionIds:[...n.hostSessionId!=null?[n.hostSessionId]:[],...t]}},MO=n=>n.createdAt??0,m8e=n=>n.updatedAt??n.createdAt??0,p8e=n=>n.kind==="room"?n.room.favoritedAt!=null:n.session.isStarred===!0,Tbt=(n,e,t)=>{const i=Number(p8e(e))-Number(p8e(n));if(i!==0)return i;const s=n.kind==="room"?m8e(n.room):MO(n.session),r=e.kind==="room"?m8e(e.room):MO(e.session),o=s-r;return t==="asc"?o:-o};function Rbt({collapsedIds:n,rooms:e,sessions:t,sortOrder:i}){const s=new Set(e.flatMap(h=>h.sessionIds)),r=t.filter(h=>!s.has(h.id)),o=new Map(r.map(h=>[h.id,h])),a=new Map;for(const h of r)if(h.parentSessionId){const f=a.get(h.parentSessionId)??[];f.push(h),a.set(h.parentSessionId,f)}const l=r.filter(h=>h.parentSessionId?!o.has(h.parentSessionId):!0).map(h=>({id:h.id,kind:"session",session:h,depth:0,hasChildren:(a.get(h.id)??[]).length>0}));l.push(...e.map(h=>({id:IO(h.id),kind:"room",room:h,depth:0,hasChildren:!1}))),l.sort((h,f)=>Tbt(h,f,i));const c=[],d=new Set,u=(h,f)=>{if(d.has(h.id))return;d.add(h.id);const g=a.get(h.id)??[];if(c.push({id:h.id,kind:"session",session:h,depth:f,hasChildren:g.length>0}),n.has(h.id))return;const m=[...g].sort((p,_)=>MO(_)-MO(p));for(const p of m)u(p,f+1)};for(const h of l)h.kind==="room"?c.push(h):u(h.session,0);return c}function Pbt({sessions:n,rooms:e=[],activeId:t,hasActiveFilters:i,isBatchMode:s,isCompactLayout:r,selectedIds:o,isTouchInteraction:a,sortOrder:l,searchQuery:c,onArchiveRoom:d,onFavoriteRoom:u,onSelectRoom:h,onSelectSession:f,onArchiveSession:g,onDeleteSession:m,onRenameSession:p,onStarSession:_,onToggleSelect:b}){const{t:y}=ht(),[w,S]=C.useState(new Set),{conversationItems:x,childSummaryMap:L}=C.useMemo(()=>{const I=new Map;for(const N of n)if(N.parentSessionId){const T=I.get(N.parentSessionId)??[];T.push(N),I.set(N.parentSessionId,T)}const M=new Map;for(const[N,T]of I.entries()){const D=T.length,P=new Map;for(const A of T){const O=A.status??"running";P.set(O,(P.get(O)??0)+1)}const R=[y("common.childSummary",{count:D})];for(const[A,O]of P.entries())R.push(y("common.childStatusItem",{count:O,status:y(`common.status.${A}`)}));M.set(N,R.join(" · "))}return{conversationItems:Rbt({collapsedIds:w,rooms:e,sessions:n,sortOrder:l}),childSummaryMap:M}},[n,w,e,l,y]),E=I=>{S(M=>{const N=new Set(M);return N.has(I)?N.delete(I):N.add(I),N})};return v.jsx("div",{className:"session-list-container",children:v.jsx("div",{className:"session-list-scroll",children:v.jsx(Wc,{className:"session-list",size:"small",locale:{emptyText:v.jsx("div",{className:"empty-text",children:y(c||i?"common.noSessions":"common.startNewChat")})},dataSource:x,renderItem:I=>I.kind==="room"?v.jsx("div",{className:"session-row session-row--room",children:v.jsx("div",{className:"session-row-main",children:v.jsx(Ebt,{room:I.room,isActive:t===IO(I.room.id),isCompactLayout:r,isTouchInteraction:a,onArchive:d,onFavorite:u,onSelect:h})})}):v.jsxs("div",{className:`session-row ${I.depth>0?"has-parent":""}`,style:{"--session-depth":I.depth},children:[v.jsxs("div",{className:"session-row-main",children:[s&&v.jsx("div",{className:"session-select-toggle",onClick:M=>M.stopPropagation(),children:v.jsx(P1,{checked:o.has(I.session.id),onChange:()=>b(I.session.id)})}),v.jsx(Mbt,{session:I.session,isActive:t===I.session.id,isBatchMode:s,isCompactLayout:r,isSelected:o.has(I.session.id),isTouchInteraction:a,onSelect:f,onArchive:g,onDelete:m,onRename:p,onStar:_,onToggleSelect:b})]}),I.hasChildren&&!s&&v.jsxs("div",{className:"session-collapse-row",style:{"--session-depth":I.depth},onClick:M=>M.stopPropagation(),children:[v.jsx(qe,{type:"text",size:"small",className:`session-tree-toggle ${w.has(I.session.id)?"collapsed":""}`,onClick:()=>E(I.session.id),icon:v.jsx("span",{className:"material-symbols-rounded",children:"chevron_right"})}),v.jsx("span",{className:"session-collapse-label",children:w.has(I.session.id)?y("common.expandChildren"):y("common.collapseChildren")}),v.jsx("span",{className:"session-collapse-summary",children:L.get(I.session.id)??y("common.childSummary",{count:0})})]})]})})})})}function Abt({isAllSelected:n,selectedCount:e,totalCount:t,onBatchArchive:i,onBatchDelete:s,onBatchStar:r,onSelectAll:o}){const{t:a}=ht(),{isTouchInteraction:l}=Mr(),c=d=>l?void 0:d;return v.jsxs("div",{className:"header-batch-actions",children:[v.jsx(Qe,{title:c(a(n?"common.deselectAll":"common.selectAll")),children:v.jsx("label",{className:"batch-select-toggle",children:v.jsx(P1,{checked:n,indeterminate:e>0&&e<t,onChange:d=>o(d.target.checked)})})}),v.jsx(Qe,{title:c(a("common.star")),children:v.jsx(qe,{className:"sidebar-tool-btn is-icon-only",type:"text",disabled:e===0,onClick:r,icon:v.jsx("span",{className:"material-symbols-rounded",children:"star"})})}),v.jsx(Cm,{title:a("common.archiveConfirm",{count:e}),onConfirm:i,okText:a("common.confirm"),cancelText:a("common.cancel"),okButtonProps:{danger:!1},disabled:e===0,children:v.jsx(Qe,{title:c(a("common.archive")),children:v.jsx(qe,{className:"sidebar-tool-btn is-icon-only",type:"text",disabled:e===0,icon:v.jsx("span",{className:"material-symbols-rounded",children:"archive"})})})}),v.jsx(Cm,{title:a("common.deleteConfirm",{count:e}),onConfirm:s,okText:a("common.confirm"),cancelText:a("common.cancel"),okButtonProps:{danger:!0},disabled:e===0,children:v.jsx(Qe,{title:c(a("common.delete")),children:v.jsx(qe,{className:"sidebar-tool-btn is-icon-only is-danger",type:"text",disabled:e===0,icon:v.jsx("span",{className:"material-symbols-rounded",children:"delete"})})})})]})}function iq({className:n,icon:e,...t}){return v.jsxs("div",{className:"toolbar-filter-control",children:[v.jsx("span",{className:"material-symbols-rounded toolbar-filter-icon",children:e}),v.jsx(ms,{className:n==null||n===""?"toolbar-filter-select":`toolbar-filter-select ${n}`,...t})]})}function Obt({adapterFilters:n,availableAdapters:e,availableTags:t,hasActiveSearchControls:i,isBatchMode:s,searchQuery:r,selectedCount:o,shouldShowSearchActions:a,sortOrder:l,sortSelection:c,tagFilters:d,totalCount:u,onAdapterFilterChange:h,onBatchArchive:f,onBatchDelete:g,onBatchStar:m,onSearchChange:p,onSortOrderChange:_,onSelectAll:b,onTagFilterChange:y,onToggleBatchMode:w,onToggleSearchActions:S}){const{t:x}=ht(),{isTouchInteraction:L}=Mr(),E=u>0&&o===u,I=C.useMemo(()=>D=>D.map(P=>({label:P,value:P})),[]),M=v.jsx("span",{className:"material-symbols-rounded toolbar-filter-chevron",children:"expand_more"}),N=D=>L?void 0:D,T=C.useMemo(()=>[{label:x("automation.sortDesc"),value:"desc"},{label:x("automation.sortAsc"),value:"asc"}],[x]);return v.jsxs(v.Fragment,{children:[v.jsx(eOe,{className:"search-input",placeholder:x("common.search"),value:r,onChange:D=>p(D.target.value),suffix:v.jsx(Qe,{title:N(x("common.searchActions")),children:v.jsx("button",{type:"button",className:`search-toggle-button ${a?"is-open":""} ${i?"has-active-filters":""}`,"aria-label":x("common.searchActions"),onMouseDown:D=>D.preventDefault(),onClick:S,children:v.jsx("span",{className:"material-symbols-rounded search-chevron",children:"expand_more"})})}),allowClear:!0}),v.jsx("div",{className:`header-search-actions ${a?"is-open":""}`,children:v.jsxs("div",{className:"header-search-actions-inner",children:[v.jsxs("div",{className:"header-toolbar-row",children:[v.jsx("div",{className:"header-toolbar-leading",children:s?v.jsx(Qe,{title:N(x("common.cancelBatch")),children:v.jsx(qe,{className:"sidebar-tool-btn is-icon-only",type:"text",onClick:w,icon:v.jsx("span",{className:"material-symbols-rounded",children:"close"})})}):v.jsx(Qe,{title:N(x("common.batchMode")),children:v.jsx(qe,{className:"sidebar-tool-btn is-icon-only",type:"text",onClick:w,icon:v.jsx("span",{className:"material-symbols-rounded",children:"checklist"})})})}),v.jsxs("div",{className:"header-filter-stack",children:[v.jsx(iq,{icon:"sell",mode:"tags",placeholder:x("common.allTags"),options:I(t),value:d,onChange:D=>y(D),maxTagCount:1,allowClear:!0,suffixIcon:M,tokenSeparators:[","]}),v.jsx(iq,{icon:"extension",mode:"tags",placeholder:x("common.allAdapters"),options:I(e),value:n,onChange:D=>h(D),maxTagCount:1,allowClear:!0,suffixIcon:M,tokenSeparators:[","]}),v.jsx(iq,{icon:"swap_vert",placeholder:x("common.sort"),options:T,value:c,onChange:D=>_(D),allowClear:!0,suffixIcon:M})]})]}),s&&v.jsx(Abt,{isAllSelected:E,selectedCount:o,totalCount:u,onBatchArchive:f,onBatchDelete:g,onBatchStar:m,onSelectAll:b})]})})]})}const Fbt=({hasActiveSearchControls:n,isBatchMode:e,isSearchActionsOpen:t,sessionCount:i,threshold:s})=>s<=0||n||e||t?!0:i>s;function Bbt({adapterFilters:n,availableAdapters:e,availableTags:t,createButtonRef:i,hasActiveSearchControls:s,isBatchMode:r,isCompactLayout:o,isCreatingSession:a,isSidebarCollapsed:l,searchQuery:c,selectedCount:d,sessionCount:u,sortOrder:h,sortSelection:f,shortcutLabel:g,tagFilters:m,totalCount:p,onBatchArchive:_,onBatchDelete:b,onBatchStar:y,onAdapterFilterChange:w,onCloseSidebar:S,onCreateSession:x,onSearchChange:L,onSortOrderChange:E,onSelectAll:I,onTagFilterChange:M,onToggleBatchMode:N,onToggleSidebarCollapsed:T}){const{t:D}=ht(),{isTouchInteraction:P}=Mr(),R=Su(zAe),[A,O]=C.useState(!1),F=!l&&(A||r),$=!l&&Fbt({hasActiveSearchControls:s,isBatchMode:r,isSearchActionsOpen:A,sessionCount:u,threshold:R}),B=l?v.jsx(Qe,{title:P?void 0:D(a?"common.alreadyInNewChat":"common.newChat"),placement:"right",children:v.jsx(qe,{className:`sidebar-list-header__icon-action sidebar-new-chat-btn ${a?"active":""}`,type:"text",disabled:!!a,onClick:x,children:v.jsx("span",{className:`material-symbols-rounded ${a?"filled":""}`,children:a?"chat_bubble":"send"})})}):v.jsxs(qe,{ref:i,className:`sidebar-list-header__primary-action new-chat-btn ${a?"active":""}`,type:a?"default":"primary",block:!0,disabled:!!a,onClick:x,children:[v.jsxs("span",{className:"sidebar-list-header__button-content btn-content",children:[v.jsx("span",{className:`material-symbols-rounded ${a?"filled":""}`,children:a?"chat_bubble":"send"}),v.jsx("span",{children:D(a?"common.creatingChat":"common.newChat")})]}),v.jsx("span",{className:"sidebar-list-header__shortcut shortcut-tag",children:g})]}),V=v.jsx(Qe,{title:P?void 0:D(o?"common.close":l?"common.expand":"common.collapse"),children:v.jsx(qe,{className:"sidebar-list-header__icon-action sidebar-collapse-btn",type:"text","aria-label":D(o?"common.close":l?"common.expand":"common.collapse"),onClick:o?S:T,children:v.jsx("span",{className:"material-symbols-rounded",children:o?"close":l?"dock_to_right":"left_panel_close"})})}),W=$?v.jsx(Obt,{adapterFilters:n,availableAdapters:e,availableTags:t,hasActiveSearchControls:s,isBatchMode:r,searchQuery:c,selectedCount:d,shouldShowSearchActions:F,sortOrder:h,sortSelection:f,tagFilters:m,totalCount:p,onBatchArchive:_,onBatchDelete:b,onBatchStar:y,onAdapterFilterChange:w,onSearchChange:L,onSortOrderChange:E,onSelectAll:I,onTagFilterChange:M,onToggleBatchMode:N,onToggleSearchActions:()=>O(H=>!H)}):null;return v.jsx(QAe,{className:"sidebar-header",compact:o,collapsed:l,primaryAction:B,sideAction:V,children:W})}const $bt=n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Hbt=n=>new RegExp(`^${$bt(n).replace(/\\\*/g,".*")}$`,"i"),Vbt=(n,e)=>{const t=n.trim(),i=e.trim();return t===""||i===""?!1:i.includes("*")?Hbt(i).test(t):t.toLowerCase().includes(i.toLowerCase())},C8e=(n,e)=>e.length===0?!0:e.some(t=>n.some(i=>Vbt(i,t)));async function jbt({mutateRooms:n,request:e,roomId:t,updateMetadata:i=Iee}){await i(t,e),await n()}const Wbt=(n,e)=>[...n].sort((t,i)=>{const s=+(i.isStarred===!0)-+(t.isStarred===!0);if(s!==0)return s;const r=(t.createdAt??0)-(i.createdAt??0);return e==="asc"?r:-r});function _8e({activeId:n,isCompactLayout:e=!1,isMobileOpen:t=!1,onRequestClose:i,onSelectRoom:s,onSelectSession:r,onDeletedSession:o,width:a}){var Ke,ze,Ve;const{adapterFilters:l,hasActiveFilterConditions:c,hasActiveSearchControls:d,isSidebarCollapsed:u,searchQuery:h,setSortOrder:f,setAdapterFilters:g,setSearchQuery:m,setSidebarCollapsed:p,setTagFilters:_,sortOrder:b,sortSelection:y,tagFilters:w}=tOe(),S=Su(RAe),[x,L]=C.useState(!1),[E,I]=C.useState(new Set),{t:M}=ht(),{isTouchInteraction:N}=Mr(),T=navigator.platform.includes("Mac"),D=Su(Fb),P=KM(Fb),{data:R,mutate:A}=Gn("/api/sessions"),{data:O,mutate:F}=Gn("/api/agent-rooms",UAe,{refreshInterval:3e3,revalidateOnFocus:!0}),$=O==null?void 0:O.rooms.map(Ne=>Ne.id).sort().join("|"),{data:B}=Gn($==null||$===""?null:["agent-room-details",$],()=>Promise.all(((O==null?void 0:O.rooms)??[]).map(Ne=>X3e(Ne.id))),{refreshInterval:3e3,revalidateOnFocus:!0}),V=C.useMemo(()=>Gvt((R==null?void 0:R.sessions)??[],D),[D,R==null?void 0:R.sessions]),W=C.useMemo(()=>{const Ne=new Map((B??[]).map(Ie=>[Ie.room.id,Ie]));return((O==null?void 0:O.rooms)??[]).map(Ie=>Dbt(Ie,Ne.get(Ie.id)))},[B,O==null?void 0:O.rooms]),{data:H}=Gn("/api/config"),U=(Ve=(ze=(Ke=H==null?void 0:H.sources)==null?void 0:Ke.merged)==null?void 0:ze.shortcuts)==null?void 0:Ve.newSession,Z=U!=null&&U.trim()!==""?U:"mod+k",G=C.useMemo(()=>nhe(Z,T),[Z,T]),q=C.useMemo(()=>Array.from(new Set(V.flatMap(Ne=>(Ne.tags??[]).map(Ie=>Ie.trim()).filter(Boolean)))).sort((Ne,Ie)=>Ne.localeCompare(Ie)),[V]),K=C.useMemo(()=>Array.from(new Set(V.map(Ne=>{var Ie;return((Ie=Ne.adapter)==null?void 0:Ie.trim())??""}).filter(Boolean))).sort((Ne,Ie)=>Ne.localeCompare(Ie)),[V]),X=C.useMemo(()=>{const Ne=h.trim().toLowerCase(),Ie=V.filter(Ge=>{if(!C8e(Ge.tags??[],w))return!1;const Fe=[Ge.adapter??"",Ge.adapter!=null&&Ge.adapter!==""?tw(Ge.adapter).title:""].filter(Boolean);return C8e(Fe,l)?Ne?(Ge.title??"").toLowerCase().includes(Ne)||(Ge.lastMessage??"").toLowerCase().includes(Ne)||(Ge.lastUserMessage??"").toLowerCase().includes(Ne)||Ge.id.toLowerCase().includes(Ne)||(Ge.tags??[]).some(Re=>Re.toLowerCase().includes(Ne))||Fe.some(Re=>Re.toLowerCase().includes(Ne)):!0:!1});return Wbt(Ie,b)},[l,h,V,b,w]),ie=C.useMemo(()=>{if(l.length>0||w.length>0)return[];const Ne=h.trim().toLowerCase();return W.filter(Ie=>Ne?Ie.title.toLowerCase().includes(Ne)||Ie.id.toLowerCase().includes(Ne)||(Ie.lastMessage??"").toLowerCase().includes(Ne):!0)},[l,W,h,w]);async function se(){i==null||i(),r({id:""},!0)}function J(Ne){Wvt(Ne),P(Ie=>{if(Ie[Ne]==null)return Ie;const Ge={...Ie};return delete Ge[Ne],Ge}),A(Ie=>(Ie==null?void 0:Ie.sessions)==null?Ie:{...Ie,sessions:Mee(Ie.sessions,Ne)},!1)}async function le(Ne){let Ie;const Ge=V.findIndex(Fe=>Fe.id===Ne);if(Ge!==-1&&(Ge+1<V.length?Ie=V[Ge+1].id:Ge-1>=0&&(Ie=V[Ge-1].id)),D[Ne]!=null){J(Ne),n===Ne&&(o==null||o(Ne,Ie));return}try{await f1(Ne,{isArchived:!0}),await A(),o==null||o(Ne,Ie)}catch(Fe){console.error("Failed to archive session:",Fe)}}async function be(Ne){let Ie;const Ge=V.findIndex(Fe=>Fe.id===Ne);if(Ge!==-1&&(Ge+1<V.length?Ie=V[Ge+1].id:Ge-1>=0&&(Ie=V[Ge-1].id)),D[Ne]!=null){J(Ne),n===Ne&&(o==null||o(Ne,Ie));return}try{await Ob(Ne),await A(),n===Ne&&(o==null||o(Ne,Ie))}catch(Fe){console.error("Failed to delete session:",Fe)}}async function ae(Ne,Ie){if(D[Ne]!=null){P(Ge=>{const Fe=Ge[Ne];return Fe==null?Ge:{...Ge,[Ne]:{...Fe,session:{...Fe.session,isStarred:Ie}}}});return}try{await f1(Ne,{isStarred:Ie}),await A()}catch(Ge){console.error("Failed to star session:",Ge)}}async function ce(Ne,Ie){try{await jbt({roomId:Ne,request:Ie,mutateRooms:F})}catch(Ge){console.error("Failed to update room metadata:",Ge)}}async function oe(Ne,Ie){await ce(Ne,{isArchived:Ie})}async function he(Ne,Ie){await ce(Ne,{isFavorited:Ie})}async function ye(Ne,Ie){if(D[Ne]!=null){P(Ge=>{const Fe=Ge[Ne];return Fe==null?Ge:{...Ge,[Ne]:{...Fe,session:{...Fe.session,title:Ie}}}});return}await Evt(Ne,Ie),await A()}const ke=Ne=>{I(Ie=>{const Ge=new Set(Ie);return Ge.has(Ne)?Ge.delete(Ne):Ge.add(Ne),Ge})},Ce=Ne=>{I(Ne?new Set(X.map(Ie=>Ie.id)):new Set)},Se=async()=>{try{if(await Promise.all(Array.from(E).map(async Ne=>f1(Ne,{isArchived:!0}))),await A(),n&&E.has(n)){let Ne;const Ie=V.find(Ge=>!E.has(Ge.id));Ie&&(Ne=Ie.id),o==null||o(n,Ne)}I(new Set),L(!1)}catch(Ne){console.error("Failed to batch archive sessions:",Ne)}},we=async()=>{try{if(await Promise.all(Array.from(E).map(async Ne=>Ob(Ne))),await A(),n&&E.has(n)){const Ne=V.find(Ie=>!E.has(Ie.id));o==null||o(n,Ne==null?void 0:Ne.id)}I(new Set),L(!1)}catch(Ne){console.error("Failed to batch delete sessions:",Ne)}},ve=async Ne=>{try{await Promise.all(Array.from(E).map(async Ie=>f1(Ie,{isStarred:Ne}))),await A()}catch(Ie){console.error("Failed to batch update star status:",Ie)}},Ee=()=>{L(Ne=>!Ne),I(new Set)},me=n===void 0||n==="",xe=e?!1:u,Oe=Ne=>N?void 0:Ne,We=C.useRef(null);return pP({shortcut:Z,isMac:T,onTrigger:Ne=>{Ne.preventDefault(),!me&&(We.current&&(We.current.classList.add("active-scale"),setTimeout(()=>{var Ie;(Ie=We.current)==null||Ie.classList.remove("active-scale")},200)),se())}}),v.jsxs("div",{className:["sidebar-container",xe?"collapsed":"",e?"sidebar-container--compact":"",t?"is-mobile-open":""].filter(Boolean).join(" "),style:e?void 0:{width:xe?0:a,minWidth:xe?0:void 0,transition:S?"none":"width 0.3s cubic-bezier(0.4, 0, 0.2, 1)",borderRight:xe?"none":void 0},children:[v.jsxs("div",{className:"sidebar-content",style:e?void 0:{width:a,transition:S?"none":"transform 0.3s cubic-bezier(0.4, 0, 0.2, 1)",transform:xe?`translateX(-${a}px)`:"translateX(0)"},children:[v.jsx(Bbt,{adapterFilters:l,availableAdapters:K,hasActiveSearchControls:d,isCompactLayout:e,isSidebarCollapsed:xe,searchQuery:h,sortOrder:b,sortSelection:y,onSearchChange:m,availableTags:q,tagFilters:w,onSortOrderChange:f,onAdapterFilterChange:g,onTagFilterChange:_,isBatchMode:x,onToggleBatchMode:Ee,onToggleSidebarCollapsed:()=>p(!u),onCloseSidebar:i,selectedCount:E.size,sessionCount:V.length,totalCount:X.length,onSelectAll:Ce,onBatchArchive:()=>{Se()},onBatchDelete:()=>{we()},onBatchStar:()=>{ve(!0)},isCreatingSession:me,shortcutLabel:G,createButtonRef:We,onCreateSession:()=>{se()}}),v.jsx(Pbt,{hasActiveFilters:c,rooms:ie,sessions:X,activeId:n,isBatchMode:x,isCompactLayout:e,selectedIds:E,isTouchInteraction:N,sortOrder:b,searchQuery:h,onArchiveRoom:oe,onFavoriteRoom:he,onSelectRoom:s,onSelectSession:r,onArchiveSession:le,onDeleteSession:be,onRenameSession:ye,onStarSession:ae,onToggleSelect:ke})]}),!e&&u&&v.jsxs(JAe,{children:[v.jsx(kO,{buttonRef:We,active:me,disabled:!!me,filled:me,icon:me?"chat_bubble":"send",tooltip:Oe(M(me?"common.alreadyInNewChat":"common.newChat")),ariaLabel:M(me?"common.alreadyInNewChat":"common.newChat"),onClick:()=>{se()}}),v.jsx(kO,{icon:"dock_to_right",tooltip:Oe(M("common.expand")),ariaLabel:M("common.expand"),onClick:()=>p(!1)})]})]})}const zbt=22,v8e=8,sq=64,b8e=.45,y8e=360,Ubt='input,textarea,select,[contenteditable="true"],[role="textbox"]',w8e=n=>n.pointerType==="touch"||n.pointerType==="pen",S8e=n=>n instanceof HTMLElement&&n.closest(Ubt)!=null,Jw=n=>{n.style.removeProperty("--vf-mobile-sidebar-drag-x"),n.removeAttribute("data-mobile-sidebar-dragging")};function fOe({canSwipeOpen:n=!0,isCompactLayout:e,isOpen:t,setIsOpen:i,sheetRef:s}){const r=C.useRef(0);C.useEffect(()=>{if(!e||!n)return;const o=s.current;if(o==null)return;const a=l=>{Date.now()>r.current||(l.preventDefault(),l.stopPropagation())};return o.addEventListener("click",a,!0),()=>o.removeEventListener("click",a,!0)},[n,e,s]),C.useEffect(()=>{if(!e)return;let o=null;const a=()=>{o=null,window.removeEventListener("pointermove",c),window.removeEventListener("pointerup",l),window.removeEventListener("pointercancel",a)},l=()=>a(),c=u=>{if(o==null||u.pointerId!==o.pointerId)return;const h=u.clientX-o.startX,f=u.clientY-o.startY,g=Math.abs(h),m=Math.abs(f);if(g<v8e||g<=m*1.2)return;o.dragging=!0,u.cancelable&&u.preventDefault();const p=Math.max(1,u.timeStamp-o.startTime),_=h/p;(h>sq||_>b8e)&&(r.current=Date.now()+y8e,i(!0),a())},d=u=>{!w8e(u)||t||u.clientX>zbt||S8e(u.target)||(o={dragging:!1,lastX:u.clientX,pointerId:u.pointerId,startTime:u.timeStamp,startX:u.clientX,startY:u.clientY},window.addEventListener("pointermove",c,{passive:!1}),window.addEventListener("pointerup",l),window.addEventListener("pointercancel",a))};return document.addEventListener("pointerdown",d),()=>{document.removeEventListener("pointerdown",d),a()}},[n,e,t,i]),C.useEffect(()=>{if(!e||!t)return;const o=s.current;if(o==null)return;let a=null;const l=()=>{a=null,window.removeEventListener("pointermove",u),window.removeEventListener("pointerup",d),window.removeEventListener("pointercancel",c)},c=()=>{if((a==null?void 0:a.dragging)===!0&&a.lastX-a.startX<-sq){i(!1),window.setTimeout(()=>Jw(o),260),l();return}Jw(o),l()},d=f=>{if(a==null||f.pointerId!==a.pointerId)return;const g=f.clientX-a.startX,m=Math.max(1,f.timeStamp-a.startTime),p=g/m,_=g<-sq||p<-b8e,b=a.dragging;if(l(),o.removeAttribute("data-mobile-sidebar-dragging"),b&&(r.current=Date.now()+y8e),_){i(!1),window.setTimeout(()=>Jw(o),260);return}Jw(o)},u=f=>{if(a==null||f.pointerId!==a.pointerId)return;const g=f.clientX-a.startX,m=f.clientY-a.startY,p=Math.abs(g),_=Math.abs(m);if(a.lastX=f.clientX,!a.dragging){if(p<v8e||p<=_*1.2)return;a.dragging=!0,o.setAttribute("data-mobile-sidebar-dragging","true")}f.cancelable&&f.preventDefault(),o.style.setProperty("--vf-mobile-sidebar-drag-x",`${Math.round(Math.min(0,g))}px`)},h=f=>{!w8e(f)||S8e(f.target)||(a={dragging:!1,lastX:f.clientX,pointerId:f.pointerId,startTime:f.timeStamp,startX:f.clientX,startY:f.clientY},window.addEventListener("pointermove",u,{passive:!1}),window.addEventListener("pointerup",d),window.addEventListener("pointercancel",c))};return o.addEventListener("pointerdown",h),()=>{o.removeEventListener("pointerdown",h),Jw(o),l()}},[e,t,i,s])}const Kbt=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(", "),gOe=n=>Array.from(n.querySelectorAll(Kbt)).filter(e=>!e.hasAttribute("disabled")&&e.getAttribute("aria-hidden")!=="true"&&e.offsetParent!==null),g_=n=>{try{n.focus({preventScroll:!0})}catch{n.focus()}},x8e=n=>{const e=gOe(n),t=e[0];return t!=null?g_(t):g_(n),e};function ihe({backgroundRefs:n,canSwipeOpen:e,isCompactLayout:t,isMobileSidebarOpen:i,setIsMobileSidebarOpen:s,sheetRef:r}){const o=C.useRef(null);fOe({canSwipeOpen:e,isCompactLayout:t,isOpen:i,setIsOpen:s,sheetRef:r}),C.useEffect(()=>{if(!t){n.forEach(a=>{var l;(l=a.current)==null||l.removeAttribute("inert")});return}return n.forEach(a=>{const l=a.current;l!=null&&(i?l.setAttribute("inert",""):l.removeAttribute("inert"))}),()=>{n.forEach(a=>{var l;(l=a.current)==null||l.removeAttribute("inert")})}},[n,t,i]),C.useEffect(()=>{if(!t||!i)return;const a=document.activeElement;o.current=a instanceof HTMLElement?a:null;const l=window.requestAnimationFrame(()=>{const u=r.current;u!=null&&x8e(u)}),c=u=>{if(u.key==="Escape"){s(!1);return}if(u.key!=="Tab")return;const h=r.current;if(h==null)return;const f=gOe(h);if(f.length===0){u.preventDefault(),g_(h);return}const g=f[0],m=f[f.length-1],p=document.activeElement;if(u.shiftKey){(p===g||p===h)&&(u.preventDefault(),g_(m));return}p===m&&(u.preventDefault(),g_(g))},d=u=>{const h=r.current,f=u.target;h==null||!(f instanceof HTMLElement)||h.contains(f)||x8e(h)};return window.addEventListener("keydown",c),document.addEventListener("focusin",d),()=>{window.cancelAnimationFrame(l),window.removeEventListener("keydown",c),document.removeEventListener("focusin",d);const u=o.current;u!=null&&document.contains(u)&&window.requestAnimationFrame(()=>{document.contains(u)&&g_(u)}),o.current=null}},[t,i,s,r]),C.useEffect(()=>{if(!t||!i)return;const{body:a,documentElement:l}=document,c=a.style.overflow,d=l.style.overflow;return a.style.overflow="hidden",l.style.overflow="hidden",()=>{a.style.overflow=c,l.style.overflow=d}},[t,i])}const Zbt="mobile-sidebar-dialog";function qbt({activeId:n,children:e,isDarkMode:t,onDeletedSession:i,onSelectRoom:s,onSelectSession:r,showSidebar:o,sidebarWidth:a}){const{t:l}=ht(),{isSidebarCollapsed:c}=tOe(),d=E3(),{isCompactLayout:u}=Mr(),[h,f]=z9(AAe),g=KM(PAe),m=!u&&c,p=C.useRef(null),_=C.useRef(null),b=C.useRef(null),y=C.useMemo(()=>[p,_],[]);C.useEffect(()=>{g(u?!1:c)},[u,c,g]),C.useEffect(()=>{f(!1)},[u,d.pathname,f]),C.useEffect(()=>{!u||o||f(!1)},[u,f,o]),ihe({backgroundRefs:y,canSwipeOpen:o,isCompactLayout:u,isMobileSidebarOpen:h,setIsMobileSidebarOpen:f,sheetRef:b});const w=u?Math.min(a,320):a,S=["app-shell__content",o?"app-shell__content--session":"",m?"is-sidebar-collapsed":"",o?"":"is-flat"].filter(Boolean).join(" "),x=v.jsx("div",{ref:p,className:"app-shell__content-region","aria-hidden":u&&h?!0:void 0,children:v.jsx(Tg.Content,{className:S,children:e})});return u?v.jsxs(Tg,{className:`app-shell app-shell--compact ${t?"app-shell--dark":""}`,children:[x,o&&v.jsxs(v.Fragment,{children:[v.jsx("button",{type:"button",className:`app-shell__mobile-sidebar-backdrop ${h?"is-open":""}`,"aria-label":l("common.close"),"aria-hidden":!h,tabIndex:-1,onClick:()=>f(!1)}),v.jsx("div",{ref:b,id:Zbt,className:`app-shell__mobile-sidebar-sheet ${h?"is-open":""}`,role:"dialog","aria-modal":h?"true":void 0,"aria-label":l("common.sessions"),"aria-hidden":!h,tabIndex:-1,children:v.jsx(_8e,{width:w,activeId:n,onSelectRoom:L=>{f(!1),s(L)},onSelectSession:(L,E)=>{f(!1),r(L,E)},onDeletedSession:(L,E)=>{f(!1),i(L,E)},isCompactLayout:!0,isMobileOpen:h,onRequestClose:()=>f(!1)})})]}),v.jsx("div",{ref:_,children:v.jsx(o8e,{isCompactLayout:!0,ariaHidden:h,showSidebar:o,onOpenSidebar:()=>f(!0)})})]}):v.jsxs(Tg,{className:`app-shell ${t?"app-shell--dark":""}`,children:[v.jsxs("div",{className:"app-shell__sidebar-region",children:[v.jsx(o8e,{}),o&&v.jsx(_8e,{width:a,activeId:n,onSelectRoom:s,onSelectSession:r,onDeletedSession:i})]}),x]})}const mOe=(...n)=>n.find(e=>typeof e=="string"&&e.trim()!==""),pOe=()=>mOe(Gm().__VF_PROJECT_AI_CLIENT_VERSION__,"3.1.4-alpha.0")??"0.0.0",Gbt=()=>mOe(Gm().__VF_PROJECT_AI_CLIENT_COMMIT_HASH__,"6d420014325992c00757b5423c2ba107904da1f2"),Xbt=/^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/,L8e=n=>{const e=n==null?void 0:n.trim().match(Xbt);if(e!=null)return{major:Number(e[1]),minor:Number(e[2]),patch:Number(e[3]),...e[4]!=null?{prerelease:e[4]}:{}}},Ybt=(n,e)=>{const t=L8e(n),i=L8e(e);return t==null||i==null?!1:t.prerelease!=null||i.prerelease!=null?t.major===i.major&&t.minor===i.minor&&t.patch===i.patch&&t.prerelease===i.prerelease:t.major!==i.major?!1:t.major===0?t.minor===i.minor:!0},jD=n=>n.authToken!=null&&n.authToken.trim()!=="",rq=(n,e)=>v.jsxs("span",{className:"server-connection-gate__modal-label",children:[v.jsx("span",{className:"material-symbols-rounded",children:n}),v.jsx("span",{children:e})]});function Qbt({profile:n,onClose:e,onProfilesChange:t}){const{t:i}=ht(),{modal:s}=Vs.useApp(),[r]=zn.useForm();C.useEffect(()=>{n!=null&&r.setFieldsValue({alias:n.alias??"",description:n.description??""})},[r,n]);const o=async()=>{if(n==null)return;const c=await r.validateFields();t(cAe(n.serverUrl,c)),e()},a=()=>{n!=null&&s.confirm({title:i("serverConnection.clearLoginState"),content:i("serverConnection.clearLoginStateConfirm"),okText:i("common.confirm"),cancelText:i("common.cancel"),okButtonProps:{danger:!0},onOk:()=>{t(uAe(n.serverUrl)),e()}})},l=()=>{n!=null&&s.confirm({title:i("serverConnection.removeProfile"),content:i("serverConnection.removeProfileConfirm"),okText:i("common.delete"),cancelText:i("common.cancel"),okButtonProps:{danger:!0},onOk:()=>{t(x7t(n.serverUrl)),e()}})};return v.jsx(Fl,{open:n!=null,title:rq("tune",i("serverConnection.manageProfile")),okText:i("common.confirm"),cancelText:i("common.cancel"),onOk:()=>void o(),onCancel:e,children:n!=null&&v.jsxs("div",{className:"server-connection-gate__profile-modal",children:[v.jsxs("div",{className:"server-connection-gate__profile-modal-url",children:[v.jsx("span",{className:"material-symbols-rounded",children:"link"}),v.jsx("span",{children:n.serverUrl})]}),v.jsxs("div",{className:`server-connection-gate__profile-modal-auth ${jD(n)?"is-saved":""}`,children:[v.jsx("span",{className:"material-symbols-rounded",children:jD(n)?"verified_user":"lock_open"}),v.jsx("strong",{children:jD(n)?i("serverConnection.loginSaved"):i("serverConnection.loginMissing")})]}),v.jsxs(zn,{form:r,layout:"vertical",requiredMark:!1,children:[v.jsx(zn.Item,{name:"alias",label:rq("label",i("serverConnection.profileAlias")),children:v.jsx(yn,{placeholder:i("serverConnection.profileAliasPlaceholder")})}),v.jsx(zn.Item,{name:"description",label:rq("notes",i("serverConnection.profileDescription")),children:v.jsx(yn.TextArea,{autoSize:{minRows:2,maxRows:4},placeholder:i("serverConnection.profileDescriptionPlaceholder")})})]}),v.jsxs("div",{className:"server-connection-gate__profile-modal-actions",children:[jD(n)&&v.jsx(qe,{danger:!0,htmlType:"button",icon:v.jsx("span",{className:"material-symbols-rounded",children:"lock_reset"}),onClick:a,children:i("serverConnection.clearLoginState")}),v.jsx(qe,{danger:!0,htmlType:"button",type:"text",icon:v.jsx("span",{className:"material-symbols-rounded",children:"delete"}),onClick:l,children:i("serverConnection.removeProfile")})]})]})})}const k8e=()=>{const n=document.activeElement;n instanceof HTMLElement&&n.blur()},E8e=n=>n.authToken!=null&&n.authToken.trim()!=="",Jbt=n=>{var e;return((e=n.alias)==null?void 0:e.trim())||n.serverUrl},eyt=n=>{var e;return(e=n.serverVersion)==null?void 0:e.trim()},tyt=n=>n.pointerType==="touch"||n.pointerType==="pen";function nyt({profiles:n,submitting:e,onConnect:t,onProfilesChange:i}){const{t:s}=ht(),[r,o]=C.useState(null);if(n.length===0)return null;const a=(l,c)=>{k8e(),!(!tyt(l)||e)&&(l.preventDefault(),t(c.serverUrl))};return v.jsxs("section",{className:"server-connection-gate__recent","aria-labelledby":"server-connection-recent-title",children:[v.jsx("h2",{id:"server-connection-recent-title",children:s("serverConnection.recentTitle")}),v.jsx("div",{className:"server-connection-gate__recent-list",children:n.map(l=>v.jsx("div",{className:"server-connection-gate__profile-row",children:v.jsxs("div",{className:`server-connection-gate__profile-card ${e?"is-disabled":""}`,children:[v.jsxs("button",{type:"button",className:"server-connection-gate__recent-item",disabled:e,onPointerDown:c=>a(c,l),onClick:()=>t(l.serverUrl),children:[v.jsx("span",{className:"material-symbols-rounded",children:"dns"}),v.jsxs("span",{className:"server-connection-gate__profile-main",children:[v.jsx("span",{className:"server-connection-gate__profile-title",children:Jbt(l)}),v.jsx("span",{className:"server-connection-gate__profile-url",children:l.serverUrl}),v.jsx("span",{className:"server-connection-gate__profile-version",children:s("serverConnection.serverVersion",{version:eyt(l)??s("serverConnection.serverVersionUnknown")})}),l.description!=null&&v.jsx("span",{className:"server-connection-gate__profile-description",children:l.description})]}),v.jsx("span",{className:`server-connection-gate__profile-auth ${E8e(l)?"is-saved":""}`,children:E8e(l)?s("serverConnection.loginSaved"):s("serverConnection.loginMissing")})]}),v.jsx(qe,{htmlType:"button",type:"text",className:"server-connection-gate__profile-manage",icon:v.jsx("span",{className:"material-symbols-rounded",children:"edit"}),"aria-label":s("serverConnection.manageProfile"),onPointerDown:k8e,onClick:()=>o(l)})]})},l.serverUrl))}),v.jsx(Qbt,{profile:r,onClose:()=>o(null),onProfilesChange:i})]})}const iyt="http",syt="localhost:8787",ryt=[{label:"http://",value:"http"},{label:"https://",value:"https"}],oyt=v.jsx("span",{className:"material-symbols-rounded server-connection-gate__scheme-chevron",children:"expand_more"}),COe=n=>{const e=n.trim(),t=/^(https?):\/\/(.+)$/i.exec(e);return t==null?{serverScheme:void 0,serverHost:e}:{serverScheme:t[1].toLowerCase(),serverHost:t[2].trim()}},ayt=n=>{const e=COe(n.serverUrl);return`${e.serverScheme??n.serverScheme}://${e.serverHost}`},_Oe=n=>{const e=n.getFieldValue("serverUrl");if(typeof e!="string")return;const t=COe(e);t.serverScheme!=null&&n.setFieldsValue({serverScheme:t.serverScheme,serverUrl:t.serverHost})};function lyt({form:n,onBlur:e,...t}){const{t:i}=ht();return v.jsx(yn,{...t,autoComplete:"url",addonBefore:v.jsx(zn.Item,{name:"serverScheme",noStyle:!0,children:v.jsx(ms,{"aria-label":i("serverConnection.serverScheme"),className:"server-connection-gate__scheme-select",options:ryt,popupMatchSelectWidth:!1,suffixIcon:oyt})}),onBlur:s=>{e==null||e(s),_Oe(n)},size:"large",placeholder:i("serverConnection.serverUrlPlaceholder")})}const cyt="https://github.com/vibe-forge-ai/vibe-forge.ai/blob/master/.ai/docs/usage/pwa.md";class vOe extends Error{constructor(e,t){super("Unsupported server version"),this.clientVersion=e,this.serverVersion=t}}const oq=n=>n!=null&&typeof n=="object"&&!Array.isArray(n),dyt=n=>{const e=oq(n)&&oq(n.data)?n.data:n;return oq(e)&&typeof e.version=="string"?{version:e.version}:{}},uyt=async n=>{const e=await fetch(JPe(n,"/api/auth/status"),{credentials:"include"});if(!e.ok)throw new Error(`Server responded with ${e.status}`);const t=dyt(await e.json().catch(()=>{})),i=pOe();if(!Ybt(i,t.version))throw new vOe(i,t.version);return t};function hyt({children:n}){const{t:e}=ht(),t=ZW(),i=_7t(),s=iAe(),r=b7t(),[o]=zn.useForm(),[a,l]=C.useState(()=>eAe()),[c,d]=C.useState(()=>pf()),[u,h]=C.useState(null),[f,g]=C.useState(!1);if(C.useEffect(()=>{s!=null&&d(b=>{if(b.some(w=>w.serverUrl===s))return b;const y=wee(s);return i?cAe(s,{alias:e("serverConnection.localServiceAlias"),description:e("serverConnection.localServiceProfileDescription")}):y})},[s,i,e]),!t||!r&&(a!=null||s!=null))return n;const m=async b=>{g(!0),h(null);try{const y=xd(b);if(y==null){h(e("serverConnection.invalidUrl"));return}const w=await uyt(y),S=p7t(y);if(S==null){h(e("serverConnection.invalidUrl"));return}y7t(),d(wee(S,{serverVersion:w.version})),l(S)}catch(y){y instanceof vOe?h(e("serverConnection.unsupportedServerVersion",{clientVersion:y.clientVersion,serverVersion:y.serverVersion??e("serverConnection.serverVersionUnknown")})):h(e("serverConnection.connectionFailed"))}finally{g(!1)}},p=async b=>{_Oe(o),await m(ayt(b))},_=b=>{m(b)};return v.jsx("div",{className:"server-connection-gate",children:v.jsxs("main",{className:"server-connection-gate__panel","aria-labelledby":"server-connection-title",children:[v.jsxs("div",{className:"server-connection-gate__intro",children:[v.jsx("h1",{id:"server-connection-title",children:e(i?"serverConnection.desktopTitle":"serverConnection.title")}),v.jsx("p",{children:e(i?"serverConnection.desktopSubtitle":"serverConnection.subtitle")})]}),i?s!=null&&v.jsxs("div",{className:"server-connection-gate__setup",children:[v.jsxs("div",{className:"server-connection-gate__setup-title",children:[v.jsx("span",{className:"material-symbols-rounded",children:"computer"}),v.jsx("span",{children:e("serverConnection.localServiceTitle")})]}),v.jsx("code",{children:s}),v.jsx("p",{children:e("serverConnection.localServiceBannerDescription")})]}):v.jsxs("div",{className:"server-connection-gate__setup",children:[v.jsxs("div",{className:"server-connection-gate__setup-title",children:[v.jsx("span",{className:"material-symbols-rounded",children:"terminal"}),v.jsx("span",{children:e("serverConnection.setupTitle")})]}),v.jsx("code",{children:"npx vfui-server"}),v.jsxs("p",{children:[e("serverConnection.setupDescription"),v.jsx("a",{href:cyt,target:"_blank",rel:"noreferrer",children:e("serverConnection.docsLink")})]})]}),u!=null&&v.jsx(nO,{type:"error",showIcon:!0,className:"server-connection-gate__notice",message:u}),v.jsxs(zn,{form:o,layout:"vertical",requiredMark:!1,initialValues:{serverScheme:iyt,serverUrl:syt},onFinish:b=>void p(b),children:[v.jsx(zn.Item,{name:"serverUrl",label:e("serverConnection.serverUrl"),rules:[{required:!0,message:e("serverConnection.serverUrlRequired")}],children:v.jsx(lyt,{form:o})}),v.jsx(nyt,{profiles:c,submitting:f,onConnect:_,onProfilesChange:d}),v.jsx(qe,{type:"primary",htmlType:"submit",size:"large",loading:f,icon:v.jsx("span",{className:"material-symbols-rounded",children:"link"}),block:!0,children:e("serverConnection.connect")})]})]})})}function fyt(){var o,a,l;const{i18n:n}=ht(),e=Su(GW),{data:t}=Gn("/api/config",Z0),i=(l=(a=(o=t==null?void 0:t.sources)==null?void 0:o.merged)==null?void 0:a.general)==null?void 0:l.interfaceLanguage,s=e==="dark"||e==="system"&&window.matchMedia("(prefers-color-scheme: dark)").matches;C.useEffect(()=>{document.documentElement.classList.toggle("dark",s)},[s]),C.useEffect(()=>{i&&n.language!==i&&n.changeLanguage(i)},[n,i]);const r=C.useMemo(()=>({algorithm:s?T5e.darkAlgorithm:T5e.defaultAlgorithm,token:{colorPrimary:s?"#3b82f6":"#000000"}}),[s]);return{isDarkMode:s,themeConfig:r}}const she=n=>"isDeleted"in n&&n.isDeleted,gyt=n=>[...n].sort((e,t)=>{const i=+(t.isStarred===!0)-+(e.isStarred===!0);return i!==0?i:(t.createdAt??0)-(e.createdAt??0)}),I8e=(n,e,t)=>{if((n==null?void 0:n.sessions)==null)return n;if(she(e))return{...n,sessions:n.sessions.filter(a=>a.id!==e.id)};const i=e,s=t==="archived"?i.isArchived===!0:i.isArchived!==!0,r=n.sessions.find(a=>a.id===e.id);if(!s)return{...n,sessions:n.sessions.filter(a=>a.id!==e.id)};const o=r?n.sessions.map(a=>a.id===e.id?{...a,...i}:a):[i,...n.sessions];return{...n,sessions:gyt(o)}},myt=(n,e)=>she(e)?(n==null?void 0:n.session.id)===e.id?void 0:n:(n==null?void 0:n.session)==null?{session:e}:n.session.id===e.id?{...n,session:{...n.session,...e}}:n;function Nee(n,e){n("/api/sessions",t=>I8e(t,e,"active"),!1),n("/api/sessions/archived",t=>I8e(t,e,"archived"),!1),n(XW(e.id),t=>myt(t,e),!1)}const pyt=n=>Array.isArray(n)?n[0]==="/api/adapters":typeof n=="string"&&n.startsWith("/api/adapters/"),Cyt=n=>Array.isArray(n)?n[0]==="worktree-environment"||n[0]==="/api/adapters":pyt(n);async function _yt(n){await Promise.all([n("/api/config"),n("worktree-environments"),n(Cyt)])}const vyt=n=>{const e=new URL(rAe(w7t()));e.protocol=e.protocol==="https:"?"wss:":"ws:";const t=hAe();if(t!=null&&e.searchParams.set("authToken",t),n)for(const[i,s]of Object.entries(n))e.searchParams.set(i,s);return e.toString()};function YW(n,e){const t=vyt(e),i=new WebSocket(t);return i.addEventListener("open",()=>{var s;return(s=n.onOpen)==null?void 0:s.call(n)}),i.addEventListener("message",s=>{var r;try{const o=JSON.parse(String(s.data));(r=n.onMessage)==null||r.call(n,o)}catch(o){console.error(o)}}),i.addEventListener("error",s=>{var r;return(r=n.onError)==null?void 0:r.call(n,s)}),i.addEventListener("close",()=>{var s;return(s=n.onClose)==null?void 0:s.call(n)}),i}function byt(){const{mutate:n}=Jy();C.useEffect(()=>{let e=!1,t,i;const s=a=>{if(a&&!(a.readyState===WebSocket.CLOSED||a.readyState===WebSocket.CLOSING)){if(a.readyState===WebSocket.CONNECTING){a.addEventListener("open",()=>a.close(),{once:!0});return}a.close()}},r=(a=0)=>{e||(i&&clearTimeout(i),i=setTimeout(()=>{i=void 0,o()},a))},o=()=>{e||(t=YW({onMessage:a=>{if(!e){if(a.type==="session_updated"){const l=a.session;Nee(n,l);return}a.type==="config_updated"&&_yt(n)}},onClose:()=>{e||r(1e3)},onError:()=>{s(t)}},{subscribe:"sessions"}))};return r(),()=>{e=!0,i&&clearTimeout(i),s(t)}},[n])}const bOe="/session/:sessionId",yOe="/rooms/:roomId",wOe="/rooms/:roomId/sessions/:sessionId",yyt=n=>{const e=sf({path:wOe,end:!0},n);if((e==null?void 0:e.params.roomId)!=null)return IO(e.params.roomId);const t=sf({path:yOe,end:!0},n);if((t==null?void 0:t.params.roomId)!=null)return IO(t.params.roomId);const i=sf({path:bOe,end:!0},n);return i==null?void 0:i.params.sessionId},wyt="agentRoomMode";function Syt(n,e){const t=new URLSearchParams(e);t.delete(wyt);const i=t.toString();return{pathname:n,search:i===""?"":`?${i}`}}function xyt(){const n=Iu(),e=E3(),t=Su(v_t),i=sf({path:bOe,end:!0},e.pathname),s=sf({path:yOe,end:!0},e.pathname),r=sf({path:wOe,end:!0},e.pathname),o=i==null?void 0:i.params.sessionId,a=yyt(e.pathname),l=e.pathname==="/"||o!=null||(s==null?void 0:s.params.roomId)!=null||(r==null?void 0:r.params.roomId)!=null,c=C.useCallback(f=>Syt(f,e.search),[e.search]),d=C.useCallback((f,g)=>{n(c(f.id===""?"/":`/session/${f.id}`))},[c,n]),u=C.useCallback(f=>{n(c(`/rooms/${f.id}`))},[c,n]),h=C.useCallback((f,g)=>{o===f&&n(c(g?`/session/${g}`:"/"))},[o,c,n]);return{activeSidebarId:a,handleDeletedSession:h,handleSelectRoom:u,handleSelectSession:d,showSidebar:l,sidebarWidth:t}}const Lyt={completed:"completed",failed:"failed",running:"running",stopped:"terminated",waiting:"waiting_input"},kyt=n=>({id:n.sessionId,status:Lyt[n.status],summary:n.latestSummary,title:n.title,updatedAtLabel:n.updatedAtLabel});function Eyt({runs:n,onOpenRun:e}){const{t}=ht(),i=(s,r)=>{if(s==="waiting_input")return v.jsx("div",{className:"waiting-input-indicator",title:r,"aria-label":r});const o=s==="completed"?"check_circle":s==="failed"?"cancel":s==="terminated"?"remove_circle":"sync";return v.jsx("span",{className:`material-symbols-rounded status-icon agent-room-run-list__status-icon agent-room-run-list__status-icon--${s} ${s==="running"?"spin":""}`,title:r,"aria-label":r,children:o})};return n.length===0?v.jsx("div",{className:"agent-room-run-list agent-room-run-list--empty",children:t("agentRoom.roster.noRuns")}):v.jsx("div",{className:"agent-room-run-list",children:n.map(s=>{const r=kyt(s),o=e!=null,a=t("agentRoom.actions.openRun"),l=r.title===""?t("common.newChat"):r.title,c=l===""?a:`${a}: ${l}`,d=t(`common.status.${r.status}`),u=r.updatedAtLabel!=null&&r.updatedAtLabel!==""?r.updatedAtLabel:d;return v.jsx(uOe,{as:"article",className:`agent-room-run-list__session-card agent-room-run-list__session-card--${s.status} session-item session-item--compact`,dataSessionCardSource:"agent-room-run",dataSessionId:r.id,leading:v.jsx("div",{className:"session-leading",children:v.jsx("div",{className:"status-indicator",children:i(r.status,d)})}),title:o?v.jsx("button",{type:"button",className:"agent-room-run-list__title-button session-title-text","aria-label":c,title:c,onClick:()=>e(s),children:l}):v.jsx("span",{className:"session-title-text",children:l}),headerSide:v.jsx("span",{className:"time-display",children:u}),lastMessage:r.summary!=null&&r.summary!==""&&v.jsx("div",{className:"last-message",children:r.summary})},s.runKey)})})}const SOe=n=>n.trim().replace(/^@+/,""),Iyt=n=>n.avatarLabel??SOe(n.label).slice(0,2).toUpperCase();function Myt({defaultExpandedMemberKeys:n=[],members:e,layout:t,onOpenRun:i,showHeader:s=!0}){const{t:r}=ht(),o=C.useId(),[a,l]=C.useState(()=>new Set(n)),c=u=>{l(h=>{const f=new Set(h);return f.has(u)?f.delete(u):f.add(u),f})},d=v.jsx("div",{className:"agent-room-roster__members",children:e.map(u=>{const h=SOe(u.label),f=a.has(u.memberKey),g=u.runs.length>0,m=`${o}-${u.memberKey}-runs`;return v.jsxs("section",{className:`agent-room-roster__member agent-room-roster__member--${u.status}`,children:[v.jsxs("div",{className:"agent-room-roster__member-head",children:[v.jsx("div",{className:"agent-room-roster__avatar","aria-hidden":"true",children:Iyt(u)}),v.jsxs("div",{className:"agent-room-roster__member-copy",children:[v.jsx("div",{className:"agent-room-roster__member-name",children:h}),u.subtitle!=null&&u.subtitle!==""&&v.jsx("div",{className:"agent-room-roster__member-subtitle",children:u.subtitle})]}),v.jsx("span",{className:"agent-room-roster__status",children:r(`agentRoom.status.member.${u.status}`)})]}),u.latestSummary!=null&&u.latestSummary!==""&&v.jsx("div",{className:"agent-room-roster__summary",children:u.latestSummary}),g&&v.jsxs("button",{type:"button",className:`agent-room-roster__runs-toggle ${f?"is-expanded":""}`,"aria-expanded":f,"aria-controls":m,onClick:()=>c(u.memberKey),children:[v.jsx("span",{className:"material-symbols-rounded","aria-hidden":"true",children:"chevron_right"}),v.jsx("span",{children:r(f?"agentRoom.roster.collapseRuns":"agentRoom.roster.expandRuns")})]}),g&&f&&v.jsx("div",{id:m,className:"agent-room-roster__runs-panel",children:v.jsx(Eyt,{runs:u.runs,onOpenRun:i})})]},u.memberKey)})});return t==="compact"?v.jsxs("details",{className:"agent-room-roster agent-room-roster--compact",open:!0,children:[v.jsxs("summary",{className:"agent-room-roster__compact-trigger",children:[v.jsx("span",{className:"material-symbols-rounded","aria-hidden":"true",children:"groups"}),v.jsx("span",{children:r("agentRoom.roster.compactTitle",{count:e.length})})]}),d]}):v.jsxs("aside",{className:"agent-room-roster agent-room-roster--desktop","aria-label":r("agentRoom.roster.title"),children:[s&&v.jsxs("div",{className:"agent-room-roster__header",children:[v.jsxs("div",{children:[v.jsx("div",{className:"agent-room-roster__eyebrow",children:r("agentRoom.roster.eyebrow")}),v.jsx("h2",{children:r("agentRoom.roster.title")})]}),v.jsx("span",{children:r("agentRoom.roster.memberCount",{count:e.length})})]}),d]})}const aq=(n,e)=>n.reduce((t,i)=>t+i.runs.filter(e).length,0),Nyt=n=>({memberKey:n.memberKey??"host",kind:"host",label:"leader",avatarLabel:"L",status:"active",pendingCount:0,activeRunCount:0,runs:[]}),Dyt=n=>{var e;return n.kind==="assignment"||n.memberKey==="host"||((e=n.memberKey)==null?void 0:e.startsWith("host:"))};function xOe(n){const e=new Map(n.members.map(s=>[s.memberKey,s])),t=new Map(n.members.flatMap(s=>s.runs.map(r=>[r.runKey,r]))),i=n.messages.map(s=>{const r=s.runKey==null?void 0:t.get(s.runKey),o=s.memberKey??(r==null?void 0:r.memberKey),a=Dyt(s)?Nyt(s):o==null?void 0:e.get(o);return{...s,member:a,run:r}});return{...n,messages:i,attentionCount:n.members.reduce((s,r)=>s+r.pendingCount,0),runningRunCount:aq(n.members,s=>s.status==="running"),completedRunCount:aq(n.members,s=>s.status==="completed"),failedRunCount:aq(n.members,s=>s.status==="failed")}}const Bb=n=>n.trim().toLowerCase(),rhe=n=>{const e=n.lastIndexOf(":");return e>=0?n.slice(e+1):n},ohe=n=>n.replace(/^@+/,""),vm=(...n)=>{for(const e of n){const t=ohe(rhe(e)).trim();if(t!=="")return t}return""},LOe=n=>Array.from(new Set(n.map(Bb).filter(Boolean))),kOe=n=>LOe([n.label,ohe(n.label),vm(n.label),n.memberKey,rhe(n.memberKey),vm(n.memberKey)]),Tyt=n=>LOe([n.title,ohe(n.title),vm(n.title),n.runKey,rhe(n.runKey),vm(n.runKey)]),nE=n=>`@${vm(n.label,n.memberKey)}`,EOe=(n,e)=>`${nE(n)}/${vm(e.title,e.runKey)}`,ahe=n=>vm(n.label,n.memberKey),Ryt=(n,e)=>`${ahe(n)}/${vm(e.title,e.runKey)}`,Pyt=n=>{const e=Bb(n.memberKey);return n.kind==="host"||e==="host"||e.startsWith("host:")||kOe(n).some(t=>t==="host"||t==="leader")},IOe=n=>n.find(Pyt),Ayt=(n,e)=>{const t=Bb(e);return n.filter(i=>kOe(i).includes(t))},Oyt=(n,e)=>{const t=Bb(e);return n.runs.filter(i=>Tyt(i).includes(t))},Fyt=(n,e)=>e==null?void 0:n.find(t=>t.memberKey===e),Byt=(n,e)=>n==null||e==null?void 0:n.runs.find(t=>t.runKey===e),lq=n=>{const e=IOe(n);return{status:"host",targetLabel:e==null?"leader":ahe(e)}},$yt=n=>{if(!n.startsWith("@"))return;const e=n.search(/\s/),t=e>=0?n.slice(0,e):n,[i="",s]=t.slice(1).split("/",2);return{memberAlias:i,runAlias:s,mention:t,contentStart:t.length}},MOe=n=>({value:nE(n),target:{memberKey:n.memberKey},kind:"member"}),NOe=(n,e)=>({value:EOe(n,e),target:{memberKey:n.memberKey,runKey:e.runKey},kind:"run"}),Hyt=n=>n.map(MOe),Vyt=(n,e)=>e.map(t=>NOe(n,t));function jyt(n,e=""){const t=Bb(e.replace(/^@/,"")),i=n.flatMap(s=>[MOe(s),...s.runs.map(r=>NOe(s,r))]);return t===""?i:i.filter(s=>Bb(s.value.slice(1)).startsWith(t))}function DOe(n,e){const t=n.trimStart();if(t.trim()==="")return{status:"empty"};const i=$yt(t);if(i==null){const h=IOe(e);return{status:"resolved",content:t.trim(),...h!=null?{target:{memberKey:h.memberKey}}:{},route:"host",previewLabel:h==null?"Host agent":nE(h)}}const{memberAlias:s,mention:r,runAlias:o}=i,a=Ayt(e,s);if(a.length===0)return{status:"missing",mention:r};if(a.length>1)return{status:"ambiguous",mention:r,suggestions:Hyt(a)};const l=a[0];if(o!=null&&o.trim()!==""){const h=Oyt(l,o);if(h.length===0)return{status:"missing",mention:r};if(h.length>1)return{status:"ambiguous",mention:r,suggestions:Vyt(l,h)};const f=h[0],g={memberKey:l.memberKey,runKey:f.runKey},m=t.slice(i.contentStart).trim(),p=EOe(l,f);return m===""?{status:"empty-targeted-message",mention:r,target:g,route:"run",previewLabel:p}:{status:"resolved",content:m,target:g,route:"run",mention:r,previewLabel:p}}const c={memberKey:l.memberKey},d=t.slice(i.contentStart).trim(),u=`${nE(l)} mailbox`;return d===""?{status:"empty-targeted-message",mention:r,target:c,route:"member",previewLabel:u}:{status:"resolved",content:d,target:c,route:"member",mention:r,previewLabel:u}}function Wyt(n,e){var o,a;const t=n.trimStart();if(t===""||!t.startsWith("@"))return lq(e);const i=DOe(n,e);if(i.status==="missing"||i.status==="ambiguous")return{status:i.status,targetLabel:i.mention};if(i.status==="empty")return lq(e);const s=Fyt(e,(o=i.target)==null?void 0:o.memberKey),r=Byt(s,(a=i.target)==null?void 0:a.runKey);return i.route==="run"?{status:"run",targetLabel:s==null||r==null?i.previewLabel:Ryt(s,r)}:i.route==="member"?{status:"member",targetLabel:s==null?i.previewLabel:ahe(s)}:lq(e)}function zyt(n){return{content:n.content,...n.target!=null?{target:n.target}:{},route:n.route}}const Uyt="modulepreload",Kyt=function(n){return"/__VF_PROJECT_AI_CLIENT_BASE__/"+n},M8e={},re=function(e,t,i){let s=Promise.resolve();if(t&&t.length>0){document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),a=(o==null?void 0:o.nonce)||(o==null?void 0:o.getAttribute("nonce"));s=Promise.allSettled(t.map(l=>{if(l=Kyt(l),l in M8e)return;M8e[l]=!0;const c=l.endsWith(".css"),d=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${l}"]${d}`))return;const u=document.createElement("link");if(u.rel=c?"stylesheet":Uyt,c||(u.as="script"),u.crossOrigin="",u.href=l,a&&u.setAttribute("nonce",a),document.head.appendChild(u),c)return new Promise((h,f)=>{u.addEventListener("load",h),u.addEventListener("error",()=>f(new Error(`Unable to preload CSS for ${l}`)))})}))}function r(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return s.then(o=>{for(const a of o||[])a.status==="rejected"&&r(a.reason);return e().catch(r)})};let xa=class extends Error{constructor(e){super(e),this.name="ShikiError"}};function Zyt(n){return lhe(n)}function lhe(n){return Array.isArray(n)?qyt(n):n instanceof RegExp?n:typeof n=="object"?Gyt(n):n}function qyt(n){let e=[];for(let t=0,i=n.length;t<i;t++)e[t]=lhe(n[t]);return e}function Gyt(n){let e={};for(let t in n)e[t]=lhe(n[t]);return e}function TOe(n,...e){return e.forEach(t=>{for(let i in t)n[i]=t[i]}),n}function ROe(n){const e=~n.lastIndexOf("/")||~n.lastIndexOf("\\");return e===0?n:~e===n.length-1?ROe(n.substring(0,n.length-1)):n.substr(~e+1)}var cq=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,WD=class{static hasCaptures(n){return n===null?!1:(cq.lastIndex=0,cq.test(n))}static replaceCaptures(n,e,t){return n.replace(cq,(i,s,r,o)=>{let a=t[parseInt(s||r,10)];if(a){let l=e.substring(a.start,a.end);for(;l[0]===".";)l=l.substring(1);switch(o){case"downcase":return l.toLowerCase();case"upcase":return l.toUpperCase();default:return l}}else return i})}};function POe(n,e){return n<e?-1:n>e?1:0}function AOe(n,e){if(n===null&&e===null)return 0;if(!n)return-1;if(!e)return 1;let t=n.length,i=e.length;if(t===i){for(let s=0;s<t;s++){let r=POe(n[s],e[s]);if(r!==0)return r}return 0}return t-i}function N8e(n){return!!(/^#[0-9a-f]{6}$/i.test(n)||/^#[0-9a-f]{8}$/i.test(n)||/^#[0-9a-f]{3}$/i.test(n)||/^#[0-9a-f]{4}$/i.test(n))}function OOe(n){return n.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var FOe=class{constructor(n){dt(this,"cache",new Map);this.fn=n}get(n){if(this.cache.has(n))return this.cache.get(n);const e=this.fn(n);return this.cache.set(n,e),e}},NO=class{constructor(n,e,t){dt(this,"_cachedMatchRoot",new FOe(n=>this._root.match(n)));this._colorMap=n,this._defaults=e,this._root=t}static createFromRawTheme(n,e){return this.createFromParsedTheme(Qyt(n),e)}static createFromParsedTheme(n,e){return ewt(n,e)}getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(n){if(n===null)return this._defaults;const e=n.scopeName,i=this._cachedMatchRoot.get(e).find(s=>Xyt(n.parent,s.parentScopes));return i?new BOe(i.fontStyle,i.foreground,i.background):null}},dq=class CP{constructor(e,t){this.parent=e,this.scopeName=t}static push(e,t){for(const i of t)e=new CP(e,i);return e}static from(...e){let t=null;for(let i=0;i<e.length;i++)t=new CP(t,e[i]);return t}push(e){return new CP(this,e)}getSegments(){let e=this;const t=[];for(;e;)t.push(e.scopeName),e=e.parent;return t.reverse(),t}toString(){return this.getSegments().join(" ")}extends(e){return this===e?!0:this.parent===null?!1:this.parent.extends(e)}getExtensionIfDefined(e){const t=[];let i=this;for(;i&&i!==e;)t.push(i.scopeName),i=i.parent;return i===e?t.reverse():void 0}};function Xyt(n,e){if(e.length===0)return!0;for(let t=0;t<e.length;t++){let i=e[t],s=!1;if(i===">"){if(t===e.length-1)return!1;i=e[++t],s=!0}for(;n&&!Yyt(n.scopeName,i);){if(s)return!1;n=n.parent}if(!n)return!1;n=n.parent}return!0}function Yyt(n,e){return e===n||n.startsWith(e)&&n[e.length]==="."}var BOe=class{constructor(n,e,t){this.fontStyle=n,this.foregroundId=e,this.backgroundId=t}};function Qyt(n){if(!n)return[];if(!n.settings||!Array.isArray(n.settings))return[];let e=n.settings,t=[],i=0;for(let s=0,r=e.length;s<r;s++){let o=e[s];if(!o.settings)continue;let a;if(typeof o.scope=="string"){let u=o.scope;u=u.replace(/^[,]+/,""),u=u.replace(/[,]+$/,""),a=u.split(",")}else Array.isArray(o.scope)?a=o.scope:a=[""];let l=-1;if(typeof o.settings.fontStyle=="string"){l=0;let u=o.settings.fontStyle.split(" ");for(let h=0,f=u.length;h<f;h++)switch(u[h]){case"italic":l=l|1;break;case"bold":l=l|2;break;case"underline":l=l|4;break;case"strikethrough":l=l|8;break}}let c=null;typeof o.settings.foreground=="string"&&N8e(o.settings.foreground)&&(c=o.settings.foreground);let d=null;typeof o.settings.background=="string"&&N8e(o.settings.background)&&(d=o.settings.background);for(let u=0,h=a.length;u<h;u++){let g=a[u].trim().split(" "),m=g[g.length-1],p=null;g.length>1&&(p=g.slice(0,g.length-1),p.reverse()),t[i++]=new Jyt(m,p,s,l,c,d)}}return t}var Jyt=class{constructor(n,e,t,i,s,r){this.scope=n,this.parentScopes=e,this.index=t,this.fontStyle=i,this.foreground=s,this.background=r}},Rc=(n=>(n[n.NotSet=-1]="NotSet",n[n.None=0]="None",n[n.Italic=1]="Italic",n[n.Bold=2]="Bold",n[n.Underline=4]="Underline",n[n.Strikethrough=8]="Strikethrough",n))(Rc||{});function ewt(n,e){n.sort((l,c)=>{let d=POe(l.scope,c.scope);return d!==0||(d=AOe(l.parentScopes,c.parentScopes),d!==0)?d:l.index-c.index});let t=0,i="#000000",s="#ffffff";for(;n.length>=1&&n[0].scope==="";){let l=n.shift();l.fontStyle!==-1&&(t=l.fontStyle),l.foreground!==null&&(i=l.foreground),l.background!==null&&(s=l.background)}let r=new twt(e),o=new BOe(t,r.getId(i),r.getId(s)),a=new iwt(new Dee(0,null,-1,0,0),[]);for(let l=0,c=n.length;l<c;l++){let d=n[l];a.insert(0,d.scope,d.parentScopes,d.fontStyle,r.getId(d.foreground),r.getId(d.background))}return new NO(r,o,a)}var twt=class{constructor(e){dt(this,"_isFrozen");dt(this,"_lastColorId");dt(this,"_id2color");dt(this,"_color2id");if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(e)){this._isFrozen=!0;for(let t=0,i=e.length;t<i;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)}},nwt=Object.freeze([]),Dee=class $Oe{constructor(e,t,i,s,r){dt(this,"scopeDepth");dt(this,"parentScopes");dt(this,"fontStyle");dt(this,"foreground");dt(this,"background");this.scopeDepth=e,this.parentScopes=t||nwt,this.fontStyle=i,this.foreground=s,this.background=r}clone(){return new $Oe(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(e){let t=[];for(let i=0,s=e.length;i<s;i++)t[i]=e[i].clone();return t}acceptOverwrite(e,t,i,s){this.scopeDepth>e?console.log("how did this happen?"):this.scopeDepth=e,t!==-1&&(this.fontStyle=t),i!==0&&(this.foreground=i),s!==0&&(this.background=s)}},iwt=class Tee{constructor(e,t=[],i={}){dt(this,"_rulesWithParentScopes");this._mainRule=e,this._children=i,this._rulesWithParentScopes=t}static _cmpBySpecificity(e,t){if(e.scopeDepth!==t.scopeDepth)return t.scopeDepth-e.scopeDepth;let i=0,s=0;for(;e.parentScopes[i]===">"&&i++,t.parentScopes[s]===">"&&s++,!(i>=e.parentScopes.length||s>=t.parentScopes.length);){const r=t.parentScopes[s].length-e.parentScopes[i].length;if(r!==0)return r;i++,s++}return t.parentScopes.length-e.parentScopes.length}match(e){if(e!==""){let i=e.indexOf("."),s,r;if(i===-1?(s=e,r=""):(s=e.substring(0,i),r=e.substring(i+1)),this._children.hasOwnProperty(s))return this._children[s].match(r)}const t=this._rulesWithParentScopes.concat(this._mainRule);return t.sort(Tee._cmpBySpecificity),t}insert(e,t,i,s,r,o){if(t===""){this._doInsertHere(e,i,s,r,o);return}let a=t.indexOf("."),l,c;a===-1?(l=t,c=""):(l=t.substring(0,a),c=t.substring(a+1));let d;this._children.hasOwnProperty(l)?d=this._children[l]:(d=new Tee(this._mainRule.clone(),Dee.cloneArr(this._rulesWithParentScopes)),this._children[l]=d),d.insert(e+1,c,i,s,r,o)}_doInsertHere(e,t,i,s,r){if(t===null){this._mainRule.acceptOverwrite(e,i,s,r);return}for(let o=0,a=this._rulesWithParentScopes.length;o<a;o++){let l=this._rulesWithParentScopes[o];if(AOe(l.parentScopes,t)===0){l.acceptOverwrite(e,i,s,r);return}}i===-1&&(i=this._mainRule.fontStyle),s===0&&(s=this._mainRule.foreground),r===0&&(r=this._mainRule.background),this._rulesWithParentScopes.push(new Dee(e,t,i,s,r))}},$b=class H3{static toBinaryStr(e){return e.toString(2).padStart(32,"0")}static print(e){const t=H3.getLanguageId(e),i=H3.getTokenType(e),s=H3.getFontStyle(e),r=H3.getForeground(e),o=H3.getBackground(e);console.log({languageId:t,tokenType:i,fontStyle:s,foreground:r,background:o})}static getLanguageId(e){return(e&255)>>>0}static getTokenType(e){return(e&768)>>>8}static containsBalancedBrackets(e){return(e&1024)!==0}static getFontStyle(e){return(e&30720)>>>11}static getForeground(e){return(e&16744448)>>>15}static getBackground(e){return(e&4278190080)>>>24}static set(e,t,i,s,r,o,a){let l=H3.getLanguageId(e),c=H3.getTokenType(e),d=H3.containsBalancedBrackets(e)?1:0,u=H3.getFontStyle(e),h=H3.getForeground(e),f=H3.getBackground(e);return t!==0&&(l=t),i!==8&&(c=i),s!==null&&(d=s?1:0),r!==-1&&(u=r),o!==0&&(h=o),a!==0&&(f=a),(l<<0|c<<8|d<<10|u<<11|h<<15|f<<24)>>>0}};function DO(n,e){const t=[],i=swt(n);let s=i.next();for(;s!==null;){let l=0;if(s.length===2&&s.charAt(1)===":"){switch(s.charAt(0)){case"R":l=1;break;case"L":l=-1;break;default:console.log(`Unknown priority ${s} in scope selector`)}s=i.next()}let c=o();if(t.push({matcher:c,priority:l}),s!==",")break;s=i.next()}return t;function r(){if(s==="-"){s=i.next();const l=r();return c=>!!l&&!l(c)}if(s==="("){s=i.next();const l=a();return s===")"&&(s=i.next()),l}if(D8e(s)){const l=[];do l.push(s),s=i.next();while(D8e(s));return c=>e(l,c)}return null}function o(){const l=[];let c=r();for(;c;)l.push(c),c=r();return d=>l.every(u=>u(d))}function a(){const l=[];let c=o();for(;c&&(l.push(c),s==="|"||s===",");){do s=i.next();while(s==="|"||s===",");c=o()}return d=>l.some(u=>u(d))}}function D8e(n){return!!n&&!!n.match(/[\w\.:]+/)}function swt(n){let e=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,t=e.exec(n);return{next:()=>{if(!t)return null;const i=t[0];return t=e.exec(n),i}}}function HOe(n){typeof n.dispose=="function"&&n.dispose()}var iE=class{constructor(n){this.scopeName=n}toKey(){return this.scopeName}},rwt=class{constructor(n,e){this.scopeName=n,this.ruleName=e}toKey(){return`${this.scopeName}#${this.ruleName}`}},owt=class{constructor(){dt(this,"_references",[]);dt(this,"_seenReferenceKeys",new Set);dt(this,"visitedRule",new Set)}get references(){return this._references}add(n){const e=n.toKey();this._seenReferenceKeys.has(e)||(this._seenReferenceKeys.add(e),this._references.push(n))}},awt=class{constructor(n,e){dt(this,"seenFullScopeRequests",new Set);dt(this,"seenPartialScopeRequests",new Set);dt(this,"Q");this.repo=n,this.initialScopeName=e,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new iE(this.initialScopeName)]}processQueue(){const n=this.Q;this.Q=[];const e=new owt;for(const t of n)lwt(t,this.initialScopeName,this.repo,e);for(const t of e.references)if(t instanceof iE){if(this.seenFullScopeRequests.has(t.scopeName))continue;this.seenFullScopeRequests.add(t.scopeName),this.Q.push(t)}else{if(this.seenFullScopeRequests.has(t.scopeName)||this.seenPartialScopeRequests.has(t.toKey()))continue;this.seenPartialScopeRequests.add(t.toKey()),this.Q.push(t)}}};function lwt(n,e,t,i){const s=t.lookup(n.scopeName);if(!s){if(n.scopeName===e)throw new Error(`No grammar provided for <${e}>`);return}const r=t.lookup(e);n instanceof iE?_P({baseGrammar:r,selfGrammar:s},i):Ree(n.ruleName,{baseGrammar:r,selfGrammar:s,repository:s.repository},i);const o=t.injections(n.scopeName);if(o)for(const a of o)i.add(new iE(a))}function Ree(n,e,t){if(e.repository&&e.repository[n]){const i=e.repository[n];TO([i],e,t)}}function _P(n,e){n.selfGrammar.patterns&&Array.isArray(n.selfGrammar.patterns)&&TO(n.selfGrammar.patterns,{...n,repository:n.selfGrammar.repository},e),n.selfGrammar.injections&&TO(Object.values(n.selfGrammar.injections),{...n,repository:n.selfGrammar.repository},e)}function TO(n,e,t){for(const i of n){if(t.visitedRule.has(i))continue;t.visitedRule.add(i);const s=i.repository?TOe({},e.repository,i.repository):e.repository;Array.isArray(i.patterns)&&TO(i.patterns,{...e,repository:s},t);const r=i.include;if(!r)continue;const o=VOe(r);switch(o.kind){case 0:_P({...e,selfGrammar:e.baseGrammar},t);break;case 1:_P(e,t);break;case 2:Ree(o.ruleName,{...e,repository:s},t);break;case 3:case 4:const a=o.scopeName===e.selfGrammar.scopeName?e.selfGrammar:o.scopeName===e.baseGrammar.scopeName?e.baseGrammar:void 0;if(a){const l={baseGrammar:e.baseGrammar,selfGrammar:a,repository:s};o.kind===4?Ree(o.ruleName,l,t):_P(l,t)}else o.kind===4?t.add(new rwt(o.scopeName,o.ruleName)):t.add(new iE(o.scopeName));break}}}var cwt=class{constructor(){dt(this,"kind",0)}},dwt=class{constructor(){dt(this,"kind",1)}},uwt=class{constructor(n){dt(this,"kind",2);this.ruleName=n}},hwt=class{constructor(n){dt(this,"kind",3);this.scopeName=n}},fwt=class{constructor(n,e){dt(this,"kind",4);this.scopeName=n,this.ruleName=e}};function VOe(n){if(n==="$base")return new cwt;if(n==="$self")return new dwt;const e=n.indexOf("#");if(e===-1)return new hwt(n);if(e===0)return new uwt(n.substring(1));{const t=n.substring(0,e),i=n.substring(e+1);return new fwt(t,i)}}var gwt=/\\(\d+)/,T8e=/\\(\d+)/g,mwt=-1,jOe=-2;var ZM=class{constructor(e,t,i,s){dt(this,"$location");dt(this,"id");dt(this,"_nameIsCapturing");dt(this,"_name");dt(this,"_contentNameIsCapturing");dt(this,"_contentName");this.$location=e,this.id=t,this._name=i||null,this._nameIsCapturing=WD.hasCaptures(this._name),this._contentName=s||null,this._contentNameIsCapturing=WD.hasCaptures(this._contentName)}get debugName(){const e=this.$location?`${ROe(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:WD.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:WD.replaceCaptures(this._contentName,e,t)}},pwt=class extends ZM{constructor(e,t,i,s,r){super(e,t,i,s);dt(this,"retokenizeCapturedWithRuleId");this.retokenizeCapturedWithRuleId=r}dispose(){}collectPatterns(e,t){throw new Error("Not supported!")}compile(e,t){throw new Error("Not supported!")}compileAG(e,t,i,s){throw new Error("Not supported!")}},Cwt=class extends ZM{constructor(e,t,i,s,r){super(e,t,i,null);dt(this,"_match");dt(this,"captures");dt(this,"_cachedCompiledPatterns");this._match=new sE(s,this.id),this.captures=r,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(e,t){t.push(this._match)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,i,s){return this._getCachedCompiledPatterns(e).compileAG(e,i,s)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new rE,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},R8e=class extends ZM{constructor(e,t,i,s,r){super(e,t,i,s);dt(this,"hasMissingPatterns");dt(this,"patterns");dt(this,"_cachedCompiledPatterns");this.patterns=r.patterns,this.hasMissingPatterns=r.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}collectPatterns(e,t){for(const i of this.patterns)e.getRule(i).collectPatterns(e,t)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,i,s){return this._getCachedCompiledPatterns(e).compileAG(e,i,s)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new rE,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Pee=class extends ZM{constructor(e,t,i,s,r,o,a,l,c,d){super(e,t,i,s);dt(this,"_begin");dt(this,"beginCaptures");dt(this,"_end");dt(this,"endHasBackReferences");dt(this,"endCaptures");dt(this,"applyEndPatternLast");dt(this,"hasMissingPatterns");dt(this,"patterns");dt(this,"_cachedCompiledPatterns");this._begin=new sE(r,this.id),this.beginCaptures=o,this._end=new sE(a||"￿",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=l,this.applyEndPatternLast=c||!1,this.patterns=d.patterns,this.hasMissingPatterns=d.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(e,t){return this._end.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e,t).compile(e)}compileAG(e,t,i,s){return this._getCachedCompiledPatterns(e,t).compileAG(e,i,s)}_getCachedCompiledPatterns(e,t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new rE;for(const i of this.patterns)e.getRule(i).collectPatterns(e,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,t):this._cachedCompiledPatterns.setSource(0,t)),this._cachedCompiledPatterns}},RO=class extends ZM{constructor(e,t,i,s,r,o,a,l,c){super(e,t,i,s);dt(this,"_begin");dt(this,"beginCaptures");dt(this,"whileCaptures");dt(this,"_while");dt(this,"whileHasBackReferences");dt(this,"hasMissingPatterns");dt(this,"patterns");dt(this,"_cachedCompiledPatterns");dt(this,"_cachedCompiledWhilePatterns");this._begin=new sE(r,this.id),this.beginCaptures=o,this.whileCaptures=l,this._while=new sE(a,jOe),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=c.patterns,this.hasMissingPatterns=c.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(e,t){return this._while.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,i,s){return this._getCachedCompiledPatterns(e).compileAG(e,i,s)}_getCachedCompiledPatterns(e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new rE;for(const t of this.patterns)e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(e,t){return this._getCachedCompiledWhilePatterns(e,t).compile(e)}compileWhileAG(e,t,i,s){return this._getCachedCompiledWhilePatterns(e,t).compileAG(e,i,s)}_getCachedCompiledWhilePatterns(e,t){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new rE,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,t||"￿"),this._cachedCompiledWhilePatterns}},WOe=class xc{static createCaptureRule(e,t,i,s,r){return e.registerRule(o=>new pwt(t,o,i,s,r))}static getCompiledRuleId(e,t,i){return e.id||t.registerRule(s=>{if(e.id=s,e.match)return new Cwt(e.$vscodeTextmateLocation,e.id,e.name,e.match,xc._compileCaptures(e.captures,t,i));if(typeof e.begin>"u"){e.repository&&(i=TOe({},i,e.repository));let r=e.patterns;return typeof r>"u"&&e.include&&(r=[{include:e.include}]),new R8e(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,xc._compilePatterns(r,t,i))}return e.while?new RO(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,e.begin,xc._compileCaptures(e.beginCaptures||e.captures,t,i),e.while,xc._compileCaptures(e.whileCaptures||e.captures,t,i),xc._compilePatterns(e.patterns,t,i)):new Pee(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,e.begin,xc._compileCaptures(e.beginCaptures||e.captures,t,i),e.end,xc._compileCaptures(e.endCaptures||e.captures,t,i),e.applyEndPatternLast,xc._compilePatterns(e.patterns,t,i))}),e.id}static _compileCaptures(e,t,i){let s=[];if(e){let r=0;for(const o in e){if(o==="$vscodeTextmateLocation")continue;const a=parseInt(o,10);a>r&&(r=a)}for(let o=0;o<=r;o++)s[o]=null;for(const o in e){if(o==="$vscodeTextmateLocation")continue;const a=parseInt(o,10);let l=0;e[o].patterns&&(l=xc.getCompiledRuleId(e[o],t,i)),s[a]=xc.createCaptureRule(t,e[o].$vscodeTextmateLocation,e[o].name,e[o].contentName,l)}}return s}static _compilePatterns(e,t,i){let s=[];if(e)for(let r=0,o=e.length;r<o;r++){const a=e[r];let l=-1;if(a.include){const c=VOe(a.include);switch(c.kind){case 0:case 1:l=xc.getCompiledRuleId(i[a.include],t,i);break;case 2:let d=i[c.ruleName];d&&(l=xc.getCompiledRuleId(d,t,i));break;case 3:case 4:const u=c.scopeName,h=c.kind===4?c.ruleName:null,f=t.getExternalGrammar(u,i);if(f)if(h){let g=f.repository[h];g&&(l=xc.getCompiledRuleId(g,t,f.repository))}else l=xc.getCompiledRuleId(f.repository.$self,t,f.repository);break}}else l=xc.getCompiledRuleId(a,t,i);if(l!==-1){const c=t.getRule(l);let d=!1;if((c instanceof R8e||c instanceof Pee||c instanceof RO)&&c.hasMissingPatterns&&c.patterns.length===0&&(d=!0),d)continue;s.push(l)}}return{patterns:s,hasMissingPatterns:(e?e.length:0)!==s.length}}},sE=class zOe{constructor(e,t){dt(this,"source");dt(this,"ruleId");dt(this,"hasAnchor");dt(this,"hasBackReferences");dt(this,"_anchorCache");if(e&&typeof e=="string"){const i=e.length;let s=0,r=[],o=!1;for(let a=0;a<i;a++)if(e.charAt(a)==="\\"&&a+1<i){const c=e.charAt(a+1);c==="z"?(r.push(e.substring(s,a)),r.push("$(?!\\n)(?<!\\n)"),s=a+2):(c==="A"||c==="G")&&(o=!0),a++}this.hasAnchor=o,s===0?this.source=e:(r.push(e.substring(s,i)),this.source=r.join(""))}else this.hasAnchor=!1,this.source=e;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=t,typeof this.source=="string"?this.hasBackReferences=gwt.test(this.source):this.hasBackReferences=!1}clone(){return new zOe(this.source,this.ruleId)}setSource(e){this.source!==e&&(this.source=e,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(e,t){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let i=t.map(s=>e.substring(s.start,s.end));return T8e.lastIndex=0,this.source.replace(T8e,(s,r)=>OOe(i[parseInt(r,10)]||""))}_buildAnchorCache(){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let e=[],t=[],i=[],s=[],r,o,a,l;for(r=0,o=this.source.length;r<o;r++)a=this.source.charAt(r),e[r]=a,t[r]=a,i[r]=a,s[r]=a,a==="\\"&&r+1<o&&(l=this.source.charAt(r+1),l==="A"?(e[r+1]="￿",t[r+1]="￿",i[r+1]="A",s[r+1]="A"):l==="G"?(e[r+1]="￿",t[r+1]="G",i[r+1]="￿",s[r+1]="G"):(e[r+1]=l,t[r+1]=l,i[r+1]=l,s[r+1]=l),r++);return{A0_G0:e.join(""),A0_G1:t.join(""),A1_G0:i.join(""),A1_G1:s.join("")}}resolveAnchors(e,t){return!this.hasAnchor||!this._anchorCache||typeof this.source!="string"?this.source:e?t?this._anchorCache.A1_G1:this._anchorCache.A1_G0:t?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},rE=class{constructor(){dt(this,"_items");dt(this,"_hasAnchors");dt(this,"_cached");dt(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(n){this._items.push(n),this._hasAnchors=this._hasAnchors||n.hasAnchor}unshift(n){this._items.unshift(n),this._hasAnchors=this._hasAnchors||n.hasAnchor}length(){return this._items.length}setSource(n,e){this._items[n].source!==e&&(this._disposeCaches(),this._items[n].setSource(e))}compile(n){if(!this._cached){let e=this._items.map(t=>t.source);this._cached=new P8e(n,e,this._items.map(t=>t.ruleId))}return this._cached}compileAG(n,e,t){return this._hasAnchors?e?t?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(n,e,t)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(n,e,t)),this._anchorCache.A1_G0):t?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(n,e,t)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(n,e,t)),this._anchorCache.A0_G0):this.compile(n)}_resolveAnchors(n,e,t){let i=this._items.map(s=>s.resolveAnchors(e,t));return new P8e(n,i,this._items.map(s=>s.ruleId))}},P8e=class{constructor(n,e,t){dt(this,"scanner");this.regExps=e,this.rules=t,this.scanner=n.createOnigScanner(e)}dispose(){typeof this.scanner.dispose=="function"&&this.scanner.dispose()}toString(){const n=[];for(let e=0,t=this.rules.length;e<t;e++)n.push(" - "+this.rules[e]+": "+this.regExps[e]);return n.join(`
524
+ `.trim(),Cbt=`data:image/svg+xml;utf8,${encodeURIComponent(pbt)}`,_bt="OpenCode",vbt={"claude-code":{title:ibt,icon:nbt},codex:{title:obt,icon:rbt},copilot:{title:cbt,icon:lbt},gemini:{title:hbt,icon:ubt},kimi:{title:mbt,icon:gbt},opencode:{title:_bt,icon:Cbt}},tw=n=>vbt[n]??{title:n,icon:void 0};var bbt={exports:{}};(function(n,e){(function(t,i){n.exports=i(RTe)})(_k,function(t){function i(o){return o&&typeof o=="object"&&"default"in o?o:{default:o}}var s=i(t),r={name:"zh-cn",weekdays:"星期日_星期一_星期二_星期三_星期四_星期五_星期六".split("_"),weekdaysShort:"周日_周一_周二_周三_周四_周五_周六".split("_"),weekdaysMin:"日_一_二_三_四_五_六".split("_"),months:"一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月".split("_"),monthsShort:"1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月".split("_"),ordinal:function(o,a){return a==="W"?o+"周":o+"日"},weekStart:1,yearStart:4,formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"YYYY/MM/DD",LL:"YYYY年M月D日",LLL:"YYYY年M月D日Ah点mm分",LLLL:"YYYY年M月D日ddddAh点mm分",l:"YYYY/M/D",ll:"YYYY年M月D日",lll:"YYYY年M月D日 HH:mm",llll:"YYYY年M月D日dddd HH:mm"},relativeTime:{future:"%s内",past:"%s前",s:"几秒",m:"1 分钟",mm:"%d 分钟",h:"1 小时",hh:"%d 小时",d:"1 天",dd:"%d 天",M:"1 个月",MM:"%d 个月",y:"1 年",yy:"%d 年"},meridiem:function(o,a){var l=100*o+a;return l<600?"凌晨":l<900?"早上":l<1100?"上午":l<1300?"中午":l<1800?"下午":"晚上"}};return s.default.locale(r,null,!0),r})})(bbt);var rOe={exports:{}};(function(n,e){(function(t,i){n.exports=i()})(_k,function(){return function(t,i,s){t=t||{};var r=i.prototype,o={future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"};function a(c,d,u,h){return r.fromToBase(c,d,u,h)}s.en.relativeTime=o,r.fromToBase=function(c,d,u,h,f){for(var g,m,p,_=u.$locale().relativeTime||o,b=t.thresholds||[{l:"s",r:44,d:"second"},{l:"m",r:89},{l:"mm",r:44,d:"minute"},{l:"h",r:89},{l:"hh",r:21,d:"hour"},{l:"d",r:35},{l:"dd",r:25,d:"day"},{l:"M",r:45},{l:"MM",r:10,d:"month"},{l:"y",r:17},{l:"yy",d:"year"}],y=b.length,w=0;w<y;w+=1){var S=b[w];S.d&&(g=h?s(c).diff(u,S.d,!0):u.diff(c,S.d,!0));var x=(t.rounding||Math.round)(Math.abs(g));if(p=g>0,x<=S.r||!S.r){x<=1&&w>0&&(S=b[w-1]);var L=_[S.l];f&&(x=f(""+x)),m=typeof L=="string"?L.replace("%d",x):L(x,d,S.l,p);break}}if(d)return m;var E=p?_.future:_.past;return typeof E=="function"?E(m):E.replace("%s",m)},r.to=function(c,d){return a(c,d,this,!0)},r.from=function(c,d){return a(c,d,this)};var l=function(c){return c.$u?s.utc():s()};r.toNow=function(c){return this.to(l(this),c)},r.fromNow=function(c){return this.from(l(this),c)}}})})(rOe);var ybt=rOe.exports;const oOe=z0(ybt),wbt=5,VD=[["#0f766e","#14b8a6"],["#1d4ed8","#60a5fa"],["#b45309","#f59e0b"],["#be123c","#fb7185"],["#4338ca","#818cf8"],["#15803d","#4ade80"],["#0e7490","#22d3ee"]],Sbt=n=>{let e=2166136261;for(let t=0;t<n.length;t+=1)e^=n.charCodeAt(t),e=Math.imul(e,16777619);return e>>>0},xbt=n=>{const e=Sbt(n),t=[];for(let i=0;i<wbt;i+=1){const s=[];for(let r=0;r<3;r+=1){const o=(e>>(i*3+r)%24&1)===1;s.push(o)}t.push(s[0],s[1],s[2],s[1],s[0])}return{accent:VD[e%VD.length][0],accentSoft:VD[(e>>>4)%VD.length][1],pixels:t}};function aOe({className:n,label:e,seed:t}){const i=C.useMemo(()=>xbt(t),[t]),s={"--room-pixel-avatar-accent":i.accent,"--room-pixel-avatar-accent-soft":i.accentSoft};return v.jsx("span",{className:["room-pixel-avatar",n].filter(Boolean).join(" "),"aria-label":e,"aria-hidden":e==null?!0:void 0,style:s,children:i.pixels.map((r,o)=>v.jsx("span",{className:["room-pixel-avatar__pixel",r?"room-pixel-avatar__pixel--filled":""].filter(Boolean).join(" ")},o))})}async function rf(n){try{return await navigator.clipboard.writeText(n.text),n.messageApi.success(n.successMessage),!0}catch{return n.messageApi.error(n.failureMessage),!1}}function lOe({entries:n,pendingAction:e,onCancelConfirm:t}){return v.jsx("div",{className:"session-context-menu",onContextMenu:i=>i.preventDefault(),children:n.map(i=>{if(i.type==="divider")return v.jsx("div",{className:"session-context-menu__divider"},i.key);const s=e===i.key;return v.jsxs("div",{role:"button",tabIndex:0,className:`session-context-menu__item session-context-menu__item--${i.key} ${i.danger?"is-danger":""} ${s?"is-confirming":""}`,onClick:r=>{r.preventDefault(),r.stopPropagation(),i.onClick()},onKeyDown:r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),i.onClick())},children:[v.jsxs("div",{className:"session-context-menu__meta",children:[v.jsx("span",{className:"material-symbols-rounded session-context-menu__icon",children:i.icon}),v.jsx("span",{className:"session-context-menu__label",children:s?i.confirmLabel??i.label:i.label})]}),s&&v.jsxs("div",{className:"session-context-menu__confirm-actions",children:[v.jsx("button",{type:"button",className:"session-context-menu__confirm-btn is-accept",onClick:r=>{r.preventDefault(),r.stopPropagation(),i.onClick()},children:v.jsx("span",{className:"material-symbols-rounded",children:"check"})}),v.jsx("button",{type:"button",className:"session-context-menu__confirm-btn is-cancel",onClick:r=>{r.preventDefault(),r.stopPropagation(),t()},children:v.jsx("span",{className:"material-symbols-rounded",children:"close"})})]})]},i.key)})})}const cOe=n=>{const e=new URL(globalThis.location.origin),t=qW().replace(/\/+$/,""),i=t===""?"":t;return e.pathname=`${i}/rooms/${encodeURIComponent(n)}`,e.search="",e.hash="",e.toString()},bv=n=>n.archivedAt!=null,Pg=n=>n.favoritedAt!=null;function Lbt({handlers:n,labels:e,room:t}){const i=Pg(t),s=bv(t);return[{key:"open-room",label:e.openRoom,icon:"open_in_new",onClick:n.onOpen},{key:"divider-metadata",type:"divider",label:"",icon:"",onClick:()=>{}},{key:"favorite-room",label:e.favoriteRoom,icon:i?"star":"star_border",onClick:n.onFavorite},{key:"archive-room",label:e.archiveRoom,confirmLabel:e.confirmArchiveRoom,icon:s?"unarchive":"archive",onClick:n.onArchive},{key:"divider-copy",type:"divider",label:"",icon:"",onClick:()=>{}},{key:"copy-room-link",label:e.copyRoomLink,icon:"link",onClick:n.onCopyLink},{key:"copy-room-id",label:e.copyRoomId,icon:"fingerprint",onClick:n.onCopyId}]}function dOe({children:n,onArchive:e,onFavorite:t,onSelect:i,room:s,trigger:r=["contextMenu"]}){const{t:o}=ht(),{message:a}=Vs.useApp(),[l,c]=C.useState(!1),[d,u]=C.useState(null),h=()=>{c(!1),u(null)},f=bv(s)?o("agentRoom.sidebar.unarchiveRoom"):o("agentRoom.sidebar.archiveRoom"),g=()=>{if(d==="archive-room"){h(),e(s.id,!bv(s));return}u("archive-room")},m=Lbt({room:s,labels:{openRoom:o("agentRoom.sidebar.openRoom"),favoriteRoom:Pg(s)?o("agentRoom.sidebar.unfavoriteRoom"):o("agentRoom.sidebar.favoriteRoom"),archiveRoom:f,confirmArchiveRoom:o("common.confirmAction",{action:f}),copyRoomLink:o("agentRoom.sidebar.copyRoomLink"),copyRoomId:o("agentRoom.sidebar.copyRoomId")},handlers:{onOpen:()=>{h(),i(s)},onFavorite:()=>{h(),t(s.id,!Pg(s))},onArchive:g,onCopyLink:()=>{h(),rf({text:cOe(s.id),messageApi:a,successMessage:o("agentRoom.sidebar.roomLinkCopied"),failureMessage:o("common.copyFailed")})},onCopyId:()=>{h(),rf({text:s.id,messageApi:a,successMessage:o("agentRoom.sidebar.roomIdCopied"),failureMessage:o("common.copyFailed")})}}});return v.jsx(Wo,{trigger:r,open:l,onOpenChange:p=>{c(p),p||u(null)},popupRender:()=>v.jsx(lOe,{entries:m,pendingAction:d,onCancelConfirm:()=>u(null)}),children:n})}function kbt({isTouchInteraction:n,onArchive:e,onFavorite:t,onSelect:i,room:s,showCompactActionMenu:r}){const{t:o}=ht(),a=C.useRef(null),[l,c]=C.useState(null),d=m=>n?void 0:m;C.useEffect(()=>{if(l==null)return;const m=p=>{var b;const _=p.target;if(!(_ instanceof Node)){c(null);return}(b=a.current)!=null&&b.contains(_)||c(null)};return document.addEventListener("pointerdown",m,!0),()=>{document.removeEventListener("pointerdown",m,!0)}},[l]);const u=bv(s)?o("agentRoom.sidebar.unarchiveRoom"):o("agentRoom.sidebar.archiveRoom"),h=o("common.confirmAction",{action:u}),f=()=>{if(l==="archive"){c(null),e(s.id,!bv(s));return}c("archive")},g=v.jsx(dOe,{room:s,trigger:["click"],onArchive:e,onFavorite:t,onSelect:i,children:v.jsx(qe,{type:"text",size:"small",className:"room-item__action-btn room-item__action-btn--more",title:o("common.moreActions"),"aria-label":o("common.moreActions"),onClick:m=>{m.stopPropagation()},icon:v.jsx("span",{className:"material-symbols-rounded",children:"more_horiz"})})});return r?v.jsx("div",{ref:a,className:"room-item__actions",children:g}):v.jsxs("div",{ref:a,className:"room-item__actions",onMouseLeave:()=>c(null),children:[v.jsx(Qe,{title:d(Pg(s)?o("agentRoom.sidebar.unfavoriteRoom"):o("agentRoom.sidebar.favoriteRoom")),children:v.jsx(qe,{type:"text",size:"small",className:`room-item__action-btn room-item__action-btn--favorite ${Pg(s)?"is-favorited":""}`,onClick:m=>{m.stopPropagation(),c(null),t(s.id,!Pg(s))},icon:v.jsx("span",{className:"material-symbols-rounded",children:"star"})})}),v.jsx(Qe,{title:d(l==="archive"?h:u),children:v.jsxs(qe,{type:"text",size:"small",className:`room-item__action-btn room-item__action-btn--archive ${l==="archive"?"is-confirming":""}`,onClick:m=>{m.stopPropagation(),f()},children:[v.jsx("span",{className:"material-symbols-rounded",children:bv(s)?"unarchive":"archive"}),l==="archive"&&v.jsx("span",{className:"room-item__action-label",children:h})]})})]})}nf.extend(oOe);function Ebt({isActive:n,isCompactLayout:e,isTouchInteraction:t,onArchive:i,onFavorite:s,onSelect:r,room:o}){const{t:a,i18n:l}=ht(),c=e||t,d=g=>t?void 0:g,u=C.useMemo(()=>{const g=nf(o.updatedAt??o.createdAt);return l.language==="zh"?g.locale("zh-cn"):g.locale("en"),{relative:g.fromNow(),full:g.format("YYYY-MM-DD HH:mm:ss")}},[l.language,o.createdAt,o.updatedAt]),h=C.useMemo(()=>o.lastMessage==null||o.lastMessage===""?null:o.lastMessage.length>60?`${o.lastMessage.slice(0,60)}...`:o.lastMessage,[o.lastMessage]),f=v.jsx(Wc.Item,{onClick:()=>r(o),className:`room-item ${n?"active":""} ${Pg(o)?"room-item--favorited":""} ${e?"room-item--compact":""} ${c?"room-item--touch":""}`,children:v.jsxs("div",{className:"room-item__content",children:[v.jsx("div",{className:`room-item__leading room-item__leading--${o.status}`,children:v.jsx(aOe,{className:"room-item__avatar",seed:o.id})}),v.jsxs("div",{className:"room-item__info",children:[v.jsxs("div",{className:"room-item__header",children:[v.jsxs("div",{className:"room-item__title",children:[v.jsx("span",{className:"room-item__title-text",children:o.title}),Pg(o)&&v.jsx("span",{className:"material-symbols-rounded room-item__favorite-icon","aria-label":a("agentRoom.sidebar.favoritedRoom"),title:a("agentRoom.sidebar.favoritedRoom"),children:"star"})]}),v.jsxs("div",{className:"room-item__header-side",children:[!e&&v.jsx(Qe,{title:d(u.full),children:v.jsx("span",{className:"room-item__time",children:u.relative})}),v.jsx(kbt,{room:o,isTouchInteraction:t,showCompactActionMenu:c,onArchive:i,onFavorite:s,onSelect:r})]})]}),!e&&h!=null&&v.jsx("div",{className:"room-item__last-message",children:h})]})]})});return v.jsx(dOe,{room:o,onArchive:i,onFavorite:s,onSelect:r,children:f})}function uOe({as:n="list-item",className:e,contentRef:t,dataSessionCardSource:i,dataSessionId:s,headerSide:r,infoClassName:o,lastMessage:a,leading:l,onClick:c,onDoubleClick:d,onMouseLeave:u,style:h,tags:f,title:g}){const m=v.jsxs("div",{ref:t,className:"session-item-content",children:[l,v.jsxs("div",{className:`session-info ${o??""}`.trim(),children:[v.jsxs("div",{className:"session-header",children:[v.jsx("div",{className:"session-title",children:g}),r!=null&&v.jsx("div",{className:"session-header-side",children:r})]}),a,f]})]});return n==="article"?v.jsx("article",{className:e,"data-session-card-source":i,"data-session-id":s,onClick:c,onDoubleClick:d,onMouseLeave:u,style:h,children:m}):v.jsx(Wc.Item,{className:e,"data-session-card-source":i,"data-session-id":s,onClick:c,onDoubleClick:d,onMouseLeave:u,style:h,children:m})}const Ibt=n=>`${qW()}/session/${n}`,Qw=(n,e)=>{const t=e==null?void 0:e.trim();return t!=null&&t!==""?`message-${n}-${t}`:`message-${n}`},hOe=(n,e)=>{const t=new URL(globalThis.location.origin);return t.pathname=Ibt(n),t.search="",t.hash=(e==null?void 0:e.anchorId)!=null&&e.anchorId!==""?`#${e.anchorId}`:"",t.toString()};function g8e({children:n,session:e,trigger:t=["contextMenu"],onArchive:i,onDelete:s,onRename:r,onStar:o}){const{t:a}=ht(),{message:l,modal:c}=Vs.useApp(),[d,u]=C.useState(!1),[h,f]=C.useState(null),g=()=>{u(!1),f(null)},m=_=>{if(h===_){if(g(),_==="archive"){i(e.id);return}s(e.id);return}f(_)},p=C.useMemo(()=>[{key:"star",label:e.isStarred?a("common.unstar"):a("common.star"),icon:e.isStarred?"star":"star_border",onClick:()=>{g(),o(e.id,!e.isStarred)}},{key:"rename",label:a("common.rename"),icon:"edit",onClick:()=>{g();let _=e.title??"";c.confirm({title:a("common.renameSession"),okText:a("common.confirm"),cancelText:a("common.cancel"),content:v.jsx(yn,{autoFocus:!0,defaultValue:e.title??"",placeholder:a("chat.enterTitle"),onChange:b=>{_=b.target.value}}),onOk:async()=>{const b=_.trim();if(b!==(e.title??"").trim())try{await r(e.id,b),l.success(a("chat.titleUpdated"))}catch{throw l.error(a("common.operationFailed")),new Error("rename-session-failed")}}})}},{key:"archive",label:e.isArchived?a("common.restore"):a("common.archive"),confirmLabel:a("common.confirmAction",{action:e.isArchived?a("common.restore"):a("common.archive")}),icon:e.isArchived?"unarchive":"archive",onClick:()=>{m("archive")}},{key:"delete",label:a("common.delete"),confirmLabel:a("common.confirmAction",{action:a("common.delete")}),icon:"delete",danger:!0,onClick:()=>{m("delete")}},{key:"divider-main",type:"divider",label:"",icon:"",onClick:()=>{}},{key:"copy-session-link",label:a("common.copySessionLink"),icon:"link",onClick:()=>{g(),rf({text:hOe(e.id),messageApi:l,successMessage:a("common.sessionLinkCopied"),failureMessage:a("common.copyFailed")})}},{key:"copy-session-id",label:a("common.copySessionId"),icon:"fingerprint",onClick:()=>{g(),rf({text:e.id,messageApi:l,successMessage:a("common.sessionIdCopied"),failureMessage:a("common.copyFailed")})}},{key:"copy-resume-command",label:a("common.copyResumeCommand"),icon:"terminal",onClick:()=>{g(),rf({text:`vf --resume ${e.id}`,messageApi:l,successMessage:a("common.resumeCommandCopied"),failureMessage:a("common.copyFailed")})}}],[l,c,i,s,r,o,h,e,a]);return v.jsx(Wo,{trigger:t,open:d,onOpenChange:_=>{u(_),_||f(null)},popupRender:()=>v.jsx(lOe,{entries:p,pendingAction:h,onCancelConfirm:()=>f(null)}),children:n})}nf.extend(oOe);function Mbt({session:n,isActive:e,isBatchMode:t,isCompactLayout:i,isSelected:s,isTouchInteraction:r,onSelect:o,onArchive:a,onDelete:l,onRename:c,onStar:d,onToggleSelect:u}){const{t:h,i18n:f}=ht(),g="automation:",m=C.useRef(null),[p,_]=C.useState(null),b=i||r,y=A=>r?void 0:A;C.useEffect(()=>{if(p==null)return;const A=O=>{var $;const F=O.target;if(!(F instanceof Node)){_(null);return}($=m.current)!=null&&$.contains(F)||_(null)};return document.addEventListener("pointerdown",A,!0),()=>{document.removeEventListener("pointerdown",A,!0)}},[p]);const w=C.useMemo(()=>{const A=nf(n.createdAt);return f.language==="zh"?A.locale("zh-cn"):A.locale("en"),{relative:A.fromNow(),full:A.format("YYYY-MM-DD HH:mm:ss")}},[n.createdAt,f.language]),S=n.isArchived?h("common.restore"):h("common.archive"),x=h("common.confirmAction",{action:S}),L=n.tags??[],E=i?L.slice(0,1):L,I=Math.max(L.length-E.length,0),M=n.title!=null&&n.title!==""?n.title:n.lastUserMessage!=null&&n.lastUserMessage!==""?n.lastUserMessage:h("common.newChat"),N=n.adapter!=null&&n.adapter!==""?tw(n.adapter):void 0,T=C.useMemo(()=>n.lastMessage==null||n.lastMessage===""?null:n.lastMessage.length>60?`${n.lastMessage.slice(0,60)}...`:n.lastMessage,[n.lastMessage]),D=C.useMemo(()=>A=>{if(!A.startsWith(g))return null;const O=A.split(":");return O.length<3?null:{ruleId:O[1],ruleTitle:O.slice(2).join(":")}},[g]),P=A=>{if(!A)return v.jsx("div",{className:`status-dot ${e?"active":""}`});let O="",F="";const $=h(`common.status.${A}`);switch(A){case"completed":O="check_circle",F="#52c41a";break;case"terminated":O="remove_circle",F="#bfbfbf";break;case"failed":O="cancel",F="#ff4d4f";break;case"running":O="sync",F="#1890ff";break;case"waiting_input":return v.jsx(Qe,{title:y($),children:v.jsx("div",{className:"waiting-input-indicator"})});default:return v.jsx("div",{className:`status-dot ${e?"active":""}`})}return v.jsx(Qe,{title:y($),children:v.jsx("span",{className:`material-symbols-rounded status-icon ${A==="running"?"spin":""}`,style:{color:F,fontSize:"16px",lineHeight:"16px",display:"flex",alignItems:"center",justifyContent:"center"},children:O})})},R=A=>{if(p===A){_(null),a(n.id);return}_(A)};return v.jsx(g8e,{session:n,onArchive:a,onDelete:l,onRename:c,onStar:d,children:v.jsx(uOe,{onClick:()=>t?u(n.id):o(n),onMouseLeave:()=>_(null),onDoubleClick:()=>{console.log("Session Details:",n)},className:`session-item ${e?"active":""} ${s?"selected":""} ${n.isStarred?"starred":""} ${i?"session-item--compact":""} ${b?"session-item--touch":""}`,contentRef:m,leading:v.jsxs("div",{className:`session-leading ${(N==null?void 0:N.icon)!=null?"has-adapter":""}`,children:[(N==null?void 0:N.icon)!=null&&v.jsx("img",{className:"session-adapter-icon",src:N.icon,alt:"","aria-hidden":"true"}),v.jsx("div",{className:`status-indicator ${(N==null?void 0:N.icon)!=null?"is-overlay":""}`,children:P(n.status)})]}),title:v.jsx("span",{className:"session-title-text",children:M}),headerSide:!t&&v.jsxs(v.Fragment,{children:[!i&&v.jsx(Qe,{title:y(w.full),children:v.jsx("span",{className:"time-display",children:w.relative})}),b?v.jsx(g8e,{session:n,trigger:["click"],onArchive:a,onDelete:l,onRename:c,onStar:d,children:v.jsx(qe,{type:"text",size:"small",className:"action-btn action-btn--more",title:h("common.moreActions"),"aria-label":h("common.moreActions"),onClick:A=>{A.stopPropagation()},icon:v.jsx("span",{className:"material-symbols-rounded",children:"more_horiz"})})}):v.jsxs("div",{className:"session-item-actions",children:[v.jsx(Qe,{title:y(n.isStarred?h("common.unstar"):h("common.star")),children:v.jsx(qe,{type:"text",size:"small",className:`action-btn star-btn ${n.isStarred?"starred":""}`,onClick:A=>{A.stopPropagation(),_(null),d(n.id,!n.isStarred)},icon:v.jsx("span",{className:`material-symbols-rounded ${n.isStarred?"filled":""}`,children:"star"})})}),v.jsx(Qe,{title:y(p==="archive"?x:S),children:v.jsxs(qe,{type:"text",size:"small",className:`action-btn archive-btn ${p==="archive"?"is-confirming":""}`,onClick:A=>{A.stopPropagation(),R("archive")},children:[v.jsx("span",{className:"material-symbols-rounded",children:n.isArchived?"unarchive":"archive"}),p==="archive"&&v.jsx("span",{className:"action-btn__label",children:x})]})})]})]}),infoClassName:t?"":"with-actions",lastMessage:!i&&T!=null&&v.jsx("div",{className:"last-message",children:T}),tags:E.length>0&&v.jsxs("div",{className:"tags-container",children:[E.map(A=>{const O=D(A);if(O){const F=`/automation?rule=${encodeURIComponent(O.ruleId)}`;return v.jsx(Qe,{title:y(O.ruleTitle),children:v.jsx(Ml,{className:"session-tag session-tag--automation",onClick:$=>$.stopPropagation(),children:v.jsx("a",{className:"session-tag__link",href:F,onClick:$=>$.stopPropagation(),children:O.ruleTitle})})},A)}return v.jsx(Qe,{title:y(A),children:v.jsx(Ml,{className:"session-tag",children:v.jsx("span",{className:"session-tag__text",children:A})})},A)}),I>0&&v.jsxs(Ml,{className:"session-tag session-tag--count",children:["+",I]})]})})})}const Nbt="room:",IO=n=>`${Nbt}${n}`,Dbt=(n,e)=>{const t=(e==null?void 0:e.runs.map(i=>i.sessionId))??[];return{...n,activeRunCount:(e==null?void 0:e.members.reduce((i,s)=>i+s.activeRunCount,0))??0,pendingCount:(e==null?void 0:e.members.reduce((i,s)=>i+s.pendingCount,0))??0,sessionIds:[...n.hostSessionId!=null?[n.hostSessionId]:[],...t]}},MO=n=>n.createdAt??0,m8e=n=>n.updatedAt??n.createdAt??0,p8e=n=>n.kind==="room"?n.room.favoritedAt!=null:n.session.isStarred===!0,Tbt=(n,e,t)=>{const i=Number(p8e(e))-Number(p8e(n));if(i!==0)return i;const s=n.kind==="room"?m8e(n.room):MO(n.session),r=e.kind==="room"?m8e(e.room):MO(e.session),o=s-r;return t==="asc"?o:-o};function Rbt({collapsedIds:n,rooms:e,sessions:t,sortOrder:i}){const s=new Set(e.flatMap(h=>h.sessionIds)),r=t.filter(h=>!s.has(h.id)),o=new Map(r.map(h=>[h.id,h])),a=new Map;for(const h of r)if(h.parentSessionId){const f=a.get(h.parentSessionId)??[];f.push(h),a.set(h.parentSessionId,f)}const l=r.filter(h=>h.parentSessionId?!o.has(h.parentSessionId):!0).map(h=>({id:h.id,kind:"session",session:h,depth:0,hasChildren:(a.get(h.id)??[]).length>0}));l.push(...e.map(h=>({id:IO(h.id),kind:"room",room:h,depth:0,hasChildren:!1}))),l.sort((h,f)=>Tbt(h,f,i));const c=[],d=new Set,u=(h,f)=>{if(d.has(h.id))return;d.add(h.id);const g=a.get(h.id)??[];if(c.push({id:h.id,kind:"session",session:h,depth:f,hasChildren:g.length>0}),n.has(h.id))return;const m=[...g].sort((p,_)=>MO(_)-MO(p));for(const p of m)u(p,f+1)};for(const h of l)h.kind==="room"?c.push(h):u(h.session,0);return c}function Pbt({sessions:n,rooms:e=[],activeId:t,hasActiveFilters:i,isBatchMode:s,isCompactLayout:r,selectedIds:o,isTouchInteraction:a,sortOrder:l,searchQuery:c,onArchiveRoom:d,onFavoriteRoom:u,onSelectRoom:h,onSelectSession:f,onArchiveSession:g,onDeleteSession:m,onRenameSession:p,onStarSession:_,onToggleSelect:b}){const{t:y}=ht(),[w,S]=C.useState(new Set),{conversationItems:x,childSummaryMap:L}=C.useMemo(()=>{const I=new Map;for(const N of n)if(N.parentSessionId){const T=I.get(N.parentSessionId)??[];T.push(N),I.set(N.parentSessionId,T)}const M=new Map;for(const[N,T]of I.entries()){const D=T.length,P=new Map;for(const A of T){const O=A.status??"running";P.set(O,(P.get(O)??0)+1)}const R=[y("common.childSummary",{count:D})];for(const[A,O]of P.entries())R.push(y("common.childStatusItem",{count:O,status:y(`common.status.${A}`)}));M.set(N,R.join(" · "))}return{conversationItems:Rbt({collapsedIds:w,rooms:e,sessions:n,sortOrder:l}),childSummaryMap:M}},[n,w,e,l,y]),E=I=>{S(M=>{const N=new Set(M);return N.has(I)?N.delete(I):N.add(I),N})};return v.jsx("div",{className:"session-list-container",children:v.jsx("div",{className:"session-list-scroll",children:v.jsx(Wc,{className:"session-list",size:"small",locale:{emptyText:v.jsx("div",{className:"empty-text",children:y(c||i?"common.noSessions":"common.startNewChat")})},dataSource:x,renderItem:I=>I.kind==="room"?v.jsx("div",{className:"session-row session-row--room",children:v.jsx("div",{className:"session-row-main",children:v.jsx(Ebt,{room:I.room,isActive:t===IO(I.room.id),isCompactLayout:r,isTouchInteraction:a,onArchive:d,onFavorite:u,onSelect:h})})}):v.jsxs("div",{className:`session-row ${I.depth>0?"has-parent":""}`,style:{"--session-depth":I.depth},children:[v.jsxs("div",{className:"session-row-main",children:[s&&v.jsx("div",{className:"session-select-toggle",onClick:M=>M.stopPropagation(),children:v.jsx(P1,{checked:o.has(I.session.id),onChange:()=>b(I.session.id)})}),v.jsx(Mbt,{session:I.session,isActive:t===I.session.id,isBatchMode:s,isCompactLayout:r,isSelected:o.has(I.session.id),isTouchInteraction:a,onSelect:f,onArchive:g,onDelete:m,onRename:p,onStar:_,onToggleSelect:b})]}),I.hasChildren&&!s&&v.jsxs("div",{className:"session-collapse-row",style:{"--session-depth":I.depth},onClick:M=>M.stopPropagation(),children:[v.jsx(qe,{type:"text",size:"small",className:`session-tree-toggle ${w.has(I.session.id)?"collapsed":""}`,onClick:()=>E(I.session.id),icon:v.jsx("span",{className:"material-symbols-rounded",children:"chevron_right"})}),v.jsx("span",{className:"session-collapse-label",children:w.has(I.session.id)?y("common.expandChildren"):y("common.collapseChildren")}),v.jsx("span",{className:"session-collapse-summary",children:L.get(I.session.id)??y("common.childSummary",{count:0})})]})]})})})})}function Abt({isAllSelected:n,selectedCount:e,totalCount:t,onBatchArchive:i,onBatchDelete:s,onBatchStar:r,onSelectAll:o}){const{t:a}=ht(),{isTouchInteraction:l}=Mr(),c=d=>l?void 0:d;return v.jsxs("div",{className:"header-batch-actions",children:[v.jsx(Qe,{title:c(a(n?"common.deselectAll":"common.selectAll")),children:v.jsx("label",{className:"batch-select-toggle",children:v.jsx(P1,{checked:n,indeterminate:e>0&&e<t,onChange:d=>o(d.target.checked)})})}),v.jsx(Qe,{title:c(a("common.star")),children:v.jsx(qe,{className:"sidebar-tool-btn is-icon-only",type:"text",disabled:e===0,onClick:r,icon:v.jsx("span",{className:"material-symbols-rounded",children:"star"})})}),v.jsx(Cm,{title:a("common.archiveConfirm",{count:e}),onConfirm:i,okText:a("common.confirm"),cancelText:a("common.cancel"),okButtonProps:{danger:!1},disabled:e===0,children:v.jsx(Qe,{title:c(a("common.archive")),children:v.jsx(qe,{className:"sidebar-tool-btn is-icon-only",type:"text",disabled:e===0,icon:v.jsx("span",{className:"material-symbols-rounded",children:"archive"})})})}),v.jsx(Cm,{title:a("common.deleteConfirm",{count:e}),onConfirm:s,okText:a("common.confirm"),cancelText:a("common.cancel"),okButtonProps:{danger:!0},disabled:e===0,children:v.jsx(Qe,{title:c(a("common.delete")),children:v.jsx(qe,{className:"sidebar-tool-btn is-icon-only is-danger",type:"text",disabled:e===0,icon:v.jsx("span",{className:"material-symbols-rounded",children:"delete"})})})})]})}function iq({className:n,icon:e,...t}){return v.jsxs("div",{className:"toolbar-filter-control",children:[v.jsx("span",{className:"material-symbols-rounded toolbar-filter-icon",children:e}),v.jsx(ms,{className:n==null||n===""?"toolbar-filter-select":`toolbar-filter-select ${n}`,...t})]})}function Obt({adapterFilters:n,availableAdapters:e,availableTags:t,hasActiveSearchControls:i,isBatchMode:s,searchQuery:r,selectedCount:o,shouldShowSearchActions:a,sortOrder:l,sortSelection:c,tagFilters:d,totalCount:u,onAdapterFilterChange:h,onBatchArchive:f,onBatchDelete:g,onBatchStar:m,onSearchChange:p,onSortOrderChange:_,onSelectAll:b,onTagFilterChange:y,onToggleBatchMode:w,onToggleSearchActions:S}){const{t:x}=ht(),{isTouchInteraction:L}=Mr(),E=u>0&&o===u,I=C.useMemo(()=>D=>D.map(P=>({label:P,value:P})),[]),M=v.jsx("span",{className:"material-symbols-rounded toolbar-filter-chevron",children:"expand_more"}),N=D=>L?void 0:D,T=C.useMemo(()=>[{label:x("automation.sortDesc"),value:"desc"},{label:x("automation.sortAsc"),value:"asc"}],[x]);return v.jsxs(v.Fragment,{children:[v.jsx(eOe,{className:"search-input",placeholder:x("common.search"),value:r,onChange:D=>p(D.target.value),suffix:v.jsx(Qe,{title:N(x("common.searchActions")),children:v.jsx("button",{type:"button",className:`search-toggle-button ${a?"is-open":""} ${i?"has-active-filters":""}`,"aria-label":x("common.searchActions"),onMouseDown:D=>D.preventDefault(),onClick:S,children:v.jsx("span",{className:"material-symbols-rounded search-chevron",children:"expand_more"})})}),allowClear:!0}),v.jsx("div",{className:`header-search-actions ${a?"is-open":""}`,children:v.jsxs("div",{className:"header-search-actions-inner",children:[v.jsxs("div",{className:"header-toolbar-row",children:[v.jsx("div",{className:"header-toolbar-leading",children:s?v.jsx(Qe,{title:N(x("common.cancelBatch")),children:v.jsx(qe,{className:"sidebar-tool-btn is-icon-only",type:"text",onClick:w,icon:v.jsx("span",{className:"material-symbols-rounded",children:"close"})})}):v.jsx(Qe,{title:N(x("common.batchMode")),children:v.jsx(qe,{className:"sidebar-tool-btn is-icon-only",type:"text",onClick:w,icon:v.jsx("span",{className:"material-symbols-rounded",children:"checklist"})})})}),v.jsxs("div",{className:"header-filter-stack",children:[v.jsx(iq,{icon:"sell",mode:"tags",placeholder:x("common.allTags"),options:I(t),value:d,onChange:D=>y(D),maxTagCount:1,allowClear:!0,suffixIcon:M,tokenSeparators:[","]}),v.jsx(iq,{icon:"extension",mode:"tags",placeholder:x("common.allAdapters"),options:I(e),value:n,onChange:D=>h(D),maxTagCount:1,allowClear:!0,suffixIcon:M,tokenSeparators:[","]}),v.jsx(iq,{icon:"swap_vert",placeholder:x("common.sort"),options:T,value:c,onChange:D=>_(D),allowClear:!0,suffixIcon:M})]})]}),s&&v.jsx(Abt,{isAllSelected:E,selectedCount:o,totalCount:u,onBatchArchive:f,onBatchDelete:g,onBatchStar:m,onSelectAll:b})]})})]})}const Fbt=({hasActiveSearchControls:n,isBatchMode:e,isSearchActionsOpen:t,sessionCount:i,threshold:s})=>s<=0||n||e||t?!0:i>s;function Bbt({adapterFilters:n,availableAdapters:e,availableTags:t,createButtonRef:i,hasActiveSearchControls:s,isBatchMode:r,isCompactLayout:o,isCreatingSession:a,isSidebarCollapsed:l,searchQuery:c,selectedCount:d,sessionCount:u,sortOrder:h,sortSelection:f,shortcutLabel:g,tagFilters:m,totalCount:p,onBatchArchive:_,onBatchDelete:b,onBatchStar:y,onAdapterFilterChange:w,onCloseSidebar:S,onCreateSession:x,onSearchChange:L,onSortOrderChange:E,onSelectAll:I,onTagFilterChange:M,onToggleBatchMode:N,onToggleSidebarCollapsed:T}){const{t:D}=ht(),{isTouchInteraction:P}=Mr(),R=Su(zAe),[A,O]=C.useState(!1),F=!l&&(A||r),$=!l&&Fbt({hasActiveSearchControls:s,isBatchMode:r,isSearchActionsOpen:A,sessionCount:u,threshold:R}),B=l?v.jsx(Qe,{title:P?void 0:D(a?"common.alreadyInNewChat":"common.newChat"),placement:"right",children:v.jsx(qe,{className:`sidebar-list-header__icon-action sidebar-new-chat-btn ${a?"active":""}`,type:"text",disabled:!!a,onClick:x,children:v.jsx("span",{className:`material-symbols-rounded ${a?"filled":""}`,children:a?"chat_bubble":"send"})})}):v.jsxs(qe,{ref:i,className:`sidebar-list-header__primary-action new-chat-btn ${a?"active":""}`,type:a?"default":"primary",block:!0,disabled:!!a,onClick:x,children:[v.jsxs("span",{className:"sidebar-list-header__button-content btn-content",children:[v.jsx("span",{className:`material-symbols-rounded ${a?"filled":""}`,children:a?"chat_bubble":"send"}),v.jsx("span",{children:D(a?"common.creatingChat":"common.newChat")})]}),v.jsx("span",{className:"sidebar-list-header__shortcut shortcut-tag",children:g})]}),V=v.jsx(Qe,{title:P?void 0:D(o?"common.close":l?"common.expand":"common.collapse"),children:v.jsx(qe,{className:"sidebar-list-header__icon-action sidebar-collapse-btn",type:"text","aria-label":D(o?"common.close":l?"common.expand":"common.collapse"),onClick:o?S:T,children:v.jsx("span",{className:"material-symbols-rounded",children:o?"close":l?"dock_to_right":"left_panel_close"})})}),W=$?v.jsx(Obt,{adapterFilters:n,availableAdapters:e,availableTags:t,hasActiveSearchControls:s,isBatchMode:r,searchQuery:c,selectedCount:d,shouldShowSearchActions:F,sortOrder:h,sortSelection:f,tagFilters:m,totalCount:p,onBatchArchive:_,onBatchDelete:b,onBatchStar:y,onAdapterFilterChange:w,onSearchChange:L,onSortOrderChange:E,onSelectAll:I,onTagFilterChange:M,onToggleBatchMode:N,onToggleSearchActions:()=>O(H=>!H)}):null;return v.jsx(QAe,{className:"sidebar-header",compact:o,collapsed:l,primaryAction:B,sideAction:V,children:W})}const $bt=n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),Hbt=n=>new RegExp(`^${$bt(n).replace(/\\\*/g,".*")}$`,"i"),Vbt=(n,e)=>{const t=n.trim(),i=e.trim();return t===""||i===""?!1:i.includes("*")?Hbt(i).test(t):t.toLowerCase().includes(i.toLowerCase())},C8e=(n,e)=>e.length===0?!0:e.some(t=>n.some(i=>Vbt(i,t)));async function jbt({mutateRooms:n,request:e,roomId:t,updateMetadata:i=Iee}){await i(t,e),await n()}const Wbt=(n,e)=>[...n].sort((t,i)=>{const s=+(i.isStarred===!0)-+(t.isStarred===!0);if(s!==0)return s;const r=(t.createdAt??0)-(i.createdAt??0);return e==="asc"?r:-r});function _8e({activeId:n,isCompactLayout:e=!1,isMobileOpen:t=!1,onRequestClose:i,onSelectRoom:s,onSelectSession:r,onDeletedSession:o,width:a}){var Ke,ze,Ve;const{adapterFilters:l,hasActiveFilterConditions:c,hasActiveSearchControls:d,isSidebarCollapsed:u,searchQuery:h,setSortOrder:f,setAdapterFilters:g,setSearchQuery:m,setSidebarCollapsed:p,setTagFilters:_,sortOrder:b,sortSelection:y,tagFilters:w}=tOe(),S=Su(RAe),[x,L]=C.useState(!1),[E,I]=C.useState(new Set),{t:M}=ht(),{isTouchInteraction:N}=Mr(),T=navigator.platform.includes("Mac"),D=Su(Fb),P=KM(Fb),{data:R,mutate:A}=Gn("/api/sessions"),{data:O,mutate:F}=Gn("/api/agent-rooms",UAe,{refreshInterval:3e3,revalidateOnFocus:!0}),$=O==null?void 0:O.rooms.map(Ne=>Ne.id).sort().join("|"),{data:B}=Gn($==null||$===""?null:["agent-room-details",$],()=>Promise.all(((O==null?void 0:O.rooms)??[]).map(Ne=>X3e(Ne.id))),{refreshInterval:3e3,revalidateOnFocus:!0}),V=C.useMemo(()=>Gvt((R==null?void 0:R.sessions)??[],D),[D,R==null?void 0:R.sessions]),W=C.useMemo(()=>{const Ne=new Map((B??[]).map(Ie=>[Ie.room.id,Ie]));return((O==null?void 0:O.rooms)??[]).map(Ie=>Dbt(Ie,Ne.get(Ie.id)))},[B,O==null?void 0:O.rooms]),{data:H}=Gn("/api/config"),U=(Ve=(ze=(Ke=H==null?void 0:H.sources)==null?void 0:Ke.merged)==null?void 0:ze.shortcuts)==null?void 0:Ve.newSession,Z=U!=null&&U.trim()!==""?U:"mod+k",G=C.useMemo(()=>nhe(Z,T),[Z,T]),q=C.useMemo(()=>Array.from(new Set(V.flatMap(Ne=>(Ne.tags??[]).map(Ie=>Ie.trim()).filter(Boolean)))).sort((Ne,Ie)=>Ne.localeCompare(Ie)),[V]),K=C.useMemo(()=>Array.from(new Set(V.map(Ne=>{var Ie;return((Ie=Ne.adapter)==null?void 0:Ie.trim())??""}).filter(Boolean))).sort((Ne,Ie)=>Ne.localeCompare(Ie)),[V]),X=C.useMemo(()=>{const Ne=h.trim().toLowerCase(),Ie=V.filter(Ge=>{if(!C8e(Ge.tags??[],w))return!1;const Fe=[Ge.adapter??"",Ge.adapter!=null&&Ge.adapter!==""?tw(Ge.adapter).title:""].filter(Boolean);return C8e(Fe,l)?Ne?(Ge.title??"").toLowerCase().includes(Ne)||(Ge.lastMessage??"").toLowerCase().includes(Ne)||(Ge.lastUserMessage??"").toLowerCase().includes(Ne)||Ge.id.toLowerCase().includes(Ne)||(Ge.tags??[]).some(Re=>Re.toLowerCase().includes(Ne))||Fe.some(Re=>Re.toLowerCase().includes(Ne)):!0:!1});return Wbt(Ie,b)},[l,h,V,b,w]),ie=C.useMemo(()=>{if(l.length>0||w.length>0)return[];const Ne=h.trim().toLowerCase();return W.filter(Ie=>Ne?Ie.title.toLowerCase().includes(Ne)||Ie.id.toLowerCase().includes(Ne)||(Ie.lastMessage??"").toLowerCase().includes(Ne):!0)},[l,W,h,w]);async function se(){i==null||i(),r({id:""},!0)}function J(Ne){Wvt(Ne),P(Ie=>{if(Ie[Ne]==null)return Ie;const Ge={...Ie};return delete Ge[Ne],Ge}),A(Ie=>(Ie==null?void 0:Ie.sessions)==null?Ie:{...Ie,sessions:Mee(Ie.sessions,Ne)},!1)}async function le(Ne){let Ie;const Ge=V.findIndex(Fe=>Fe.id===Ne);if(Ge!==-1&&(Ge+1<V.length?Ie=V[Ge+1].id:Ge-1>=0&&(Ie=V[Ge-1].id)),D[Ne]!=null){J(Ne),n===Ne&&(o==null||o(Ne,Ie));return}try{await f1(Ne,{isArchived:!0}),await A(),o==null||o(Ne,Ie)}catch(Fe){console.error("Failed to archive session:",Fe)}}async function be(Ne){let Ie;const Ge=V.findIndex(Fe=>Fe.id===Ne);if(Ge!==-1&&(Ge+1<V.length?Ie=V[Ge+1].id:Ge-1>=0&&(Ie=V[Ge-1].id)),D[Ne]!=null){J(Ne),n===Ne&&(o==null||o(Ne,Ie));return}try{await Ob(Ne),await A(),n===Ne&&(o==null||o(Ne,Ie))}catch(Fe){console.error("Failed to delete session:",Fe)}}async function ae(Ne,Ie){if(D[Ne]!=null){P(Ge=>{const Fe=Ge[Ne];return Fe==null?Ge:{...Ge,[Ne]:{...Fe,session:{...Fe.session,isStarred:Ie}}}});return}try{await f1(Ne,{isStarred:Ie}),await A()}catch(Ge){console.error("Failed to star session:",Ge)}}async function ce(Ne,Ie){try{await jbt({roomId:Ne,request:Ie,mutateRooms:F})}catch(Ge){console.error("Failed to update room metadata:",Ge)}}async function oe(Ne,Ie){await ce(Ne,{isArchived:Ie})}async function he(Ne,Ie){await ce(Ne,{isFavorited:Ie})}async function ye(Ne,Ie){if(D[Ne]!=null){P(Ge=>{const Fe=Ge[Ne];return Fe==null?Ge:{...Ge,[Ne]:{...Fe,session:{...Fe.session,title:Ie}}}});return}await Evt(Ne,Ie),await A()}const ke=Ne=>{I(Ie=>{const Ge=new Set(Ie);return Ge.has(Ne)?Ge.delete(Ne):Ge.add(Ne),Ge})},Ce=Ne=>{I(Ne?new Set(X.map(Ie=>Ie.id)):new Set)},Se=async()=>{try{if(await Promise.all(Array.from(E).map(async Ne=>f1(Ne,{isArchived:!0}))),await A(),n&&E.has(n)){let Ne;const Ie=V.find(Ge=>!E.has(Ge.id));Ie&&(Ne=Ie.id),o==null||o(n,Ne)}I(new Set),L(!1)}catch(Ne){console.error("Failed to batch archive sessions:",Ne)}},we=async()=>{try{if(await Promise.all(Array.from(E).map(async Ne=>Ob(Ne))),await A(),n&&E.has(n)){const Ne=V.find(Ie=>!E.has(Ie.id));o==null||o(n,Ne==null?void 0:Ne.id)}I(new Set),L(!1)}catch(Ne){console.error("Failed to batch delete sessions:",Ne)}},ve=async Ne=>{try{await Promise.all(Array.from(E).map(async Ie=>f1(Ie,{isStarred:Ne}))),await A()}catch(Ie){console.error("Failed to batch update star status:",Ie)}},Ee=()=>{L(Ne=>!Ne),I(new Set)},me=n===void 0||n==="",xe=e?!1:u,Oe=Ne=>N?void 0:Ne,We=C.useRef(null);return pP({shortcut:Z,isMac:T,onTrigger:Ne=>{Ne.preventDefault(),!me&&(We.current&&(We.current.classList.add("active-scale"),setTimeout(()=>{var Ie;(Ie=We.current)==null||Ie.classList.remove("active-scale")},200)),se())}}),v.jsxs("div",{className:["sidebar-container",xe?"collapsed":"",e?"sidebar-container--compact":"",t?"is-mobile-open":""].filter(Boolean).join(" "),style:e?void 0:{width:xe?0:a,minWidth:xe?0:void 0,transition:S?"none":"width 0.3s cubic-bezier(0.4, 0, 0.2, 1)",borderRight:xe?"none":void 0},children:[v.jsxs("div",{className:"sidebar-content",style:e?void 0:{width:a,transition:S?"none":"transform 0.3s cubic-bezier(0.4, 0, 0.2, 1)",transform:xe?`translateX(-${a}px)`:"translateX(0)"},children:[v.jsx(Bbt,{adapterFilters:l,availableAdapters:K,hasActiveSearchControls:d,isCompactLayout:e,isSidebarCollapsed:xe,searchQuery:h,sortOrder:b,sortSelection:y,onSearchChange:m,availableTags:q,tagFilters:w,onSortOrderChange:f,onAdapterFilterChange:g,onTagFilterChange:_,isBatchMode:x,onToggleBatchMode:Ee,onToggleSidebarCollapsed:()=>p(!u),onCloseSidebar:i,selectedCount:E.size,sessionCount:V.length,totalCount:X.length,onSelectAll:Ce,onBatchArchive:()=>{Se()},onBatchDelete:()=>{we()},onBatchStar:()=>{ve(!0)},isCreatingSession:me,shortcutLabel:G,createButtonRef:We,onCreateSession:()=>{se()}}),v.jsx(Pbt,{hasActiveFilters:c,rooms:ie,sessions:X,activeId:n,isBatchMode:x,isCompactLayout:e,selectedIds:E,isTouchInteraction:N,sortOrder:b,searchQuery:h,onArchiveRoom:oe,onFavoriteRoom:he,onSelectRoom:s,onSelectSession:r,onArchiveSession:le,onDeleteSession:be,onRenameSession:ye,onStarSession:ae,onToggleSelect:ke})]}),!e&&u&&v.jsxs(JAe,{children:[v.jsx(kO,{buttonRef:We,active:me,disabled:!!me,filled:me,icon:me?"chat_bubble":"send",tooltip:Oe(M(me?"common.alreadyInNewChat":"common.newChat")),ariaLabel:M(me?"common.alreadyInNewChat":"common.newChat"),onClick:()=>{se()}}),v.jsx(kO,{icon:"dock_to_right",tooltip:Oe(M("common.expand")),ariaLabel:M("common.expand"),onClick:()=>p(!1)})]})]})}const zbt=22,v8e=8,sq=64,b8e=.45,y8e=360,Ubt='input,textarea,select,[contenteditable="true"],[role="textbox"]',w8e=n=>n.pointerType==="touch"||n.pointerType==="pen",S8e=n=>n instanceof HTMLElement&&n.closest(Ubt)!=null,Jw=n=>{n.style.removeProperty("--vf-mobile-sidebar-drag-x"),n.removeAttribute("data-mobile-sidebar-dragging")};function fOe({canSwipeOpen:n=!0,isCompactLayout:e,isOpen:t,setIsOpen:i,sheetRef:s}){const r=C.useRef(0);C.useEffect(()=>{if(!e||!n)return;const o=s.current;if(o==null)return;const a=l=>{Date.now()>r.current||(l.preventDefault(),l.stopPropagation())};return o.addEventListener("click",a,!0),()=>o.removeEventListener("click",a,!0)},[n,e,s]),C.useEffect(()=>{if(!e)return;let o=null;const a=()=>{o=null,window.removeEventListener("pointermove",c),window.removeEventListener("pointerup",l),window.removeEventListener("pointercancel",a)},l=()=>a(),c=u=>{if(o==null||u.pointerId!==o.pointerId)return;const h=u.clientX-o.startX,f=u.clientY-o.startY,g=Math.abs(h),m=Math.abs(f);if(g<v8e||g<=m*1.2)return;o.dragging=!0,u.cancelable&&u.preventDefault();const p=Math.max(1,u.timeStamp-o.startTime),_=h/p;(h>sq||_>b8e)&&(r.current=Date.now()+y8e,i(!0),a())},d=u=>{!w8e(u)||t||u.clientX>zbt||S8e(u.target)||(o={dragging:!1,lastX:u.clientX,pointerId:u.pointerId,startTime:u.timeStamp,startX:u.clientX,startY:u.clientY},window.addEventListener("pointermove",c,{passive:!1}),window.addEventListener("pointerup",l),window.addEventListener("pointercancel",a))};return document.addEventListener("pointerdown",d),()=>{document.removeEventListener("pointerdown",d),a()}},[n,e,t,i]),C.useEffect(()=>{if(!e||!t)return;const o=s.current;if(o==null)return;let a=null;const l=()=>{a=null,window.removeEventListener("pointermove",u),window.removeEventListener("pointerup",d),window.removeEventListener("pointercancel",c)},c=()=>{if((a==null?void 0:a.dragging)===!0&&a.lastX-a.startX<-sq){i(!1),window.setTimeout(()=>Jw(o),260),l();return}Jw(o),l()},d=f=>{if(a==null||f.pointerId!==a.pointerId)return;const g=f.clientX-a.startX,m=Math.max(1,f.timeStamp-a.startTime),p=g/m,_=g<-sq||p<-b8e,b=a.dragging;if(l(),o.removeAttribute("data-mobile-sidebar-dragging"),b&&(r.current=Date.now()+y8e),_){i(!1),window.setTimeout(()=>Jw(o),260);return}Jw(o)},u=f=>{if(a==null||f.pointerId!==a.pointerId)return;const g=f.clientX-a.startX,m=f.clientY-a.startY,p=Math.abs(g),_=Math.abs(m);if(a.lastX=f.clientX,!a.dragging){if(p<v8e||p<=_*1.2)return;a.dragging=!0,o.setAttribute("data-mobile-sidebar-dragging","true")}f.cancelable&&f.preventDefault(),o.style.setProperty("--vf-mobile-sidebar-drag-x",`${Math.round(Math.min(0,g))}px`)},h=f=>{!w8e(f)||S8e(f.target)||(a={dragging:!1,lastX:f.clientX,pointerId:f.pointerId,startTime:f.timeStamp,startX:f.clientX,startY:f.clientY},window.addEventListener("pointermove",u,{passive:!1}),window.addEventListener("pointerup",d),window.addEventListener("pointercancel",c))};return o.addEventListener("pointerdown",h),()=>{o.removeEventListener("pointerdown",h),Jw(o),l()}},[e,t,i,s])}const Kbt=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(", "),gOe=n=>Array.from(n.querySelectorAll(Kbt)).filter(e=>!e.hasAttribute("disabled")&&e.getAttribute("aria-hidden")!=="true"&&e.offsetParent!==null),g_=n=>{try{n.focus({preventScroll:!0})}catch{n.focus()}},x8e=n=>{const e=gOe(n),t=e[0];return t!=null?g_(t):g_(n),e};function ihe({backgroundRefs:n,canSwipeOpen:e,isCompactLayout:t,isMobileSidebarOpen:i,setIsMobileSidebarOpen:s,sheetRef:r}){const o=C.useRef(null);fOe({canSwipeOpen:e,isCompactLayout:t,isOpen:i,setIsOpen:s,sheetRef:r}),C.useEffect(()=>{if(!t){n.forEach(a=>{var l;(l=a.current)==null||l.removeAttribute("inert")});return}return n.forEach(a=>{const l=a.current;l!=null&&(i?l.setAttribute("inert",""):l.removeAttribute("inert"))}),()=>{n.forEach(a=>{var l;(l=a.current)==null||l.removeAttribute("inert")})}},[n,t,i]),C.useEffect(()=>{if(!t||!i)return;const a=document.activeElement;o.current=a instanceof HTMLElement?a:null;const l=window.requestAnimationFrame(()=>{const u=r.current;u!=null&&x8e(u)}),c=u=>{if(u.key==="Escape"){s(!1);return}if(u.key!=="Tab")return;const h=r.current;if(h==null)return;const f=gOe(h);if(f.length===0){u.preventDefault(),g_(h);return}const g=f[0],m=f[f.length-1],p=document.activeElement;if(u.shiftKey){(p===g||p===h)&&(u.preventDefault(),g_(m));return}p===m&&(u.preventDefault(),g_(g))},d=u=>{const h=r.current,f=u.target;h==null||!(f instanceof HTMLElement)||h.contains(f)||x8e(h)};return window.addEventListener("keydown",c),document.addEventListener("focusin",d),()=>{window.cancelAnimationFrame(l),window.removeEventListener("keydown",c),document.removeEventListener("focusin",d);const u=o.current;u!=null&&document.contains(u)&&window.requestAnimationFrame(()=>{document.contains(u)&&g_(u)}),o.current=null}},[t,i,s,r]),C.useEffect(()=>{if(!t||!i)return;const{body:a,documentElement:l}=document,c=a.style.overflow,d=l.style.overflow;return a.style.overflow="hidden",l.style.overflow="hidden",()=>{a.style.overflow=c,l.style.overflow=d}},[t,i])}const Zbt="mobile-sidebar-dialog";function qbt({activeId:n,children:e,isDarkMode:t,onDeletedSession:i,onSelectRoom:s,onSelectSession:r,showSidebar:o,sidebarWidth:a}){const{t:l}=ht(),{isSidebarCollapsed:c}=tOe(),d=E3(),{isCompactLayout:u}=Mr(),[h,f]=z9(AAe),g=KM(PAe),m=!u&&c,p=C.useRef(null),_=C.useRef(null),b=C.useRef(null),y=C.useMemo(()=>[p,_],[]);C.useEffect(()=>{g(u?!1:c)},[u,c,g]),C.useEffect(()=>{f(!1)},[u,d.pathname,f]),C.useEffect(()=>{!u||o||f(!1)},[u,f,o]),ihe({backgroundRefs:y,canSwipeOpen:o,isCompactLayout:u,isMobileSidebarOpen:h,setIsMobileSidebarOpen:f,sheetRef:b});const w=u?Math.min(a,320):a,S=["app-shell__content",o?"app-shell__content--session":"",m?"is-sidebar-collapsed":"",o?"":"is-flat"].filter(Boolean).join(" "),x=v.jsx("div",{ref:p,className:"app-shell__content-region","aria-hidden":u&&h?!0:void 0,children:v.jsx(Tg.Content,{className:S,children:e})});return u?v.jsxs(Tg,{className:`app-shell app-shell--compact ${t?"app-shell--dark":""}`,children:[x,o&&v.jsxs(v.Fragment,{children:[v.jsx("button",{type:"button",className:`app-shell__mobile-sidebar-backdrop ${h?"is-open":""}`,"aria-label":l("common.close"),"aria-hidden":!h,tabIndex:-1,onClick:()=>f(!1)}),v.jsx("div",{ref:b,id:Zbt,className:`app-shell__mobile-sidebar-sheet ${h?"is-open":""}`,role:"dialog","aria-modal":h?"true":void 0,"aria-label":l("common.sessions"),"aria-hidden":!h,tabIndex:-1,children:v.jsx(_8e,{width:w,activeId:n,onSelectRoom:L=>{f(!1),s(L)},onSelectSession:(L,E)=>{f(!1),r(L,E)},onDeletedSession:(L,E)=>{f(!1),i(L,E)},isCompactLayout:!0,isMobileOpen:h,onRequestClose:()=>f(!1)})})]}),v.jsx("div",{ref:_,children:v.jsx(o8e,{isCompactLayout:!0,ariaHidden:h,showSidebar:o,onOpenSidebar:()=>f(!0)})})]}):v.jsxs(Tg,{className:`app-shell ${t?"app-shell--dark":""}`,children:[v.jsxs("div",{className:"app-shell__sidebar-region",children:[v.jsx(o8e,{}),o&&v.jsx(_8e,{width:a,activeId:n,onSelectRoom:s,onSelectSession:r,onDeletedSession:i})]}),x]})}const mOe=(...n)=>n.find(e=>typeof e=="string"&&e.trim()!==""),pOe=()=>mOe(Gm().__VF_PROJECT_AI_CLIENT_VERSION__,"3.1.4")??"0.0.0",Gbt=()=>mOe(Gm().__VF_PROJECT_AI_CLIENT_COMMIT_HASH__,"f7859c85f377ef47c87f6e0ef239f6a779b2f0df"),Xbt=/^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/,L8e=n=>{const e=n==null?void 0:n.trim().match(Xbt);if(e!=null)return{major:Number(e[1]),minor:Number(e[2]),patch:Number(e[3]),...e[4]!=null?{prerelease:e[4]}:{}}},Ybt=(n,e)=>{const t=L8e(n),i=L8e(e);return t==null||i==null?!1:t.prerelease!=null||i.prerelease!=null?t.major===i.major&&t.minor===i.minor&&t.patch===i.patch&&t.prerelease===i.prerelease:t.major!==i.major?!1:t.major===0?t.minor===i.minor:!0},jD=n=>n.authToken!=null&&n.authToken.trim()!=="",rq=(n,e)=>v.jsxs("span",{className:"server-connection-gate__modal-label",children:[v.jsx("span",{className:"material-symbols-rounded",children:n}),v.jsx("span",{children:e})]});function Qbt({profile:n,onClose:e,onProfilesChange:t}){const{t:i}=ht(),{modal:s}=Vs.useApp(),[r]=zn.useForm();C.useEffect(()=>{n!=null&&r.setFieldsValue({alias:n.alias??"",description:n.description??""})},[r,n]);const o=async()=>{if(n==null)return;const c=await r.validateFields();t(cAe(n.serverUrl,c)),e()},a=()=>{n!=null&&s.confirm({title:i("serverConnection.clearLoginState"),content:i("serverConnection.clearLoginStateConfirm"),okText:i("common.confirm"),cancelText:i("common.cancel"),okButtonProps:{danger:!0},onOk:()=>{t(uAe(n.serverUrl)),e()}})},l=()=>{n!=null&&s.confirm({title:i("serverConnection.removeProfile"),content:i("serverConnection.removeProfileConfirm"),okText:i("common.delete"),cancelText:i("common.cancel"),okButtonProps:{danger:!0},onOk:()=>{t(x7t(n.serverUrl)),e()}})};return v.jsx(Fl,{open:n!=null,title:rq("tune",i("serverConnection.manageProfile")),okText:i("common.confirm"),cancelText:i("common.cancel"),onOk:()=>void o(),onCancel:e,children:n!=null&&v.jsxs("div",{className:"server-connection-gate__profile-modal",children:[v.jsxs("div",{className:"server-connection-gate__profile-modal-url",children:[v.jsx("span",{className:"material-symbols-rounded",children:"link"}),v.jsx("span",{children:n.serverUrl})]}),v.jsxs("div",{className:`server-connection-gate__profile-modal-auth ${jD(n)?"is-saved":""}`,children:[v.jsx("span",{className:"material-symbols-rounded",children:jD(n)?"verified_user":"lock_open"}),v.jsx("strong",{children:jD(n)?i("serverConnection.loginSaved"):i("serverConnection.loginMissing")})]}),v.jsxs(zn,{form:r,layout:"vertical",requiredMark:!1,children:[v.jsx(zn.Item,{name:"alias",label:rq("label",i("serverConnection.profileAlias")),children:v.jsx(yn,{placeholder:i("serverConnection.profileAliasPlaceholder")})}),v.jsx(zn.Item,{name:"description",label:rq("notes",i("serverConnection.profileDescription")),children:v.jsx(yn.TextArea,{autoSize:{minRows:2,maxRows:4},placeholder:i("serverConnection.profileDescriptionPlaceholder")})})]}),v.jsxs("div",{className:"server-connection-gate__profile-modal-actions",children:[jD(n)&&v.jsx(qe,{danger:!0,htmlType:"button",icon:v.jsx("span",{className:"material-symbols-rounded",children:"lock_reset"}),onClick:a,children:i("serverConnection.clearLoginState")}),v.jsx(qe,{danger:!0,htmlType:"button",type:"text",icon:v.jsx("span",{className:"material-symbols-rounded",children:"delete"}),onClick:l,children:i("serverConnection.removeProfile")})]})]})})}const k8e=()=>{const n=document.activeElement;n instanceof HTMLElement&&n.blur()},E8e=n=>n.authToken!=null&&n.authToken.trim()!=="",Jbt=n=>{var e;return((e=n.alias)==null?void 0:e.trim())||n.serverUrl},eyt=n=>{var e;return(e=n.serverVersion)==null?void 0:e.trim()},tyt=n=>n.pointerType==="touch"||n.pointerType==="pen";function nyt({profiles:n,submitting:e,onConnect:t,onProfilesChange:i}){const{t:s}=ht(),[r,o]=C.useState(null);if(n.length===0)return null;const a=(l,c)=>{k8e(),!(!tyt(l)||e)&&(l.preventDefault(),t(c.serverUrl))};return v.jsxs("section",{className:"server-connection-gate__recent","aria-labelledby":"server-connection-recent-title",children:[v.jsx("h2",{id:"server-connection-recent-title",children:s("serverConnection.recentTitle")}),v.jsx("div",{className:"server-connection-gate__recent-list",children:n.map(l=>v.jsx("div",{className:"server-connection-gate__profile-row",children:v.jsxs("div",{className:`server-connection-gate__profile-card ${e?"is-disabled":""}`,children:[v.jsxs("button",{type:"button",className:"server-connection-gate__recent-item",disabled:e,onPointerDown:c=>a(c,l),onClick:()=>t(l.serverUrl),children:[v.jsx("span",{className:"material-symbols-rounded",children:"dns"}),v.jsxs("span",{className:"server-connection-gate__profile-main",children:[v.jsx("span",{className:"server-connection-gate__profile-title",children:Jbt(l)}),v.jsx("span",{className:"server-connection-gate__profile-url",children:l.serverUrl}),v.jsx("span",{className:"server-connection-gate__profile-version",children:s("serverConnection.serverVersion",{version:eyt(l)??s("serverConnection.serverVersionUnknown")})}),l.description!=null&&v.jsx("span",{className:"server-connection-gate__profile-description",children:l.description})]}),v.jsx("span",{className:`server-connection-gate__profile-auth ${E8e(l)?"is-saved":""}`,children:E8e(l)?s("serverConnection.loginSaved"):s("serverConnection.loginMissing")})]}),v.jsx(qe,{htmlType:"button",type:"text",className:"server-connection-gate__profile-manage",icon:v.jsx("span",{className:"material-symbols-rounded",children:"edit"}),"aria-label":s("serverConnection.manageProfile"),onPointerDown:k8e,onClick:()=>o(l)})]})},l.serverUrl))}),v.jsx(Qbt,{profile:r,onClose:()=>o(null),onProfilesChange:i})]})}const iyt="http",syt="localhost:8787",ryt=[{label:"http://",value:"http"},{label:"https://",value:"https"}],oyt=v.jsx("span",{className:"material-symbols-rounded server-connection-gate__scheme-chevron",children:"expand_more"}),COe=n=>{const e=n.trim(),t=/^(https?):\/\/(.+)$/i.exec(e);return t==null?{serverScheme:void 0,serverHost:e}:{serverScheme:t[1].toLowerCase(),serverHost:t[2].trim()}},ayt=n=>{const e=COe(n.serverUrl);return`${e.serverScheme??n.serverScheme}://${e.serverHost}`},_Oe=n=>{const e=n.getFieldValue("serverUrl");if(typeof e!="string")return;const t=COe(e);t.serverScheme!=null&&n.setFieldsValue({serverScheme:t.serverScheme,serverUrl:t.serverHost})};function lyt({form:n,onBlur:e,...t}){const{t:i}=ht();return v.jsx(yn,{...t,autoComplete:"url",addonBefore:v.jsx(zn.Item,{name:"serverScheme",noStyle:!0,children:v.jsx(ms,{"aria-label":i("serverConnection.serverScheme"),className:"server-connection-gate__scheme-select",options:ryt,popupMatchSelectWidth:!1,suffixIcon:oyt})}),onBlur:s=>{e==null||e(s),_Oe(n)},size:"large",placeholder:i("serverConnection.serverUrlPlaceholder")})}const cyt="https://github.com/vibe-forge-ai/vibe-forge.ai/blob/master/.ai/docs/usage/pwa.md";class vOe extends Error{constructor(e,t){super("Unsupported server version"),this.clientVersion=e,this.serverVersion=t}}const oq=n=>n!=null&&typeof n=="object"&&!Array.isArray(n),dyt=n=>{const e=oq(n)&&oq(n.data)?n.data:n;return oq(e)&&typeof e.version=="string"?{version:e.version}:{}},uyt=async n=>{const e=await fetch(JPe(n,"/api/auth/status"),{credentials:"include"});if(!e.ok)throw new Error(`Server responded with ${e.status}`);const t=dyt(await e.json().catch(()=>{})),i=pOe();if(!Ybt(i,t.version))throw new vOe(i,t.version);return t};function hyt({children:n}){const{t:e}=ht(),t=ZW(),i=_7t(),s=iAe(),r=b7t(),[o]=zn.useForm(),[a,l]=C.useState(()=>eAe()),[c,d]=C.useState(()=>pf()),[u,h]=C.useState(null),[f,g]=C.useState(!1);if(C.useEffect(()=>{s!=null&&d(b=>{if(b.some(w=>w.serverUrl===s))return b;const y=wee(s);return i?cAe(s,{alias:e("serverConnection.localServiceAlias"),description:e("serverConnection.localServiceProfileDescription")}):y})},[s,i,e]),!t||!r&&(a!=null||s!=null))return n;const m=async b=>{g(!0),h(null);try{const y=xd(b);if(y==null){h(e("serverConnection.invalidUrl"));return}const w=await uyt(y),S=p7t(y);if(S==null){h(e("serverConnection.invalidUrl"));return}y7t(),d(wee(S,{serverVersion:w.version})),l(S)}catch(y){y instanceof vOe?h(e("serverConnection.unsupportedServerVersion",{clientVersion:y.clientVersion,serverVersion:y.serverVersion??e("serverConnection.serverVersionUnknown")})):h(e("serverConnection.connectionFailed"))}finally{g(!1)}},p=async b=>{_Oe(o),await m(ayt(b))},_=b=>{m(b)};return v.jsx("div",{className:"server-connection-gate",children:v.jsxs("main",{className:"server-connection-gate__panel","aria-labelledby":"server-connection-title",children:[v.jsxs("div",{className:"server-connection-gate__intro",children:[v.jsx("h1",{id:"server-connection-title",children:e(i?"serverConnection.desktopTitle":"serverConnection.title")}),v.jsx("p",{children:e(i?"serverConnection.desktopSubtitle":"serverConnection.subtitle")})]}),i?s!=null&&v.jsxs("div",{className:"server-connection-gate__setup",children:[v.jsxs("div",{className:"server-connection-gate__setup-title",children:[v.jsx("span",{className:"material-symbols-rounded",children:"computer"}),v.jsx("span",{children:e("serverConnection.localServiceTitle")})]}),v.jsx("code",{children:s}),v.jsx("p",{children:e("serverConnection.localServiceBannerDescription")})]}):v.jsxs("div",{className:"server-connection-gate__setup",children:[v.jsxs("div",{className:"server-connection-gate__setup-title",children:[v.jsx("span",{className:"material-symbols-rounded",children:"terminal"}),v.jsx("span",{children:e("serverConnection.setupTitle")})]}),v.jsx("code",{children:"npx vfui-server"}),v.jsxs("p",{children:[e("serverConnection.setupDescription"),v.jsx("a",{href:cyt,target:"_blank",rel:"noreferrer",children:e("serverConnection.docsLink")})]})]}),u!=null&&v.jsx(nO,{type:"error",showIcon:!0,className:"server-connection-gate__notice",message:u}),v.jsxs(zn,{form:o,layout:"vertical",requiredMark:!1,initialValues:{serverScheme:iyt,serverUrl:syt},onFinish:b=>void p(b),children:[v.jsx(zn.Item,{name:"serverUrl",label:e("serverConnection.serverUrl"),rules:[{required:!0,message:e("serverConnection.serverUrlRequired")}],children:v.jsx(lyt,{form:o})}),v.jsx(nyt,{profiles:c,submitting:f,onConnect:_,onProfilesChange:d}),v.jsx(qe,{type:"primary",htmlType:"submit",size:"large",loading:f,icon:v.jsx("span",{className:"material-symbols-rounded",children:"link"}),block:!0,children:e("serverConnection.connect")})]})]})})}function fyt(){var o,a,l;const{i18n:n}=ht(),e=Su(GW),{data:t}=Gn("/api/config",Z0),i=(l=(a=(o=t==null?void 0:t.sources)==null?void 0:o.merged)==null?void 0:a.general)==null?void 0:l.interfaceLanguage,s=e==="dark"||e==="system"&&window.matchMedia("(prefers-color-scheme: dark)").matches;C.useEffect(()=>{document.documentElement.classList.toggle("dark",s)},[s]),C.useEffect(()=>{i&&n.language!==i&&n.changeLanguage(i)},[n,i]);const r=C.useMemo(()=>({algorithm:s?T5e.darkAlgorithm:T5e.defaultAlgorithm,token:{colorPrimary:s?"#3b82f6":"#000000"}}),[s]);return{isDarkMode:s,themeConfig:r}}const she=n=>"isDeleted"in n&&n.isDeleted,gyt=n=>[...n].sort((e,t)=>{const i=+(t.isStarred===!0)-+(e.isStarred===!0);return i!==0?i:(t.createdAt??0)-(e.createdAt??0)}),I8e=(n,e,t)=>{if((n==null?void 0:n.sessions)==null)return n;if(she(e))return{...n,sessions:n.sessions.filter(a=>a.id!==e.id)};const i=e,s=t==="archived"?i.isArchived===!0:i.isArchived!==!0,r=n.sessions.find(a=>a.id===e.id);if(!s)return{...n,sessions:n.sessions.filter(a=>a.id!==e.id)};const o=r?n.sessions.map(a=>a.id===e.id?{...a,...i}:a):[i,...n.sessions];return{...n,sessions:gyt(o)}},myt=(n,e)=>she(e)?(n==null?void 0:n.session.id)===e.id?void 0:n:(n==null?void 0:n.session)==null?{session:e}:n.session.id===e.id?{...n,session:{...n.session,...e}}:n;function Nee(n,e){n("/api/sessions",t=>I8e(t,e,"active"),!1),n("/api/sessions/archived",t=>I8e(t,e,"archived"),!1),n(XW(e.id),t=>myt(t,e),!1)}const pyt=n=>Array.isArray(n)?n[0]==="/api/adapters":typeof n=="string"&&n.startsWith("/api/adapters/"),Cyt=n=>Array.isArray(n)?n[0]==="worktree-environment"||n[0]==="/api/adapters":pyt(n);async function _yt(n){await Promise.all([n("/api/config"),n("worktree-environments"),n(Cyt)])}const vyt=n=>{const e=new URL(rAe(w7t()));e.protocol=e.protocol==="https:"?"wss:":"ws:";const t=hAe();if(t!=null&&e.searchParams.set("authToken",t),n)for(const[i,s]of Object.entries(n))e.searchParams.set(i,s);return e.toString()};function YW(n,e){const t=vyt(e),i=new WebSocket(t);return i.addEventListener("open",()=>{var s;return(s=n.onOpen)==null?void 0:s.call(n)}),i.addEventListener("message",s=>{var r;try{const o=JSON.parse(String(s.data));(r=n.onMessage)==null||r.call(n,o)}catch(o){console.error(o)}}),i.addEventListener("error",s=>{var r;return(r=n.onError)==null?void 0:r.call(n,s)}),i.addEventListener("close",()=>{var s;return(s=n.onClose)==null?void 0:s.call(n)}),i}function byt(){const{mutate:n}=Jy();C.useEffect(()=>{let e=!1,t,i;const s=a=>{if(a&&!(a.readyState===WebSocket.CLOSED||a.readyState===WebSocket.CLOSING)){if(a.readyState===WebSocket.CONNECTING){a.addEventListener("open",()=>a.close(),{once:!0});return}a.close()}},r=(a=0)=>{e||(i&&clearTimeout(i),i=setTimeout(()=>{i=void 0,o()},a))},o=()=>{e||(t=YW({onMessage:a=>{if(!e){if(a.type==="session_updated"){const l=a.session;Nee(n,l);return}a.type==="config_updated"&&_yt(n)}},onClose:()=>{e||r(1e3)},onError:()=>{s(t)}},{subscribe:"sessions"}))};return r(),()=>{e=!0,i&&clearTimeout(i),s(t)}},[n])}const bOe="/session/:sessionId",yOe="/rooms/:roomId",wOe="/rooms/:roomId/sessions/:sessionId",yyt=n=>{const e=sf({path:wOe,end:!0},n);if((e==null?void 0:e.params.roomId)!=null)return IO(e.params.roomId);const t=sf({path:yOe,end:!0},n);if((t==null?void 0:t.params.roomId)!=null)return IO(t.params.roomId);const i=sf({path:bOe,end:!0},n);return i==null?void 0:i.params.sessionId},wyt="agentRoomMode";function Syt(n,e){const t=new URLSearchParams(e);t.delete(wyt);const i=t.toString();return{pathname:n,search:i===""?"":`?${i}`}}function xyt(){const n=Iu(),e=E3(),t=Su(v_t),i=sf({path:bOe,end:!0},e.pathname),s=sf({path:yOe,end:!0},e.pathname),r=sf({path:wOe,end:!0},e.pathname),o=i==null?void 0:i.params.sessionId,a=yyt(e.pathname),l=e.pathname==="/"||o!=null||(s==null?void 0:s.params.roomId)!=null||(r==null?void 0:r.params.roomId)!=null,c=C.useCallback(f=>Syt(f,e.search),[e.search]),d=C.useCallback((f,g)=>{n(c(f.id===""?"/":`/session/${f.id}`))},[c,n]),u=C.useCallback(f=>{n(c(`/rooms/${f.id}`))},[c,n]),h=C.useCallback((f,g)=>{o===f&&n(c(g?`/session/${g}`:"/"))},[o,c,n]);return{activeSidebarId:a,handleDeletedSession:h,handleSelectRoom:u,handleSelectSession:d,showSidebar:l,sidebarWidth:t}}const Lyt={completed:"completed",failed:"failed",running:"running",stopped:"terminated",waiting:"waiting_input"},kyt=n=>({id:n.sessionId,status:Lyt[n.status],summary:n.latestSummary,title:n.title,updatedAtLabel:n.updatedAtLabel});function Eyt({runs:n,onOpenRun:e}){const{t}=ht(),i=(s,r)=>{if(s==="waiting_input")return v.jsx("div",{className:"waiting-input-indicator",title:r,"aria-label":r});const o=s==="completed"?"check_circle":s==="failed"?"cancel":s==="terminated"?"remove_circle":"sync";return v.jsx("span",{className:`material-symbols-rounded status-icon agent-room-run-list__status-icon agent-room-run-list__status-icon--${s} ${s==="running"?"spin":""}`,title:r,"aria-label":r,children:o})};return n.length===0?v.jsx("div",{className:"agent-room-run-list agent-room-run-list--empty",children:t("agentRoom.roster.noRuns")}):v.jsx("div",{className:"agent-room-run-list",children:n.map(s=>{const r=kyt(s),o=e!=null,a=t("agentRoom.actions.openRun"),l=r.title===""?t("common.newChat"):r.title,c=l===""?a:`${a}: ${l}`,d=t(`common.status.${r.status}`),u=r.updatedAtLabel!=null&&r.updatedAtLabel!==""?r.updatedAtLabel:d;return v.jsx(uOe,{as:"article",className:`agent-room-run-list__session-card agent-room-run-list__session-card--${s.status} session-item session-item--compact`,dataSessionCardSource:"agent-room-run",dataSessionId:r.id,leading:v.jsx("div",{className:"session-leading",children:v.jsx("div",{className:"status-indicator",children:i(r.status,d)})}),title:o?v.jsx("button",{type:"button",className:"agent-room-run-list__title-button session-title-text","aria-label":c,title:c,onClick:()=>e(s),children:l}):v.jsx("span",{className:"session-title-text",children:l}),headerSide:v.jsx("span",{className:"time-display",children:u}),lastMessage:r.summary!=null&&r.summary!==""&&v.jsx("div",{className:"last-message",children:r.summary})},s.runKey)})})}const SOe=n=>n.trim().replace(/^@+/,""),Iyt=n=>n.avatarLabel??SOe(n.label).slice(0,2).toUpperCase();function Myt({defaultExpandedMemberKeys:n=[],members:e,layout:t,onOpenRun:i,showHeader:s=!0}){const{t:r}=ht(),o=C.useId(),[a,l]=C.useState(()=>new Set(n)),c=u=>{l(h=>{const f=new Set(h);return f.has(u)?f.delete(u):f.add(u),f})},d=v.jsx("div",{className:"agent-room-roster__members",children:e.map(u=>{const h=SOe(u.label),f=a.has(u.memberKey),g=u.runs.length>0,m=`${o}-${u.memberKey}-runs`;return v.jsxs("section",{className:`agent-room-roster__member agent-room-roster__member--${u.status}`,children:[v.jsxs("div",{className:"agent-room-roster__member-head",children:[v.jsx("div",{className:"agent-room-roster__avatar","aria-hidden":"true",children:Iyt(u)}),v.jsxs("div",{className:"agent-room-roster__member-copy",children:[v.jsx("div",{className:"agent-room-roster__member-name",children:h}),u.subtitle!=null&&u.subtitle!==""&&v.jsx("div",{className:"agent-room-roster__member-subtitle",children:u.subtitle})]}),v.jsx("span",{className:"agent-room-roster__status",children:r(`agentRoom.status.member.${u.status}`)})]}),u.latestSummary!=null&&u.latestSummary!==""&&v.jsx("div",{className:"agent-room-roster__summary",children:u.latestSummary}),g&&v.jsxs("button",{type:"button",className:`agent-room-roster__runs-toggle ${f?"is-expanded":""}`,"aria-expanded":f,"aria-controls":m,onClick:()=>c(u.memberKey),children:[v.jsx("span",{className:"material-symbols-rounded","aria-hidden":"true",children:"chevron_right"}),v.jsx("span",{children:r(f?"agentRoom.roster.collapseRuns":"agentRoom.roster.expandRuns")})]}),g&&f&&v.jsx("div",{id:m,className:"agent-room-roster__runs-panel",children:v.jsx(Eyt,{runs:u.runs,onOpenRun:i})})]},u.memberKey)})});return t==="compact"?v.jsxs("details",{className:"agent-room-roster agent-room-roster--compact",open:!0,children:[v.jsxs("summary",{className:"agent-room-roster__compact-trigger",children:[v.jsx("span",{className:"material-symbols-rounded","aria-hidden":"true",children:"groups"}),v.jsx("span",{children:r("agentRoom.roster.compactTitle",{count:e.length})})]}),d]}):v.jsxs("aside",{className:"agent-room-roster agent-room-roster--desktop","aria-label":r("agentRoom.roster.title"),children:[s&&v.jsxs("div",{className:"agent-room-roster__header",children:[v.jsxs("div",{children:[v.jsx("div",{className:"agent-room-roster__eyebrow",children:r("agentRoom.roster.eyebrow")}),v.jsx("h2",{children:r("agentRoom.roster.title")})]}),v.jsx("span",{children:r("agentRoom.roster.memberCount",{count:e.length})})]}),d]})}const aq=(n,e)=>n.reduce((t,i)=>t+i.runs.filter(e).length,0),Nyt=n=>({memberKey:n.memberKey??"host",kind:"host",label:"leader",avatarLabel:"L",status:"active",pendingCount:0,activeRunCount:0,runs:[]}),Dyt=n=>{var e;return n.kind==="assignment"||n.memberKey==="host"||((e=n.memberKey)==null?void 0:e.startsWith("host:"))};function xOe(n){const e=new Map(n.members.map(s=>[s.memberKey,s])),t=new Map(n.members.flatMap(s=>s.runs.map(r=>[r.runKey,r]))),i=n.messages.map(s=>{const r=s.runKey==null?void 0:t.get(s.runKey),o=s.memberKey??(r==null?void 0:r.memberKey),a=Dyt(s)?Nyt(s):o==null?void 0:e.get(o);return{...s,member:a,run:r}});return{...n,messages:i,attentionCount:n.members.reduce((s,r)=>s+r.pendingCount,0),runningRunCount:aq(n.members,s=>s.status==="running"),completedRunCount:aq(n.members,s=>s.status==="completed"),failedRunCount:aq(n.members,s=>s.status==="failed")}}const Bb=n=>n.trim().toLowerCase(),rhe=n=>{const e=n.lastIndexOf(":");return e>=0?n.slice(e+1):n},ohe=n=>n.replace(/^@+/,""),vm=(...n)=>{for(const e of n){const t=ohe(rhe(e)).trim();if(t!=="")return t}return""},LOe=n=>Array.from(new Set(n.map(Bb).filter(Boolean))),kOe=n=>LOe([n.label,ohe(n.label),vm(n.label),n.memberKey,rhe(n.memberKey),vm(n.memberKey)]),Tyt=n=>LOe([n.title,ohe(n.title),vm(n.title),n.runKey,rhe(n.runKey),vm(n.runKey)]),nE=n=>`@${vm(n.label,n.memberKey)}`,EOe=(n,e)=>`${nE(n)}/${vm(e.title,e.runKey)}`,ahe=n=>vm(n.label,n.memberKey),Ryt=(n,e)=>`${ahe(n)}/${vm(e.title,e.runKey)}`,Pyt=n=>{const e=Bb(n.memberKey);return n.kind==="host"||e==="host"||e.startsWith("host:")||kOe(n).some(t=>t==="host"||t==="leader")},IOe=n=>n.find(Pyt),Ayt=(n,e)=>{const t=Bb(e);return n.filter(i=>kOe(i).includes(t))},Oyt=(n,e)=>{const t=Bb(e);return n.runs.filter(i=>Tyt(i).includes(t))},Fyt=(n,e)=>e==null?void 0:n.find(t=>t.memberKey===e),Byt=(n,e)=>n==null||e==null?void 0:n.runs.find(t=>t.runKey===e),lq=n=>{const e=IOe(n);return{status:"host",targetLabel:e==null?"leader":ahe(e)}},$yt=n=>{if(!n.startsWith("@"))return;const e=n.search(/\s/),t=e>=0?n.slice(0,e):n,[i="",s]=t.slice(1).split("/",2);return{memberAlias:i,runAlias:s,mention:t,contentStart:t.length}},MOe=n=>({value:nE(n),target:{memberKey:n.memberKey},kind:"member"}),NOe=(n,e)=>({value:EOe(n,e),target:{memberKey:n.memberKey,runKey:e.runKey},kind:"run"}),Hyt=n=>n.map(MOe),Vyt=(n,e)=>e.map(t=>NOe(n,t));function jyt(n,e=""){const t=Bb(e.replace(/^@/,"")),i=n.flatMap(s=>[MOe(s),...s.runs.map(r=>NOe(s,r))]);return t===""?i:i.filter(s=>Bb(s.value.slice(1)).startsWith(t))}function DOe(n,e){const t=n.trimStart();if(t.trim()==="")return{status:"empty"};const i=$yt(t);if(i==null){const h=IOe(e);return{status:"resolved",content:t.trim(),...h!=null?{target:{memberKey:h.memberKey}}:{},route:"host",previewLabel:h==null?"Host agent":nE(h)}}const{memberAlias:s,mention:r,runAlias:o}=i,a=Ayt(e,s);if(a.length===0)return{status:"missing",mention:r};if(a.length>1)return{status:"ambiguous",mention:r,suggestions:Hyt(a)};const l=a[0];if(o!=null&&o.trim()!==""){const h=Oyt(l,o);if(h.length===0)return{status:"missing",mention:r};if(h.length>1)return{status:"ambiguous",mention:r,suggestions:Vyt(l,h)};const f=h[0],g={memberKey:l.memberKey,runKey:f.runKey},m=t.slice(i.contentStart).trim(),p=EOe(l,f);return m===""?{status:"empty-targeted-message",mention:r,target:g,route:"run",previewLabel:p}:{status:"resolved",content:m,target:g,route:"run",mention:r,previewLabel:p}}const c={memberKey:l.memberKey},d=t.slice(i.contentStart).trim(),u=`${nE(l)} mailbox`;return d===""?{status:"empty-targeted-message",mention:r,target:c,route:"member",previewLabel:u}:{status:"resolved",content:d,target:c,route:"member",mention:r,previewLabel:u}}function Wyt(n,e){var o,a;const t=n.trimStart();if(t===""||!t.startsWith("@"))return lq(e);const i=DOe(n,e);if(i.status==="missing"||i.status==="ambiguous")return{status:i.status,targetLabel:i.mention};if(i.status==="empty")return lq(e);const s=Fyt(e,(o=i.target)==null?void 0:o.memberKey),r=Byt(s,(a=i.target)==null?void 0:a.runKey);return i.route==="run"?{status:"run",targetLabel:s==null||r==null?i.previewLabel:Ryt(s,r)}:i.route==="member"?{status:"member",targetLabel:s==null?i.previewLabel:ahe(s)}:lq(e)}function zyt(n){return{content:n.content,...n.target!=null?{target:n.target}:{},route:n.route}}const Uyt="modulepreload",Kyt=function(n){return"/__VF_PROJECT_AI_CLIENT_BASE__/"+n},M8e={},re=function(e,t,i){let s=Promise.resolve();if(t&&t.length>0){document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),a=(o==null?void 0:o.nonce)||(o==null?void 0:o.getAttribute("nonce"));s=Promise.allSettled(t.map(l=>{if(l=Kyt(l),l in M8e)return;M8e[l]=!0;const c=l.endsWith(".css"),d=c?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${l}"]${d}`))return;const u=document.createElement("link");if(u.rel=c?"stylesheet":Uyt,c||(u.as="script"),u.crossOrigin="",u.href=l,a&&u.setAttribute("nonce",a),document.head.appendChild(u),c)return new Promise((h,f)=>{u.addEventListener("load",h),u.addEventListener("error",()=>f(new Error(`Unable to preload CSS for ${l}`)))})}))}function r(o){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=o,window.dispatchEvent(a),!a.defaultPrevented)throw o}return s.then(o=>{for(const a of o||[])a.status==="rejected"&&r(a.reason);return e().catch(r)})};let xa=class extends Error{constructor(e){super(e),this.name="ShikiError"}};function Zyt(n){return lhe(n)}function lhe(n){return Array.isArray(n)?qyt(n):n instanceof RegExp?n:typeof n=="object"?Gyt(n):n}function qyt(n){let e=[];for(let t=0,i=n.length;t<i;t++)e[t]=lhe(n[t]);return e}function Gyt(n){let e={};for(let t in n)e[t]=lhe(n[t]);return e}function TOe(n,...e){return e.forEach(t=>{for(let i in t)n[i]=t[i]}),n}function ROe(n){const e=~n.lastIndexOf("/")||~n.lastIndexOf("\\");return e===0?n:~e===n.length-1?ROe(n.substring(0,n.length-1)):n.substr(~e+1)}var cq=/\$(\d+)|\${(\d+):\/(downcase|upcase)}/g,WD=class{static hasCaptures(n){return n===null?!1:(cq.lastIndex=0,cq.test(n))}static replaceCaptures(n,e,t){return n.replace(cq,(i,s,r,o)=>{let a=t[parseInt(s||r,10)];if(a){let l=e.substring(a.start,a.end);for(;l[0]===".";)l=l.substring(1);switch(o){case"downcase":return l.toLowerCase();case"upcase":return l.toUpperCase();default:return l}}else return i})}};function POe(n,e){return n<e?-1:n>e?1:0}function AOe(n,e){if(n===null&&e===null)return 0;if(!n)return-1;if(!e)return 1;let t=n.length,i=e.length;if(t===i){for(let s=0;s<t;s++){let r=POe(n[s],e[s]);if(r!==0)return r}return 0}return t-i}function N8e(n){return!!(/^#[0-9a-f]{6}$/i.test(n)||/^#[0-9a-f]{8}$/i.test(n)||/^#[0-9a-f]{3}$/i.test(n)||/^#[0-9a-f]{4}$/i.test(n))}function OOe(n){return n.replace(/[\-\\\{\}\*\+\?\|\^\$\.\,\[\]\(\)\#\s]/g,"\\$&")}var FOe=class{constructor(n){dt(this,"cache",new Map);this.fn=n}get(n){if(this.cache.has(n))return this.cache.get(n);const e=this.fn(n);return this.cache.set(n,e),e}},NO=class{constructor(n,e,t){dt(this,"_cachedMatchRoot",new FOe(n=>this._root.match(n)));this._colorMap=n,this._defaults=e,this._root=t}static createFromRawTheme(n,e){return this.createFromParsedTheme(Qyt(n),e)}static createFromParsedTheme(n,e){return ewt(n,e)}getColorMap(){return this._colorMap.getColorMap()}getDefaults(){return this._defaults}match(n){if(n===null)return this._defaults;const e=n.scopeName,i=this._cachedMatchRoot.get(e).find(s=>Xyt(n.parent,s.parentScopes));return i?new BOe(i.fontStyle,i.foreground,i.background):null}},dq=class CP{constructor(e,t){this.parent=e,this.scopeName=t}static push(e,t){for(const i of t)e=new CP(e,i);return e}static from(...e){let t=null;for(let i=0;i<e.length;i++)t=new CP(t,e[i]);return t}push(e){return new CP(this,e)}getSegments(){let e=this;const t=[];for(;e;)t.push(e.scopeName),e=e.parent;return t.reverse(),t}toString(){return this.getSegments().join(" ")}extends(e){return this===e?!0:this.parent===null?!1:this.parent.extends(e)}getExtensionIfDefined(e){const t=[];let i=this;for(;i&&i!==e;)t.push(i.scopeName),i=i.parent;return i===e?t.reverse():void 0}};function Xyt(n,e){if(e.length===0)return!0;for(let t=0;t<e.length;t++){let i=e[t],s=!1;if(i===">"){if(t===e.length-1)return!1;i=e[++t],s=!0}for(;n&&!Yyt(n.scopeName,i);){if(s)return!1;n=n.parent}if(!n)return!1;n=n.parent}return!0}function Yyt(n,e){return e===n||n.startsWith(e)&&n[e.length]==="."}var BOe=class{constructor(n,e,t){this.fontStyle=n,this.foregroundId=e,this.backgroundId=t}};function Qyt(n){if(!n)return[];if(!n.settings||!Array.isArray(n.settings))return[];let e=n.settings,t=[],i=0;for(let s=0,r=e.length;s<r;s++){let o=e[s];if(!o.settings)continue;let a;if(typeof o.scope=="string"){let u=o.scope;u=u.replace(/^[,]+/,""),u=u.replace(/[,]+$/,""),a=u.split(",")}else Array.isArray(o.scope)?a=o.scope:a=[""];let l=-1;if(typeof o.settings.fontStyle=="string"){l=0;let u=o.settings.fontStyle.split(" ");for(let h=0,f=u.length;h<f;h++)switch(u[h]){case"italic":l=l|1;break;case"bold":l=l|2;break;case"underline":l=l|4;break;case"strikethrough":l=l|8;break}}let c=null;typeof o.settings.foreground=="string"&&N8e(o.settings.foreground)&&(c=o.settings.foreground);let d=null;typeof o.settings.background=="string"&&N8e(o.settings.background)&&(d=o.settings.background);for(let u=0,h=a.length;u<h;u++){let g=a[u].trim().split(" "),m=g[g.length-1],p=null;g.length>1&&(p=g.slice(0,g.length-1),p.reverse()),t[i++]=new Jyt(m,p,s,l,c,d)}}return t}var Jyt=class{constructor(n,e,t,i,s,r){this.scope=n,this.parentScopes=e,this.index=t,this.fontStyle=i,this.foreground=s,this.background=r}},Rc=(n=>(n[n.NotSet=-1]="NotSet",n[n.None=0]="None",n[n.Italic=1]="Italic",n[n.Bold=2]="Bold",n[n.Underline=4]="Underline",n[n.Strikethrough=8]="Strikethrough",n))(Rc||{});function ewt(n,e){n.sort((l,c)=>{let d=POe(l.scope,c.scope);return d!==0||(d=AOe(l.parentScopes,c.parentScopes),d!==0)?d:l.index-c.index});let t=0,i="#000000",s="#ffffff";for(;n.length>=1&&n[0].scope==="";){let l=n.shift();l.fontStyle!==-1&&(t=l.fontStyle),l.foreground!==null&&(i=l.foreground),l.background!==null&&(s=l.background)}let r=new twt(e),o=new BOe(t,r.getId(i),r.getId(s)),a=new iwt(new Dee(0,null,-1,0,0),[]);for(let l=0,c=n.length;l<c;l++){let d=n[l];a.insert(0,d.scope,d.parentScopes,d.fontStyle,r.getId(d.foreground),r.getId(d.background))}return new NO(r,o,a)}var twt=class{constructor(e){dt(this,"_isFrozen");dt(this,"_lastColorId");dt(this,"_id2color");dt(this,"_color2id");if(this._lastColorId=0,this._id2color=[],this._color2id=Object.create(null),Array.isArray(e)){this._isFrozen=!0;for(let t=0,i=e.length;t<i;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)}},nwt=Object.freeze([]),Dee=class $Oe{constructor(e,t,i,s,r){dt(this,"scopeDepth");dt(this,"parentScopes");dt(this,"fontStyle");dt(this,"foreground");dt(this,"background");this.scopeDepth=e,this.parentScopes=t||nwt,this.fontStyle=i,this.foreground=s,this.background=r}clone(){return new $Oe(this.scopeDepth,this.parentScopes,this.fontStyle,this.foreground,this.background)}static cloneArr(e){let t=[];for(let i=0,s=e.length;i<s;i++)t[i]=e[i].clone();return t}acceptOverwrite(e,t,i,s){this.scopeDepth>e?console.log("how did this happen?"):this.scopeDepth=e,t!==-1&&(this.fontStyle=t),i!==0&&(this.foreground=i),s!==0&&(this.background=s)}},iwt=class Tee{constructor(e,t=[],i={}){dt(this,"_rulesWithParentScopes");this._mainRule=e,this._children=i,this._rulesWithParentScopes=t}static _cmpBySpecificity(e,t){if(e.scopeDepth!==t.scopeDepth)return t.scopeDepth-e.scopeDepth;let i=0,s=0;for(;e.parentScopes[i]===">"&&i++,t.parentScopes[s]===">"&&s++,!(i>=e.parentScopes.length||s>=t.parentScopes.length);){const r=t.parentScopes[s].length-e.parentScopes[i].length;if(r!==0)return r;i++,s++}return t.parentScopes.length-e.parentScopes.length}match(e){if(e!==""){let i=e.indexOf("."),s,r;if(i===-1?(s=e,r=""):(s=e.substring(0,i),r=e.substring(i+1)),this._children.hasOwnProperty(s))return this._children[s].match(r)}const t=this._rulesWithParentScopes.concat(this._mainRule);return t.sort(Tee._cmpBySpecificity),t}insert(e,t,i,s,r,o){if(t===""){this._doInsertHere(e,i,s,r,o);return}let a=t.indexOf("."),l,c;a===-1?(l=t,c=""):(l=t.substring(0,a),c=t.substring(a+1));let d;this._children.hasOwnProperty(l)?d=this._children[l]:(d=new Tee(this._mainRule.clone(),Dee.cloneArr(this._rulesWithParentScopes)),this._children[l]=d),d.insert(e+1,c,i,s,r,o)}_doInsertHere(e,t,i,s,r){if(t===null){this._mainRule.acceptOverwrite(e,i,s,r);return}for(let o=0,a=this._rulesWithParentScopes.length;o<a;o++){let l=this._rulesWithParentScopes[o];if(AOe(l.parentScopes,t)===0){l.acceptOverwrite(e,i,s,r);return}}i===-1&&(i=this._mainRule.fontStyle),s===0&&(s=this._mainRule.foreground),r===0&&(r=this._mainRule.background),this._rulesWithParentScopes.push(new Dee(e,t,i,s,r))}},$b=class H3{static toBinaryStr(e){return e.toString(2).padStart(32,"0")}static print(e){const t=H3.getLanguageId(e),i=H3.getTokenType(e),s=H3.getFontStyle(e),r=H3.getForeground(e),o=H3.getBackground(e);console.log({languageId:t,tokenType:i,fontStyle:s,foreground:r,background:o})}static getLanguageId(e){return(e&255)>>>0}static getTokenType(e){return(e&768)>>>8}static containsBalancedBrackets(e){return(e&1024)!==0}static getFontStyle(e){return(e&30720)>>>11}static getForeground(e){return(e&16744448)>>>15}static getBackground(e){return(e&4278190080)>>>24}static set(e,t,i,s,r,o,a){let l=H3.getLanguageId(e),c=H3.getTokenType(e),d=H3.containsBalancedBrackets(e)?1:0,u=H3.getFontStyle(e),h=H3.getForeground(e),f=H3.getBackground(e);return t!==0&&(l=t),i!==8&&(c=i),s!==null&&(d=s?1:0),r!==-1&&(u=r),o!==0&&(h=o),a!==0&&(f=a),(l<<0|c<<8|d<<10|u<<11|h<<15|f<<24)>>>0}};function DO(n,e){const t=[],i=swt(n);let s=i.next();for(;s!==null;){let l=0;if(s.length===2&&s.charAt(1)===":"){switch(s.charAt(0)){case"R":l=1;break;case"L":l=-1;break;default:console.log(`Unknown priority ${s} in scope selector`)}s=i.next()}let c=o();if(t.push({matcher:c,priority:l}),s!==",")break;s=i.next()}return t;function r(){if(s==="-"){s=i.next();const l=r();return c=>!!l&&!l(c)}if(s==="("){s=i.next();const l=a();return s===")"&&(s=i.next()),l}if(D8e(s)){const l=[];do l.push(s),s=i.next();while(D8e(s));return c=>e(l,c)}return null}function o(){const l=[];let c=r();for(;c;)l.push(c),c=r();return d=>l.every(u=>u(d))}function a(){const l=[];let c=o();for(;c&&(l.push(c),s==="|"||s===",");){do s=i.next();while(s==="|"||s===",");c=o()}return d=>l.some(u=>u(d))}}function D8e(n){return!!n&&!!n.match(/[\w\.:]+/)}function swt(n){let e=/([LR]:|[\w\.:][\w\.:\-]*|[\,\|\-\(\)])/g,t=e.exec(n);return{next:()=>{if(!t)return null;const i=t[0];return t=e.exec(n),i}}}function HOe(n){typeof n.dispose=="function"&&n.dispose()}var iE=class{constructor(n){this.scopeName=n}toKey(){return this.scopeName}},rwt=class{constructor(n,e){this.scopeName=n,this.ruleName=e}toKey(){return`${this.scopeName}#${this.ruleName}`}},owt=class{constructor(){dt(this,"_references",[]);dt(this,"_seenReferenceKeys",new Set);dt(this,"visitedRule",new Set)}get references(){return this._references}add(n){const e=n.toKey();this._seenReferenceKeys.has(e)||(this._seenReferenceKeys.add(e),this._references.push(n))}},awt=class{constructor(n,e){dt(this,"seenFullScopeRequests",new Set);dt(this,"seenPartialScopeRequests",new Set);dt(this,"Q");this.repo=n,this.initialScopeName=e,this.seenFullScopeRequests.add(this.initialScopeName),this.Q=[new iE(this.initialScopeName)]}processQueue(){const n=this.Q;this.Q=[];const e=new owt;for(const t of n)lwt(t,this.initialScopeName,this.repo,e);for(const t of e.references)if(t instanceof iE){if(this.seenFullScopeRequests.has(t.scopeName))continue;this.seenFullScopeRequests.add(t.scopeName),this.Q.push(t)}else{if(this.seenFullScopeRequests.has(t.scopeName)||this.seenPartialScopeRequests.has(t.toKey()))continue;this.seenPartialScopeRequests.add(t.toKey()),this.Q.push(t)}}};function lwt(n,e,t,i){const s=t.lookup(n.scopeName);if(!s){if(n.scopeName===e)throw new Error(`No grammar provided for <${e}>`);return}const r=t.lookup(e);n instanceof iE?_P({baseGrammar:r,selfGrammar:s},i):Ree(n.ruleName,{baseGrammar:r,selfGrammar:s,repository:s.repository},i);const o=t.injections(n.scopeName);if(o)for(const a of o)i.add(new iE(a))}function Ree(n,e,t){if(e.repository&&e.repository[n]){const i=e.repository[n];TO([i],e,t)}}function _P(n,e){n.selfGrammar.patterns&&Array.isArray(n.selfGrammar.patterns)&&TO(n.selfGrammar.patterns,{...n,repository:n.selfGrammar.repository},e),n.selfGrammar.injections&&TO(Object.values(n.selfGrammar.injections),{...n,repository:n.selfGrammar.repository},e)}function TO(n,e,t){for(const i of n){if(t.visitedRule.has(i))continue;t.visitedRule.add(i);const s=i.repository?TOe({},e.repository,i.repository):e.repository;Array.isArray(i.patterns)&&TO(i.patterns,{...e,repository:s},t);const r=i.include;if(!r)continue;const o=VOe(r);switch(o.kind){case 0:_P({...e,selfGrammar:e.baseGrammar},t);break;case 1:_P(e,t);break;case 2:Ree(o.ruleName,{...e,repository:s},t);break;case 3:case 4:const a=o.scopeName===e.selfGrammar.scopeName?e.selfGrammar:o.scopeName===e.baseGrammar.scopeName?e.baseGrammar:void 0;if(a){const l={baseGrammar:e.baseGrammar,selfGrammar:a,repository:s};o.kind===4?Ree(o.ruleName,l,t):_P(l,t)}else o.kind===4?t.add(new rwt(o.scopeName,o.ruleName)):t.add(new iE(o.scopeName));break}}}var cwt=class{constructor(){dt(this,"kind",0)}},dwt=class{constructor(){dt(this,"kind",1)}},uwt=class{constructor(n){dt(this,"kind",2);this.ruleName=n}},hwt=class{constructor(n){dt(this,"kind",3);this.scopeName=n}},fwt=class{constructor(n,e){dt(this,"kind",4);this.scopeName=n,this.ruleName=e}};function VOe(n){if(n==="$base")return new cwt;if(n==="$self")return new dwt;const e=n.indexOf("#");if(e===-1)return new hwt(n);if(e===0)return new uwt(n.substring(1));{const t=n.substring(0,e),i=n.substring(e+1);return new fwt(t,i)}}var gwt=/\\(\d+)/,T8e=/\\(\d+)/g,mwt=-1,jOe=-2;var ZM=class{constructor(e,t,i,s){dt(this,"$location");dt(this,"id");dt(this,"_nameIsCapturing");dt(this,"_name");dt(this,"_contentNameIsCapturing");dt(this,"_contentName");this.$location=e,this.id=t,this._name=i||null,this._nameIsCapturing=WD.hasCaptures(this._name),this._contentName=s||null,this._contentNameIsCapturing=WD.hasCaptures(this._contentName)}get debugName(){const e=this.$location?`${ROe(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:WD.replaceCaptures(this._name,e,t)}getContentName(e,t){return!this._contentNameIsCapturing||this._contentName===null?this._contentName:WD.replaceCaptures(this._contentName,e,t)}},pwt=class extends ZM{constructor(e,t,i,s,r){super(e,t,i,s);dt(this,"retokenizeCapturedWithRuleId");this.retokenizeCapturedWithRuleId=r}dispose(){}collectPatterns(e,t){throw new Error("Not supported!")}compile(e,t){throw new Error("Not supported!")}compileAG(e,t,i,s){throw new Error("Not supported!")}},Cwt=class extends ZM{constructor(e,t,i,s,r){super(e,t,i,null);dt(this,"_match");dt(this,"captures");dt(this,"_cachedCompiledPatterns");this._match=new sE(s,this.id),this.captures=r,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}get debugMatchRegExp(){return`${this._match.source}`}collectPatterns(e,t){t.push(this._match)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,i,s){return this._getCachedCompiledPatterns(e).compileAG(e,i,s)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new rE,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},R8e=class extends ZM{constructor(e,t,i,s,r){super(e,t,i,s);dt(this,"hasMissingPatterns");dt(this,"patterns");dt(this,"_cachedCompiledPatterns");this.patterns=r.patterns,this.hasMissingPatterns=r.hasMissingPatterns,this._cachedCompiledPatterns=null}dispose(){this._cachedCompiledPatterns&&(this._cachedCompiledPatterns.dispose(),this._cachedCompiledPatterns=null)}collectPatterns(e,t){for(const i of this.patterns)e.getRule(i).collectPatterns(e,t)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,i,s){return this._getCachedCompiledPatterns(e).compileAG(e,i,s)}_getCachedCompiledPatterns(e){return this._cachedCompiledPatterns||(this._cachedCompiledPatterns=new rE,this.collectPatterns(e,this._cachedCompiledPatterns)),this._cachedCompiledPatterns}},Pee=class extends ZM{constructor(e,t,i,s,r,o,a,l,c,d){super(e,t,i,s);dt(this,"_begin");dt(this,"beginCaptures");dt(this,"_end");dt(this,"endHasBackReferences");dt(this,"endCaptures");dt(this,"applyEndPatternLast");dt(this,"hasMissingPatterns");dt(this,"patterns");dt(this,"_cachedCompiledPatterns");this._begin=new sE(r,this.id),this.beginCaptures=o,this._end=new sE(a||"￿",-1),this.endHasBackReferences=this._end.hasBackReferences,this.endCaptures=l,this.applyEndPatternLast=c||!1,this.patterns=d.patterns,this.hasMissingPatterns=d.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(e,t){return this._end.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e,t).compile(e)}compileAG(e,t,i,s){return this._getCachedCompiledPatterns(e,t).compileAG(e,i,s)}_getCachedCompiledPatterns(e,t){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new rE;for(const i of this.patterns)e.getRule(i).collectPatterns(e,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,t):this._cachedCompiledPatterns.setSource(0,t)),this._cachedCompiledPatterns}},RO=class extends ZM{constructor(e,t,i,s,r,o,a,l,c){super(e,t,i,s);dt(this,"_begin");dt(this,"beginCaptures");dt(this,"whileCaptures");dt(this,"_while");dt(this,"whileHasBackReferences");dt(this,"hasMissingPatterns");dt(this,"patterns");dt(this,"_cachedCompiledPatterns");dt(this,"_cachedCompiledWhilePatterns");this._begin=new sE(r,this.id),this.beginCaptures=o,this.whileCaptures=l,this._while=new sE(a,jOe),this.whileHasBackReferences=this._while.hasBackReferences,this.patterns=c.patterns,this.hasMissingPatterns=c.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(e,t){return this._while.resolveBackReferences(e,t)}collectPatterns(e,t){t.push(this._begin)}compile(e,t){return this._getCachedCompiledPatterns(e).compile(e)}compileAG(e,t,i,s){return this._getCachedCompiledPatterns(e).compileAG(e,i,s)}_getCachedCompiledPatterns(e){if(!this._cachedCompiledPatterns){this._cachedCompiledPatterns=new rE;for(const t of this.patterns)e.getRule(t).collectPatterns(e,this._cachedCompiledPatterns)}return this._cachedCompiledPatterns}compileWhile(e,t){return this._getCachedCompiledWhilePatterns(e,t).compile(e)}compileWhileAG(e,t,i,s){return this._getCachedCompiledWhilePatterns(e,t).compileAG(e,i,s)}_getCachedCompiledWhilePatterns(e,t){return this._cachedCompiledWhilePatterns||(this._cachedCompiledWhilePatterns=new rE,this._cachedCompiledWhilePatterns.push(this._while.hasBackReferences?this._while.clone():this._while)),this._while.hasBackReferences&&this._cachedCompiledWhilePatterns.setSource(0,t||"￿"),this._cachedCompiledWhilePatterns}},WOe=class xc{static createCaptureRule(e,t,i,s,r){return e.registerRule(o=>new pwt(t,o,i,s,r))}static getCompiledRuleId(e,t,i){return e.id||t.registerRule(s=>{if(e.id=s,e.match)return new Cwt(e.$vscodeTextmateLocation,e.id,e.name,e.match,xc._compileCaptures(e.captures,t,i));if(typeof e.begin>"u"){e.repository&&(i=TOe({},i,e.repository));let r=e.patterns;return typeof r>"u"&&e.include&&(r=[{include:e.include}]),new R8e(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,xc._compilePatterns(r,t,i))}return e.while?new RO(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,e.begin,xc._compileCaptures(e.beginCaptures||e.captures,t,i),e.while,xc._compileCaptures(e.whileCaptures||e.captures,t,i),xc._compilePatterns(e.patterns,t,i)):new Pee(e.$vscodeTextmateLocation,e.id,e.name,e.contentName,e.begin,xc._compileCaptures(e.beginCaptures||e.captures,t,i),e.end,xc._compileCaptures(e.endCaptures||e.captures,t,i),e.applyEndPatternLast,xc._compilePatterns(e.patterns,t,i))}),e.id}static _compileCaptures(e,t,i){let s=[];if(e){let r=0;for(const o in e){if(o==="$vscodeTextmateLocation")continue;const a=parseInt(o,10);a>r&&(r=a)}for(let o=0;o<=r;o++)s[o]=null;for(const o in e){if(o==="$vscodeTextmateLocation")continue;const a=parseInt(o,10);let l=0;e[o].patterns&&(l=xc.getCompiledRuleId(e[o],t,i)),s[a]=xc.createCaptureRule(t,e[o].$vscodeTextmateLocation,e[o].name,e[o].contentName,l)}}return s}static _compilePatterns(e,t,i){let s=[];if(e)for(let r=0,o=e.length;r<o;r++){const a=e[r];let l=-1;if(a.include){const c=VOe(a.include);switch(c.kind){case 0:case 1:l=xc.getCompiledRuleId(i[a.include],t,i);break;case 2:let d=i[c.ruleName];d&&(l=xc.getCompiledRuleId(d,t,i));break;case 3:case 4:const u=c.scopeName,h=c.kind===4?c.ruleName:null,f=t.getExternalGrammar(u,i);if(f)if(h){let g=f.repository[h];g&&(l=xc.getCompiledRuleId(g,t,f.repository))}else l=xc.getCompiledRuleId(f.repository.$self,t,f.repository);break}}else l=xc.getCompiledRuleId(a,t,i);if(l!==-1){const c=t.getRule(l);let d=!1;if((c instanceof R8e||c instanceof Pee||c instanceof RO)&&c.hasMissingPatterns&&c.patterns.length===0&&(d=!0),d)continue;s.push(l)}}return{patterns:s,hasMissingPatterns:(e?e.length:0)!==s.length}}},sE=class zOe{constructor(e,t){dt(this,"source");dt(this,"ruleId");dt(this,"hasAnchor");dt(this,"hasBackReferences");dt(this,"_anchorCache");if(e&&typeof e=="string"){const i=e.length;let s=0,r=[],o=!1;for(let a=0;a<i;a++)if(e.charAt(a)==="\\"&&a+1<i){const c=e.charAt(a+1);c==="z"?(r.push(e.substring(s,a)),r.push("$(?!\\n)(?<!\\n)"),s=a+2):(c==="A"||c==="G")&&(o=!0),a++}this.hasAnchor=o,s===0?this.source=e:(r.push(e.substring(s,i)),this.source=r.join(""))}else this.hasAnchor=!1,this.source=e;this.hasAnchor?this._anchorCache=this._buildAnchorCache():this._anchorCache=null,this.ruleId=t,typeof this.source=="string"?this.hasBackReferences=gwt.test(this.source):this.hasBackReferences=!1}clone(){return new zOe(this.source,this.ruleId)}setSource(e){this.source!==e&&(this.source=e,this.hasAnchor&&(this._anchorCache=this._buildAnchorCache()))}resolveBackReferences(e,t){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let i=t.map(s=>e.substring(s.start,s.end));return T8e.lastIndex=0,this.source.replace(T8e,(s,r)=>OOe(i[parseInt(r,10)]||""))}_buildAnchorCache(){if(typeof this.source!="string")throw new Error("This method should only be called if the source is a string");let e=[],t=[],i=[],s=[],r,o,a,l;for(r=0,o=this.source.length;r<o;r++)a=this.source.charAt(r),e[r]=a,t[r]=a,i[r]=a,s[r]=a,a==="\\"&&r+1<o&&(l=this.source.charAt(r+1),l==="A"?(e[r+1]="￿",t[r+1]="￿",i[r+1]="A",s[r+1]="A"):l==="G"?(e[r+1]="￿",t[r+1]="G",i[r+1]="￿",s[r+1]="G"):(e[r+1]=l,t[r+1]=l,i[r+1]=l,s[r+1]=l),r++);return{A0_G0:e.join(""),A0_G1:t.join(""),A1_G0:i.join(""),A1_G1:s.join("")}}resolveAnchors(e,t){return!this.hasAnchor||!this._anchorCache||typeof this.source!="string"?this.source:e?t?this._anchorCache.A1_G1:this._anchorCache.A1_G0:t?this._anchorCache.A0_G1:this._anchorCache.A0_G0}},rE=class{constructor(){dt(this,"_items");dt(this,"_hasAnchors");dt(this,"_cached");dt(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(n){this._items.push(n),this._hasAnchors=this._hasAnchors||n.hasAnchor}unshift(n){this._items.unshift(n),this._hasAnchors=this._hasAnchors||n.hasAnchor}length(){return this._items.length}setSource(n,e){this._items[n].source!==e&&(this._disposeCaches(),this._items[n].setSource(e))}compile(n){if(!this._cached){let e=this._items.map(t=>t.source);this._cached=new P8e(n,e,this._items.map(t=>t.ruleId))}return this._cached}compileAG(n,e,t){return this._hasAnchors?e?t?(this._anchorCache.A1_G1||(this._anchorCache.A1_G1=this._resolveAnchors(n,e,t)),this._anchorCache.A1_G1):(this._anchorCache.A1_G0||(this._anchorCache.A1_G0=this._resolveAnchors(n,e,t)),this._anchorCache.A1_G0):t?(this._anchorCache.A0_G1||(this._anchorCache.A0_G1=this._resolveAnchors(n,e,t)),this._anchorCache.A0_G1):(this._anchorCache.A0_G0||(this._anchorCache.A0_G0=this._resolveAnchors(n,e,t)),this._anchorCache.A0_G0):this.compile(n)}_resolveAnchors(n,e,t){let i=this._items.map(s=>s.resolveAnchors(e,t));return new P8e(n,i,this._items.map(s=>s.ruleId))}},P8e=class{constructor(n,e,t){dt(this,"scanner");this.regExps=e,this.rules=t,this.scanner=n.createOnigScanner(e)}dispose(){typeof this.scanner.dispose=="function"&&this.scanner.dispose()}toString(){const n=[];for(let e=0,t=this.rules.length;e<t;e++)n.push(" - "+this.rules[e]+": "+this.regExps[e]);return n.join(`
525
525
  `)}findNextMatchSync(n,e,t){const i=this.scanner.findNextMatchSync(n,e,t);return i?{ruleId:this.rules[i.index],captureIndices:i.captureIndices}:null}},uq=class{constructor(n,e){this.languageId=n,this.tokenType=e}},R2,_wt=(R2=class{constructor(e,t){dt(this,"_defaultAttributes");dt(this,"_embeddedLanguagesMatcher");dt(this,"_getBasicScopeAttributes",new FOe(e=>{const t=this._scopeToLanguage(e),i=this._toStandardTokenType(e);return new uq(t,i)}));this._defaultAttributes=new uq(e,8),this._embeddedLanguagesMatcher=new vwt(Object.entries(t||{}))}getDefaultAttributes(){return this._defaultAttributes}getBasicScopeAttributes(e){return e===null?R2._NULL_SCOPE_METADATA:this._getBasicScopeAttributes.get(e)}_scopeToLanguage(e){return this._embeddedLanguagesMatcher.match(e)||0}_toStandardTokenType(e){const t=e.match(R2.STANDARD_TOKEN_TYPE_REGEXP);if(!t)return 8;switch(t[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!")}},dt(R2,"_NULL_SCOPE_METADATA",new uq(0,0)),dt(R2,"STANDARD_TOKEN_TYPE_REGEXP",/\b(comment|string|regex|meta\.embedded)\b/),R2),vwt=class{constructor(n){dt(this,"values");dt(this,"scopesRegExp");if(n.length===0)this.values=null,this.scopesRegExp=null;else{this.values=new Map(n);const e=n.map(([t,i])=>OOe(t));e.sort(),e.reverse(),this.scopesRegExp=new RegExp(`^((${e.join(")|(")}))($|\\.)`,"")}}match(n){if(!this.scopesRegExp)return;const e=n.match(this.scopesRegExp);if(e)return this.values.get(e[1])}},A8e=class{constructor(n,e){this.stack=n,this.stoppedEarly=e}};function UOe(n,e,t,i,s,r,o,a){const l=e.content.length;let c=!1,d=-1;if(o){const f=bwt(n,e,t,i,s,r);s=f.stack,i=f.linePos,t=f.isFirstLine,d=f.anchorPosition}const u=Date.now();for(;!c;){if(a!==0&&Date.now()-u>a)return new A8e(s,!0);h()}return new A8e(s,!1);function h(){const f=ywt(n,e,t,i,s,d);if(!f){r.produce(s,l),c=!0;return}const g=f.captureIndices,m=f.matchedRuleId,p=g&&g.length>0?g[0].end>i:!1;if(m===mwt){const _=s.getRule(n);r.produce(s,g[0].start),s=s.withContentNameScopesList(s.nameScopesList),ix(n,e,t,s,r,_.endCaptures,g),r.produce(s,g[0].end);const b=s;if(s=s.parent,d=b.getAnchorPos(),!p&&b.getEnterPos()===i){s=b,r.produce(s,l),c=!0;return}}else{const _=n.getRule(m);r.produce(s,g[0].start);const b=s,y=_.getName(e.content,g),w=s.contentNameScopesList.pushAttributed(y,n);if(s=s.push(m,i,d,g[0].end===l,null,w,w),_ instanceof Pee){const S=_;ix(n,e,t,s,r,S.beginCaptures,g),r.produce(s,g[0].end),d=g[0].end;const x=S.getContentName(e.content,g),L=w.pushAttributed(x,n);if(s=s.withContentNameScopesList(L),S.endHasBackReferences&&(s=s.withEndRule(S.getEndWithResolvedBackReferences(e.content,g))),!p&&b.hasSameRuleAs(s)){s=s.pop(),r.produce(s,l),c=!0;return}}else if(_ instanceof RO){const S=_;ix(n,e,t,s,r,S.beginCaptures,g),r.produce(s,g[0].end),d=g[0].end;const x=S.getContentName(e.content,g),L=w.pushAttributed(x,n);if(s=s.withContentNameScopesList(L),S.whileHasBackReferences&&(s=s.withEndRule(S.getWhileWithResolvedBackReferences(e.content,g))),!p&&b.hasSameRuleAs(s)){s=s.pop(),r.produce(s,l),c=!0;return}}else if(ix(n,e,t,s,r,_.captures,g),r.produce(s,g[0].end),s=s.pop(),!p){s=s.safePop(),r.produce(s,l),c=!0;return}}g[0].end>i&&(i=g[0].end,t=!1)}}function bwt(n,e,t,i,s,r){let o=s.beginRuleCapturedEOL?0:-1;const a=[];for(let l=s;l;l=l.pop()){const c=l.getRule(n);c instanceof RO&&a.push({rule:c,stack:l})}for(let l=a.pop();l;l=a.pop()){const{ruleScanner:c,findOptions:d}=xwt(l.rule,n,l.stack.endRule,t,i===o),u=c.findNextMatchSync(e,i,d);if(u){if(u.ruleId!==jOe){s=l.stack.pop();break}u.captureIndices&&u.captureIndices.length&&(r.produce(l.stack,u.captureIndices[0].start),ix(n,e,t,l.stack,r,l.rule.whileCaptures,u.captureIndices),r.produce(l.stack,u.captureIndices[0].end),o=u.captureIndices[0].end,u.captureIndices[0].end>i&&(i=u.captureIndices[0].end,t=!1))}else{s=l.stack.pop();break}}return{stack:s,linePos:i,anchorPosition:o,isFirstLine:t}}function ywt(n,e,t,i,s,r){const o=wwt(n,e,t,i,s,r),a=n.getInjections();if(a.length===0)return o;const l=Swt(a,n,e,t,i,s,r);if(!l)return o;if(!o)return l;const c=o.captureIndices[0].start,d=l.captureIndices[0].start;return d<c||l.priorityMatch&&d===c?l:o}function wwt(n,e,t,i,s,r){const o=s.getRule(n),{ruleScanner:a,findOptions:l}=KOe(o,n,s.endRule,t,i===r),c=a.findNextMatchSync(e,i,l);return c?{captureIndices:c.captureIndices,matchedRuleId:c.ruleId}:null}function Swt(n,e,t,i,s,r,o){let a=Number.MAX_VALUE,l=null,c,d=0;const u=r.contentNameScopesList.getScopeNames();for(let h=0,f=n.length;h<f;h++){const g=n[h];if(!g.matcher(u))continue;const m=e.getRule(g.ruleId),{ruleScanner:p,findOptions:_}=KOe(m,e,null,i,s===o),b=p.findNextMatchSync(t,s,_);if(!b)continue;const y=b.captureIndices[0].start;if(!(y>=a)&&(a=y,l=b.captureIndices,c=b.ruleId,d=g.priority,a===s))break}return l?{priorityMatch:d===-1,captureIndices:l,matchedRuleId:c}:null}function KOe(n,e,t,i,s){return{ruleScanner:n.compileAG(e,t,i,s),findOptions:0}}function xwt(n,e,t,i,s){return{ruleScanner:n.compileWhileAG(e,t,i,s),findOptions:0}}function ix(n,e,t,i,s,r,o){if(r.length===0)return;const a=e.content,l=Math.min(r.length,o.length),c=[],d=o[0].end;for(let u=0;u<l;u++){const h=r[u];if(h===null)continue;const f=o[u];if(f.length===0)continue;if(f.start>d)break;for(;c.length>0&&c[c.length-1].endPos<=f.start;)s.produceFromScopes(c[c.length-1].scopes,c[c.length-1].endPos),c.pop();if(c.length>0?s.produceFromScopes(c[c.length-1].scopes,f.start):s.produce(i,f.start),h.retokenizeCapturedWithRuleId){const m=h.getName(a,o),p=i.contentNameScopesList.pushAttributed(m,n),_=h.getContentName(a,o),b=p.pushAttributed(_,n),y=i.push(h.retokenizeCapturedWithRuleId,f.start,-1,!1,null,p,b),w=n.createOnigString(a.substring(0,f.end));UOe(n,w,t&&f.start===0,f.start,y,s,!1,0),HOe(w);continue}const g=h.getName(a,o);if(g!==null){const p=(c.length>0?c[c.length-1].scopes:i.contentNameScopesList).pushAttributed(g,n);c.push(new Lwt(p,f.end))}}for(;c.length>0;)s.produceFromScopes(c[c.length-1].scopes,c[c.length-1].endPos),c.pop()}var Lwt=class{constructor(n,e){dt(this,"scopes");dt(this,"endPos");this.scopes=n,this.endPos=e}};function kwt(n,e,t,i,s,r,o,a){return new Iwt(n,e,t,i,s,r,o,a)}function O8e(n,e,t,i,s){const r=DO(e,PO),o=WOe.getCompiledRuleId(t,i,s.repository);for(const a of r)n.push({debugSelector:e,matcher:a.matcher,ruleId:o,grammar:s,priority:a.priority})}function PO(n,e){if(e.length<n.length)return!1;let t=0;return n.every(i=>{for(let s=t;s<e.length;s++)if(Ewt(e[s],i))return t=s+1,!0;return!1})}function Ewt(n,e){if(!n)return!1;if(n===e)return!0;const t=e.length;return n.length>t&&n.substr(0,t)===e&&n[t]==="."}var Iwt=class{constructor(n,e,t,i,s,r,o,a){dt(this,"_rootId");dt(this,"_lastRuleId");dt(this,"_ruleId2desc");dt(this,"_includedGrammars");dt(this,"_grammarRepository");dt(this,"_grammar");dt(this,"_injections");dt(this,"_basicScopeAttributesProvider");dt(this,"_tokenTypeMatchers");if(this._rootScopeName=n,this.balancedBracketSelectors=r,this._onigLib=a,this._basicScopeAttributesProvider=new _wt(t,i),this._rootId=-1,this._lastRuleId=0,this._ruleId2desc=[null],this._includedGrammars={},this._grammarRepository=o,this._grammar=F8e(e,null),this._injections=null,this._tokenTypeMatchers=[],s)for(const l of Object.keys(s)){const c=DO(l,PO);for(const d of c)this._tokenTypeMatchers.push({matcher:d.matcher,type:s[l]})}}get themeProvider(){return this._grammarRepository}dispose(){for(const n of this._ruleId2desc)n&&n.dispose()}createOnigScanner(n){return this._onigLib.createOnigScanner(n)}createOnigString(n){return this._onigLib.createOnigString(n)}getMetadataForScope(n){return this._basicScopeAttributesProvider.getBasicScopeAttributes(n)}_collectInjections(){const n={lookup:s=>s===this._rootScopeName?this._grammar:this.getExternalGrammar(s),injections:s=>this._grammarRepository.injections(s)},e=[],t=this._rootScopeName,i=n.lookup(t);if(i){const s=i.injections;if(s)for(let o in s)O8e(e,o,s[o],this,i);const r=this._grammarRepository.injections(t);r&&r.forEach(o=>{const a=this.getExternalGrammar(o);if(a){const l=a.injectionSelector;l&&O8e(e,l,a,this,a)}})}return e.sort((s,r)=>s.priority-r.priority),e}getInjections(){return this._injections===null&&(this._injections=this._collectInjections()),this._injections}registerRule(n){const e=++this._lastRuleId,t=n(e);return this._ruleId2desc[e]=t,t}getRule(n){return this._ruleId2desc[n]}getExternalGrammar(n,e){if(this._includedGrammars[n])return this._includedGrammars[n];if(this._grammarRepository){const t=this._grammarRepository.lookup(n);if(t)return this._includedGrammars[n]=F8e(t,e&&e.$base),this._includedGrammars[n]}}tokenizeLine(n,e,t=0){const i=this._tokenize(n,e,!1,t);return{tokens:i.lineTokens.getResult(i.ruleStack,i.lineLength),ruleStack:i.ruleStack,stoppedEarly:i.stoppedEarly}}tokenizeLine2(n,e,t=0){const i=this._tokenize(n,e,!0,t);return{tokens:i.lineTokens.getBinaryResult(i.ruleStack,i.lineLength),ruleStack:i.ruleStack,stoppedEarly:i.stoppedEarly}}_tokenize(n,e,t,i){this._rootId===-1&&(this._rootId=WOe.getCompiledRuleId(this._grammar.repository.$self,this,this._grammar.repository),this.getInjections());let s;if(!e||e===Aee.NULL){s=!0;const c=this._basicScopeAttributesProvider.getDefaultAttributes(),d=this.themeProvider.getDefaults(),u=$b.set(0,c.languageId,c.tokenType,null,d.fontStyle,d.foregroundId,d.backgroundId),h=this.getRule(this._rootId).getName(null,null);let f;h?f=Gx.createRootAndLookUpScopeName(h,u,this):f=Gx.createRoot("unknown",u),e=new Aee(null,this._rootId,-1,-1,!1,null,f,f)}else s=!1,e.reset();n=n+`
526
526
  `;const r=this.createOnigString(n),o=r.content.length,a=new Nwt(t,n,this._tokenTypeMatchers,this.balancedBracketSelectors),l=UOe(this,r,s,0,e,a,!0,i);return HOe(r),{lineLength:o,lineTokens:a,ruleStack:l.stack,stoppedEarly:l.stoppedEarly}}};function F8e(n,e){return n=Zyt(n),n.repository=n.repository||{},n.repository.$self={$vscodeTextmateLocation:n.$vscodeTextmateLocation,patterns:n.patterns,name:n.scopeName},n.repository.$base=e||n.repository.$self,n}var Gx=class c6{constructor(e,t,i){this.parent=e,this.scopePath=t,this.tokenAttributes=i}static fromExtension(e,t){let i=e,s=(e==null?void 0:e.scopePath)??null;for(const r of t)s=dq.push(s,r.scopeNames),i=new c6(i,s,r.encodedTokenAttributes);return i}static createRoot(e,t){return new c6(null,new dq(null,e),t)}static createRootAndLookUpScopeName(e,t,i){const s=i.getMetadataForScope(e),r=new dq(null,e),o=i.themeProvider.themeMatch(r),a=c6.mergeAttributes(t,s,o);return new c6(null,r,a)}get scopeName(){return this.scopePath.scopeName}toString(){return this.getScopeNames().join(" ")}equals(e){return c6.equals(this,e)}static equals(e,t){do{if(e===t||!e&&!t)return!0;if(!e||!t||e.scopeName!==t.scopeName||e.tokenAttributes!==t.tokenAttributes)return!1;e=e.parent,t=t.parent}while(!0)}static mergeAttributes(e,t,i){let s=-1,r=0,o=0;return i!==null&&(s=i.fontStyle,r=i.foregroundId,o=i.backgroundId),$b.set(e,t.languageId,t.tokenType,null,s,r,o)}pushAttributed(e,t){if(e===null)return this;if(e.indexOf(" ")===-1)return c6._pushAttributed(this,e,t);const i=e.split(/ /g);let s=this;for(const r of i)s=c6._pushAttributed(s,r,t);return s}static _pushAttributed(e,t,i){const s=i.getMetadataForScope(t),r=e.scopePath.push(t),o=i.themeProvider.themeMatch(r),a=c6.mergeAttributes(e.tokenAttributes,s,o);return new c6(e,r,a)}getScopeNames(){return this.scopePath.getSegments()}getExtensionIfDefined(e){var s;const t=[];let i=this;for(;i&&i!==e;)t.push({encodedTokenAttributes:i.tokenAttributes,scopeNames:i.scopePath.getExtensionIfDefined(((s=i.parent)==null?void 0:s.scopePath)??null)}),i=i.parent;return i===e?t.reverse():void 0}},ah,Aee=(ah=class{constructor(e,t,i,s,r,o,a,l){dt(this,"_stackElementBrand");dt(this,"_enterPos");dt(this,"_anchorPos");dt(this,"depth");this.parent=e,this.ruleId=t,this.beginRuleCapturedEOL=r,this.endRule=o,this.nameScopesList=a,this.contentNameScopesList=l,this.depth=this.parent?this.parent.depth+1:1,this._enterPos=i,this._anchorPos=s}equals(e){return e===null?!1:ah._equals(this,e)}static _equals(e,t){return e===t?!0:this._structuralEquals(e,t)?Gx.equals(e.contentNameScopesList,t.contentNameScopesList):!1}static _structuralEquals(e,t){do{if(e===t||!e&&!t)return!0;if(!e||!t||e.depth!==t.depth||e.ruleId!==t.ruleId||e.endRule!==t.endRule)return!1;e=e.parent,t=t.parent}while(!0)}clone(){return this}static _reset(e){for(;e;)e._enterPos=-1,e._anchorPos=-1,e=e.parent}reset(){ah._reset(this)}pop(){return this.parent}safePop(){return this.parent?this.parent:this}push(e,t,i,s,r,o,a){return new ah(this,e,t,i,s,r,o,a)}getEnterPos(){return this._enterPos}getAnchorPos(){return this._anchorPos}getRule(e){return e.getRule(this.ruleId)}toString(){const e=[];return this._writeString(e,0),"["+e.join(",")+"]"}_writeString(e,t){var i,s;return this.parent&&(t=this.parent._writeString(e,t)),e[t++]=`(${this.ruleId}, ${(i=this.nameScopesList)==null?void 0:i.toString()}, ${(s=this.contentNameScopesList)==null?void 0:s.toString()})`,t}withContentNameScopesList(e){return this.contentNameScopesList===e?this:this.parent.push(this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,this.endRule,this.nameScopesList,e)}withEndRule(e){return this.endRule===e?this:new ah(this.parent,this.ruleId,this._enterPos,this._anchorPos,this.beginRuleCapturedEOL,e,this.nameScopesList,this.contentNameScopesList)}hasSameRuleAs(e){let t=this;for(;t&&t._enterPos===e._enterPos;){if(t.ruleId===e.ruleId)return!0;t=t.parent}return!1}toStateStackFrame(){var e,t,i;return{ruleId:this.ruleId,beginRuleCapturedEOL:this.beginRuleCapturedEOL,endRule:this.endRule,nameScopesList:((t=this.nameScopesList)==null?void 0:t.getExtensionIfDefined(((e=this.parent)==null?void 0:e.nameScopesList)??null))??[],contentNameScopesList:((i=this.contentNameScopesList)==null?void 0:i.getExtensionIfDefined(this.nameScopesList))??[]}}static pushFrame(e,t){const i=Gx.fromExtension((e==null?void 0:e.nameScopesList)??null,t.nameScopesList);return new ah(e,t.ruleId,t.enterPos??-1,t.anchorPos??-1,t.beginRuleCapturedEOL,t.endRule,i,Gx.fromExtension(i,t.contentNameScopesList))}},dt(ah,"NULL",new ah(null,0,0,0,!1,null,null,null)),ah),Mwt=class{constructor(n,e){dt(this,"balancedBracketScopes");dt(this,"unbalancedBracketScopes");dt(this,"allowAny",!1);this.balancedBracketScopes=n.flatMap(t=>t==="*"?(this.allowAny=!0,[]):DO(t,PO).map(i=>i.matcher)),this.unbalancedBracketScopes=e.flatMap(t=>DO(t,PO).map(i=>i.matcher))}get matchesAlways(){return this.allowAny&&this.unbalancedBracketScopes.length===0}get matchesNever(){return this.balancedBracketScopes.length===0&&!this.allowAny}match(n){for(const e of this.unbalancedBracketScopes)if(e(n))return!1;for(const e of this.balancedBracketScopes)if(e(n))return!0;return this.allowAny}},Nwt=class{constructor(e,t,i,s){dt(this,"_emitBinaryTokens");dt(this,"_lineText");dt(this,"_tokens");dt(this,"_binaryTokens");dt(this,"_lastTokenEndIndex");dt(this,"_tokenTypeOverrides");this.balancedBracketSelectors=s,this._emitBinaryTokens=e,this._tokenTypeOverrides=i,this._lineText=null,this._tokens=[],this._binaryTokens=[],this._lastTokenEndIndex=0}produce(e,t){this.produceFromScopes(e.contentNameScopesList,t)}produceFromScopes(e,t){var s;if(this._lastTokenEndIndex>=t)return;if(this._emitBinaryTokens){let r=(e==null?void 0:e.tokenAttributes)??0,o=!1;if((s=this.balancedBracketSelectors)!=null&&s.matchesAlways&&(o=!0),this._tokenTypeOverrides.length>0||this.balancedBracketSelectors&&!this.balancedBracketSelectors.matchesAlways&&!this.balancedBracketSelectors.matchesNever){const a=(e==null?void 0:e.getScopeNames())??[];for(const l of this._tokenTypeOverrides)l.matcher(a)&&(r=$b.set(r,0,l.type,null,-1,0,0));this.balancedBracketSelectors&&(o=this.balancedBracketSelectors.match(a))}if(o&&(r=$b.set(r,0,8,o,-1,0,0)),this._binaryTokens.length>0&&this._binaryTokens[this._binaryTokens.length-1]===r){this._lastTokenEndIndex=t;return}this._binaryTokens.push(this._lastTokenEndIndex),this._binaryTokens.push(r),this._lastTokenEndIndex=t;return}const i=(e==null?void 0:e.getScopeNames())??[];this._tokens.push({startIndex:this._lastTokenEndIndex,endIndex:t,scopes:i}),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 i=new Uint32Array(this._binaryTokens.length);for(let s=0,r=this._binaryTokens.length;s<r;s++)i[s]=this._binaryTokens[s];return i}},Dwt=class{constructor(n,e){dt(this,"_grammars",new Map);dt(this,"_rawGrammars",new Map);dt(this,"_injectionGrammars",new Map);dt(this,"_theme");this._onigLib=e,this._theme=n}dispose(){for(const n of this._grammars.values())n.dispose()}setTheme(n){this._theme=n}getColorMap(){return this._theme.getColorMap()}addGrammar(n,e){this._rawGrammars.set(n.scopeName,n),e&&this._injectionGrammars.set(n.scopeName,e)}lookup(n){return this._rawGrammars.get(n)}injections(n){return this._injectionGrammars.get(n)}getDefaults(){return this._theme.getDefaults()}themeMatch(n){return this._theme.match(n)}grammarForScopeName(n,e,t,i,s){if(!this._grammars.has(n)){let r=this._rawGrammars.get(n);if(!r)return null;this._grammars.set(n,kwt(n,r,e,t,i,s,this,this._onigLib))}return this._grammars.get(n)}},Twt=class{constructor(e){dt(this,"_options");dt(this,"_syncRegistry");dt(this,"_ensureGrammarCache");this._options=e,this._syncRegistry=new Dwt(NO.createFromRawTheme(e.theme,e.colorMap),e.onigLib),this._ensureGrammarCache=new Map}dispose(){this._syncRegistry.dispose()}setTheme(e,t){this._syncRegistry.setTheme(NO.createFromRawTheme(e,t))}getColorMap(){return this._syncRegistry.getColorMap()}loadGrammarWithEmbeddedLanguages(e,t,i){return this.loadGrammarWithConfiguration(e,t,{embeddedLanguages:i})}loadGrammarWithConfiguration(e,t,i){return this._loadGrammar(e,t,i.embeddedLanguages,i.tokenTypes,new Mwt(i.balancedBracketSelectors||[],i.unbalancedBracketSelectors||[]))}loadGrammar(e){return this._loadGrammar(e,0,null,null,null)}_loadGrammar(e,t,i,s,r){const o=new awt(this._syncRegistry,e);for(;o.Q.length>0;)o.Q.map(a=>this._loadSingleGrammar(a.scopeName)),o.processQueue();return this._grammarForScopeName(e,t,i,s,r)}_loadSingleGrammar(e){this._ensureGrammarCache.has(e)||(this._doLoadSingleGrammar(e),this._ensureGrammarCache.set(e,!0))}_doLoadSingleGrammar(e){const t=this._options.loadGrammar(e);if(t){const i=typeof this._options.getInjections=="function"?this._options.getInjections(e):void 0;this._syncRegistry.addGrammar(t,i)}}addGrammar(e,t=[],i=0,s=null){return this._syncRegistry.addGrammar(e,t),this._grammarForScopeName(e.scopeName,i,s)}_grammarForScopeName(e,t=0,i=null,s=null,r=null){return this._syncRegistry.grammarForScopeName(e,t,i,s,r)}},Oee=Aee.NULL;const Rwt=["area","base","basefont","bgsound","br","col","command","embed","frame","hr","image","img","input","keygen","link","meta","param","source","track","wbr"];class qM{constructor(e,t,i){this.normal=t,this.property=e,i&&(this.space=i)}}qM.prototype.normal={};qM.prototype.property={};qM.prototype.space=void 0;function ZOe(n,e){const t={},i={};for(const s of n)Object.assign(t,s.property),Object.assign(i,s.normal);return new qM(t,i,e)}function Fee(n){return n.toLowerCase()}class Mu{constructor(e,t){this.attribute=t,this.property=e}}Mu.prototype.attribute="";Mu.prototype.booleanish=!1;Mu.prototype.boolean=!1;Mu.prototype.commaOrSpaceSeparated=!1;Mu.prototype.commaSeparated=!1;Mu.prototype.defined=!1;Mu.prototype.mustUseProperty=!1;Mu.prototype.number=!1;Mu.prototype.overloadedBoolean=!1;Mu.prototype.property="";Mu.prototype.spaceSeparated=!1;Mu.prototype.space=void 0;let Pwt=0;const Ki=xC(),Ca=xC(),Bee=xC(),Xt=xC(),Vr=xC(),yv=xC(),Hu=xC();function xC(){return 2**++Pwt}const $ee=Object.freeze(Object.defineProperty({__proto__:null,boolean:Ki,booleanish:Ca,commaOrSpaceSeparated:Hu,commaSeparated:yv,number:Xt,overloadedBoolean:Bee,spaceSeparated:Vr},Symbol.toStringTag,{value:"Module"})),hq=Object.keys($ee);class che extends Mu{constructor(e,t,i,s){let r=-1;if(super(e,t),B8e(this,"space",s),typeof i=="number")for(;++r<hq.length;){const o=hq[r];B8e(this,hq[r],(i&$ee[o])===$ee[o])}}}che.prototype.defined=!0;function B8e(n,e,t){t&&(n[e]=t)}function nw(n){const e={},t={};for(const[i,s]of Object.entries(n.properties)){const r=new che(i,n.transform(n.attributes||{},i),s,n.space);n.mustUseProperty&&n.mustUseProperty.includes(i)&&(r.mustUseProperty=!0),e[i]=r,t[Fee(i)]=i,t[Fee(r.attribute)]=i}return new qM(e,t,n.space)}const qOe=nw({properties:{ariaActiveDescendant:null,ariaAtomic:Ca,ariaAutoComplete:null,ariaBusy:Ca,ariaChecked:Ca,ariaColCount:Xt,ariaColIndex:Xt,ariaColSpan:Xt,ariaControls:Vr,ariaCurrent:null,ariaDescribedBy:Vr,ariaDetails:null,ariaDisabled:Ca,ariaDropEffect:Vr,ariaErrorMessage:null,ariaExpanded:Ca,ariaFlowTo:Vr,ariaGrabbed:Ca,ariaHasPopup:null,ariaHidden:Ca,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Vr,ariaLevel:Xt,ariaLive:null,ariaModal:Ca,ariaMultiLine:Ca,ariaMultiSelectable:Ca,ariaOrientation:null,ariaOwns:Vr,ariaPlaceholder:null,ariaPosInSet:Xt,ariaPressed:Ca,ariaReadOnly:Ca,ariaRelevant:null,ariaRequired:Ca,ariaRoleDescription:Vr,ariaRowCount:Xt,ariaRowIndex:Xt,ariaRowSpan:Xt,ariaSelected:Ca,ariaSetSize:Xt,ariaSort:null,ariaValueMax:Xt,ariaValueMin:Xt,ariaValueNow:Xt,ariaValueText:null,role:null},transform(n,e){return e==="role"?e:"aria-"+e.slice(4).toLowerCase()}});function GOe(n,e){return e in n?n[e]:e}function XOe(n,e){return GOe(n,e.toLowerCase())}const Awt=nw({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:yv,acceptCharset:Vr,accessKey:Vr,action:null,allow:null,allowFullScreen:Ki,allowPaymentRequest:Ki,allowUserMedia:Ki,alt:null,as:null,async:Ki,autoCapitalize:null,autoComplete:Vr,autoFocus:Ki,autoPlay:Ki,blocking:Vr,capture:null,charSet:null,checked:Ki,cite:null,className:Vr,cols:Xt,colSpan:null,content:null,contentEditable:Ca,controls:Ki,controlsList:Vr,coords:Xt|yv,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Ki,defer:Ki,dir:null,dirName:null,disabled:Ki,download:Bee,draggable:Ca,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Ki,formTarget:null,headers:Vr,height:Xt,hidden:Bee,high:Xt,href:null,hrefLang:null,htmlFor:Vr,httpEquiv:Vr,id:null,imageSizes:null,imageSrcSet:null,inert:Ki,inputMode:null,integrity:null,is:null,isMap:Ki,itemId:null,itemProp:Vr,itemRef:Vr,itemScope:Ki,itemType:Vr,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Ki,low:Xt,manifest:null,max:null,maxLength:Xt,media:null,method:null,min:null,minLength:Xt,multiple:Ki,muted:Ki,name:null,nonce:null,noModule:Ki,noValidate:Ki,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:Ki,optimum:Xt,pattern:null,ping:Vr,placeholder:null,playsInline:Ki,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Ki,referrerPolicy:null,rel:Vr,required:Ki,reversed:Ki,rows:Xt,rowSpan:Xt,sandbox:Vr,scope:null,scoped:Ki,seamless:Ki,selected:Ki,shadowRootClonable:Ki,shadowRootDelegatesFocus:Ki,shadowRootMode:null,shape:null,size:Xt,sizes:null,slot:null,span:Xt,spellCheck:Ca,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Xt,step:null,style:null,tabIndex:Xt,target:null,title:null,translate:null,type:null,typeMustMatch:Ki,useMap:null,value:Ca,width:Xt,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Vr,axis:null,background:null,bgColor:null,border:Xt,borderColor:null,bottomMargin:Xt,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Ki,declare:Ki,event:null,face:null,frame:null,frameBorder:null,hSpace:Xt,leftMargin:Xt,link:null,longDesc:null,lowSrc:null,marginHeight:Xt,marginWidth:Xt,noResize:Ki,noHref:Ki,noShade:Ki,noWrap:Ki,object:null,profile:null,prompt:null,rev:null,rightMargin:Xt,rules:null,scheme:null,scrolling:Ca,standby:null,summary:null,text:null,topMargin:Xt,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Xt,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Ki,disableRemotePlayback:Ki,prefix:null,property:null,results:Xt,security:null,unselectable:null},space:"html",transform:XOe}),Owt=nw({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Hu,accentHeight:Xt,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Xt,amplitude:Xt,arabicForm:null,ascent:Xt,attributeName:null,attributeType:null,azimuth:Xt,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Xt,by:null,calcMode:null,capHeight:Xt,className:Vr,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:Xt,diffuseConstant:Xt,direction:null,display:null,dur:null,divisor:Xt,dominantBaseline:null,download:Ki,dx:null,dy:null,edgeMode:null,editable:null,elevation:Xt,enableBackground:null,end:null,event:null,exponent:Xt,externalResourcesRequired:null,fill:null,fillOpacity:Xt,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:yv,g2:yv,glyphName:yv,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Xt,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Xt,horizOriginX:Xt,horizOriginY:Xt,id:null,ideographic:Xt,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Xt,k:Xt,k1:Xt,k2:Xt,k3:Xt,k4:Xt,kernelMatrix:Hu,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Xt,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Xt,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:Xt,overlineThickness:Xt,paintOrder:null,panose1:null,path:null,pathLength:Xt,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Vr,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Xt,pointsAtY:Xt,pointsAtZ:Xt,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Hu,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Hu,rev:Hu,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Hu,requiredFeatures:Hu,requiredFonts:Hu,requiredFormats:Hu,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:Xt,specularExponent:Xt,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Xt,strikethroughThickness:Xt,string:null,stroke:null,strokeDashArray:Hu,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Xt,strokeOpacity:Xt,strokeWidth:null,style:null,surfaceScale:Xt,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Hu,tabIndex:Xt,tableValues:null,target:null,targetX:Xt,targetY:Xt,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Hu,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Xt,underlineThickness:Xt,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Xt,values:null,vAlphabetic:Xt,vMathematical:Xt,vectorEffect:null,vHanging:Xt,vIdeographic:Xt,version:null,vertAdvY:Xt,vertOriginX:Xt,vertOriginY:Xt,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Xt,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:GOe}),YOe=nw({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(n,e){return"xlink:"+e.slice(5).toLowerCase()}}),QOe=nw({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:XOe}),JOe=nw({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(n,e){return"xml:"+e.slice(3).toLowerCase()}}),Fwt={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"},Bwt=/[A-Z]/g,$8e=/-[a-z]/g,$wt=/^data[-\w.:]+$/i;function eFe(n,e){const t=Fee(e);let i=e,s=Mu;if(t in n.normal)return n.property[n.normal[t]];if(t.length>4&&t.slice(0,4)==="data"&&$wt.test(e)){if(e.charAt(4)==="-"){const r=e.slice(5).replace($8e,Vwt);i="data"+r.charAt(0).toUpperCase()+r.slice(1)}else{const r=e.slice(4);if(!$8e.test(r)){let o=r.replace(Bwt,Hwt);o.charAt(0)!=="-"&&(o="-"+o),e="data"+o}}s=che}return new s(i,e)}function Hwt(n){return"-"+n.toLowerCase()}function Vwt(n){return n.charAt(1).toUpperCase()}const tFe=ZOe([qOe,Awt,YOe,QOe,JOe],"html"),GM=ZOe([qOe,Owt,YOe,QOe,JOe],"svg"),H8e={}.hasOwnProperty;function jwt(n,e){const t=e||{};function i(s,...r){let o=i.invalid;const a=i.handlers;if(s&&H8e.call(s,n)){const l=String(s[n]);o=H8e.call(a,l)?a[l]:i.unknown}if(o)return o.call(this,s,...r)}return i.handlers=t.handlers||{},i.invalid=t.invalid,i.unknown=t.unknown,i}const Wwt=/["&'<>`]/g,zwt=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g,Uwt=/[\x01-\t\v\f\x0E-\x1F\x7F\x81\x8D\x8F\x90\x9D\xA0-\uFFFF]/g,Kwt=/[|\\{}()[\]^$+*?.]/g,V8e=new WeakMap;function Zwt(n,e){if(n=n.replace(e.subset?qwt(e.subset):Wwt,i),e.subset||e.escapeOnly)return n;return n.replace(zwt,t).replace(Uwt,i);function t(s,r,o){return e.format((s.charCodeAt(0)-55296)*1024+s.charCodeAt(1)-56320+65536,o.charCodeAt(r+2),e)}function i(s,r,o){return e.format(s.charCodeAt(0),o.charCodeAt(r+1),e)}}function qwt(n){let e=V8e.get(n);return e||(e=Gwt(n),V8e.set(n,e)),e}function Gwt(n){const e=[];let t=-1;for(;++t<n.length;)e.push(n[t].replace(Kwt,"\\$&"));return new RegExp("(?:"+e.join("|")+")","g")}const Xwt=/[\dA-Fa-f]/;function Ywt(n,e,t){const i="&#x"+n.toString(16).toUpperCase();return t&&e&&!Xwt.test(String.fromCharCode(e))?i:i+";"}const Qwt=/\d/;function Jwt(n,e,t){const i="&#"+String(n);return t&&e&&!Qwt.test(String.fromCharCode(e))?i:i+";"}const eSt=["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"],fq={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:"€"},tSt=["cent","copy","divide","gt","lt","not","para","times"],nFe={}.hasOwnProperty,Hee={};let zD;for(zD in fq)nFe.call(fq,zD)&&(Hee[fq[zD]]=zD);const nSt=/[^\dA-Za-z]/;function iSt(n,e,t,i){const s=String.fromCharCode(n);if(nFe.call(Hee,s)){const r=Hee[s],o="&"+r;return t&&eSt.includes(r)&&!tSt.includes(r)&&(!i||e&&e!==61&&nSt.test(String.fromCharCode(e)))?o:o+";"}return""}function sSt(n,e,t){let i=Ywt(n,e,t.omitOptionalSemicolons),s;if((t.useNamedReferences||t.useShortestReferences)&&(s=iSt(n,e,t.omitOptionalSemicolons,t.attribute)),(t.useShortestReferences||!s)&&t.useShortestReferences){const r=Jwt(n,e,t.omitOptionalSemicolons);r.length<i.length&&(i=r)}return s&&(!t.useShortestReferences||s.length<i.length)?s:i}function wv(n,e){return Zwt(n,Object.assign({format:sSt},e))}const rSt=/^>|^->|<!--|-->|--!>|<!-$/g,oSt=[">"],aSt=["<",">"];function lSt(n,e,t,i){return i.settings.bogusComments?"<?"+wv(n.value,Object.assign({},i.settings.characterReferences,{subset:oSt}))+">":"<!--"+n.value.replace(rSt,s)+"-->";function s(r){return wv(r,Object.assign({},i.settings.characterReferences,{subset:aSt}))}}function cSt(n,e,t,i){return"<!"+(i.settings.upperDoctype?"DOCTYPE":"doctype")+(i.settings.tightDoctype?"":" ")+"html>"}function AO(n,e){const t=String(n);if(typeof e!="string")throw new TypeError("Expected character");let i=0,s=t.indexOf(e);for(;s!==-1;)i++,s=t.indexOf(e,s+e.length);return i}function iFe(n,e){const t=e||{};return(n[n.length-1]===""?[...n,""]:n).join((t.padRight?" ":"")+","+(t.padLeft===!1?"":" ")).trim()}function sFe(n){return n.join(" ").trim()}const dSt=/[ \t\n\f\r]/g;function QW(n){return typeof n=="object"?n.type==="text"?j8e(n.value):!1:j8e(n)}function j8e(n){return n.replace(dSt,"")===""}const ol=oFe(1),rFe=oFe(-1),uSt=[];function oFe(n){return e;function e(t,i,s){const r=t?t.children:uSt;let o=(i||0)+n,a=r[o];if(!s)for(;a&&QW(a);)o+=n,a=r[o];return a}}const hSt={}.hasOwnProperty;function aFe(n){return e;function e(t,i,s){return hSt.call(n,t.tagName)&&n[t.tagName](t,i,s)}}const dhe=aFe({body:gSt,caption:gq,colgroup:gq,dd:_St,dt:CSt,head:gq,html:fSt,li:pSt,optgroup:vSt,option:bSt,p:mSt,rp:W8e,rt:W8e,tbody:wSt,td:z8e,tfoot:SSt,th:z8e,thead:ySt,tr:xSt});function gq(n,e,t){const i=ol(t,e,!0);return!i||i.type!=="comment"&&!(i.type==="text"&&QW(i.value.charAt(0)))}function fSt(n,e,t){const i=ol(t,e);return!i||i.type!=="comment"}function gSt(n,e,t){const i=ol(t,e);return!i||i.type!=="comment"}function mSt(n,e,t){const i=ol(t,e);return i?i.type==="element"&&(i.tagName==="address"||i.tagName==="article"||i.tagName==="aside"||i.tagName==="blockquote"||i.tagName==="details"||i.tagName==="div"||i.tagName==="dl"||i.tagName==="fieldset"||i.tagName==="figcaption"||i.tagName==="figure"||i.tagName==="footer"||i.tagName==="form"||i.tagName==="h1"||i.tagName==="h2"||i.tagName==="h3"||i.tagName==="h4"||i.tagName==="h5"||i.tagName==="h6"||i.tagName==="header"||i.tagName==="hgroup"||i.tagName==="hr"||i.tagName==="main"||i.tagName==="menu"||i.tagName==="nav"||i.tagName==="ol"||i.tagName==="p"||i.tagName==="pre"||i.tagName==="section"||i.tagName==="table"||i.tagName==="ul"):!t||!(t.type==="element"&&(t.tagName==="a"||t.tagName==="audio"||t.tagName==="del"||t.tagName==="ins"||t.tagName==="map"||t.tagName==="noscript"||t.tagName==="video"))}function pSt(n,e,t){const i=ol(t,e);return!i||i.type==="element"&&i.tagName==="li"}function CSt(n,e,t){const i=ol(t,e);return!!(i&&i.type==="element"&&(i.tagName==="dt"||i.tagName==="dd"))}function _St(n,e,t){const i=ol(t,e);return!i||i.type==="element"&&(i.tagName==="dt"||i.tagName==="dd")}function W8e(n,e,t){const i=ol(t,e);return!i||i.type==="element"&&(i.tagName==="rp"||i.tagName==="rt")}function vSt(n,e,t){const i=ol(t,e);return!i||i.type==="element"&&i.tagName==="optgroup"}function bSt(n,e,t){const i=ol(t,e);return!i||i.type==="element"&&(i.tagName==="option"||i.tagName==="optgroup")}function ySt(n,e,t){const i=ol(t,e);return!!(i&&i.type==="element"&&(i.tagName==="tbody"||i.tagName==="tfoot"))}function wSt(n,e,t){const i=ol(t,e);return!i||i.type==="element"&&(i.tagName==="tbody"||i.tagName==="tfoot")}function SSt(n,e,t){return!ol(t,e)}function xSt(n,e,t){const i=ol(t,e);return!i||i.type==="element"&&i.tagName==="tr"}function z8e(n,e,t){const i=ol(t,e);return!i||i.type==="element"&&(i.tagName==="td"||i.tagName==="th")}const LSt=aFe({body:ISt,colgroup:MSt,head:ESt,html:kSt,tbody:NSt});function kSt(n){const e=ol(n,-1);return!e||e.type!=="comment"}function ESt(n){const e=new Set;for(const i of n.children)if(i.type==="element"&&(i.tagName==="base"||i.tagName==="title")){if(e.has(i.tagName))return!1;e.add(i.tagName)}const t=n.children[0];return!t||t.type==="element"}function ISt(n){const e=ol(n,-1,!0);return!e||e.type!=="comment"&&!(e.type==="text"&&QW(e.value.charAt(0)))&&!(e.type==="element"&&(e.tagName==="meta"||e.tagName==="link"||e.tagName==="script"||e.tagName==="style"||e.tagName==="template"))}function MSt(n,e,t){const i=rFe(t,e),s=ol(n,-1,!0);return t&&i&&i.type==="element"&&i.tagName==="colgroup"&&dhe(i,t.children.indexOf(i),t)?!1:!!(s&&s.type==="element"&&s.tagName==="col")}function NSt(n,e,t){const i=rFe(t,e),s=ol(n,-1);return t&&i&&i.type==="element"&&(i.tagName==="thead"||i.tagName==="tbody")&&dhe(i,t.children.indexOf(i),t)?!1:!!(s&&s.type==="element"&&s.tagName==="tr")}const UD={name:[[`
527
527
  \f\r &/=>`.split(""),`
@@ -1479,7 +1479,7 @@ ${e.toString()}`}}class dH{constructor(e=new ww,t=!1,i,s=$0n){this._services=e,t
1479
1479
  `:`\r
1480
1480
  `}};Qle=jf([Rr(0,Ln)],Qle);class Y0n{publicLog2(){}}const Ck=class Ck{constructor(){const e=zt.from({scheme:Ck.SCHEME,authority:"model",path:"/"});this.workspace={id:sze,folders:[new ftn({uri:e,name:"",index:0})]}}getWorkspace(){return this.workspace}getWorkspaceFolder(e){return e&&e.scheme===Ck.SCHEME?this.workspace.folders[0]:null}};Ck.SCHEME="inmemory";let Jle=Ck;function hH(n,e,t){if(!e||!(n instanceof uH))return;const i=[];Object.keys(e).forEach(s=>{Dtn(s)&&i.push([`editor.${s}`,e[s]]),t&&Ttn(s)&&i.push([`diffEditor.${s}`,e[s]])}),i.length>0&&n.updateValues(i)}let ece=class{constructor(e){this._modelService=e}hasPreviewHandler(){return!1}async apply(e,t){const i=Array.isArray(e)?e:Q6e.convert(e),s=new Map;for(const a of i){if(!(a instanceof Wg))throw new Error("bad edit - only text edits are supported");const l=this._modelService.getModel(a.resource);if(!l)throw new Error("bad edit - model not found");if(typeof a.versionId=="number"&&l.getVersionId()!==a.versionId)throw new Error("bad state - model changed in the meantime");let c=s.get(l);c||(c=[],s.set(l,c)),c.push(ir.replaceMove(z.lift(a.textEdit.range),a.textEdit.text))}let r=0,o=0;for(const[a,l]of s)a.pushStackElement(),a.pushEditOperations([],l,()=>[]),a.pushStackElement(),o+=1,r+=l.length;return{ariaSummary:A4(Koe.bulkEditServiceSummary,r,o),isApplied:r>0}}};ece=jf([Rr(0,js)],ece);class Q0n{getUriLabel(e,t){return e.scheme==="file"?e.fsPath:e.path}getUriBasenameLabel(e){return y3(e)}}let tce=class extends g2n{constructor(e,t){super(e),this._codeEditorService=t}showContextView(e,t,i){if(!t){const s=this._codeEditorService.getFocusedCodeEditor()||this._codeEditorService.getActiveCodeEditor();s&&(t=s.getContainerDomNode())}return super.showContextView(e,t,i)}};tce=jf([Rr(0,$f),Rr(1,ai)],tce);class J0n{constructor(){this._neverEmitter=new fe,this.onDidChangeTrust=this._neverEmitter.event}isWorkspaceTrusted(){return!0}}class e9n extends ple{constructor(){super()}}class t9n extends z0n{constructor(){super(new aBt)}}let nce=class extends vle{constructor(e,t,i,s,r,o){super(e,t,i,s,r,o),this.configure({blockMouse:!1})}};nce=jf([Rr(0,al),Rr(1,cr),Rr(2,J0),Rr(3,mi),Rr(4,I3),Rr(5,dn)],nce);const n9n={esmModuleLocation:void 0,label:"editorWorkerService"};let ice=class extends sle{constructor(e,t,i,s,r){super(n9n,e,t,i,s,r)}};ice=jf([Rr(0,js),Rr(1,HU),Rr(2,ps),Rr(3,Ws),Rr(4,Nt)],ice);class i9n{async playSignal(e,t){}}Kn(ps,t9n,0);Kn(Ln,uH,0);Kn(HU,Yle,0);Kn(JKe,Qle,0);Kn($0,Jle,0);Kn(oC,Q0n,0);Kn(al,Y0n,0);Kn(jN,G0n,0);Kn(lfe,q0n,0);Kn(cr,Gle,0);Kn(Hf,d5,0);Kn(lr,e9n,0);Kn(Ru,ofn,0);Kn(js,Lle,0);Kn(T1e,xle,0);Kn(dn,Kle,0);Kn(Dje,Z0n,0);Kn(F0,qle,0);Kn(Hl,XJt,0);Kn(Jc,ice,0);Kn(NN,ece,0);Kn(uZe,J0n,0);Kn($l,Zle,0);Kn(oa,jle,0);Kn(T3,srn,0);Kn(Cs,Xle,0);Kn(mi,Ey,0);Kn(il,Hle,0);Kn(J0,tce,0);Kn(e9,Sle,0);Kn(Nd,zle,0);Kn(Tu,nce,0);Kn(I3,kie,0);Kn(Y0,i9n,0);Kn(C6e,U0n,0);Kn(rHe,uBt,0);Kn(Yfe,bln,0);var Cn;(function(n){const e=new ww;for(const[l,c]of o7e())e.set(l,c);const t=new dH(e,!0);e.set(Ft,t);function i(l){s||o({});const c=e.get(l);if(!c)throw new Error("Missing service "+l);return c instanceof R6?t.invokeFunction(d=>d.get(l)):c}n.get=i;let s=!1;const r=new fe;function o(l){if(s)return t;s=!0;for(const[d,u]of o7e())e.get(d)||e.set(d,u);for(const d in l)if(l.hasOwnProperty(d)){const u=An(d);e.get(u)instanceof R6&&e.set(u,l[d])}const c=fnn();for(const d of c)try{t.createInstance(d)}catch(u){pn(u)}return r.fire(),t}n.initialize=o;function a(l){if(s)return l();const c=new Ae,d=c.add(r.event(()=>{d.dispose(),c.add(l())}));return c}n.withServices=a})(Cn||(Cn={}));var s9n=function(n,e,t,i){var s=arguments.length,r=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(n,e,t,i);else for(var a=n.length-1;a>=0;a--)(o=n[a])&&(r=(s<3?o(r):s>3?o(e,t,r):o(e,t))||r);return s>3&&r&&Object.defineProperty(e,t,r),r},OSe=function(n,e){return function(t,i){e(t,i,n)}},lA,f4;let sce=(f4=class{constructor(e,t){this._configurationService=e,this._languageService=t}async renderCodeBlock(e,t,i){var d;const s=j1(i.context)?i.context:void 0;let r;e?r=this._languageService.getLanguageIdByLanguageName(e):s&&(r=(d=s.getModel())==null?void 0:d.getLanguageId()),r||(r=vu);const o=await hGt(this._languageService,t,r),a=lA._ttpTokenizer?lA._ttpTokenizer.createHTML(o)??o:o,l=document.createElement("span");l.innerHTML=a;const c=l.querySelector(".monaco-tokenized-source");return or(c)?(zo(c,this.getFontInfo(s)),l):document.createElement("span")}getFontInfo(e){return e?e.getOption(59):zHt({fontFamily:this._configurationService.getValue("editor").fontFamily},1)}},lA=f4,f4._ttpTokenizer=Ff("tokenizeToString",{createHTML(e){return e}}),f4);sce=lA=s9n([OSe(0,Ln),OSe(1,lr)],sce);var M2e=function(n,e,t,i){var s=arguments.length,r=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(n,e,t,i);else for(var a=n.length-1;a>=0;a--)(o=n[a])&&(r=(s<3?o(r):s>3?o(e,t,r):o(e,t))||r);return s>3&&r&&Object.defineProperty(e,t,r),r},rs=function(n,e){return function(t,i){e(t,i,n)}};let r9n=0,FSe=!1;function o9n(n){if(!n){if(FSe)return;FSe=!0}kFt(n||zi.document.body)}let fH=class extends z4{constructor(e,t,i,s,r,o,a,l,c,d,u,h,f,g){const m={...t};m.ariaLabel=m.ariaLabel||zoe.editorViewAccessibleLabel,super(e,m,{},i,s,r,o,c,d,u,h,f),l instanceof Ey?this._standaloneKeybindingService=l:this._standaloneKeybindingService=null,o9n(m.ariaContainerElement),QGt((p,_)=>i.createInstance(dy,p,{instantHover:_},{})),lQt(a),g.setDefaultCodeBlockRenderer(i.createInstance(sce))}addCommand(e,t,i){if(!this._standaloneKeybindingService)return console.warn("Cannot add command because the editor is configured with an unrecognized KeybindingService"),null;const s="DYNAMIC_"+ ++r9n,r=je.deserialize(i);return this._standaloneKeybindingService.addDynamicKeybinding(s,e,t,r),s}createContextKey(e,t){return this._contextKeyService.createKey(e,t)}addAction(e){if(typeof e.id!="string"||typeof e.label!="string"||typeof e.run!="function")throw new Error("Invalid action descriptor, `id`, `label` and `run` are required properties!");if(!this._standaloneKeybindingService)return console.warn("Cannot add keybinding because the editor is configured with an unrecognized KeybindingService"),pe.None;const t=e.id,i=e.label,s=je.and(je.equals("editorId",this.getId()),je.deserialize(e.precondition)),r=e.keybindings,o=je.and(s,je.deserialize(e.keybindingContext)),a=e.contextMenuGroupId||null,l=e.contextMenuOrder||0,c=(f,...g)=>Promise.resolve(e.run(this,...g)),d=new Ae,u=this.getId()+":"+t;if(d.add(ti.registerCommand(u,c)),a){const f={command:{id:u,title:i},when:s,group:a,order:l};d.add(jo.appendMenuItem(Dt.EditorContext,f))}if(Array.isArray(r))for(const f of r)d.add(this._standaloneKeybindingService.addDynamicKeybinding(u,f,c,o));const h=new tje(u,i,i,void 0,s,(...f)=>Promise.resolve(e.run(this,...f)),this._contextKeyService);return this._actions.set(t,h),d.add(Rt(()=>{this._actions.delete(t)})),d}_triggerCommand(e,t){if(this._codeEditorService instanceof eH)try{this._codeEditorService.setActiveCodeEditor(this),super._triggerCommand(e,t)}finally{this._codeEditorService.setActiveCodeEditor(null)}else super._triggerCommand(e,t)}};fH=M2e([rs(2,Ft),rs(3,ai),rs(4,Cs),rs(5,dn),rs(6,pc),rs(7,mi),rs(8,Qs),rs(9,cr),rs(10,oa),rs(11,Ws),rs(12,Nt),rs(13,Ah)],fH);let rce=class extends fH{constructor(e,t,i,s,r,o,a,l,c,d,u,h,f,g,m,p,_){const b={...t};hH(u,b,!1);const y=c.registerEditorContainer(e);typeof b.theme=="string"&&c.setTheme(b.theme),typeof b.autoDetectHighContrast<"u"&&c.setAutoDetectHighContrast(!!b.autoDetectHighContrast);const w=b.model;delete b.model,super(e,b,i,s,r,o,a,l,c,d,h,m,p,_),this._configurationService=u,this._standaloneThemeService=c,this._register(y);let S;if(typeof w>"u"){const x=g.getLanguageIdByMimeType(b.language)||b.language||vu;S=iqe(f,g,b.value||"",x,void 0),this._ownsModel=!0}else S=w,this._ownsModel=!1;if(this._attachModel(S),S){const x={oldModelUrl:null,newModelUrl:S.uri};this._onDidChangeModel.fire(x)}}dispose(){super.dispose()}updateOptions(e){hH(this._configurationService,e,!1),typeof e.theme=="string"&&this._standaloneThemeService.setTheme(e.theme),typeof e.autoDetectHighContrast<"u"&&this._standaloneThemeService.setAutoDetectHighContrast(!!e.autoDetectHighContrast),super.updateOptions(e)}_postDetachModelCleanup(e){super._postDetachModelCleanup(e),e&&this._ownsModel&&(e.dispose(),this._ownsModel=!1)}};rce=M2e([rs(2,Ft),rs(3,ai),rs(4,Cs),rs(5,dn),rs(6,pc),rs(7,mi),rs(8,Ru),rs(9,cr),rs(10,Ln),rs(11,oa),rs(12,js),rs(13,lr),rs(14,Ws),rs(15,Nt),rs(16,Ah)],rce);let oce=class extends Sf{constructor(e,t,i,s,r,o,a,l,c,d,u,h){const f={...t};hH(l,f,!0);const g=o.registerEditorContainer(e);typeof f.theme=="string"&&o.setTheme(f.theme),typeof f.autoDetectHighContrast<"u"&&o.setAutoDetectHighContrast(!!f.autoDetectHighContrast),super(e,f,{},s,i,r,h,d),this._configurationService=l,this._standaloneThemeService=o,this._register(g)}dispose(){super.dispose()}updateOptions(e){hH(this._configurationService,e,!0),typeof e.theme=="string"&&this._standaloneThemeService.setTheme(e.theme),typeof e.autoDetectHighContrast<"u"&&this._standaloneThemeService.setAutoDetectHighContrast(!!e.autoDetectHighContrast),super.updateOptions(e)}_createInnerEditor(e,t,i){return e.createInstance(fH,t,i)}getOriginalEditor(){return super.getOriginalEditor()}getModifiedEditor(){return super.getModifiedEditor()}addCommand(e,t,i){return this.getModifiedEditor().addCommand(e,t,i)}createContextKey(e,t){return this.getModifiedEditor().createContextKey(e,t)}addAction(e){return this.getModifiedEditor().addAction(e)}};oce=M2e([rs(2,Ft),rs(3,dn),rs(4,ai),rs(5,Ru),rs(6,cr),rs(7,Ln),rs(8,Tu),rs(9,F0),rs(10,Nd),rs(11,Y0)],oce);function iqe(n,e,t,i,s){if(t=t||"",!i){const r=t.indexOf(`
1481
1481
  `);let o=t;return r!==-1&&(o=t.substring(0,r)),BSe(n,t,e.createByFilepathOrFirstLine(s||null,o),s)}return BSe(n,t,e.createById(i),s)}function BSe(n,e,t,i){return n.createModel(e,t,i)}Q("multiDiffEditor.headerBackground",{dark:"#262626",light:"tab.inactiveBackground",hcDark:"tab.inactiveBackground",hcLight:"tab.inactiveBackground"},k(142,"The background color of the diff editor's header"));Q("multiDiffEditor.background",Lr,k(143,"The background color of the multi file diff editor"));Q("multiDiffEditor.border",{dark:"sideBarSectionHeader.border",light:"#cccccc",hcDark:"sideBarSectionHeader.border",hcLight:"#cccccc"},k(144,"The border color of the multi file diff editor"));var a9n=function(n,e,t,i){var s=arguments.length,r=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(n,e,t,i);else for(var a=n.length-1;a>=0;a--)(o=n[a])&&(r=(s<3?o(r):s>3?o(e,t,r):o(e,t))||r);return s>3&&r&&Object.defineProperty(e,t,r),r},$Se=function(n,e){return function(t,i){e(t,i,n)}};class l9n{constructor(e,t){this.viewModel=e,this.deltaScrollVertical=t}getId(){return this.viewModel}}let ace=class extends pe{constructor(e,t,i,s,r){super(),this._container=e,this._overflowWidgetsDomNode=t,this._workbenchUIElementFactory=i,this._instantiationService=s,this._viewModel=cn(this,void 0),this._collapsed=$e(this,l=>{var c;return(c=this._viewModel.read(l))==null?void 0:c.collapsed.read(l)}),this._editorContentHeight=cn(this,500),this.contentHeight=$e(this,l=>(this._collapsed.read(l)?0:this._editorContentHeight.read(l))+this._outerEditorHeight),this._modifiedContentWidth=cn(this,0),this._modifiedWidth=cn(this,0),this._originalContentWidth=cn(this,0),this._originalWidth=cn(this,0),this.maxScroll=$e(this,l=>{const c=this._modifiedContentWidth.read(l)-this._modifiedWidth.read(l),d=this._originalContentWidth.read(l)-this._originalWidth.read(l);return c>d?{maxScroll:c,width:this._modifiedWidth.read(l)}:{maxScroll:d,width:this._originalWidth.read(l)}}),this._elements=ri("div.multiDiffEntry",[ri("div.header@header",[ri("div.header-content",[ri("div.collapse-button@collapseButton"),ri("div.file-path",[ri("div.title.modified.show-file-icons@primaryPath",[]),ri("div.status.deleted@status",["R"]),ri("div.title.original.show-file-icons@secondaryPath",[])]),ri("div.actions@actions")])]),ri("div.editorParent",[ri("div.editorContainer@editor")])]),this.editor=this._register(this._instantiationService.createInstance(Sf,this._elements.editor,{overflowWidgetsDomNode:this._overflowWidgetsDomNode,fixedOverflowWidgets:!0},{})),this.isModifedFocused=Hs(this.editor.getModifiedEditor()).isFocused,this.isOriginalFocused=Hs(this.editor.getOriginalEditor()).isFocused,this.isFocused=$e(this,l=>this.isModifedFocused.read(l)||this.isOriginalFocused.read(l)),this._resourceLabel=this._workbenchUIElementFactory.createResourceLabel?this._register(this._workbenchUIElementFactory.createResourceLabel(this._elements.primaryPath)):void 0,this._resourceLabel2=this._workbenchUIElementFactory.createResourceLabel?this._register(this._workbenchUIElementFactory.createResourceLabel(this._elements.secondaryPath)):void 0,this._dataStore=this._register(new Ae),this._headerHeight=40,this._lastScrollTop=-1,this._isSettingScrollTop=!1;const o=new EB(this._elements.collapseButton,{});this._register(nn(l=>{o.element.className="",o.icon=this._collapsed.read(l)?Ue.chevronRight:Ue.chevronDown})),this._register(o.onDidClick(()=>{var l;(l=this._viewModel.get())==null||l.collapsed.set(!this._collapsed.get(),void 0)})),this._register(nn(l=>{this._elements.editor.style.display=this._collapsed.read(l)?"none":"block"})),this._register(this.editor.getModifiedEditor().onDidLayoutChange(l=>{const c=this.editor.getModifiedEditor().getLayoutInfo().contentWidth;this._modifiedWidth.set(c,void 0)})),this._register(this.editor.getOriginalEditor().onDidLayoutChange(l=>{const c=this.editor.getOriginalEditor().getLayoutInfo().contentWidth;this._originalWidth.set(c,void 0)})),this._register(this.editor.onDidContentSizeChange(l=>{ox(c=>{this._editorContentHeight.set(l.contentHeight,c),this._modifiedContentWidth.set(this.editor.getModifiedEditor().getContentWidth(),c),this._originalContentWidth.set(this.editor.getOriginalEditor().getContentWidth(),c)})})),this._register(this.editor.getOriginalEditor().onDidScrollChange(l=>{if(this._isSettingScrollTop||!l.scrollTopChanged||!this._data)return;const c=l.scrollTop-this._lastScrollTop;this._data.deltaScrollVertical(c)})),this._register(nn(l=>{var d;const c=(d=this._viewModel.read(l))==null?void 0:d.isActive.read(l);this._elements.root.classList.toggle("active",c)})),this._container.appendChild(this._elements.root),this._outerEditorHeight=this._headerHeight,this._contextKeyService=this._register(r.createScoped(this._elements.actions));const a=this._register(this._instantiationService.createChild(new ww([dn,this._contextKeyService])));this._register(a.createInstance(aI,this._elements.actions,Dt.MultiDiffEditorFileToolbar,{actionRunner:this._register(new zWe(()=>{var l,c;return((l=this._viewModel.get())==null?void 0:l.modifiedUri)??((c=this._viewModel.get())==null?void 0:c.originalUri)})),menuOptions:{shouldForwardArgs:!0},toolbarOptions:{primaryGroup:l=>l.startsWith("navigation")},actionViewItemProvider:(l,c)=>X6e(a,l,c)}))}setScrollLeft(e){this._modifiedContentWidth.get()-this._modifiedWidth.get()>this._originalContentWidth.get()-this._originalWidth.get()?this.editor.getModifiedEditor().setScrollLeft(e):this.editor.getOriginalEditor().setScrollLeft(e)}setData(e){this._data=e;function t(s){return{...s,scrollBeyondLastLine:!1,hideUnchangedRegions:{enabled:!0},scrollbar:{vertical:"hidden",horizontal:"hidden",handleMouseWheel:!1,useShadows:!1},renderOverviewRuler:!1,fixedOverflowWidgets:!0,overviewRulerBorder:!1}}if(!e){ox(s=>{this._viewModel.set(void 0,s),this.editor.setDiffModel(null,s),this._dataStore.clear()});return}const i=e.viewModel.documentDiffItem;if(ox(s=>{var c,d;(c=this._resourceLabel)==null||c.setUri(e.viewModel.modifiedUri??e.viewModel.originalUri,{strikethrough:e.viewModel.modifiedUri===void 0});let r=!1,o=!1,a=!1,l="";e.viewModel.modifiedUri&&e.viewModel.originalUri&&e.viewModel.modifiedUri.path!==e.viewModel.originalUri.path?(l="R",r=!0):e.viewModel.modifiedUri?e.viewModel.originalUri||(l="A",a=!0):(l="D",o=!0),this._elements.status.classList.toggle("renamed",r),this._elements.status.classList.toggle("deleted",o),this._elements.status.classList.toggle("added",a),this._elements.status.innerText=l,(d=this._resourceLabel2)==null||d.setUri(r?e.viewModel.originalUri:void 0,{strikethrough:!0}),this._dataStore.clear(),this._viewModel.set(e.viewModel,s),this.editor.setDiffModel(e.viewModel.diffEditorViewModelRef,s),this.editor.updateOptions(t(i.options??{}))}),i.onOptionsDidChange&&this._dataStore.add(i.onOptionsDidChange(()=>{this.editor.updateOptions(t(i.options??{}))})),e.viewModel.isAlive.recomputeInitiallyAndOnChange(this._dataStore,s=>{s||this.setData(void 0)}),e.viewModel.documentDiffItem.contextKeys)for(const[s,r]of Object.entries(e.viewModel.documentDiffItem.contextKeys))this._contextKeyService.createKey(s,r)}render(e,t,i,s){this._elements.root.style.visibility="visible",this._elements.root.style.top=`${e.start}px`,this._elements.root.style.height=`${e.length}px`,this._elements.root.style.width=`${t}px`,this._elements.root.style.position="absolute";const r=e.length-this._headerHeight,o=Math.max(0,Math.min(s.start-e.start,r));this._elements.header.style.transform=`translateY(${o}px)`,ox(a=>{this.editor.layout({width:t-2*8-2*1,height:e.length-this._outerEditorHeight})});try{this._isSettingScrollTop=!0,this._lastScrollTop=i,this.editor.getOriginalEditor().setScrollTop(i)}finally{this._isSettingScrollTop=!1}this._elements.header.classList.toggle("shadow",o>0||i>0),this._elements.header.classList.toggle("collapsed",o===r)}hide(){this._elements.root.style.top="-100000px",this._elements.root.style.visibility="hidden"}};ace=a9n([$Se(3,Ft),$Se(4,dn)],ace);class c9n{constructor(e){this._create=e,this._unused=new Set,this._used=new Set,this._itemData=new Map}getUnusedObj(e){let t;if(this._unused.size===0)t=this._create(e),this._itemData.set(t,e);else{const i=[...this._unused.values()];t=i.find(s=>this._itemData.get(s).getId()===e.getId())??i[0],this._unused.delete(t),this._itemData.set(t,e),t.setData(e)}return this._used.add(t),{object:t,dispose:()=>{this._used.delete(t),this._unused.size>5?t.dispose():this._unused.add(t)}}}dispose(){for(const e of this._used)e.dispose();for(const e of this._unused)e.dispose();this._used.clear(),this._unused.clear()}}var d9n=function(n,e,t,i){var s=arguments.length,r=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(n,e,t,i);else for(var a=n.length-1;a>=0;a--)(o=n[a])&&(r=(s<3?o(r):s>3?o(e,t,r):o(e,t))||r);return s>3&&r&&Object.defineProperty(e,t,r),r},HSe=function(n,e){return function(t,i){e(t,i,n)}};let lce=class extends pe{constructor(e,t,i,s,r,o){super(),this._element=e,this._dimension=t,this._viewModel=i,this._workbenchUIElementFactory=s,this._parentContextKeyService=r,this._parentInstantiationService=o,this._scrollableElements=ri("div.scrollContent",[ri("div@content",{style:{overflow:"hidden"}}),ri("div.monaco-editor@overflowWidgetsDomNode",{})]),this._scrollable=this._register(new bw({forceIntegerValues:!1,scheduleAtNextAnimationFrame:c=>Kc(Bt(this._element),c),smoothScrollDuration:100})),this._scrollableElement=this._register(new Yz(this._scrollableElements.root,{vertical:1,horizontal:1,useShadows:!1},this._scrollable)),this._elements=ri("div.monaco-component.multiDiffEditor",{},[ri("div",{},[this._scrollableElement.getDomNode()]),ri("div.placeholder@placeholder",{},[ri("div")])]),this._sizeObserver=this._register(new xWe(this._element,void 0)),this._objectPool=this._register(new c9n(c=>{const d=this._instantiationService.createInstance(ace,this._scrollableElements.content,this._scrollableElements.overflowWidgetsDomNode,this._workbenchUIElementFactory);return d.setData(c),d})),this.scrollTop=Ei(this,this._scrollableElement.onScroll,()=>this._scrollableElement.getScrollPosition().scrollTop),this.scrollLeft=Ei(this,this._scrollableElement.onScroll,()=>this._scrollableElement.getScrollPosition().scrollLeft),this._viewItemsInfo=$e(this,c=>{const d=this._viewModel.read(c);if(!d)return{items:[],getItem:g=>{throw new Kt}};const u=d.items.read(c),h=new Map;return{items:u.map(g=>{var _;const m=c.store.add(new h9n(g,this._objectPool,this.scrollLeft,b=>{this._scrollableElement.setScrollPosition({scrollTop:this._scrollableElement.getScrollPosition().scrollTop+b})})),p=(_=this._lastDocStates)==null?void 0:_[m.getKey()];return p&&as(b=>{m.setViewState(p,b)}),h.set(g,m),m}),getItem:g=>h.get(g)}}),this._viewItems=this._viewItemsInfo.map(this,c=>c.items),this._spaceBetweenPx=0,this._totalHeight=this._viewItems.map(this,(c,d)=>c.reduce((u,h)=>u+h.contentHeight.read(d)+this._spaceBetweenPx,0)),this.activeControl=$e(this,c=>{var h,f;const d=(h=this._viewModel.read(c))==null?void 0:h.activeDiffItem.read(c);return d?(f=this._viewItemsInfo.read(c).getItem(d).template.read(c))==null?void 0:f.editor:void 0}),this._contextKeyService=this._register(this._parentContextKeyService.createScoped(this._element)),this._instantiationService=this._register(this._parentInstantiationService.createChild(new ww([dn,this._contextKeyService]))),this._contextKeyService.createKey(ee.inMultiDiffEditor.key,!0),this._lastDocStates={},this._register(Qa((c,d)=>{const u=this._viewModel.read(c);if(u&&u.contextKeys)for(const[h,f]of Object.entries(u.contextKeys)){const g=this._contextKeyService.createKey(h,void 0);g.set(f),d.add(Rt(()=>g.reset()))}}));const a=this._parentContextKeyService.createKey(ee.multiDiffEditorAllCollapsed.key,!1);this._register(nn(c=>{const d=this._viewModel.read(c);if(d){const u=d.items.read(c).every(h=>h.collapsed.read(c));a.set(u)}})),this._register(nn(c=>{const d=this._dimension.read(c);this._sizeObserver.observe(d)}));const l=$e(c=>{if(this._viewItems.read(c).length>0)return;const u=this._viewModel.read(c);return!u||u.isLoading.read(c)?k(145,"Loading..."):k(146,"No Changed Files")});this._register(nn(c=>{const d=l.read(c);this._elements.placeholder.innerText=d??"",this._elements.placeholder.classList.toggle("visible",!!d)})),this._scrollableElements.content.style.position="relative",this._register(nn(c=>{const d=this._sizeObserver.height.read(c);this._scrollableElements.root.style.height=`${d}px`;const u=this._totalHeight.read(c);this._scrollableElements.content.style.height=`${u}px`;const h=this._sizeObserver.width.read(c);let f=h;const g=this._viewItems.read(c),m=Y1e(g,Da(p=>p.maxScroll.read(c).maxScroll,vd));if(m){const p=m.maxScroll.read(c);f=h+p.maxScroll}this._scrollableElement.setScrollDimensions({width:h,height:d,scrollHeight:u,scrollWidth:f})})),e.replaceChildren(this._elements.root),this._register(Rt(()=>{e.replaceChildren()})),this._register(nn(c=>{const d=this._viewModel.read(c);if(d&&!d.isLoading.read(c)){if(d.items.read(c).length===0||d.activeDiffItem.read(c))return;this.goToNextChange()}})),this._register(this._register(nn(c=>{ox(d=>{this.render(c)})})))}reveal(e,t){var c;const i=this._viewItems.get(),s=i.findIndex(d=>{var u,h,f,g;return((u=d.viewModel.originalUri)==null?void 0:u.toString())===((h=e.original)==null?void 0:h.toString())&&((f=d.viewModel.modifiedUri)==null?void 0:f.toString())===((g=e.modified)==null?void 0:g.toString())});if(s===-1)throw new Kt("Resource not found in diff editor");const r=i[s];this._viewModel.get().activeDiffItem.setCache(r.viewModel,void 0);let o=0;for(let d=0;d<s;d++)o+=i[d].contentHeight.get()+this._spaceBetweenPx;this._scrollableElement.setScrollPosition({scrollTop:o});const a=(c=r.template.get())==null?void 0:c.editor,l="original"in e?a==null?void 0:a.getOriginalEditor():a==null?void 0:a.getModifiedEditor();l&&(t!=null&&t.range)&&(l.revealRangeInCenter(t.range),u9n(l,t.range))}goToNextChange(){this._navigateToChange("next")}_navigateToChange(e){var l,c,d,u,h;const t=this._viewItems.get();if(t.length===0)return;const i=(l=this._viewModel.get())==null?void 0:l.activeDiffItem.get(),s=i?t.findIndex(f=>f.viewModel===i):-1;if(s===-1){this._goToFile(0,"first");return}const r=t[s];r.viewModel.collapsed.get()&&r.viewModel.collapsed.set(!1,void 0);const o=(c=r.template.get())==null?void 0:c.editor;if((u=(d=o==null?void 0:o.getDiffComputationResult())==null?void 0:d.changes2)!=null&&u.length){const f=((h=o.getModifiedEditor().getPosition())==null?void 0:h.lineNumber)||1,g=o.getDiffComputationResult().changes2;if(e==="next"?g.some(p=>p.modified.startLineNumber>f):g.some(p=>p.modified.endLineNumberExclusive<=f)){o.goToDiff(e);return}}const a=(s+(e==="next"?1:-1)+t.length)%t.length;this._goToFile(a,e==="next"?"first":"last")}_goToFile(e,t){var r,o,a;const i=this._viewItems.get()[e];i.viewModel.collapsed.get()&&i.viewModel.collapsed.set(!1,void 0),this.reveal({original:i.viewModel.originalUri,modified:i.viewModel.modifiedUri});const s=(r=i.template.get())==null?void 0:r.editor;if((a=(o=s==null?void 0:s.getDiffComputationResult())==null?void 0:o.changes2)!=null&&a.length)if(t==="first")s.revealFirstDiff();else{const l=s.getDiffComputationResult().changes2.at(-1),c=s.getModifiedEditor();c.setPosition({lineNumber:l.modified.startLineNumber,column:1}),c.revealLineInCenter(l.modified.startLineNumber)}s==null||s.focus()}render(e){const t=this.scrollTop.read(e);let i=0,s=0,r=0;const o=this._sizeObserver.height.read(e),a=At.ofStartAndLength(t,o),l=this._sizeObserver.width.read(e);for(const c of this._viewItems.read(e)){const d=c.contentHeight.read(e),u=Math.min(d,o),h=At.ofStartAndLength(s,u),f=At.ofStartAndLength(r,d);if(f.isBefore(a))i-=d-u,c.hide();else if(f.isAfter(a))c.hide();else{const g=Math.max(0,Math.min(a.start-f.start,d-u));i-=g;const m=At.ofStartAndLength(t+i,o);c.render(h,g,l,m)}s+=u+this._spaceBetweenPx,r+=d+this._spaceBetweenPx}this._scrollableElements.content.style.transform=`translateY(${-(t+i)}px)`}};lce=d9n([HSe(4,dn),HSe(5,Ft)],lce);function u9n(n,e){const t=n.getModel(),i=n.createDecorationsCollection([{range:e,options:{description:"symbol-navigate-action-highlight",className:"symbolHighlight"}}]);setTimeout(()=>{n.getModel()===t&&i.clear()},350)}class h9n extends pe{constructor(e,t,i,s){super(),this.viewModel=e,this._objectPool=t,this._scrollLeft=i,this._deltaScrollVertical=s,this._templateRef=this._register(f1e(this,void 0)),this.contentHeight=$e(this,r=>{var o,a;return((a=(o=this._templateRef.read(r))==null?void 0:o.object.contentHeight)==null?void 0:a.read(r))??this.viewModel.lastTemplateData.read(r).contentHeight}),this.maxScroll=$e(this,r=>{var o;return((o=this._templateRef.read(r))==null?void 0:o.object.maxScroll.read(r))??{maxScroll:0,scrollWidth:0}}),this.template=$e(this,r=>{var o;return(o=this._templateRef.read(r))==null?void 0:o.object}),this._isHidden=cn(this,!1),this._isFocused=$e(this,r=>{var o;return((o=this.template.read(r))==null?void 0:o.isFocused.read(r))??!1}),this.viewModel.setIsFocused(this._isFocused,void 0),this._register(nn(r=>{var a;const o=this._scrollLeft.read(r);(a=this._templateRef.read(r))==null||a.object.setScrollLeft(o)})),this._register(nn(r=>{const o=this._templateRef.read(r);!o||!this._isHidden.read(r)||o.object.isFocused.read(r)||this._clear()}))}dispose(){this._clear(),super.dispose()}toString(){var e;return`VirtualViewItem(${(e=this.viewModel.documentDiffItem.modified)==null?void 0:e.uri.toString()})`}getKey(){return this.viewModel.getKey()}setViewState(e,t){var o;this.viewModel.collapsed.set(e.collapsed,t),this._updateTemplateData(t);const i=this.viewModel.lastTemplateData.get(),s=(o=e.selections)==null?void 0:o.map(Lt.liftSelection);this.viewModel.lastTemplateData.set({...i,selections:s},t);const r=this._templateRef.get();r&&s&&r.object.editor.setSelections(s)}_updateTemplateData(e){const t=this._templateRef.get();t&&this.viewModel.lastTemplateData.set({contentHeight:t.object.contentHeight.get(),selections:t.object.editor.getSelections()??void 0},e)}_clear(){const e=this._templateRef.get();e&&as(t=>{this._updateTemplateData(t),e.object.hide(),this._templateRef.set(void 0,t)})}hide(){this._isHidden.set(!0,void 0)}render(e,t,i,s){this._isHidden.set(!1,void 0);let r=this._templateRef.get();if(!r){r=this._objectPool.getUnusedObj(new l9n(this.viewModel,this._deltaScrollVertical)),this._templateRef.set(r,void 0);const o=this.viewModel.lastTemplateData.get().selections;o&&r.object.editor.setSelections(o)}r.object.render(e,i,t,s)}}var f9n=function(n,e,t,i){var s=arguments.length,r=s<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(n,e,t,i);else for(var a=n.length-1;a>=0;a--)(o=n[a])&&(r=(s<3?o(r):s>3?o(e,t,r):o(e,t))||r);return s>3&&r&&Object.defineProperty(e,t,r),r},g9n=function(n,e){return function(t,i){e(t,i,n)}};let cce=class extends pe{constructor(e,t,i){super(),this._element=e,this._workbenchUIElementFactory=t,this._instantiationService=i,this._dimension=cn(this,void 0),this._viewModel=cn(this,void 0),this._widgetImpl=$e(this,s=>s.store.add(this._instantiationService.createInstance(r2(lce),this._element,this._dimension,this._viewModel,this._workbenchUIElementFactory))),this._register(Zb(this._widgetImpl))}};cce=f9n([g9n(2,Ft)],cce);function m9n(n,e,t){return Cn.initialize(t||{}).createInstance(rce,n,e)}function p9n(n){return Cn.get(ai).onCodeEditorAdd(t=>{n(t)})}function C9n(n){return Cn.get(ai).onDiffEditorAdd(t=>{n(t)})}function _9n(){return Cn.get(ai).listCodeEditors()}function v9n(){return Cn.get(ai).listDiffEditors()}function b9n(n,e,t){return Cn.initialize(t||{}).createInstance(oce,n,e)}function y9n(n,e){const t=Cn.initialize(e||{});return new cce(n,{},t)}function w9n(n){if(typeof n.id!="string"||typeof n.run!="function")throw new Error("Invalid command descriptor, `id` and `run` are required properties!");return ti.registerCommand(n.id,n.run)}function S9n(n){if(typeof n.id!="string"||typeof n.label!="string"||typeof n.run!="function")throw new Error("Invalid action descriptor, `id`, `label` and `run` are required properties!");const e=je.deserialize(n.precondition),t=(s,...r)=>co.runEditorCommand(s,r,e,(o,a,l)=>Promise.resolve(n.run(a,...l))),i=new Ae;if(i.add(ti.registerCommand(n.id,t)),n.contextMenuGroupId){const s={command:{id:n.id,title:n.label},when:e,group:n.contextMenuGroupId,order:n.contextMenuOrder||0};i.add(jo.appendMenuItem(Dt.EditorContext,s))}if(Array.isArray(n.keybindings)){const s=Cn.get(mi);if(!(s instanceof Ey))console.warn("Cannot add keybinding because the editor is configured with an unrecognized KeybindingService");else{const r=je.and(e,je.deserialize(n.keybindingContext));i.add(s.addDynamicKeybindings(n.keybindings.map(o=>({keybinding:o,command:n.id,when:r}))))}}return i}function x9n(n){return sqe([n])}function sqe(n){const e=Cn.get(mi);return e instanceof Ey?e.addDynamicKeybindings(n.map(t=>({keybinding:t.keybinding,command:t.command,commandArgs:t.commandArgs,when:je.deserialize(t.when)}))):(console.warn("Cannot add keybinding because the editor is configured with an unrecognized KeybindingService"),pe.None)}function L9n(n,e,t){const i=Cn.get(lr),s=i.getLanguageIdByMimeType(e)||e;return iqe(Cn.get(js),i,n,s,t)}function k9n(n,e){const t=Cn.get(lr),i=t.getLanguageIdByMimeType(e)||e||vu;n.setLanguage(t.createById(i))}function E9n(n,e,t){n&&Cn.get(Hf).changeOne(e,n.uri,t)}function I9n(n){Cn.get(Hf).changeAll(n,[])}function M9n(n){return Cn.get(Hf).read(n)}function N9n(n){return Cn.get(Hf).onMarkerChanged(n)}function D9n(n){return Cn.get(js).getModel(n)}function T9n(){return Cn.get(js).getModels()}function R9n(n){return Cn.get(js).onModelAdded(n)}function P9n(n){return Cn.get(js).onModelRemoved(n)}function A9n(n){return Cn.get(js).onModelLanguageChanged(t=>{n({model:t.model,oldLanguage:t.oldLanguageId})})}function O9n(n){return jfn(Cn.get(js),n)}function F9n(n,e){const t=Cn.get(lr),i=Cn.get(Ru);return x2e.colorizeElement(i,t,n,e).then(()=>{i.registerEditorContainer(n)})}function B9n(n,e,t){const i=Cn.get(lr);return Cn.get(Ru).registerEditorContainer(zi.document.body),x2e.colorize(i,n,e,t)}function $9n(n,e,t=4){return Cn.get(Ru).registerEditorContainer(zi.document.body),x2e.colorizeModelLine(n,e,t)}function H9n(n){const e=nr.get(n);return e||{getInitialState:()=>ay,tokenize:(t,i,s)=>p6e(n,s)}}function V9n(n,e){nr.getOrCreate(e);const t=H9n(e),i=Ed(n),s=[];let r=t.getInitialState();for(let o=0,a=i.length;o<a;o++){const l=i[o],c=t.tokenize(l,!0,r);s[o]=c.tokens,r=c.endState}return s}function j9n(n,e){Cn.get(Ru).defineTheme(n,e)}function W9n(n){Cn.get(Ru).setTheme(n)}function z9n(){Kte.clearAllFontInfos()}function U9n(n,e){return ti.registerCommand({id:n,handler:e})}function K9n(n){return Cn.get(e9).registerOpener({async open(t){return typeof t=="string"&&(t=zt.parse(t)),n.open(t)}})}function Z9n(n){return Cn.get(ai).registerCodeEditorOpenHandler(async(t,i,s)=>{var a;if(!i)return null;const r=(a=t.options)==null?void 0:a.selection;let o;return r&&typeof r.endLineNumber=="number"&&typeof r.endColumn=="number"?o=r:r&&(o={lineNumber:r.startLineNumber,column:r.startColumn}),await n.openCodeEditor(i,t.resource,o)?i:null})}function q9n(){return{create:m9n,getEditors:_9n,getDiffEditors:v9n,onDidCreateEditor:p9n,onDidCreateDiffEditor:C9n,createDiffEditor:b9n,addCommand:w9n,addEditorAction:S9n,addKeybindingRule:x9n,addKeybindingRules:sqe,createModel:L9n,setModelLanguage:k9n,setModelMarkers:E9n,getModelMarkers:M9n,removeAllMarkers:I9n,onDidChangeMarkers:N9n,getModels:T9n,getModel:D9n,onDidCreateModel:R9n,onWillDisposeModel:P9n,onDidChangeModelLanguage:A9n,createWebWorker:O9n,colorizeElement:F9n,colorize:B9n,colorizeModelLine:$9n,tokenize:V9n,defineTheme:j9n,setTheme:W9n,remeasureFonts:z9n,registerCommand:U9n,registerLinkOpener:K9n,registerEditorOpener:Z9n,AccessibilitySupport:rae,ContentWidgetPositionPreference:uae,CursorChangeReason:hae,DefaultEndOfLine:fae,EditorAutoIndentStrategy:mae,EditorOption:pae,EndOfLinePreference:Cae,EndOfLineSequence:_ae,MinimapPosition:Nae,MinimapSectionHeaderStyle:Dae,MouseTargetType:Tae,OverlayWidgetPositionPreference:Aae,OverviewRulerLane:Oae,GlyphMarginLane:vae,RenderLineNumbersType:$ae,RenderMinimap:Hae,ScrollbarVisibility:jae,ScrollType:Vae,TextEditorCursorBlinkingStyle:Gae,TextEditorCursorStyle:Xae,TrackedRangeStickiness:Yae,WrappingIndent:Qae,InjectedTextCursorStops:wae,PositionAffinity:Bae,ShowLightbulbIconMode:zae,TextDirection:qae,ConfigurationChangedEvent:OHe,BareFontInfo:B4,FontInfo:xF,TextModelResolvedOptions:TP,FindMatch:xE,ApplyUpdateResult:sL,EditorZoom:i3,createMultiFileDiffEditor:y9n,EditorType:bN,EditorOptions:Sl}}function G9n(n,e){if(!e||!Array.isArray(e))return!1;for(const t of e)if(!n(t))return!1;return!0}function SR(n,e){return typeof n=="boolean"?n:e}function VSe(n,e){return typeof n=="string"?n:e}function X9n(n){const e={};for(const t of n)e[t]=!0;return e}function jSe(n,e=!1){e&&(n=n.map(function(i){return i.toLowerCase()}));const t=X9n(n);return e?function(i){return t[i.toLowerCase()]!==void 0&&t.hasOwnProperty(i.toLowerCase())}:function(i){return t[i]!==void 0&&t.hasOwnProperty(i)}}function dce(n,e,t){e=e.replace(/@@/g,"");let i=0,s;do s=!1,e=e.replace(/@(\w+)/g,function(o,a){s=!0;let l="";if(typeof n[a]=="string")l=n[a];else if(n[a]&&n[a]instanceof RegExp)l=n[a].source;else throw n[a]===void 0?Es(n,"language definition does not contain attribute '"+a+"', used at: "+e):Es(n,"attribute reference '"+a+"' must be a string, used at: "+e);return l5(l)?"":"(?:"+l+")"}),i++;while(s&&i<5);e=e.replace(/\x01/g,"@");const r=(n.ignoreCase?"i":"")+(n.unicode?"u":"");if(t&&e.match(/\$[sS](\d\d?)/g)){let a=null,l=null;return c=>(l&&a===c||(a=c,l=new RegExp(Zfn(n,e,c),r)),l)}return new RegExp(e,r)}function Y9n(n,e,t,i){if(i<0)return n;if(i<e.length)return e[i];if(i>=100){i=i-100;const s=t.split(".");if(s.unshift(t),i<s.length)return s[i]}return null}function Q9n(n,e,t,i){let s=-1,r=t,o=t.match(/^\$(([sS]?)(\d\d?)|#)(.*)$/);o&&(o[3]&&(s=parseInt(o[3]),o[2]&&(s=s+100)),r=o[4]);let a="~",l=r;!r||r.length===0?(a="!=",l=""):/^\w*$/.test(l)?a="==":(o=r.match(/^(@|!@|~|!~|==|!=)(.*)$/),o&&(a=o[1],l=o[2]));let c;if((a==="~"||a==="!~")&&/^(\w|\|)*$/.test(l)){const d=jSe(l.split("|"),n.ignoreCase);c=function(u){return a==="~"?d(u):!d(u)}}else if(a==="@"||a==="!@"){const d=n[l];if(!d)throw Es(n,"the @ match target '"+l+"' is not defined, in rule: "+e);if(!G9n(function(h){return typeof h=="string"},d))throw Es(n,"the @ match target '"+l+"' must be an array of strings, in rule: "+e);const u=jSe(d,n.ignoreCase);c=function(h){return a==="@"?u(h):!u(h)}}else if(a==="~"||a==="!~")if(l.indexOf("$")<0){const d=dce(n,"^"+l+"$",!1);c=function(u){return a==="~"?d.test(u):!d.test(u)}}else c=function(d,u,h,f){return dce(n,"^"+Y9(n,l,u,h,f)+"$",!1).test(d)};else if(l.indexOf("$")<0){const d=m0(n,l);c=function(u){return a==="=="?u===d:u!==d}}else{const d=m0(n,l);c=function(u,h,f,g,m){const p=Y9(n,d,h,f,g);return a==="=="?u===p:u!==p}}return s===-1?{name:t,value:i,test:function(d,u,h,f){return c(d,d,u,h,f)}}:{name:t,value:i,test:function(d,u,h,f){const g=Y9n(d,u,h,s);return c(g||"",d,u,h,f)}}}function uce(n,e,t){if(t){if(typeof t=="string")return t;if(t.token||t.token===""){if(typeof t.token!="string")throw Es(n,"a 'token' attribute must be of type string, in rule: "+e);{const i={token:t.token};if(t.token.indexOf("$")>=0&&(i.tokenSubst=!0),typeof t.bracket=="string")if(t.bracket==="@open")i.bracket=1;else if(t.bracket==="@close")i.bracket=-1;else throw Es(n,"a 'bracket' attribute must be either '@open' or '@close', in rule: "+e);if(t.next){if(typeof t.next!="string")throw Es(n,"the next state must be a string value in rule: "+e);{let s=t.next;if(!/^(@pop|@push|@popall)$/.test(s)&&(s[0]==="@"&&(s=s.substr(1)),s.indexOf("$")<0&&!qfn(n,Y9(n,s,"",[],""))))throw Es(n,"the next state '"+t.next+"' is not defined in rule: "+e);i.next=s}}return typeof t.goBack=="number"&&(i.goBack=t.goBack),typeof t.switchTo=="string"&&(i.switchTo=t.switchTo),typeof t.log=="string"&&(i.log=t.log),typeof t.nextEmbedded=="string"&&(i.nextEmbedded=t.nextEmbedded,n.usesEmbedded=!0),i}}else if(Array.isArray(t)){const i=[];for(let s=0,r=t.length;s<r;s++)i[s]=uce(n,e,t[s]);return{group:i}}else if(t.cases){const i=[];let s=!1;for(const o in t.cases)if(t.cases.hasOwnProperty(o)){const a=uce(n,e,t.cases[o]);o==="@default"||o==="@"||o===""?i.push({test:void 0,value:a,name:o}):o==="@eos"?i.push({test:function(l,c,d,u){return u},value:a,name:o}):i.push(Q9n(n,e,o,a)),s||(s=!Io(a)&&(a.hasEmbeddedEndInCases||["@pop","@popall"].includes(a.nextEmbedded||"")))}const r=n.defaultToken;return{hasEmbeddedEndInCases:s,test:function(o,a,l,c){for(const d of i)if(!d.test||d.test(o,a,l,c))return d.value;return r}}}else throw Es(n,"an action must be a string, an object with a 'token' or 'cases' attribute, or an array of actions; in rule: "+e)}else return{token:""}}class J9n{constructor(e){this.regex=new RegExp(""),this.action={token:""},this.matchOnlyAtLineStart=!1,this.name="",this.name=e}setRegex(e,t){let i;if(typeof t=="string")i=t;else if(t instanceof RegExp)i=t.source;else throw Es(e,"rules must start with a match string or regular expression: "+this.name);this.matchOnlyAtLineStart=i.length>0&&i[0]==="^",this.name=this.name+": "+i,this.regex=dce(e,"^(?:"+(this.matchOnlyAtLineStart?i.substr(1):i)+")",!0)}setAction(e,t){this.action=uce(e,this.name,t)}resolveRegex(e){return this.regex instanceof RegExp?this.regex:this.regex(e)}}function rqe(n,e){if(!e||typeof e!="object")throw new Error("Monarch: expecting a language definition object");const t={languageId:n,includeLF:SR(e.includeLF,!1),noThrow:!1,maxStack:100,start:typeof e.start=="string"?e.start:null,ignoreCase:SR(e.ignoreCase,!1),unicode:SR(e.unicode,!1),tokenPostfix:VSe(e.tokenPostfix,"."+n),defaultToken:VSe(e.defaultToken,"source"),usesEmbedded:!1,stateNames:{},tokenizer:{},brackets:[]},i=e;i.languageId=n,i.includeLF=t.includeLF,i.ignoreCase=t.ignoreCase,i.unicode=t.unicode,i.noThrow=t.noThrow,i.usesEmbedded=t.usesEmbedded,i.stateNames=e.tokenizer,i.defaultToken=t.defaultToken;function s(o,a,l){for(const c of l){let d=c.include;if(d){if(typeof d!="string")throw Es(t,"an 'include' attribute must be a string at: "+o);if(d[0]==="@"&&(d=d.substr(1)),!e.tokenizer[d])throw Es(t,"include target '"+d+"' is not defined at: "+o);s(o+"."+d,a,e.tokenizer[d])}else{const u=new J9n(o);if(Array.isArray(c)&&c.length>=1&&c.length<=3)if(u.setRegex(i,c[0]),c.length>=3)if(typeof c[1]=="string")u.setAction(i,{token:c[1],next:c[2]});else if(typeof c[1]=="object"){const h=c[1];h.next=c[2],u.setAction(i,h)}else throw Es(t,"a next state as the last element of a rule can only be given if the action is either an object or a string, at: "+o);else u.setAction(i,c[1]);else{if(!c.regex)throw Es(t,"a rule must either be an array, or an object with a 'regex' or 'include' field at: "+o);c.name&&typeof c.name=="string"&&(u.name=c.name),c.matchOnlyAtStart&&(u.matchOnlyAtLineStart=SR(c.matchOnlyAtLineStart,!1)),u.setRegex(i,c.regex),u.setAction(i,c.action)}a.push(u)}}}if(!e.tokenizer||typeof e.tokenizer!="object")throw Es(t,"a language definition must define the 'tokenizer' attribute as an object");t.tokenizer=[];for(const o in e.tokenizer)if(e.tokenizer.hasOwnProperty(o)){t.start||(t.start=o);const a=e.tokenizer[o];t.tokenizer[o]=new Array,s("tokenizer."+o,t.tokenizer[o],a)}if(t.usesEmbedded=i.usesEmbedded,e.brackets){if(!Array.isArray(e.brackets))throw Es(t,"the 'brackets' attribute must be defined as an array")}else e.brackets=[{open:"{",close:"}",token:"delimiter.curly"},{open:"[",close:"]",token:"delimiter.square"},{open:"(",close:")",token:"delimiter.parenthesis"},{open:"<",close:">",token:"delimiter.angle"}];const r=[];for(const o of e.brackets){let a=o;if(a&&Array.isArray(a)&&a.length===3&&(a={token:a[2],open:a[0],close:a[1]}),a.open===a.close)throw Es(t,"open and close brackets in a 'brackets' attribute must be different: "+a.open+`
1482
- hint: use the 'bracket' attribute if matching on equal brackets is required.`);if(typeof a.open=="string"&&typeof a.token=="string"&&typeof a.close=="string")r.push({token:a.token+t.tokenPostfix,open:m0(t,a.open),close:m0(t,a.close)});else throw Es(t,"every element in the 'brackets' array must be a '{open,close,token}' object or array")}return t.brackets=r,t.noThrow=!0,t}function egn(n){Gb.registerLanguage(n)}function tgn(){let n=[];return n=n.concat(Gb.getLanguages()),n}function ngn(n){return Cn.get(lr).languageIdCodec.encodeLanguageId(n)}function ign(n,e){return Cn.withServices(()=>{const i=Cn.get(lr).onDidRequestRichLanguageFeatures(s=>{s===n&&(i.dispose(),e())});return i})}function sgn(n,e){return Cn.withServices(()=>{const i=Cn.get(lr).onDidRequestBasicLanguageFeatures(s=>{s===n&&(i.dispose(),e())});return i})}function rgn(n,e){if(!Cn.get(lr).isRegisteredLanguageId(n))throw new Error(`Cannot set configuration for unknown language ${n}`);return Cn.get(Ws).register(n,e,100)}class ogn{constructor(e,t){this._languageId=e,this._actual=t}dispose(){}getInitialState(){return this._actual.getInitialState()}tokenize(e,t,i){if(typeof this._actual.tokenize=="function")return eM.adaptTokenize(this._languageId,this._actual,e,i);throw new Error("Not supported!")}tokenizeEncoded(e,t,i){const s=this._actual.tokenizeEncoded(e,i);return new tU(s.tokens,s.endState)}}class eM{constructor(e,t,i,s){this._languageId=e,this._actual=t,this._languageService=i,this._standaloneThemeService=s}dispose(){}getInitialState(){return this._actual.getInitialState()}static _toClassicTokens(e,t){const i=[];let s=0;for(let r=0,o=e.length;r<o;r++){const a=e[r];let l=a.startIndex;r===0?l=0:l<s&&(l=s),i[r]=new BE(l,a.scopes,t),s=l}return i}static adaptTokenize(e,t,i,s){const r=t.tokenize(i,s),o=eM._toClassicTokens(r.tokens,e);let a;return r.endState.equals(s)?a=s:a=r.endState,new Q1e(o,a)}tokenize(e,t,i){return eM.adaptTokenize(this._languageId,this._actual,e,i)}_toBinaryTokens(e,t){const i=e.encodeLanguageId(this._languageId),s=this._standaloneThemeService.getColorTheme().tokenTheme,r=[];let o=0,a=0;for(let c=0,d=t.length;c<d;c++){const u=t[c],h=s.match(i,u.scopes)|1024;if(o>0&&r[o-1]===h)continue;let f=u.startIndex;c===0?f=0:f<a&&(f=a),r[o++]=f,r[o++]=h,a=f}const l=new Uint32Array(o);for(let c=0;c<o;c++)l[c]=r[c];return l}tokenizeEncoded(e,t,i){const s=this._actual.tokenize(e,i),r=this._toBinaryTokens(this._languageService.languageIdCodec,s.tokens);let o;return s.endState.equals(i)?o=i:o=s.endState,new tU(r,o)}}function agn(n){return typeof n.getInitialState=="function"}function lgn(n){return"tokenizeEncoded"in n}function oqe(n){return n&&typeof n.then=="function"}function cgn(n){const e=Cn.get(Ru);if(n){const t=[null];for(let i=1,s=n.length;i<s;i++)t[i]=Be.fromHex(n[i]);e.setColorMapOverride(t)}else e.setColorMapOverride(null)}function aqe(n,e){return lgn(e)?new ogn(n,e):new eM(n,e,Cn.get(lr),Cn.get(Ru))}function N2e(n,e){const t=new oUt(async()=>{const i=await Promise.resolve(e.create());return i?agn(i)?aqe(n,i):new ZI(Cn.get(lr),Cn.get(Ru),n,rqe(n,i),Cn.get(Ln)):null});return nr.registerFactory(n,t)}function dgn(n,e){if(!Cn.get(lr).isRegisteredLanguageId(n))throw new Error(`Cannot set tokens provider for unknown language ${n}`);return oqe(e)?N2e(n,{create:()=>e}):nr.register(n,aqe(n,e))}function ugn(n,e){const t=i=>new ZI(Cn.get(lr),Cn.get(Ru),n,rqe(n,i),Cn.get(Ln));return oqe(e)?N2e(n,{create:()=>e}):nr.register(n,t(e))}function hgn(n,e){return Cn.get(Nt).referenceProvider.register(n,e)}function fgn(n,e){return Cn.get(Nt).renameProvider.register(n,e)}function ggn(n,e){return Cn.get(Nt).newSymbolNamesProvider.register(n,e)}function mgn(n,e){return Cn.get(Nt).signatureHelpProvider.register(n,e)}function pgn(n,e){return Cn.get(Nt).hoverProvider.register(n,{provideHover:async(i,s,r,o)=>{const a=i.getWordAtPosition(s);return Promise.resolve(e.provideHover(i,s,r,o)).then(l=>{if(l)return!l.range&&a&&(l.range=new z(s.lineNumber,a.startColumn,s.lineNumber,a.endColumn)),l.range||(l.range=new z(s.lineNumber,s.column,s.lineNumber,s.column)),l})}})}function Cgn(n,e){return Cn.get(Nt).documentSymbolProvider.register(n,e)}function _gn(n,e){return Cn.get(Nt).documentHighlightProvider.register(n,e)}function vgn(n,e){return Cn.get(Nt).linkedEditingRangeProvider.register(n,e)}function bgn(n,e){return Cn.get(Nt).definitionProvider.register(n,e)}function ygn(n,e){return Cn.get(Nt).implementationProvider.register(n,e)}function wgn(n,e){return Cn.get(Nt).typeDefinitionProvider.register(n,e)}function Sgn(n,e){return Cn.get(Nt).codeLensProvider.register(n,e)}function xgn(n,e,t){return Cn.get(Nt).codeActionProvider.register(n,{providedCodeActionKinds:t==null?void 0:t.providedCodeActionKinds,documentation:t==null?void 0:t.documentation,provideCodeActions:(s,r,o,a)=>{const c=Cn.get(Hf).read({resource:s.uri}).filter(d=>z.areIntersectingOrTouching(d,r));return e.provideCodeActions(s,r,{markers:c,only:o.only,trigger:o.trigger},a)},resolveCodeAction:e.resolveCodeAction})}function Lgn(n,e){return Cn.get(Nt).documentFormattingEditProvider.register(n,e)}function kgn(n,e){return Cn.get(Nt).documentRangeFormattingEditProvider.register(n,e)}function Egn(n,e){return Cn.get(Nt).onTypeFormattingEditProvider.register(n,e)}function Ign(n,e){return Cn.get(Nt).linkProvider.register(n,e)}function Mgn(n,e){return Cn.get(Nt).completionProvider.register(n,e)}function Ngn(n,e){return Cn.get(Nt).colorProvider.register(n,e)}function Dgn(n,e){return Cn.get(Nt).foldingRangeProvider.register(n,e)}function Tgn(n,e){return Cn.get(Nt).declarationProvider.register(n,e)}function Rgn(n,e){return Cn.get(Nt).selectionRangeProvider.register(n,e)}function Pgn(n,e){return Cn.get(Nt).documentSemanticTokensProvider.register(n,e)}function Agn(n,e){return Cn.get(Nt).documentRangeSemanticTokensProvider.register(n,e)}function Ogn(n,e){return Cn.get(Nt).inlineCompletionsProvider.register(n,e)}function Fgn(n,e){return Cn.get(Nt).inlayHintsProvider.register(n,e)}function Bgn(){return{register:egn,getLanguages:tgn,onLanguage:ign,onLanguageEncountered:sgn,getEncodedLanguageId:ngn,setLanguageConfiguration:rgn,setColorMap:cgn,registerTokensProviderFactory:N2e,setTokensProvider:dgn,setMonarchTokensProvider:ugn,registerReferenceProvider:hgn,registerRenameProvider:fgn,registerNewSymbolNameProvider:ggn,registerCompletionItemProvider:Mgn,registerSignatureHelpProvider:mgn,registerHoverProvider:pgn,registerDocumentSymbolProvider:Cgn,registerDocumentHighlightProvider:_gn,registerLinkedEditingRangeProvider:vgn,registerDefinitionProvider:bgn,registerImplementationProvider:ygn,registerTypeDefinitionProvider:wgn,registerCodeLensProvider:Sgn,registerCodeActionProvider:xgn,registerDocumentFormattingEditProvider:Lgn,registerDocumentRangeFormattingEditProvider:kgn,registerOnTypeFormattingEditProvider:Egn,registerLinkProvider:Ign,registerColorProvider:Ngn,registerFoldingRangeProvider:Dgn,registerDeclarationProvider:Tgn,registerSelectionRangeProvider:Rgn,registerDocumentSemanticTokensProvider:Pgn,registerDocumentRangeSemanticTokensProvider:Agn,registerInlineCompletionsProvider:Ogn,registerInlayHintsProvider:Fgn,DocumentHighlightKind:gae,CompletionItemKind:lae,CompletionItemTag:cae,CompletionItemInsertTextRule:aae,SymbolKind:Kae,SymbolTag:Zae,IndentAction:yae,CompletionTriggerKind:dae,SignatureHelpTriggerKind:Uae,InlayHintKind:Sae,InlineCompletionTriggerKind:kae,CodeActionTriggerType:oae,NewSymbolNameTag:Rae,NewSymbolNameTriggerKind:Pae,PartialAcceptTriggerKind:Fae,HoverVerbosityAction:bae,InlineCompletionEndOfLifeReasonKind:xae,InlineCompletionHintStyle:Lae,FoldingRangeKind:PC,SelectedSuggestionInfo:HVe,EditDeltaInfo:XE}}Sl.wrappingIndent.defaultValue=0;Sl.glyphMargin.defaultValue=!1;Sl.autoIndent.defaultValue=3;Sl.overviewRulerLanes.defaultValue=2;LI.setFormatterSelector((n,e,t)=>Promise.resolve(n[0]));const _c=PZe();_c.editor=q9n();_c.languages=Bgn();const lqe=_c.CancellationTokenSource,Fm=_c.Emitter,D2e=_c.KeyCode,T2e=_c.KeyMod,s9=_c.Position,KC=_c.Range,cqe=_c.Selection,dqe=_c.SelectionDirection,dh=_c.MarkerSeverity,gH=_c.MarkerTag,GU=_c.Uri,uqe=_c.Token,_h=_c.editor,Mt=_c.languages,aY=$he(),Yv=globalThis;(aY!=null&&aY.globalAPI||typeof Yv.define=="function"&&Yv.define.amd)&&(Yv.monaco=_c);typeof Yv.require<"u"&&typeof Yv.require.config=="function"&&Yv.require.config({ignoreDuplicateModules:["vscode-languageserver-types","vscode-languageserver-types/main","vscode-languageserver-textdocument","vscode-languageserver-textdocument/main","vscode-nls","vscode-nls/vscode-nls","jsonc-parser","jsonc-parser/main","vscode-uri","vscode-uri/index","vs/basic-languages/typescript/typescript"]});const $gn=Object.freeze(Object.defineProperty({__proto__:null,CancellationTokenSource:lqe,Emitter:Fm,KeyCode:D2e,KeyMod:T2e,MarkerSeverity:dh,MarkerTag:gH,Position:s9,Range:KC,Selection:cqe,SelectionDirection:dqe,Token:uqe,Uri:GU,editor:_h,languages:Mt},Symbol.toStringTag,{value:"Module"}));let R2e=class{constructor(e,t,i){this._onDidChange=new Fm,this._languageId=e,this.setOptions(t),this.setModeConfiguration(i)}get onDidChange(){return this._onDidChange.event}get languageId(){return this._languageId}get modeConfiguration(){return this._modeConfiguration}get diagnosticsOptions(){return this.options}get options(){return this._options}setOptions(e){this._options=e||Object.create(null),this._onDidChange.fire(this)}setDiagnosticsOptions(e){this.setOptions(e)}setModeConfiguration(e){this._modeConfiguration=e||Object.create(null),this._onDidChange.fire(this)}};const P2e={validate:!0,lint:{compatibleVendorPrefixes:"ignore",vendorPrefix:"warning",duplicateProperties:"warning",emptyRules:"warning",importStatement:"ignore",boxModel:"ignore",universalSelector:"ignore",zeroUnits:"ignore",fontFaceProperties:"warning",hexColorLength:"error",argumentsInColorFunction:"error",unknownProperties:"warning",ieHack:"ignore",unknownVendorSpecificProperties:"ignore",propertyIgnoredDueToDisplay:"warning",important:"ignore",float:"ignore",idSelector:"ignore"},data:{useDefaultDataProvider:!0},format:{newlineBetweenSelectors:!0,newlineBetweenRules:!0,spaceAroundSelectorSeparator:!1,braceStyle:"collapse",maxPreserveNewLines:void 0,preserveNewLines:!0}},A2e={completionItems:!0,hovers:!0,documentSymbols:!0,definitions:!0,references:!0,documentHighlights:!0,rename:!0,colors:!0,foldingRanges:!0,diagnostics:!0,selectionRanges:!0,documentFormattingEdits:!0,documentRangeFormattingEdits:!0},hqe=new R2e("css",P2e,A2e),fqe=new R2e("scss",P2e,A2e),gqe=new R2e("less",P2e,A2e);function O2e(){return re(()=>import("./cssMode-DWNQvDzf.js"),__vite__mapDeps([97,98]))}Mt.onLanguage("less",()=>{O2e().then(n=>n.setupMode(gqe))});Mt.onLanguage("scss",()=>{O2e().then(n=>n.setupMode(fqe))});Mt.onLanguage("css",()=>{O2e().then(n=>n.setupMode(hqe))});const mqe=Object.freeze(Object.defineProperty({__proto__:null,cssDefaults:hqe,lessDefaults:gqe,scssDefaults:fqe},Symbol.toStringTag,{value:"Module"}));let Hgn=class{constructor(e,t,i){this._onDidChange=new Fm,this._languageId=e,this.setOptions(t),this.setModeConfiguration(i)}get onDidChange(){return this._onDidChange.event}get languageId(){return this._languageId}get options(){return this._options}get modeConfiguration(){return this._modeConfiguration}setOptions(e){this._options=e||Object.create(null),this._onDidChange.fire(this)}setModeConfiguration(e){this._modeConfiguration=e||Object.create(null),this._onDidChange.fire(this)}};const Vgn={tabSize:4,insertSpaces:!1,wrapLineLength:120,unformatted:'default": "a, abbr, acronym, b, bdo, big, br, button, cite, code, dfn, em, i, img, input, kbd, label, map, object, q, samp, select, small, span, strong, sub, sup, textarea, tt, var',contentUnformatted:"pre",indentInnerHtml:!1,preserveNewLines:!0,maxPreserveNewLines:void 0,indentHandlebars:!1,endWithNewline:!1,extraLiners:"head, body, /html",wrapAttributes:"auto"},XU={format:Vgn,suggest:{},data:{useDefaultDataProvider:!0}};function YU(n){return{completionItems:!0,hovers:!0,documentSymbols:!0,links:!0,documentHighlights:!0,rename:!0,colors:!0,foldingRanges:!0,selectionRanges:!0,diagnostics:n===ZL,documentFormattingEdits:n===ZL,documentRangeFormattingEdits:n===ZL}}const ZL="html",WSe="handlebars",zSe="razor",pqe=QU(ZL,XU,YU(ZL)),jgn=pqe.defaults,Cqe=QU(WSe,XU,YU(WSe)),Wgn=Cqe.defaults,_qe=QU(zSe,XU,YU(zSe)),zgn=_qe.defaults;function Ugn(){return re(()=>import("./htmlMode-BsgOVHtb.js"),__vite__mapDeps([99,98]))}function QU(n,e=XU,t=YU(n)){const i=new Hgn(n,e,t);let s;const r=Mt.onLanguage(n,async()=>{s=(await Ugn()).setupMode(i)});return{defaults:i,dispose(){r.dispose(),s==null||s.dispose(),s=void 0}}}const vqe=Object.freeze(Object.defineProperty({__proto__:null,handlebarDefaults:Wgn,handlebarLanguageService:Cqe,htmlDefaults:jgn,htmlLanguageService:pqe,razorDefaults:zgn,razorLanguageService:_qe,registerHTMLLanguageService:QU},Symbol.toStringTag,{value:"Module"}));let Kgn=class{constructor(e,t,i){this._onDidChange=new Fm,this._languageId=e,this.setDiagnosticsOptions(t),this.setModeConfiguration(i)}get onDidChange(){return this._onDidChange.event}get languageId(){return this._languageId}get modeConfiguration(){return this._modeConfiguration}get diagnosticsOptions(){return this._diagnosticsOptions}setDiagnosticsOptions(e){this._diagnosticsOptions=e||Object.create(null),this._onDidChange.fire(this)}setModeConfiguration(e){this._modeConfiguration=e||Object.create(null),this._onDidChange.fire(this)}};const Zgn={validate:!0,allowComments:!0,schemas:[],enableSchemaRequest:!1,schemaRequest:"warning",schemaValidation:"warning",comments:"error",trailingCommas:"error"},qgn={documentFormattingEdits:!0,documentRangeFormattingEdits:!0,completionItems:!0,hovers:!0,documentSymbols:!0,tokens:!0,colors:!0,foldingRanges:!0,diagnostics:!0,selectionRanges:!0},bqe=new Kgn("json",Zgn,qgn),Ggn=()=>yqe().then(n=>n.getWorker());function yqe(){return re(()=>import("./jsonMode-A5VNSpp6.js"),__vite__mapDeps([100,98]))}Mt.register({id:"json",extensions:[".json",".bowerrc",".jshintrc",".jscsrc",".eslintrc",".babelrc",".har"],aliases:["JSON","json"],mimetypes:["application/json"]});Mt.onLanguage("json",()=>{yqe().then(n=>n.setupMode(bqe))});const wqe=Object.freeze(Object.defineProperty({__proto__:null,getWorker:Ggn,jsonDefaults:bqe},Symbol.toStringTag,{value:"Module"})),Xgn="5.9.3";var Sqe=(n=>(n[n.None=0]="None",n[n.CommonJS=1]="CommonJS",n[n.AMD=2]="AMD",n[n.UMD=3]="UMD",n[n.System=4]="System",n[n.ES2015=5]="ES2015",n[n.ESNext=99]="ESNext",n))(Sqe||{}),xqe=(n=>(n[n.None=0]="None",n[n.Preserve=1]="Preserve",n[n.React=2]="React",n[n.ReactNative=3]="ReactNative",n[n.ReactJSX=4]="ReactJSX",n[n.ReactJSXDev=5]="ReactJSXDev",n))(xqe||{}),Lqe=(n=>(n[n.CarriageReturnLineFeed=0]="CarriageReturnLineFeed",n[n.LineFeed=1]="LineFeed",n))(Lqe||{}),kqe=(n=>(n[n.ES3=0]="ES3",n[n.ES5=1]="ES5",n[n.ES2015=2]="ES2015",n[n.ES2016=3]="ES2016",n[n.ES2017=4]="ES2017",n[n.ES2018=5]="ES2018",n[n.ES2019=6]="ES2019",n[n.ES2020=7]="ES2020",n[n.ESNext=99]="ESNext",n[n.JSON=100]="JSON",n[n.Latest=99]="Latest",n))(kqe||{}),Eqe=(n=>(n[n.Classic=1]="Classic",n[n.NodeJs=2]="NodeJs",n))(Eqe||{});class Iqe{constructor(e,t,i,s,r){this._onDidChange=new Fm,this._onDidExtraLibsChange=new Fm,this._extraLibs=Object.create(null),this._removedExtraLibs=Object.create(null),this._eagerModelSync=!1,this.setCompilerOptions(e),this.setDiagnosticsOptions(t),this.setWorkerOptions(i),this.setInlayHintsOptions(s),this.setModeConfiguration(r),this._onDidExtraLibsChangeTimeout=-1}get onDidChange(){return this._onDidChange.event}get onDidExtraLibsChange(){return this._onDidExtraLibsChange.event}get modeConfiguration(){return this._modeConfiguration}get workerOptions(){return this._workerOptions}get inlayHintsOptions(){return this._inlayHintsOptions}getExtraLibs(){return this._extraLibs}addExtraLib(e,t){let i;if(typeof t>"u"?i=`ts:extralib-${Math.random().toString(36).substring(2,15)}`:i=t,this._extraLibs[i]&&this._extraLibs[i].content===e)return{dispose:()=>{}};let s=1;return this._removedExtraLibs[i]&&(s=this._removedExtraLibs[i]+1),this._extraLibs[i]&&(s=this._extraLibs[i].version+1),this._extraLibs[i]={content:e,version:s},this._fireOnDidExtraLibsChangeSoon(),{dispose:()=>{let r=this._extraLibs[i];r&&r.version===s&&(delete this._extraLibs[i],this._removedExtraLibs[i]=s,this._fireOnDidExtraLibsChangeSoon())}}}setExtraLibs(e){for(const t in this._extraLibs)this._removedExtraLibs[t]=this._extraLibs[t].version;if(this._extraLibs=Object.create(null),e&&e.length>0)for(const t of e){const i=t.filePath||`ts:extralib-${Math.random().toString(36).substring(2,15)}`,s=t.content;let r=1;this._removedExtraLibs[i]&&(r=this._removedExtraLibs[i]+1),this._extraLibs[i]={content:s,version:r}}this._fireOnDidExtraLibsChangeSoon()}_fireOnDidExtraLibsChangeSoon(){this._onDidExtraLibsChangeTimeout===-1&&(this._onDidExtraLibsChangeTimeout=window.setTimeout(()=>{this._onDidExtraLibsChangeTimeout=-1,this._onDidExtraLibsChange.fire(void 0)},0))}getCompilerOptions(){return this._compilerOptions}setCompilerOptions(e){this._compilerOptions=e||Object.create(null),this._onDidChange.fire(void 0)}getDiagnosticsOptions(){return this._diagnosticsOptions}setDiagnosticsOptions(e){this._diagnosticsOptions=e||Object.create(null),this._onDidChange.fire(void 0)}setWorkerOptions(e){this._workerOptions=e||Object.create(null),this._onDidChange.fire(void 0)}setInlayHintsOptions(e){this._inlayHintsOptions=e||Object.create(null),this._onDidChange.fire(void 0)}setMaximumWorkerIdleTime(e){}setEagerModelSync(e){this._eagerModelSync=e}getEagerModelSync(){return this._eagerModelSync}setModeConfiguration(e){this._modeConfiguration=e||Object.create(null),this._onDidChange.fire(void 0)}}const Ygn=Xgn,Mqe={completionItems:!0,hovers:!0,documentSymbols:!0,definitions:!0,references:!0,documentHighlights:!0,rename:!0,diagnostics:!0,documentRangeFormattingEdits:!0,signatureHelp:!0,onTypeFormattingEdits:!0,codeActions:!0,inlayHints:!0},Nqe=new Iqe({allowNonTsExtensions:!0,target:99},{noSemanticValidation:!1,noSyntaxValidation:!1,onlyVisible:!1},{},{},Mqe),Dqe=new Iqe({allowNonTsExtensions:!0,allowJs:!0,target:99},{noSemanticValidation:!0,noSyntaxValidation:!1,onlyVisible:!1},{},{},Mqe),Qgn=()=>JU().then(n=>n.getTypeScriptWorker()),Jgn=()=>JU().then(n=>n.getJavaScriptWorker());function JU(){return re(()=>import("./tsMode-C5Lv-ixK.js"),[])}Mt.onLanguage("typescript",()=>JU().then(n=>n.setupTypeScript(Nqe)));Mt.onLanguage("javascript",()=>JU().then(n=>n.setupJavaScript(Dqe)));const Tqe=Object.freeze(Object.defineProperty({__proto__:null,JsxEmit:xqe,ModuleKind:Sqe,ModuleResolutionKind:Eqe,NewLineKind:Lqe,ScriptTarget:kqe,getJavaScriptWorker:Jgn,getTypeScriptWorker:Qgn,javascriptDefaults:Dqe,typescriptDefaults:Nqe,typescriptVersion:Ygn},Symbol.toStringTag,{value:"Module"})),Rqe={},lY={};class F2e{static getOrCreate(e){return lY[e]||(lY[e]=new F2e(e)),lY[e]}constructor(e){this._languageId=e,this._loadingTriggered=!1,this._lazyLoadPromise=new Promise((t,i)=>{this._lazyLoadPromiseResolve=t,this._lazyLoadPromiseReject=i})}load(){return this._loadingTriggered||(this._loadingTriggered=!0,Rqe[this._languageId].loader().then(e=>this._lazyLoadPromiseResolve(e),e=>this._lazyLoadPromiseReject(e))),this._lazyLoadPromise}}function Jt(n){const e=n.id;Rqe[e]=n,Mt.register(n);const t=F2e.getOrCreate(e);Mt.registerTokensProviderFactory(e,{create:async()=>(await t.load()).language}),Mt.onLanguageEncountered(e,async()=>{const i=await t.load();Mt.setLanguageConfiguration(e,i.conf)})}Jt({id:"abap",extensions:[".abap"],aliases:["abap","ABAP"],loader:()=>re(()=>import("./abap-DLDM7-KI.js"),[])});Jt({id:"apex",extensions:[".cls"],aliases:["Apex","apex"],mimetypes:["text/x-apex-source","text/x-apex"],loader:()=>re(()=>import("./apex-DNDY2TF8.js"),[])});Jt({id:"azcli",extensions:[".azcli"],aliases:["Azure CLI","azcli"],loader:()=>re(()=>import("./azcli-Y6nb8tq_.js"),[])});Jt({id:"bat",extensions:[".bat",".cmd"],aliases:["Batch","bat"],loader:()=>re(()=>import("./bat-BwHxbl9M.js"),[])});Jt({id:"bicep",extensions:[".bicep"],aliases:["Bicep"],loader:()=>re(()=>import("./bicep-CFznDFnq.js"),[])});Jt({id:"cameligo",extensions:[".mligo"],aliases:["Cameligo"],loader:()=>re(()=>import("./cameligo-Bf6VGUru.js"),[])});Jt({id:"clojure",extensions:[".clj",".cljs",".cljc",".edn"],aliases:["clojure","Clojure"],loader:()=>re(()=>import("./clojure-Dnu-v4kV.js"),[])});Jt({id:"coffeescript",extensions:[".coffee"],aliases:["CoffeeScript","coffeescript","coffee"],mimetypes:["text/x-coffeescript","text/coffeescript"],loader:()=>re(()=>import("./coffee-Bd8akH9Z.js"),[])});Jt({id:"c",extensions:[".c",".h"],aliases:["C","c"],loader:()=>re(()=>import("./cpp-BbWJElDN.js"),[])});Jt({id:"cpp",extensions:[".cpp",".cc",".cxx",".hpp",".hh",".hxx"],aliases:["C++","Cpp","cpp"],loader:()=>re(()=>import("./cpp-BbWJElDN.js"),[])});Jt({id:"csharp",extensions:[".cs",".csx",".cake"],aliases:["C#","csharp"],loader:()=>re(()=>import("./csharp-Co3qMtFm.js"),[])});Jt({id:"csp",extensions:[".csp"],aliases:["CSP","csp"],loader:()=>re(()=>import("./csp-D-4FJmMZ.js"),[])});Jt({id:"css",extensions:[".css"],aliases:["CSS","css"],mimetypes:["text/css"],loader:()=>re(()=>import("./css-DdJfP1eB.js"),[])});Jt({id:"cypher",extensions:[".cypher",".cyp"],aliases:["Cypher","OpenCypher"],loader:()=>re(()=>import("./cypher-cTPe9QuQ.js"),[])});Jt({id:"dart",extensions:[".dart"],aliases:["Dart","dart"],mimetypes:["text/x-dart-source","text/x-dart"],loader:()=>re(()=>import("./dart-BOtBlQCF.js"),[])});Jt({id:"dockerfile",extensions:[".dockerfile"],filenames:["Dockerfile"],aliases:["Dockerfile"],loader:()=>re(()=>import("./dockerfile-BG73LgW2.js"),[])});Jt({id:"ecl",extensions:[".ecl"],aliases:["ECL","Ecl","ecl"],loader:()=>re(()=>import("./ecl-BEgZUVRK.js"),[])});Jt({id:"elixir",extensions:[".ex",".exs"],aliases:["Elixir","elixir","ex"],loader:()=>re(()=>import("./elixir-BkW5O-1t.js"),[])});Jt({id:"flow9",extensions:[".flow"],aliases:["Flow9","Flow","flow9","flow"],loader:()=>re(()=>import("./flow9-BeJ5waoc.js"),[])});Jt({id:"fsharp",extensions:[".fs",".fsi",".ml",".mli",".fsx",".fsscript"],aliases:["F#","FSharp","fsharp"],loader:()=>re(()=>import("./fsharp-PahG7c26.js"),[])});Jt({id:"freemarker2",extensions:[".ftl",".ftlh",".ftlx"],aliases:["FreeMarker2","Apache FreeMarker2"],loader:()=>re(()=>import("./freemarker2-b_gJmXuF.js"),[]).then(n=>n.TagAutoInterpolationDollar)});Jt({id:"freemarker2.tag-angle.interpolation-dollar",aliases:["FreeMarker2 (Angle/Dollar)","Apache FreeMarker2 (Angle/Dollar)"],loader:()=>re(()=>import("./freemarker2-b_gJmXuF.js"),[]).then(n=>n.TagAngleInterpolationDollar)});Jt({id:"freemarker2.tag-bracket.interpolation-dollar",aliases:["FreeMarker2 (Bracket/Dollar)","Apache FreeMarker2 (Bracket/Dollar)"],loader:()=>re(()=>import("./freemarker2-b_gJmXuF.js"),[]).then(n=>n.TagBracketInterpolationDollar)});Jt({id:"freemarker2.tag-angle.interpolation-bracket",aliases:["FreeMarker2 (Angle/Bracket)","Apache FreeMarker2 (Angle/Bracket)"],loader:()=>re(()=>import("./freemarker2-b_gJmXuF.js"),[]).then(n=>n.TagAngleInterpolationBracket)});Jt({id:"freemarker2.tag-bracket.interpolation-bracket",aliases:["FreeMarker2 (Bracket/Bracket)","Apache FreeMarker2 (Bracket/Bracket)"],loader:()=>re(()=>import("./freemarker2-b_gJmXuF.js"),[]).then(n=>n.TagBracketInterpolationBracket)});Jt({id:"freemarker2.tag-auto.interpolation-dollar",aliases:["FreeMarker2 (Auto/Dollar)","Apache FreeMarker2 (Auto/Dollar)"],loader:()=>re(()=>import("./freemarker2-b_gJmXuF.js"),[]).then(n=>n.TagAutoInterpolationDollar)});Jt({id:"freemarker2.tag-auto.interpolation-bracket",aliases:["FreeMarker2 (Auto/Bracket)","Apache FreeMarker2 (Auto/Bracket)"],loader:()=>re(()=>import("./freemarker2-b_gJmXuF.js"),[]).then(n=>n.TagAutoInterpolationBracket)});Jt({id:"go",extensions:[".go"],aliases:["Go"],loader:()=>re(()=>import("./go-acbASCJo.js"),[])});Jt({id:"graphql",extensions:[".graphql",".gql"],aliases:["GraphQL","graphql","gql"],mimetypes:["application/graphql"],loader:()=>re(()=>import("./graphql-BxJiqAUM.js"),[])});Jt({id:"handlebars",extensions:[".handlebars",".hbs"],aliases:["Handlebars","handlebars","hbs"],mimetypes:["text/x-handlebars-template"],loader:()=>re(()=>import("./handlebars-CWhoL04S.js"),[])});Jt({id:"hcl",extensions:[".tf",".tfvars",".hcl"],aliases:["Terraform","tf","HCL","hcl"],loader:()=>re(()=>import("./hcl-DtV1sZF8.js"),[])});Jt({id:"html",extensions:[".html",".htm",".shtml",".xhtml",".mdoc",".jsp",".asp",".aspx",".jshtm"],aliases:["HTML","htm","html","xhtml"],mimetypes:["text/html","text/x-jshtm","text/template","text/ng-template"],loader:()=>re(()=>import("./html-DyrmcYNn.js"),[])});Jt({id:"ini",extensions:[".ini",".properties",".gitconfig"],filenames:["config",".gitattributes",".gitconfig",".editorconfig"],aliases:["Ini","ini"],loader:()=>re(()=>import("./ini-Kd9XrMLS.js"),[])});Jt({id:"java",extensions:[".java",".jav"],aliases:["Java","java"],mimetypes:["text/x-java-source","text/x-java"],loader:()=>re(()=>import("./java-CXBNlu9o.js"),[])});Jt({id:"javascript",extensions:[".js",".es6",".jsx",".mjs",".cjs"],firstLine:"^#!.*\\bnode",filenames:["jakefile"],aliases:["JavaScript","javascript","js"],mimetypes:["text/javascript"],loader:()=>re(()=>import("./javascript-BgX3Uy8S.js"),__vite__mapDeps([101,102]))});Jt({id:"julia",extensions:[".jl"],aliases:["julia","Julia"],loader:()=>re(()=>import("./julia-cl7-CwDS.js"),[])});Jt({id:"kotlin",extensions:[".kt",".kts"],aliases:["Kotlin","kotlin"],mimetypes:["text/x-kotlin-source","text/x-kotlin"],loader:()=>re(()=>import("./kotlin-s7OhZKlX.js"),[])});Jt({id:"less",extensions:[".less"],aliases:["Less","less"],mimetypes:["text/x-less","text/less"],loader:()=>re(()=>import("./less-9HpZscsL.js"),[])});Jt({id:"lexon",extensions:[".lex"],aliases:["Lexon"],loader:()=>re(()=>import("./lexon-OrD6JF1K.js"),[])});Jt({id:"lua",extensions:[".lua"],aliases:["Lua","lua"],loader:()=>re(()=>import("./lua-Cyyb5UIc.js"),[])});Jt({id:"liquid",extensions:[".liquid",".html.liquid"],aliases:["Liquid","liquid"],mimetypes:["application/liquid"],loader:()=>re(()=>import("./liquid-BySBA1oH.js"),[])});Jt({id:"m3",extensions:[".m3",".i3",".mg",".ig"],aliases:["Modula-3","Modula3","modula3","m3"],loader:()=>re(()=>import("./m3-B8OfTtLu.js"),[])});Jt({id:"markdown",extensions:[".md",".markdown",".mdown",".mkdn",".mkd",".mdwn",".mdtxt",".mdtext"],aliases:["Markdown","markdown"],loader:()=>re(()=>import("./markdown-BFxVWTOG.js"),[])});Jt({id:"mdx",extensions:[".mdx"],aliases:["MDX","mdx"],loader:()=>re(()=>import("./mdx-BQ6MhT52.js"),[])});Jt({id:"mips",extensions:[".s"],aliases:["MIPS","MIPS-V"],mimetypes:["text/x-mips","text/mips","text/plaintext"],loader:()=>re(()=>import("./mips-CiqrrVzr.js"),[])});Jt({id:"msdax",extensions:[".dax",".msdax"],aliases:["DAX","MSDAX"],loader:()=>re(()=>import("./msdax-DmeGPVcC.js"),[])});Jt({id:"mysql",extensions:[],aliases:["MySQL","mysql"],loader:()=>re(()=>import("./mysql-C_tMU-Nz.js"),[])});Jt({id:"objective-c",extensions:[".m"],aliases:["Objective-C"],loader:()=>re(()=>import("./objective-c-BDtDVThU.js"),[])});Jt({id:"pascal",extensions:[".pas",".p",".pp"],aliases:["Pascal","pas"],mimetypes:["text/x-pascal-source","text/x-pascal"],loader:()=>re(()=>import("./pascal-vHIfCaH5.js"),[])});Jt({id:"pascaligo",extensions:[".ligo"],aliases:["Pascaligo","ligo"],loader:()=>re(()=>import("./pascaligo-DtZ0uQbO.js"),[])});Jt({id:"perl",extensions:[".pl",".pm"],aliases:["Perl","pl"],loader:()=>re(()=>import("./perl-Ub6l9XKa.js"),[])});Jt({id:"pgsql",extensions:[],aliases:["PostgreSQL","postgres","pg","postgre"],loader:()=>re(()=>import("./pgsql-BlNEE0v7.js"),[])});Jt({id:"php",extensions:[".php",".php4",".php5",".phtml",".ctp"],aliases:["PHP","php"],mimetypes:["application/x-php"],loader:()=>re(()=>import("./php-BBUBE1dy.js"),[])});Jt({id:"pla",extensions:[".pla"],loader:()=>re(()=>import("./pla-DSh2-awV.js"),[])});Jt({id:"postiats",extensions:[".dats",".sats",".hats"],aliases:["ATS","ATS/Postiats"],loader:()=>re(()=>import("./postiats-CocnycG-.js"),[])});Jt({id:"powerquery",extensions:[".pq",".pqm"],aliases:["PQ","M","Power Query","Power Query M"],loader:()=>re(()=>import("./powerquery-tScXyioY.js"),[])});Jt({id:"powershell",extensions:[".ps1",".psm1",".psd1"],aliases:["PowerShell","powershell","ps","ps1"],loader:()=>re(()=>import("./powershell-COWaemsV.js"),[])});Jt({id:"proto",extensions:[".proto"],aliases:["protobuf","Protocol Buffers"],loader:()=>re(()=>import("./protobuf-Brw8urJB.js"),[])});Jt({id:"pug",extensions:[".jade",".pug"],aliases:["Pug","Jade","jade"],loader:()=>re(()=>import("./pug-8SOpv6rk.js"),[])});Jt({id:"python",extensions:[".py",".rpy",".pyw",".cpy",".gyp",".gypi"],aliases:["Python","py"],firstLine:"^#!/.*\\bpython[0-9.-]*\\b",loader:()=>re(()=>import("./python-C3bCba7U.js"),[])});Jt({id:"qsharp",extensions:[".qs"],aliases:["Q#","qsharp"],loader:()=>re(()=>import("./qsharp-Bw9ernYp.js"),[])});Jt({id:"r",extensions:[".r",".rhistory",".rmd",".rprofile",".rt"],aliases:["R","r"],loader:()=>re(()=>import("./r-j7ic8hl3.js"),[])});Jt({id:"razor",extensions:[".cshtml"],aliases:["Razor","razor"],mimetypes:["text/x-cshtml"],loader:()=>re(()=>import("./razor-DWZY4z0v.js"),[])});Jt({id:"redis",extensions:[".redis"],aliases:["redis"],loader:()=>re(()=>import("./redis-Bu5POkcn.js"),[])});Jt({id:"redshift",extensions:[],aliases:["Redshift","redshift"],loader:()=>re(()=>import("./redshift-Bs9aos_-.js"),[])});Jt({id:"restructuredtext",extensions:[".rst"],aliases:["reStructuredText","restructuredtext"],loader:()=>re(()=>import("./restructuredtext-CqXO7rUv.js"),[])});Jt({id:"ruby",extensions:[".rb",".rbx",".rjs",".gemspec",".pp"],filenames:["rakefile","Gemfile"],aliases:["Ruby","rb"],loader:()=>re(()=>import("./ruby-zBfavPgS.js"),[])});Jt({id:"rust",extensions:[".rs",".rlib"],aliases:["Rust","rust"],loader:()=>re(()=>import("./rust-BzKRNQWT.js"),[])});Jt({id:"sb",extensions:[".sb"],aliases:["Small Basic","sb"],loader:()=>re(()=>import("./sb-BBc9UKZt.js"),[])});Jt({id:"scala",extensions:[".scala",".sc",".sbt"],aliases:["Scala","scala","SBT","Sbt","sbt","Dotty","dotty"],mimetypes:["text/x-scala-source","text/x-scala","text/x-sbt","text/x-dotty"],loader:()=>re(()=>import("./scala-D9hQfWCl.js"),[])});Jt({id:"scheme",extensions:[".scm",".ss",".sch",".rkt"],aliases:["scheme","Scheme"],loader:()=>re(()=>import("./scheme-BPhDTwHR.js"),[])});Jt({id:"scss",extensions:[".scss"],aliases:["Sass","sass","scss"],mimetypes:["text/x-scss","text/scss"],loader:()=>re(()=>import("./scss-CBJaRo0y.js"),[])});Jt({id:"shell",extensions:[".sh",".bash"],aliases:["Shell","sh"],loader:()=>re(()=>import("./shell-DiJ1NA_G.js"),[])});Jt({id:"sol",extensions:[".sol"],aliases:["sol","solidity","Solidity"],loader:()=>re(()=>import("./solidity-Db0IVjzk.js"),[])});Jt({id:"aes",extensions:[".aes"],aliases:["aes","sophia","Sophia"],loader:()=>re(()=>import("./sophia-CnS9iZB_.js"),[])});Jt({id:"sparql",extensions:[".rq"],aliases:["sparql","SPARQL"],loader:()=>re(()=>import("./sparql-CJmd_6j2.js"),[])});Jt({id:"sql",extensions:[".sql"],aliases:["SQL"],loader:()=>re(()=>import("./sql-ClhHkBeG.js"),[])});Jt({id:"st",extensions:[".st",".iecst",".iecplc",".lc3lib",".TcPOU",".TcDUT",".TcGVL",".TcIO"],aliases:["StructuredText","scl","stl"],loader:()=>re(()=>import("./st-CHwy0fLd.js"),[])});Jt({id:"swift",aliases:["Swift","swift"],extensions:[".swift"],mimetypes:["text/swift"],loader:()=>re(()=>import("./swift-Bqt4WxQ4.js"),[])});Jt({id:"systemverilog",extensions:[".sv",".svh"],aliases:["SV","sv","SystemVerilog","systemverilog"],loader:()=>re(()=>import("./systemverilog-Bs9z6M-B.js"),[])});Jt({id:"verilog",extensions:[".v",".vh"],aliases:["V","v","Verilog","verilog"],loader:()=>re(()=>import("./systemverilog-Bs9z6M-B.js"),[])});Jt({id:"tcl",extensions:[".tcl"],aliases:["tcl","Tcl","tcltk","TclTk","tcl/tk","Tcl/Tk"],loader:()=>re(()=>import("./tcl-Dm6ycUr_.js"),[])});Jt({id:"twig",extensions:[".twig"],aliases:["Twig","twig"],mimetypes:["text/x-twig"],loader:()=>re(()=>import("./twig-Csy3S7wG.js"),[])});Jt({id:"typescript",extensions:[".ts",".tsx",".cts",".mts"],aliases:["TypeScript","ts","typescript"],mimetypes:["text/typescript"],loader:()=>re(()=>import("./typescript-IXjxtali.js"),[])});Jt({id:"typespec",extensions:[".tsp"],aliases:["TypeSpec"],loader:()=>re(()=>import("./typespec-Btyra-wh.js"),[])});Jt({id:"vb",extensions:[".vb"],aliases:["Visual Basic","vb"],loader:()=>re(()=>import("./vb-Db0cS2oM.js"),[])});Jt({id:"wgsl",extensions:[".wgsl"],aliases:["WebGPU Shading Language","WGSL","wgsl"],loader:()=>re(()=>import("./wgsl-BTesnYfV.js"),[])});Jt({id:"xml",extensions:[".xml",".xsd",".dtd",".ascx",".csproj",".config",".props",".targets",".wxi",".wxl",".wxs",".xaml",".svg",".svgz",".opf",".xslt",".xsl"],firstLine:"(\\<\\?xml.*)|(\\<svg)|(\\<\\!doctype\\s+svg)",aliases:["XML","xml"],mimetypes:["text/xml","application/xml","application/xaml+xml","application/xml-dtd"],loader:()=>re(()=>import("./xml-z63Txqyp.js"),[])});Jt({id:"yaml",extensions:[".yaml",".yml"],aliases:["YAML","yaml","YML","yml"],mimetypes:["application/x-yaml","text/x-yaml"],loader:()=>re(()=>import("./yaml-N2kAbToy.js"),[])});var emn=Object.defineProperty,tmn=(n,e,t)=>e in n?emn(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Zt=(n,e,t)=>tmn(n,typeof e!="symbol"?e+"":e,t),xR,USe,LR,cY,kR;function nmn(n){return n.method!==void 0}var KSe;(function(n){function e(t){return t}n.create=e})(KSe||(KSe={}));var rh;(function(n){n.parseError=-32700,n.invalidRequest=-32600,n.methodNotFound=-32601,n.invalidParams=-32602,n.internalError=-32603;function e(r){return-32099<=r&&r<=-32e3}n.isServerError=e;function t(r){if(!e(r))throw new Error("Invalid range for a server error.");return r}n.serverError=t,n.unexpectedServerError=-32e3;function i(r){return!0}n.isApplicationError=i;function s(r){return r}n.applicationError=s,n.genericApplicationError=-320100})(rh||(rh={}));var B2e=class{constructor(){Zt(this,"listeners",new Set),Zt(this,"event",n=>(this.listeners.add(n),{dispose:()=>{this.listeners.delete(n)}}))}fire(n){this.listeners.forEach(e=>e(n))}},imn=class{constructor(n){Zt(this,"_value"),Zt(this,"eventEmitter"),this._value=n,this.eventEmitter=new B2e}get value(){return this._value}set value(n){this._value!==n&&(this._value=n,this.eventEmitter.fire(n))}get onChange(){return this.eventEmitter.event}};function smn(n,e){const t=setTimeout(e,n);return{dispose:()=>clearTimeout(t)}}function dY(n,e,t){return n instanceof Set?(n.add(e),{dispose:()=>n.delete(e)}):(n.set(e,t),{dispose:()=>n.delete(e)})}var rmn=class{constructor(){Zt(this,"_state","none"),Zt(this,"promise"),Zt(this,"resolve",()=>{}),Zt(this,"reject",()=>{}),this.promise=new Promise((n,e)=>{this.resolve=n,this.reject=e})}get state(){return this._state}},Pqe=(xR=class{constructor(){Zt(this,"_unprocessedMessages",[]),Zt(this,"_messageListener"),Zt(this,"id",xR.id++),Zt(this,"_state",new imn({state:"open"})),Zt(this,"state",this._state)}setListener(n){if(this._messageListener=n,!!n)for(;this._unprocessedMessages.length>0&&this._messageListener!==void 0;){const e=this._unprocessedMessages.shift();this._messageListener(e)}}send(n){return this._sendImpl(n)}_dispatchReceivedMessage(n){this._unprocessedMessages.length===0&&this._messageListener?this._messageListener(n):this._unprocessedMessages.push(n)}_onConnectionClosed(){this._state.value={state:"closed",error:void 0}}log(n){return new omn(this,n??new amn)}},Zt(xR,"id",0),xR),omn=class{constructor(n,e){Zt(this,"baseStream"),Zt(this,"logger"),this.baseStream=n,this.logger=e}get state(){return this.baseStream.state}setListener(n){if(n===void 0){this.baseStream.setListener(void 0);return}this.baseStream.setListener(e=>{this.logger.log(this.baseStream,"incoming",e),n(e)})}send(n){return this.logger.log(this.baseStream,"outgoing",n),this.baseStream.send(n)}toString(){return`StreamLogger/${this.baseStream.toString()}`}},amn=class{log(n,e,t){console.log(`${e==="incoming"?"<-":"->"} [${n.toString()}] ${JSON.stringify(t)}`)}},lmn=class Aqe{constructor(e){Zt(this,"connect"),this.connect=e}mapContext(e){return new Aqe(t=>this.connect(t?cmn(t,e):void 0))}};function cmn(n,e){return{handleNotification:(t,i)=>n.handleNotification(t,e(i)),handleRequest:(t,i,s)=>n.handleRequest(t,i,e(s))}}var dmn=class Oqe{constructor(e,t,i){Zt(this,"_stream"),Zt(this,"_listener"),Zt(this,"_logger"),Zt(this,"_unprocessedResponses",new Map),Zt(this,"_lastUsedRequestId",0),this._stream=e,this._listener=t,this._logger=i,this._stream.setListener(s=>{nmn(s)?s.id===void 0?this._processNotification(s):this._processRequest(s):this._processResponse(s)})}static createChannel(e,t){let i=!1;return new lmn(s=>{if(i)throw new Error(`A channel to the stream ${e} was already constructed!`);return i=!0,new Oqe(e,s,t)})}get state(){return this._stream.state}async _processNotification(e){if(e.id!==void 0)throw new Error;if(!this._listener){this._logger&&this._logger.debug({text:"Notification ignored",message:e});return}try{await this._listener.handleNotification({method:e.method,params:e.params||null})}catch(t){this._logger&&this._logger.warn({text:`Exception was thrown while handling notification: ${t}`,exception:t,message:e})}}async _processRequest(e){if(e.id===void 0)throw new Error;let t;if(this._listener)try{t=await this._listener.handleRequest({method:e.method,params:e.params||null},e.id)}catch(s){this._logger&&this._logger.warn({text:`Exception was thrown while handling request: ${s}`,message:e,exception:s}),t={error:{code:rh.internalError,message:"An unexpected exception was thrown.",data:void 0}}}else this._logger&&this._logger.debug({text:"Received request even though not listening for requests",message:e}),t={error:{code:rh.methodNotFound,message:"This endpoint does not listen for requests or notifications.",data:void 0}};let i;"result"in t?i={jsonrpc:"2.0",id:e.id,result:t.result}:i={jsonrpc:"2.0",id:e.id,error:t.error},await this._stream.send(i)}_processResponse(e){const t=""+e.id,i=this._unprocessedResponses.get(t);if(!i){this._logger&&this._logger.debug({text:"Got an unexpected response message",message:e});return}this._unprocessedResponses.delete(t),i(e)}_newRequestId(){return this._lastUsedRequestId++}sendRequest(e,t,i){const s={jsonrpc:"2.0",id:this._newRequestId(),method:e.method,params:e.params||void 0};return i&&i(s.id),new Promise((r,o)=>{const a=""+s.id;this._unprocessedResponses.set(a,l=>{"result"in l?r({result:l.result}):(l.error||o(new Error("Response had neither 'result' nor 'error' field set.")),r({error:l.error}))}),this._stream.send(s).then(void 0,l=>{this._unprocessedResponses.delete(a),o(l)})})}sendNotification(e,t){const i={jsonrpc:"2.0",id:void 0,method:e.method,params:e.params||void 0};return this._stream.send(i)}toString(){return"StreamChannel/"+this._stream.toString()}},Qv;(function(n){function e(){return{deserializeFromJson:s=>({hasErrors:!1,value:s}),serializeToJson:s=>s}}n.sAny=e;function t(){return{deserializeFromJson:s=>({hasErrors:!1,value:{}}),serializeToJson:s=>({})}}n.sEmptyObject=t;function i(){return{deserializeFromJson:s=>({hasErrors:!1,value:void 0}),serializeToJson:s=>null}}n.sVoidFromNull=i})(Qv||(Qv={}));const Fqe=Symbol("OptionalMethodNotFound");var Bqe=class{contextualize(n){return new umn(this,n)}},umn=class extends Bqe{constructor(n,e){super(),Zt(this,"underylingTypedChannel"),Zt(this,"converters"),this.underylingTypedChannel=n,this.converters=e}async request(n,e,t){const i=await this.converters.getSendContext(t);return this.underylingTypedChannel.request(n,e,i)}async notify(n,e,t){const i=await this.converters.getSendContext(t);return this.underylingTypedChannel.notify(n,e,i)}registerNotificationHandler(n,e){return this.underylingTypedChannel.registerNotificationHandler(n,async(t,i)=>await e(t,await this.converters.getNewContext(i)))}registerRequestHandler(n,e){return this.underylingTypedChannel.registerRequestHandler(n,async(t,i,s)=>await e(t,i,await this.converters.getNewContext(s)))}},hce=class $qe extends Bqe{constructor(e,t={}){super(),Zt(this,"channelCtor"),Zt(this,"_requestSender"),Zt(this,"_handler",new Map),Zt(this,"_unknownNotificationHandler",new Set),Zt(this,"_timeout"),Zt(this,"sendExceptionDetails",!1),Zt(this,"_logger"),Zt(this,"listeningDeferred",new rmn),Zt(this,"onListening",this.listeningDeferred.promise),Zt(this,"_requestDidErrorEventEmitter",new B2e),Zt(this,"onRequestDidError",this._requestDidErrorEventEmitter.event),this.channelCtor=e,this._logger=t.logger,this.sendExceptionDetails=!!t.sendExceptionDetails,this._timeout=smn(1e3,()=>{this._requestSender||console.warn(`"${this.startListen.name}" has not been called within 1 second after construction of this channel. Did you forget to call it?`,this)})}static fromTransport(e,t={}){return new $qe(dmn.createChannel(e,t.logger),t)}startListen(){if(this._requestSender)throw new Error(`"${this.startListen.name}" can be called only once, but it already has been called.`);this._timeout&&(this._timeout.dispose(),this._timeout=void 0),this._requestSender=this.channelCtor.connect({handleRequest:(e,t,i)=>this.handleRequest(e,t,i),handleNotification:(e,t)=>this.handleNotification(e,t)}),this.listeningDeferred.resolve()}checkChannel(e){if(!e)throw new Error(`"${this.startListen.name}" must be called before any messages can be sent or received.`);return!0}async handleRequest(e,t,i){const s=this._handler.get(e.method);if(!s)return this._logger&&this._logger.debug({text:`No request handler for "${e.method}".`,data:{requestObject:e}}),{error:{code:rh.methodNotFound,message:`No request handler for "${e.method}".`,data:{method:e.method}}};if(s.kind!="request"){const o=`"${e.method}" is registered as notification, but was sent as request.`;return this._logger&&this._logger.debug({text:o,data:{requestObject:e}}),{error:{code:rh.invalidRequest,message:o,data:{method:e.method}}}}const r=s.requestType.paramsSerializer.deserializeFromJson(e.params);if(r.hasErrors){const o=`Got invalid params: ${r.errorMessage}`;return this._logger&&this._logger.debug({text:o,data:{requestObject:e,errorMessage:r.errorMessage}}),{error:{code:rh.invalidParams,message:o,data:{errors:r.errorMessage}}}}else{const o=r.value;let a;try{const l=await s.handler(o,t,i);if("error"in l||"errorMessage"in l){const c=l.error?s.requestType.errorSerializer.serializeToJson(l.error):void 0;a={error:{code:l.errorCode||rh.genericApplicationError,message:l.errorMessage||"An error was returned",data:c}}}else a={result:s.requestType.resultSerializer.serializeToJson(l.ok)}}catch(l){l instanceof qSe?a={error:{code:l.code,message:l.message}}:(this._logger&&this._logger.warn({text:`An exception was thrown while handling a request: ${l}.`,exception:l,data:{requestObject:e}}),a={error:{code:rh.unexpectedServerError,message:this.sendExceptionDetails?`An exception was thrown while handling a request: ${l}.`:"Server has thrown an unexpected exception"}})}return a}}async handleNotification(e,t){const i=this._handler.get(e.method);if(!i){for(const o of this._unknownNotificationHandler)o(e);this._unknownNotificationHandler.size===0&&this._logger&&this._logger.debug({text:`Unhandled notification "${e.method}"`,data:{requestObject:e}});return}if(i.kind!="notification"){this._logger&&this._logger.debug({text:`"${e.method}" is registered as request, but was sent as notification.`,data:{requestObject:e}});return}const s=i.notificationType.paramsSerializer.deserializeFromJson(e.params);if(s.hasErrors){this._logger&&this._logger.debug({text:`Got invalid params: ${s}`,data:{requestObject:e,errorMessage:s.errorMessage}});return}const r=s.value;for(const o of i.handlers)try{o(r,t)}catch(a){this._logger&&this._logger.warn({text:`An exception was thrown while handling a notification: ${a}.`,exception:a,data:{requestObject:e}})}}registerUnknownNotificationHandler(e){return dY(this._unknownNotificationHandler,e)}registerRequestHandler(e,t){if(this._handler.get(e.method))throw new Error(`Handler with method "${e.method}" already registered.`);return dY(this._handler,e.method,{kind:"request",requestType:e,handler:t})}registerNotificationHandler(e,t){let i=this._handler.get(e.method);if(!i)i={kind:"notification",notificationType:e,handlers:new Set},this._handler.set(e.method,i);else{if(i.kind!=="notification")throw new Error(`Method "${e.method}" was already registered as request handler.`);if(i.notificationType!==e)throw new Error(`Method "${e.method}" was registered for a different type.`)}return dY(i.handlers,t)}getRegisteredTypes(){const e=[];for(const t of this._handler.values())t.kind==="notification"?e.push(t.notificationType):t.kind==="request"&&e.push(t.requestType);return e}async request(e,t,i){if(!this.checkChannel(this._requestSender))throw new Error("Impossible");const s=e.paramsSerializer.serializeToJson(t);ZSe(s);const r=await this._requestSender.sendRequest({method:e.method,params:s},i);if("error"in r){if(e.isOptional&&r.error.code===rh.methodNotFound)return Fqe;let o;if(r.error.data!==void 0){const l=e.errorSerializer.deserializeFromJson(r.error.data);if(l.hasErrors)throw new Error(l.errorMessage);o=l.value}else o=void 0;const a=new qSe(r.error.message,o,r.error.code);throw this._requestDidErrorEventEmitter.fire({error:a}),a}else{const o=e.resultSerializer.deserializeFromJson(r.result);if(o.hasErrors)throw new Error("Could not deserialize response: "+o.errorMessage+`
1482
+ hint: use the 'bracket' attribute if matching on equal brackets is required.`);if(typeof a.open=="string"&&typeof a.token=="string"&&typeof a.close=="string")r.push({token:a.token+t.tokenPostfix,open:m0(t,a.open),close:m0(t,a.close)});else throw Es(t,"every element in the 'brackets' array must be a '{open,close,token}' object or array")}return t.brackets=r,t.noThrow=!0,t}function egn(n){Gb.registerLanguage(n)}function tgn(){let n=[];return n=n.concat(Gb.getLanguages()),n}function ngn(n){return Cn.get(lr).languageIdCodec.encodeLanguageId(n)}function ign(n,e){return Cn.withServices(()=>{const i=Cn.get(lr).onDidRequestRichLanguageFeatures(s=>{s===n&&(i.dispose(),e())});return i})}function sgn(n,e){return Cn.withServices(()=>{const i=Cn.get(lr).onDidRequestBasicLanguageFeatures(s=>{s===n&&(i.dispose(),e())});return i})}function rgn(n,e){if(!Cn.get(lr).isRegisteredLanguageId(n))throw new Error(`Cannot set configuration for unknown language ${n}`);return Cn.get(Ws).register(n,e,100)}class ogn{constructor(e,t){this._languageId=e,this._actual=t}dispose(){}getInitialState(){return this._actual.getInitialState()}tokenize(e,t,i){if(typeof this._actual.tokenize=="function")return eM.adaptTokenize(this._languageId,this._actual,e,i);throw new Error("Not supported!")}tokenizeEncoded(e,t,i){const s=this._actual.tokenizeEncoded(e,i);return new tU(s.tokens,s.endState)}}class eM{constructor(e,t,i,s){this._languageId=e,this._actual=t,this._languageService=i,this._standaloneThemeService=s}dispose(){}getInitialState(){return this._actual.getInitialState()}static _toClassicTokens(e,t){const i=[];let s=0;for(let r=0,o=e.length;r<o;r++){const a=e[r];let l=a.startIndex;r===0?l=0:l<s&&(l=s),i[r]=new BE(l,a.scopes,t),s=l}return i}static adaptTokenize(e,t,i,s){const r=t.tokenize(i,s),o=eM._toClassicTokens(r.tokens,e);let a;return r.endState.equals(s)?a=s:a=r.endState,new Q1e(o,a)}tokenize(e,t,i){return eM.adaptTokenize(this._languageId,this._actual,e,i)}_toBinaryTokens(e,t){const i=e.encodeLanguageId(this._languageId),s=this._standaloneThemeService.getColorTheme().tokenTheme,r=[];let o=0,a=0;for(let c=0,d=t.length;c<d;c++){const u=t[c],h=s.match(i,u.scopes)|1024;if(o>0&&r[o-1]===h)continue;let f=u.startIndex;c===0?f=0:f<a&&(f=a),r[o++]=f,r[o++]=h,a=f}const l=new Uint32Array(o);for(let c=0;c<o;c++)l[c]=r[c];return l}tokenizeEncoded(e,t,i){const s=this._actual.tokenize(e,i),r=this._toBinaryTokens(this._languageService.languageIdCodec,s.tokens);let o;return s.endState.equals(i)?o=i:o=s.endState,new tU(r,o)}}function agn(n){return typeof n.getInitialState=="function"}function lgn(n){return"tokenizeEncoded"in n}function oqe(n){return n&&typeof n.then=="function"}function cgn(n){const e=Cn.get(Ru);if(n){const t=[null];for(let i=1,s=n.length;i<s;i++)t[i]=Be.fromHex(n[i]);e.setColorMapOverride(t)}else e.setColorMapOverride(null)}function aqe(n,e){return lgn(e)?new ogn(n,e):new eM(n,e,Cn.get(lr),Cn.get(Ru))}function N2e(n,e){const t=new oUt(async()=>{const i=await Promise.resolve(e.create());return i?agn(i)?aqe(n,i):new ZI(Cn.get(lr),Cn.get(Ru),n,rqe(n,i),Cn.get(Ln)):null});return nr.registerFactory(n,t)}function dgn(n,e){if(!Cn.get(lr).isRegisteredLanguageId(n))throw new Error(`Cannot set tokens provider for unknown language ${n}`);return oqe(e)?N2e(n,{create:()=>e}):nr.register(n,aqe(n,e))}function ugn(n,e){const t=i=>new ZI(Cn.get(lr),Cn.get(Ru),n,rqe(n,i),Cn.get(Ln));return oqe(e)?N2e(n,{create:()=>e}):nr.register(n,t(e))}function hgn(n,e){return Cn.get(Nt).referenceProvider.register(n,e)}function fgn(n,e){return Cn.get(Nt).renameProvider.register(n,e)}function ggn(n,e){return Cn.get(Nt).newSymbolNamesProvider.register(n,e)}function mgn(n,e){return Cn.get(Nt).signatureHelpProvider.register(n,e)}function pgn(n,e){return Cn.get(Nt).hoverProvider.register(n,{provideHover:async(i,s,r,o)=>{const a=i.getWordAtPosition(s);return Promise.resolve(e.provideHover(i,s,r,o)).then(l=>{if(l)return!l.range&&a&&(l.range=new z(s.lineNumber,a.startColumn,s.lineNumber,a.endColumn)),l.range||(l.range=new z(s.lineNumber,s.column,s.lineNumber,s.column)),l})}})}function Cgn(n,e){return Cn.get(Nt).documentSymbolProvider.register(n,e)}function _gn(n,e){return Cn.get(Nt).documentHighlightProvider.register(n,e)}function vgn(n,e){return Cn.get(Nt).linkedEditingRangeProvider.register(n,e)}function bgn(n,e){return Cn.get(Nt).definitionProvider.register(n,e)}function ygn(n,e){return Cn.get(Nt).implementationProvider.register(n,e)}function wgn(n,e){return Cn.get(Nt).typeDefinitionProvider.register(n,e)}function Sgn(n,e){return Cn.get(Nt).codeLensProvider.register(n,e)}function xgn(n,e,t){return Cn.get(Nt).codeActionProvider.register(n,{providedCodeActionKinds:t==null?void 0:t.providedCodeActionKinds,documentation:t==null?void 0:t.documentation,provideCodeActions:(s,r,o,a)=>{const c=Cn.get(Hf).read({resource:s.uri}).filter(d=>z.areIntersectingOrTouching(d,r));return e.provideCodeActions(s,r,{markers:c,only:o.only,trigger:o.trigger},a)},resolveCodeAction:e.resolveCodeAction})}function Lgn(n,e){return Cn.get(Nt).documentFormattingEditProvider.register(n,e)}function kgn(n,e){return Cn.get(Nt).documentRangeFormattingEditProvider.register(n,e)}function Egn(n,e){return Cn.get(Nt).onTypeFormattingEditProvider.register(n,e)}function Ign(n,e){return Cn.get(Nt).linkProvider.register(n,e)}function Mgn(n,e){return Cn.get(Nt).completionProvider.register(n,e)}function Ngn(n,e){return Cn.get(Nt).colorProvider.register(n,e)}function Dgn(n,e){return Cn.get(Nt).foldingRangeProvider.register(n,e)}function Tgn(n,e){return Cn.get(Nt).declarationProvider.register(n,e)}function Rgn(n,e){return Cn.get(Nt).selectionRangeProvider.register(n,e)}function Pgn(n,e){return Cn.get(Nt).documentSemanticTokensProvider.register(n,e)}function Agn(n,e){return Cn.get(Nt).documentRangeSemanticTokensProvider.register(n,e)}function Ogn(n,e){return Cn.get(Nt).inlineCompletionsProvider.register(n,e)}function Fgn(n,e){return Cn.get(Nt).inlayHintsProvider.register(n,e)}function Bgn(){return{register:egn,getLanguages:tgn,onLanguage:ign,onLanguageEncountered:sgn,getEncodedLanguageId:ngn,setLanguageConfiguration:rgn,setColorMap:cgn,registerTokensProviderFactory:N2e,setTokensProvider:dgn,setMonarchTokensProvider:ugn,registerReferenceProvider:hgn,registerRenameProvider:fgn,registerNewSymbolNameProvider:ggn,registerCompletionItemProvider:Mgn,registerSignatureHelpProvider:mgn,registerHoverProvider:pgn,registerDocumentSymbolProvider:Cgn,registerDocumentHighlightProvider:_gn,registerLinkedEditingRangeProvider:vgn,registerDefinitionProvider:bgn,registerImplementationProvider:ygn,registerTypeDefinitionProvider:wgn,registerCodeLensProvider:Sgn,registerCodeActionProvider:xgn,registerDocumentFormattingEditProvider:Lgn,registerDocumentRangeFormattingEditProvider:kgn,registerOnTypeFormattingEditProvider:Egn,registerLinkProvider:Ign,registerColorProvider:Ngn,registerFoldingRangeProvider:Dgn,registerDeclarationProvider:Tgn,registerSelectionRangeProvider:Rgn,registerDocumentSemanticTokensProvider:Pgn,registerDocumentRangeSemanticTokensProvider:Agn,registerInlineCompletionsProvider:Ogn,registerInlayHintsProvider:Fgn,DocumentHighlightKind:gae,CompletionItemKind:lae,CompletionItemTag:cae,CompletionItemInsertTextRule:aae,SymbolKind:Kae,SymbolTag:Zae,IndentAction:yae,CompletionTriggerKind:dae,SignatureHelpTriggerKind:Uae,InlayHintKind:Sae,InlineCompletionTriggerKind:kae,CodeActionTriggerType:oae,NewSymbolNameTag:Rae,NewSymbolNameTriggerKind:Pae,PartialAcceptTriggerKind:Fae,HoverVerbosityAction:bae,InlineCompletionEndOfLifeReasonKind:xae,InlineCompletionHintStyle:Lae,FoldingRangeKind:PC,SelectedSuggestionInfo:HVe,EditDeltaInfo:XE}}Sl.wrappingIndent.defaultValue=0;Sl.glyphMargin.defaultValue=!1;Sl.autoIndent.defaultValue=3;Sl.overviewRulerLanes.defaultValue=2;LI.setFormatterSelector((n,e,t)=>Promise.resolve(n[0]));const _c=PZe();_c.editor=q9n();_c.languages=Bgn();const lqe=_c.CancellationTokenSource,Fm=_c.Emitter,D2e=_c.KeyCode,T2e=_c.KeyMod,s9=_c.Position,KC=_c.Range,cqe=_c.Selection,dqe=_c.SelectionDirection,dh=_c.MarkerSeverity,gH=_c.MarkerTag,GU=_c.Uri,uqe=_c.Token,_h=_c.editor,Mt=_c.languages,aY=$he(),Yv=globalThis;(aY!=null&&aY.globalAPI||typeof Yv.define=="function"&&Yv.define.amd)&&(Yv.monaco=_c);typeof Yv.require<"u"&&typeof Yv.require.config=="function"&&Yv.require.config({ignoreDuplicateModules:["vscode-languageserver-types","vscode-languageserver-types/main","vscode-languageserver-textdocument","vscode-languageserver-textdocument/main","vscode-nls","vscode-nls/vscode-nls","jsonc-parser","jsonc-parser/main","vscode-uri","vscode-uri/index","vs/basic-languages/typescript/typescript"]});const $gn=Object.freeze(Object.defineProperty({__proto__:null,CancellationTokenSource:lqe,Emitter:Fm,KeyCode:D2e,KeyMod:T2e,MarkerSeverity:dh,MarkerTag:gH,Position:s9,Range:KC,Selection:cqe,SelectionDirection:dqe,Token:uqe,Uri:GU,editor:_h,languages:Mt},Symbol.toStringTag,{value:"Module"}));let R2e=class{constructor(e,t,i){this._onDidChange=new Fm,this._languageId=e,this.setOptions(t),this.setModeConfiguration(i)}get onDidChange(){return this._onDidChange.event}get languageId(){return this._languageId}get modeConfiguration(){return this._modeConfiguration}get diagnosticsOptions(){return this.options}get options(){return this._options}setOptions(e){this._options=e||Object.create(null),this._onDidChange.fire(this)}setDiagnosticsOptions(e){this.setOptions(e)}setModeConfiguration(e){this._modeConfiguration=e||Object.create(null),this._onDidChange.fire(this)}};const P2e={validate:!0,lint:{compatibleVendorPrefixes:"ignore",vendorPrefix:"warning",duplicateProperties:"warning",emptyRules:"warning",importStatement:"ignore",boxModel:"ignore",universalSelector:"ignore",zeroUnits:"ignore",fontFaceProperties:"warning",hexColorLength:"error",argumentsInColorFunction:"error",unknownProperties:"warning",ieHack:"ignore",unknownVendorSpecificProperties:"ignore",propertyIgnoredDueToDisplay:"warning",important:"ignore",float:"ignore",idSelector:"ignore"},data:{useDefaultDataProvider:!0},format:{newlineBetweenSelectors:!0,newlineBetweenRules:!0,spaceAroundSelectorSeparator:!1,braceStyle:"collapse",maxPreserveNewLines:void 0,preserveNewLines:!0}},A2e={completionItems:!0,hovers:!0,documentSymbols:!0,definitions:!0,references:!0,documentHighlights:!0,rename:!0,colors:!0,foldingRanges:!0,diagnostics:!0,selectionRanges:!0,documentFormattingEdits:!0,documentRangeFormattingEdits:!0},hqe=new R2e("css",P2e,A2e),fqe=new R2e("scss",P2e,A2e),gqe=new R2e("less",P2e,A2e);function O2e(){return re(()=>import("./cssMode-Ca5YrKlU.js"),__vite__mapDeps([97,98]))}Mt.onLanguage("less",()=>{O2e().then(n=>n.setupMode(gqe))});Mt.onLanguage("scss",()=>{O2e().then(n=>n.setupMode(fqe))});Mt.onLanguage("css",()=>{O2e().then(n=>n.setupMode(hqe))});const mqe=Object.freeze(Object.defineProperty({__proto__:null,cssDefaults:hqe,lessDefaults:gqe,scssDefaults:fqe},Symbol.toStringTag,{value:"Module"}));let Hgn=class{constructor(e,t,i){this._onDidChange=new Fm,this._languageId=e,this.setOptions(t),this.setModeConfiguration(i)}get onDidChange(){return this._onDidChange.event}get languageId(){return this._languageId}get options(){return this._options}get modeConfiguration(){return this._modeConfiguration}setOptions(e){this._options=e||Object.create(null),this._onDidChange.fire(this)}setModeConfiguration(e){this._modeConfiguration=e||Object.create(null),this._onDidChange.fire(this)}};const Vgn={tabSize:4,insertSpaces:!1,wrapLineLength:120,unformatted:'default": "a, abbr, acronym, b, bdo, big, br, button, cite, code, dfn, em, i, img, input, kbd, label, map, object, q, samp, select, small, span, strong, sub, sup, textarea, tt, var',contentUnformatted:"pre",indentInnerHtml:!1,preserveNewLines:!0,maxPreserveNewLines:void 0,indentHandlebars:!1,endWithNewline:!1,extraLiners:"head, body, /html",wrapAttributes:"auto"},XU={format:Vgn,suggest:{},data:{useDefaultDataProvider:!0}};function YU(n){return{completionItems:!0,hovers:!0,documentSymbols:!0,links:!0,documentHighlights:!0,rename:!0,colors:!0,foldingRanges:!0,selectionRanges:!0,diagnostics:n===ZL,documentFormattingEdits:n===ZL,documentRangeFormattingEdits:n===ZL}}const ZL="html",WSe="handlebars",zSe="razor",pqe=QU(ZL,XU,YU(ZL)),jgn=pqe.defaults,Cqe=QU(WSe,XU,YU(WSe)),Wgn=Cqe.defaults,_qe=QU(zSe,XU,YU(zSe)),zgn=_qe.defaults;function Ugn(){return re(()=>import("./htmlMode-DNwcJ7l2.js"),__vite__mapDeps([99,98]))}function QU(n,e=XU,t=YU(n)){const i=new Hgn(n,e,t);let s;const r=Mt.onLanguage(n,async()=>{s=(await Ugn()).setupMode(i)});return{defaults:i,dispose(){r.dispose(),s==null||s.dispose(),s=void 0}}}const vqe=Object.freeze(Object.defineProperty({__proto__:null,handlebarDefaults:Wgn,handlebarLanguageService:Cqe,htmlDefaults:jgn,htmlLanguageService:pqe,razorDefaults:zgn,razorLanguageService:_qe,registerHTMLLanguageService:QU},Symbol.toStringTag,{value:"Module"}));let Kgn=class{constructor(e,t,i){this._onDidChange=new Fm,this._languageId=e,this.setDiagnosticsOptions(t),this.setModeConfiguration(i)}get onDidChange(){return this._onDidChange.event}get languageId(){return this._languageId}get modeConfiguration(){return this._modeConfiguration}get diagnosticsOptions(){return this._diagnosticsOptions}setDiagnosticsOptions(e){this._diagnosticsOptions=e||Object.create(null),this._onDidChange.fire(this)}setModeConfiguration(e){this._modeConfiguration=e||Object.create(null),this._onDidChange.fire(this)}};const Zgn={validate:!0,allowComments:!0,schemas:[],enableSchemaRequest:!1,schemaRequest:"warning",schemaValidation:"warning",comments:"error",trailingCommas:"error"},qgn={documentFormattingEdits:!0,documentRangeFormattingEdits:!0,completionItems:!0,hovers:!0,documentSymbols:!0,tokens:!0,colors:!0,foldingRanges:!0,diagnostics:!0,selectionRanges:!0},bqe=new Kgn("json",Zgn,qgn),Ggn=()=>yqe().then(n=>n.getWorker());function yqe(){return re(()=>import("./jsonMode-C8lI1qS6.js"),__vite__mapDeps([100,98]))}Mt.register({id:"json",extensions:[".json",".bowerrc",".jshintrc",".jscsrc",".eslintrc",".babelrc",".har"],aliases:["JSON","json"],mimetypes:["application/json"]});Mt.onLanguage("json",()=>{yqe().then(n=>n.setupMode(bqe))});const wqe=Object.freeze(Object.defineProperty({__proto__:null,getWorker:Ggn,jsonDefaults:bqe},Symbol.toStringTag,{value:"Module"})),Xgn="5.9.3";var Sqe=(n=>(n[n.None=0]="None",n[n.CommonJS=1]="CommonJS",n[n.AMD=2]="AMD",n[n.UMD=3]="UMD",n[n.System=4]="System",n[n.ES2015=5]="ES2015",n[n.ESNext=99]="ESNext",n))(Sqe||{}),xqe=(n=>(n[n.None=0]="None",n[n.Preserve=1]="Preserve",n[n.React=2]="React",n[n.ReactNative=3]="ReactNative",n[n.ReactJSX=4]="ReactJSX",n[n.ReactJSXDev=5]="ReactJSXDev",n))(xqe||{}),Lqe=(n=>(n[n.CarriageReturnLineFeed=0]="CarriageReturnLineFeed",n[n.LineFeed=1]="LineFeed",n))(Lqe||{}),kqe=(n=>(n[n.ES3=0]="ES3",n[n.ES5=1]="ES5",n[n.ES2015=2]="ES2015",n[n.ES2016=3]="ES2016",n[n.ES2017=4]="ES2017",n[n.ES2018=5]="ES2018",n[n.ES2019=6]="ES2019",n[n.ES2020=7]="ES2020",n[n.ESNext=99]="ESNext",n[n.JSON=100]="JSON",n[n.Latest=99]="Latest",n))(kqe||{}),Eqe=(n=>(n[n.Classic=1]="Classic",n[n.NodeJs=2]="NodeJs",n))(Eqe||{});class Iqe{constructor(e,t,i,s,r){this._onDidChange=new Fm,this._onDidExtraLibsChange=new Fm,this._extraLibs=Object.create(null),this._removedExtraLibs=Object.create(null),this._eagerModelSync=!1,this.setCompilerOptions(e),this.setDiagnosticsOptions(t),this.setWorkerOptions(i),this.setInlayHintsOptions(s),this.setModeConfiguration(r),this._onDidExtraLibsChangeTimeout=-1}get onDidChange(){return this._onDidChange.event}get onDidExtraLibsChange(){return this._onDidExtraLibsChange.event}get modeConfiguration(){return this._modeConfiguration}get workerOptions(){return this._workerOptions}get inlayHintsOptions(){return this._inlayHintsOptions}getExtraLibs(){return this._extraLibs}addExtraLib(e,t){let i;if(typeof t>"u"?i=`ts:extralib-${Math.random().toString(36).substring(2,15)}`:i=t,this._extraLibs[i]&&this._extraLibs[i].content===e)return{dispose:()=>{}};let s=1;return this._removedExtraLibs[i]&&(s=this._removedExtraLibs[i]+1),this._extraLibs[i]&&(s=this._extraLibs[i].version+1),this._extraLibs[i]={content:e,version:s},this._fireOnDidExtraLibsChangeSoon(),{dispose:()=>{let r=this._extraLibs[i];r&&r.version===s&&(delete this._extraLibs[i],this._removedExtraLibs[i]=s,this._fireOnDidExtraLibsChangeSoon())}}}setExtraLibs(e){for(const t in this._extraLibs)this._removedExtraLibs[t]=this._extraLibs[t].version;if(this._extraLibs=Object.create(null),e&&e.length>0)for(const t of e){const i=t.filePath||`ts:extralib-${Math.random().toString(36).substring(2,15)}`,s=t.content;let r=1;this._removedExtraLibs[i]&&(r=this._removedExtraLibs[i]+1),this._extraLibs[i]={content:s,version:r}}this._fireOnDidExtraLibsChangeSoon()}_fireOnDidExtraLibsChangeSoon(){this._onDidExtraLibsChangeTimeout===-1&&(this._onDidExtraLibsChangeTimeout=window.setTimeout(()=>{this._onDidExtraLibsChangeTimeout=-1,this._onDidExtraLibsChange.fire(void 0)},0))}getCompilerOptions(){return this._compilerOptions}setCompilerOptions(e){this._compilerOptions=e||Object.create(null),this._onDidChange.fire(void 0)}getDiagnosticsOptions(){return this._diagnosticsOptions}setDiagnosticsOptions(e){this._diagnosticsOptions=e||Object.create(null),this._onDidChange.fire(void 0)}setWorkerOptions(e){this._workerOptions=e||Object.create(null),this._onDidChange.fire(void 0)}setInlayHintsOptions(e){this._inlayHintsOptions=e||Object.create(null),this._onDidChange.fire(void 0)}setMaximumWorkerIdleTime(e){}setEagerModelSync(e){this._eagerModelSync=e}getEagerModelSync(){return this._eagerModelSync}setModeConfiguration(e){this._modeConfiguration=e||Object.create(null),this._onDidChange.fire(void 0)}}const Ygn=Xgn,Mqe={completionItems:!0,hovers:!0,documentSymbols:!0,definitions:!0,references:!0,documentHighlights:!0,rename:!0,diagnostics:!0,documentRangeFormattingEdits:!0,signatureHelp:!0,onTypeFormattingEdits:!0,codeActions:!0,inlayHints:!0},Nqe=new Iqe({allowNonTsExtensions:!0,target:99},{noSemanticValidation:!1,noSyntaxValidation:!1,onlyVisible:!1},{},{},Mqe),Dqe=new Iqe({allowNonTsExtensions:!0,allowJs:!0,target:99},{noSemanticValidation:!0,noSyntaxValidation:!1,onlyVisible:!1},{},{},Mqe),Qgn=()=>JU().then(n=>n.getTypeScriptWorker()),Jgn=()=>JU().then(n=>n.getJavaScriptWorker());function JU(){return re(()=>import("./tsMode-ClzzMo6h.js"),[])}Mt.onLanguage("typescript",()=>JU().then(n=>n.setupTypeScript(Nqe)));Mt.onLanguage("javascript",()=>JU().then(n=>n.setupJavaScript(Dqe)));const Tqe=Object.freeze(Object.defineProperty({__proto__:null,JsxEmit:xqe,ModuleKind:Sqe,ModuleResolutionKind:Eqe,NewLineKind:Lqe,ScriptTarget:kqe,getJavaScriptWorker:Jgn,getTypeScriptWorker:Qgn,javascriptDefaults:Dqe,typescriptDefaults:Nqe,typescriptVersion:Ygn},Symbol.toStringTag,{value:"Module"})),Rqe={},lY={};class F2e{static getOrCreate(e){return lY[e]||(lY[e]=new F2e(e)),lY[e]}constructor(e){this._languageId=e,this._loadingTriggered=!1,this._lazyLoadPromise=new Promise((t,i)=>{this._lazyLoadPromiseResolve=t,this._lazyLoadPromiseReject=i})}load(){return this._loadingTriggered||(this._loadingTriggered=!0,Rqe[this._languageId].loader().then(e=>this._lazyLoadPromiseResolve(e),e=>this._lazyLoadPromiseReject(e))),this._lazyLoadPromise}}function Jt(n){const e=n.id;Rqe[e]=n,Mt.register(n);const t=F2e.getOrCreate(e);Mt.registerTokensProviderFactory(e,{create:async()=>(await t.load()).language}),Mt.onLanguageEncountered(e,async()=>{const i=await t.load();Mt.setLanguageConfiguration(e,i.conf)})}Jt({id:"abap",extensions:[".abap"],aliases:["abap","ABAP"],loader:()=>re(()=>import("./abap-DLDM7-KI.js"),[])});Jt({id:"apex",extensions:[".cls"],aliases:["Apex","apex"],mimetypes:["text/x-apex-source","text/x-apex"],loader:()=>re(()=>import("./apex-DNDY2TF8.js"),[])});Jt({id:"azcli",extensions:[".azcli"],aliases:["Azure CLI","azcli"],loader:()=>re(()=>import("./azcli-Y6nb8tq_.js"),[])});Jt({id:"bat",extensions:[".bat",".cmd"],aliases:["Batch","bat"],loader:()=>re(()=>import("./bat-BwHxbl9M.js"),[])});Jt({id:"bicep",extensions:[".bicep"],aliases:["Bicep"],loader:()=>re(()=>import("./bicep-CFznDFnq.js"),[])});Jt({id:"cameligo",extensions:[".mligo"],aliases:["Cameligo"],loader:()=>re(()=>import("./cameligo-Bf6VGUru.js"),[])});Jt({id:"clojure",extensions:[".clj",".cljs",".cljc",".edn"],aliases:["clojure","Clojure"],loader:()=>re(()=>import("./clojure-Dnu-v4kV.js"),[])});Jt({id:"coffeescript",extensions:[".coffee"],aliases:["CoffeeScript","coffeescript","coffee"],mimetypes:["text/x-coffeescript","text/coffeescript"],loader:()=>re(()=>import("./coffee-Bd8akH9Z.js"),[])});Jt({id:"c",extensions:[".c",".h"],aliases:["C","c"],loader:()=>re(()=>import("./cpp-BbWJElDN.js"),[])});Jt({id:"cpp",extensions:[".cpp",".cc",".cxx",".hpp",".hh",".hxx"],aliases:["C++","Cpp","cpp"],loader:()=>re(()=>import("./cpp-BbWJElDN.js"),[])});Jt({id:"csharp",extensions:[".cs",".csx",".cake"],aliases:["C#","csharp"],loader:()=>re(()=>import("./csharp-Co3qMtFm.js"),[])});Jt({id:"csp",extensions:[".csp"],aliases:["CSP","csp"],loader:()=>re(()=>import("./csp-D-4FJmMZ.js"),[])});Jt({id:"css",extensions:[".css"],aliases:["CSS","css"],mimetypes:["text/css"],loader:()=>re(()=>import("./css-DdJfP1eB.js"),[])});Jt({id:"cypher",extensions:[".cypher",".cyp"],aliases:["Cypher","OpenCypher"],loader:()=>re(()=>import("./cypher-cTPe9QuQ.js"),[])});Jt({id:"dart",extensions:[".dart"],aliases:["Dart","dart"],mimetypes:["text/x-dart-source","text/x-dart"],loader:()=>re(()=>import("./dart-BOtBlQCF.js"),[])});Jt({id:"dockerfile",extensions:[".dockerfile"],filenames:["Dockerfile"],aliases:["Dockerfile"],loader:()=>re(()=>import("./dockerfile-BG73LgW2.js"),[])});Jt({id:"ecl",extensions:[".ecl"],aliases:["ECL","Ecl","ecl"],loader:()=>re(()=>import("./ecl-BEgZUVRK.js"),[])});Jt({id:"elixir",extensions:[".ex",".exs"],aliases:["Elixir","elixir","ex"],loader:()=>re(()=>import("./elixir-BkW5O-1t.js"),[])});Jt({id:"flow9",extensions:[".flow"],aliases:["Flow9","Flow","flow9","flow"],loader:()=>re(()=>import("./flow9-BeJ5waoc.js"),[])});Jt({id:"fsharp",extensions:[".fs",".fsi",".ml",".mli",".fsx",".fsscript"],aliases:["F#","FSharp","fsharp"],loader:()=>re(()=>import("./fsharp-PahG7c26.js"),[])});Jt({id:"freemarker2",extensions:[".ftl",".ftlh",".ftlx"],aliases:["FreeMarker2","Apache FreeMarker2"],loader:()=>re(()=>import("./freemarker2-CACU9C35.js"),[]).then(n=>n.TagAutoInterpolationDollar)});Jt({id:"freemarker2.tag-angle.interpolation-dollar",aliases:["FreeMarker2 (Angle/Dollar)","Apache FreeMarker2 (Angle/Dollar)"],loader:()=>re(()=>import("./freemarker2-CACU9C35.js"),[]).then(n=>n.TagAngleInterpolationDollar)});Jt({id:"freemarker2.tag-bracket.interpolation-dollar",aliases:["FreeMarker2 (Bracket/Dollar)","Apache FreeMarker2 (Bracket/Dollar)"],loader:()=>re(()=>import("./freemarker2-CACU9C35.js"),[]).then(n=>n.TagBracketInterpolationDollar)});Jt({id:"freemarker2.tag-angle.interpolation-bracket",aliases:["FreeMarker2 (Angle/Bracket)","Apache FreeMarker2 (Angle/Bracket)"],loader:()=>re(()=>import("./freemarker2-CACU9C35.js"),[]).then(n=>n.TagAngleInterpolationBracket)});Jt({id:"freemarker2.tag-bracket.interpolation-bracket",aliases:["FreeMarker2 (Bracket/Bracket)","Apache FreeMarker2 (Bracket/Bracket)"],loader:()=>re(()=>import("./freemarker2-CACU9C35.js"),[]).then(n=>n.TagBracketInterpolationBracket)});Jt({id:"freemarker2.tag-auto.interpolation-dollar",aliases:["FreeMarker2 (Auto/Dollar)","Apache FreeMarker2 (Auto/Dollar)"],loader:()=>re(()=>import("./freemarker2-CACU9C35.js"),[]).then(n=>n.TagAutoInterpolationDollar)});Jt({id:"freemarker2.tag-auto.interpolation-bracket",aliases:["FreeMarker2 (Auto/Bracket)","Apache FreeMarker2 (Auto/Bracket)"],loader:()=>re(()=>import("./freemarker2-CACU9C35.js"),[]).then(n=>n.TagAutoInterpolationBracket)});Jt({id:"go",extensions:[".go"],aliases:["Go"],loader:()=>re(()=>import("./go-acbASCJo.js"),[])});Jt({id:"graphql",extensions:[".graphql",".gql"],aliases:["GraphQL","graphql","gql"],mimetypes:["application/graphql"],loader:()=>re(()=>import("./graphql-BxJiqAUM.js"),[])});Jt({id:"handlebars",extensions:[".handlebars",".hbs"],aliases:["Handlebars","handlebars","hbs"],mimetypes:["text/x-handlebars-template"],loader:()=>re(()=>import("./handlebars-DHtyM93b.js"),[])});Jt({id:"hcl",extensions:[".tf",".tfvars",".hcl"],aliases:["Terraform","tf","HCL","hcl"],loader:()=>re(()=>import("./hcl-DtV1sZF8.js"),[])});Jt({id:"html",extensions:[".html",".htm",".shtml",".xhtml",".mdoc",".jsp",".asp",".aspx",".jshtm"],aliases:["HTML","htm","html","xhtml"],mimetypes:["text/html","text/x-jshtm","text/template","text/ng-template"],loader:()=>re(()=>import("./html-DCIlVDn9.js"),[])});Jt({id:"ini",extensions:[".ini",".properties",".gitconfig"],filenames:["config",".gitattributes",".gitconfig",".editorconfig"],aliases:["Ini","ini"],loader:()=>re(()=>import("./ini-Kd9XrMLS.js"),[])});Jt({id:"java",extensions:[".java",".jav"],aliases:["Java","java"],mimetypes:["text/x-java-source","text/x-java"],loader:()=>re(()=>import("./java-CXBNlu9o.js"),[])});Jt({id:"javascript",extensions:[".js",".es6",".jsx",".mjs",".cjs"],firstLine:"^#!.*\\bnode",filenames:["jakefile"],aliases:["JavaScript","javascript","js"],mimetypes:["text/javascript"],loader:()=>re(()=>import("./javascript-2ieTkVr_.js"),__vite__mapDeps([101,102]))});Jt({id:"julia",extensions:[".jl"],aliases:["julia","Julia"],loader:()=>re(()=>import("./julia-cl7-CwDS.js"),[])});Jt({id:"kotlin",extensions:[".kt",".kts"],aliases:["Kotlin","kotlin"],mimetypes:["text/x-kotlin-source","text/x-kotlin"],loader:()=>re(()=>import("./kotlin-s7OhZKlX.js"),[])});Jt({id:"less",extensions:[".less"],aliases:["Less","less"],mimetypes:["text/x-less","text/less"],loader:()=>re(()=>import("./less-9HpZscsL.js"),[])});Jt({id:"lexon",extensions:[".lex"],aliases:["Lexon"],loader:()=>re(()=>import("./lexon-OrD6JF1K.js"),[])});Jt({id:"lua",extensions:[".lua"],aliases:["Lua","lua"],loader:()=>re(()=>import("./lua-Cyyb5UIc.js"),[])});Jt({id:"liquid",extensions:[".liquid",".html.liquid"],aliases:["Liquid","liquid"],mimetypes:["application/liquid"],loader:()=>re(()=>import("./liquid-4HmYxWqB.js"),[])});Jt({id:"m3",extensions:[".m3",".i3",".mg",".ig"],aliases:["Modula-3","Modula3","modula3","m3"],loader:()=>re(()=>import("./m3-B8OfTtLu.js"),[])});Jt({id:"markdown",extensions:[".md",".markdown",".mdown",".mkdn",".mkd",".mdwn",".mdtxt",".mdtext"],aliases:["Markdown","markdown"],loader:()=>re(()=>import("./markdown-BFxVWTOG.js"),[])});Jt({id:"mdx",extensions:[".mdx"],aliases:["MDX","mdx"],loader:()=>re(()=>import("./mdx-BSJ29RMi.js"),[])});Jt({id:"mips",extensions:[".s"],aliases:["MIPS","MIPS-V"],mimetypes:["text/x-mips","text/mips","text/plaintext"],loader:()=>re(()=>import("./mips-CiqrrVzr.js"),[])});Jt({id:"msdax",extensions:[".dax",".msdax"],aliases:["DAX","MSDAX"],loader:()=>re(()=>import("./msdax-DmeGPVcC.js"),[])});Jt({id:"mysql",extensions:[],aliases:["MySQL","mysql"],loader:()=>re(()=>import("./mysql-C_tMU-Nz.js"),[])});Jt({id:"objective-c",extensions:[".m"],aliases:["Objective-C"],loader:()=>re(()=>import("./objective-c-BDtDVThU.js"),[])});Jt({id:"pascal",extensions:[".pas",".p",".pp"],aliases:["Pascal","pas"],mimetypes:["text/x-pascal-source","text/x-pascal"],loader:()=>re(()=>import("./pascal-vHIfCaH5.js"),[])});Jt({id:"pascaligo",extensions:[".ligo"],aliases:["Pascaligo","ligo"],loader:()=>re(()=>import("./pascaligo-DtZ0uQbO.js"),[])});Jt({id:"perl",extensions:[".pl",".pm"],aliases:["Perl","pl"],loader:()=>re(()=>import("./perl-Ub6l9XKa.js"),[])});Jt({id:"pgsql",extensions:[],aliases:["PostgreSQL","postgres","pg","postgre"],loader:()=>re(()=>import("./pgsql-BlNEE0v7.js"),[])});Jt({id:"php",extensions:[".php",".php4",".php5",".phtml",".ctp"],aliases:["PHP","php"],mimetypes:["application/x-php"],loader:()=>re(()=>import("./php-BBUBE1dy.js"),[])});Jt({id:"pla",extensions:[".pla"],loader:()=>re(()=>import("./pla-DSh2-awV.js"),[])});Jt({id:"postiats",extensions:[".dats",".sats",".hats"],aliases:["ATS","ATS/Postiats"],loader:()=>re(()=>import("./postiats-CocnycG-.js"),[])});Jt({id:"powerquery",extensions:[".pq",".pqm"],aliases:["PQ","M","Power Query","Power Query M"],loader:()=>re(()=>import("./powerquery-tScXyioY.js"),[])});Jt({id:"powershell",extensions:[".ps1",".psm1",".psd1"],aliases:["PowerShell","powershell","ps","ps1"],loader:()=>re(()=>import("./powershell-COWaemsV.js"),[])});Jt({id:"proto",extensions:[".proto"],aliases:["protobuf","Protocol Buffers"],loader:()=>re(()=>import("./protobuf-Brw8urJB.js"),[])});Jt({id:"pug",extensions:[".jade",".pug"],aliases:["Pug","Jade","jade"],loader:()=>re(()=>import("./pug-8SOpv6rk.js"),[])});Jt({id:"python",extensions:[".py",".rpy",".pyw",".cpy",".gyp",".gypi"],aliases:["Python","py"],firstLine:"^#!/.*\\bpython[0-9.-]*\\b",loader:()=>re(()=>import("./python-BGBkGI4c.js"),[])});Jt({id:"qsharp",extensions:[".qs"],aliases:["Q#","qsharp"],loader:()=>re(()=>import("./qsharp-Bw9ernYp.js"),[])});Jt({id:"r",extensions:[".r",".rhistory",".rmd",".rprofile",".rt"],aliases:["R","r"],loader:()=>re(()=>import("./r-j7ic8hl3.js"),[])});Jt({id:"razor",extensions:[".cshtml"],aliases:["Razor","razor"],mimetypes:["text/x-cshtml"],loader:()=>re(()=>import("./razor-J2LRfvrP.js"),[])});Jt({id:"redis",extensions:[".redis"],aliases:["redis"],loader:()=>re(()=>import("./redis-Bu5POkcn.js"),[])});Jt({id:"redshift",extensions:[],aliases:["Redshift","redshift"],loader:()=>re(()=>import("./redshift-Bs9aos_-.js"),[])});Jt({id:"restructuredtext",extensions:[".rst"],aliases:["reStructuredText","restructuredtext"],loader:()=>re(()=>import("./restructuredtext-CqXO7rUv.js"),[])});Jt({id:"ruby",extensions:[".rb",".rbx",".rjs",".gemspec",".pp"],filenames:["rakefile","Gemfile"],aliases:["Ruby","rb"],loader:()=>re(()=>import("./ruby-zBfavPgS.js"),[])});Jt({id:"rust",extensions:[".rs",".rlib"],aliases:["Rust","rust"],loader:()=>re(()=>import("./rust-BzKRNQWT.js"),[])});Jt({id:"sb",extensions:[".sb"],aliases:["Small Basic","sb"],loader:()=>re(()=>import("./sb-BBc9UKZt.js"),[])});Jt({id:"scala",extensions:[".scala",".sc",".sbt"],aliases:["Scala","scala","SBT","Sbt","sbt","Dotty","dotty"],mimetypes:["text/x-scala-source","text/x-scala","text/x-sbt","text/x-dotty"],loader:()=>re(()=>import("./scala-D9hQfWCl.js"),[])});Jt({id:"scheme",extensions:[".scm",".ss",".sch",".rkt"],aliases:["scheme","Scheme"],loader:()=>re(()=>import("./scheme-BPhDTwHR.js"),[])});Jt({id:"scss",extensions:[".scss"],aliases:["Sass","sass","scss"],mimetypes:["text/x-scss","text/scss"],loader:()=>re(()=>import("./scss-CBJaRo0y.js"),[])});Jt({id:"shell",extensions:[".sh",".bash"],aliases:["Shell","sh"],loader:()=>re(()=>import("./shell-DiJ1NA_G.js"),[])});Jt({id:"sol",extensions:[".sol"],aliases:["sol","solidity","Solidity"],loader:()=>re(()=>import("./solidity-Db0IVjzk.js"),[])});Jt({id:"aes",extensions:[".aes"],aliases:["aes","sophia","Sophia"],loader:()=>re(()=>import("./sophia-CnS9iZB_.js"),[])});Jt({id:"sparql",extensions:[".rq"],aliases:["sparql","SPARQL"],loader:()=>re(()=>import("./sparql-CJmd_6j2.js"),[])});Jt({id:"sql",extensions:[".sql"],aliases:["SQL"],loader:()=>re(()=>import("./sql-ClhHkBeG.js"),[])});Jt({id:"st",extensions:[".st",".iecst",".iecplc",".lc3lib",".TcPOU",".TcDUT",".TcGVL",".TcIO"],aliases:["StructuredText","scl","stl"],loader:()=>re(()=>import("./st-CHwy0fLd.js"),[])});Jt({id:"swift",aliases:["Swift","swift"],extensions:[".swift"],mimetypes:["text/swift"],loader:()=>re(()=>import("./swift-Bqt4WxQ4.js"),[])});Jt({id:"systemverilog",extensions:[".sv",".svh"],aliases:["SV","sv","SystemVerilog","systemverilog"],loader:()=>re(()=>import("./systemverilog-Bs9z6M-B.js"),[])});Jt({id:"verilog",extensions:[".v",".vh"],aliases:["V","v","Verilog","verilog"],loader:()=>re(()=>import("./systemverilog-Bs9z6M-B.js"),[])});Jt({id:"tcl",extensions:[".tcl"],aliases:["tcl","Tcl","tcltk","TclTk","tcl/tk","Tcl/Tk"],loader:()=>re(()=>import("./tcl-Dm6ycUr_.js"),[])});Jt({id:"twig",extensions:[".twig"],aliases:["Twig","twig"],mimetypes:["text/x-twig"],loader:()=>re(()=>import("./twig-Csy3S7wG.js"),[])});Jt({id:"typescript",extensions:[".ts",".tsx",".cts",".mts"],aliases:["TypeScript","ts","typescript"],mimetypes:["text/typescript"],loader:()=>re(()=>import("./typescript-PTtJjTZB.js"),[])});Jt({id:"typespec",extensions:[".tsp"],aliases:["TypeSpec"],loader:()=>re(()=>import("./typespec-Btyra-wh.js"),[])});Jt({id:"vb",extensions:[".vb"],aliases:["Visual Basic","vb"],loader:()=>re(()=>import("./vb-Db0cS2oM.js"),[])});Jt({id:"wgsl",extensions:[".wgsl"],aliases:["WebGPU Shading Language","WGSL","wgsl"],loader:()=>re(()=>import("./wgsl-BTesnYfV.js"),[])});Jt({id:"xml",extensions:[".xml",".xsd",".dtd",".ascx",".csproj",".config",".props",".targets",".wxi",".wxl",".wxs",".xaml",".svg",".svgz",".opf",".xslt",".xsl"],firstLine:"(\\<\\?xml.*)|(\\<svg)|(\\<\\!doctype\\s+svg)",aliases:["XML","xml"],mimetypes:["text/xml","application/xml","application/xaml+xml","application/xml-dtd"],loader:()=>re(()=>import("./xml-CFW_XanW.js"),[])});Jt({id:"yaml",extensions:[".yaml",".yml"],aliases:["YAML","yaml","YML","yml"],mimetypes:["application/x-yaml","text/x-yaml"],loader:()=>re(()=>import("./yaml-CXH4pPqt.js"),[])});var emn=Object.defineProperty,tmn=(n,e,t)=>e in n?emn(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Zt=(n,e,t)=>tmn(n,typeof e!="symbol"?e+"":e,t),xR,USe,LR,cY,kR;function nmn(n){return n.method!==void 0}var KSe;(function(n){function e(t){return t}n.create=e})(KSe||(KSe={}));var rh;(function(n){n.parseError=-32700,n.invalidRequest=-32600,n.methodNotFound=-32601,n.invalidParams=-32602,n.internalError=-32603;function e(r){return-32099<=r&&r<=-32e3}n.isServerError=e;function t(r){if(!e(r))throw new Error("Invalid range for a server error.");return r}n.serverError=t,n.unexpectedServerError=-32e3;function i(r){return!0}n.isApplicationError=i;function s(r){return r}n.applicationError=s,n.genericApplicationError=-320100})(rh||(rh={}));var B2e=class{constructor(){Zt(this,"listeners",new Set),Zt(this,"event",n=>(this.listeners.add(n),{dispose:()=>{this.listeners.delete(n)}}))}fire(n){this.listeners.forEach(e=>e(n))}},imn=class{constructor(n){Zt(this,"_value"),Zt(this,"eventEmitter"),this._value=n,this.eventEmitter=new B2e}get value(){return this._value}set value(n){this._value!==n&&(this._value=n,this.eventEmitter.fire(n))}get onChange(){return this.eventEmitter.event}};function smn(n,e){const t=setTimeout(e,n);return{dispose:()=>clearTimeout(t)}}function dY(n,e,t){return n instanceof Set?(n.add(e),{dispose:()=>n.delete(e)}):(n.set(e,t),{dispose:()=>n.delete(e)})}var rmn=class{constructor(){Zt(this,"_state","none"),Zt(this,"promise"),Zt(this,"resolve",()=>{}),Zt(this,"reject",()=>{}),this.promise=new Promise((n,e)=>{this.resolve=n,this.reject=e})}get state(){return this._state}},Pqe=(xR=class{constructor(){Zt(this,"_unprocessedMessages",[]),Zt(this,"_messageListener"),Zt(this,"id",xR.id++),Zt(this,"_state",new imn({state:"open"})),Zt(this,"state",this._state)}setListener(n){if(this._messageListener=n,!!n)for(;this._unprocessedMessages.length>0&&this._messageListener!==void 0;){const e=this._unprocessedMessages.shift();this._messageListener(e)}}send(n){return this._sendImpl(n)}_dispatchReceivedMessage(n){this._unprocessedMessages.length===0&&this._messageListener?this._messageListener(n):this._unprocessedMessages.push(n)}_onConnectionClosed(){this._state.value={state:"closed",error:void 0}}log(n){return new omn(this,n??new amn)}},Zt(xR,"id",0),xR),omn=class{constructor(n,e){Zt(this,"baseStream"),Zt(this,"logger"),this.baseStream=n,this.logger=e}get state(){return this.baseStream.state}setListener(n){if(n===void 0){this.baseStream.setListener(void 0);return}this.baseStream.setListener(e=>{this.logger.log(this.baseStream,"incoming",e),n(e)})}send(n){return this.logger.log(this.baseStream,"outgoing",n),this.baseStream.send(n)}toString(){return`StreamLogger/${this.baseStream.toString()}`}},amn=class{log(n,e,t){console.log(`${e==="incoming"?"<-":"->"} [${n.toString()}] ${JSON.stringify(t)}`)}},lmn=class Aqe{constructor(e){Zt(this,"connect"),this.connect=e}mapContext(e){return new Aqe(t=>this.connect(t?cmn(t,e):void 0))}};function cmn(n,e){return{handleNotification:(t,i)=>n.handleNotification(t,e(i)),handleRequest:(t,i,s)=>n.handleRequest(t,i,e(s))}}var dmn=class Oqe{constructor(e,t,i){Zt(this,"_stream"),Zt(this,"_listener"),Zt(this,"_logger"),Zt(this,"_unprocessedResponses",new Map),Zt(this,"_lastUsedRequestId",0),this._stream=e,this._listener=t,this._logger=i,this._stream.setListener(s=>{nmn(s)?s.id===void 0?this._processNotification(s):this._processRequest(s):this._processResponse(s)})}static createChannel(e,t){let i=!1;return new lmn(s=>{if(i)throw new Error(`A channel to the stream ${e} was already constructed!`);return i=!0,new Oqe(e,s,t)})}get state(){return this._stream.state}async _processNotification(e){if(e.id!==void 0)throw new Error;if(!this._listener){this._logger&&this._logger.debug({text:"Notification ignored",message:e});return}try{await this._listener.handleNotification({method:e.method,params:e.params||null})}catch(t){this._logger&&this._logger.warn({text:`Exception was thrown while handling notification: ${t}`,exception:t,message:e})}}async _processRequest(e){if(e.id===void 0)throw new Error;let t;if(this._listener)try{t=await this._listener.handleRequest({method:e.method,params:e.params||null},e.id)}catch(s){this._logger&&this._logger.warn({text:`Exception was thrown while handling request: ${s}`,message:e,exception:s}),t={error:{code:rh.internalError,message:"An unexpected exception was thrown.",data:void 0}}}else this._logger&&this._logger.debug({text:"Received request even though not listening for requests",message:e}),t={error:{code:rh.methodNotFound,message:"This endpoint does not listen for requests or notifications.",data:void 0}};let i;"result"in t?i={jsonrpc:"2.0",id:e.id,result:t.result}:i={jsonrpc:"2.0",id:e.id,error:t.error},await this._stream.send(i)}_processResponse(e){const t=""+e.id,i=this._unprocessedResponses.get(t);if(!i){this._logger&&this._logger.debug({text:"Got an unexpected response message",message:e});return}this._unprocessedResponses.delete(t),i(e)}_newRequestId(){return this._lastUsedRequestId++}sendRequest(e,t,i){const s={jsonrpc:"2.0",id:this._newRequestId(),method:e.method,params:e.params||void 0};return i&&i(s.id),new Promise((r,o)=>{const a=""+s.id;this._unprocessedResponses.set(a,l=>{"result"in l?r({result:l.result}):(l.error||o(new Error("Response had neither 'result' nor 'error' field set.")),r({error:l.error}))}),this._stream.send(s).then(void 0,l=>{this._unprocessedResponses.delete(a),o(l)})})}sendNotification(e,t){const i={jsonrpc:"2.0",id:void 0,method:e.method,params:e.params||void 0};return this._stream.send(i)}toString(){return"StreamChannel/"+this._stream.toString()}},Qv;(function(n){function e(){return{deserializeFromJson:s=>({hasErrors:!1,value:s}),serializeToJson:s=>s}}n.sAny=e;function t(){return{deserializeFromJson:s=>({hasErrors:!1,value:{}}),serializeToJson:s=>({})}}n.sEmptyObject=t;function i(){return{deserializeFromJson:s=>({hasErrors:!1,value:void 0}),serializeToJson:s=>null}}n.sVoidFromNull=i})(Qv||(Qv={}));const Fqe=Symbol("OptionalMethodNotFound");var Bqe=class{contextualize(n){return new umn(this,n)}},umn=class extends Bqe{constructor(n,e){super(),Zt(this,"underylingTypedChannel"),Zt(this,"converters"),this.underylingTypedChannel=n,this.converters=e}async request(n,e,t){const i=await this.converters.getSendContext(t);return this.underylingTypedChannel.request(n,e,i)}async notify(n,e,t){const i=await this.converters.getSendContext(t);return this.underylingTypedChannel.notify(n,e,i)}registerNotificationHandler(n,e){return this.underylingTypedChannel.registerNotificationHandler(n,async(t,i)=>await e(t,await this.converters.getNewContext(i)))}registerRequestHandler(n,e){return this.underylingTypedChannel.registerRequestHandler(n,async(t,i,s)=>await e(t,i,await this.converters.getNewContext(s)))}},hce=class $qe extends Bqe{constructor(e,t={}){super(),Zt(this,"channelCtor"),Zt(this,"_requestSender"),Zt(this,"_handler",new Map),Zt(this,"_unknownNotificationHandler",new Set),Zt(this,"_timeout"),Zt(this,"sendExceptionDetails",!1),Zt(this,"_logger"),Zt(this,"listeningDeferred",new rmn),Zt(this,"onListening",this.listeningDeferred.promise),Zt(this,"_requestDidErrorEventEmitter",new B2e),Zt(this,"onRequestDidError",this._requestDidErrorEventEmitter.event),this.channelCtor=e,this._logger=t.logger,this.sendExceptionDetails=!!t.sendExceptionDetails,this._timeout=smn(1e3,()=>{this._requestSender||console.warn(`"${this.startListen.name}" has not been called within 1 second after construction of this channel. Did you forget to call it?`,this)})}static fromTransport(e,t={}){return new $qe(dmn.createChannel(e,t.logger),t)}startListen(){if(this._requestSender)throw new Error(`"${this.startListen.name}" can be called only once, but it already has been called.`);this._timeout&&(this._timeout.dispose(),this._timeout=void 0),this._requestSender=this.channelCtor.connect({handleRequest:(e,t,i)=>this.handleRequest(e,t,i),handleNotification:(e,t)=>this.handleNotification(e,t)}),this.listeningDeferred.resolve()}checkChannel(e){if(!e)throw new Error(`"${this.startListen.name}" must be called before any messages can be sent or received.`);return!0}async handleRequest(e,t,i){const s=this._handler.get(e.method);if(!s)return this._logger&&this._logger.debug({text:`No request handler for "${e.method}".`,data:{requestObject:e}}),{error:{code:rh.methodNotFound,message:`No request handler for "${e.method}".`,data:{method:e.method}}};if(s.kind!="request"){const o=`"${e.method}" is registered as notification, but was sent as request.`;return this._logger&&this._logger.debug({text:o,data:{requestObject:e}}),{error:{code:rh.invalidRequest,message:o,data:{method:e.method}}}}const r=s.requestType.paramsSerializer.deserializeFromJson(e.params);if(r.hasErrors){const o=`Got invalid params: ${r.errorMessage}`;return this._logger&&this._logger.debug({text:o,data:{requestObject:e,errorMessage:r.errorMessage}}),{error:{code:rh.invalidParams,message:o,data:{errors:r.errorMessage}}}}else{const o=r.value;let a;try{const l=await s.handler(o,t,i);if("error"in l||"errorMessage"in l){const c=l.error?s.requestType.errorSerializer.serializeToJson(l.error):void 0;a={error:{code:l.errorCode||rh.genericApplicationError,message:l.errorMessage||"An error was returned",data:c}}}else a={result:s.requestType.resultSerializer.serializeToJson(l.ok)}}catch(l){l instanceof qSe?a={error:{code:l.code,message:l.message}}:(this._logger&&this._logger.warn({text:`An exception was thrown while handling a request: ${l}.`,exception:l,data:{requestObject:e}}),a={error:{code:rh.unexpectedServerError,message:this.sendExceptionDetails?`An exception was thrown while handling a request: ${l}.`:"Server has thrown an unexpected exception"}})}return a}}async handleNotification(e,t){const i=this._handler.get(e.method);if(!i){for(const o of this._unknownNotificationHandler)o(e);this._unknownNotificationHandler.size===0&&this._logger&&this._logger.debug({text:`Unhandled notification "${e.method}"`,data:{requestObject:e}});return}if(i.kind!="notification"){this._logger&&this._logger.debug({text:`"${e.method}" is registered as request, but was sent as notification.`,data:{requestObject:e}});return}const s=i.notificationType.paramsSerializer.deserializeFromJson(e.params);if(s.hasErrors){this._logger&&this._logger.debug({text:`Got invalid params: ${s}`,data:{requestObject:e,errorMessage:s.errorMessage}});return}const r=s.value;for(const o of i.handlers)try{o(r,t)}catch(a){this._logger&&this._logger.warn({text:`An exception was thrown while handling a notification: ${a}.`,exception:a,data:{requestObject:e}})}}registerUnknownNotificationHandler(e){return dY(this._unknownNotificationHandler,e)}registerRequestHandler(e,t){if(this._handler.get(e.method))throw new Error(`Handler with method "${e.method}" already registered.`);return dY(this._handler,e.method,{kind:"request",requestType:e,handler:t})}registerNotificationHandler(e,t){let i=this._handler.get(e.method);if(!i)i={kind:"notification",notificationType:e,handlers:new Set},this._handler.set(e.method,i);else{if(i.kind!=="notification")throw new Error(`Method "${e.method}" was already registered as request handler.`);if(i.notificationType!==e)throw new Error(`Method "${e.method}" was registered for a different type.`)}return dY(i.handlers,t)}getRegisteredTypes(){const e=[];for(const t of this._handler.values())t.kind==="notification"?e.push(t.notificationType):t.kind==="request"&&e.push(t.requestType);return e}async request(e,t,i){if(!this.checkChannel(this._requestSender))throw new Error("Impossible");const s=e.paramsSerializer.serializeToJson(t);ZSe(s);const r=await this._requestSender.sendRequest({method:e.method,params:s},i);if("error"in r){if(e.isOptional&&r.error.code===rh.methodNotFound)return Fqe;let o;if(r.error.data!==void 0){const l=e.errorSerializer.deserializeFromJson(r.error.data);if(l.hasErrors)throw new Error(l.errorMessage);o=l.value}else o=void 0;const a=new qSe(r.error.message,o,r.error.code);throw this._requestDidErrorEventEmitter.fire({error:a}),a}else{const o=e.resultSerializer.deserializeFromJson(r.result);if(o.hasErrors)throw new Error("Could not deserialize response: "+o.errorMessage+`
1483
1483
 
1484
1484
  ${JSON.stringify(r,null,2)}`);return o.value}}async notify(e,t,i){if(!this.checkChannel(this._requestSender))throw new Error;const s=e.paramsSerializer.serializeToJson(t);ZSe(s),this._requestSender.sendNotification({method:e.method,params:s},i)}};function ZSe(n){if(n!==null&&Array.isArray(n)&&typeof n!="object")throw new Error("Invalid value! Only null, array and object is allowed.")}var qSe=class Hqe extends Error{constructor(e,t,i=rh.genericApplicationError){super(e),Zt(this,"data"),Zt(this,"code"),this.data=t,this.code=i,Object.setPrototypeOf(this,Hqe.prototype)}},hmn=class fce{constructor(e,t,i,s,r=!1){Zt(this,"method"),Zt(this,"paramsSerializer"),Zt(this,"resultSerializer"),Zt(this,"errorSerializer"),Zt(this,"isOptional"),Zt(this,"kind","request"),this.method=e,this.paramsSerializer=t,this.resultSerializer=i,this.errorSerializer=s,this.isOptional=r}withMethod(e){return new fce(e,this.paramsSerializer,this.resultSerializer,this.errorSerializer)}optional(){return new fce(this.method,this.paramsSerializer,this.resultSerializer,this.errorSerializer,!0)}},fmn=class Vqe{constructor(e,t){Zt(this,"method"),Zt(this,"paramsSerializer"),Zt(this,"kind","notification"),this.method=e,this.paramsSerializer=t}withMethod(e){return new Vqe(e,this.paramsSerializer)}};function Mn(n){return new hmn((n||{}).method,Qv.sAny(),Qv.sAny(),Qv.sAny())}function br(n){return new fmn((n||{}).method,Qv.sAny())}const gmn=Symbol();var GSe=(USe=gmn,LR=class{constructor(n){Zt(this,"error"),Zt(this,USe),this.error=n}},Zt(LR,"factory",n=>new LR(n)),LR);function mmn(n){const e=XSe(n.server),t=XSe(n.client);return new pmn(n.tags||[],e,t)}function XSe(n){const e={};for(const[t,i]of Object.entries(n)){const s=i.method?i.method:t;e[t]=i.withMethod(s)}return e}var pmn=class jqe{constructor(e=[],t,i){Zt(this,"tags"),Zt(this,"server"),Zt(this,"client"),this.tags=e,this.server=t,this.client=i}_onlyDesignTime(){return new Error("This property is not meant to be accessed at runtime")}get TContractObject(){throw this._onlyDesignTime()}get TClientInterface(){throw this._onlyDesignTime()}get TServerInterface(){throw this._onlyDesignTime()}get TClientHandler(){throw this._onlyDesignTime()}get TServerHandler(){throw this._onlyDesignTime()}get TTags(){throw this._onlyDesignTime()}getInterface(e,t,i,s){const r=this.buildCounterpart(e,i),o=this.registerHandlers(e,t,s,r);return{counterpart:r,dispose:()=>o.dispose()}}buildCounterpart(e,t){const i={};for(const[s,r]of Object.entries(t)){let o;r.kind==="request"?r.isOptional?o=async(a,l)=>{a===void 0&&(a={});try{return await e.request(r,a,l)}catch(c){if(c&&c.code===rh.methodNotFound)return Fqe;throw c}}:o=(a,l)=>(a===void 0&&(a={}),e.request(r,a,l)):o=(a,l)=>(a===void 0&&(a={}),e.notify(r,a,l)),i[s]=o}return i}registerHandlers(e,t,i,s){const r=[];for(const[o,a]of Object.entries(t))if(a.kind==="request"){let l=i[o];if(!l)continue;const c=this.createRequestHandler(s,l);r.push(e.registerRequestHandler(a,c))}else{const l=i[o];l&&r.push(e.registerNotificationHandler(a,(c,d)=>{l(c,{context:d,counterpart:s})}))}return{dispose:()=>r.forEach(o=>o.dispose())}}createRequestHandler(e,t){return async(i,s,r)=>{const o=await t(i,{context:r,counterpart:e,newErr:GSe.factory,requestId:s});return o instanceof GSe?o.error:{ok:o}}}static getServerFromStream(e,t,i,s){const r=hce.fromTransport(t,i),{server:o}=e.getServer(r,s);return r.startListen(),{channel:r,server:o}}static registerServerToStream(e,t,i,s){const r=hce.fromTransport(t,i),{client:o}=e.registerServer(r,s);return r.startListen(),{channel:r,client:o}}getServer(e,t){const{counterpart:i,dispose:s}=this.getInterface(e,this.client,this.server,t);return{server:i,dispose:s}}registerServer(e,t){const{counterpart:i,dispose:s}=this.getInterface(e,this.server,this.client,t);return{client:i,dispose:s}}withContext(){return new jqe(this.tags,this.server,this.client)}};let Jv=function(n){return n.Comment="comment",n.Imports="imports",n.Region="region",n}({}),Br=function(n){return n[n.File=1]="File",n[n.Module=2]="Module",n[n.Namespace=3]="Namespace",n[n.Package=4]="Package",n[n.Class=5]="Class",n[n.Method=6]="Method",n[n.Property=7]="Property",n[n.Field=8]="Field",n[n.Constructor=9]="Constructor",n[n.Enum=10]="Enum",n[n.Interface=11]="Interface",n[n.Function=12]="Function",n[n.Variable=13]="Variable",n[n.Constant=14]="Constant",n[n.String=15]="String",n[n.Number=16]="Number",n[n.Boolean=17]="Boolean",n[n.Array=18]="Array",n[n.Object=19]="Object",n[n.Key=20]="Key",n[n.Null=21]="Null",n[n.EnumMember=22]="EnumMember",n[n.Struct=23]="Struct",n[n.Event=24]="Event",n[n.Operator=25]="Operator",n[n.TypeParameter=26]="TypeParameter",n}({}),Wqe=function(n){return n[n.Deprecated=1]="Deprecated",n}({}),YSe=function(n){return n[n.Type=1]="Type",n[n.Parameter=2]="Parameter",n}({}),Cmn=function(n){return n[n.None=0]="None",n[n.Full=1]="Full",n[n.Incremental=2]="Incremental",n}({}),Zr=function(n){return n[n.Text=1]="Text",n[n.Method=2]="Method",n[n.Function=3]="Function",n[n.Constructor=4]="Constructor",n[n.Field=5]="Field",n[n.Variable=6]="Variable",n[n.Class=7]="Class",n[n.Interface=8]="Interface",n[n.Module=9]="Module",n[n.Property=10]="Property",n[n.Unit=11]="Unit",n[n.Value=12]="Value",n[n.Enum=13]="Enum",n[n.Keyword=14]="Keyword",n[n.Snippet=15]="Snippet",n[n.Color=16]="Color",n[n.File=17]="File",n[n.Reference=18]="Reference",n[n.Folder=19]="Folder",n[n.EnumMember=20]="EnumMember",n[n.Constant=21]="Constant",n[n.Struct=22]="Struct",n[n.Event=23]="Event",n[n.Operator=24]="Operator",n[n.TypeParameter=25]="TypeParameter",n}({}),_mn=function(n){return n[n.Deprecated=1]="Deprecated",n}({}),vmn=function(n){return n[n.PlainText=1]="PlainText",n[n.Snippet=2]="Snippet",n}({}),uY=function(n){return n[n.Text=1]="Text",n[n.Read=2]="Read",n[n.Write=3]="Write",n}({}),e2=function(n){return n.Empty="",n.QuickFix="quickfix",n.Refactor="refactor",n.RefactorExtract="refactor.extract",n.RefactorInline="refactor.inline",n.RefactorRewrite="refactor.rewrite",n.Source="source",n.SourceOrganizeImports="source.organizeImports",n.SourceFixAll="source.fixAll",n}({}),mH=function(n){return n.PlainText="plaintext",n.Markdown="markdown",n}({}),Z2=function(n){return n[n.Error=1]="Error",n[n.Warning=2]="Warning",n[n.Information=3]="Information",n[n.Hint=4]="Hint",n}({}),QSe=function(n){return n[n.Unnecessary=1]="Unnecessary",n[n.Deprecated=2]="Deprecated",n}({}),cA=function(n){return n[n.Invoked=1]="Invoked",n[n.TriggerCharacter=2]="TriggerCharacter",n[n.TriggerForIncompleteCompletions=3]="TriggerForIncompleteCompletions",n}({}),dA=function(n){return n[n.Invoked=1]="Invoked",n[n.TriggerCharacter=2]="TriggerCharacter",n[n.ContentChange=3]="ContentChange",n}({}),gce=function(n){return n[n.Invoked=1]="Invoked",n[n.Automatic=2]="Automatic",n}({}),bmn=function(n){return n.Relative="relative",n}({});var _i=class{constructor(n){this.method=n}};const Xn={textDocumentImplementation:new _i("textDocument/implementation"),textDocumentTypeDefinition:new _i("textDocument/typeDefinition"),textDocumentDocumentColor:new _i("textDocument/documentColor"),textDocumentColorPresentation:new _i("textDocument/colorPresentation"),textDocumentFoldingRange:new _i("textDocument/foldingRange"),textDocumentDeclaration:new _i("textDocument/declaration"),textDocumentSelectionRange:new _i("textDocument/selectionRange"),textDocumentPrepareCallHierarchy:new _i("textDocument/prepareCallHierarchy"),textDocumentSemanticTokensFull:new _i("textDocument/semanticTokens/full"),textDocumentSemanticTokensFullDelta:new _i("textDocument/semanticTokens/full/delta"),textDocumentLinkedEditingRange:new _i("textDocument/linkedEditingRange"),workspaceWillCreateFiles:new _i("workspace/willCreateFiles"),workspaceWillRenameFiles:new _i("workspace/willRenameFiles"),workspaceWillDeleteFiles:new _i("workspace/willDeleteFiles"),textDocumentMoniker:new _i("textDocument/moniker"),textDocumentPrepareTypeHierarchy:new _i("textDocument/prepareTypeHierarchy"),textDocumentInlineValue:new _i("textDocument/inlineValue"),textDocumentInlayHint:new _i("textDocument/inlayHint"),textDocumentDiagnostic:new _i("textDocument/diagnostic"),textDocumentInlineCompletion:new _i("textDocument/inlineCompletion"),textDocumentWillSaveWaitUntil:new _i("textDocument/willSaveWaitUntil"),textDocumentCompletion:new _i("textDocument/completion"),textDocumentHover:new _i("textDocument/hover"),textDocumentSignatureHelp:new _i("textDocument/signatureHelp"),textDocumentDefinition:new _i("textDocument/definition"),textDocumentReferences:new _i("textDocument/references"),textDocumentDocumentHighlight:new _i("textDocument/documentHighlight"),textDocumentDocumentSymbol:new _i("textDocument/documentSymbol"),textDocumentCodeAction:new _i("textDocument/codeAction"),workspaceSymbol:new _i("workspace/symbol"),textDocumentCodeLens:new _i("textDocument/codeLens"),textDocumentDocumentLink:new _i("textDocument/documentLink"),textDocumentFormatting:new _i("textDocument/formatting"),textDocumentRangeFormatting:new _i("textDocument/rangeFormatting"),textDocumentRangesFormatting:new _i("textDocument/rangesFormatting"),textDocumentOnTypeFormatting:new _i("textDocument/onTypeFormatting"),textDocumentRename:new _i("textDocument/rename"),workspaceExecuteCommand:new _i("workspace/executeCommand"),workspaceDidCreateFiles:new _i("workspace/didCreateFiles"),workspaceDidRenameFiles:new _i("workspace/didRenameFiles"),workspaceDidDeleteFiles:new _i("workspace/didDeleteFiles"),workspaceDidChangeConfiguration:new _i("workspace/didChangeConfiguration"),textDocumentDidOpen:new _i("textDocument/didOpen"),textDocumentDidChange:new _i("textDocument/didChange"),textDocumentDidClose:new _i("textDocument/didClose"),textDocumentDidSave:new _i("textDocument/didSave"),textDocumentWillSave:new _i("textDocument/willSave"),workspaceDidChangeWatchedFiles:new _i("workspace/didChangeWatchedFiles")},tM=mmn({server:{textDocumentImplementation:Mn({method:"textDocument/implementation"}),textDocumentTypeDefinition:Mn({method:"textDocument/typeDefinition"}),textDocumentDocumentColor:Mn({method:"textDocument/documentColor"}),textDocumentColorPresentation:Mn({method:"textDocument/colorPresentation"}),textDocumentFoldingRange:Mn({method:"textDocument/foldingRange"}),textDocumentDeclaration:Mn({method:"textDocument/declaration"}),textDocumentSelectionRange:Mn({method:"textDocument/selectionRange"}),textDocumentPrepareCallHierarchy:Mn({method:"textDocument/prepareCallHierarchy"}),callHierarchyIncomingCalls:Mn({method:"callHierarchy/incomingCalls"}),callHierarchyOutgoingCalls:Mn({method:"callHierarchy/outgoingCalls"}),textDocumentSemanticTokensFull:Mn({method:"textDocument/semanticTokens/full"}),textDocumentSemanticTokensFullDelta:Mn({method:"textDocument/semanticTokens/full/delta"}),textDocumentSemanticTokensRange:Mn({method:"textDocument/semanticTokens/range"}),textDocumentLinkedEditingRange:Mn({method:"textDocument/linkedEditingRange"}),workspaceWillCreateFiles:Mn({method:"workspace/willCreateFiles"}),workspaceWillRenameFiles:Mn({method:"workspace/willRenameFiles"}),workspaceWillDeleteFiles:Mn({method:"workspace/willDeleteFiles"}),textDocumentMoniker:Mn({method:"textDocument/moniker"}),textDocumentPrepareTypeHierarchy:Mn({method:"textDocument/prepareTypeHierarchy"}),typeHierarchySupertypes:Mn({method:"typeHierarchy/supertypes"}),typeHierarchySubtypes:Mn({method:"typeHierarchy/subtypes"}),textDocumentInlineValue:Mn({method:"textDocument/inlineValue"}),textDocumentInlayHint:Mn({method:"textDocument/inlayHint"}),inlayHintResolve:Mn({method:"inlayHint/resolve"}),textDocumentDiagnostic:Mn({method:"textDocument/diagnostic"}),workspaceDiagnostic:Mn({method:"workspace/diagnostic"}),textDocumentInlineCompletion:Mn({method:"textDocument/inlineCompletion"}),initialize:Mn({method:"initialize"}),shutdown:Mn({method:"shutdown"}),textDocumentWillSaveWaitUntil:Mn({method:"textDocument/willSaveWaitUntil"}),textDocumentCompletion:Mn({method:"textDocument/completion"}),completionItemResolve:Mn({method:"completionItem/resolve"}),textDocumentHover:Mn({method:"textDocument/hover"}),textDocumentSignatureHelp:Mn({method:"textDocument/signatureHelp"}),textDocumentDefinition:Mn({method:"textDocument/definition"}),textDocumentReferences:Mn({method:"textDocument/references"}),textDocumentDocumentHighlight:Mn({method:"textDocument/documentHighlight"}),textDocumentDocumentSymbol:Mn({method:"textDocument/documentSymbol"}),textDocumentCodeAction:Mn({method:"textDocument/codeAction"}),codeActionResolve:Mn({method:"codeAction/resolve"}),workspaceSymbol:Mn({method:"workspace/symbol"}),workspaceSymbolResolve:Mn({method:"workspaceSymbol/resolve"}),textDocumentCodeLens:Mn({method:"textDocument/codeLens"}),codeLensResolve:Mn({method:"codeLens/resolve"}),textDocumentDocumentLink:Mn({method:"textDocument/documentLink"}),documentLinkResolve:Mn({method:"documentLink/resolve"}),textDocumentFormatting:Mn({method:"textDocument/formatting"}),textDocumentRangeFormatting:Mn({method:"textDocument/rangeFormatting"}),textDocumentRangesFormatting:Mn({method:"textDocument/rangesFormatting"}),textDocumentOnTypeFormatting:Mn({method:"textDocument/onTypeFormatting"}),textDocumentRename:Mn({method:"textDocument/rename"}),textDocumentPrepareRename:Mn({method:"textDocument/prepareRename"}),workspaceExecuteCommand:Mn({method:"workspace/executeCommand"}),workspaceDidChangeWorkspaceFolders:br({method:"workspace/didChangeWorkspaceFolders"}),windowWorkDoneProgressCancel:br({method:"window/workDoneProgress/cancel"}),workspaceDidCreateFiles:br({method:"workspace/didCreateFiles"}),workspaceDidRenameFiles:br({method:"workspace/didRenameFiles"}),workspaceDidDeleteFiles:br({method:"workspace/didDeleteFiles"}),notebookDocumentDidOpen:br({method:"notebookDocument/didOpen"}),notebookDocumentDidChange:br({method:"notebookDocument/didChange"}),notebookDocumentDidSave:br({method:"notebookDocument/didSave"}),notebookDocumentDidClose:br({method:"notebookDocument/didClose"}),initialized:br({method:"initialized"}),exit:br({method:"exit"}),workspaceDidChangeConfiguration:br({method:"workspace/didChangeConfiguration"}),textDocumentDidOpen:br({method:"textDocument/didOpen"}),textDocumentDidChange:br({method:"textDocument/didChange"}),textDocumentDidClose:br({method:"textDocument/didClose"}),textDocumentDidSave:br({method:"textDocument/didSave"}),textDocumentWillSave:br({method:"textDocument/willSave"}),workspaceDidChangeWatchedFiles:br({method:"workspace/didChangeWatchedFiles"}),setTrace:br({method:"$/setTrace"}),cancelRequest:br({method:"$/cancelRequest"}),progress:br({method:"$/progress"})},client:{workspaceWorkspaceFolders:Mn({method:"workspace/workspaceFolders"}).optional(),workspaceConfiguration:Mn({method:"workspace/configuration"}).optional(),workspaceFoldingRangeRefresh:Mn({method:"workspace/foldingRange/refresh"}).optional(),windowWorkDoneProgressCreate:Mn({method:"window/workDoneProgress/create"}).optional(),workspaceSemanticTokensRefresh:Mn({method:"workspace/semanticTokens/refresh"}).optional(),windowShowDocument:Mn({method:"window/showDocument"}).optional(),workspaceInlineValueRefresh:Mn({method:"workspace/inlineValue/refresh"}).optional(),workspaceInlayHintRefresh:Mn({method:"workspace/inlayHint/refresh"}).optional(),workspaceDiagnosticRefresh:Mn({method:"workspace/diagnostic/refresh"}).optional(),clientRegisterCapability:Mn({method:"client/registerCapability"}).optional(),clientUnregisterCapability:Mn({method:"client/unregisterCapability"}).optional(),windowShowMessageRequest:Mn({method:"window/showMessageRequest"}).optional(),workspaceCodeLensRefresh:Mn({method:"workspace/codeLens/refresh"}).optional(),workspaceApplyEdit:Mn({method:"workspace/applyEdit"}).optional(),windowShowMessage:br({method:"window/showMessage"}),windowLogMessage:br({method:"window/logMessage"}),telemetryEvent:br({method:"telemetry/event"}),textDocumentPublishDiagnostics:br({method:"textDocument/publishDiagnostics"}),logTrace:br({method:"$/logTrace"}),cancelRequest:br({method:"$/cancelRequest"}),progress:br({method:"$/progress"})}});function g8(n,e){if(n.textModel!==e)throw new Error(`Expected text model to be ${e}, but got ${n.textModel}`);return n}var Ur=(cY=class{constructor(){Zt(this,"_store",new $2e)}dispose(){this._store.dispose()}_register(n){if(n===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(n)}},Zt(cY,"None",Object.freeze({dispose(){}})),cY),$2e=(kR=class{constructor(){Zt(this,"_toDispose",new Set),Zt(this,"_isDisposed",!1)}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}clear(){if(this._toDispose.size!==0)try{for(const n of this._toDispose)n.dispose()}finally{this._toDispose.clear()}}add(n){if(!n)return n;if(n===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?kR.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(n),n}},Zt(kR,"DISABLE_DISPOSED_WARNING",!1),kR);const zqe=new Map([[e2.Empty,""],[e2.QuickFix,"quickfix"],[e2.Refactor,"refactor"],[e2.RefactorExtract,"refactor.extract"],[e2.RefactorInline,"refactor.inline"],[e2.RefactorRewrite,"refactor.rewrite"],[e2.Source,"source"],[e2.SourceOrganizeImports,"source.organizeImports"],[e2.SourceFixAll,"source.fixAll"]]);function ymn(n){if(n)return zqe.get(n)??n}const wmn=new Map([[Mt.CodeActionTriggerType.Invoke,gce.Invoked],[Mt.CodeActionTriggerType.Auto,gce.Automatic]]);function Smn(n){return wmn.get(n)??gce.Invoked}const Uqe=new Map([[Zr.Text,Mt.CompletionItemKind.Text],[Zr.Method,Mt.CompletionItemKind.Method],[Zr.Function,Mt.CompletionItemKind.Function],[Zr.Constructor,Mt.CompletionItemKind.Constructor],[Zr.Field,Mt.CompletionItemKind.Field],[Zr.Variable,Mt.CompletionItemKind.Variable],[Zr.Class,Mt.CompletionItemKind.Class],[Zr.Interface,Mt.CompletionItemKind.Interface],[Zr.Module,Mt.CompletionItemKind.Module],[Zr.Property,Mt.CompletionItemKind.Property],[Zr.Unit,Mt.CompletionItemKind.Unit],[Zr.Value,Mt.CompletionItemKind.Value],[Zr.Enum,Mt.CompletionItemKind.Enum],[Zr.Keyword,Mt.CompletionItemKind.Keyword],[Zr.Snippet,Mt.CompletionItemKind.Snippet],[Zr.Color,Mt.CompletionItemKind.Color],[Zr.File,Mt.CompletionItemKind.File],[Zr.Reference,Mt.CompletionItemKind.Reference],[Zr.Folder,Mt.CompletionItemKind.Folder],[Zr.EnumMember,Mt.CompletionItemKind.EnumMember],[Zr.Constant,Mt.CompletionItemKind.Constant],[Zr.Struct,Mt.CompletionItemKind.Struct],[Zr.Event,Mt.CompletionItemKind.Event],[Zr.Operator,Mt.CompletionItemKind.Operator],[Zr.TypeParameter,Mt.CompletionItemKind.TypeParameter]]);function xmn(n){return n?Uqe.get(n)??Mt.CompletionItemKind.Text:Mt.CompletionItemKind.Text}const Kqe=new Map([[_mn.Deprecated,Mt.CompletionItemTag.Deprecated]]);function Lmn(n){return Kqe.get(n)}const kmn=new Map([[Mt.CompletionTriggerKind.Invoke,cA.Invoked],[Mt.CompletionTriggerKind.TriggerCharacter,cA.TriggerCharacter],[Mt.CompletionTriggerKind.TriggerForIncompleteCompletions,cA.TriggerForIncompleteCompletions]]);function Emn(n){return kmn.get(n)??cA.Invoked}const Imn=new Map([[vmn.Snippet,Mt.CompletionItemInsertTextRule.InsertAsSnippet]]);function Mmn(n){if(n)return Imn.get(n)}const Zqe=new Map([[Br.File,Mt.SymbolKind.File],[Br.Module,Mt.SymbolKind.Module],[Br.Namespace,Mt.SymbolKind.Namespace],[Br.Package,Mt.SymbolKind.Package],[Br.Class,Mt.SymbolKind.Class],[Br.Method,Mt.SymbolKind.Method],[Br.Property,Mt.SymbolKind.Property],[Br.Field,Mt.SymbolKind.Field],[Br.Constructor,Mt.SymbolKind.Constructor],[Br.Enum,Mt.SymbolKind.Enum],[Br.Interface,Mt.SymbolKind.Interface],[Br.Function,Mt.SymbolKind.Function],[Br.Variable,Mt.SymbolKind.Variable],[Br.Constant,Mt.SymbolKind.Constant],[Br.String,Mt.SymbolKind.String],[Br.Number,Mt.SymbolKind.Number],[Br.Boolean,Mt.SymbolKind.Boolean],[Br.Array,Mt.SymbolKind.Array],[Br.Object,Mt.SymbolKind.Object],[Br.Key,Mt.SymbolKind.Key],[Br.Null,Mt.SymbolKind.Null],[Br.EnumMember,Mt.SymbolKind.EnumMember],[Br.Struct,Mt.SymbolKind.Struct],[Br.Event,Mt.SymbolKind.Event],[Br.Operator,Mt.SymbolKind.Operator],[Br.TypeParameter,Mt.SymbolKind.TypeParameter]]);function qqe(n){return Zqe.get(n)??Mt.SymbolKind.File}const Nmn=new Map([[Wqe.Deprecated,Mt.SymbolTag.Deprecated]]);function Gqe(n){return Nmn.get(n)}const Dmn=new Map([[uY.Text,Mt.DocumentHighlightKind.Text],[uY.Read,Mt.DocumentHighlightKind.Read],[uY.Write,Mt.DocumentHighlightKind.Write]]);function Tmn(n){return n?Dmn.get(n)??Mt.DocumentHighlightKind.Text:Mt.DocumentHighlightKind.Text}const Rmn=new Map([[Jv.Comment,Mt.FoldingRangeKind.Comment],[Jv.Imports,Mt.FoldingRangeKind.Imports],[Jv.Region,Mt.FoldingRangeKind.Region]]);function Pmn(n){if(n)return Rmn.get(n)}const Amn=new Map([[dh.Error,Z2.Error],[dh.Warning,Z2.Warning],[dh.Info,Z2.Information],[dh.Hint,Z2.Hint]]);function Omn(n){return Amn.get(n)??Z2.Error}const Fmn=new Map([[Z2.Error,dh.Error],[Z2.Warning,dh.Warning],[Z2.Information,dh.Info],[Z2.Hint,dh.Hint]]);function Bmn(n){return n?Fmn.get(n)??dh.Error:dh.Error}const Xqe=new Map([[QSe.Unnecessary,gH.Unnecessary],[QSe.Deprecated,gH.Deprecated]]);function $mn(n){return Xqe.get(n)}const Hmn=new Map([[Mt.SignatureHelpTriggerKind.Invoke,dA.Invoked],[Mt.SignatureHelpTriggerKind.TriggerCharacter,dA.TriggerCharacter],[Mt.SignatureHelpTriggerKind.ContentChange,dA.ContentChange]]);function Vmn(n){return Hmn.get(n)??dA.Invoked}function eb(n){if(n)return{id:n.command,title:n.title,arguments:n.arguments}}const jmn=new Map([[YSe.Type,Mt.InlayHintKind.Type],[YSe.Parameter,Mt.InlayHintKind.Parameter]]);function Wmn(n){return n?jmn.get(n)??Mt.InlayHintKind.Type:Mt.InlayHintKind.Type}function Bm(n,e){if("targetUri"in n){const t=e.bridge.translateBackRange({uri:n.targetUri},n.targetRange);return{uri:t.textModel.uri,range:t.range,originSelectionRange:n.originSelectionRange?e.bridge.translateBackRange({uri:n.targetUri},n.originSelectionRange).range:void 0,targetSelectionRange:n.targetSelectionRange?e.bridge.translateBackRange({uri:n.targetUri},n.targetSelectionRange).range:void 0}}else{const t=e.bridge.translateBackRange({uri:n.uri},n.range);return{uri:t.textModel.uri,range:t.range}}}function la(n){return!n||n.length===0?{language:"*"}:n.map(e=>"notebook"in e?typeof e.notebook=="string"?{notebookType:e.notebook,language:e.language}:{notebookType:e.notebook.notebookType,language:e.language,pattern:e.notebook.pattern,scheme:e.notebook.scheme}:{language:e.language,pattern:e.pattern,scheme:e.scheme})}function zmn(n,e){if(!e)return!0;const t=n.getLanguageId();if(n.uri.toString(!0),!e||e.length===0)return!0;for(const i of e)if(!(i.language&&i.language!=="*"&&i.language!==t))return!0;return!1}function mce(n){var t;const e={severity:Bmn(n.severity),startLineNumber:n.range.start.line+1,startColumn:n.range.start.character+1,endLineNumber:n.range.end.line+1,endColumn:n.range.end.character+1,message:n.message,source:n.source,code:typeof n.code=="string"?n.code:(t=n.code)==null?void 0:t.toString()};return n.tags&&(e.tags=n.tags.map(i=>$mn(i)).filter(i=>i!==void 0)),n.relatedInformation&&(e.relatedInformation=n.relatedInformation.map(i=>({resource:GU.parse(i.location.uri),startLineNumber:i.location.range.start.line+1,startColumn:i.location.range.start.character+1,endLineNumber:i.location.range.end.line+1,endColumn:i.location.range.end.character+1,message:i.message}))),e}var Umn=class extends Ur{constructor(n){super(),this._connection=n,this._register(this._connection.capabilities.addStaticClientCapabilities({textDocument:{completion:{dynamicRegistration:!0,contextSupport:!0,completionItemKind:{valueSet:Array.from(Uqe.keys())},completionItem:{tagSupport:{valueSet:Array.from(Kqe.keys())},commitCharactersSupport:!0,deprecatedSupport:!0,preselectSupport:!0}}}})),this._register(this._connection.capabilities.registerCapabilityHandler(Xn.textDocumentCompletion,!0,e=>Mt.registerCompletionItemProvider(la(e.documentSelector),new Kmn(this._connection,e))))}},Kmn=class{constructor(n,e){Zt(this,"resolveCompletionItem"),this._client=n,this._capabilities=e,e.resolveProvider&&(this.resolveCompletionItem=async(t,i)=>(Yqe(t,await this._client.server.completionItemResolve(t._lspItem),this._client.bridge,t._translated,t._model),t))}get triggerCharacters(){return this._capabilities.triggerCharacters}async provideCompletionItems(n,e,t,i){const s=this._client.bridge.translate(n,e),r=await this._client.server.textDocumentCompletion({textDocument:s.textDocument,position:s.position,context:t.triggerCharacter?{triggerKind:Emn(t.triggerKind),triggerCharacter:t.triggerCharacter}:void 0});return r?{suggestions:(Array.isArray(r)?r:r.items).map(o=>({...Zmn(o,this._client.bridge,s,n,e),_lspItem:o,_translated:s,_model:n}))}:{suggestions:[]}}};function Zmn(n,e,t,i,s){let r=n.insertText||n.label,o;n.textEdit&&("range"in n.textEdit?(r=n.textEdit.newText,o=g8(e.translateBackRange(t.textDocument,n.textEdit.range),i).range):(r=n.textEdit.newText,o={insert:g8(e.translateBackRange(t.textDocument,n.textEdit.insert),i).range,replace:g8(e.translateBackRange(t.textDocument,n.textEdit.replace),i).range})),o||(o=KC.fromPositions(s,s));const a={label:n.label,kind:xmn(n.kind),insertText:r,sortText:n.sortText,filterText:n.filterText,preselect:n.preselect,commitCharacters:n.commitCharacters,range:o};return Yqe(a,n,e,t,i),a}function Yqe(n,e,t,i,s){e.detail!==void 0&&(n.detail=e.detail),e.documentation!==void 0&&(n.documentation=qmn(e.documentation)),e.insertTextFormat!==void 0&&(n.insertTextRules=Mmn(e.insertTextFormat)),e.tags&&e.tags.length>0&&(n.tags=e.tags.map(Lmn).filter(r=>r!==void 0)),e.additionalTextEdits&&e.additionalTextEdits.length>0&&(n.additionalTextEdits=e.additionalTextEdits.map(r=>({range:g8(t.translateBackRange(i.textDocument,r.range),s).range,text:r.newText}))),e.command&&(n.command=eb(e.command))}function qmn(n){if(n)return typeof n=="string"?n:{value:n.value,isTrusted:!0}}var Gmn=class extends Ur{constructor(n){super(),this._connection=n,this._register(this._connection.capabilities.addStaticClientCapabilities({textDocument:{hover:{dynamicRegistration:!0,contentFormat:[mH.Markdown,mH.PlainText]}}})),this._register(this._connection.capabilities.registerCapabilityHandler(Xn.textDocumentHover,!0,e=>Mt.registerHoverProvider(la(e.documentSelector),new Xmn(this._connection,e))))}},Xmn=class{constructor(n,e){this._client=n,this._capabilities=e}async provideHover(n,e,t){const i=this._client.bridge.translate(n,e),s=await this._client.server.textDocumentHover({textDocument:i.textDocument,position:i.position});return!s||!s.contents?null:{contents:Ymn(s.contents),range:s.range?this._client.bridge.translateBackRange(i.textDocument,s.range).range:void 0}}};function Ymn(n){return Array.isArray(n)?n.map(e=>JSe(e)):[JSe(n)]}function JSe(n){return typeof n=="string"?{value:n,isTrusted:!0}:"kind"in n?{value:n.value,isTrusted:!0}:{value:`\`\`\`${n.language}
1485
1485
  ${n.value}
@@ -1509,7 +1509,7 @@ ${n.value}
1509
1509
  `)}),lCn=n=>n.trim(),uf=n=>n.endsWith(".local")?n.slice(0,-6):n,Lce=n=>n.isLocal?`${uf(n.id)}.local`:n.id,Sxe=(n,e)=>{const t=lCn(n);return t===""?"":(e==="project"||e==="user")&&t.endsWith(".local")?t.slice(0,-6):t},cCn=n=>n.endsWith(".windows")?"powershell":"shell";function dCn({compact:n=!1,disabled:e=!1,value:t,placement:i="topLeft",onChange:s}){const{t:r}=ht(),{data:o}=Gn("worktree-environments",Q3e,{revalidateOnFocus:!1}),a=(o==null?void 0:o.environments)??[],l=a.find(h=>Lce(h)===t||h.id===t),c=l!=null?uf(l.id):t!=null&&t!==""?uf(t):r("chat.sessionWorkspaceEnvironmentDefault"),d=a.length>0,u=C.useMemo(()=>v.jsxs("div",{className:"chat-header-git__overlay chat-header-git__overlay--environment",children:[v.jsx("button",{type:"button",className:`chat-header-git__menu-row ${t==null||t===""?"is-active":""}`,disabled:e,onClick:()=>s(void 0),children:v.jsxs("span",{className:"chat-header-git__menu-row-main",children:[v.jsx("span",{className:"chat-header-git__row-icon material-symbols-rounded",children:"settings_suggest"}),v.jsx("span",{className:"chat-header-git__menu-row-title",children:r("chat.sessionWorkspaceEnvironmentDefault")})]})}),d?a.map(h=>{const f=Lce(h),g=f===t||h.id===t;return v.jsxs("button",{type:"button",className:`chat-header-git__menu-row ${g?"is-active":""}`,disabled:e,title:h.path,onClick:()=>s(f),children:[v.jsxs("span",{className:"chat-header-git__menu-row-main",children:[v.jsx("span",{className:"chat-header-git__row-icon material-symbols-rounded",children:h.isLocal?"person":"folder"}),v.jsx("span",{className:"chat-header-git__menu-row-title",children:uf(h.id)})]}),v.jsx("span",{className:"chat-header-git__menu-row-trailing",children:v.jsx("span",{className:"chat-header-git__menu-row-value",children:h.isLocal?r("chat.sessionWorkspaceEnvironmentLocal"):r("chat.sessionWorkspaceEnvironmentProject")})})]},`${h.source}:${h.id}`)}):v.jsx("div",{className:"chat-header-git__empty chat-header-git__empty--environment",children:v.jsx(jn,{image:jn.PRESENTED_IMAGE_SIMPLE,description:r("chat.sessionWorkspaceNoEnvironments")})})]}),[e,a,d,s,r,t]);return v.jsx(Wo,{placement:i,trigger:["click"],popupRender:()=>u,children:v.jsxs(qe,{type:"text",disabled:e,className:`chat-header-git__trigger chat-header-git__trigger--environment ${n?"is-compact":""}`.trim(),title:(l==null?void 0:l.path)??c,"aria-label":r("chat.sessionWorkspaceEnvironment"),children:[v.jsxs("span",{className:"chat-header-git__trigger-main",children:[v.jsx("span",{className:"material-symbols-rounded",children:"deployed_code"}),v.jsx("span",{className:"chat-header-git__trigger-label",children:c})]}),v.jsx("span",{className:"chat-header-git__trigger-chevron material-symbols-rounded",children:"expand_more"})]})})}const uCn={available:!1,cwd:""};function hCn({draft:n,onChange:e}){const{t}=ht(),[i,s]=C.useState(!1),[r,o]=C.useState(!1),[a,l]=C.useState(!1),[c,d]=C.useState(""),{data:u}=Gn("workspace-git-state",()=>ZAe(),{revalidateOnFocus:!1}),{data:h,isLoading:f}=Gn(a?"workspace-git-branches":null,()=>svt(),{revalidateOnFocus:!1}),{data:g}=Gn((u==null?void 0:u.available)===!0?"workspace-git-worktrees":null,()=>ovt(),{revalidateOnFocus:!1});C.useEffect(()=>{i||d("")},[i]);const m=(h==null?void 0:h.branches)??[],p=C.useMemo(()=>$Ge(m,c),[m,c]),_=n.createWorktree?"":(u==null?void 0:u.repositoryRoot)??"",{availableLocalBranches:b,hasResults:y,remoteBranches:w}=C.useMemo(()=>FGe(p,m,_),[m,_,p]),S=c.trim()!==""&&!HGe(m,c),x=C.useMemo(()=>WGe({currentBranch:u==null?void 0:u.currentBranch,enabled:(u==null?void 0:u.available)===!0,repositoryRoot:u==null?void 0:u.repositoryRoot,worktrees:g==null?void 0:g.worktrees}),[u==null?void 0:u.available,u==null?void 0:u.currentBranch,u==null?void 0:u.repositoryRoot,g==null?void 0:g.worktrees]),{currentBranchLabel:L}=AGe(u,!1,{detachedHead:t("chat.gitDetachedHead"),pushNeedsSyncOrForce:t("chat.gitPushNeedsSyncOrForce"),pushUnavailable:t("common.operationFailed")}),E=n.branch==null?L:n.branch.mode==="create"?t("chat.sessionWorkspaceDraftCreateBranchLabel",{branch:n.branch.name}):n.branch.name,I=D=>{e(D)};return{availableLocalBranches:b,branchMenuOpen:i,branchQuery:c,canCreateBranch:S,currentBranchLabel:E,handleBranchSwitch:D=>{I({...n,branch:{mode:"checkout",name:D.name,kind:D.kind}}),s(!1)},handleCreateBranch:D=>{const P=D.trim();P!==""&&(I({...n,branch:{mode:"create",name:P}}),s(!1))},handleCreateWorktreeChange:D=>{if(n.branch==null||n.branch.mode==="create"){I({...n,createWorktree:D});return}const P=m.find(O=>{var F,$;return O.kind===((F=n.branch)==null?void 0:F.kind)&&O.name===(($=n.branch)==null?void 0:$.name)});if(P==null){I({...n,createWorktree:D});return}const R=D?"":(u==null?void 0:u.repositoryRoot)??"",A=OGe(P,m,R);I({...n,createWorktree:D,branch:A==null?n.branch:void 0})},hasBranchResults:y,isBranchListLoading:f,repoState:u??uCn,remoteBranches:w,setBranchMenuOpen:s,setBranchQuery:d,setShouldLoadBranches:l,setWorktreeMenuOpen:o,shouldLoadBranches:a,worktreeMenuOpen:r,worktrees:x.worktrees}}function fCn({compact:n=!1,disabled:e=!1,draft:t,placement:i="topLeft",onChange:s}){const{t:r}=ht(),o=hCn({draft:t,onChange:s});return v.jsx("div",{className:`chat-draft-git ${n?"chat-draft-git--compact":""}`.trim(),children:o.repoState.available?v.jsxs("div",{className:"chat-header-git chat-draft-git__controls",children:[v.jsx(VGe,{compact:n,currentBranch:o.repoState.currentBranch,open:o.worktreeMenuOpen,placement:i,mode:{type:"draft",createWorktree:t.createWorktree,disabled:e,onCreateWorktreeChange:o.handleCreateWorktreeChange},worktrees:o.worktrees,onOpenChange:a=>{o.setWorktreeMenuOpen(a),a&&o.setBranchMenuOpen(!1)}}),v.jsx(dCn,{compact:n,disabled:e,placement:i,value:t.worktreeEnvironment,onChange:a=>{s({...t,worktreeEnvironment:a})}}),v.jsx(TGe,{availableLocalBranches:o.availableLocalBranches,branchQuery:o.branchQuery,compact:n,canCreateBranch:o.canCreateBranch,currentBranchLabel:o.currentBranchLabel,hasBranchResults:o.hasBranchResults,isBusy:e,isLoading:o.isBranchListLoading,open:o.branchMenuOpen,placement:i,remoteBranches:o.remoteBranches,repoState:o.repoState,onCreateBranch:o.handleCreateBranch,onOpenChange:a=>{if(o.setBranchMenuOpen(a),a){o.setWorktreeMenuOpen(!1),o.setShouldLoadBranches(!0);return}o.setBranchQuery("")},onQueryChange:o.setBranchQuery,onSwitchBranch:o.handleBranchSwitch})]}):v.jsxs("div",{className:"chat-draft-git__unavailable",children:[v.jsx("span",{className:"material-symbols-rounded",children:"info"}),v.jsx("span",{children:r("chat.sessionWorkspaceDraftGitUnavailable")})]})})}function K2e({draftWorkspace:n,isCreating:e,sessionId:t,adapterLocked:i=!1,isThinking:s=!1,modelUnavailable:r=!1,selectedAdapter:o,adapterOptions:a,onAdapterChange:l,selectedAccount:c,accountOptions:d,showAccountSelector:u=!1,onAccountChange:h,onDraftWorkspaceChange:f}){const{isCompactLayout:g}=Mr();return v.jsxs("div",{className:`chat-status-bar ${g?"chat-status-bar--compact":""}`,children:[v.jsx("div",{className:"chat-status-bar__content",children:t!=null&&t!==""?v.jsx(sCn,{compact:g,placement:"topLeft",sessionId:t}):v.jsx(fCn,{compact:g,disabled:e,draft:n,placement:"topLeft",onChange:f})}),v.jsxs("div",{className:"chat-status-bar__actions",children:[v.jsx(k4n,{state:{isThinking:s,modelUnavailable:r,selectedAccount:c,selectedAdapter:o,showAccountSelector:u},data:{accountOptions:d},handlers:{onAccountChange:h}}),v.jsx(E4n,{state:{adapterLocked:i,modelUnavailable:r,isThinking:s,selectedAdapter:o},data:{adapterOptions:a},handlers:{onAdapterChange:l}})]})]})}function gCn({anchorId:n,items:e,originalMessage:t,sessionId:i,targetToolUseId:s,footer:r}){const{t:o}=ht(),[a]=qm(),l=a.get("debug")==="true",[c,d]=C.useState(!1);if(e.length===0)return null;const u=E8n(e,o),h=s!=null&&s!==""&&e.some(g=>g.item.id===s),f=c||h;return e.length===1?v.jsx(vH,{anchorId:n,canEdit:!1,canFork:!1,canRecall:!1,isDebugMode:l,isEditing:!1,message:t,sessionId:i,onFork:()=>{},onRecall:()=>{},onStartEditing:()=>{},children:v.jsxs("div",{id:n,className:"tool-group-container",children:[v.jsx("div",{className:"tool-group-wrapper single-item","data-tool-use-id":e[0].item.id,children:v.jsx(rM,{item:e[0].item,resultItem:e[0].resultItem})}),r&&l&&v.jsx("div",{className:"tool-group-footer-wrapper",children:v.jsx(bce,{msg:r.originalMessage,isUser:!1})})]})}):v.jsx(vH,{anchorId:n,canEdit:!1,canFork:!1,canRecall:!1,isDebugMode:l,isEditing:!1,message:t,sessionId:i,onFork:()=>{},onRecall:()=>{},onStartEditing:()=>{},children:v.jsxs("div",{id:n,className:"tool-group-container",children:[v.jsxs("div",{className:"tool-group-wrapper card-style",children:[v.jsxs("div",{className:"tool-group-header","aria-expanded":f,onClick:()=>d(!c),children:[v.jsx("div",{className:"header-left",children:v.jsx("span",{children:u})}),v.jsx("span",{className:`material-symbols-rounded expand-icon ${f?"is-expanded":""}`,children:"chevron_right"})]}),v.jsx("div",{className:`tool-group-list-shell ${f?"expanded":"collapsed"}`,"aria-hidden":!f,children:v.jsx("div",{className:"tool-group-list",children:e.map((g,m)=>v.jsx(rM,{item:g.item,resultItem:g.resultItem},g.item.id||m))})})]}),r&&l&&v.jsx("div",{className:"tool-group-footer-wrapper",children:v.jsx(bce,{msg:r.originalMessage,isUser:!1})})]})})}const mCn=(n,e)=>{if(n.anchorId!==e.anchorId||n.items.length!==e.items.length||n.targetToolUseId!==e.targetToolUseId)return!1;for(let t=0;t<n.items.length;t++)if(n.items[t].item!==e.items[t].item||n.items[t].resultItem!==e.items[t].resultItem)return!1;return n.originalMessage!==e.originalMessage||n.sessionId!==e.sessionId?!1:n.footer==null&&e.footer==null?!0:n.footer==null||e.footer==null?!1:n.footer.originalMessage===e.footer.originalMessage&&n.footer.createdAt===e.footer.createdAt&&n.footer.model===e.footer.model&&n.footer.usage===e.footer.usage},pCn=te.memo(gCn,mCn);function CCn({isReady:n,messages:e,session:t,targetMessageId:i,targetToolUseId:s,sessionInfo:r,historyStatusNotices:o,historyCreationProgress:a=[],sessionActivityLabel:l,queuedMessages:c,onRetryConnection:d,interactionRequest:u,onInteractionResponse:h,setMessages:f,onClearMessages:g,placeholder:m,modelMenuGroups:p,modelSearchOptions:_,recommendedModelOptions:b,servicePreviewModelOptions:y,onToggleRecommendedModel:w,updatingRecommendedModelValue:S,selectedModel:x,modelForQuery:L,onModelChange:E,effort:I,effortOptions:M,onEffortChange:N,permissionMode:T,permissionModeOptions:D,onPermissionModeChange:P,selectedAdapter:R,adapterOptions:A,onAdapterChange:O,selectedAccount:F,accountOptions:$,showAccountSelector:B,onAccountChange:V,modelUnavailable:W,hasAvailableModels:H,agentRoomTranscript:U,contextReferenceRequest:Z}){var wi,Jr;const{t:G}=ht(),{message:q}=Vs.useApp(),K=E3(),{isCompactLayout:X,isTouchInteraction:ie}=Mr(),{data:se}=Gn("/api/config",Z0),J=C.useMemo(()=>Phe(se),[se]),le=C.useRef(!1),[be,ae]=C.useState(()=>({...jb})),[ce,oe]=C.useState(()=>({...KO})),[he,ye]=C.useState(void 0),{creationProgress:ke,isCreating:Ce,send:Se,sendContent:we,retrySessionCreation:ve,enqueueContent:Ee,removeQueuedContent:me,moveQueuedContent:xe,reorderQueuedContent:Oe,editMessage:We,forkMessage:Ke,interrupt:ze,clearMessages:Ve,recallMessage:Ne}=xBe({session:t,modelForQuery:L,hasAvailableModels:H,effort:I,permissionMode:T,adapter:R,account:F,sessionTargetDraft:be,workspaceDraft:ce,workspaceDraftDirty:le.current,workspaceConfigReady:se!=null,onClearMessages:g}),Ie=U!=null,Ge=C.useMemo(()=>U==null?null:{type:"init",uuid:U.room.id,model:"agent-room",version:"agent-room",tools:[],slashCommands:[],cwd:"",agents:jyt(U.members).map(st=>st.value.slice(1)),title:U.room.title},[U]),Fe=Ce||(t==null?void 0:t.status)==="running",Re=(Ie?U.room.messages.length:e.length)+o.length+ke.length+a.length+(Fe?1:0),{messagesEndRef:Je,messagesContainerRef:vt,messagesContentRef:$t,showScrollBottom:en,scrollToBottom:gt}=JDt({contentVersion:Re}),Ht=C.useRef(!1),at=C.useRef(""),ft=C.useRef(""),[Tt,hn]=C.useState(null),[wn,Pe]=C.useState(new Set),[mt,xt]=C.useState("steer"),[rt,et]=C.useState(null),[ct,St]=C.useState(!1),[Ut,Qt]=C.useState(null),[Dn,wt]=C.useState(0),It=(u==null?void 0:u.payload.options)??[],{announcements:rn,startupPresets:ei,builtinActions:li}=C.useMemo(()=>mTt(se),[se]),ni=st=>{var ci;return{id:(ci=globalThis.crypto)!=null&&ci.randomUUID?globalThis.crypto.randomUUID():`local-${Date.now()}-${Math.random().toString(16).slice(2)}`,role:"user",content:st,createdAt:Date.now()}},Wt=()=>(t==null?void 0:t.id)!=null||GDt(be)?!0:(q.warning(G("chat.sessionTarget.missingResourceWarning")),!1),Me=async(st,on)=>{if(!Wt())return!1;const ci=on??mt;if(t!=null&&t.id&&t.status==="running"){const Si=await Ee(ci,st);return Si&&rt!=null&&(et(null),xt("steer")),Si}if(!(t!=null&&t.id)){const Si=await we(st,on);return Si&&rt!=null&&(et(null),xt("steer")),Si}const pi=await we(st,on);return pi&&(f(Si=>[...Si,ni(st)]),rt!=null&&(et(null),xt("steer"))),pi},bt=async(st,on)=>{if(!Wt())return!1;const ci=on??mt;if(t!=null&&t.id&&t.status==="running"){const Si=await Ee(ci,[{type:"text",text:st.trim()}]);return Si&&rt!=null&&(et(null),xt("steer")),Si}if(!(t!=null&&t.id)){const Si=await Se(st,on);return Si&&rt!=null&&(et(null),xt("steer")),Si}const pi=await Se(st,on);return pi&&(f(Si=>[...Si,ni(st)]),rt!=null&&(et(null),xt("steer"))),pi},it=async st=>{if(U==null)return!1;const on=DOe(st,U.members);if(on.status==="empty")return!1;if(on.status==="missing")return q.warning(G("agentRoom.composer.error.missingTarget",{target:on.mention})),!1;if(on.status==="ambiguous")return q.warning(G("agentRoom.composer.error.ambiguousTarget",{target:on.mention})),!1;if(on.status==="empty-targeted-message")return q.warning(G("agentRoom.composer.error.emptyTargetedMessage",{target:on.previewLabel})),!1;St(!0);try{return await U.onSubmitMessage(zyt(on)),!0}catch(ci){return console.error("Failed to send agent room message:",ci),q.error(G("common.operationFailed")),!1}finally{St(!1)}},Pt=async st=>{if(st.filter(pi=>pi.type!=="text").length>0)return q.warning(G("agentRoom.composer.error.unsupportedAttachments")),!1;const ci=st.filter(pi=>pi.type==="text").map(pi=>pi.text).join(`
1510
1510
  `).trim();return it(ci)},Ot=st=>{const on=nE(st);Qt({requestId:`${st.memberKey}:${Date.now()}:${Math.random().toString(16).slice(2)}`,content:[{type:"text",text:`${on} `}]})},yt=()=>{Qt({requestId:`host:${Date.now()}:${Math.random().toString(16).slice(2)}`,content:[]})};C.useEffect(()=>{Ht.current=!1,at.current="",ft.current="",hn(null),Pe(new Set),et(null),xt("steer"),St(!1),Qt(null),ye(void 0),ae((t==null?void 0:t.id)!=null?W4e(t):{...jb})},[U==null?void 0:U.room.id,t==null?void 0:t.id,t==null?void 0:t.promptName,t==null?void 0:t.promptType]),C.useEffect(()=>{(t==null?void 0:t.id)==null&&(le.current=!1,oe({...J}))},[t==null?void 0:t.id]),C.useEffect(()=>{(t==null?void 0:t.id)==null&&(le.current||oe({...J}))},[J,t==null?void 0:t.id]),C.useEffect(()=>{wt(0)},[u==null?void 0:u.id]),C.useEffect(()=>{if(It.length===0){wt(0);return}wt(st=>Math.min(st,It.length-1))},[It.length]);const tn=C.useCallback(st=>{It.length!==0&&wt(on=>Zp(on,st,It.length))},[It.length]),Wn=C.useCallback(()=>{if(u==null)return;const st=It[Dn]??It[0];st!=null&&h(u.id,st.value??st.label)},[Dn,It,u,h]);C.useEffect(()=>{!Ht.current&&n&&K.hash===""&&(gt("auto"),Ht.current=!0)},[Re,n,K.hash,gt]),C.useEffect(()=>{K.hash===""&&!en&&gt("auto")},[Re,K.hash,gt,en]);const fi=st=>{let on=!1;hn(ci=>ci!=null&&ci!==st?(on=!0,ci):st),on&&q.warning(G("chat.messageActions.editInProgress"))},_s=Tt!=null,Yt=!Ie&&!(t!=null&&t.id)&&e.length===0&&o.length===0,In=C.useCallback(st=>{var Fa,Oh,GC;if((t==null?void 0:t.id)!=null)return;st.mode!=null&&ae(uTt(st));const on=hTt(st);on!=null&&(le.current=!0,oe(Pw=>({...Pw,...on})));const ci=(Fa=st.model)==null?void 0:Fa.trim();ci!=null&&ci!==""&&E(ci);const pi=(Oh=st.adapter)==null?void 0:Oh.trim();pi!=null&&pi!==""&&O(pi);const Si=(GC=st.account)==null?void 0:GC.trim();Si!=null&&Si!==""&&V(Si),st.effort!=null&&N(st.effort),st.permissionMode!=null&&P(st.permissionMode),ye(fTt(st))},[V,O,N,E,P,t==null?void 0:t.id]),En=C.useMemo(()=>Ie?[]:o4n(e),[Ie,e]),ds=C.useMemo(()=>decodeURIComponent(K.hash.replace(/^#/,"")),[K.hash]),dr=C.useMemo(()=>{if(s!=null&&s!==""){const st=En.find(on=>on.type==="tool-group"&&on.items.some(ci=>ci.item.id===s));return(st==null?void 0:st.anchorId)??""}if(i!=null&&i!==""){const st=En.find(on=>on.type==="message"&&on.originalMessage.id===i);return(st==null?void 0:st.anchorId)??""}return""},[En,i,s]),Kr=C.useMemo(()=>r4n({renderItems:En,expandedTurnIds:wn,hashAnchorId:ds!==""?ds:dr,keepLastTurnExpanded:Ce||(t==null?void 0:t.status)==="running"||(t==null?void 0:t.status)==="waiting_input"}),[wn,ds,Ce,En,t==null?void 0:t.status,dr]),mo=Ce||(t==null?void 0:t.status)==="running"||(t==null?void 0:t.status)==="waiting_input",Ro=C.useMemo(()=>i4n(En),[En]),vc=C.useMemo(()=>n4n(En),[En]),jl=async st=>{await me(st.id)&&(et({content:st.content}),xt("steer"))},ll=async(st,on)=>{await xe(st.id,on)},Oa=!Ie&&(u==null?void 0:u.payload.kind)==="permission",is=!Ie&&!_s&&u!=null?v.jsx(d4n,{interactionRequest:u,activeOptionIndex:Dn,permissionContext:u.payload.kind==="permission"?u.payload.permissionContext:void 0,deniedTools:u.payload.kind==="permission"?((wi=u.payload.permissionContext)==null?void 0:wi.deniedTools)??[]:[],reasons:u.payload.kind==="permission"?((Jr=u.payload.permissionContext)==null?void 0:Jr.reasons)??[]:[],onActiveOptionIndexChange:wt,onMoveActiveOption:tn,onInteractionResponse:h}):null,fn=Ie?U.workspaceSessionId:t==null?void 0:t.id,gn=fn!=null&&fn!=="",ts=Ie?void 0:Ce?"running":t==null?void 0:t.status,Xi=!Ie&&(Ce||(t==null?void 0:t.status)==="running"),As=Ie?Ut==null?void 0:Ut.content:(rt==null?void 0:rt.content)??he,ur=!Ie&&rt!=null?G("chat.queue.requeueMessage"):void 0,ca=Ie?G("agentRoom.composer.placeholder"):m,po=Ie?Ge:r;C.useEffect(()=>{const st=ds;if(st===""){at.current="";return}if(!n||at.current===st)return;let on=null,ci=null,pi=null;const Si=()=>{const Fa=document.getElementById(st);return Fa==null?!1:(at.current=st,Fa.scrollIntoView({block:"center",behavior:"auto"}),Fa.classList.add("is-anchor-target"),on=setTimeout(()=>{Fa.classList.remove("is-anchor-target")},1800),!0)};return Si()||(pi=requestAnimationFrame(()=>{Si()||(ci=setTimeout(()=>{Si()},120))})),()=>{pi!=null&&cancelAnimationFrame(pi),ci!=null&&clearTimeout(ci),on!=null&&clearTimeout(on)}},[ds,Re,n,Kr]),C.useEffect(()=>{const st=s!=null&&s!==""?{key:"data-tool-use-id",value:s,targetKey:`tool:${s}`}:i!=null&&i!==""?{key:"data-message-id",value:i,targetKey:`message:${i}`}:void 0;if(st==null){ft.current="";return}if(ft.current===st.targetKey)return;const on=window.requestAnimationFrame(()=>{const ci=$t.current;if(ci==null)return;const pi=Array.from(ci.querySelectorAll(`[${st.key}]`)).find(Si=>Si.getAttribute(st.key)===st.value);pi!=null&&(ft.current=st.targetKey,pi.scrollIntoView({block:"center",behavior:"smooth"}))});return()=>{window.cancelAnimationFrame(on)}},[Re,Kr,$t,i,s]);const da=st=>{Pe(on=>{const ci=new Set(on);return ci.has(st)?ci.delete(st):ci.add(st),ci})},Co=st=>{if(st==null)return null;const on=Math.floor(st/1e3);if(on<=0)return G("chat.turnDurationUnderSecond");const ci=Math.floor(on/3600),pi=Math.floor(on%3600/60),Si=on%60;return ci>0?[G("chat.turnDurationHours",{count:ci}),pi>0?G("chat.turnDurationMinutes",{count:pi}):null].filter(Boolean).join(" "):pi>0?[G("chat.turnDurationMinutes",{count:pi}),Si>0?G("chat.turnDurationSeconds",{count:Si}):null].filter(Boolean).join(" "):G("chat.turnDurationSeconds",{count:Si})},ua=st=>v.jsx("div",{className:`chat-turn-summary ${st.isCollapsed?"is-collapsed":"is-expanded"}`,children:v.jsxs("div",{className:"chat-turn-summary__content",children:[v.jsxs("div",{className:"chat-turn-summary__meta",children:[Co(st.durationMs)!=null&&v.jsx("span",{className:"chat-turn-summary__time",children:G("chat.turnProcessedDuration",{duration:Co(st.durationMs)})}),v.jsx("span",{className:"chat-turn-summary__count",children:G("chat.turnSummaryCount",{count:st.hiddenCount})})]}),v.jsx("button",{type:"button",className:"chat-turn-summary__toggle","aria-expanded":!st.isCollapsed,onClick:()=>da(st.id),children:v.jsx("span",{className:"material-symbols-rounded",children:"chevron_right"})})]})}),Wl=(st,on)=>st.type==="message"?v.jsx(e4n,{anchorId:st.anchorId,msg:st.message,isFirstInGroup:st.isFirstInGroup,isTargeted:st.originalMessage.id===i,originalMessage:st.originalMessage,sessionInfo:r,isEditing:Tt===st.originalMessage.id,isCompactLayout:X,isTouchInteraction:ie,isSessionBusy:mo,hideActionButtons:mo&&st.anchorId===vc,showAssistantActions:st.anchorId===Ro,onEditMessage:We,onForkMessage:Ke,onRecallMessage:Ne,onStartEditing:fi,onCancelEditing:ci=>{hn(pi=>pi===ci?null:pi)},sessionId:t==null?void 0:t.id},on??st.anchorId):v.jsx(pCn,{anchorId:st.anchorId,items:st.items,originalMessage:st.originalMessage,sessionId:t==null?void 0:t.id,targetToolUseId:s,footer:st.footer},on??st.id),Zn=v.jsxs(v.Fragment,{children:[Oa&&is,v.jsx(oTt,{messages:Ie?[]:e}),!_s&&v.jsx(eCe,{mode:"next",items:Ie?[]:c.next,onMove:(st,on)=>void ll(st,on),onDelete:st=>void me(st.id),onEdit:st=>void jl(st),onReorder:st=>Oe("next",st)}),!_s&&v.jsx(eCe,{mode:"steer",items:Ie?[]:c.steer,onMove:(st,on)=>void ll(st,on),onDelete:st=>void me(st.id),onEdit:st=>void jl(st),onReorder:st=>Oe("steer",st)}),!Oa&&is,!_s&&v.jsxs("div",{className:"sender-container",children:[v.jsx(tK,{onSend:Ie?it:bt,onSendContent:Ie?Pt:Me,adapterLocked:gn,sessionId:fn,sessionStatus:ts,onInterrupt:Ie?()=>{}:ze,onClear:Ie?void 0:Ve,sessionInfo:po,interactionRequest:Ie?null:u,onInteractionResponse:Ie?void 0:h,interactionOptionNavigation:!Ie&&u!=null&&It.length>0?{optionCount:It.length,activeIndex:Dn,onMove:tn,onSubmit:Wn}:void 0,initialContent:As,autoFocus:Ie&&Ut!=null,placeholder:ca,submitLabel:ur,submitLoading:Ie?ct:void 0,modelMenuGroups:p,modelSearchOptions:_,recommendedModelOptions:b,servicePreviewModelOptions:y,onToggleRecommendedModel:w,updatingRecommendedModelValue:S,selectedModel:x,onModelChange:E,effort:I,effortOptions:M,onEffortChange:N,permissionMode:T,permissionModeOptions:D,onPermissionModeChange:P,selectedAdapter:R,adapterOptions:A,onAdapterChange:O,selectedAccount:F,accountOptions:$,showAccountSelector:B,onAccountChange:V,modelUnavailable:W,sessionTarget:Ie?void 0:{draft:(t==null?void 0:t.id)!=null?W4e(t):be,locked:(t==null?void 0:t.id)!=null,disabled:Ce,onChange:ae},agentRoomTargetMembers:Ie?U.members:void 0,queueMode:Ie?void 0:mt,onQueueModeChange:Ie?void 0:xt,contextReferenceRequest:Z},Ie?(Ut==null?void 0:Ut.requestId)??U.room.id:void 0),v.jsx(K2e,{draftWorkspace:ce,isCreating:!Ie&&Ce,sessionId:fn,adapterLocked:gn,isThinking:Xi,modelUnavailable:W,selectedAdapter:R,adapterOptions:A,onAdapterChange:O,selectedAccount:F,accountOptions:$,showAccountSelector:B,onAccountChange:V,onDraftWorkspaceChange:st=>{le.current=!0,oe(st)}})]})]});return v.jsxs(v.Fragment,{children:[v.jsxs("div",{className:`chat-messages ${n?"ready":""}`,ref:vt,children:[v.jsxs("div",{className:"chat-messages-content",ref:$t,children:[!(t!=null&&t.id)&&Ce&&v.jsx(mxe,{progress:ke}),(t==null?void 0:t.id)!=null&&a.length>0&&v.jsx(mxe,{progress:a,collapseWhenComplete:!0}),Ie?v.jsx(qDt,{room:U.room,onOpenHostSession:U.onOpenHostSession,onOpenRun:U.onOpenRun,onReplyToRun:U.onReplyToRun,onSelectHostTarget:yt,onSelectMemberTarget:Ot}):Kr.map(st=>st.isExpandable?v.jsxs("div",{className:`chat-turn ${st.isCollapsed?"is-collapsed":"is-expanded"}`,children:[Wl(st.items[0],`${st.id}:leading`),v.jsxs("div",{className:`chat-turn__summary-region ${st.isCollapsed?"is-collapsed":"is-expanded"}`,children:[ua(st),v.jsx("div",{className:`chat-turn__collapsible ${st.isCollapsed?"is-collapsed":"is-expanded"}`,"aria-hidden":st.isCollapsed,children:v.jsx("div",{className:"chat-turn__collapsible-inner",children:st.items.slice(1,-1).map(on=>Wl(on))})})]}),Wl(st.items[st.items.length-1],`${st.id}:trailing`)]},st.id):v.jsx(te.Fragment,{children:st.items.map(on=>Wl(on))},st.id)),o.map(st=>v.jsx(t4n,{notice:st,onRetryConnection:d,onRetrySessionCreation:()=>{ve()}},st.id)),Fe&&v.jsx("div",{className:"chat-thinking-indicator",role:"status","aria-live":"polite",children:v.jsx("span",{className:"chat-thinking-indicator__text",children:l??G("chat.thinking")})}),v.jsx("div",{ref:Je})]}),en&&v.jsx("div",{className:"scroll-bottom-btn",onClick:()=>gt(),children:v.jsx("span",{className:"material-symbols-rounded",children:"arrow_downward"})})]}),!Ie&&Yt?v.jsx(yBe,{compact:X,composer:Zn,contentClassName:"chat-history-view__new-session-content",children:v.jsx(STt,{announcements:rn,startupPresets:ei,builtinActions:li,onApplyStarter:In})}):v.jsx(bBe,{children:Zn})]})}const _Cn=({value:n})=>{const{t:e}=ht(),[t,i]=C.useState(!1),s=n!=null&&typeof n=="object"?n:void 0,r=s==null?void 0:s.urls,o=s==null?void 0:s.version,a=pOe(),l=Gbt(),c=s==null?void 0:s.lastReleaseAt;return v.jsxs("div",{className:"config-about",children:[v.jsxs("div",{className:"config-about__card",children:[v.jsxs("div",{className:"config-about__app",children:[v.jsx("div",{className:"config-about__app-icon",children:v.jsx("span",{className:"material-symbols-rounded",children:"auto_awesome"})}),v.jsxs("div",{className:"config-about__app-info",children:[v.jsx("div",{className:"config-about__app-title",children:e("config.about.software")}),v.jsxs("div",{className:"config-about__app-meta",children:[v.jsxs("span",{className:"config-about__app-version",title:e("config.about.commitHash"),onDoubleClick:()=>i(!0),children:[e("config.about.clientVersion"),": ",a]}),t&&v.jsxs("span",{className:"config-about__app-commit",children:[e("config.about.commitHash"),": ",l??e("config.about.unknown")]}),v.jsxs("span",{className:"config-about__app-server-version",children:[e("config.about.serverVersion"),": ",o??e("config.about.unknown")]}),v.jsx("span",{className:"config-about__app-date",children:c??e("config.about.unknown")})]})]})]}),v.jsx("a",{className:"config-about__primary",href:(r==null?void 0:r.releases)??(r==null?void 0:r.repo),target:"_blank",rel:"noreferrer",children:e("config.about.checkUpdate")})]}),v.jsxs("div",{className:"config-about__list",children:[v.jsxs("a",{className:"config-about__item-row",href:(r==null?void 0:r.docs)??(r==null?void 0:r.repo),target:"_blank",rel:"noreferrer",children:[v.jsxs("span",{className:"config-about__item-left",children:[v.jsx("span",{className:"material-symbols-rounded config-about__item-icon",children:"menu_book"}),v.jsx("span",{children:e("config.about.docs")})]}),v.jsx("span",{className:"material-symbols-rounded config-about__arrow",children:"open_in_new"})]}),v.jsxs("a",{className:"config-about__item-row",href:(r==null?void 0:r.contact)??(r==null?void 0:r.repo),target:"_blank",rel:"noreferrer",children:[v.jsxs("span",{className:"config-about__item-left",children:[v.jsx("span",{className:"material-symbols-rounded config-about__item-icon",children:"mail"}),v.jsx("span",{children:e("config.about.contact")})]}),v.jsx("span",{className:"material-symbols-rounded config-about__arrow",children:"open_in_new"})]}),v.jsxs("a",{className:"config-about__item-row",href:(r==null?void 0:r.issues)??(r==null?void 0:r.repo),target:"_blank",rel:"noreferrer",children:[v.jsxs("span",{className:"config-about__item-left",children:[v.jsx("span",{className:"material-symbols-rounded config-about__item-icon",children:"bug_report"}),v.jsx("span",{children:e("config.about.feedback")})]}),v.jsx("span",{className:"material-symbols-rounded config-about__arrow",children:"open_in_new"})]})]})]})},bs=({title:n,description:e,icon:t,layout:i="inline",children:s})=>v.jsxs("div",{className:`config-view__field-row${i==="stacked"?" config-view__field-row--stacked":""}`,children:[v.jsxs("div",{className:"config-view__field-meta",children:[t!=null&&v.jsx("span",{className:"material-symbols-rounded config-view__field-icon",children:t}),v.jsxs("div",{className:"config-view__field-text",children:[v.jsx("div",{className:"config-view__field-title",children:n}),e!=null&&e!==""&&v.jsx("div",{className:"config-view__field-desc",children:e})]})]}),v.jsx("div",{className:"config-view__field-control",children:s})]}),kce=n=>n==null?!0:Array.isArray(n)?n.length===0:typeof n=="object"?Object.keys(n).length===0:!1,m9=n=>n==null?n:JSON.parse(JSON.stringify(n)),zGe=n=>Array.isArray(n)?"array":n!=null&&typeof n=="object"?"object":typeof n=="number"?"number":typeof n=="boolean"?"boolean":"string",Is=n=>n==="string"?"text_fields":n==="number"?"numbers":n==="boolean"?"toggle_on":n==="array"?"view_list":"account_tree",Dy=(n,e,t,i)=>{if(t.length===0)return i;const s=`config.fields.${e}.${t.join(".")}.label`;return n(s,{defaultValue:i})},bH=(n,e,t)=>{if(t.length===0)return"";const i=`config.fields.${e}.${t.join(".")}.desc`;return n(i,{defaultValue:""})},UGe=n=>/key|token|secret|password/i.test(n),au=(n,e)=>{if(e.length===0)return n;let t=n;for(const i of e){if(t==null||typeof t!="object")return;t=t[i]}return t},C1=(n,e,t)=>{if(e.length===0)return t;const i=n!=null&&typeof n=="object"&&!Array.isArray(n)?{...n}:{};let s=i;for(let r=0;r<e.length-1;r+=1){const o=e[r],a=s[o],l=a!=null&&typeof a=="object"&&!Array.isArray(a)?{...a}:{};s[o]=l,s=l}return s[e[e.length-1]]=t,i},GL=({value:n,sectionKey:e,path:t=[],t:i})=>kce(n)?v.jsx(jn,{description:i("common.noData"),image:null}):Array.isArray(n)?n.some(r=>r!=null&&typeof r=="object")?v.jsx("span",{className:"config-view__pill",children:i("config.editor.complexValue")}):v.jsx("div",{className:"config-view__display-pill",children:n.map((r,o)=>v.jsx("span",{className:"config-view__pill",children:String(r)},`${o}-${String(r)}`))}):n!=null&&typeof n=="object"?v.jsx("div",{className:"config-view__field-list",children:Object.entries(n).map(([s,r])=>{const o=Dy(i,e,[...t,s],s),a=bH(i,e,[...t,s]);return v.jsx(bs,{title:o,description:a,icon:Is(zGe(r)),children:v.jsx(GL,{value:r,sectionKey:e,path:[...t,s],t:i})},s)})}):v.jsx("span",{className:"config-view__pill",children:String(n)}),Ty=({value:n,onChange:e})=>{const{message:t}=Vs.useApp(),{t:i}=ht(),[s,r]=C.useState(()=>JSON.stringify(n??{},null,2));return C.useEffect(()=>{r(JSON.stringify(n??{},null,2))},[n]),v.jsx(yn.TextArea,{className:"config-view__complex-editor",value:s,onChange:o=>{r(o.target.value)},onBlur:()=>{try{const o=JSON.parse(s);e==null||e(o),r(JSON.stringify(o??{},null,2))}catch{t.error(i("config.invalidJson")),r(JSON.stringify(n??{},null,2))}},placeholder:i("config.editor.complexPlaceholder"),autoSize:{minRows:6}})},KN=({value:n,onChange:e,t})=>v.jsxs("div",{className:"config-view__array-list",children:[n.map((i,s)=>v.jsxs("div",{className:"config-view__array-item",children:[v.jsx(yn,{value:i,placeholder:t("config.editor.itemPlaceholder"),onChange:r=>{const o=n.slice();o[s]=r.target.value,e(o)}}),v.jsx(Qe,{title:t("config.editor.remove"),children:v.jsx(qe,{size:"small",type:"text",danger:!0,className:"config-view__icon-button config-view__icon-button--compact","aria-label":t("config.editor.remove"),icon:v.jsx("span",{className:"material-symbols-rounded",children:"delete"}),onClick:()=>{const r=n.slice();r.splice(s,1),e(r)}})})]},`${s}-${i}`)),v.jsx(Qe,{title:t("config.editor.addItem"),children:v.jsx(qe,{size:"small",type:"primary",className:"config-view__icon-button config-view__icon-button--full","aria-label":t("config.editor.addItem"),icon:v.jsx("span",{className:"material-symbols-rounded",children:"add"}),onClick:()=>{e([...n,""])}})})]}),KGe=n=>n.replace(/_/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/\b\w/g,e=>e.toUpperCase()),ZGe=n=>{const e={};for(const t of(n==null?void 0:n.fields)??[]){if(t.defaultValue===void 0)continue;const i=typeof t.defaultValue=="object"&&t.defaultValue!=null?JSON.parse(JSON.stringify(t.defaultValue)):t.defaultValue;Object.assign(e,C1(e,t.path,i))}return e},qGe=({schema:n,entryKey:e,entryValue:t})=>{if(n.mode==="keyed"){const r=n.schemas[e];return{itemSchema:r??n.unknownSchema,isKnownEntry:r!=null}}const i=n.discriminatorField??"type",s=au(t,[i]);if(typeof s=="string"){const r=n.schemas[s];return{itemSchema:r??n.unknownSchema,isKnownEntry:r!=null}}return{itemSchema:n.unknownSchema,isKnownEntry:!1}},xxe=(n=[])=>n.map(e=>({value:e.value,label:e.label??e.value})),Lxe=v.jsx("span",{className:"material-symbols-rounded config-view__select-chevron",children:"expand_more"}),vCn=n=>n.icon!=null?n.icon:n.type==="json"?Is("object"):n.type==="string[]"?Is("array"):n.type==="select"||n.type==="multiline"?Is("string"):n.type==="string"||n.type==="number"||n.type==="boolean"?Is(n.type):Is("object"),yH=({value:n,schema:e,onChange:t,t:i,hideFieldPaths:s,visibleFieldPaths:r,resolveFieldLabel:o,resolveFieldDescription:a,resolveFieldOptions:l})=>{const c=d=>{if(r!=null&&!r.some(S=>d.path.length===S.length&&d.path.every((x,L)=>x===S[L]))||s!=null&&s.some(S=>d.path.length===S.length&&d.path.every((x,L)=>x===S[L])))return null;const u=au(n,d.path),h=u!==void 0?u:d.defaultValue,f=d.label??KGe(d.path[d.path.length-1]??""),g=d.description??"",m=(o==null?void 0:o(d,f))??f,p=(a==null?void 0:a(d,g))??g,_=l==null?void 0:l(d),b=S=>{t(C1(n,d.path,S))};let y=null;const w=d.type==="json"||d.type==="multiline"||d.type==="string[]";return d.type==="string"&&_!=null?y=v.jsx(ms,{allowClear:!0,value:typeof h=="string"&&h!==""?h:void 0,options:xxe(_),placeholder:d.placeholder,suffixIcon:Lxe,onChange:S=>b(typeof S=="string"?S:void 0)}):d.type==="string"?y=d.sensitive===!0||UGe(d.path[d.path.length-1]??"")?v.jsx(yn.Password,{value:typeof h=="string"?h:"",onChange:x=>b(x.target.value),placeholder:d.placeholder??i("config.editor.secretPlaceholder")}):v.jsx(yn,{value:typeof h=="string"?h:"",onChange:x=>b(x.target.value),placeholder:d.placeholder}):d.type==="multiline"?y=v.jsx(yn.TextArea,{value:typeof h=="string"?h:"",onChange:S=>b(S.target.value),autoSize:{minRows:2},placeholder:d.placeholder}):d.type==="number"?y=v.jsx(E4,{value:typeof h=="number"?h:void 0,onChange:S=>b(typeof S=="number"?S:void 0)}):d.type==="boolean"?y=v.jsx(yu,{checked:!!h,onChange:S=>b(S)}):d.type==="string[]"?y=v.jsx(KN,{value:Array.isArray(h)?h.filter(S=>typeof S=="string"):[],onChange:S=>b(S),t:i}):d.type==="select"?y=v.jsx(ms,{value:typeof h=="string"?h:void 0,options:xxe(_??d.options??[]),suffixIcon:Lxe,onChange:S=>b(S)}):y=v.jsx(Ty,{value:h??{},onChange:S=>b(S)}),v.jsx(bs,{title:m,description:p,icon:vCn(d),layout:w?"stacked":"inline",children:y},d.path.join("."))};return v.jsx("div",{className:"config-view__record-fields",children:e.fields.map(c)})},Z2e=n=>n!=null&&typeof n=="object"&&!Array.isArray(n),GGe={add:"person_add",refresh:"refresh",remove:"delete"},mY={ready:"check_circle",missing:"warning",error:"error"},XGe=n=>{const e=au(n,["accounts"]);return Z2e(e)?e:{}},bCn=(n,e)=>{const t=XGe(n)[e];return Z2e(t)?t:{}},yCn=(n,e,t)=>C1(n,["accounts",e],t),wCn=(n,e)=>{switch(n){case"missing":return{label:e("config.accounts.status.missing"),color:"default",icon:mY.missing};case"error":return{label:e("config.accounts.status.error"),color:"error",icon:mY.error};case"ready":default:return{label:e("config.accounts.status.ready"),color:"success",icon:mY.ready}}},Ece=(n,e)=>e(`config.accounts.actions.${n.key}.label`,{defaultValue:n.label}),YGe=(n,e)=>e(`config.accounts.actions.${n.key}.description`,{defaultValue:n.description??n.label}),wH=n=>(n==null?void 0:n.trim().toLowerCase())??"",SCn=n=>{if(n==null)return;const e=n.trim();if(!e.endsWith("%"))return;const t=Number(e.slice(0,-1));if(Number.isFinite(t))return Math.min(100,Math.max(0,t))},xCn=n=>n>=85?"var(--error-color, #ff4d4f)":n>=60?"var(--warning-color, #faad14)":"var(--success-color, #52c41a)",LCn=(n,e)=>{if(n.isDefault===!0&&e.isDefault!==!0)return-1;if(e.isDefault===!0&&n.isDefault!==!0)return 1;if(n.status!==e.status){if(n.status==="ready")return-1;if(e.status==="ready")return 1}const t=wH(n.title).localeCompare(wH(e.title));return t!==0?t:n.key.localeCompare(e.key)},SH=(n,e)=>{const t=e==null?void 0:e.trim();return t==null||t===""||t===n?n:v.jsxs("div",{className:"adapter-account-manager__tooltip",children:[v.jsx("div",{className:"adapter-account-manager__tooltip-title",children:n}),v.jsx("div",{className:"adapter-account-manager__tooltip-description",children:t})]})},kxe=({color:n,icon:e,label:t,description:i})=>{const s=n==="success"?{color:"var(--success-color, #52c41a)"}:n==="error"?{color:"var(--error-color, #ff4d4f)"}:void 0;return v.jsx(Qe,{title:SH(t,i),children:v.jsx("span",{className:"adapter-account-manager__icon-tag",style:s,"aria-label":t,children:v.jsx("span",{className:"material-symbols-rounded","aria-hidden":"true",children:e})})})},kCn=({actions:n,loadingAction:e,onRunAction:t,t:i})=>n.length===0?null:v.jsx("div",{className:"adapter-account-manager__actions",children:n.map(s=>{const r=Ece(s,i),o=YGe(s,i),a=GGe[s.key];return s.key==="remove"?v.jsx(Cm,{title:i("config.accounts.deleteConfirmTitle",{defaultValue:"Delete the stored snapshot for {{account}}?",account:r}),okText:i("common.confirm"),cancelText:i("common.cancel"),onConfirm:async()=>{await t(s)},children:v.jsx(Qe,{title:SH(r,o),children:v.jsx(qe,{type:"default",size:"small",danger:!0,loading:e===s.key,"aria-label":r,className:"adapter-account-manager__icon-button adapter-account-manager__header-action",icon:v.jsx("span",{className:"material-symbols-rounded",children:a})})})},s.key):v.jsx(Qe,{title:SH(r,o),children:v.jsx(qe,{type:"default",size:"small",loading:e===s.key,"aria-label":r,className:"adapter-account-manager__icon-button adapter-account-manager__header-action",icon:v.jsx("span",{className:"material-symbols-rounded",children:a}),onClick:async()=>{await t(s)}})},s.key)})}),QGe=(n,e,t)=>{const i=new Map;return Object.entries(n).forEach(([s,r])=>{const o=Z2e(r)?r:{},a=typeof o.title=="string"?o.title.trim():"",l=typeof o.description=="string"?o.description.trim():"";i.set(s,{key:s,title:a!==""?a:s,...l!==""?{description:l}:{},status:"missing"})}),e.forEach(s=>{const r=i.get(s.key);i.set(s.key,{...r,...s})}),[...i.values()].map(s=>({...s,isDefault:t!=null&&t!==""?s.key===t:s.isDefault})).sort(LCn)},ECn=({adapterKey:n,accountKey:e,accountItemSchema:t,value:i,onChange:s,t:r})=>{if(t==null||t.fields.length===0)return null;const o={...t,fields:t.fields.map(l=>l.path.length===1&&l.path[0]==="description"?{...l,type:"multiline"}:l)},a=`.ai/.local/adapters/${n}/accounts/${e}/auth.json`;return v.jsxs("div",{className:"adapter-account-manager__editor",children:[v.jsxs("div",{className:"adapter-account-manager__section-title",children:[v.jsx("span",{className:"material-symbols-rounded",children:"tune"}),v.jsx("span",{children:r("config.accounts.settingsTitle",{defaultValue:"Account settings"})})]}),v.jsx(yH,{value:bCn(i,e),schema:o,onChange:l=>s(yCn(i,e,l)),t:r,resolveFieldLabel:(l,c)=>Dy(r,"adapterAccount",l.path,c),resolveFieldDescription:(l,c)=>{const d=bH(r,"adapterAccount",l.path),u=d!==""?d:c;if(l.path.length===1&&l.path[0]==="authFile"){const h=r("config.accounts.authFileDefaultLookup",{defaultValue:"Leave empty to use {{path}}.",path:a});return[u,h].map(f=>f.trim()).filter(f=>f!=="").join(" ")}return u}})]})},ICn=({adapterKey:n,accountKey:e,accountItemSchema:t,value:i,onChange:s,onChanged:r,onRemoved:o,t:a})=>{var y,w;const{message:l}=Vs.useApp(),{data:c,isLoading:d,mutate:u}=Gn(`/api/adapters/${n}/accounts/${e}`,()=>a8e(n,e)),[h,f]=C.useState(),g=c==null?void 0:c.account,m=wCn(g==null?void 0:g.status,a),p=((g==null?void 0:g.actions)??[]).filter(S=>S.key!=="refresh"),_=((w=(y=g==null?void 0:g.quota)==null?void 0:y.metrics)==null?void 0:w.filter(S=>typeof S.value=="string"?S.value.trim()!=="":S.value!=null))??[],b=async S=>{f(S.key);try{const x=await LO(n,{action:S.key,account:e,refresh:S.key==="refresh"});if(await r(),S.key==="remove"){l.success(x.message??a("config.accounts.actionSuccess.remove")),o();return}if(x.account!=null)await u({account:x.account},{revalidate:!1});else{const L=await a8e(n,e,{refresh:!0});await u(L,{revalidate:!1})}l.success(x.message??a(`config.accounts.actionSuccess.${S.key}`))}catch(x){l.error(Ii(x,a(`config.accounts.actionFailed.${S.key}`)))}finally{f(void 0)}};return v.jsxs("div",{className:"adapter-account-manager__detail",children:[d&&v.jsx("div",{className:"adapter-account-manager__state",children:v.jsx(el,{size:"small"})}),!d&&g==null&&v.jsx(jn,{image:null,description:a("config.accounts.detailMissing")}),g!=null&&v.jsxs("div",{className:"adapter-account-manager__detail-body",children:[v.jsx("div",{className:"adapter-account-manager__hero",children:v.jsx("div",{className:"adapter-account-manager__hero-body",children:v.jsxs("div",{className:"adapter-account-manager__hero-title-row",children:[v.jsx("div",{className:"adapter-account-manager__hero-title",children:g.title}),v.jsxs("div",{className:"adapter-account-manager__hero-meta",children:[v.jsxs("div",{className:"adapter-account-manager__hero-badges",children:[v.jsx(kxe,{color:m.color,icon:m.icon,label:m.label}),g.isDefault===!0&&v.jsx(kxe,{icon:"star",label:a("config.accounts.default")})]}),p.length>0&&v.jsx(kCn,{actions:p,loadingAction:h,onRunAction:b,t:a})]})]})})}),_.length>0&&v.jsxs("div",{className:"adapter-account-manager__section",children:[v.jsxs("div",{className:"adapter-account-manager__section-title",children:[v.jsx("span",{className:"material-symbols-rounded",children:"query_stats"}),v.jsx("span",{children:a("config.accounts.quotaTitle",{defaultValue:"Quota"})})]}),v.jsx("div",{className:"adapter-account-manager__metrics",children:_.map(S=>v.jsxs("div",{className:"adapter-account-manager__metric",children:[v.jsx("div",{className:"adapter-account-manager__metric-label",children:S.label}),v.jsxs("div",{className:"adapter-account-manager__metric-value",children:[S.value??"-",(()=>{const x=SCn(S.value);return x==null?null:v.jsx("span",{className:"adapter-account-manager__metric-ring","aria-hidden":"true",style:{background:`conic-gradient(${xCn(x)} ${x}%, color-mix(in srgb, var(--border-color) 72%, transparent) 0)`},children:v.jsx("span",{className:"adapter-account-manager__metric-ring-inner"})})})()]}),S.description!=null&&S.description.trim()!==""&&v.jsx("div",{className:"adapter-account-manager__metric-description",children:S.description})]},S.id))})]}),v.jsx(ECn,{adapterKey:n,accountKey:e,accountItemSchema:t,value:i,onChange:s,t:a})]})]})},MCn=({accounts:n,onOpenAccounts:e,t})=>{const i=n.filter(r=>r.status!=="missing"&&r.status!=="error").length,s=n.find(r=>r.isDefault===!0);return v.jsx("div",{className:"adapter-account-manager__overview",children:v.jsxs("button",{type:"button",className:"adapter-account-manager__overview-card config-view__field-row",onClick:e,children:[v.jsxs("div",{className:"config-view__field-meta",children:[v.jsx("span",{className:"material-symbols-rounded config-view__field-icon",children:"manage_accounts"}),v.jsxs("div",{className:"config-view__field-text",children:[v.jsx("div",{className:"config-view__field-title",children:t("config.accounts.title")}),v.jsxs("div",{className:"config-view__field-desc adapter-account-manager__overview-meta",children:[v.jsx("span",{children:t("config.accounts.count",{count:n.length})}),v.jsx("span",{children:t("config.accounts.readyCount",{count:i})}),s!=null&&v.jsx("span",{children:t("config.accounts.defaultHint",{account:s.title})})]})]})]}),v.jsx("div",{className:"config-view__field-control adapter-account-manager__overview-control",children:v.jsx("span",{className:"material-symbols-rounded adapter-account-manager__overview-arrow",children:"chevron_right"})})]})})},NCn=({accounts:n,actions:e,loadingAction:t,onOpenAccount:i,onRunAction:s,currentDefaultAccount:r,deletingAccountKey:o,onToggleDefaultAccount:a,onDeleteAccount:l,t:c})=>{const[d,u]=C.useState(""),h=wH(d),f=e.find(m=>m.key==="add"),g=C.useMemo(()=>h===""?n:n.filter(m=>{var _;return[m.title,m.key,m.description,(_=m.quota)==null?void 0:_.summary].some(b=>wH(b).includes(h))}),[n,h]);return v.jsxs("div",{className:"adapter-account-manager",children:[v.jsxs("div",{className:"adapter-account-manager__header",children:[v.jsx(yn,{allowClear:!0,value:d,onChange:m=>u(m.target.value),className:"adapter-account-manager__search",placeholder:c("config.accounts.searchPlaceholder",{defaultValue:"Search accounts"}),prefix:v.jsx("span",{className:"material-symbols-rounded",children:"search"})}),f!=null&&v.jsx(Qe,{title:SH(Ece(f,c),YGe(f,c)),children:v.jsx(qe,{size:"small",type:"default",loading:t===f.key,"aria-label":Ece(f,c),className:"adapter-account-manager__icon-button adapter-account-manager__header-action",icon:v.jsx("span",{className:"material-symbols-rounded",children:GGe[f.key]}),onClick:()=>s(f)})})]}),g.length===0&&v.jsx(jn,{image:null,description:n.length===0?c("config.accounts.empty"):c("config.accounts.searchEmpty",{defaultValue:"No matching accounts"})}),g.length>0&&v.jsx("div",{className:"adapter-account-manager__list",children:g.map(m=>{var b;const p=r===m.key||m.isDefault===!0,_=m.status!=="missing";return v.jsxs("div",{className:"adapter-account-manager__item",children:[v.jsx("button",{type:"button",className:"adapter-account-manager__item-trigger",onClick:()=>i(m.key),children:v.jsxs("div",{className:"adapter-account-manager__item-main",children:[v.jsx("div",{className:"adapter-account-manager__item-title",children:m.title}),((b=m.quota)==null?void 0:b.summary)!=null&&m.quota.summary!==""&&v.jsxs("div",{className:"adapter-account-manager__item-description",children:[v.jsx("span",{className:"material-symbols-rounded",children:"speed"}),v.jsx("span",{children:m.quota.summary})]})]})}),v.jsxs("div",{className:"adapter-account-manager__item-actions",children:[v.jsx(Qe,{title:p?c("config.accounts.rowActions.clearDefault",{defaultValue:"Clear default account"}):c("config.accounts.rowActions.setDefault",{defaultValue:"Set as default account"}),children:v.jsx(qe,{type:"text",size:"small","aria-label":p?c("config.accounts.rowActions.clearDefault",{defaultValue:"Clear default account"}):c("config.accounts.rowActions.setDefault",{defaultValue:"Set as default account"}),className:`adapter-account-manager__row-action ${p?"adapter-account-manager__row-action--active":""}`,icon:v.jsx("span",{className:"material-symbols-rounded",children:"star"}),onClick:y=>{y.stopPropagation(),a(m.key)}})}),_&&v.jsx(Cm,{title:c("config.accounts.deleteConfirmTitle",{defaultValue:"Delete the stored snapshot for {{account}}?",account:m.title}),okText:c("common.confirm"),cancelText:c("common.cancel"),onConfirm:async y=>{var w;(w=y==null?void 0:y.stopPropagation)==null||w.call(y),await l(m.key)},children:v.jsx(qe,{type:"text",size:"small",danger:!0,loading:o===m.key,"aria-label":c("config.accounts.rowActions.delete",{defaultValue:"Delete account snapshot"}),className:"adapter-account-manager__row-action",icon:v.jsx("span",{className:"material-symbols-rounded",children:"delete"}),onClick:y=>{y.stopPropagation()}})})]})]},m.key)})})]})},Exe=({adapterKey:n,value:e,accountItemSchema:t,nestedPath:i=[],onChange:s,onOpenNestedPath:r,t:o})=>{const{message:a}=Vs.useApp(),l=typeof e.defaultAccount=="string"&&e.defaultAccount.trim()!==""?e.defaultAccount.trim():void 0,{data:c,isLoading:d,mutate:u}=Gn(`/api/adapters/${n}/accounts`,()=>G3e(n)),[h,f]=C.useState(),[g,m]=C.useState(),p=C.useMemo(()=>XGe(e),[e]),_=C.useMemo(()=>QGe(p,(c==null?void 0:c.accounts)??[],l),[p,l,c==null?void 0:c.accounts]),b=(c==null?void 0:c.actions)??[],y=i[0]==="accounts",w=y?i[1]:void 0,S=async()=>{await u()},x=I=>{const M={...e};l===I?delete M.defaultAccount:M.defaultAccount=I,s(M)},L=async I=>{if(I.key==="add"){f(I.key);try{const M=await LO(n,{action:"add"});await S(),a.success(M.message??o("config.accounts.actionSuccess.add")),M.accountKey!=null&&M.accountKey.trim()!==""?r(["accounts",M.accountKey]):r(["accounts"])}catch(M){a.error(Ii(M,o("config.accounts.actionFailed.add")))}finally{f(void 0)}}},E=async I=>{m(I);try{const M=await LO(n,{action:"remove",account:I,refresh:!0});await S(),a.success(M.message??o("config.accounts.actionSuccess.remove"))}catch(M){a.error(Ii(M,o("config.accounts.actionFailed.remove")))}finally{m(void 0)}};return d&&_.length===0?v.jsx("div",{className:"adapter-account-manager__state",children:v.jsx(el,{size:"small"})}):y&&w!=null&&w!==""?v.jsx(ICn,{adapterKey:n,accountKey:w,accountItemSchema:t,value:e,onChange:s,onChanged:S,onRemoved:()=>r(["accounts"]),t:o}):y?v.jsx(NCn,{accounts:_,actions:b,loadingAction:h,onOpenAccount:I=>r(["accounts",I]),onRunAction:L,currentDefaultAccount:l,deletingAccountKey:g,onToggleDefaultAccount:x,onDeleteAccount:E,t:o}):v.jsx(MCn,{accounts:_,onOpenAccounts:()=>r(["accounts"]),t:o})},DCn=({value:n,displayValue:e,onChange:t,placeholder:i,normalizeShortcut:s,isMac:r,t:o})=>{const a=(e??n).trim(),l=a===""?"":nhe(a,r);return v.jsxs("div",{className:"config-shortcut-input",children:[v.jsx(yn,{value:l,placeholder:i,readOnly:!0,onKeyDown:c=>{if(c.key==="Backspace"||c.key==="Delete"){c.preventDefault(),t("");return}const d=ebt(c);if(d==null)return;const u=(s==null?void 0:s(d))??d;u!=null&&(c.preventDefault(),t(u))}}),v.jsx(Qe,{title:o("config.editor.clearShortcut"),children:v.jsx(qe,{size:"small",type:"text",className:"config-view__icon-button config-view__icon-button--compact","aria-label":o("config.editor.clearShortcut"),icon:v.jsx("span",{className:"material-symbols-rounded",children:"close"}),onClick:()=>t("")})})]})},TCn=({index:n,itemCount:e,onMove:t,onRemove:i,t:s})=>v.jsxs("div",{className:"config-view__record-actions",children:[t!=null&&v.jsxs(v.Fragment,{children:[v.jsx(Qe,{title:s("config.editor.moveUp"),children:v.jsx(qe,{size:"small",type:"text",className:"config-view__icon-button config-view__icon-button--compact","aria-label":s("config.editor.moveUp"),icon:v.jsx("span",{className:"material-symbols-rounded",children:"keyboard_arrow_up"}),disabled:n===0,onClick:()=>t(-1)})}),v.jsx(Qe,{title:s("config.editor.moveDown"),children:v.jsx(qe,{size:"small",type:"text",className:"config-view__icon-button config-view__icon-button--compact","aria-label":s("config.editor.moveDown"),icon:v.jsx("span",{className:"material-symbols-rounded",children:"keyboard_arrow_down"}),disabled:n===e-1,onClick:()=>t(1)})})]}),v.jsx(Cm,{title:s("config.editor.removeItemConfirmTitle"),okText:s("common.confirm"),cancelText:s("common.cancel"),onConfirm:i,children:v.jsx(Qe,{title:s("config.editor.remove"),children:v.jsx(qe,{size:"small",type:"text",danger:!0,className:"config-view__icon-button config-view__icon-button--compact","aria-label":s("config.editor.remove"),icon:v.jsx("span",{className:"material-symbols-rounded",children:"delete"})})})})]}),RCn={general:{base:{labelKey:"config.sectionGroups.base",collapsible:!0,defaultExpanded:!0},models:{labelKey:"config.sectionGroups.models",collapsible:!0,defaultExpanded:!0},advanced:{labelKey:"config.sectionGroups.advanced",collapsible:!0,defaultExpanded:!1},permissions:{labelKey:"config.sectionGroups.permissions",collapsible:!0,defaultExpanded:!0},env:{labelKey:"config.sectionGroups.env",collapsible:!0,defaultExpanded:!1},items:{labelKey:"config.fields.general.notifications.label",collapsible:!0,defaultExpanded:!0}},conversation:{defaults:{labelKey:"config.sectionGroups.base",collapsible:!0,defaultExpanded:!0},presets:{labelKey:"config.fields.conversation.startupPresets.label",collapsible:!0,defaultExpanded:!0},actions:{labelKey:"config.fields.conversation.builtinActions.label",collapsible:!0,defaultExpanded:!0}}},PCn={general:["base","models","permissions","env","items","advanced","default"],conversation:["defaults","presets","actions","default"]},ACn=[{path:["title"],type:"string",defaultValue:"",icon:"title",labelKey:"config.fields.general.notifications.events.item.title.label",descriptionKey:"config.fields.general.notifications.events.item.title.desc"},{path:["description"],type:"multiline",defaultValue:"",icon:"notes",labelKey:"config.fields.general.notifications.events.item.description.label",descriptionKey:"config.fields.general.notifications.events.item.description.desc"},{path:["sound"],type:"string",defaultValue:"",icon:"volume_up",labelKey:"config.fields.general.notifications.events.item.sound.label",descriptionKey:"config.fields.general.notifications.events.item.sound.desc"}],OCn=[{path:["title"],type:"string",defaultValue:"",icon:"title",labelKey:"config.fields.modelServices.item.title.label",descriptionKey:"config.fields.modelServices.item.title.desc"},{path:["description"],type:"multiline",defaultValue:"",icon:"notes",labelKey:"config.fields.modelServices.item.description.label",descriptionKey:"config.fields.modelServices.item.description.desc"},{path:["apiBaseUrl"],type:"string",defaultValue:"",icon:"link",labelKey:"config.fields.modelServices.item.apiBaseUrl.label",descriptionKey:"config.fields.modelServices.item.apiBaseUrl.desc"},{path:["apiKey"],type:"string",defaultValue:"",icon:"key",sensitive:!0,labelKey:"config.fields.modelServices.item.apiKey.label",descriptionKey:"config.fields.modelServices.item.apiKey.desc"},{path:["models"],type:"string[]",defaultValue:[],icon:"view_list",labelKey:"config.fields.modelServices.item.models.label",descriptionKey:"config.fields.modelServices.item.models.desc"},{path:["timeoutMs"],type:"number",defaultValue:void 0,icon:"timer",labelKey:"config.fields.modelServices.item.timeoutMs.label",descriptionKey:"config.fields.modelServices.item.timeoutMs.desc"},{path:["maxOutputTokens"],type:"number",defaultValue:void 0,icon:"numbers",labelKey:"config.fields.modelServices.item.maxOutputTokens.label",descriptionKey:"config.fields.modelServices.item.maxOutputTokens.desc"},{path:["extra"],type:"json",defaultValue:{},icon:"account_tree",labelKey:"config.fields.modelServices.item.extra.label",descriptionKey:"config.fields.modelServices.item.extra.desc"}],FCn=[{value:"default",label:"config.options.conversationStarterMode.default"},{value:"workspace",label:"config.options.conversationStarterMode.workspace"},{value:"agent",label:"config.options.conversationStarterMode.agent"},{value:"entity",label:"config.options.conversationStarterMode.entity"},{value:"spec",label:"config.options.conversationStarterMode.spec"}],BCn=[{value:"default",label:"config.options.effort.default"},{value:"low",label:"config.options.effort.low"},{value:"medium",label:"config.options.effort.medium"},{value:"high",label:"config.options.effort.high"},{value:"max",label:"config.options.effort.max"}],$Cn=[{value:"default",label:"config.options.permissionMode.default"},{value:"acceptEdits",label:"config.options.permissionMode.acceptEdits"},{value:"plan",label:"config.options.permissionMode.plan"},{value:"dontAsk",label:"config.options.permissionMode.dontAsk"},{value:"bypassPermissions",label:"config.options.permissionMode.bypassPermissions"}],HCn=[{value:"local",label:"config.options.branchKind.local"},{value:"remote",label:"config.options.branchKind.remote"}],VCn=[{value:"checkout",label:"config.options.branchMode.checkout"},{value:"create",label:"config.options.branchMode.create"}],Ixe=[{path:["title"],type:"string",defaultValue:"",icon:"title",labelKey:"config.fields.conversation.starterItem.title.label",descriptionKey:"config.fields.conversation.starterItem.title.desc"},{path:["description"],type:"multiline",defaultValue:"",icon:"notes",labelKey:"config.fields.conversation.starterItem.description.label",descriptionKey:"config.fields.conversation.starterItem.description.desc"},{path:["icon"],type:"string",defaultValue:"",icon:"palette",labelKey:"config.fields.conversation.starterItem.icon.label",descriptionKey:"config.fields.conversation.starterItem.icon.desc"},{path:["mode"],type:"select",defaultValue:"default",icon:"category",options:FCn,labelKey:"config.fields.conversation.starterItem.mode.label",descriptionKey:"config.fields.conversation.starterItem.mode.desc"},{path:["target"],type:"string",defaultValue:"",icon:"label",labelKey:"config.fields.conversation.starterItem.target.label",descriptionKey:"config.fields.conversation.starterItem.target.desc"},{path:["targetLabel"],type:"string",defaultValue:"",icon:"title",labelKey:"config.fields.conversation.starterItem.targetLabel.label",descriptionKey:"config.fields.conversation.starterItem.targetLabel.desc"},{path:["targetDescription"],type:"multiline",defaultValue:"",icon:"info",labelKey:"config.fields.conversation.starterItem.targetDescription.label",descriptionKey:"config.fields.conversation.starterItem.targetDescription.desc"},{path:["model"],type:"string",defaultValue:"",icon:"model_training",labelKey:"config.fields.conversation.starterItem.model.label",descriptionKey:"config.fields.conversation.starterItem.model.desc"},{path:["adapter"],type:"string",defaultValue:"",icon:"settings_input_component",labelKey:"config.fields.conversation.starterItem.adapter.label",descriptionKey:"config.fields.conversation.starterItem.adapter.desc"},{path:["account"],type:"string",defaultValue:"",icon:"person",labelKey:"config.fields.conversation.starterItem.account.label",descriptionKey:"config.fields.conversation.starterItem.account.desc"},{path:["effort"],type:"select",defaultValue:"default",icon:"psychology",options:BCn,labelKey:"config.fields.conversation.starterItem.effort.label",descriptionKey:"config.fields.conversation.starterItem.effort.desc"},{path:["permissionMode"],type:"select",defaultValue:"default",icon:"policy",options:$Cn,labelKey:"config.fields.conversation.starterItem.permissionMode.label",descriptionKey:"config.fields.conversation.starterItem.permissionMode.desc"},{path:["worktree","create"],type:"boolean",defaultValue:!1,icon:"account_tree",labelKey:"config.fields.conversation.starterItem.worktreeCreate.label",descriptionKey:"config.fields.conversation.starterItem.worktreeCreate.desc"},{path:["worktree","environment"],type:"string",defaultValue:"",icon:"deployed_code",labelKey:"config.fields.conversation.starterItem.worktreeEnvironment.label",descriptionKey:"config.fields.conversation.starterItem.worktreeEnvironment.desc"},{path:["worktree","branch","name"],type:"string",defaultValue:"",icon:"call_split",labelKey:"config.fields.conversation.starterItem.branchName.label",descriptionKey:"config.fields.conversation.starterItem.branchName.desc"},{path:["worktree","branch","kind"],type:"select",defaultValue:"",icon:"fork_right",options:HCn,labelKey:"config.fields.conversation.starterItem.branchKind.label",descriptionKey:"config.fields.conversation.starterItem.branchKind.desc"},{path:["worktree","branch","mode"],type:"select",defaultValue:"",icon:"alt_route",options:VCn,labelKey:"config.fields.conversation.starterItem.branchMode.label",descriptionKey:"config.fields.conversation.starterItem.branchMode.desc"},{path:["prompt"],type:"multiline",defaultValue:"",icon:"chat",labelKey:"config.fields.conversation.starterItem.prompt.label",descriptionKey:"config.fields.conversation.starterItem.prompt.desc"},{path:["files"],type:"string[]",defaultValue:[],icon:"draft",labelKey:"config.fields.conversation.starterItem.files.label",descriptionKey:"config.fields.conversation.starterItem.files.desc"},{path:["rules"],type:"string[]",defaultValue:[],icon:"gavel",labelKey:"config.fields.conversation.starterItem.rules.label",descriptionKey:"config.fields.conversation.starterItem.rules.desc"},{path:["skills"],type:"string[]",defaultValue:[],icon:"school",labelKey:"config.fields.conversation.starterItem.skills.label",descriptionKey:"config.fields.conversation.starterItem.skills.desc"}],jCn=[{path:["id"],type:"string",defaultValue:"",icon:"extension"},{path:["enabled"],type:"boolean",defaultValue:!0,icon:"toggle_on",labelKey:"config.fields.plugins.enabled.label",descriptionKey:"config.fields.plugins.enabled.desc"},{path:["scope"],type:"string",defaultValue:"",icon:"label"},{path:["options"],type:"json",defaultValue:{},icon:"tune"},{path:["children"],type:"json",defaultValue:[],icon:"device_hub"}],WCn=[{path:["type"],type:"string",defaultValue:"claude-code",icon:"category"},{path:["enabled"],type:"boolean",defaultValue:!0,icon:"toggle_on",labelKey:"config.fields.plugins.enabled.label",descriptionKey:"config.fields.plugins.enabled.desc"},{path:["syncOnRun"],type:"boolean",defaultValue:!1,icon:"sync"},{path:["plugins"],type:"json",defaultValue:{},icon:"extension"},{path:["options"],type:"json",defaultValue:{},icon:"store"}],zCn=["completed","failed","terminated","waiting_input"],Mxe=(n,e)=>{const t=`config.fields.general.notifications.events.${e}.label`,i=n(t);return i===t?e:i},UCn=(n,e)=>{const t=`config.fields.general.notifications.events.${e}.desc`,i=n(t,{defaultValue:""});return i===t?"":i},JGe={general:[{path:["baseDir"],type:"string",defaultValue:".ai",icon:"folder",group:"base"},{path:["effort"],type:"select",defaultValue:"",icon:"psychology",group:"models",options:[{value:"low",label:"config.options.effort.low"},{value:"medium",label:"config.options.effort.medium"},{value:"high",label:"config.options.effort.high"},{value:"max",label:"config.options.effort.max"}]},{path:["defaultAdapter"],type:"select",defaultValue:"",icon:"settings_input_component",group:"models"},{path:["defaultModelService"],type:"select",defaultValue:"",icon:"hub",group:"models"},{path:["defaultModel"],type:"select",defaultValue:"",icon:"model_training",group:"models"},{path:["recommendedModels"],type:"detailCollection",defaultValue:[],icon:"stars",group:"models",detailCollection:{collectionKind:"list",detailKind:"recommendedModels",createItem:()=>({model:"",placement:"modelSelector"}),getItemTitle:(n,e,t,{t:i})=>{const s=typeof n.title=="string"?n.title.trim():"";if(s!=="")return s;const r=typeof n.model=="string"?n.model.trim():"";return r!==""?r:`${i("config.fields.general.recommendedModels.label")} #${t+1}`},getItemSubtitle:(n,e,t,{t:i})=>{const s=[],r=typeof n.service=="string"?n.service.trim():"",o=typeof n.model=="string"?n.model.trim():"",a=typeof n.placement=="string"?i(`config.options.recommendedModels.${n.placement}`,{defaultValue:n.placement}):"";return r!==""&&s.push(r),o!==""&&s.push(o),a!==""&&s.push(a),s.length>0?s.join(" · "):void 0},getItemDescription:n=>{const e=typeof n.description=="string"?n.description.trim():"";return e!==""?e:void 0},getBreadcrumbLabel:(n,e,t,i)=>typeof n.title=="string"&&n.title.trim()!==""?n.title.trim():typeof n.model=="string"&&n.model.trim()!==""?n.model.trim():`${i.t("config.fields.general.recommendedModels.label")} #${t+1}`}},{path:["interfaceLanguage"],type:"select",defaultValue:"",icon:"language",group:"base",options:[{value:"zh",label:"config.options.language.zh"},{value:"en",label:"config.options.language.en"}]},{path:["modelLanguage"],type:"select",defaultValue:"",icon:"translate",group:"base",options:[{value:"zh",label:"config.options.language.zh"},{value:"en",label:"config.options.language.en"}]},{path:["announcements"],type:"string[]",defaultValue:[],icon:"campaign",group:"advanced"},{path:["permissions","allow"],type:"string[]",defaultValue:[],icon:"check_circle",group:"permissions"},{path:["permissions","deny"],type:"string[]",defaultValue:[],icon:"block",group:"permissions"},{path:["permissions","ask"],type:"string[]",defaultValue:[],icon:"help",group:"permissions"},{path:["env"],type:"record",recordKind:"keyValue",defaultValue:{},icon:"terminal",group:"env"},{path:["notifications","disabled"],type:"boolean",defaultValue:!1,icon:"notifications",group:"items"},{path:["notifications","volume"],type:"number",defaultValue:100,icon:"volume_down",group:"items"},{path:["notifications","events"],type:"detailCollection",defaultValue:{},icon:"notifications_active",group:"items",labelKey:"config.fields.general.notifications.events.label",descriptionKey:"config.fields.general.notifications.events.desc",detailCollection:{collectionKind:"record",itemKeys:[...zCn],createItem:()=>({}),itemFields:ACn,summaryControls:[{kind:"boolean",path:["disabled"],checkedValue:!1,labelKey:"config.fields.general.notifications.events.item.enabled.label"}],getItemTitle:(n,e,t,{t:i})=>Mxe(i,e),getItemSubtitle:n=>{const e=[],t=typeof n.title=="string"?n.title.trim():"",i=typeof n.sound=="string"?n.sound.trim():"";return t!==""&&e.push(t),i!==""&&e.push(i),e.length>0?e.join(" · "):void 0},getItemDescription:(n,e,t,{t:i})=>UCn(i,e),getBreadcrumbLabel:(n,e,t,{t:i})=>Mxe(i,e)}}],conversation:[{path:["style"],type:"select",defaultValue:"friendly",icon:"forum",group:"defaults",options:[{value:"friendly",label:"config.options.conversation.friendly"},{value:"programmatic",label:"config.options.conversation.programmatic"}]},{path:["createSessionWorktree"],type:"boolean",defaultValue:!1,icon:"account_tree",group:"defaults"},{path:["worktreeEnvironment"],type:"select",defaultValue:"",icon:"deployed_code",group:"defaults"},{path:["customInstructions"],type:"multiline",defaultValue:"",icon:"description",group:"defaults"},{path:["startupPresets"],type:"detailCollection",defaultValue:[],icon:"bolt",group:"presets",labelKey:"config.fields.conversation.startupPresets.label",descriptionKey:"config.fields.conversation.startupPresets.desc",detailCollection:{collectionKind:"list",createItem:()=>({title:"Untitled preset",mode:"default",prompt:"",files:[],rules:[],skills:[]}),itemFields:Ixe,getItemTitle:(n,e,t,{t:i})=>{const s=typeof n.title=="string"?n.title.trim():"";return s!==""?s:`${i("config.fields.conversation.startupPresets.label")} #${t+1}`},getItemSubtitle:(n,e,t,{t:i})=>{const s=[],r=typeof n.mode=="string"?n.mode:"default",o=typeof n.target=="string"?n.target.trim():"",a=typeof n.model=="string"?n.model.trim():"",l=typeof n.effort=="string"?n.effort:"",c=n.worktree!=null&&typeof n.worktree=="object"&&!Array.isArray(n.worktree)&&n.worktree.create===!0;return s.push(i(`config.options.conversationStarterMode.${r}`,{defaultValue:r})),o!==""&&s.push(o),a!==""&&s.push(a),l!==""&&s.push(i(`config.options.effort.${l}`,{defaultValue:l})),c&&s.push(i("config.fields.conversation.starterItem.worktreeEnabledBadge")),s.join(" · ")},getItemDescription:n=>{const e=typeof n.description=="string"?n.description.trim():"";return e!==""?e:void 0},getBreadcrumbLabel:(n,e,t,{t:i})=>{const s=typeof n.title=="string"?n.title.trim():"";return s!==""?s:`${i("config.fields.conversation.startupPresets.label")} #${t+1}`}}},{path:["builtinActions"],type:"detailCollection",defaultValue:[],icon:"construction",group:"actions",labelKey:"config.fields.conversation.builtinActions.label",descriptionKey:"config.fields.conversation.builtinActions.desc",detailCollection:{collectionKind:"list",createItem:()=>({title:"Untitled action",mode:"default",prompt:"",files:[],rules:[],skills:[]}),itemFields:Ixe,getItemTitle:(n,e,t,{t:i})=>{const s=typeof n.title=="string"?n.title.trim():"";return s!==""?s:`${i("config.fields.conversation.builtinActions.label")} #${t+1}`},getItemSubtitle:(n,e,t,{t:i})=>{const s=[],r=typeof n.mode=="string"?n.mode:"default",o=typeof n.target=="string"?n.target.trim():"",a=typeof n.prompt=="string"?n.prompt.trim():"";return s.push(i(`config.options.conversationStarterMode.${r}`,{defaultValue:r})),o!==""&&s.push(o),a!==""&&s.push(a.slice(0,24)),s.join(" · ")},getItemDescription:n=>{const e=typeof n.description=="string"?n.description.trim():"";return e!==""?e:void 0},getBreadcrumbLabel:(n,e,t,{t:i})=>{const s=typeof n.title=="string"?n.title.trim():"";return s!==""?s:`${i("config.fields.conversation.builtinActions.label")} #${t+1}`}}}],models:[{path:[],type:"record",recordKind:"json",defaultValue:{},icon:"tune"}],modelServices:[{path:[],type:"detailCollection",defaultValue:{},icon:"hub",labelKey:"config.fields.modelServices.items.label",descriptionKey:"config.fields.modelServices.items.desc",detailCollection:{collectionKind:"recordMap",keyPlaceholderKey:"config.editor.newModelServiceName",createItem:()=>({title:"",description:"",apiBaseUrl:"",apiKey:"",models:[],timeoutMs:void 0,maxOutputTokens:void 0,extra:{}}),itemFields:OCn,getItemTitle:(n,e)=>{const t=typeof n.title=="string"?n.title.trim():"";return t!==""?t:e},getItemSubtitle:(n,e)=>(typeof n.title=="string"?n.title.trim():"")!==""?e:void 0,getItemDescription:n=>{const e=typeof n.description=="string"?n.description.trim():"";return e!==""?e:void 0},getBreadcrumbLabel:(n,e)=>{const t=typeof n.title=="string"?n.title.trim():"";return t!==""?t:e}}}],channels:[{path:[],type:"detailCollection",defaultValue:{},icon:"campaign",labelKey:"config.sections.channels",detailCollection:{collectionKind:"recordMap",keyPlaceholderKey:"config.editor.newChannelName",getItemTitle:(n,e)=>e,getItemSubtitle:(n,e,t,{t:i})=>{const s=typeof n.type=="string"?n.type:"";return s===""?void 0:i(`config.options.channels.${s}`,{defaultValue:s})},getItemDescription:n=>{const e=typeof n.description=="string"?n.description.trim():"";return e!==""?e:void 0},getBreadcrumbLabel:(n,e)=>e}}],adapters:[{path:[],type:"detailCollection",defaultValue:{},icon:"settings_input_component",labelKey:"config.sections.adapters",detailCollection:{collectionKind:"recordMap",keyPlaceholderKey:"config.editor.newAdapterName",getItemTitle:(n,e)=>e,getBreadcrumbLabel:(n,e)=>e}}],plugins:[{path:["plugins"],type:"detailCollection",defaultValue:[],icon:"extension",labelKey:"config.fields.plugins.items.label",descriptionKey:"config.fields.plugins.items.desc",detailCollection:{collectionKind:"list",createItem:()=>({id:"",enabled:!0,scope:"",options:{},children:[]}),getMergeKey:n=>{const e=typeof n.id=="string"?n.id.trim():"";if(e==="")return;const t=typeof n.scope=="string"?n.scope.trim():"";return`${e}::${t}`},itemFields:jCn,summaryControls:[{kind:"boolean",path:["enabled"],checkedValue:!0}],getItemTitle:(n,e,t)=>{const i=typeof n.id=="string"?n.id.trim():"";return i!==""?i:`Plugin #${t+1}`},getItemSubtitle:n=>{const e=typeof n.scope=="string"?n.scope.trim():"";return e!==""?e:void 0},getBreadcrumbLabel:(n,e,t)=>{const i=typeof n.id=="string"?n.id.trim():"";return i!==""?i:`Plugin #${t+1}`}}},{path:["marketplaces"],type:"detailCollection",defaultValue:{},icon:"store",labelKey:"config.fields.plugins.marketplaces.label",descriptionKey:"config.fields.plugins.marketplaces.desc",detailCollection:{collectionKind:"recordMap",keyPlaceholderKey:"config.editor.newMarketplaceName",createItem:()=>({type:"claude-code",enabled:!0,syncOnRun:!1,plugins:{},options:{}}),itemFields:WCn,summaryControls:[{kind:"boolean",path:["enabled"],checkedValue:!0}],getItemTitle:(n,e)=>e,getItemSubtitle:n=>{const e=typeof n.type=="string"?n.type.trim():"";return e!==""?e:void 0},getBreadcrumbLabel:(n,e)=>e}}],mcp:[{path:["defaultIncludeMcpServers"],type:"string[]",defaultValue:[],group:"base",icon:"playlist_add"},{path:["defaultExcludeMcpServers"],type:"string[]",defaultValue:[],group:"base",icon:"playlist_remove"},{path:["noDefaultVibeForgeMcpServer"],type:"boolean",defaultValue:!1,group:"base",icon:"block"},{path:["mcpServers"],type:"detailCollection",defaultValue:{},icon:"account_tree",labelKey:"config.fields.mcp.mcpServers.label",descriptionKey:"config.fields.mcp.mcpServers.desc",detailCollection:{collectionKind:"recordMap",detailKind:"mcpServer",keyPlaceholderKey:"config.editor.newMcpServerName",createItem:()=>({enabled:!0,command:"",args:[]}),summaryControls:[{kind:"boolean",path:["enabled"],checkedValue:!0}],getItemTitle:(n,e)=>e,getItemSubtitle:(n,e,t,{t:i})=>{const s=typeof n.type=="string"&&n.type.trim()!==""?n.type.trim():"command";return i(`config.options.mcp.${s}`,{defaultValue:s})},getBreadcrumbLabel:(n,e)=>e}}],shortcuts:[{path:["newSession"],type:"shortcut",defaultValue:"",icon:"add_comment"},{path:["openConfig"],type:"shortcut",defaultValue:"",icon:"settings"},{path:["sendMessage"],type:"shortcut",shortcutKind:"sendMessage",defaultValue:"",icon:"send"},{path:["clearInput"],type:"shortcut",defaultValue:"",icon:"clear"},{path:["switchModel"],type:"shortcut",defaultValue:"",icon:"model_training"},{path:["switchEffort"],type:"shortcut",defaultValue:"",icon:"psychology"},{path:["switchPermissionMode"],type:"shortcut",defaultValue:"",icon:"lock"}],experiments:[{path:["agentRoom"],type:"boolean",defaultValue:!1,icon:"groups",group:"base",labelKey:"config.fields.experiments.agentRoom.label",descriptionKey:"config.fields.experiments.agentRoom.desc"}]},B3=n=>n!=null&&typeof n=="object"&&!Array.isArray(n),KCn=(n,e)=>n.length===e.length&&n.every((t,i)=>t===e[i]),ER=(n,e)=>JSON.stringify(n)===JSON.stringify(e),eXe=(n,e)=>e??JGe[n]??[],Ice=({field:n,value:e,resolvedValue:t})=>{const i=n.detailCollection;if(n.type!=="detailCollection"||i==null)return[];if(i.collectionKind==="list"){const o=Array.isArray(e)?e.filter(B3):[],a=Array.isArray(t)?t.filter(B3):o,l=i.getMergeKey;if(l!=null){const h=new Map;o.forEach((m,p)=>{const _=l(m);if(_==null||_==="")return;const b=h.get(_)??[];b.push(p),h.set(_,b)});const f=new Set,g=a.map((m,p)=>{var w;const _=l(m),b=_!=null?(w=h.get(_))==null?void 0:w.shift():void 0;if(b==null)return{key:String(p),item:m,index:p,resolvedIndex:p,source:"inherited",resolvedItem:m,hasResolvedOverlay:!1};const y=o[b];return f.add(b),{key:String(p),item:y,index:p,localIndex:b,resolvedIndex:p,source:"local",localItem:y,resolvedItem:m,hasResolvedOverlay:!ER(y,m)}});return o.forEach((m,p)=>{if(f.has(p))return;const _=g.length;g.push({key:String(_),item:m,index:_,localIndex:p,source:"local",localItem:m,resolvedItem:m,hasResolvedOverlay:!1})}),g}const c=Math.max(a.length-o.length,0),d=a.slice(0,c).map((h,f)=>({key:String(f),item:h,index:f,resolvedIndex:f,source:"inherited",resolvedItem:h,hasResolvedOverlay:!1})),u=o.map((h,f)=>{const g=c+f,m=a[g],p=B3(m)?m:h;return{key:String(g),item:h,index:g,localIndex:f,resolvedIndex:g,source:"local",localItem:h,resolvedItem:p,hasResolvedOverlay:!ER(h,p)}});return[...d,...u]}if(i.collectionKind==="recordMap"){const o=B3(e)?e:{},a=B3(t)?t:o,c=Object.keys(a).map((u,h)=>{var _;const f=o[u],g=B3(f)?f:void 0,m=a[u],p=B3(m)?m:((_=i.createItem)==null?void 0:_.call(i,u))??{};return g==null?{key:u,item:p,index:h,resolvedIndex:h,source:"inherited",resolvedItem:p,hasResolvedOverlay:!1}:{key:u,item:g,index:h,resolvedIndex:h,source:"local",localItem:g,resolvedItem:p,hasResolvedOverlay:!ER(g,p)}}),d=Object.keys(o).filter(u=>!Object.hasOwn(a,u)).map((u,h)=>{var m;const f=o[u],g=B3(f)?f:((m=i.createItem)==null?void 0:m.call(i,u))??{};return{key:u,item:g,index:c.length+h,source:"local",localItem:g,resolvedItem:g,hasResolvedOverlay:!1}});return[...c,...d]}const s=B3(e)?e:{},r=B3(t)?t:s;return i.itemKeys.map((o,a)=>{var h;const l=s[o],c=r[o],d=B3(l)?l:void 0,u=B3(c)?c:((h=i.createItem)==null?void 0:h.call(i,o))??{};return{key:o,item:d??u,index:a,resolvedIndex:a,source:d!=null?"local":"inherited",localItem:d,resolvedItem:u,hasResolvedOverlay:d!=null&&!ER(d,u)}})},ZCn=(n,e)=>n.find(t=>KCn(t.path,e)),qCn=({field:n,sectionKey:e,t})=>n.labelKey!=null?t(n.labelKey):Dy(t,e,n.path,n.path.at(-1)??e),GCn=n=>n==null?"root":`${n.kind}:${n.fieldPath.join(".")}:${n.itemKey}:${(n.nestedPath??[]).join("/")}`,IR=n=>n==null?"":[...n.fieldPath,n.itemKey,...n.nestedPath??[]].map(e=>encodeURIComponent(e)).join("/"),XCn=({fields:n,raw:e})=>{const t=e.trim();if(t==="")return null;const i=t.split("/").map(r=>decodeURIComponent(r).trim()).filter(r=>r!=="");if(i.length<1)return null;const s=n.filter(r=>r.type==="detailCollection"&&r.detailCollection!=null).sort((r,o)=>o.path.length-r.path.length).find(r=>{var a;if(i.length<r.path.length+1||!r.path.every((l,c)=>l===i[c]))return!1;const o=i[r.path.length]??"";return o===""?!1:((a=r.detailCollection)==null?void 0:a.collectionKind)==="list"?/^\d+$/.test(o):!0});return s==null?null:{kind:"detailCollectionItem",fieldPath:s.path,itemKey:i[s.path.length],...i.length>s.path.length+1?{nestedPath:i.slice(s.path.length+1)}:{}}},tXe=({sectionKey:n,fields:e,value:t,resolvedValue:i,route:s,detailContext:r,t:o})=>{var f,g;if(s==null||s.kind!=="detailCollectionItem")return null;const a=eXe(n,e),l=ZCn(a,s.fieldPath);if((l==null?void 0:l.type)!=="detailCollection"||l.detailCollection==null)return null;const d=Ice({field:l,value:au(t,l.path),resolvedValue:au(i??t,l.path)}).find(m=>m.key===s.itemKey);if(d==null)return null;const u=qCn({field:l,sectionKey:n,t:o}),h=((g=(f=l.detailCollection).getBreadcrumbLabel)==null?void 0:g.call(f,d.item,d.key,d.index,r))??l.detailCollection.getItemTitle(d.item,d.key,d.index,r);return{field:l,fieldLabel:u,item:d.item,resolvedItem:d.resolvedItem,itemLabel:h,itemKey:d.key,itemIndex:d.index,localItemIndex:d.localIndex,resolvedItemIndex:d.resolvedIndex,itemSource:d.source,hasResolvedOverlay:d.hasResolvedOverlay}},Mce=n=>typeof n=="string"&&n.trim()!==""?n.trim():"",YCn=n=>n.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[-_]+/g," ").split(/\s+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "),QCn=n=>{const e=tw(n),t=Mce(e.title);return t!==""&&t!==n?t:YCn(n)},JCn=({item:n,fallbackSubtitle:e,t})=>{const i=[],s=Mce(n.defaultModel),r=Mce(n.defaultAccount);return s!==""&&i.push(`${t("config.fields.adapters.defaultModel.label")}: ${s}`),r!==""&&i.push(`${t("config.fields.adapters.defaultAccount.label")}: ${r}`),i.length>0?i.join(" · "):e},e7n=({sectionKey:n,field:e,value:t,resolvedValue:i,onChange:s,onOpenDetail:r,mergedModelServices:o,mergedAdapters:a,uiSection:l,t:c})=>{var A,O;const d=e.detailCollection;if(d==null)return null;const[u,h]=C.useState(""),[f,g]=C.useState((l==null?void 0:l.kind)==="recordMap"?((O=(A=l.recordMap.entryKinds)==null?void 0:A[0])==null?void 0:O.key)??"":""),m=Ice({field:e,value:t,resolvedValue:i}),p={mergedModelServices:o,mergedAdapters:a,t:c},_=e.labelKey!=null?c(e.labelKey):Dy(c,n,e.path,e.path.at(-1)??n),b=d.collectionKind==="list",y=d.collectionKind==="recordMap",w=y&&(l==null?void 0:l.kind)==="recordMap"&&l.recordMap.mode==="discriminated",S=d.collectionKind==="recordMap"?d.keyPlaceholderKey!=null?c(d.keyPlaceholderKey):c("config.editor.fieldKey"):"",x=C.useMemo(()=>(l==null?void 0:l.kind)==="recordMap"?(l.recordMap.entryKinds??[]).map(F=>({value:F.key,label:F.label??F.key})):[],[l]),L=b&&Array.isArray(t)?t.filter(F=>F!=null&&typeof F=="object"&&!Array.isArray(F)):[],E=(F,$)=>{s(C1(t,[F],$))},I=F=>{s(F)},M=(F,$)=>{if(!b)return;const B=F+$;if(B<0||B>=L.length)return;const V=[...L],[W]=V.splice(F,1);W!=null&&(V.splice(B,0,W),I(V))},N=F=>{b&&I(L.filter(($,B)=>B!==F))},T=F=>{if(!y)return;const $=t!=null&&typeof t=="object"&&!Array.isArray(t)?{...t}:{};delete $[F],s($)},D=F=>{r({kind:"detailCollectionItem",fieldPath:e.path,itemKey:F})},P=({item:F,itemKey:$,title:B,localIndex:V,source:W})=>{var H;return W!=="local"||(((H=d.summaryControls)==null?void 0:H.length)??0)===0?null:v.jsx("div",{className:"config-view__detail-summary-controls",onClick:U=>U.stopPropagation(),children:d.summaryControls.map(U=>{if(U.kind!=="boolean")return null;const Z=U.checkedValue??!0,q=!!au(F,U.path)===Z,K=U.labelKey!=null?c(U.labelKey):B;return v.jsx(yu,{size:"small",checked:q,"aria-label":K,onChange:X=>{const ie=C1(F,U.path,X?Z:!Z);if(b){if(V==null)return;const se=[...L];se[V]=ie,I(se);return}E($,ie)}},`${$}:${U.path.join(".")}`)})})},R=()=>{var B;if(!y)return;const F=u.trim();if(F===""||m.some(V=>V.key===F))return;let $;if((l==null?void 0:l.kind)==="recordMap"){const V=l.recordMap.mode==="discriminated"?l.recordMap.schemas[f]??l.recordMap.unknownSchema:l.recordMap.schemas[F]??l.recordMap.unknownSchema;if($=ZGe(V),l.recordMap.mode==="discriminated"){const W=l.recordMap.discriminatorField??"type";$=C1($,[W],f)}}else $=((B=d.createItem)==null?void 0:B.call(d,F,f))??{};E(F,$),h(""),D(F)};return v.jsxs("div",{className:"config-view__detail-list",children:[m.map(({item:F,key:$,index:B,localIndex:V,source:W,hasResolvedOverlay:H})=>{var ie,se;const U=d.getItemTitle(F,$,B,p),Z=(ie=d.getItemSubtitle)==null?void 0:ie.call(d,F,$,B,p),G=(se=d.getItemDescription)==null?void 0:se.call(d,F,$,B,p),q=n==="adapters"?tw($):void 0,K=n==="adapters"?QCn($):U,X=n==="adapters"?JCn({item:F,fallbackSubtitle:Z,t:c}):Z;return v.jsx("div",{className:`config-view__record-card${W==="inherited"?" config-view__record-card--readonly":""}`,children:v.jsxs("div",{className:"config-view__detail-list-row",children:[v.jsx("button",{type:"button",className:"config-view__detail-list-main",onClick:()=>D($),children:v.jsxs("div",{className:`config-view__record-heading${(q==null?void 0:q.icon)!=null?" has-adapter-icon":""}`,children:[q!=null&&v.jsx("div",{className:"config-view__adapter-icon-wrap","aria-hidden":"true",children:q.icon!=null?v.jsx("img",{className:"config-view__adapter-icon",src:q.icon,alt:""}):v.jsx("span",{className:"config-view__adapter-icon-fallback material-symbols-rounded",children:"deployed_code"})}),v.jsxs("div",{className:"config-view__record-heading-text",children:[v.jsxs("div",{className:"config-view__detail-list-title",children:[v.jsx("span",{children:K}),(W==="inherited"||H)&&v.jsx("span",{className:`config-view__detail-badge${W==="inherited"?" config-view__detail-badge--readonly":" config-view__detail-badge--override"}`,children:c(W==="inherited"?"config.detail.inheritedBadge":"config.detail.overrideBadge")})]}),X!=null&&X!==""&&v.jsx("div",{className:"config-view__record-subtitle",children:X}),G!=null&&G!==""&&v.jsx("div",{className:"config-view__record-desc",children:G})]})]})}),P({item:F,itemKey:$,title:K,localIndex:V,source:W}),(b||y)&&W==="local"&&v.jsx(TCn,{index:V??0,itemCount:b?L.length:m.filter(J=>J.source==="local").length,onMove:b?J=>{V!=null&&M(V,J)}:void 0,onRemove:()=>{if(b){if(V==null)return;N(V);return}T($)},t:c})]})},`${e.path.join(".")}:${$}:${U}`)}),b&&m.length===0&&v.jsxs("div",{className:"config-view__detail-list-empty",children:[v.jsx("div",{className:"config-view__detail-list-empty-title",children:_}),v.jsx("div",{className:"config-view__detail-list-empty-desc",children:c("common.noData")})]}),b&&v.jsx("div",{className:"config-view__record-add",children:v.jsx(Qe,{title:c("config.editor.addItem"),children:v.jsx(qe,{size:"small",type:"primary",className:"config-view__icon-button config-view__icon-button--full","aria-label":c("config.editor.addItem"),icon:v.jsx("span",{className:"material-symbols-rounded",children:"add"}),onClick:()=>{const F=[...L,d.createItem()];I(F);const B=Ice({field:e,value:F,resolvedValue:i}).find(V=>V.localIndex===F.length-1);D((B==null?void 0:B.key)??String(F.length-1))}})})}),y&&v.jsx("div",{className:"config-view__record-add",children:v.jsxs("div",{className:"config-view__record-add-inputs",children:[v.jsx(yn,{value:u,placeholder:S,onChange:F=>h(F.target.value)}),w&&v.jsx(ms,{value:f,options:x,onChange:F=>g(F)}),v.jsx(Qe,{title:c("common.confirm"),children:v.jsx(qe,{size:"small",type:"primary",className:"config-view__icon-button","aria-label":c("common.confirm"),icon:v.jsx("span",{className:"material-symbols-rounded",children:"check"}),disabled:u.trim()===""||m.some(F=>F.key===u.trim())||w&&f.trim()==="",onClick:R})})]})})]})},t7n=({value:n,onChange:e,t,keyPlaceholder:i})=>{const[s,r]=C.useState(""),o=Object.entries(n);return v.jsxs("div",{className:"config-view__record-list",children:[o.map(([a,l])=>v.jsxs("div",{className:"config-view__record-row",children:[v.jsx("div",{className:"config-view__record-key",children:a}),v.jsx(yu,{checked:!!l,onChange:c=>{e({...n,[a]:c})}}),v.jsx(Qe,{title:t("config.editor.remove"),children:v.jsx(qe,{size:"small",type:"text",danger:!0,className:"config-view__icon-button config-view__icon-button--compact","aria-label":t("config.editor.remove"),icon:v.jsx("span",{className:"material-symbols-rounded",children:"delete"}),onClick:()=>{const c={...n};delete c[a],e(c)}})})]},a)),v.jsx("div",{className:"config-view__record-add",children:v.jsxs("div",{className:"config-view__record-add-inputs",children:[v.jsx(yn,{value:s,placeholder:i,onChange:a=>r(a.target.value)}),v.jsx(Qe,{title:t("common.confirm"),children:v.jsx(qe,{size:"small",type:"primary",className:"config-view__icon-button","aria-label":t("common.confirm"),icon:v.jsx("span",{className:"material-symbols-rounded",children:"check"}),disabled:s.trim()===""||Object.hasOwn(n,s),onClick:()=>{e({...n,[s]:!0}),r("")}})})]})})]})},oM=({value:n,onChange:e,t,keyPlaceholder:i})=>{const[s,r]=C.useState(""),[o,a]=C.useState(""),l=Object.entries(n);return v.jsxs("div",{className:"config-view__array-list",children:[l.map(([c,d])=>v.jsxs("div",{className:"config-view__array-item",children:[v.jsx("div",{className:"config-view__record-key",children:c}),UGe(c)?v.jsx(yn.Password,{value:d,onChange:u=>{e({...n,[c]:u.target.value})},placeholder:t("config.editor.fieldValue")}):v.jsx(yn,{value:d,onChange:u=>{e({...n,[c]:u.target.value})},placeholder:t("config.editor.fieldValue")}),v.jsx(Qe,{title:t("config.editor.remove"),children:v.jsx(qe,{size:"small",type:"text",danger:!0,className:"config-view__icon-button config-view__icon-button--compact","aria-label":t("config.editor.remove"),icon:v.jsx("span",{className:"material-symbols-rounded",children:"delete"}),onClick:()=>{const u={...n};delete u[c],e(u)}})})]},c)),v.jsx("div",{className:"config-view__array-add",children:v.jsxs("div",{className:"config-view__array-add-inputs",children:[v.jsx(yn,{value:s,placeholder:i,onChange:c=>r(c.target.value)}),v.jsx(yn,{value:o,placeholder:t("config.editor.fieldValue"),onChange:c=>a(c.target.value)}),v.jsx(Qe,{title:t("common.confirm"),children:v.jsx(qe,{size:"small",type:"primary",className:"config-view__icon-button","aria-label":t("common.confirm"),icon:v.jsx("span",{className:"material-symbols-rounded",children:"check"}),disabled:s.trim()===""||Object.hasOwn(n,s),onClick:()=>{const c={...n,[s]:o};e(c),r(""),a("")}})})]})})]})},n7n=({value:n,onChange:e,t,keyPlaceholder:i})=>{const[s,r]=C.useState(""),o=C.useMemo(()=>Object.entries(n),[n]),[a,l]=C.useState(()=>Object.fromEntries(o.map(([c])=>[c,!0])));return C.useEffect(()=>{l(c=>{const d={};for(const[u]of o)d[u]=c[u]??!0;return d})},[o]),v.jsxs("div",{className:"config-view__record-list",children:[o.map(([c,d])=>{const u=d!=null&&typeof d=="object"?d:{},h=typeof u.type=="string"?u.type:"command",f=u.env!=null&&typeof u.env=="object"?u.env:{},g=u.headers!=null&&typeof u.headers=="object"?u.headers:{},m=Array.isArray(u.args)?u.args.filter(b=>typeof b=="string"):[],p=b=>{e({...n,[c]:b})},_=a[c]===!0;return v.jsxs("div",{className:`config-view__record-card${_?" config-view__record-card--collapsed":""}`,children:[v.jsxs("div",{className:"config-view__record-title",children:[v.jsxs("div",{className:"config-view__record-title-left",children:[v.jsx(Qe,{title:t(_?"config.editor.expand":"config.editor.collapse"),children:v.jsx(qe,{size:"small",type:"text",className:"config-view__icon-button config-view__icon-button--compact","aria-label":t(_?"config.editor.expand":"config.editor.collapse"),icon:v.jsx("span",{className:"material-symbols-rounded",children:_?"chevron_right":"expand_more"}),onClick:()=>{l(b=>({...b,[c]:!_}))}})}),v.jsx("span",{children:c})]}),v.jsx(Qe,{title:t("config.editor.remove"),children:v.jsx(qe,{size:"small",type:"text",danger:!0,className:"config-view__icon-button config-view__icon-button--compact","aria-label":t("config.editor.remove"),icon:v.jsx("span",{className:"material-symbols-rounded",children:"delete"}),onClick:()=>{const b={...n};delete b[c],e(b)}})})]}),v.jsx("div",{className:"config-view__record-body",children:v.jsxs("div",{className:"config-view__record-fields",children:[v.jsx(bs,{title:t("config.fields.mcpServer.enabled.label"),description:t("config.fields.mcpServer.enabled.desc"),icon:Is("boolean"),children:v.jsx(yu,{checked:!!u.enabled,onChange:b=>{p({...u,enabled:b})}})}),v.jsx(bs,{title:t("config.fields.mcpServer.type.label"),description:t("config.fields.mcpServer.type.desc"),icon:Is("string"),children:v.jsx(ms,{value:h,options:[{value:"command",label:t("config.options.mcp.command")},{value:"sse",label:t("config.options.mcp.sse")},{value:"http",label:t("config.options.mcp.http")}],onChange:b=>{const y={...u};b==="command"?(delete y.type,y.command==null&&(y.command=""),y.args==null&&(y.args=[]),delete y.url,delete y.headers):(y.type=b,y.url==null&&(y.url=""),y.headers==null&&(y.headers={}),delete y.command,delete y.args),p(y)}})}),h==="command"&&v.jsxs(v.Fragment,{children:[v.jsx(bs,{title:t("config.fields.mcpServer.command.label"),description:t("config.fields.mcpServer.command.desc"),icon:Is("string"),children:v.jsx(yn,{value:typeof u.command=="string"?u.command:"",onChange:b=>{p({...u,command:b.target.value})},placeholder:t("config.editor.commandPlaceholder")})}),v.jsx(bs,{title:t("config.fields.mcpServer.args.label"),description:t("config.fields.mcpServer.args.desc"),icon:Is("array"),layout:"stacked",children:v.jsx(KN,{value:m,onChange:b=>{p({...u,args:b})},t})})]}),h!=="command"&&v.jsxs(v.Fragment,{children:[v.jsx(bs,{title:t("config.fields.mcpServer.url.label"),description:t("config.fields.mcpServer.url.desc"),icon:Is("string"),children:v.jsx(yn,{value:typeof u.url=="string"?u.url:"",onChange:b=>{p({...u,url:b.target.value})},placeholder:t("config.editor.urlPlaceholder")})}),v.jsx(bs,{title:t("config.fields.mcpServer.headers.label"),description:t("config.fields.mcpServer.headers.desc"),icon:Is("object"),layout:"stacked",children:v.jsx(oM,{value:g,onChange:b=>{p({...u,headers:b})},t,keyPlaceholder:t("config.editor.newHeaderName")})})]}),v.jsx(bs,{title:t("config.fields.mcpServer.env.label"),description:t("config.fields.mcpServer.env.desc"),icon:Is("object"),layout:"stacked",children:v.jsx(oM,{value:f,onChange:b=>{p({...u,env:b})},t,keyPlaceholder:t("config.editor.newEnvVarName")})})]})})]},c)}),v.jsx("div",{className:"config-view__record-add",children:v.jsxs("div",{className:"config-view__record-add-inputs",children:[v.jsx(yn,{value:s,placeholder:i,onChange:c=>r(c.target.value)}),v.jsx(Qe,{title:t("common.confirm"),children:v.jsx(qe,{size:"small",type:"primary",className:"config-view__icon-button","aria-label":t("common.confirm"),icon:v.jsx("span",{className:"material-symbols-rounded",children:"check"}),disabled:s.trim()===""||Object.hasOwn(n,s),onClick:()=>{e({...n,[s]:{enabled:!0,command:"",args:[]}}),r("")}})})]})})]})},i7n=({value:n,onChange:e,t,keyPlaceholder:i})=>{const[s,r]=C.useState(""),o=C.useMemo(()=>Object.entries(n),[n]),[a,l]=C.useState(()=>Object.fromEntries(o.map(([c])=>[c,!0])));return C.useEffect(()=>{l(c=>{const d={};for(const[u]of o)d[u]=c[u]??!0;return d})},[o]),v.jsxs("div",{className:"config-view__record-list",children:[o.map(([c,d])=>{const u=d!=null&&typeof d=="object"?d:{},h=typeof u.title=="string"?u.title:"",f=typeof u.description=="string"?u.description:"",g=h.trim()!==""?h:c,m=Array.isArray(u.models)?u.models.filter(_=>typeof _=="string"):[],p=a[c]===!0;return v.jsxs("div",{className:`config-view__record-card${p?" config-view__record-card--collapsed":""}`,children:[v.jsxs("div",{className:"config-view__record-title",children:[v.jsxs("div",{className:"config-view__record-title-left",children:[v.jsx(Qe,{title:t(p?"config.editor.expand":"config.editor.collapse"),children:v.jsx(qe,{size:"small",type:"text",className:"config-view__icon-button config-view__icon-button--compact","aria-label":t(p?"config.editor.expand":"config.editor.collapse"),icon:v.jsx("span",{className:"material-symbols-rounded",children:p?"chevron_right":"expand_more"}),onClick:()=>{l(_=>({..._,[c]:!p}))}})}),v.jsxs("div",{className:"config-view__record-heading",children:[v.jsx("div",{children:g}),g!==c&&v.jsx("div",{className:"config-view__record-subtitle",children:c}),f!==""&&v.jsx("div",{className:"config-view__record-desc",children:f})]})]}),v.jsx(Qe,{title:t("config.editor.remove"),children:v.jsx(qe,{size:"small",type:"text",danger:!0,className:"config-view__icon-button config-view__icon-button--compact","aria-label":t("config.editor.remove"),icon:v.jsx("span",{className:"material-symbols-rounded",children:"delete"}),onClick:()=>{const _={...n};delete _[c],e(_)}})})]}),v.jsx("div",{className:"config-view__record-body",children:v.jsxs("div",{className:"config-view__record-fields",children:[v.jsx(bs,{title:t("config.fields.modelServices.item.title.label"),description:t("config.fields.modelServices.item.title.desc"),icon:Is("string"),children:v.jsx(yn,{value:h,onChange:_=>{e({...n,[c]:{...u,title:_.target.value}})},placeholder:t("config.editor.titlePlaceholder")})}),v.jsx(bs,{title:t("config.fields.modelServices.item.description.label"),description:t("config.fields.modelServices.item.description.desc"),icon:Is("string"),layout:"stacked",children:v.jsx(yn.TextArea,{value:f,onChange:_=>{e({...n,[c]:{...u,description:_.target.value}})},autoSize:{minRows:2},placeholder:t("config.editor.descriptionPlaceholder")})}),v.jsx(bs,{title:t("config.fields.modelServices.item.apiBaseUrl.label"),description:t("config.fields.modelServices.item.apiBaseUrl.desc"),icon:Is("string"),children:v.jsx(yn,{value:typeof u.apiBaseUrl=="string"?u.apiBaseUrl:"",onChange:_=>{e({...n,[c]:{...u,apiBaseUrl:_.target.value}})}})}),v.jsx(bs,{title:t("config.fields.modelServices.item.apiKey.label"),description:t("config.fields.modelServices.item.apiKey.desc"),icon:Is("string"),children:v.jsx(yn.Password,{value:typeof u.apiKey=="string"?u.apiKey:"",onChange:_=>{e({...n,[c]:{...u,apiKey:_.target.value}})},placeholder:t("config.editor.secretPlaceholder")})}),v.jsx(bs,{title:t("config.fields.modelServices.item.models.label"),description:t("config.fields.modelServices.item.models.desc"),icon:Is("array"),layout:"stacked",children:v.jsx(KN,{value:m,onChange:_=>{e({...n,[c]:{...u,models:_}})},t})}),v.jsx(bs,{title:t("config.fields.modelServices.item.timeoutMs.label"),description:t("config.fields.modelServices.item.timeoutMs.desc"),icon:Is("number"),children:v.jsx(E4,{min:1,step:1e3,value:typeof u.timeoutMs=="number"?u.timeoutMs:void 0,onChange:_=>{e({...n,[c]:{...u,...typeof _=="number"?{timeoutMs:_}:{timeoutMs:void 0}}})}})}),v.jsx(bs,{title:t("config.fields.modelServices.item.maxOutputTokens.label"),description:t("config.fields.modelServices.item.maxOutputTokens.desc"),icon:Is("number"),children:v.jsx(E4,{min:1,step:256,value:typeof u.maxOutputTokens=="number"?u.maxOutputTokens:void 0,onChange:_=>{e({...n,[c]:{...u,...typeof _=="number"?{maxOutputTokens:_}:{maxOutputTokens:void 0}}})}})}),v.jsx(bs,{title:t("config.fields.modelServices.item.extra.label"),description:t("config.fields.modelServices.item.extra.desc"),icon:Is("object"),layout:"stacked",children:v.jsx(Ty,{value:u.extra??{},onChange:_=>{e({...n,[c]:{...u,extra:_}})}})})]})})]},c)}),v.jsx("div",{className:"config-view__record-add",children:v.jsxs("div",{className:"config-view__record-add-inputs",children:[v.jsx(yn,{value:s,placeholder:i,onChange:c=>r(c.target.value)}),v.jsx(Qe,{title:t("common.confirm"),children:v.jsx(qe,{size:"small",type:"primary",className:"config-view__icon-button","aria-label":t("common.confirm"),icon:v.jsx("span",{className:"material-symbols-rounded",children:"check"}),disabled:s.trim()===""||Object.hasOwn(n,s),onClick:()=>{e({...n,[s]:{title:"",description:"",apiBaseUrl:"",apiKey:"",models:[],timeoutMs:void 0,maxOutputTokens:void 0,extra:{}}}),r("")}})})]})})]})},pY=({value:n,onChange:e,highlightedKey:t,t:i,keyPlaceholder:s})=>{const[r,o]=C.useState(""),a=C.useMemo(()=>Object.entries(n),[n]),l=C.useRef({}),[c,d]=C.useState(()=>Object.fromEntries(a.map(([u])=>[u,!0])));return C.useEffect(()=>{d(u=>{const h={};for(const[f]of a)h[f]=u[f]??!0;return h})},[a]),C.useEffect(()=>{if(t==null||t.trim()===""||!Object.hasOwn(n,t))return;d(h=>h[t]===!1?h:{...h,[t]:!1});const u=window.requestAnimationFrame(()=>{var h;(h=l.current[t])==null||h.scrollIntoView({block:"center",behavior:"smooth"})});return()=>window.cancelAnimationFrame(u)},[t,n]),v.jsxs("div",{className:"config-view__record-list",children:[a.map(([u,h])=>{const f=c[u]===!0;return v.jsxs("div",{ref:g=>{l.current[u]=g},className:["config-view__record-card",f?"config-view__record-card--collapsed":"",t===u?"config-view__record-card--highlighted":""].filter(Boolean).join(" "),children:[v.jsxs("div",{className:"config-view__record-title",children:[v.jsxs("div",{className:"config-view__record-title-left",children:[v.jsx(Qe,{title:i(f?"config.editor.expand":"config.editor.collapse"),children:v.jsx(qe,{size:"small",type:"text",className:"config-view__icon-button config-view__icon-button--compact","aria-label":i(f?"config.editor.expand":"config.editor.collapse"),icon:v.jsx("span",{className:"material-symbols-rounded",children:f?"chevron_right":"expand_more"}),onClick:()=>{d(g=>({...g,[u]:!f}))}})}),v.jsx("span",{children:u})]}),v.jsx(Qe,{title:i("config.editor.remove"),children:v.jsx(qe,{size:"small",type:"text",danger:!0,className:"config-view__icon-button config-view__icon-button--compact","aria-label":i("config.editor.remove"),icon:v.jsx("span",{className:"material-symbols-rounded",children:"delete"}),onClick:()=>{const g={...n};delete g[u],e(g)}})})]}),v.jsx("div",{className:"config-view__record-body",children:v.jsx(Ty,{value:h,onChange:g=>{e({...n,[u]:g})}})})]},u)}),v.jsx("div",{className:"config-view__record-add",children:v.jsxs("div",{className:"config-view__record-add-inputs",children:[v.jsx(yn,{value:r,placeholder:s,onChange:u=>o(u.target.value)}),v.jsx(Qe,{title:i("common.confirm"),children:v.jsx(qe,{size:"small",type:"primary",className:"config-view__icon-button","aria-label":i("common.confirm"),icon:v.jsx("span",{className:"material-symbols-rounded",children:"check"}),disabled:r.trim()===""||Object.hasOwn(n,r),onClick:()=>{e({...n,[r]:{}}),o("")}})})]})})]})},s7n=({value:n,schema:e,onChange:t,t:i,keyPlaceholder:s})=>{var h,f;const[r,o]=C.useState(""),[a,l]=C.useState(((f=(h=e.entryKinds)==null?void 0:h[0])==null?void 0:f.key)??""),c=C.useMemo(()=>Object.entries(n),[n]),[d,u]=C.useState(()=>Object.fromEntries(c.map(([g])=>[g,!0])));return C.useEffect(()=>{u(g=>{const m={};for(const[p]of c)m[p]=g[p]??!0;return m})},[c]),v.jsxs("div",{className:"config-view__record-list",children:[c.map(([g,m])=>{var E,I;const p=m!=null&&typeof m=="object"?m:{},{itemSchema:_,isKnownEntry:b}=qGe({schema:e,entryKey:g,entryValue:p}),y=d[g]===!0,w=e.discriminatorField??"type",S=e.mode==="discriminated"?au(p,[w]):void 0,x=!b&&e.unknownEditor==="json",L=typeof S=="string"?(E=e.entryKinds)==null?void 0:E.find(M=>M.key===S):(I=e.entryKinds)==null?void 0:I.find(M=>M.key===g);return v.jsxs("div",{className:`config-view__record-card${y?" config-view__record-card--collapsed":""}`,children:[v.jsxs("div",{className:"config-view__record-title",children:[v.jsxs("div",{className:"config-view__record-title-left",children:[v.jsx(Qe,{title:i(y?"config.editor.expand":"config.editor.collapse"),children:v.jsx(qe,{size:"small",type:"text",className:"config-view__icon-button config-view__icon-button--compact","aria-label":i(y?"config.editor.expand":"config.editor.collapse"),icon:v.jsx("span",{className:"material-symbols-rounded",children:y?"chevron_right":"expand_more"}),onClick:()=>{u(M=>({...M,[g]:!y}))}})}),v.jsxs("div",{className:"config-view__record-heading",children:[v.jsx("div",{children:g}),(L==null?void 0:L.label)!=null&&L.label!==g&&v.jsx("div",{className:"config-view__record-subtitle",children:L.label}),(L==null?void 0:L.description)!=null&&L.description!==""&&v.jsx("div",{className:"config-view__record-desc",children:L.description})]})]}),v.jsx(Qe,{title:i("config.editor.remove"),children:v.jsx(qe,{size:"small",type:"text",danger:!0,className:"config-view__icon-button config-view__icon-button--compact","aria-label":i("config.editor.remove"),icon:v.jsx("span",{className:"material-symbols-rounded",children:"delete"}),onClick:()=>{const M={...n};delete M[g],t(M)}})})]}),v.jsxs("div",{className:"config-view__record-body",children:[!x&&_!=null&&v.jsx(yH,{value:p,schema:_,onChange:M=>{t({...n,[g]:M})},t:i,hideFieldPaths:b&&e.mode==="discriminated"?[[w]]:void 0}),x&&v.jsx(Ty,{value:p,onChange:M=>{t({...n,[g]:M})}})]})]},g)}),v.jsx("div",{className:"config-view__record-add",children:v.jsxs("div",{className:"config-view__record-add-inputs",children:[v.jsx(yn,{value:r,placeholder:s,onChange:g=>o(g.target.value)}),e.mode==="discriminated"&&v.jsx(ms,{value:a,options:(e.entryKinds??[]).map(g=>({value:g.key,label:g.label??g.key})),onChange:g=>l(g)}),v.jsx(Qe,{title:i("common.confirm"),children:v.jsx(qe,{size:"small",type:"primary",className:"config-view__icon-button","aria-label":i("common.confirm"),icon:v.jsx("span",{className:"material-symbols-rounded",children:"check"}),disabled:r.trim()===""||Object.hasOwn(n,r)||e.mode==="discriminated"&&a.trim()==="",onClick:()=>{const g=e.mode==="discriminated"?e.schemas[a]??e.unknownSchema:e.schemas[r]??e.unknownSchema,m=ZGe(g);if(e.mode==="discriminated"){const p=e.discriminatorField??"type";Object.assign(m,C1(m,[p],a))}t({...n,[r]:m}),o("")}})})]})})]})},r7n=({value:n,onChange:e,t})=>{const i=typeof n.type=="string"?n.type:"command",s=n.env!=null&&typeof n.env=="object"?n.env:{},r=n.headers!=null&&typeof n.headers=="object"?n.headers:{},o=Array.isArray(n.args)?n.args.filter(a=>typeof a=="string"):[];return v.jsxs("div",{className:"config-view__field-stack",children:[v.jsx(bs,{title:t("config.fields.mcpServer.enabled.label"),description:t("config.fields.mcpServer.enabled.desc"),icon:Is("boolean"),children:v.jsx(yu,{checked:!!n.enabled,onChange:a=>{e({...n,enabled:a})}})}),v.jsx(bs,{title:t("config.fields.mcpServer.type.label"),description:t("config.fields.mcpServer.type.desc"),icon:Is("string"),children:v.jsx(ms,{value:i,options:[{value:"command",label:t("config.options.mcp.command")},{value:"sse",label:t("config.options.mcp.sse")},{value:"http",label:t("config.options.mcp.http")}],onChange:a=>{const l={...n};a==="command"?(delete l.type,l.command==null&&(l.command=""),l.args==null&&(l.args=[]),delete l.url,delete l.headers):(l.type=a,l.url==null&&(l.url=""),l.headers==null&&(l.headers={}),delete l.command,delete l.args),e(l)}})}),i==="command"&&v.jsxs(v.Fragment,{children:[v.jsx(bs,{title:t("config.fields.mcpServer.command.label"),description:t("config.fields.mcpServer.command.desc"),icon:Is("string"),children:v.jsx(yn,{value:typeof n.command=="string"?n.command:"",onChange:a=>{e({...n,command:a.target.value})},placeholder:t("config.editor.commandPlaceholder")})}),v.jsx(bs,{title:t("config.fields.mcpServer.args.label"),description:t("config.fields.mcpServer.args.desc"),icon:Is("array"),layout:"stacked",children:v.jsx(KN,{value:o,onChange:a=>{e({...n,args:a})},t})})]}),i!=="command"&&v.jsxs(v.Fragment,{children:[v.jsx(bs,{title:t("config.fields.mcpServer.url.label"),description:t("config.fields.mcpServer.url.desc"),icon:Is("string"),children:v.jsx(yn,{value:typeof n.url=="string"?n.url:"",onChange:a=>{e({...n,url:a.target.value})},placeholder:t("config.editor.urlPlaceholder")})}),v.jsx(bs,{title:t("config.fields.mcpServer.headers.label"),description:t("config.fields.mcpServer.headers.desc"),icon:Is("object"),layout:"stacked",children:v.jsx(oM,{value:r,onChange:a=>{e({...n,headers:a})},t,keyPlaceholder:t("config.editor.newHeaderName")})})]}),v.jsx(bs,{title:t("config.fields.mcpServer.env.label"),description:t("config.fields.mcpServer.env.desc"),icon:Is("object"),layout:"stacked",children:v.jsx(oM,{value:s,onChange:a=>{e({...n,env:a})},t,keyPlaceholder:t("config.editor.newEnvVarName")})})]})},CY=n=>n!=null&&typeof n=="object"&&!Array.isArray(n),o7n=({value:n,onChange:e,mergedModelServices:t,t:i})=>{const s=CY(n)?n:{},r=typeof s.service=="string"?s.service:void 0,o=Object.entries(t).map(([d,u])=>{const h=CY(u)?u:{},f=typeof h.title=="string"&&h.title.trim()!==""?h.title:d;return{value:d,label:f}}),a=r!=null&&CY(t[r])?t[r]:void 0,l=Array.isArray(a==null?void 0:a.models)?a.models.filter(d=>typeof d=="string"):[],c=d=>{e({...s,...d})};return v.jsxs("div",{className:"config-view__field-stack",children:[v.jsx(bs,{title:i("config.fields.general.recommendedModels.item.service.label"),description:i("config.fields.general.recommendedModels.item.service.desc"),icon:Is("string"),children:v.jsx(ms,{value:r,options:o,onChange:d=>{c({service:d,model:void 0})},allowClear:!0,placeholder:i("config.editor.defaultModelServicePlaceholder")})}),v.jsx(bs,{title:i("config.fields.general.recommendedModels.item.model.label"),description:i("config.fields.general.recommendedModels.item.model.desc"),icon:Is("string"),children:l.length>0?v.jsx(ms,{value:typeof s.model=="string"&&s.model!==""?s.model:void 0,options:l.map(d=>({value:d,label:d})),onChange:d=>c({model:d}),allowClear:!0,placeholder:i("config.editor.defaultModelPlaceholder")}):v.jsx(yn,{value:typeof s.model=="string"?s.model:"",onChange:d=>c({model:d.target.value}),placeholder:i("config.editor.defaultModelPlaceholder")})}),v.jsx(bs,{title:i("config.fields.general.recommendedModels.item.title.label"),description:i("config.fields.general.recommendedModels.item.title.desc"),icon:Is("string"),children:v.jsx(yn,{value:typeof s.title=="string"?s.title:"",onChange:d=>c({title:d.target.value}),placeholder:i("config.editor.titlePlaceholder")})}),v.jsx(bs,{title:i("config.fields.general.recommendedModels.item.description.label"),description:i("config.fields.general.recommendedModels.item.description.desc"),icon:Is("string"),layout:"stacked",children:v.jsx(yn.TextArea,{value:typeof s.description=="string"?s.description:"",onChange:d=>c({description:d.target.value}),autoSize:{minRows:4},placeholder:i("config.editor.descriptionPlaceholder")})}),v.jsx(bs,{title:i("config.fields.general.recommendedModels.item.placement.label"),description:i("config.fields.general.recommendedModels.item.placement.desc"),icon:Is("string"),children:v.jsx(ms,{value:s.placement,options:[{value:"modelSelector",label:i("config.options.recommendedModels.modelSelector")}],onChange:d=>c({placement:d}),allowClear:!0})})]})},Nxe=new Set(["models"]),a7n=new Set(["modelServices","channels","adapters"]),l7n=["base","permissions","env","items","default"],Dxe=n=>n!=null&&typeof n=="object"&&!Array.isArray(n),Sc=(n,e)=>n.length===1&&n[0]===e,c7n=v.jsx("span",{className:"material-symbols-rounded config-view__select-chevron",children:"expand_more"}),d7n=({sectionKey:n,fields:e,uiSection:t,value:i,resolvedValue:s,onChange:r,mergedModelServices:o,mergedAdapters:a,selectedModelService:l,worktreeEnvironmentOptions:c,detailRoute:d=null,onOpenDetailRoute:u,t:h})=>{var O,F,$,B,V,W,H,U,Z,G;const f=e??JGe[n]??[],g={mergedModelServices:o,mergedAdapters:a,t:h},m=q=>(K,X)=>Dy(h,q,K.path,X),p=q=>(K,X)=>{const ie=bH(h,q,K.path);return ie!==""?ie:X},_=({body:q,title:K,collapsible:X=!1,defaultExpanded:ie=!0,collapseKey:se="section"})=>X?v.jsx(hZ,{className:"config-view__subsection-collapse",ghost:!0,expandIconPosition:"end",expandIcon:({isActive:J})=>v.jsx("span",{className:`material-symbols-rounded config-view__subsection-expand-icon${J?" is-active":""}`,children:"chevron_right"}),defaultActiveKey:ie?[se]:[],items:[{key:se,label:v.jsx("div",{className:"config-view__subsection-title",children:K}),children:q}]}):v.jsxs("div",{className:"config-view__subsection",children:[K!=null&&K!==""&&v.jsx("div",{className:"config-view__subsection-title",children:K}),q]}),b=({schema:q,currentValue:K,onCurrentValueChange:X,visibleFieldPaths:ie,title:se,collapsible:J=!1,defaultExpanded:le=!0,collapseKey:be,resolveFieldOptions:ae})=>ie.length===0?null:_({title:se,collapsible:J,defaultExpanded:le,collapseKey:be,body:v.jsx("div",{className:"config-view__subsection-body",children:v.jsx(yH,{value:K,schema:q,onChange:X,t:h,visibleFieldPaths:ie,resolveFieldLabel:m("adapters"),resolveFieldDescription:p("adapters"),resolveFieldOptions:ae})})}),y=({schema:q,currentValue:K,onCurrentValueChange:X,modelSection:ie,advancedSections:se})=>{const J=se.filter(ae=>ae.visibleFieldPaths.length>0),le=ie!=null&&ie.visibleFieldPaths.length>0;if(!le&&J.length===0)return null;const be=!le&&J.length>0;return v.jsxs("div",{className:"config-view__field-stack",children:[le&&b({schema:q,currentValue:K,onCurrentValueChange:X,visibleFieldPaths:ie.visibleFieldPaths,title:ie.title,collapsible:!0,defaultExpanded:!0,collapseKey:"models"}),J.length>0&&_({title:h("config.sectionGroups.advanced"),collapsible:!0,defaultExpanded:be,collapseKey:"advanced",body:v.jsx("div",{className:"config-view__subsection-body",children:v.jsx("div",{className:"config-view__field-stack",children:J.map(ae=>v.jsx(C.Fragment,{children:b({schema:q,currentValue:K,onCurrentValueChange:X,visibleFieldPaths:ae.visibleFieldPaths,title:ae.title})},ae.key))})})})]})};if((t==null?void 0:t.kind)==="recordMap"&&f.length===0){const q=i!=null&&typeof i=="object"?i:{};return t.recordMap.mode==="discriminated"&&(((O=t.recordMap.entryKinds)==null?void 0:O.length)??0)===0?v.jsx(pY,{value:q,onChange:r,t:h,keyPlaceholder:h("config.editor.fieldKey")}):v.jsx(s7n,{value:q,schema:t.recordMap,onChange:r,t:h,keyPlaceholder:t.recordMap.keyPlaceholder??h("config.editor.fieldKey")})}if(f.length===0)return v.jsx(jn,{description:h("common.noData"),image:null});const S=Object.entries(o).map(([q,K])=>{const X=K!=null&&typeof K=="object"?K:{},ie=typeof X.title=="string"&&X.title.trim()!==""?X.title:q,se=typeof X.description=="string"?X.description:"";return{value:q,label:v.jsxs("div",{className:"config-view__option",children:[v.jsx("div",{className:"config-view__option-title",children:ie}),se!==""&&v.jsx("div",{className:"config-view__option-desc",children:se})]})}}),x=l?o[l]:void 0,L=x!=null&&typeof x=="object"?x.models:void 0,E=Array.isArray(L)?L.filter(q=>typeof q=="string").map(q=>({value:q,label:v.jsx("span",{children:q})})):[],I=Object.keys(a).map(q=>({value:q,label:v.jsx("span",{children:q})})),M=({fieldValue:q,fieldPath:K,onOverride:X})=>v.jsxs("div",{className:"config-view__field-readonly",children:[v.jsx("div",{className:"config-view__field-readonly-value",children:v.jsx(GL,{value:q,sectionKey:n,path:K,t:h})}),X!=null&&v.jsx(qe,{size:"small",onClick:X,children:h("config.detail.override")})]}),N=({field:q,currentValue:K,currentResolvedValue:X,onCurrentValueChange:ie,keyPrefix:se,readOnly:J=!1})=>{const le=au(K,q.path),be=au(X,q.path),ae=le!==void 0,ce=be!==void 0,oe=!ae&&ce,he=q.type==="string"||q.type==="multiline"||q.type==="number"||q.type==="boolean"||q.type==="select"||q.type==="shortcut",ye=ae?le:ce&&he?be:q.defaultValue,ke=q.labelKey?h(q.labelKey):Dy(h,n,q.path,q.path[q.path.length-1]??""),Ce=q.descriptionKey?h(q.descriptionKey):bH(h,n,q.path),Se=q.icon??Is(zGe(ye)),we=xe=>{ie(C1(K,q.path,xe))};let ve=null;const Ee=["multiline","json","record","string[]","detailCollection"].includes(q.type),me=()=>{ce&&we(be)};if(J)ve=v.jsx(GL,{value:ce?be:le??q.defaultValue,sectionKey:n,path:q.path,t:h});else if(q.type==="detailCollection")ve=v.jsx(e7n,{sectionKey:n,field:q,value:le,resolvedValue:be,onChange:xe=>we(xe),onOpenDetail:xe=>u==null?void 0:u(xe),mergedModelServices:o,mergedAdapters:a,uiSection:t,t:h});else if(oe&&!he)ve=M({fieldValue:be,fieldPath:q.path,onOverride:me});else if(q.type==="string"){const xe=q.placeholderKey?h(q.placeholderKey):void 0;q.sensitive===!0?ve=v.jsx(yn.Password,{value:typeof ye=="string"?ye:"",onChange:Oe=>we(Oe.target.value),placeholder:h("config.editor.secretPlaceholder")}):ve=v.jsx(yn,{value:typeof ye=="string"?ye:"",onChange:Oe=>we(Oe.target.value),placeholder:xe})}else if(q.type==="multiline"){const xe=typeof ye=="string"?ye:"",Oe=q.placeholderKey?h(q.placeholderKey):h("config.editor.multilinePlaceholder");ve=v.jsx("div",{className:"config-view__multiline",children:v.jsx(yn.TextArea,{className:"config-view__multiline-input",value:xe,onChange:We=>we(We.target.value),autoSize:{minRows:3},placeholder:Oe})})}else if(q.type==="number")if(q.path.join(".")==="notifications.volume"){const Oe=typeof ye=="number"?ye:0;ve=v.jsx(b2t,{className:"config-view__slider",min:0,max:100,step:1,value:Oe,onChange:We=>we(typeof We=="number"?We:0)})}else ve=v.jsx(E4,{value:typeof ye=="number"?ye:0,onChange:Oe=>we(typeof Oe=="number"?Oe:0)});else if(q.type==="boolean")ve=v.jsx(yu,{checked:!!ye,onChange:xe=>we(xe)});else if(q.type==="string[]"){const xe=Array.isArray(ye)?ye.filter(Oe=>typeof Oe=="string"):[];ve=v.jsx(KN,{value:xe,onChange:Oe=>we(Oe),t:h})}else if(q.type==="select"){const xe=n==="general"&&q.path.join(".")==="defaultAdapter",Oe=n==="general"&&q.path.join(".")==="defaultModelService",We=n==="general"&&q.path.join(".")==="defaultModel",Ke=n==="conversation"&&q.path.join(".")==="worktreeEnvironment",ze=Oe?S:We?E:xe?I:Ke?c??[]:(q.options??[]).map(Ve=>({value:Ve.value,label:v.jsx("span",{children:h(Ve.label)})}));ve=v.jsx(ms,{value:typeof ye=="string"&&ye!==""?ye:void 0,options:ze,onChange:Ve=>we(Ve),allowClear:!0,suffixIcon:c7n,disabled:We&&E.length===0,placeholder:h(xe?"config.editor.defaultAdapterPlaceholder":Oe?"config.editor.defaultModelServicePlaceholder":Ke?"config.editor.worktreeEnvironmentPlaceholder":"config.editor.defaultModelPlaceholder")})}else if(q.type==="json")ve=v.jsx(Ty,{value:ye,onChange:we});else if(q.type==="record"){const xe=ye!=null&&typeof ye=="object"?ye:{};q.recordKind==="modelServices"?ve=v.jsx(i7n,{value:xe,onChange:we,t:h,keyPlaceholder:F7(n,q,h)}):q.recordKind==="channels"?ve=v.jsx(pY,{value:xe,onChange:we,t:h,keyPlaceholder:F7(n,q,h)}):q.recordKind==="mcpServers"?ve=v.jsx(n7n,{value:xe,onChange:we,t:h,keyPlaceholder:F7(n,q,h)}):q.recordKind==="keyValue"?ve=v.jsx(oM,{value:xe,onChange:we,t:h,keyPlaceholder:F7(n,q,h)}):q.recordKind==="boolean"?ve=v.jsx(t7n,{value:xe,onChange:we,t:h,keyPlaceholder:F7(n,q,h)}):ve=v.jsx(pY,{value:xe,onChange:we,t:h,keyPlaceholder:F7(n,q,h)})}else if(q.type==="shortcut"){const xe=navigator.platform.includes("Mac"),Oe=typeof ye=="string"?ye:"",We=q.shortcutKind==="sendMessage";ve=v.jsx(DCn,{value:Oe,displayValue:We?sOe(Oe,xe):void 0,onChange:Ke=>we(Ke),placeholder:h("config.editor.shortcutPlaceholder"),normalizeShortcut:We?Ke=>iOe(Ke,xe):void 0,isMac:xe,t:h})}return Nxe.has(n)&&q.type==="record"?v.jsx("div",{children:ve},`${se}:${q.path.join(".")}:${q.type}:${q.recordKind??""}`):a7n.has(n)&&q.type==="detailCollection"&&q.path.length===0?v.jsx("div",{children:ve},`${se}:${q.path.join(".")}:${q.type}`):v.jsx(bs,{title:ke,description:Ce,icon:Se,layout:Ee?"stacked":"inline",children:ve},`${se}:${q.path.join(".")}:${q.type}:${q.labelKey??""}:${q.recordKind??""}`)},T=({currentFields:q,currentValue:K,currentResolvedValue:X,onCurrentValueChange:ie,keyPrefix:se,readOnly:J=!1})=>{const le=q.reduce((ae,ce)=>{const oe=ce.group??"default";return ae[oe]||(ae[oe]=[]),ae[oe].push(ce),ae},{}),be=(PCn[n]??l7n).filter(ae=>{var ce;return(ce=le[ae])==null?void 0:ce.length});return v.jsx("div",{className:"config-view__field-stack",children:be.map(ae=>{var Ee;const ce=le[ae]??[];if(ae==="default")return Nxe.has(n)?v.jsx("div",{children:ce.map(me=>N({field:me,currentValue:K,currentResolvedValue:X,onCurrentValueChange:ie,keyPrefix:se,readOnly:J}))},`${se}:${ae}`):v.jsx("div",{className:"config-view__field-list",children:ce.map(me=>N({field:me,currentValue:K,currentResolvedValue:X,onCurrentValueChange:ie,keyPrefix:se,readOnly:J}))},`${se}:${ae}`);const oe=(Ee=RCn[n])==null?void 0:Ee[ae],he=(()=>{const me=oe==null?void 0:oe.labelKey;return h(me||(ae==="base"?"config.sectionGroups.base":ae==="models"?"config.sectionGroups.models":ae==="advanced"?"config.sectionGroups.advanced":ae==="permissions"?"config.sectionGroups.permissions":ae==="env"?"config.sectionGroups.env":n==="plugins"?"config.sectionGroups.plugins":"config.sectionGroups.items"))})(),ye=ce.filter(me=>me.hidden!==!0),ke=ye.filter(me=>me.collapse!=null),Ce=ye.filter(me=>me.collapse==null),Se=ke.reduce((me,xe)=>{const Oe=xe.collapse;if(!Oe)return me;const We=me.get(Oe.key);return We?We.fields.push(xe):me.set(Oe.key,{meta:Oe,fields:[xe]}),me},new Map),we=Array.from(Se.values()).map(me=>({key:me.meta.key,collapsible:"header",label:v.jsxs("div",{className:"config-view__collapse-header",children:[v.jsxs("div",{className:"config-view__collapse-header-main",children:[v.jsx("div",{className:"config-view__collapse-title",children:h(me.meta.labelKey)}),me.meta.descKey&&v.jsx("div",{className:"config-view__collapse-desc",children:h(me.meta.descKey)})]}),me.meta.togglePath&&v.jsx(yu,{checked:!au(K,me.meta.togglePath),onChange:xe=>{ie(C1(K,me.meta.togglePath,!xe))},disabled:J,onClick:(xe,Oe)=>{Oe.stopPropagation()}})]}),children:v.jsx("div",{className:"config-view__field-list",children:me.fields.map(xe=>N({field:xe,currentValue:K,currentResolvedValue:X,onCurrentValueChange:ie,keyPrefix:se,readOnly:J}))})})),ve=v.jsxs("div",{className:"config-view__subsection-body",children:[Ce.map(me=>N({field:me,currentValue:K,currentResolvedValue:X,onCurrentValueChange:ie,keyPrefix:se,readOnly:J})),we.length>0&&v.jsx(hZ,{className:"config-view__collapse-group config-view__field-row",ghost:!0,items:we})]});return(oe==null?void 0:oe.collapsible)===!0?v.jsx(hZ,{className:"config-view__subsection-collapse",ghost:!0,expandIconPosition:"end",expandIcon:({isActive:me})=>v.jsx("span",{className:`material-symbols-rounded config-view__subsection-expand-icon${me?" is-active":""}`,children:"chevron_right"}),defaultActiveKey:oe.defaultExpanded===!1?[]:[ae],items:[{key:ae,label:v.jsx("div",{className:"config-view__subsection-title",children:he}),children:ve}]},`${se}:${ae}`):v.jsxs("div",{className:"config-view__subsection",children:[v.jsx("div",{className:"config-view__subsection-title",children:he}),ve]},`${se}:${ae}`)})})},D=tXe({sectionKey:n,fields:f,value:i,resolvedValue:s,route:d,detailContext:g,t:h}),P=n==="adapters"&&(t==null?void 0:t.kind)==="recordMap"&&(D==null?void 0:D.field.path.length)===0?D.itemKey:null,{data:R}=Gn(P!=null?`/api/adapters/${P}/accounts`:null,()=>G3e(P)),A=C.useMemo(()=>{if(P==null||!Dxe(D==null?void 0:D.item))return;const q=typeof D.item.defaultAccount=="string"&&D.item.defaultAccount.trim()!==""?D.item.defaultAccount.trim():void 0,K=au(D.item,["accounts"]),X=Dxe(K)?{...K}:{};return q!=null&&X[q]==null&&(X[q]={title:q}),QGe(X,(R==null?void 0:R.accounts)??[],q).map(ie=>({value:ie.key,label:ie.title===ie.key?ie.key:`${ie.title} (${ie.key})`}))},[R==null?void 0:R.accounts,P,D==null?void 0:D.item]);if(D!=null){const q=D.field.detailCollection,K=q!=null&&(q.collectionKind!=="list"||q.getMergeKey!=null),X=J=>{if(D.field.type!=="detailCollection"||D.field.detailCollection==null)return;const le=J!=null&&typeof J=="object"&&!Array.isArray(J)?J:{};if(D.field.detailCollection.collectionKind==="list"){const be=au(i,D.field.path),ce=[...Array.isArray(be)?be.filter(oe=>oe!=null&&typeof oe=="object"&&!Array.isArray(oe)):[]];D.localItemIndex==null?ce.push(le):ce[D.localItemIndex]=le,r(C1(i,D.field.path,ce));return}r(C1(i,[...D.field.path,D.itemKey],le))},ie=()=>{K&&X(D.resolvedItem)},se=D.itemSource==="inherited"?v.jsxs("div",{className:"config-view__detail-notice",children:[v.jsx("div",{className:"config-view__detail-notice-text",children:h(K?"config.detail.inheritedReadonly":"config.detail.inheritedAppendOnly")}),K&&v.jsx(qe,{size:"small",type:"primary",onClick:ie,children:h("config.detail.override")})]}):D.hasResolvedOverlay?v.jsx("div",{className:"config-view__detail-notice",children:v.jsx("div",{className:"config-view__detail-notice-text",children:h("config.detail.partialOverride")})}):null;if(D.itemSource==="inherited")return((($=(F=D.field.detailCollection)==null?void 0:F.itemFields)==null?void 0:$.length)??0)>0?v.jsxs("div",{className:"config-view__detail-panel",children:[se,T({currentFields:D.field.detailCollection.itemFields,currentValue:void 0,currentResolvedValue:D.resolvedItem,onCurrentValueChange:()=>{},keyPrefix:`detail:${D.field.path.join(".")}:${D.itemKey}`,readOnly:!0})]}):v.jsxs("div",{className:"config-view__detail-panel",children:[se,v.jsx(GL,{value:D.resolvedItem,sectionKey:n,path:D.field.path,t:h})]});if(((B=D.field.detailCollection)==null?void 0:B.detailKind)==="recommendedModels")return v.jsxs("div",{className:"config-view__detail-panel",children:[se,v.jsx(o7n,{value:D.item,onChange:X,mergedModelServices:o,t:h})]});if(((V=D.field.detailCollection)==null?void 0:V.detailKind)==="mcpServer")return v.jsxs("div",{className:"config-view__detail-panel",children:[se,v.jsx(r7n,{value:D.item,onChange:X,t:h})]});if((t==null?void 0:t.kind)==="recordMap"&&D.field.path.length===0){const{itemSchema:J,isKnownEntry:le}=qGe({schema:t.recordMap,entryKey:D.itemKey,entryValue:D.item}),be=!le&&t.recordMap.unknownEditor==="json",ae=t.recordMap.discriminatorField??"type";if(be)return v.jsxs("div",{className:"config-view__detail-panel",children:[se,v.jsx(Ty,{value:D.item,onChange:ce=>X(ce??{})})]});if(J!=null){if(n==="adapters"){const ce=(H=(W=J.recordFields)==null?void 0:W.accounts)==null?void 0:H.itemSchema,oe=((U=d==null?void 0:d.nestedPath)==null?void 0:U[0])==="accounts",he=[...le&&t.recordMap.mode==="discriminated"?[[ae]]:[],["accounts"]],ye=J.fields.filter(Ee=>!he.some(me=>Ee.path.length===me.length&&Ee.path.every((xe,Oe)=>xe===me[Oe]))),ke=ye.filter(Ee=>Ee.path.length===1&&Ee.path[0]==="defaultAccount").map(Ee=>Ee.path),Ce=ye.filter(Ee=>Ee.path.length===1&&(Ee.path[0]==="includeModels"||Ee.path[0]==="excludeModels"||Ee.path[0]==="experimentalApi"||Ee.path[0]==="maxOutputTokens")||Ee.type==="json"||Ee.type==="multiline"||Ee.type==="string[]"),Se=ye.filter(Ee=>!ke.some(me=>Ee.path.length===me.length&&Ee.path.every((xe,Oe)=>xe===me[Oe]))).filter(Ee=>!Ce.some(me=>Ee.path.length===me.path.length&&Ee.path.every((xe,Oe)=>xe===me.path[Oe]))).map(Ee=>Ee.path),we={title:h("config.sectionGroups.models"),visibleFieldPaths:Ce.filter(Ee=>Sc(Ee.path,"includeModels")||Sc(Ee.path,"excludeModels")).map(Ee=>Ee.path)},ve=[{key:"runtime",title:h("config.sectionGroups.advancedRuntime"),visibleFieldPaths:Ce.filter(Ee=>Sc(Ee.path,"experimentalApi")||Sc(Ee.path,"maxOutputTokens")).map(Ee=>Ee.path)},{key:"sandbox",title:h("config.sectionGroups.advancedSandbox"),visibleFieldPaths:Ce.filter(Ee=>Sc(Ee.path,"sandboxPolicy")).map(Ee=>Ee.path)},{key:"client",title:h("config.sectionGroups.advancedClient"),visibleFieldPaths:Ce.filter(Ee=>Sc(Ee.path,"clientInfo")).map(Ee=>Ee.path)},{key:"overrides",title:h("config.sectionGroups.advancedOverrides"),visibleFieldPaths:Ce.filter(Ee=>Sc(Ee.path,"configOverrides")||Sc(Ee.path,"features")).map(Ee=>Ee.path)},{key:"misc",title:h("config.sectionGroups.advancedMisc"),visibleFieldPaths:Ce.filter(Ee=>!(Sc(Ee.path,"includeModels")||Sc(Ee.path,"excludeModels")||Sc(Ee.path,"experimentalApi")||Sc(Ee.path,"maxOutputTokens")||Sc(Ee.path,"sandboxPolicy")||Sc(Ee.path,"clientInfo")||Sc(Ee.path,"configOverrides")||Sc(Ee.path,"features"))).map(Ee=>Ee.path)}];return oe?v.jsxs("div",{className:"config-view__detail-panel",children:[se,v.jsx(Exe,{adapterKey:D.itemKey,value:D.item,accountItemSchema:ce,onChange:X,nestedPath:d==null?void 0:d.nestedPath,onOpenNestedPath:Ee=>{u==null||u({kind:(d==null?void 0:d.kind)??"detailCollectionItem",fieldPath:D.field.path,itemKey:D.itemKey,nestedPath:Ee})},t:h})]}):v.jsxs("div",{className:"config-view__detail-panel",children:[se,v.jsxs("div",{className:"config-view__field-stack",children:[b({schema:J,currentValue:D.item,onCurrentValueChange:X,visibleFieldPaths:Se,title:h("config.sectionGroups.base"),collapsible:!0,defaultExpanded:!0,collapseKey:"base"}),b({schema:J,currentValue:D.item,onCurrentValueChange:X,visibleFieldPaths:ke,title:void 0,resolveFieldOptions:Ee=>Ee.path.length===1&&Ee.path[0]==="defaultAccount"?A??[]:void 0}),v.jsx(Exe,{adapterKey:D.itemKey,value:D.item,accountItemSchema:ce,onChange:X,nestedPath:d==null?void 0:d.nestedPath,onOpenNestedPath:Ee=>{u==null||u({kind:(d==null?void 0:d.kind)??"detailCollectionItem",fieldPath:D.field.path,itemKey:D.itemKey,nestedPath:Ee})},t:h}),y({schema:J,currentValue:D.item,onCurrentValueChange:X,modelSection:we,advancedSections:ve})]})]})}return v.jsxs("div",{className:"config-view__detail-panel",children:[se,v.jsx(yH,{value:D.item,schema:J,onChange:X,t:h,hideFieldPaths:le&&t.recordMap.mode==="discriminated"?[[ae]]:void 0})]})}}return(((G=(Z=D.field.detailCollection)==null?void 0:Z.itemFields)==null?void 0:G.length)??0)>0?v.jsxs("div",{className:"config-view__detail-panel",children:[se,T({currentFields:D.field.detailCollection.itemFields,currentValue:D.item,currentResolvedValue:D.resolvedItem,onCurrentValueChange:X,keyPrefix:`detail:${D.field.path.join(".")}:${D.itemKey}`})]}):v.jsxs("div",{className:"config-view__detail-panel",children:[se,v.jsx(jn,{description:h("common.noData"),image:null})]})}return T({currentFields:f,currentValue:i,currentResolvedValue:s,onCurrentValueChange:r,keyPrefix:n})},F7=(n,e,t)=>n==="models"?t("config.editor.newModelSelectorName"):n==="modelServices"?t("config.editor.newModelServiceName"):n==="channels"?t("config.editor.newChannelName"):n==="adapters"?t("config.editor.newAdapterName"):n==="plugins"?t("config.editor.newPluginName"):n==="mcp"?t("config.editor.newMcpServerName"):n==="general"&&e.path.join(".")==="env"?t("config.editor.newEnvVarName"):t("config.editor.fieldKey");function nXe({sectionKey:n,title:e,icon:t,headerLeading:i,fields:s,uiSection:r,value:o,resolvedValue:a,onChange:l,mergedModelServices:c,mergedAdapters:d,selectedModelService:u,worktreeEnvironmentOptions:h,detailQuery:f="",onDetailQueryChange:g,headerExtra:m,t:p,className:_}){const b=["config-view__editor-wrap",_].filter(Boolean).join(" "),y=e!=null||t!=null,w=C.useRef(null),S=C.useRef({}),x=eXe(n,s),L=XCn({fields:x,raw:f}),E=tXe({sectionKey:n,fields:x,value:o,resolvedValue:a,route:L,detailContext:{mergedModelServices:c,mergedAdapters:d,t:p},t:p}),I=GCn(L),M=y||i!=null||m!=null||E!=null,N=["config-view__section-header",y?"":"config-view__section-header--actions-only"].filter(Boolean).join(" "),T=()=>{const F=w.current;F!=null&&(S.current[I]=F.scrollTop)},D=F=>{T(),g==null||g(IR(F))},P=()=>{var F,$;if(T(),(((F=L==null?void 0:L.nestedPath)==null?void 0:F.length)??0)>0&&L!=null){g==null||g(IR({...L,nestedPath:(($=L.nestedPath)==null?void 0:$.slice(0,-1))??[]}));return}g==null||g("")},R=(L==null?void 0:L.nestedPath)??[],A=R.map((F,$)=>{const B=$===0&&F==="accounts"?p("config.accounts.title"):KGe(F),V=$===R.length-1;return{key:`${F}:${$}`,label:B,isCurrent:V,onClick:V?void 0:()=>{L!=null&&(T(),g==null||g(IR({...L,nestedPath:R.slice(0,$+1)})))}}}),O=E==null?[]:[...[{key:"section",label:e},{key:"item",label:E.itemLabel,isCurrent:A.length===0,...A.length>0?{onClick:()=>{T(),g==null||g(IR({...L,nestedPath:[]}))}}:{}}],...A];return C.useLayoutEffect(()=>{const F=w.current;F!=null&&(F.scrollTop=S.current[I]??0)},[I]),v.jsxs("div",{className:b,children:[M&&v.jsxs("div",{className:N,children:[y?E==null?v.jsxs("div",{className:"config-view__section-title",children:[i,t!=null&&v.jsx("span",{className:"material-symbols-rounded config-view__section-icon",children:t}),v.jsx("span",{children:e})]}):v.jsxs("div",{className:"config-view__detail-trail",children:[i,v.jsx(Qe,{title:p("config.detail.back"),children:v.jsx(qe,{size:"small",type:"text",className:"config-view__detail-back","aria-label":p("config.detail.back"),icon:v.jsx("span",{className:"material-symbols-rounded",children:"chevron_left"}),onClick:P})}),v.jsx("div",{className:"config-view__detail-breadcrumb",children:O.map((F,$)=>v.jsxs("span",{className:"config-view__detail-breadcrumb-item",children:[$>0&&v.jsx("span",{className:"config-view__detail-separator","aria-hidden":"true",children:v.jsx("span",{className:"material-symbols-rounded",children:"chevron_right"})}),v.jsx("span",{className:`config-view__detail-crumb ${F.isCurrent===!0?"config-view__detail-crumb--current":"config-view__detail-crumb--static"}`,children:F.label})]},F.key))})]}):null,m!=null&&v.jsx("div",{className:"config-view__section-header-extra",children:m})]}),v.jsx("div",{ref:w,className:"config-view__card",children:v.jsx(d7n,{sectionKey:n,fields:x,uiSection:r,value:o,resolvedValue:a,onChange:l,mergedModelServices:c,mergedAdapters:d,selectedModelService:u,worktreeEnvironmentOptions:h,detailRoute:L,onOpenDetailRoute:D,t:p})})]})}function iXe({value:n,onChange:e,options:t}){const{isTouchInteraction:i}=Mr();return v.jsx("div",{className:"config-view__source-switch",role:"group",children:t.map(s=>{const r=s.value===n;return v.jsx(Qe,{title:i?void 0:s.label,placement:"top",children:v.jsx(qe,{type:"text",size:"small","aria-pressed":r,"aria-label":String(s.label),className:`config-view__source-switch-button ${r?"is-active":""}`,icon:v.jsxs("span",{className:"config-view__source-option","aria-hidden":"true",children:[v.jsx("span",{className:"material-symbols-rounded",children:s.icon}),v.jsx("span",{className:"config-view__source-option-label",children:s.label})]}),onClick:()=>{e(s.value)}})},s.value)})})}const Txe=n=>{const e=n.split("__");return e[e.length-1]||n},u7n=n=>n==null||n.type!=="init"?[]:[{key:"chrome-devtools",labelKey:"chat.toolGroupChromeDevtools",icon:"web_traffic",tools:n.tools.filter(e=>e.startsWith("mcp__ChromeDevtools__"))},{key:"system",labelKey:"chat.toolGroupSystem",icon:"memory",tools:n.tools.filter(e=>!e.startsWith("mcp__ChromeDevtools__"))}].filter(e=>e.tools.length>0),h7n=n=>n==null||n.type!=="init"?[]:(n.assetDiagnostics??[]).filter(e=>e.status==="skipped"),f7n=n=>n==null||n.type!=="init"?[]:n.selectionWarnings??[],g7n=new Set(["sessionId","uuid","leafUuid","adapter","model","version","cwd"]),_Y=n=>{const e=n==null?void 0:n.trim();return e==null||e===""?void 0:e};function m7n({breadcrumb:n,displayTitle:e,roomIconSeed:t,sessionInfo:i,sessionId:s,sessionTitle:r,sessionStatus:o,isStarred:a,isArchived:l,tags:c,lastMessage:d,lastUserMessage:u,activeView:h,isTerminalOpen:f,isWorkspaceDrawerOpen:g,isNewSessionActive:m,modeSwitch:p,moreItems:_,showViewSwitches:b,onCreateSession:y,onOpenSidebar:w,onViewChange:S,onToggleTerminal:x,onToggleWorkspaceDrawer:L}){const{t:E}=ht(),{message:I}=Vs.useApp(),{isCompactLayout:M,isTouchInteraction:N}=Mr(),T=Su(PAe),D=Su(RAe),{searchParams:P,update:R}=Rf({keys:["debug"],omit:{debug:Ke=>Ke===""}}),A=C.useRef(0),O=C.useRef(null),F=P.has("debug"),$=P.get("debug")==="true",B=F,V=s!=null&&s!=="",W=b??V,H=m??!V,U=Ke=>N?void 0:Ke,Z=(i==null?void 0:i.type)==="summary"?i.summary:null,G=_Y(r),q=_Y((i==null?void 0:i.type)==="init"?i.title:void 0),K=G??q,X=e??(V?K??(Z!=null&&Z!==""?Z:u!=null&&u!==""?u:d!=null&&d!==""?d:E("common.newChat")):E("chat.newSessionTitle")),ie=n==null?X:v.jsxs("div",{className:"chat-header-breadcrumb","aria-label":E("agentRoom.sessionBreadcrumbLabel",{roomTitle:n.parentTitle,sessionTitle:X}),children:[v.jsx("button",{type:"button",className:"chat-header-breadcrumb__back","aria-label":n.backLabel,onClick:Ke=>{Ke.stopPropagation(),n.onBack()},children:v.jsx("span",{className:"material-symbols-rounded","aria-hidden":"true",children:"chevron_left"})}),v.jsx("span",{className:"chat-header-breadcrumb__parent",title:n.parentTitle,children:n.parentTitle}),v.jsx("span",{className:"chat-header-breadcrumb__separator","aria-hidden":"true",children:v.jsx("span",{className:"material-symbols-rounded",children:"chevron_right"})}),v.jsx("span",{className:"chat-header-breadcrumb__current",title:X,children:X})]}),se=_Y(t)??X,J=(p==null?void 0:p.mode)==="room"?v.jsx(aOe,{className:"chat-header-room-icon",seed:se}):null,le=n==null&&J!=null?v.jsxs("span",{className:"chat-header-title-content",children:[J,v.jsx("span",{className:"chat-header-title-text",title:X,children:X})]}):ie,be=()=>{R({debug:$?"false":"true"})},ae=[{value:"history",icon:"forum",title:E("chat.viewHistory")},{value:"timeline",icon:"timeline",title:E("chat.viewTimeline")},{value:"settings",icon:"tune",title:E("chat.viewSettings")}],ce=ae.find(Ke=>Ke.value===h)??ae[0],oe=async()=>{if(!(s==null||s===""))try{await f1(s,{isStarred:!a}),I.success(E(a?"common.unstarred":"common.starred"))}catch(Ke){I.error(Ii(Ke,E("common.operationFailed")))}},he=async()=>{if(!(s==null||s===""))try{await f1(s,{isArchived:!l}),I.success(E(l?"common.restored":"common.archived"))}catch(Ke){I.error(Ii(Ke,E("common.operationFailed")))}},ye=[{key:"star",label:E(a?"common.unstar":"common.star"),icon:v.jsx("span",{className:`material-symbols-rounded chat-header-icon ${a?"is-filled":""}`,children:a?"star":"star_border"}),onClick:()=>{oe()}},{key:"archive",label:E(l?"common.restore":"common.archive"),icon:v.jsx("span",{className:"material-symbols-rounded chat-header-icon",children:l?"unarchive":"archive"}),onClick:()=>{he()}}],ke=_??(V?ye:[]),Ce=ke.length>0,Se=ae.map(Ke=>({key:`view:${Ke.value}`,label:Ke.title,icon:v.jsx("span",{className:`material-symbols-rounded chat-header-icon ${h===Ke.value?"is-filled":""}`,children:Ke.icon}),onClick:()=>{S(Ke.value)}})),we=V&&B?[{key:"debug",label:E($?"chat.debugDisable":"chat.debugEnable"),icon:v.jsx("span",{className:`material-symbols-rounded chat-header-icon ${$?"is-filled":""}`,children:"bug_report"}),onClick:be}]:[],ve=[...ke,...B?we:[]],Ee=v.jsx(Qe,{title:U(E("chat.viewTerminal")),children:v.jsx(qe,{type:"text",className:`chat-header-action-button ${f?"is-active":""}`,title:E("chat.viewTerminal"),"aria-label":E("chat.viewTerminal"),onClick:x,icon:v.jsx("span",{className:"chat-header-view-option material-symbols-rounded",children:"terminal"})})}),me=v.jsx(Qe,{title:U(E("chat.workspaceDrawerToggle")),children:v.jsx(qe,{type:"text",className:`chat-header-action-button ${g?"is-active":""}`,title:E("chat.workspaceDrawerToggle"),"aria-label":E("chat.workspaceDrawerToggle"),"aria-pressed":g,onClick:L,icon:v.jsx("span",{className:"chat-header-view-option material-symbols-rounded",children:"view_sidebar"})})}),xe=p==null?void 0:p.mode==="room"?{icon:"chat_bubble",label:E("agentRoom.mode.session"),onClick:p.onOpenSession}:{icon:"forum",label:E("agentRoom.mode.room"),onClick:p.onOpenRoom},Oe=xe==null?null:v.jsx(Qe,{title:U(xe.label),children:v.jsx(qe,{type:"text",className:"chat-header-action-button",title:xe.label,"aria-label":xe.label,onClick:xe.onClick,icon:v.jsx("span",{className:"chat-header-view-option material-symbols-rounded",children:xe.icon})})});C.useEffect(()=>()=>{O.current!=null&&clearTimeout(O.current)},[]);const We=()=>{if(O.current!=null&&clearTimeout(O.current),A.current+=1,A.current>=5){A.current=0,O.current=null,be(),console.log("Session Full Info:",{sessionId:s,sessionTitle:r,isStarred:a,isArchived:l,tags:c,lastMessage:d,lastUserMessage:u,sessionInfo:i});return}O.current=setTimeout(()=>{A.current=0,O.current=null},500)};return v.jsxs("div",{className:`chat-header ${T?"is-collapsed":""} ${D?"is-resizing":""} ${M?"is-compact":""}`,children:[v.jsxs("div",{className:"chat-header-main",children:[M&&v.jsxs("div",{className:"chat-header-leading-actions",children:[w!=null&&v.jsx(Qe,{title:U(E("common.sessions")),children:v.jsx(qe,{type:"text",className:"chat-header-action-button",title:E("common.sessions"),"aria-label":E("common.sessions"),onClick:w,icon:v.jsx("span",{className:"chat-header-view-option material-symbols-rounded",children:"menu"})})}),y!=null&&v.jsx(Qe,{title:U(E("common.newChat")),children:v.jsx(qe,{type:"text",className:`chat-header-action-button ${H?"is-active":""}`,title:E("common.newChat"),"aria-label":E("common.newChat"),onClick:y,icon:v.jsx("span",{className:"chat-header-view-option material-symbols-rounded",children:"edit_square"})})})]}),v.jsx("div",{className:"chat-header-info",children:v.jsx("div",{className:"chat-header-title",onClick:We,children:le})})]}),v.jsx("div",{className:"chat-header-actions",children:M?v.jsxs(v.Fragment,{children:[W&&v.jsx(Qe,{title:U(ce.title),children:v.jsx(Wo,{menu:{items:Se},placement:"bottomRight",trigger:["click"],children:v.jsx(qe,{type:"text",className:"chat-header-action-button",title:ce.title,"aria-label":ce.title,icon:v.jsx("span",{className:"chat-header-view-option material-symbols-rounded",children:ce.icon})})})}),Oe,Ee,me,Ce&&v.jsx(Qe,{title:U(E("common.moreActions")),children:v.jsx(Wo,{menu:{items:ve},placement:"bottomRight",trigger:["click"],children:v.jsx(qe,{type:"text",className:"chat-header-action-button",title:E("common.moreActions"),"aria-label":E("common.moreActions"),icon:v.jsx("span",{className:"chat-header-view-option material-symbols-rounded",children:"more_vert"})})})})]}):v.jsxs(v.Fragment,{children:[W&&ae.map(Ke=>v.jsx(Qe,{title:U(Ke.title),children:v.jsx(qe,{type:"text",className:`chat-header-action-button ${h===Ke.value?"is-active":""}`,title:Ke.title,"aria-label":Ke.title,onClick:()=>{S(Ke.value)},icon:v.jsx("span",{className:"chat-header-view-option material-symbols-rounded",children:Ke.icon})})},Ke.value)),Oe,Ee,me,V&&B&&v.jsx(Qe,{title:U(E($?"chat.debugDisable":"chat.debugEnable")),children:v.jsx(qe,{type:"text",className:`chat-header-action-button ${$?"is-debug-active":""}`,title:E($?"chat.debugDisable":"chat.debugEnable"),"aria-label":E($?"chat.debugDisable":"chat.debugEnable"),onClick:be,icon:v.jsx("span",{className:"chat-header-view-option material-symbols-rounded",children:"bug_report"})})}),Ce&&v.jsx(Qe,{title:U(E("common.moreActions")),children:v.jsx(Wo,{menu:{items:ke},placement:"bottomRight",trigger:["click"],children:v.jsx(qe,{type:"text",className:"chat-header-action-button",title:E("common.moreActions"),"aria-label":E("common.moreActions"),icon:v.jsx("span",{className:"chat-header-view-option material-symbols-rounded",children:"more_vert"})})})})]})})]})}function p7n({session:n,sessionInfo:e,onClose:t}){const{t:i}=ht(),{isCompactLayout:s}=Mr(),{message:r,modal:o}=Vs.useApp(),{searchParams:a}=Rf({keys:["debug"]}),l=a.get("debug")==="true",c=n.id,d=C.useMemo(()=>[{path:["title"],type:"string",defaultValue:"",icon:"edit_note",labelKey:"chat.title",placeholderKey:"chat.enterTitle"},{path:["tags"],type:"string[]",defaultValue:[],icon:"sell",labelKey:"chat.tags"}],[]),u=C.useMemo(()=>({title:n.title??"",tags:n.tags??[]}),[n.tags,n.title]),[h,f]=C.useState(u),[g,m]=C.useState({}),p=C.useRef(u),_=C.useRef(null),b=C.useRef(!1),y=C.useRef(null);C.useEffect(()=>{f(u)},[u]),C.useEffect(()=>{p.current=h},[h]),C.useEffect(()=>()=>{_.current&&clearTimeout(_.current)},[]);const w=C.useMemo(()=>u7n(e),[e]),S=C.useMemo(()=>h7n(e),[e]),x=C.useMemo(()=>f7n(e),[e]);C.useEffect(()=>{!s||w.length===0||m(D=>{const P={...D};let R=!1;for(const A of w)A.key in P||(P[A.key]=!0,R=!0);return R?P:D})},[s,w]);const L=C.useMemo(()=>{const D=i("chat.timelineEmptyValue"),P=O=>i(O?"chat.debugEnabledValue":"chat.debugDisabledValue"),R=n.tags??[],A=[{key:"sessionId",label:i("chat.debugSessionId"),value:n.id,icon:"fingerprint"},{key:"view",label:i("chat.debugView"),value:i("chat.viewSettings"),icon:"tune"},{key:"starred",label:i("chat.debugStarred"),value:P(n.isStarred),icon:"star"},{key:"archived",label:i("chat.debugArchived"),value:P(n.isArchived),icon:"archive"}];return R.length>0&&A.push({key:"tags",label:i("chat.debugTags"),value:R.join(", "),icon:"sell"}),(e==null?void 0:e.type)==="init"&&A.push({key:"type",label:i("chat.debugType"),value:e.type,icon:"deployed_code"},{key:"uuid",label:i("chat.debugUuid"),value:e.uuid,icon:"tag"},{key:"adapter",label:i("chat.debugAdapter"),value:e.adapter??D,icon:"extension"},{key:"model",label:i("chat.debugModel"),value:e.model,icon:"model_training"},{key:"effort",label:i("chat.debugEffort"),value:e.effort??D,icon:"psychology"},{key:"version",label:i("chat.debugVersion"),value:e.version,icon:"deployed_code_update"},{key:"tools",label:i("chat.debugTools"),value:String(e.tools.length),icon:"handyman"},{key:"agents",label:i("chat.debugAgents"),value:String(e.agents.length),icon:"hub"},{key:"cwd",label:i("chat.debugCwd"),value:e.cwd,icon:"folder_open"}),(e==null?void 0:e.type)==="summary"&&A.push({key:"type",label:i("chat.debugType"),value:e.type,icon:"deployed_code"},{key:"leafUuid",label:i("chat.debugLeafUuid"),value:e.leafUuid,icon:"call_split"}),A},[n.id,n.isArchived,n.isStarred,n.tags,e,i]),E=D=>{const P=D.reason==="excluded"?i("chat.selectionWarningReasonExcluded"):i("chat.selectionWarningReasonNotIncluded");return i("chat.selectionWarningFallback",{adapter:D.adapter,requestedModel:D.requestedModel,resolvedModel:D.resolvedModel,reason:P})},I=D=>{const P=JSON.stringify(D??{});y.current!==P&&(_.current&&clearTimeout(_.current),_.current=setTimeout(async()=>{if(b.current)return;const R=p.current,A=JSON.stringify(R??{});if(y.current!==A){b.current=!0;try{await f1(c,{title:typeof R.title=="string"?R.title:"",tags:Array.isArray(R.tags)?R.tags:[]}),y.current=A}catch(O){r.error(Ii(O,i("common.operationFailed")))}finally{b.current=!1}}},500))},M=D=>{const P=D!=null&&typeof D=="object"?D:{},R={title:typeof P.title=="string"?P.title:"",tags:Array.isArray(P.tags)?P.tags.filter(A=>typeof A=="string"):[]};f(R),I(R)},N=()=>{const D=async(P=!1)=>{await Ob(c,{force:P}),r.success(i("common.deleteSuccess")),t()};o.confirm({title:i("common.deleteSession"),content:i("common.deleteSessionConfirm"),okText:i("common.delete"),okType:"danger",cancelText:i("common.cancel"),onOk:async()=>{try{await D()}catch(P){if(P instanceof I5&&P.code==="session_worktree_not_clean"){o.confirm({title:i("chat.sessionWorkspaceForceDeleteTitle"),content:i("chat.sessionWorkspaceForceDeleteDescription"),okText:i("common.delete"),okType:"danger",cancelText:i("common.cancel"),onOk:async()=>{try{await D(!0)}catch(R){r.error(Ii(R,i("common.deleteFailed")))}}});return}r.error(Ii(P,i("common.deleteFailed")))}}})},T=D=>{m(P=>({...P,[D]:!P[D]}))};return v.jsxs("div",{className:"session-settings-drawer",children:[v.jsx(nXe,{sectionKey:"session",title:null,icon:void 0,fields:d,value:h,onChange:M,mergedModelServices:{},mergedAdapters:{},selectedModelService:void 0,t:i,className:"session-settings-drawer__form"}),v.jsxs("div",{className:"settings-section session-runtime-section",children:[v.jsxs("div",{className:"section-header",children:[v.jsx("span",{className:"material-symbols-rounded",children:"build"}),v.jsx("span",{children:i("chat.availableTools")})]}),x.length>0&&v.jsxs("div",{className:"session-info-note-list",children:[v.jsx("div",{className:"session-info-note-list__title",children:i("chat.selectionWarningsTitle")}),x.map((D,P)=>v.jsxs("div",{className:"session-info-note session-info-note--warning",children:[v.jsx("span",{className:"material-symbols-rounded",children:"warning"}),v.jsx("span",{children:E(D)})]},`${D.adapter}:${D.requestedModel}:${D.resolvedModel}:${P}`))]}),S.length>0&&v.jsxs("div",{className:"session-info-note-list",children:[v.jsx("div",{className:"session-info-note-list__title",children:i("chat.assetWarningsTitle")}),S.map(D=>v.jsxs("div",{className:"session-info-note",children:[v.jsx("span",{className:"material-symbols-rounded",children:"warning"}),v.jsxs("div",{className:"session-info-note__content",children:[v.jsx("code",{children:D.assetId}),v.jsx("span",{children:D.reason})]})]},D.assetId))]}),w.length>0?v.jsx("div",{className:"session-tool-groups",children:w.map(D=>v.jsxs("div",{className:"session-tool-group-card",children:[v.jsxs("button",{type:"button",className:"session-tool-group-card__header",onClick:()=>T(D.key),children:[v.jsxs("div",{className:"session-tool-group-card__title",children:[v.jsx("span",{className:"material-symbols-rounded",children:D.icon}),v.jsx("span",{children:i(D.labelKey)})]}),v.jsxs("div",{className:"session-tool-group-card__meta",children:[v.jsx("span",{className:"session-tool-group-card__count",children:D.tools.length}),v.jsx("span",{className:"material-symbols-rounded session-tool-group-card__expand",children:g[D.key]?"expand_more":"expand_less"})]})]}),!g[D.key]&&v.jsx("div",{className:"session-tool-group-card__list",children:D.tools.map(P=>v.jsxs("div",{className:"session-tool-row",title:Txe(P),children:[v.jsx("span",{className:"session-tool-row__dot"}),v.jsx("code",{children:Txe(P)})]},P))})]},D.key))}):v.jsx("div",{className:"session-settings-empty",children:i("chat.availableToolsEmpty")})]}),l&&L.length>0&&v.jsxs("div",{className:"settings-section session-debug-section",children:[v.jsxs("div",{className:"section-header",children:[v.jsx("span",{className:"material-symbols-rounded",children:"bug_report"}),v.jsx("span",{children:i("chat.debugSectionTitle")})]}),v.jsx("div",{className:"session-debug-panel",children:v.jsx("div",{className:"session-debug-list",children:L.map(D=>v.jsxs("div",{className:"session-debug-row",children:[v.jsx("span",{className:"session-debug-row__label",children:D.label}),v.jsx("span",{className:`session-debug-row__value ${g7n.has(D.key)?"is-mono":""}`,children:D.value})]},D.key))})})]}),v.jsx("div",{className:"settings-footer",children:v.jsx("div",{className:"danger-zone",children:v.jsxs("div",{className:"delete-session-row",children:[v.jsxs("div",{className:"delete-session-meta",children:[v.jsx("div",{className:"delete-session-title",children:i("chat.deleteSessionTitle")}),v.jsx("div",{className:"delete-session-desc",children:i("chat.deleteSessionDesc")})]}),v.jsx(qe,{danger:!0,type:"primary",size:"middle",icon:v.jsx("span",{className:"material-symbols-rounded",children:"delete_forever"}),onClick:N,className:"delete-session-btn",children:i("common.delete")})]})})})]})}function C7n({session:n,sessionInfo:e,onClose:t}){return v.jsx("div",{className:"chat-settings-panel",children:v.jsx(p7n,{session:n,sessionInfo:e,onClose:t})})}function _7n(n){return n.replace(/\W/g,"_")}function oh(n){const[e,t,i]=n.split(":").map(Number);return(e||0)*3600+(t||0)*60+(i||0)}function $_(n){const[e,t,i]=n.split(":"),s=r=>{const o=Number.parseInt(r??"0",10);return Number.isFinite(o)?`${o}`.padStart(2,"0"):"00"};return`${s(e)}:${s(t)}:${s(i)}`}function Rxe(){let n=0;return e=>`${e}_${n++}`}const v7n=18,b7n=(n,e,t="")=>{if(n.length+t.length<=e)return`${n}${t}`;const i=Math.max(4,e-t.length-1);return`${n.slice(0,i).trimEnd()}…${t}`};function y7n(n,e,t){const i=Rxe(),s=Rxe(),r=[],o=[],a="​";let l=0;const c=()=>(l+=1,a.repeat(l)),d=m=>{r.push(m)},u=m=>{const p=[{start:m.startTime,end:m.endTime}],_=m.events??[],b=_.findIndex(x=>x.type==="tool__AskUserQuestion");if(b<0)return p;const y=_[b],w=oh(y.startTime)<=oh(y.endTime)?y.startTime:y.endTime,S=oh(y.startTime)<=oh(y.endTime)?y.endTime:y.startTime;return oh(S)<=oh(w)||(p[p.length-1]={start:p[p.length-1].start,end:w},p.push({start:S,end:m.endTime})),p},h=m=>{for(let p=0;p<m.length;p+=1){const _=m[p],{type:b,startTime:y,endTime:w}=_;switch(b){case"tool__StartTasks":{const{tasks:S={}}=_,x=s("section"),L=c();for(const[E,I]of Object.entries(S)){const M=u(I);M.forEach((T,D)=>{const P=i("task"),R=M.length>1?` ·${D+1}`:"",A=t!=null&&t.compact?b7n(E,v7n,R):`${E}${R}`,O={id:P,label:E,payload:{kind:"task",name:E,task:I}};o.push({id:P,label:A,start:$_(T.start),end:$_(T.end),sectionId:x,sectionLabel:L,type:"task",interaction:O}),d(O)});const{events:N=[]}=I;N.length>0&&h(N)}break}}}},f=i("main"),g=s("section");return o.push({id:f,label:e.ganttMainSection,start:$_(n.startTime),end:$_(n.endTime),sectionId:g,sectionLabel:e.ganttMainSection,type:"task"}),h(n.events??[]),{items:o,interactions:r}}function w7n(n){var i;const e=["gantt","dateFormat HH:mm:ss","axisFormat %H:%M:%S"],t=new Map;for(const s of n)t.has(s.sectionId)||t.set(s.sectionId,{label:s.sectionLabel,items:[]}),(i=t.get(s.sectionId))==null||i.items.push(s);for(const s of t.values()){e.push(s.label?`section ${s.label}`:"section");for(const r of s.items)r.end&&e.push(`${r.label} :${r.id}, ${r.start}, ${r.end}`)}return e.join(`
1511
1511
  `)}function S7n(n,e,t){const{items:i,interactions:s}=y7n(n,e,t);return{code:w7n(i),interactions:s}}function x7n(n){if(n)return n.replace(/"/g,"'")}function L7n(n){return{normalizeCommitId:i=>i.replace(/\s+/g,"_"),allocateCommitId:i=>{let s=i,r=1;for(;n.has(s);)s=`${i}_${r}`,r+=1;return n.add(s),s}}}function MR(n,e){switch(e){case"tool__StartTasks":return n.startTasks;case"tool__AskUserQuestion":return n.askUserQuestion;case"tool__Edit":return n.edit;case"tool__ResumeTask":return n.resumeTask;case"user__Prompt":return n.userPrompt;default:return e}}function Pxe(n){switch(n.kind){case"merge":return n.target;case"branch":return n.name;default:return n.branch}}function k7n(n){return[...n].sort((e,t)=>{const i=oh(e.time)-oh(t.time);if(i!==0)return i;if(e.priority!==t.priority)return e.priority-t.priority;const s=Pxe(e),r=Pxe(t);return s!==r?s.localeCompare(r):e.seq-t.seq})}function E7n(n){const e=["gitGraph TB:"],t=new Set,i=new Set,{normalizeCommitId:s,allocateCommitId:r}=L7n(i),o=new Map,a=new Map,l=new Map,c=new Map;let d,u,h=0;const f=[],g=[],m=(N,T)=>{const D=x7n(T);return D?e.push(`commit id:"${N}" tag:"${D}"`):e.push(`commit id:"${N}"`),N},p=(N,T,D,P)=>{if(!d){d={id:N,branch:T,time:D,seq:P};return}const R=oh(D)-oh(d.time);(R>0||R===0&&P>d.seq)&&(d={id:N,branch:T,time:D,seq:P})},_=N=>{let T=N;for(;T;){const D=a.get(T);if(D)return{id:D,branch:l.get(D)??T};const P=c.get(T);if(!P||P===T)break;T=P}},b=N=>{if(N)return _(N);if(d)return{id:d.id,branch:d.branch}},y=(N,T,D,P)=>{const R=s(N),A=r(R);return D!=null&&D.branchName&&typeof D.priority=="number"?(f.push({kind:"commit",time:N,branch:D.branchName,commitId:A,action:T,priority:D.priority,seq:h++}),a.set(D.branchName,A),l.set(A,D.branchName),p(A,D.branchName,N,h-1),P&&g.push({id:A,label:T??A,payload:P}),A):(P&&g.push({id:A,label:T??A,payload:P}),m(A,T))},w=N=>{t.has(N)||(t.add(N),u=N,e.push(`branch ${N}`))},S=N=>{u=N,e.push(`checkout ${N}`)},x=(N,T,D,P)=>{const R=[];T&&R.push(`id:"${T}"`),D&&R.push(`tag:"${D}"`),e.push(`merge ${N} ${R.join(" ")}`),T&&(P!=null&&P.branchName)&&P.time&&typeof P.seq=="number"&&(a.set(P.branchName,T),l.set(T,P.branchName),p(T,P.branchName,P.time,P.seq))},L=(N,T,D,P)=>{f.push({kind:"branch",time:N,baseBranch:T,name:D,priority:P,seq:h++})},E=(N,T,D,P,R,A)=>{const O=s(N),F=r(O);return f.push({kind:"merge",time:N,target:T,source:D,action:P,mergeId:F,priority:R,seq:h++}),A&&g.push({id:F,label:P,payload:A}),F},I="main";return{get curBranch(){return u},labels:n,lines:e,ops:f,interactions:g,commit:m,branch:w,checkout:S,merge:x,addCommit:y,addBranch:L,addMerge:E,ensureBranch:N=>{N!==I&&w(N)},normalizeCommitId:s,allocateCommitId:r,findLatestCommitId:b,resumeCommitIds:o,parentByBranch:c}}function sXe(n,e,t,i){const{labels:s,addCommit:r,addBranch:o,addMerge:a,parentByBranch:l,resumeCommitIds:c}=i;for(const d of n){const{type:u,startTime:h,endTime:f}=d;switch(u){case"tool__StartTasks":{r(h,s.taskStart,{branchName:e,priority:10},{kind:"event",event:d});const{tasks:g={}}=d;for(const[m,p]of Object.entries(g)){const _=_7n(m);l.set(_,e),o(h,e,_,15),r(p.startTime,s.taskStart,{branchName:_,priority:16},{kind:"task",name:m,task:p});const{events:b=[]}=p;b.length>0&&sXe(b,_,e,i),r(p.endTime,s.taskEnd,{branchName:_,priority:60})}r(f,s.allTasksDone,{branchName:e,priority:70});break}case"tool__AskUserQuestion":r(h,s.askUserQuestion,{branchName:e,priority:20},{kind:"event",event:d}),a(f,t,e,s.userAnswer,80,{kind:"event",event:d});break;case"tool__Edit":r(h,MR(s,u),{branchName:e,priority:30},{kind:"event",event:d});break;case"tool__ResumeTask":{const g=r(h,MR(s,u),{branchName:e,priority:40},{kind:"event",event:d});c.set(e,g);break}case"user__Prompt":a(h,e,"<prev_branch>",MR(s,u),50,{kind:"event",event:d});break;default:r(f,MR(s,u),{branchName:e,priority:55},{kind:"event",event:d});break}}}function I7n(n){const e=k7n(n.ops);for(const t of e)switch(t.kind){case"commit":n.ensureBranch(t.branch),n.checkout(t.branch),n.commit(t.commitId,t.action);break;case"branch":n.checkout(t.baseBranch),n.ensureBranch(t.name);break;case"merge":{t.source==="<prev_branch>"&&(t.source=n.curBranch),n.ensureBranch(t.target),n.ensureBranch(t.source),n.checkout(t.target),n.merge(t.source,t.mergeId,t.action,{branchName:t.target,time:t.time,seq:t.seq});break}}}function M7n(n,e,t){const i=E7n(e),s="main";return i.checkout(s),i.addCommit(n.startTime,e.mainStart),sXe(n.events??[],s,s,i),I7n(i),i.checkout(s),i.addCommit(n.endTime,e.mainEnd),{code:i.lines.join(`
1512
- `),interactions:i.interactions}}const N7n=(n,e)=>e?{...n,mainStart:"启动",mainEnd:"结束",startTasks:"任务",allTasksDone:"完成",askUserQuestion:"提问",resumeTask:"继续",userPrompt:"提示",userAnswer:"回答",receiveReply:"回复",taskStart:"开始",taskEnd:"结束",ganttMainSection:"主"}:{...n,mainStart:"Start",mainEnd:"End",startTasks:"Tasks",allTasksDone:"Done",askUserQuestion:"Ask",resumeTask:"Resume",userPrompt:"Prompt",userAnswer:"Answer",receiveReply:"Reply",taskStart:"Start",taskEnd:"End",ganttMainSection:"Main"};function NR(n){const{task:e,viewMode:t,className:i,style:s}=n,r=te.useRef(null),{t:o,i18n:a}=ht(),{isCompactLayout:l}=Mr(),c=te.useMemo(()=>({mainStart:o("chat.timeline.mainStart"),mainEnd:o("chat.timeline.mainEnd"),startTasks:o("chat.timeline.startTasks"),allTasksDone:o("chat.timeline.allTasksDone"),askUserQuestion:o("chat.timeline.askUserQuestion"),edit:o("chat.timeline.edit"),resumeTask:o("chat.timeline.resumeTask"),userPrompt:o("chat.timeline.userPrompt"),userAnswer:o("chat.timeline.userAnswer"),receiveReply:o("chat.timeline.receiveReply"),taskStart:o("chat.timeline.taskStart"),taskEnd:o("chat.timeline.taskEnd"),ganttTitle:o("chat.timeline.ganttTitle"),ganttMainSection:o("chat.timeline.ganttMainSection"),ganttTasksSection:o("chat.timeline.ganttTasksSection")}),[o]),d=te.useMemo(()=>{var p;return l?N7n(c,((p=a.resolvedLanguage)==null?void 0:p.startsWith("zh"))===!0):c},[a.resolvedLanguage,l,c]),u=te.useMemo(()=>t==="gantt"?S7n(e,d,{compact:l}):M7n(e,d),[d,l,e,t]),h=te.useId(),f=te.useMemo(()=>h.replace(/\W/g,"_"),[h]),g=te.useRef(new Map),m=te.useMemo(()=>u.code,[u.code]);return te.useEffect(()=>{let p=!1;return(async()=>{const y=(await re(()=>import("./mermaid.core-BG9PyDfl.js").then(I=>I.b5),[])).default,w=getComputedStyle(document.body).fontFamily;if(y.initialize({startOnLoad:!1,securityLevel:"loose",themeVariables:{fontFamily:w,fontSize:l?"12px":"14px"},gitGraph:l?{rotateCommitLabel:!1,showBranches:!1}:{},gantt:{topAxis:!0,displayMode:"compact",gridLineStartPadding:0,leftPadding:l?8:16,rightPadding:l?8:16,topPadding:l?28:36,barHeight:l?16:20,barGap:l?3:4,fontSize:l?10:11,sectionFontSize:l?10:11}}),p)return;const S=r.current;if(!S)return;const{svg:x,bindFunctions:L}=await y.render(f,m);if(p)return;S.innerHTML=x;const E=S.querySelector("svg");if(E){E.classList.add("session-timeline-mermaid__svg");for(const I of u.interactions){const M=E.querySelector(`#${CSS.escape(I.id)}`);M&&(M.classList.add("session-timeline-mermaid__interactive"),M.addEventListener("click",()=>{const N=g.current.get(I.id);N&&console.warn(N.payload)}))}}typeof L=="function"&&L(S)})(),()=>{p=!0}},[u.interactions,l,m,f]),te.useEffect(()=>{g.current=new Map(u.interactions.map(p=>[p.id,{label:p.label,payload:p.payload}]))},[u.interactions]),v.jsx("div",{ref:r,className:["session-timeline-panel",`session-timeline-panel--${t}`,l?"session-timeline-panel--compact":"",i??""].filter(Boolean).join(" "),style:s})}const D7n=(n,e)=>{const t=[];let i=0;const s=(o,a,l,c,d)=>{t.push({id:`${o}-${a}-${l}-${i}`,label:o,startTime:a,endTime:l,depth:c,payload:d}),i+=1},r=(o,a)=>{for(const l of o)l.type==="tool__StartTasks"?s(e.startTasks,l.startTime,l.endTime,a,l):l.type==="tool__AskUserQuestion"?s(e.askUserQuestion,l.startTime,l.endTime,a,l):l.type==="tool__Edit"?s(e.edit,l.startTime,l.endTime,a,l):l.type==="tool__ResumeTask"?s(e.resumeTask,l.startTime,l.endTime,a,l):l.type==="user__Prompt"&&s(e.userPrompt,l.startTime,l.endTime,a,l)};return s(e.mainStart,n.startTime,n.startTime,0),r(n.events??[],0),s(e.mainEnd,n.endTime,n.endTime,0),t.map((o,a)=>({...o,index:a})).sort((o,a)=>{const l=oh(o.startTime)-oh(a.startTime);return l!==0?l:o.index-a.index}).map(({index:o,...a})=>a)};function Axe({task:n}){const{t:e}=ht(),{isCompactLayout:t}=Mr(),[i,s]=te.useState(""),r=te.useRef(null),[o,a]=te.useState(240),l=te.useMemo(()=>({mainStart:e("chat.timeline.mainStart"),mainEnd:e("chat.timeline.mainEnd"),startTasks:e("chat.timeline.startTasks"),askUserQuestion:e("chat.timeline.askUserQuestion"),edit:e("chat.timeline.edit"),resumeTask:e("chat.timeline.resumeTask"),userPrompt:e("chat.timeline.userPrompt")}),[e]),c=te.useMemo(()=>D7n(n,l),[l,n]),d=te.useMemo(()=>{const g=i.trim().toLowerCase();return g?c.filter(m=>`${m.label} ${m.startTime} ${m.endTime}`.toLowerCase().includes(g)):c},[c,i]),u=e("chat.timelineEmptyValue"),h=te.useCallback(g=>{const m=$_(g.startTime),p=$_(g.endTime);return v.jsx("span",{className:"session-timeline-event-table__time",children:m===p?m:`${m} → ${p}`})},[]),f=te.useMemo(()=>t?[{title:e("chat.timelineEventName"),key:"summary",render:(g,m)=>{const p=[{key:e("chat.timelineInput"),value:m.input},{key:e("chat.timelineOutput"),value:m.output}].filter(_=>_.value!=null&&_.value!=="");return v.jsxs("div",{className:"session-timeline-event-table__summary",children:[v.jsx("span",{className:"session-timeline-event-table__label",style:{paddingLeft:`${m.depth*12}px`},children:m.label}),p.length>0&&v.jsx("div",{className:"session-timeline-event-table__detail-list",children:p.map(_=>v.jsxs("span",{className:"session-timeline-event-table__detail-item",children:[v.jsx("span",{className:"session-timeline-event-table__detail-key",children:_.key}),v.jsx("span",{className:"session-timeline-event-table__detail-text",children:_.value})]},_.key))})]})}},{title:e("chat.timelineTiming"),key:"time",width:120,render:(g,m)=>v.jsx("span",{className:"session-timeline-event-table__cell-timing",children:h(m)})}]:[{title:e("chat.timelineEventName"),key:"label",width:180,render:(g,m)=>v.jsx("span",{className:"session-timeline-event-table__label",style:{paddingLeft:`${m.depth*16}px`},children:m.label})},{title:e("chat.timelineInput"),key:"input",width:180,render:(g,m)=>v.jsx("span",{className:"session-timeline-event-table__value",children:m.input??u})},{title:e("chat.timelineOutput"),key:"output",width:180,render:(g,m)=>v.jsx("span",{className:"session-timeline-event-table__value",children:m.output??u})},{title:e("chat.timelineTiming"),key:"time",width:160,render:(g,m)=>h(m)}],[u,t,h,e]);return te.useEffect(()=>{const g=r.current;if(!g)return;const m=()=>{const _=g.querySelector(".session-timeline-event-table__header"),b=g.querySelector(".ant-table-pagination"),y=(_==null?void 0:_.offsetHeight)??0,w=(b==null?void 0:b.offsetHeight)??0,S=Math.max(160,g.clientHeight-y-w-16);a(x=>x===S?x:S)};m();const p=new ResizeObserver(m);return p.observe(g),()=>{p.disconnect()}},[]),v.jsxs("div",{ref:r,className:"session-timeline-event-table",children:[v.jsxs("div",{className:"session-timeline-event-table__header",children:[v.jsx("span",{className:"session-timeline-event-table__title",children:e("chat.timeline.eventListTitle")}),v.jsx(yn,{className:"session-timeline-event-table__search",allowClear:!0,value:i,onChange:g=>s(g.target.value),placeholder:e("chat.timeline.eventListSearch")})]}),v.jsx(Df,{className:"session-timeline-event-table__table",size:"small",columns:f,dataSource:d,rowKey:"id",onRow:g=>({onClick:()=>{g.payload&&console.warn(g.payload)}}),pagination:{pageSize:20,showSizeChanger:!t,pageSizeOptions:["10","20","50"]},scroll:{y:o},locale:{emptyText:e("chat.timelineEmpty")}})]})}const B7={startTime:"09:40:00",endTime:"11:30:48",events:[{type:"tool__StartTasks",startTime:"09:41:02",endTime:"10:10:25",tasks:{taskA:{startTime:"09:41:10",endTime:"09:55:02",description:"Task A"},taskB:{startTime:"09:41:10",endTime:"09:50:40",description:"Task B"},taskC:{startTime:"09:41:10",endTime:"10:10:20",description:"Task C",events:[{type:"tool__StartTasks",startTime:"09:48:00",endTime:"10:05:30",tasks:{taskC0:{startTime:"09:49:10",endTime:"10:05:25",events:[{type:"tool__AskUserQuestion",startTime:"09:57:00",endTime:"09:59:23"},{type:"user__Prompt",startTime:"09:58:10",endTime:"09:58:20"}]}}},{type:"tool__Edit",startTime:"09:57:10",endTime:"09:59:20"},{type:"tool__ResumeTask",startTime:"09:59:22",endTime:"10:05:30"}]}}},{type:"tool__StartTasks",startTime:"10:41:02",endTime:"11:10:25",tasks:{taskA1:{startTime:"10:41:10",endTime:"10:55:02",description:"Task A1"},taskB1:{startTime:"10:41:10",endTime:"10:50:40",description:"Task B1"},taskC1:{startTime:"10:41:10",endTime:"11:10:20",description:"Task C1",events:[{type:"tool__StartTasks",startTime:"10:48:00",endTime:"11:05:30",tasks:{taskC10:{startTime:"10:49:10",endTime:"11:05:25",events:[{type:"tool__AskUserQuestion",startTime:"10:57:00",endTime:"10:59:23"},{type:"user__Prompt",startTime:"10:58:10",endTime:"10:58:20"}]}}},{type:"tool__Edit",startTime:"10:57:10",endTime:"10:59:20"},{type:"tool__ResumeTask",startTime:"10:59:22",endTime:"11:05:30"}]}}}]};function T7n({messages:n}){const{t:e}=ht(),{isCompactLayout:t}=Mr(),[i,s]=te.useState("events");if(t){const r=[{key:"events",label:e("chat.timeline.eventListTitle")},{key:"gantt",label:e("chat.timeline.viewGantt")},{key:"git",label:e("chat.timeline.viewGit")}];return v.jsxs("div",{className:"chat-timeline-view chat-timeline-view--compact",children:[v.jsx("div",{className:"chat-timeline-view__tabs",role:"tablist","aria-label":e("chat.timelineTiming"),children:r.map(o=>v.jsx("button",{type:"button",role:"tab","aria-selected":i===o.key,className:`chat-timeline-view__tab ${i===o.key?"is-active":""}`,onClick:()=>s(o.key),children:o.label},o.key))}),v.jsxs("section",{className:`chat-timeline-view__panel ${i==="events"?"chat-timeline-view__panel--events":"chat-timeline-view__panel--diagram"}`,children:[i==="events"&&v.jsx(Axe,{task:B7}),i==="gantt"&&v.jsx(NR,{task:B7,viewMode:"gantt"}),i==="git"&&v.jsx(NR,{task:B7,viewMode:"git"})]})]})}return v.jsxs("div",{className:"chat-timeline-view",children:[v.jsx("section",{className:"session-timeline-section session-timeline-section--fixed",children:v.jsx(NR,{task:B7,viewMode:"gantt"})}),v.jsxs("section",{className:"session-timeline-section session-timeline-section--flex session-timeline-section--row",children:[v.jsx("div",{className:"session-timeline-column session-timeline-column--graph",children:v.jsx(NR,{task:B7,viewMode:"git"})}),v.jsx("div",{className:"session-timeline-column session-timeline-column--events",children:v.jsx(Axe,{task:B7})})]})]})}const Oxe=(n,e=!1)=>({icon:"settings_suggest",id:e?"mock-model-unavailable":"model-unavailable",isMock:e,message:n("chat.modelConfigRequired"),detail:n("chat.modelConfigRequiredHelp"),tone:"warning",title:n("chat.modelConfigRequiredTitle")}),vY=(n,e,t=!1)=>{const i=e.reason==="closed";return{action:t?void 0:"retry-connection",detail:n(i?"chat.connectionClosedHelp":"chat.connectionErrorHelp"),icon:i?"wifi_off":"cloud_off",id:t?i?"mock-connection-closed":"mock-connection-error":i?"connection-closed":"connection-error",isMock:t,message:e.message,tone:"error",title:n(i?"chat.connectionClosedTitle":"chat.connectionErrorTitle")}},Fxe=(n,e,t=!1)=>{const i=e.action==="retry-session-creation";return{...t||e.action==null?{}:{action:e.action},detail:n(i?"chat.sessionCreateFailedHelp":"chat.sessionErrorHelp"),icon:"error",id:t?"mock-session-error":i?"session-create-failed":"session-error",isMock:t,message:e.message,...!i&&e.code!=null&&e.code!==""?{meta:n("chat.sessionErrorCode",{code:e.code})}:{},tone:"error",title:n(i?"chat.sessionCreateFailedTitle":"chat.sessionErrorTitle")}},R7n=({errorState:n,isDebugMode:e,modelUnavailable:t,t:i})=>{const s=[],r=new Set;if(t&&(s.push(Oxe(i)),r.add("model-unavailable")),n!=null&&n.message.trim()!==""&&(n.kind==="session"?(s.push(Fxe(i,n)),r.add("session-error")):(s.push(vY(i,n)),r.add(n.reason==="closed"?"connection-closed":"connection-error"))),!e)return s;const o=[{scenario:"connection-error",notice:vY(i,{message:i("chat.debugMockConnectionErrorMessage"),reason:"error"},!0)},{scenario:"connection-closed",notice:vY(i,{message:i("chat.debugMockConnectionClosedMessage"),reason:"closed"},!0)},{scenario:"session-error",notice:Fxe(i,{message:i("chat.debugMockSessionErrorMessage"),code:"session_timeout"},!0)},{scenario:"model-unavailable",notice:Oxe(i,!0)}];for(const a of o)r.has(a.scenario)||s.push(a.notice);return s};function P7n({activeView:n,setActiveView:e,targetMessageId:t,targetToolUseId:i}){const s=C.useRef(""),r=i!=null&&i.trim()?`tool:${i.trim()}`:t!=null&&t.trim()?`message:${t.trim()}`:"";C.useEffect(()=>{r===""?s.current="":s.current!==r&&(s.current=r,n!=="history"&&e("history"))},[n,r,e])}const cK=n=>n!=null&&typeof n=="object"&&!Array.isArray(n)?n:{},rXe=n=>Array.isArray(n)?n.map(e=>hi(e)).filter(e=>!!e):[],hi=n=>typeof n=="string"&&n.trim()!==""?n.trim():void 0,xH=n=>n==="low"||n==="medium"||n==="high"||n==="max"?n:void 0,A7n=n=>{if(typeof n=="string"){const e=hi(n);return e?[e]:[]}return Array.isArray(n)?Array.from(new Set(n.map(e=>hi(e)).filter(e=>!!e))):[]},aM=(n,e)=>`${n},${e}`,hC=n=>{const e=hi(n);if(!e||!e.includes(","))return;const[t,i]=e.split(/,(.+)/),s=hi(t),r=hi(i);if(!(!s||!r))return{serviceKey:s,modelName:r,selectorValue:aM(s,r)}},oXe=n=>{const e=[];for(const[t,i]of Object.entries(n)){const s=hi(t);if(!s)continue;const r=i!=null&&typeof i=="object"?i:void 0,o=Array.isArray(r==null?void 0:r.models)?r.models:[];for(const a of o){const l=hi(a);l&&e.push({serviceKey:s,model:l,selectorValue:aM(s,l)})}}return e},O7n=(n,e,t)=>n.find(i=>i.serviceKey===e&&i.model===t),Nce=n=>{var r;const e=hi(n.value);if(!e)return;const t=hC(e);if(t){const o=O7n(n.serviceModels,t.serviceKey,t.modelName);return o?o.selectorValue:void 0}const i=n.serviceModels.filter(o=>o.model===e);if(i.length===0)return;const s=hi(n.preferredServiceKey);if(s){const o=i.find(a=>a.serviceKey===s);if(o)return o.selectorValue}return(r=i[0])==null?void 0:r.selectorValue},q2e=n=>{const e=hi(n.value);if(!e)return;const t=new Set(Array.from(n.builtinModels??[]).map(r=>hi(r)).filter(r=>!!r));if(t.has(e))return e;const i=Nce({value:e,serviceModels:n.serviceModels,preferredServiceKey:n.preferredServiceKey});if(i)return i;const s=hC(e);return s!=null&&s.modelName&&t.has(s.modelName)?s.modelName:n.preserveUnknown===!1?void 0:e},F7n=n=>{var s;const e=Array.from(n.builtinModels??[]).map(r=>hi(r)).filter(r=>!!r),t=hi(n.defaultModel);if(t){const r=hC(t),o=q2e({value:t,builtinModels:e,serviceModels:n.serviceModels,preferredServiceKey:(r==null?void 0:r.serviceKey)??n.defaultModelService,preserveUnknown:n.preserveUnknownDefaultModel});if(o)return o}const i=hi(n.defaultModelService);if(i){const r=n.serviceModels.find(o=>o.serviceKey===i);if(r)return r.selectorValue}return e.length>0?e[0]:(s=n.serviceModels[0])==null?void 0:s.selectorValue},aXe=n=>{var s;const e=hi(n.model);if(!e)return;const t=hC(e),i=t==null?[e]:[t.selectorValue,t.modelName,t.serviceKey];for(const r of i){const o=(s=n.models)==null?void 0:s[r];if(o!=null&&typeof o=="object"&&!Array.isArray(o))return o}},B7n=n=>{var s;const e=hi(n.model);if(!e)return;const t=hC(e),i=t==null?[e]:[t.selectorValue,t.modelName];for(const r of i){const o=(s=n.models)==null?void 0:s[r];if(o!=null&&typeof o=="object"&&!Array.isArray(o))return o}},G2e=n=>{const e=B7n(n);if(!e)return;const t=A7n(e.alias),i=hi(e.title),s=hi(e.description);if(!(t.length===0&&!i&&!s))return{aliases:t,title:i,description:s}},$7n=n=>{var e;return hi((e=aXe(n))==null?void 0:e.defaultAdapter)},H7n=n=>{var e;return xH((e=aXe(n))==null?void 0:e.effort)},X2e=n=>{const e=cK(n);return hi(e.defaultModel)??hi(e.model)},V7n=n=>xH(cK(n).effort),Bxe=n=>rXe(cK(n).includeModels),$xe=n=>rXe(cK(n).excludeModels),lXe=n=>{const e=X2e(n.adapterConfig);return q2e({value:e,builtinModels:n.builtinModels,serviceModels:n.serviceModels,preferredServiceKey:n.preferredServiceKey,preserveUnknown:n.preserveUnknown})},j7n=n=>{const e=xH(n.explicitEffort);if(e!=null)return{effort:e,source:"explicit"};const t=H7n({model:n.model,models:n.models});if(t!=null)return{effort:t,source:"model"};const i=V7n(n.adapterConfig);if(i!=null)return{effort:i,source:"adapter"};const s=xH(n.configEffort);return s!=null?{effort:s,source:"config"}:{effort:void 0,source:void 0}},Hxe=n=>{const e=hi(n.model),t=hi(n.selector);if(!e||!t)return!1;const i=hC(e),s=hC(t);return i?s?i.serviceKey===s.serviceKey&&i.modelName===s.modelName:i.serviceKey===t||i.modelName===t||e===t:e===t},Vxe=n=>{const e=hi(n.model);if(!e||e==="default")return{allowed:!0,includeModels:Bxe(n.adapterConfig),excludeModels:$xe(n.adapterConfig)};const t=Bxe(n.adapterConfig),i=$xe(n.adapterConfig),s=e===X2e(n.adapterConfig);return i.some(r=>Hxe({model:e,selector:r}))?{allowed:!1,reason:"excluded",includeModels:t,excludeModels:i}:!s&&t.length>0&&!t.some(r=>Hxe({model:e,selector:r}))?{allowed:!1,reason:"not_included",includeModels:t,excludeModels:i}:{allowed:!0,includeModels:t,excludeModels:i}},Dce=n=>{const e=hi(n.model);if(!e)return{model:e};const t=Vxe({model:e,adapterConfig:n.adapterConfig});if(t.allowed)return{model:e};const i=lXe({adapterConfig:n.adapterConfig,builtinModels:n.builtinModels,serviceModels:n.serviceModels,preferredServiceKey:n.preferredServiceKey,preserveUnknown:n.preserveUnknownDefaultModel});if(!i)return{error:{type:"missing_default_model",adapter:n.adapter,requestedModel:e,defaultModel:X2e(n.adapterConfig),reason:t.reason??"not_included",includeModels:t.includeModels.length>0?t.includeModels:void 0,excludeModels:t.excludeModels.length>0?t.excludeModels:void 0}};const s=Vxe({model:i,adapterConfig:n.adapterConfig});return s.allowed?{model:i,warning:{type:"adapter_model_fallback",adapter:n.adapter,requestedModel:e,resolvedModel:i,reason:t.reason??"not_included",includeModels:t.includeModels.length>0?t.includeModels:void 0,excludeModels:t.excludeModels.length>0?t.excludeModels:void 0}}:{error:{type:"default_model_not_allowed",adapter:n.adapter,requestedModel:e,defaultModel:i,reason:s.reason??"not_included",includeModels:s.includeModels.length>0?s.includeModels:void 0,excludeModels:s.excludeModels.length>0?s.excludeModels:void 0}}},Y2e=n=>{var e;return hi((e=n.service)==null?void 0:e.title)??n.serviceKey},cXe=n=>q2e({value:n.value,builtinModels:n.builtinModels,serviceModels:n.serviceModels,preferredServiceKey:n.defaultModelService,preserveUnknown:n.preserveUnknown}),Q2e=n=>F7n({defaultModel:n.defaultModel,defaultModelService:n.defaultModelService,builtinModels:n.builtinModels,serviceModels:n.serviceModels,preserveUnknownDefaultModel:n.preserveUnknownDefaultModel}),J2e=n=>{const e=hi(n.value),t=Array.from(n.availableAdapters),i=new Set(t),s=hi(n.defaultAdapter);return e&&(i.has(e)||n.preserveUnknown===!0)?e:s&&i.has(s)?s:t[0]},W7n=(n,e)=>{const t=hi(n);return t?Object.entries(e).filter(([,i])=>Array.isArray(i)&&i.some(s=>(s==null?void 0:s.value)===t)).map(([i])=>i):[]},z7n=n=>{const e=Array.from(n.availableAdapters),t=new Set(e),i=$7n({model:n.model,models:n.modelMetadata});if(i&&t.has(i))return i;const s=W7n(n.model,n.adapterBuiltinModels??{}),r=hi(n.defaultAdapter);return r&&s.includes(r)?r:s.length>0?s[0]:J2e({availableAdapters:e,defaultAdapter:n.defaultAdapter})},dXe=n=>{var t;const e=lXe({adapterConfig:n.adapter!=null?(t=n.adapters)==null?void 0:t[n.adapter]:void 0,builtinModels:n.builtinModels,serviceModels:n.serviceModels,preferredServiceKey:n.defaultModelService,preserveUnknown:!1});return e||Q2e({defaultModel:n.defaultModel,defaultModelService:n.defaultModelService,builtinModels:n.builtinModels??n.fallbackBuiltinModels,serviceModels:n.serviceModels,preserveUnknownDefaultModel:!1})},uXe="vf_chat_adapter_account:",U7n=n=>{const e=hi(n.label)??hi(n.id.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim().replace(/\b\w/g,i=>i.toUpperCase())),t=hi(n.value);return e!=null&&t!=null?`${e}: ${t}`:t??e},K7n=n=>{const e=((n==null?void 0:n.metrics)??[]).slice().sort((i,s)=>+(s.primary===!0)-+(i.primary===!0)).map(U7n).filter(i=>i!=null&&i!=="");if(e.length>0)return e.slice(0,2).join(" · ");const t=hi(n==null?void 0:n.summary);return t==null?void 0:`Quota: ${t}`},jxe=n=>{const e=hi(n);if(e!=null)try{const t=localStorage.getItem(`${uXe}${e}`);return t==null||t.trim()===""?void 0:t.trim()}catch{return}};function Z7n({adapter:n,model:e}){const t=hi(n),[i,s]=C.useState(()=>jxe(n));C.useEffect(()=>{s(jxe(t))},[t]);const{data:r}=Gn(t==null?null:["/api/adapters",t,e??""],t==null?null:()=>G3e(t,{model:e})),o=C.useMemo(()=>((r==null?void 0:r.accounts)??[]).filter(d=>d.status!=="missing").map(d=>({value:d.key,label:d.title,hint:d.description,meta:K7n(d.quota)})),[r==null?void 0:r.accounts]),a=C.useCallback((d,u=!1)=>{var m;const h=hi(d),f=new Set(o.map(p=>p.value));if(h!=null&&(f.has(h)||u))return h;const g=hi(r==null?void 0:r.defaultAccount);return g!=null&&f.has(g)?g:(m=o[0])==null?void 0:m.value},[o,r==null?void 0:r.defaultAccount]);C.useEffect(()=>{if(t==null){s(void 0);return}const d=a(i);s(u=>u===d?u:d)},[t,a,i]),C.useEffect(()=>{if(t!=null)try{const d=`${uXe}${t}`;i==null||i.trim()===""?localStorage.removeItem(d):localStorage.setItem(d,i)}catch{}},[t,i]);const l=C.useCallback(d=>{const u=a(d.account,!0)??hi(d.account);s(h=>h===u?h:u)},[a]),c=C.useCallback(d=>{const u=a(d);s(h=>h===u?h:u)},[a]);return{accountOptions:o,selectedAccount:a(i,!0)??i,setSelectedAccount:c,applySessionSelection:l,showAccountSelector:t!=null&&o.length>0}}const Wxe="vf_chat_effort",zxe=n=>n==="default"||n==="low"||n==="medium"||n==="high"||n==="max";function hXe(){const[n,e]=C.useState("default"),t=s=>{if(s!=null&&zxe(s)){e(s);return}e("default")};C.useEffect(()=>{try{const s=localStorage.getItem(Wxe);s&&zxe(s)&&t(s)}catch{}},[]),C.useEffect(()=>{try{localStorage.setItem(Wxe,n)}catch{}},[n]);const i=C.useMemo(()=>[{value:"default",label:"默认"},{value:"low",label:"低"},{value:"medium",label:"中"},{value:"high",label:"高"},{value:"max",label:"最高"}],[]);return{effort:n,setEffort:t,effortOptions:i}}function q7n({sessionId:n}){const[e,t]=C.useState(null),i=C.useCallback((s,r)=>{n&&kvt(n,s,r).then(()=>{t(o=>(o==null?void 0:o.id)===s?null:o)}).catch(o=>{console.error("Failed to submit interaction response:",o)})},[n]);return{interactionRequest:e,setInteractionRequest:t,handleInteractionResponse:i}}const G7n=n=>[...n].sort((e,t)=>{const i=e.displayLabel.localeCompare(t.displayLabel,void 0,{sensitivity:"base"});if(i!==0)return i;const s=e.modelName.localeCompare(t.modelName,void 0,{sensitivity:"base"});return s!==0?s:e.value.localeCompare(t.value,void 0,{sensitivity:"base"})}),e0e=n=>{var s;const e=(s=n.description)==null?void 0:s.trim(),t=Array.from(new Set((n.aliases??[]).filter(Boolean))),i=[...t.filter(r=>r!==n.title),n.modelName!==n.title?n.modelName:void 0,e].filter(r=>!!r);return{value:n.value,title:n.title,description:e,aliases:t,modelName:n.modelName,tooltipLines:i,serviceKey:n.serviceKey,serviceTitle:n.serviceTitle,searchText:[n.title,n.modelName,n.value,n.serviceTitle,n.serviceKey,e,...t,...n.searchTerms??[]].filter(Boolean).join(" "),displayLabel:n.title}},X7n=n=>Object.entries(n.mergedModelServices).map(([e,t])=>{var a;const i=t!=null&&typeof t=="object"?t:void 0,s=Y2e({serviceKey:e,service:i}),r=(s==null?void 0:s.trim())!==""?s:e,o=Array.isArray(i==null?void 0:i.models)?i.models.filter(l=>typeof l=="string"):[];return o.length===0?null:{key:`service:${e}`,title:r,description:((a=i==null?void 0:i.description)==null?void 0:a.trim())||void 0,options:o.map(l=>{const c=aM(e,l),d=G2e({model:c,models:n.mergedModels});return e0e({value:c,title:(d==null?void 0:d.title)??(d==null?void 0:d.aliases[0])??l,modelName:l,description:d==null?void 0:d.description,aliases:d==null?void 0:d.aliases,serviceKey:e,serviceTitle:s,searchTerms:[l,...(d==null?void 0:d.aliases)??[],d==null?void 0:d.title]})})}}).filter(e=>e!=null),Y7n=n=>Object.entries(n.activeBuiltinModels).map(([e,t])=>!Array.isArray(t)||t.length===0?null:{key:`builtin:${e}`,title:n.builtinGroupTitle(e),options:t.map(i=>{const s=G2e({model:i.value,models:n.mergedModels});return e0e({value:i.value,title:(s==null?void 0:s.title)??(s==null?void 0:s.aliases[0])??i.title,modelName:i.value,description:(s==null?void 0:s.description)??i.description,aliases:s==null?void 0:s.aliases,searchTerms:[i.value,...(s==null?void 0:s.aliases)??[],s==null?void 0:s.title]})})}).filter(e=>e!=null),Q7n=n=>n.recommendedModels.filter(e=>e.placement&&e.placement!=="modelSelector"?!1:Nce({value:e.service?aM(e.service,e.model):e.model,serviceModels:n.availableServiceModels,preferredServiceKey:e.service??n.defaultModelService})!=null).map(e=>{var c,d,u,h;const t=e.service?n.mergedModelServices[e.service]:void 0,i=e.service?Y2e({serviceKey:e.service,service:t}):(c=n.modelToService.get(e.model))==null?void 0:c.title,s=e.service?aM(e.service,e.model):e.model,r=G2e({model:s,models:n.mergedModels}),o=(d=e.title)==null?void 0:d.trim(),a=(u=e.description)==null?void 0:u.trim(),l=Nce({value:s,serviceModels:n.availableServiceModels,preferredServiceKey:e.service??n.defaultModelService})??e.model;return e0e({value:l,title:o||(r==null?void 0:r.title)||(r==null?void 0:r.aliases[0])||e.model,modelName:e.model,description:a||(r==null?void 0:r.description),aliases:r==null?void 0:r.aliases,serviceKey:e.service??((h=n.modelToService.get(e.model))==null?void 0:h.key),serviceTitle:i,searchTerms:[e.model,...(r==null?void 0:r.aliases)??[],r==null?void 0:r.title]})}),fXe=n=>{const e=new Map;for(const u of n.availableServiceModels){const h=n.mergedModelServices[u.serviceKey],f=Y2e({serviceKey:u.serviceKey,service:h});e.has(u.model)||e.set(u.model,{key:u.serviceKey,title:f})}const t=X7n({mergedModelServices:n.mergedModelServices,mergedModels:n.mergedModels}),i=Y7n({activeBuiltinModels:n.activeBuiltinModels,builtinGroupTitle:n.builtinGroupTitle,mergedModels:n.mergedModels}),s=Q7n({availableServiceModels:n.availableServiceModels,defaultModelService:n.defaultModelService,mergedModels:n.mergedModels,mergedModelServices:n.mergedModelServices,recommendedModels:n.recommendedModels,modelToService:e}),r=t.map(u=>u.options[0]??null).filter(u=>u!=null),o=G7n(s),a=[];r.length>0&&a.push({key:"service-preview",title:n.servicePreviewGroupTitle,options:r}),o.length>0&&a.push({key:"recommended",title:n.recommendedGroupTitle,options:o});const l=[...i,...t];a.push(...l);const c=new Map;for(const u of[...o,...r,...l.flatMap(h=>h.options)])c.has(u.value)||c.set(u.value,u);const d=Array.from(c.values());return{servicePreviewOptions:r,recommendedOptions:o,moreModelGroups:l,flatGroups:a,searchOptions:d}},gXe="modelSelector",J7n=n=>n!=null&&typeof n=="object"&&typeof n.model=="string"&&n.model.trim()!=="",LH=n=>n.placement==null||n.placement===gXe,tb=({model:n,service:e})=>`${e??""}::${n}`,e_n=({currentGeneral:n,recommendedModels:e})=>({...n??{},recommendedModels:e.length>0?e:void 0}),t_n=({currentRecommendedModels:n,nextRecommendedModel:e})=>{const t=Array.isArray(n)?n.filter(J7n):[],i=tb(e),s=t.some(r=>LH(r)&&tb(r)===i);return{isCurrentlyRecommended:s,recommendedModels:s?t.filter(r=>!(LH(r)&&tb(r)===i)):[{service:e.service,model:e.model,placement:gXe},...t]}},bY="vf_chat_adapter",yY="vf_chat_selected_model",mXe="vf_chat_selection_driver",Tce=n=>{try{const e=localStorage.getItem(n);return e==null||e.trim()===""?void 0:e}catch{return}},n_n=()=>Tce(mXe)==="model"?"model":"adapter",$7=n=>Array.isArray(n)?n.map(e=>e.value):[];function pXe({adapterLocked:n=!1}={}){var J,le,be,ae,ce,oe,he,ye,ke,Ce,Se,we,ve,Ee,me,xe,Oe,We,Ke,ze,Ve,Ne,Ie,Ge,Fe;const{t:e}=ht(),[t,i]=C.useState(()=>Tce(bY)),[s,r]=C.useState(()=>Tce(yY)),[o,a]=C.useState(()=>n_n()),[l,c]=C.useState(),{data:d,mutate:u}=Gn("/api/config",Z0),h=C.useMemo(()=>{var Re,Je;return((Je=(Re=d==null?void 0:d.sources)==null?void 0:Re.merged)==null?void 0:Je.adapters)??{}},[(le=(J=d==null?void 0:d.sources)==null?void 0:J.merged)==null?void 0:le.adapters]),f=C.useMemo(()=>{var Re,Je;return((Je=(Re=d==null?void 0:d.sources)==null?void 0:Re.merged)==null?void 0:Je.models)??{}},[(ae=(be=d==null?void 0:d.sources)==null?void 0:be.merged)==null?void 0:ae.models]),g=C.useMemo(()=>{var Re,Je;return((Je=(Re=d==null?void 0:d.sources)==null?void 0:Re.merged)==null?void 0:Je.modelServices)??{}},[(oe=(ce=d==null?void 0:d.sources)==null?void 0:ce.merged)==null?void 0:oe.modelServices]),m=C.useMemo(()=>{var Je,vt,$t;const Re=($t=(vt=(Je=d==null?void 0:d.sources)==null?void 0:Je.merged)==null?void 0:vt.general)==null?void 0:$t.recommendedModels;return Array.isArray(Re)?Re.filter(en=>en!=null&&typeof en=="object"&&typeof en.model=="string"&&en.model.trim()!==""):[]},[(ke=(ye=(he=d==null?void 0:d.sources)==null?void 0:he.merged)==null?void 0:ye.general)==null?void 0:ke.recommendedModels]),p=C.useMemo(()=>{var Je,vt,$t;const Re=($t=(vt=(Je=d==null?void 0:d.sources)==null?void 0:Je.user)==null?void 0:vt.general)==null?void 0:$t.recommendedModels;return Array.isArray(Re)?Re.filter(en=>en!=null&&typeof en=="object"&&typeof en.model=="string"&&en.model.trim()!==""):[]},[(we=(Se=(Ce=d==null?void 0:d.sources)==null?void 0:Ce.user)==null?void 0:Se.general)==null?void 0:we.recommendedModels]),_=C.useMemo(()=>new Set(p.filter(LH).map(Re=>tb({model:Re.model,service:Re.service}))),[p]),b=C.useMemo(()=>new Set(m.filter(LH).map(Re=>tb({model:Re.model,service:Re.service}))),[m]),y=C.useMemo(()=>{var Re,Je;return((Je=(Re=d==null?void 0:d.sources)==null?void 0:Re.merged)==null?void 0:Je.adapterBuiltinModels)??{}},[(Ee=(ve=d==null?void 0:d.sources)==null?void 0:ve.merged)==null?void 0:Ee.adapterBuiltinModels]),w=hi((Oe=(xe=(me=d==null?void 0:d.sources)==null?void 0:me.merged)==null?void 0:xe.general)==null?void 0:Oe.defaultAdapter),S=hi((ze=(Ke=(We=d==null?void 0:d.sources)==null?void 0:We.merged)==null?void 0:Ke.general)==null?void 0:ze.defaultModelService),x=hi((Ie=(Ne=(Ve=d==null?void 0:d.sources)==null?void 0:Ve.merged)==null?void 0:Ne.general)==null?void 0:Ie.defaultModel),L=C.useMemo(()=>Object.keys(h),[h]),E=C.useMemo(()=>oXe(g),[g]),I=C.useMemo(()=>Object.values(y).flatMap(Re=>$7(Re)),[y]),M=C.useMemo(()=>t&&y[t]?{[t]:y[t]}:y,[y,t]),N=C.useMemo(()=>Object.values(M).flatMap(Re=>$7(Re)),[M]),T=E.length>0||N.length>0,D=C.useCallback(Re=>J2e({value:Re,availableAdapters:L,defaultAdapter:w}),[L,w]),P=C.useCallback((Re,Je,vt=!1)=>cXe({value:Re,builtinModels:Je,serviceModels:E,defaultModelService:S,preserveUnknown:vt}),[E,S]),R=C.useCallback(Re=>{const Je=$7(Re!=null?y[Re]:void 0),vt=dXe({adapter:Re,adapters:h,defaultModel:x,defaultModelService:S,builtinModels:Je,fallbackBuiltinModels:I,serviceModels:E});return!Re||!vt?vt:Dce({adapter:Re,model:vt,adapterConfig:h[Re],builtinModels:Je,serviceModels:E,preferredServiceKey:S,preserveUnknownDefaultModel:!1}).model??vt},[y,I,E,x,S,h]),A=C.useCallback((Re,Je)=>!Re||!Je?Je:Dce({adapter:Re,model:Je,adapterConfig:h[Re],builtinModels:$7(y[Re]),serviceModels:E,preferredServiceKey:S,preserveUnknownDefaultModel:!1}).model??Je,[y,E,S,h]),O=C.useCallback(Re=>z7n({model:Re,availableAdapters:L,defaultAdapter:w,adapterBuiltinModels:y,modelMetadata:f}),[y,L,w,f]),F=C.useMemo(()=>Q2e({defaultModel:x,defaultModelService:S,builtinModels:I,serviceModels:E,preserveUnknownDefaultModel:!1}),[I,E,x,S]);C.useEffect(()=>{if(n)return;if(L.length===0){i(void 0),T||r(void 0);return}if(!T){r(void 0),i(vt=>D(vt));return}if(o==="model"){const vt=P(s,I,!1)??F,$t=O(vt)??D(t),en=A($t,vt);r(gt=>gt===en?gt:en),i(gt=>gt===$t?gt:$t);return}const Re=D(t),Je=R(Re);i(vt=>vt===Re?vt:Re),r(vt=>vt===Je?vt:Je)},[n,I,L.length,T,O,A,D,R,P,F,t,s,o]),C.useEffect(()=>{try{t==null||t.trim()===""?localStorage.removeItem(bY):localStorage.setItem(bY,t)}catch{}},[t]),C.useEffect(()=>{try{s==null||s.trim()===""?localStorage.removeItem(yY):localStorage.setItem(yY,s)}catch{}},[s]),C.useEffect(()=>{try{localStorage.setItem(mXe,o)}catch{}},[o]);const $=C.useCallback(Re=>{const Je=n?$7(t!=null?y[t]:void 0):I,vt=P(Re,Je,!1);if(!vt)return;a("model");const $t=n?t:O(vt)??D(t),en=A($t,vt);r(gt=>gt===en?gt:en),!n&&i(gt=>gt===$t?gt:$t)},[y,n,I,A,O,D,P,t]),B=C.useCallback(Re=>{const Je=D(Re);if(a("adapter"),i($t=>$t===Je?$t:Je),n)return;const vt=R(Je);r($t=>$t===vt?$t:vt)},[n,D,R]),V=C.useCallback(Re=>{const Je=hi(Re.adapter)??D(void 0),vt=$7(Je!=null?y[Je]:void 0),$t=P(Re.model,vt,!0)??P(Re.model,I,!0)??hi(Re.model)??R(Je);i(en=>en===Je?en:Je),r(en=>en===$t?en:$t)},[y,I,D,R,P]),W=C.useMemo(()=>P(s,N,!0)??s,[N,P,s]),H=C.useMemo(()=>L.map(Re=>{const Je=tw(Re);return{value:Re,label:C.createElement("span",{className:"adapter-option"},[Je.icon!=null?C.createElement("img",{key:"icon",className:"adapter-option__icon",src:Je.icon,alt:"","aria-hidden":!0}):C.createElement("span",{key:"fallback-icon",className:"adapter-option__icon adapter-option__icon--fallback material-symbols-rounded","aria-hidden":!0},"deployed_code"),C.createElement("span",{key:"text",className:"adapter-option__text"},Je.title)])}}),[L]),U=C.useCallback(async Re=>{var $t,en,gt,Ht,at,ft;const Je=($t=Re.serviceKey)==null?void 0:$t.trim(),vt=Re.modelName.trim();if(!((d==null?void 0:d.sources)==null||!Je||vt===""||l===Re.value)){c(Re.value);try{const{recommendedModels:Tt}=t_n({currentRecommendedModels:(Ht=(gt=(en=d==null?void 0:d.sources)==null?void 0:en.user)==null?void 0:gt.general)==null?void 0:Ht.recommendedModels,nextRecommendedModel:{service:Je,model:vt,placement:"modelSelector"}}),hn=e_n({currentGeneral:(ft=(at=d==null?void 0:d.sources)==null?void 0:at.user)==null?void 0:ft.general,recommendedModels:Tt});await Y3e("user","general",hn),await u()}catch(Tt){console.error("[chat] failed to update recommended models",Tt)}finally{c(void 0)}}},[(Fe=(Ge=d==null?void 0:d.sources)==null?void 0:Ge.user)==null?void 0:Fe.general,u,l]),Z=C.useCallback(Re=>{const Je=Re.serviceKey==null?void 0:tb({model:Re.modelName,service:Re.serviceKey}),vt={...Re,canToggleRecommendation:Re.serviceKey!=null&&Re.modelName.trim()!=="",isRecommended:Je!=null&&b.has(Je),isUserRecommended:Je!=null&&_.has(Je),label:null};return vt.label=v.jsx(CH,{option:vt,onToggleRecommendedModel:U,updatingRecommendedModelValue:l}),vt},[b,U,l,_]),G=C.useMemo(()=>fXe({activeBuiltinModels:M,availableServiceModels:E,defaultModelService:S,mergedModels:f,mergedModelServices:g,recommendedModels:m,recommendedGroupTitle:e("chat.modelGroupRecommended",{defaultValue:"推荐模型"}),servicePreviewGroupTitle:e("chat.modelGroupServices",{defaultValue:"模型服务"}),builtinGroupTitle:Re=>e("chat.modelGroupBuiltin",{adapter:Re,defaultValue:`${Re} (Default)`})}),[M,E,S,f,g,m,e]),q=C.useMemo(()=>G.searchOptions.map(Z),[Z,G.searchOptions]),K=C.useMemo(()=>G.recommendedOptions.map(Z),[Z,G.recommendedOptions]),X=C.useMemo(()=>G.servicePreviewOptions.map(Z),[Z,G.servicePreviewOptions]),ie=C.useMemo(()=>G.moreModelGroups.map(Re=>({...Re,options:Re.options.map(Z)})),[Z,G.moreModelGroups]),se=C.useMemo(()=>G.flatGroups.map(Re=>({key:Re.key,label:v.jsxs("div",{className:"model-group-label",children:[v.jsx("div",{className:"model-group-title",children:Re.title}),Re.description&&v.jsx("div",{className:"model-group-desc",children:Re.description})]}),options:Re.options.map(Z)})),[Z,G.flatGroups]);return{adapterOptions:H,applySessionSelection:V,hasAvailableModels:T,modelMenuGroups:ie,modelOptions:se,modelSearchOptions:q,recommendedModelOptions:K,servicePreviewModelOptions:X,selectedAdapter:t,selectedModel:s,selectedModelWithService:W,setSelectedAdapter:B,setSelectedModel:$,toggleRecommendedModel:U,updatingRecommendedModelValue:l}}const Uxe="vf_chat_permission_mode",Kxe=n=>n==="default"||n==="acceptEdits"||n==="plan"||n==="dontAsk"||n==="bypassPermissions";function CXe(){const[n,e]=C.useState("default"),t=s=>{if(s!=null&&Kxe(s)){e(s);return}e("default")};C.useEffect(()=>{try{const s=localStorage.getItem(Uxe);s&&Kxe(s)&&t(s)}catch{}},[]),C.useEffect(()=>{try{localStorage.setItem(Uxe,n)}catch{}},[n]);const i=C.useMemo(()=>[{value:"default",label:"默认"},{value:"acceptEdits",label:"接受编辑"},{value:"plan",label:"计划"},{value:"dontAsk",label:"不询问"},{value:"bypassPermissions",label:"跳过权限"}],[]);return{permissionMode:n,setPermissionMode:t,permissionModeOptions:i}}const i_n=27,s_n=n=>{let e="",t=0;for(;t<n.length;){if(n.charCodeAt(t)===i_n&&n[t+1]==="["){for(t+=2;t<n.length;){const i=n.charCodeAt(t);if(i>=64&&i<=126){t+=1;break}t+=1}continue}e+=n[t],t+=1}return e},Zxe=n=>s_n(n).trim(),_Xe=n=>{if((n==null?void 0:n.type)!=="error"||n.data!=null&&typeof n.data=="object"&&"fatal"in n.data&&n.data.fatal===!1)return null;const e=n.data!=null&&typeof n.data=="object"&&"code"in n.data&&typeof n.data.code=="string"&&n.data.code.trim()!==""?n.data.code:void 0;if(n.data!=null&&typeof n.data=="object"&&"message"in n.data){const t=n.data.message;if(typeof t=="string"){const i=Zxe(t);if(i!=="")return{message:i,code:e}}}if(typeof n.message=="string"){const t=Zxe(n.message);if(t!=="")return{message:t,code:e}}return null},vXe=(n,e)=>{if(e.type==="interaction_request")return{id:e.id,payload:e.payload};if(e.type==="interaction_response")return(n==null?void 0:n.id)===e.id||n==null?null:n;if(e.type==="session_updated"){const t=e.session;if("isDeleted"in t||t.status!=="waiting_input")return null}return e.type==="error"&&e.data!=null&&typeof e.data=="object"&&"fatal"in e.data&&e.data.fatal!==!1?null:n},r_n=(n,e,t)=>{let i=null;for(const s of n)i=vXe(i,s);return i??(t==="waiting_input"?e:null)},o_n=n=>{for(let e=n.length-1;e>=0;e-=1){const t=_Xe(n[e]);if(t!=null)return t}return null},a_n=20,kH=n=>({creationProgress:(n==null?void 0:n.creationProgress)??[],messages:(n==null?void 0:n.messages)??[],sessionInfo:(n==null?void 0:n.sessionInfo)??null,queuedMessages:(n==null?void 0:n.queuedMessages)??{steer:[],next:[]},errorState:(n==null?void 0:n.errorState)??null,interactionRequest:(n==null?void 0:n.interactionRequest)??null,isHydrated:(n==null?void 0:n.isHydrated)??!1}),l_n=(n,e)=>kH({...kH(n),...e}),c_n=n=>{const e=kH(n),t=e.isHydrated===!0?e:kH();return{creationProgress:t.creationProgress,messages:t.messages,sessionInfo:t.sessionInfo,queuedMessages:t.queuedMessages,errorState:t.errorState,interactionRequest:t.interactionRequest,isReady:t.isHydrated}},d_n=(n,e,t)=>{const i=l_n(n.get(e),t);for(n.has(e)&&n.delete(e),n.set(e,i);n.size>a_n;){const s=n.keys().next().value;if(s==null)break;n.delete(s)}return i},u_n=(n,e)=>{n.delete(e)},DR={steer:[],next:[]},h_n=n=>n==="user"||n==="assistant"||n==="system",qxe=n=>{const e=typeof n.createdAt=="number"?n.createdAt:n.ts;return typeof e=="number"?e:Date.now()},f_n=n=>n.type!=="message"?null:"message"in n&&n.message!=null?n.message:!h_n(n.role)||typeof n.content!="string"&&!Array.isArray(n.content)?null:{id:typeof n.id=="string"&&n.id!==""?n.id:`runtime-message-${qxe(n)}`,role:n.role,content:n.content,model:typeof n.model=="string"?n.model:void 0,createdAt:qxe(n)},g_n=(n,e)=>!e||(n==null?void 0:n.id)==null||n.id===""||n.parentSessionId!=null&&n.parentSessionId!==""?!1:n.status==="waiting_input",Gxe=(n,e)=>{const t=f_n(e);return t==null?n:n.find(s=>s.id===t.id)!=null?n.map(s=>s.id===t.id?t:s):[...n,t]},m_n=n=>{var e;return((e=n.toolCall)==null?void 0:e.id)??n.id},Xxe=(n,e)=>{if(e.type!=="tool_result")return n;const t=e.isError===!0?"error":"success";return n.map(i=>i.toolCall!=null&&m_n(i)===e.toolCallId?{...i,toolCall:{...i.toolCall,status:t,output:e.output}}:i)},Yxe=(n,e)=>e.type!=="session_creation_progress"?n:[...n,e.progress];function p_n({session:n,modelForQuery:e,effort:t,permissionMode:i,adapter:s,account:r,optimisticCreation:o,setInteractionRequest:a}){const{t:l}=ht(),{mutate:c}=Jy(),[d,u]=C.useState([]),[h,f]=C.useState([]),[g,m]=C.useState(null),[p,_]=C.useState({steer:[],next:[]}),[b,y]=C.useState(!1),[w,S]=C.useState(null),[x,L]=C.useState(0),E=C.useRef(!0),I=C.useRef(void 0),M=C.useRef(void 0),N=C.useRef(void 0),T=C.useRef(void 0),D=C.useRef(void 0),P=C.useRef(n==null?void 0:n.status),R=C.useRef(!1),A=C.useRef(null),O=C.useRef(n==null?void 0:n.id),F=C.useRef(0),$=C.useRef([]),B=C.useRef(new Map);O.current=n==null?void 0:n.id;const V=C.useCallback((K,X)=>d_n(B.current,K,X),[]),W=C.useCallback(K=>{u_n(B.current,K)},[]),H=C.useCallback(K=>{u(X=>{const ie=typeof K=="function"?K(X):K,se=O.current;if(se!=null&&se!==""){const J=B.current.get(se);V(se,{messages:ie,isHydrated:(J==null?void 0:J.isHydrated)===!0})}return ie})},[V]),U=C.useCallback(()=>{for(const K of $.current)clearTimeout(K);$.current=[]},[]),Z=C.useCallback(async(K={})=>{var se,J;const X=O.current;if(X==null||X==="")return;const ie=++F.current;try{const le=await XAe(X);if(O.current!==X||F.current!==ie)return;const be=le.messages;le.session&&Nee(c,le.session);let ae=[],ce=[],oe=null;const he=r_n(be,le.interaction??null,(se=le.session)==null?void 0:se.status),ye=o_n(be),ke=he==null&&((J=le.session)==null?void 0:J.status)==="failed"&&ye!=null?{kind:"session",message:ye.message,code:ye.code}:null,Ce=le.queuedMessages??DR;A.current=he,a(he),_(Ce),S(ke);for(const Se of be)ae=Gxe(ae,Se),ae=Xxe(ae,Se),ce=Yxe(ce,Se),Se.type==="session_info"&&Se.info!=null&&Se.info.type!=="summary"&&(oe=Se.info);V(X,{messages:ae,creationProgress:ce,sessionInfo:oe,queuedMessages:Ce,errorState:ke,interactionRequest:he,isHydrated:!0}),H(ae),f(ce),m(oe),K.updateReadiness!==!1&&setTimeout(()=>{O.current!==X||F.current!==ie||(y(!0),E.current=!1)},100)}catch(le){console.error("Failed to fetch history messages:",le)}},[c,a,H,V]),G=C.useCallback(()=>{U();for(const K of[0,800,2400,5e3,9e3,15e3]){const X=globalThis.setTimeout(()=>{Z({updateReadiness:!1})},K);$.current.push(X)}},[U,Z]),q=C.useCallback(()=>{(n==null?void 0:n.id)==null||n.id===""||(R.current=!0,S(null),V(n.id,{errorState:null}),E2.close(n.id),L(K=>K+1))},[n==null?void 0:n.id,V]);return C.useEffect(()=>{if((n==null?void 0:n.id)==null||n.id===""){u([]),f([]),m(null),_(DR),y(!0),S(null),a(null),A.current=null,E.current=!0,I.current=void 0,M.current=void 0,N.current=void 0,T.current=void 0,D.current=void 0,U();return}if(o!=null){U(),F.current+=1;const X=[o.message],ie=o.status==="failed"?{action:"retry-session-creation",code:"session_create_failed",kind:"session",message:o.errorMessage??l("chat.sessionCreateFailedMessage")}:null;A.current=null,a(null),u(X),m(null),_(DR),S(ie),y(!0),E.current=!1,V(n.id,{messages:X,sessionInfo:null,queuedMessages:DR,errorState:ie,interactionRequest:null,isHydrated:!0});return}const K=c_n(B.current.get(n.id));return u(K.messages),f(K.creationProgress),m(K.sessionInfo),_(K.queuedMessages),S(K.errorState),a(K.interactionRequest),A.current=K.interactionRequest,y(K.isReady),E.current=!K.isReady,Z(),Z(),()=>{U()}},[U,o,Z,n==null?void 0:n.id,a,l,V]),C.useEffect(()=>{if((n==null?void 0:n.id)==null||n.id===""){P.current=void 0;return}if(o!=null){P.current=n.status;return}const K=P.current;P.current=n.status,!(K==null||K===n.status)&&Z({updateReadiness:!1})},[o,Z,n==null?void 0:n.id,n==null?void 0:n.status]),C.useEffect(()=>{if((n==null?void 0:n.id)==null||n.id==="")return;if(o!=null){R.current=!0,E2.close(n.id);return}let K=!1,X;const ie=e??"",se=e!=null&&I.current!=null&&ie!==I.current&&(n==null?void 0:n.status)!=="running",J=t==="default"?"":t,le=M.current!=null&&J!==M.current&&(n==null?void 0:n.status)!=="running",be=i??"",ae=i!=null&&N.current!=null&&be!==N.current&&(n==null?void 0:n.status)!=="running",ce=s??"",oe=s!=null&&T.current!=null&&ce!==T.current&&(n==null?void 0:n.status)!=="running",he=r??"",ye=r!=null&&D.current!=null&&he!==D.current&&(n==null?void 0:n.status)!=="running",Ce=g_n(n,se||le||ae||oe||ye);Ce&&(R.current=!0,S(null),E2.send(n.id,{type:"terminate_session"}),E2.close(n.id)),I.current=ie,M.current=J,N.current=be,T.current=ce,D.current=he;const Se=setTimeout(()=>{if(K)return;const we={};e&&(we.model=e),t!=="default"&&(we.effort=t),i&&(we.permissionMode=i),s&&(we.adapter=s),r&&(we.account=r),X=E2.connect(n.id,{onOpen(){R.current=!1,S(ve=>{const Ee=(ve==null?void 0:ve.kind)==="session"?ve:null;return V(n.id,{errorState:Ee}),Ee})},onMessage(ve){if(K)return;const Ee=vXe(A.current,ve);if(Ee!==A.current&&(A.current=Ee,a(Ee),V(n.id,{interactionRequest:Ee}),Ee!=null&&(S(null),V(n.id,{errorState:null}))),ve.type==="interaction_response"){G();return}if(ve.type==="error"){const me=_Xe(ve);if(me!=null){const xe={kind:"session",message:me.message,code:me.code};S(xe),V(n.id,{errorState:xe})}return}if(ve.type==="session_updated"){const me=ve.session;she(me)&&W(me.id),Nee(c,me);return}if(ve.type==="session_queue_updated"){_(ve.queue),V(n.id,{queuedMessages:ve.queue});return}if(ve.type==="message"){H(me=>Gxe(me,ve));return}if(ve.type==="session_creation_progress"){f(me=>{const xe=Yxe(me,ve);return V(n.id,{creationProgress:xe}),xe});return}if(ve.type==="session_info"){ve.info!=null&&ve.info.type==="summary"?c("/api/sessions"):(m(ve.info??null),V(n.id,{sessionInfo:ve.info??null}),E.current&&setTimeout(()=>{K||E.current&&(y(!0),E.current=!1)},100));return}if(ve.type==="tool_result"){H(me=>Xxe(me,ve));return}ve.type==="interaction_request"&&(A.current=ve,a(ve),V(n.id,{interactionRequest:ve}))},onError(){if(K)return;const ve={kind:"connection",message:l("chat.connectionError"),reason:"error"};S(ve),V(n.id,{errorState:ve})},onClose(){if(!K){if(R.current){R.current=!1;return}S(ve=>{const Ee=ve??{kind:"connection",message:l("chat.connectionClosed"),reason:"closed"};return V(n.id,{errorState:Ee}),Ee})}}},Object.keys(we).length>0?we:void 0)},Ce?200:100);return()=>{K=!0,clearTimeout(Se),X==null||X()}},[s,r,U,t,e,c,o,i,G,x,Z,n==null?void 0:n.id,n==null?void 0:n.status,a,l,W,V]),{messages:d,creationProgress:h,setMessages:H,sessionInfo:g,queuedMessages:p,isReady:b,errorState:w,retryConnection:q,reconcileAfterInteraction:G}}const C_n=n=>n==="timeline"||n==="settings"||n==="history"?n:"history";function __n(){const{values:n,update:e}=Rf({keys:["view","terminal"],defaults:{view:"history",terminal:""},omit:{view:a=>a==="history",terminal:a=>a===""||a==="false"}}),t=n.view==="terminal",i=C_n(t?"history":n.view),s=n.terminal==="true"||t,r=C.useCallback(a=>{e({view:a})},[e]),o=C.useCallback(a=>{e({terminal:a?"true":"false"})},[e]);return C.useEffect(()=>{i!==n.view&&e({view:i})},[i,n.view,e]),C.useEffect(()=>{t&&e({view:"history",terminal:"true"})},[t,e]),{activeView:i,isTerminalOpen:s,setActiveView:r,setIsTerminalOpen:o}}function v_n({session:n}){const{t:e}=ht(),t=Su(Fb),i=(n==null?void 0:n.id)==null||n.id===""?void 0:t[n.id],{adapterOptions:s,applySessionSelection:r,modelMenuGroups:o,selectedAdapter:a,selectedModel:l,selectedModelWithService:c,setSelectedModel:d,setSelectedAdapter:u,modelSearchOptions:h,recommendedModelOptions:f,servicePreviewModelOptions:g,toggleRecommendedModel:m,updatingRecommendedModelValue:p,hasAvailableModels:_}=pXe({adapterLocked:(n==null?void 0:n.id)!=null}),{accountOptions:b,selectedAccount:y,setSelectedAccount:w,applySessionSelection:S,showAccountSelector:x}=Z7n({adapter:a,model:c}),{permissionMode:L,setPermissionMode:E,permissionModeOptions:I}=CXe(),{effort:M,setEffort:N,effortOptions:T}=hXe(),{activeView:D,isTerminalOpen:P,setActiveView:R,setIsTerminalOpen:A}=__n(),{interactionRequest:O,setInteractionRequest:F,handleInteractionResponse:$}=q7n({sessionId:n==null?void 0:n.id}),{creationProgress:B,messages:V,setMessages:W,sessionInfo:H,queuedMessages:U,isReady:Z,errorState:G,retryConnection:q,reconcileAfterInteraction:K}=p_n({session:n,modelForQuery:c,effort:M,permissionMode:L,adapter:a,account:y,optimisticCreation:i,setInteractionRequest:F}),X=C.useCallback((J,le)=>{K(),$(J,le)},[K,$]),ie=C.useRef(null),se=(n==null?void 0:n.status)==="running";return C.useEffect(()=>{if((n==null?void 0:n.id)==null||n.id===""){ie.current=null;return}const J=ie.current,le=(J==null?void 0:J.id)!==n.id;(le||(J==null?void 0:J.model)!==n.model||(J==null?void 0:J.adapter)!==n.adapter)&&r({model:n.model,adapter:n.adapter}),(le||(J==null?void 0:J.account)!==n.account)&&S({account:n.account}),(le||(J==null?void 0:J.permissionMode)!==n.permissionMode)&&E(n.permissionMode),(le||(J==null?void 0:J.effort)!==n.effort)&&N(n.effort),ie.current={id:n.id,model:n.model,permissionMode:n.permissionMode,adapter:n.adapter,account:n.account,effort:n.effort}},[S,n==null?void 0:n.adapter,n==null?void 0:n.account,n==null?void 0:n.effort,n==null?void 0:n.id,n==null?void 0:n.model,n==null?void 0:n.permissionMode,r,N,E]),{creationProgress:B,messages:V,sessionInfo:H,queuedMessages:U,interactionRequest:O,isReady:Z,errorState:G,retryConnection:q,isThinking:se,activeView:D,isTerminalOpen:P,setActiveView:R,setIsTerminalOpen:A,handleInteractionResponse:X,setMessages:W,placeholder:n!=null&&n.id?void 0:e("chat.newSessionPlaceholder"),modelMenuGroups:o,modelSearchOptions:h,recommendedModelOptions:f,servicePreviewModelOptions:g,toggleRecommendedModel:m,updatingRecommendedModelValue:p,selectedModel:l,modelForQuery:c,setSelectedModel:d,effort:M,setEffort:N,effortOptions:T,permissionMode:L,setPermissionMode:E,permissionModeOptions:I,selectedAdapter:a,setSelectedAdapter:u,selectedAccount:y,setSelectedAccount:w,accountOptions:b,showAccountSelector:x,adapterOptions:s,hasAvailableModels:_,modelUnavailable:!_}}const b_n=n=>{var e,t;return n.role!=="agent"?!1:n.kind==="attention"||((e=n.run)==null?void 0:e.status)==="waiting"||((t=n.member)==null?void 0:t.status)==="waiting"};function y_n(n){var s;const e=xOe(n),t=new Set,i=[];for(let r=e.messages.length-1;r>=0;r-=1){const o=e.messages[r];if(!b_n(o))continue;const a=((s=o.run)==null?void 0:s.runKey)??o.id;t.has(a)||(t.add(a),i.push(o))}return i.reverse()}const w_n=[{key:"folders",icon:"account_tree",labelKey:"chat.workspaceDrawerChangedFolders"},{key:"flat",icon:"view_list",labelKey:"chat.workspaceDrawerChangedFlat"}],S_n={type:"divider"},wY=n=>v.jsx("span",{className:"material-symbols-rounded chat-workspace-drawer__menu-icon",children:n});function x_n({activeView:n,agentApprovals:e,agentRoster:t,changedFilesCount:i,changedLayout:s,onActiveViewChange:r,onChangedLayoutChange:o,onChangedTreeCommand:a,onForceSync:l,onWorkspaceTreeCommand:c,selectedFilePath:d}){const{t:u}=ht(),h=C.useMemo(()=>[{key:"tree",icon:"folder",label:u("chat.workspaceDrawerTree")},{key:"changes",icon:"difference",label:u("chat.workspaceDrawerChangedFiles"),count:i},...e==null?[]:[{key:"approvals",icon:"approval",label:u("chat.workspaceDrawerApprovals"),count:e.count}],...t==null?[]:[{key:"agents",icon:"groups",label:u("chat.workspaceDrawerAgents"),count:t.pendingCount>0?t.pendingCount:t.memberCount}]],[e,t,i,u]),f=C.useMemo(()=>[{key:"force-sync",label:u("chat.workspaceDrawerForceSync"),icon:wY("sync"),onClick:l},...n==="changes"?[S_n,{key:"display-mode",label:u("chat.workspaceDrawerDisplayMode"),icon:wY("view_module"),children:w_n.map(b=>({key:`layout:${b.key}`,label:u(b.labelKey),icon:wY(s===b.key?"check":b.icon),onClick:()=>o(b.key)}))}]:[]],[n,s,o,l,u]),g=d!=null&&d!=="",m=n!=="agents"&&n!=="approvals",p=()=>{if(n==="tree"){c("expand");return}a("expand")},_=()=>{if(n==="tree"){c("collapse");return}a("collapse")};return v.jsxs("div",{className:"chat-workspace-drawer__toolbar",children:[v.jsx("div",{className:"chat-workspace-drawer__view-actions",children:h.map(b=>v.jsx(Qe,{title:b.label,children:v.jsxs(qe,{type:"text",className:`chat-workspace-drawer__view-btn ${n===b.key?"is-active":""}`,"aria-label":b.label,"aria-pressed":n===b.key,onClick:()=>r(b.key),children:[v.jsx("span",{className:"material-symbols-rounded",children:b.icon}),b.count!=null&&b.count>0&&v.jsx("span",{className:"chat-workspace-drawer__view-count",children:b.count})]})},b.key))}),m&&v.jsxs("div",{className:"chat-workspace-drawer__toolbar-actions",children:[v.jsx(Qe,{title:u("chat.workspaceDrawerLocateFile"),children:v.jsx("span",{className:"chat-workspace-drawer__toolbar-button-wrap",children:v.jsx(qe,{type:"text",className:"chat-workspace-drawer__icon-btn","aria-label":u("chat.workspaceDrawerLocateFile"),disabled:!g,onClick:()=>c("locate",d??void 0),children:v.jsx("span",{className:"material-symbols-rounded",children:"my_location"})})})}),v.jsx(Qe,{title:u("chat.workspaceDrawerExpandAll"),children:v.jsx(qe,{type:"text",className:"chat-workspace-drawer__icon-btn","aria-label":u("chat.workspaceDrawerExpandAll"),onClick:p,children:v.jsx("span",{className:"material-symbols-rounded",children:"unfold_more"})})}),v.jsx(Qe,{title:u("chat.workspaceDrawerCollapseAll"),children:v.jsx(qe,{type:"text",className:"chat-workspace-drawer__icon-btn","aria-label":u("chat.workspaceDrawerCollapseAll"),onClick:_,children:v.jsx("span",{className:"material-symbols-rounded",children:"unfold_less"})})}),v.jsx(Wo,{menu:{items:f},overlayClassName:"chat-workspace-drawer-more-dropdown",placement:"bottomRight",trigger:["click"],children:v.jsx(qe,{type:"text",className:"chat-workspace-drawer__icon-btn","aria-label":u("common.moreActions"),title:u("common.moreActions"),children:v.jsx("span",{className:"material-symbols-rounded",children:"more_vert"})})})]})]})}const L_n=n=>(n==null?void 0:n.trim().replace(/^@+/,""))??"";function k_n({approvals:n,onOpenRun:e}){const{t}=ht();return n.length===0?v.jsx("div",{className:"chat-workspace-drawer__approvals-empty",children:v.jsx(jn,{image:jn.PRESENTED_IMAGE_SIMPLE,description:t("agentRoom.approvals.empty")})}):v.jsx("div",{className:"chat-workspace-drawer__approvals","aria-label":t("chat.workspaceDrawerApprovals"),children:n.map(i=>{var c,d;const s=L_n((c=i.member)==null?void 0:c.label),r=s!==""?s:t("agentRoom.message.agent"),o=i.run,a=(d=i.run)==null?void 0:d.title,l=t("agentRoom.approvals.waitingForInput");return v.jsxs("article",{className:"chat-workspace-drawer__approval-card","aria-label":l,children:[v.jsxs("div",{className:"chat-workspace-drawer__approval-head",children:[v.jsxs("div",{className:"chat-workspace-drawer__approval-context",children:[v.jsx("span",{className:"chat-workspace-drawer__approval-agent",children:r}),a!=null&&a!==""&&v.jsx("span",{className:"chat-workspace-drawer__approval-run",children:a})]}),v.jsx("span",{className:"chat-workspace-drawer__approval-status",children:l})]}),v.jsx("div",{className:"chat-workspace-drawer__approval-message",children:i.content}),v.jsx("div",{className:"chat-workspace-drawer__approval-note",children:t("agentRoom.approvals.waitingDescription")}),o!=null&&e!=null&&v.jsxs("button",{type:"button",className:"chat-workspace-drawer__approval-open-run",onClick:()=>e(o),children:[v.jsx("span",{className:"material-symbols-rounded","aria-hidden":"true",children:"open_in_new"}),v.jsx("span",{children:t("agentRoom.actions.openRun")})]})]},i.id)})})}const bXe=n=>[...n].sort((e,t)=>e.file.path.localeCompare(t.file.path)),yXe=n=>n.split("/").pop()??n,E_n=n=>{const e=yXe(n);return n===e?"":n.slice(0,Math.max(0,n.length-e.length-1))},I_n=n=>{const e=[];return n.staged&&e.push({file:n,key:`${n.path}:staged`,scope:"staged"}),n.unstaged&&!n.untracked&&e.push({file:n,key:`${n.path}:tracked`,scope:"tracked"}),n.untracked&&e.push({file:n,key:`${n.path}:untracked`,scope:"untracked"}),e},M_n=n=>{const e=n.flatMap(I_n),t=[{scope:"staged",entries:[],count:0},{scope:"tracked",entries:[],count:0},{scope:"untracked",entries:[],count:0}];for(const i of t)i.entries=bXe(e.filter(s=>s.scope===i.scope)),i.count=i.entries.length;return t.filter(i=>i.count>0)},N_n=(n,e,t)=>{const i=n.children.find(r=>r.path===t);if(i!=null)return i;const s={name:e,path:t,children:[],entries:[]};return n.children.push(s),s},wXe=n=>{n.children.sort((e,t)=>e.name.localeCompare(t.name)),n.entries=bXe(n.entries);for(const e of n.children)wXe(e)},Qxe=n=>{const e={name:"",path:"",children:[],entries:[]};for(const t of n){const i=t.file.path.split("/").filter(Boolean);if(i.pop()==null)continue;let r=e,o="";for(const a of i)o=o===""?a:`${o}/${a}`,r=N_n(r,a,o);r.entries.push(t)}return wXe(e),e},Rce=n=>{const e=n.path===""?[]:[n.path];for(const t of n.children)e.push(...Rce(t));return e},SXe=(n,e)=>{if(n.path===e)return n;for(const t of n.children){const i=SXe(t,e);if(i!=null)return i}return null},xXe=n=>n.trim().toLowerCase(),D_n=n=>{const e=xXe(n),t=e.lastIndexOf(".");return t<=0?"":e.slice(t+1)},LXe=n=>{const e=xXe(n),t=D_n(n);return e==="package.json"?{icon:"inventory_2",tone:"package"}:e.includes("lock")?{icon:"lock",tone:"lock"}:e.startsWith(".env")?{icon:"key",tone:"env"}:e.includes("config")?{icon:"tune",tone:"config"}:e.includes("readme")||t==="md"||t==="mdx"?{icon:"article",tone:"docs"}:e.includes("gitignore")||e.includes("dockerignore")?{icon:"hide_source",tone:"ignore"}:t==="ts"||t==="tsx"?{icon:"data_object",tone:"typescript"}:t==="js"||t==="jsx"||t==="mjs"||t==="cjs"?{icon:"javascript",tone:"javascript"}:t==="json"?{icon:"data_object",tone:"json"}:t==="scss"||t==="sass"||t==="css"?{icon:"palette",tone:"style"}:t==="html"?{icon:"language",tone:"html"}:["png","jpg","jpeg","gif","webp","svg","ico"].includes(t)?{icon:"image",tone:"image"}:["yml","yaml","toml"].includes(t)?{icon:"settings",tone:"config"}:["sh","bash","zsh"].includes(t)?{icon:"terminal",tone:"script"}:{icon:"draft",tone:"file"}},T_n=(n,e)=>{const t=n.file.submodule;return t==null?[]:[t.commitChanged?e("chat.workspaceDrawerSubmoduleCommit"):null,t.trackedChanges?e("chat.workspaceDrawerSubmoduleTracked"):null,t.untrackedChanges?e("chat.workspaceDrawerSubmoduleUntracked"):null].filter(i=>i!=null)};function kXe({entry:n,onOpenFile:e,selectedFilePath:t,showDirectory:i=!0}){const{t:s}=ht(),r=yXe(n.file.path),o=E_n(n.file.path),a=n.file.submodule!=null?{icon:"folder_special",tone:"submodule"}:LXe(r),l=C.useMemo(()=>{const c=T_n(n,s),d=s(`chat.workspaceDrawerFileStatus.${n.scope}`);return c.length===0?d:`${d} · ${s("chat.workspaceDrawerSubmodule")}: ${c.join(", ")}`},[n,s]);return v.jsxs("button",{type:"button",className:`chat-workspace-drawer__changed-file ${t===n.file.path?"is-selected":""}`,title:n.file.path,onClick:()=>e==null?void 0:e(n.file.path),children:[v.jsx("span",{className:`material-symbols-rounded chat-workspace-drawer__changed-icon is-${a.tone}`,children:a.icon}),v.jsxs("span",{className:"chat-workspace-drawer__changed-copy",children:[v.jsx("span",{className:"chat-workspace-drawer__changed-name",children:r}),i&&o!==""&&v.jsx("span",{className:"chat-workspace-drawer__changed-path",children:o})]}),v.jsx(Qe,{title:l,children:v.jsx("span",{className:`chat-workspace-drawer__changed-status-dot is-${n.scope}`,"aria-label":l})})]})}const Jxe=n=>({"--changed-folder-depth":n}),R_n=n=>{const e=[n.name];let t=n;for(;t.entries.length===0&&t.children.length===1;)t=t.children[0],e.push(t.name);return{label:e.join("/"),node:t}};function EXe({depth:n,expandedPaths:e,node:t,onOpenFile:i,onSelectFolder:s,onToggleFolder:r,selectedFilePath:o,selectedFolder:a,scope:l}){const c=t.path==="",d=c?{label:"",node:t}:R_n(t),u=d.node,h=c||e.has(u.path),f=(a==null?void 0:a.scope)===l&&a.path===u.path;return v.jsxs("div",{className:"chat-workspace-drawer__changed-folder-node",children:[!c&&v.jsxs("button",{type:"button",className:`chat-workspace-drawer__changed-folder ${h?"is-expanded":""} ${f?"is-selected":""}`,style:Jxe(n),"aria-expanded":h,"aria-pressed":f,title:u.path,onClick:()=>{s(u.path),r(u.path)},children:[v.jsx("span",{className:"material-symbols-rounded chat-workspace-drawer__changed-folder-icon",children:h?"folder_open":"folder"}),v.jsx("span",{className:"chat-workspace-drawer__changed-folder-name",children:d.label})]}),v.jsx("div",{className:`chat-workspace-drawer__changed-folder-children ${h?"is-expanded":"is-collapsed"}`,children:v.jsxs("div",{className:"chat-workspace-drawer__changed-folder-children-inner",children:[u.children.map(g=>v.jsx(EXe,{depth:n+1,expandedPaths:e,node:g,selectedFilePath:o,onOpenFile:i,onSelectFolder:s,onToggleFolder:r,selectedFolder:a,scope:l},g.path)),u.entries.map(g=>v.jsx("div",{className:"chat-workspace-drawer__changed-folder-entry",style:Jxe(u.path===""?0:n+1),children:v.jsx(kXe,{entry:g,selectedFilePath:o,showDirectory:!1,onOpenFile:i})},g.key))]})})]})}function P_n({command:n,onOpenFile:e,onSelectFolder:t,root:i,scope:s,selectedFilePath:r,selectedFolder:o}){const a=C.useMemo(()=>Rce(i),[i]),[l,c]=C.useState(()=>new Set(a));C.useEffect(()=>{c(new Set(a))},[a]),C.useEffect(()=>{if(n==null)return;const u=(o==null?void 0:o.scope)===s?o.path:null,h=u==null?i:SXe(i,u),f=h==null?a:Rce(h),g=u==null?f:[u,...f];c(m=>{if(n.action==="expand")return new Set([...m,...g]);const p=new Set(m);for(const _ of g)p.delete(_);return p})},[a,n,i,s,o]);const d=u=>{c(h=>{const f=new Set(h);return f.has(u)?f.delete(u):f.add(u),f})};return v.jsx(EXe,{depth:0,expandedPaths:l,node:i,selectedFilePath:r,onOpenFile:e,onSelectFolder:u=>t({scope:s,path:u}),onToggleFolder:d,selectedFolder:o,scope:s})}function A_n({command:n,isLoading:e,layout:t,onOpenFile:i,repoState:s,selectedFilePath:r}){const{t:o}=ht(),[a,l]=C.useState(new Set),[c,d]=C.useState(null),u=C.useMemo(()=>(s==null?void 0:s.available)!==!0?[]:s.changedFiles??[],[s]),h=C.useMemo(()=>M_n(u),[u]),f=C.useMemo(()=>h.map(p=>p.scope),[h]),g=C.useMemo(()=>new Map(h.map(p=>[p.scope,Qxe(p.entries)])),[h]);C.useEffect(()=>{l(p=>new Set(Array.from(p).filter(_=>f.includes(_))))},[f]),C.useEffect(()=>{t!=="folders"&&d(null)},[t]),C.useEffect(()=>{if(n!=null){if(c==null){l(n.action==="expand"?new Set:new Set(f));return}n.action==="expand"&&l(p=>{const _=new Set(p);return _.delete(c.scope),_})}},[n,f,c]);const m=p=>{l(_=>{const b=new Set(_);return b.has(p)?b.delete(p):b.add(p),b})};return e?v.jsxs("div",{className:"chat-workspace-drawer__loading",children:[v.jsx(el,{size:"small"}),v.jsx("span",{children:o("chat.workspaceDrawerLoadingGit")})]}):s!=null&&s.available!==!0?v.jsx(jn,{image:jn.PRESENTED_IMAGE_SIMPLE,description:o("chat.workspaceDrawerGitUnavailable")}):h.length===0?v.jsx(jn,{image:jn.PRESENTED_IMAGE_SIMPLE,description:o("chat.workspaceDrawerNoChangedFiles")}):v.jsx("div",{className:"chat-workspace-drawer__changed-list",children:v.jsx("div",{className:"chat-workspace-drawer__changed-sections",children:h.map(p=>{const _=a.has(p.scope);return v.jsxs("section",{className:"chat-workspace-drawer__changed-section",children:[v.jsxs("div",{className:"chat-workspace-drawer__changed-section-header",children:[v.jsx("span",{children:o(`chat.workspaceDrawerChangedSection.${p.scope}`)}),v.jsxs("span",{className:"chat-workspace-drawer__changed-section-meta",children:[v.jsx("span",{children:p.count}),v.jsx(qe,{type:"text",className:"chat-workspace-drawer__changed-section-toggle","aria-label":o("chat.workspaceDrawerToggleSection"),"aria-expanded":!_,onClick:()=>m(p.scope),children:v.jsx("span",{className:"material-symbols-rounded",children:_?"expand_more":"expand_less"})})]})]}),v.jsx("div",{className:`chat-workspace-drawer__changed-section-body ${_?"is-collapsed":"is-expanded"}`,children:v.jsx("div",{className:"chat-workspace-drawer__changed-section-body-inner",children:t==="folders"?v.jsx(P_n,{command:n,root:g.get(p.scope)??Qxe([]),scope:p.scope,selectedFolder:c,selectedFilePath:r,onOpenFile:i,onSelectFolder:d}):p.entries.map(b=>v.jsx(kXe,{entry:b,selectedFilePath:r,onOpenFile:i},b.key))})})]},p.scope)})})})}function O_n({command:n,onOpenFile:e,onReferencePaths:t,refreshKey:i,selectedFilePath:s,sessionId:r}){return v.jsx($Be,{activePath:s,className:"chat-workspace-drawer__tree",command:n,refreshKey:i,selectableTypes:"all",selectionMode:"multiple",sessionId:r,showContextMenu:!0,onOpenFile:e,onReferenceNodes:o=>t==null?void 0:t(o.map(DBe))})}function F_n({activeView:n,agentApprovals:e,agentRoster:t,approvalMessages:i,changedLayout:s,changedTreeCommand:r,isGitLoading:o,onOpenFile:a,onReferencePaths:l,repoState:c,selectedFilePath:d,sessionId:u,treeRefreshKey:h,workspaceTreeCommand:f}){return n==="approvals"&&e!=null?v.jsx(k_n,{approvals:i,onOpenRun:e.onOpenRun}):n==="agents"&&t!=null?v.jsx("div",{className:"chat-workspace-drawer__agents-panel",children:v.jsx(Myt,{layout:"desktop",members:t.members,showHeader:!1,onOpenRun:t.onOpenRun})}):n==="tree"?v.jsx(O_n,{command:f,refreshKey:h,selectedFilePath:d,sessionId:u,onOpenFile:a,onReferencePaths:l}):v.jsx(A_n,{command:r,isLoading:o,layout:s,repoState:c,selectedFilePath:d,onOpenFile:a})}function B_n({agentApprovals:n,agentRoster:e,defaultView:t="tree",onOpenFile:i,onReferencePaths:s,selectedFilePath:r,sessionId:o}){var B;const{t:a}=ht(),l=n!=null,c=e!=null,[d,u]=C.useState("folders"),[h,f]=C.useState(null),[g,m]=C.useState(null),[p,_]=C.useState(0),b=o!=null&&o!==""?["chat-workspace-drawer-git",o]:"chat-workspace-drawer-git",{data:y,isLoading:w,mutate:S}=Gn(b,()=>o!=null&&o!==""?KAe(o):ZAe(),{refreshInterval:3e3,revalidateOnFocus:!0}),x=(y==null?void 0:y.available)===!0?((B=y.changedFiles)==null?void 0:B.length)??0:0,L=C.useMemo(()=>n==null?[]:y_n(n.room),[n]),E=L.length>0,I=t==="approvals"&&!E&&c?"agents":t,M=c?"agents":"tree",N=I==="agents"&&!c||I==="approvals"&&!l,[T,D]=C.useState(()=>N?M:I),P=C.useMemo(()=>{if(e!=null)return{memberCount:e.members.length,pendingCount:e.members.reduce((V,W)=>V+W.pendingCount,0)}},[e]),R=T==="agents"&&!c||T==="approvals"&&!l;C.useEffect(()=>{R&&D(M)},[M,R]);const A=R?M:T,O=()=>{S(),_(V=>V+1)},F=V=>{D("changes"),u("folders"),f(W=>({action:V,id:((W==null?void 0:W.id)??0)+1}))},$=(V,W)=>{D("tree"),m(H=>({action:V,id:((H==null?void 0:H.id)??0)+1,path:W}))};return v.jsxs("aside",{className:"chat-workspace-drawer","aria-label":a("chat.workspaceDrawerTitle"),children:[v.jsx(x_n,{activeView:A,agentApprovals:l?{count:L.length}:void 0,agentRoster:P,changedFilesCount:x,changedLayout:d,onActiveViewChange:D,onChangedLayoutChange:u,onChangedTreeCommand:F,onForceSync:O,onWorkspaceTreeCommand:$,selectedFilePath:r}),v.jsx("div",{className:"chat-workspace-drawer__body",children:v.jsx("div",{className:"chat-workspace-drawer__view-panel",children:v.jsx(F_n,{activeView:A,agentApprovals:n,agentRoster:e,approvalMessages:L,changedLayout:d,changedTreeCommand:h,isGitLoading:w,repoState:y,selectedFilePath:r,sessionId:o,treeRefreshKey:p,workspaceTreeCommand:g,onOpenFile:i,onReferencePaths:s})},A)})]})}const Pce=n=>{const e=[],t=new Set;for(const i of n){const s=i==null?void 0:i.trim();s==null||s===""||t.has(s)||(t.add(s),e.push(s))}return e},SY=n=>{var s;const e=((s=n==null?void 0:n.selectedPath)==null?void 0:s.trim())||null,t=Pce([...(n==null?void 0:n.openPaths)??[],e]),i=e!=null&&t.includes(e)?e:t.at(0)??null;return{openPaths:t,selectedPath:i,isOpen:(n==null?void 0:n.isOpen)===!0&&i!=null}},$_n=n=>({openPaths:n.openPaths,...n.selectedPath==null?{}:{selectedPath:n.selectedPath},isOpen:n.isOpen});function H_n({isTerminalOpen:n,session:e,setIsTerminalOpen:t}){const i=SY(e==null?void 0:e.workspaceFileState),[s,r]=C.useState("terminal"),[o,a]=C.useState(i.selectedPath),[l,c]=C.useState(i.openPaths),[d,u]=C.useState(i.isOpen),h=n&&s==="terminal",f=d&&o!=null&&s==="file",g=h||f,m=JSON.stringify((e==null?void 0:e.workspaceFileState)??null);C.useEffect(()=>{const M=SY(e==null?void 0:e.workspaceFileState);c(M.openPaths),a(M.selectedPath),u(M.isOpen),r(N=>M.isOpen&&M.selectedPath!=null?"file":N==="file"?"terminal":N)},[m,e==null?void 0:e.id]);const p=M=>{const N=SY(M);c(N.openPaths),a(N.selectedPath),u(N.isOpen),(e==null?void 0:e.id)!=null&&f1(e.id,{workspaceFileState:$_n(N)}).catch(T=>{console.error("[chat] failed to persist workspace file state:",T)})};return{handleCloseAllWorkspaceFileTabs:()=>{p({openPaths:[],selectedPath:null,isOpen:!1}),n&&r("terminal")},handleCloseTerminal:()=>{t(!1),d&&o!=null&&r("file")},handleCloseWorkspaceFile:()=>{p({openPaths:l,selectedPath:o,isOpen:!1}),n&&r("terminal")},handleCloseOtherWorkspaceFileTabs:M=>{l.includes(M)&&(p({openPaths:[M],selectedPath:M,isOpen:!0}),r("file"))},handleCloseWorkspaceFileTab:M=>{const N=l.filter(P=>P!==M),T=l.indexOf(M),D=o===M?N[Math.min(Math.max(T-1,0),N.length-1)]??null:o;p({openPaths:N,selectedPath:D,isOpen:d&&D!=null}),D==null&&n&&r("terminal")},handleCloseWorkspaceFileTabsToRight:M=>{const N=l.indexOf(M);if(N<0)return;const T=l.slice(0,N+1),D=o!=null&&T.includes(o)?o:M;p({openPaths:T,selectedPath:D,isOpen:d&&D!=null})},handleOpenWorkspaceFile:M=>{p({openPaths:Pce([...l,M]),selectedPath:M,isOpen:!0}),r("file")},handleSelectWorkspaceFile:M=>{p({openPaths:Pce([...l,M]),selectedPath:M,isOpen:!0}),r("file")},handleToggleTerminal:()=>{if(s!=="terminal"){r("terminal"),t(!0);return}t(!n)},openWorkspaceFilePaths:l,selectedWorkspaceFilePath:o,shouldShowBottomPanel:g,shouldShowFileEditor:f,shouldShowTerminal:h}}const V_n=240;function j_n(n){const[e,t]=C.useState(n),[i,s]=C.useState(n);return C.useEffect(()=>{if(n){t(!0);const o=window.setTimeout(()=>{s(!0)},0);return()=>{window.clearTimeout(o)}}if(s(!1),!e)return;const r=window.setTimeout(()=>{t(!1)},V_n);return()=>{window.clearTimeout(r)}},[n,e]),{isRendered:e,isVisible:i}}const W_n=n=>n==="workspace"?n:void 0;function z_n(){const{values:n,update:e}=Rf({keys:["layout"],defaults:{layout:""},omit:{layout:i=>i===""}}),t=W_n(n.layout);return{activeLayout:t,isWorkspaceDrawerOpen:t==="workspace",setWorkspaceDrawerOpen:i=>e({layout:i?"workspace":""})}}function U_n({actions:n,closeLabel:e,fullscreenEnterLabel:t,fullscreenExitLabel:i,isFullscreen:s,meta:r,onClose:o,onToggleFullscreen:a,title:l}){const c=s?i:t;return v.jsxs("div",{className:"dock-panel__header",children:[v.jsxs("div",{className:"dock-panel__header-main",children:[v.jsx("span",{className:"dock-panel__title",children:l}),r!=null&&v.jsx("span",{className:"dock-panel__meta",children:r})]}),v.jsx("div",{className:"dock-panel__header-spacer"}),(n!=null||a!=null||o!=null)&&v.jsxs("div",{className:"dock-panel__header-actions",children:[n,a!=null&&c!=null&&v.jsx(qe,{type:"text",className:"dock-panel__close-btn dock-panel__fullscreen-btn","data-dock-panel-no-resize":"true",icon:v.jsx("span",{className:"material-symbols-rounded",children:s?"fullscreen_exit":"fullscreen"}),title:c,"aria-label":c,onClick:a}),o!=null&&e!=null&&v.jsx(qe,{type:"text",className:"dock-panel__close-btn","data-dock-panel-no-resize":"true",icon:v.jsx("span",{className:"material-symbols-rounded",children:"close"}),title:e,"aria-label":e,onClick:o})]})]})}const K_n=180;function Z_n(){const[n,e]=C.useState(!1),[t,i]=C.useState(!1),s=C.useRef(null),r=C.useCallback(()=>{s.current!=null&&(window.clearTimeout(s.current),s.current=null)},[]),o=C.useCallback(()=>{r(),i(!1),e(!0)},[r]),a=C.useCallback(()=>{r(),i(!0),s.current=window.setTimeout(()=>{e(!1),i(!1),s.current=null},K_n)},[r]),l=C.useCallback(()=>{if(n&&!t){a();return}o()},[o,a,n,t]);return C.useEffect(()=>r,[r]),{isFullscreen:n,isFullscreenExiting:t,toggleFullscreen:l}}const q_n=240,xY=(n,e,t)=>Math.min(Math.max(n,e),Math.max(e,t)),G_n=n=>(n==null?void 0:n.closest('button, a, input, textarea, select, option, [role="button"], [data-dock-panel-no-resize="true"]'))!=null;function IXe({enterMotion:n="slide-up",allowResize:e=!0,allowFullscreen:t=!1,children:i,className:s,closeLabel:r,defaultHeight:o=q_n,footer:a,fullscreenEnterLabel:l,fullscreenExitLabel:c,isResizeDisabled:d=!1,isOpen:u=!0,maxHeight:h=520,meta:f,minHeight:g=180,onClose:m,resizeLabel:p,storageKey:_,title:b,actions:y}){const w=C.useRef(null),S=C.useRef(null),[x,L]=C.useState(!1),{isFullscreen:E,isFullscreenExiting:I,toggleFullscreen:M}=Z_n(),[N,T]=C.useState(()=>{const A=Number(localStorage.getItem(_));return Number.isFinite(A)&&A>0?xY(A,g,h):xY(o,g,h)}),D=e&&!d&&!E;C.useEffect(()=>{localStorage.setItem(_,String(N))},[N,_]),C.useEffect(()=>()=>{document.body.style.cursor="",document.body.style.userSelect=""},[]),C.useEffect(()=>{if(!D||!x)return;const A=F=>{const $=S.current;if($==null)return;const B=xY($.startHeight+$.startY-F.clientY,g,$.maxHeight);T(B)},O=()=>{S.current=null,L(!1),document.body.style.cursor="",document.body.style.userSelect=""};return window.addEventListener("pointermove",A),window.addEventListener("pointerup",O),window.addEventListener("pointercancel",O),()=>{window.removeEventListener("pointermove",A),window.removeEventListener("pointerup",O),window.removeEventListener("pointercancel",O)}},[x,g,D]);const P=A=>{if(!D||G_n(A.target))return;A.preventDefault();const O=w.current,F=O==null?void 0:O.parentElement,$=F==null?void 0:F.getBoundingClientRect().height;S.current={startY:A.clientY,startHeight:(O==null?void 0:O.getBoundingClientRect().height)??N,maxHeight:$!=null?Math.min(h,$-96):h},L(!0),document.body.style.cursor="row-resize",document.body.style.userSelect="none"},R=C.useMemo(()=>({"--dock-panel-height":`${N}px`,"--dock-panel-max-height":`${h}px`,"--dock-panel-min-height":`${g}px`}),[h,g,N]);return v.jsxs("div",{ref:w,className:`dock-panel ${u&&n==="slide-up"?"is-entering-slide-up":""} ${u?"is-open":"is-closing"} ${s??""} ${x?"is-resizing":""} ${D?"is-resizable":"is-static"} ${d||E?"is-resize-disabled":""} ${E?"is-fullscreen":""} ${I?"is-fullscreen-exiting":""}`,style:R,children:[D&&v.jsx("div",{className:"dock-panel__resize-strip",title:p,onPointerDown:P}),v.jsx(U_n,{actions:y,closeLabel:r,fullscreenEnterLabel:l,fullscreenExitLabel:c,isFullscreen:E,meta:f,title:b,onClose:m,onToggleFullscreen:t?M:void 0}),v.jsx("div",{className:"dock-panel__body",children:i}),a!=null&&v.jsx("div",{className:"dock-panel__footer",children:a})]})}const MXe=320,NXe="chatBottomDockHeight",DXe=620,TXe=220;function X_n({onActivate:n,onRename:e,panes:t}){const[i,s]=C.useState(null),[r,o]=C.useState(""),a=C.useRef(null),l=C.useRef(null);C.useEffect(()=>{i!=null&&window.requestAnimationFrame(()=>{var h,f;(h=a.current)==null||h.focus(),(f=a.current)==null||f.select()})},[i]),C.useEffect(()=>{i!=null&&t.every(h=>h.id!==i)&&(l.current=null,s(null),o(""))},[i,t]);const c=h=>{n(h.id),l.current=h.id,s(h.id),o(h.title)},d=()=>{l.current=null,s(null),o("")};return{cancelEditing:d,editingInputRef:a,editingTerminalId:i,editingTitle:r,finishEditing:()=>{const h=l.current;if(h!=null){const f=r.trim();f!==""&&e(h,f)}d()},setEditingTitle:o,startEditing:c}}function Y_n({activeTerminalId:n,infoById:e,panes:t,onActivate:i,onClose:s,onMove:r,onRename:o}){const{t:a}=ht(),[l,c]=C.useState(null),[d,u]=C.useState(null),{cancelEditing:h,editingInputRef:f,editingTerminalId:g,editingTitle:m,finishEditing:p,setEditingTitle:_,startEditing:b}=X_n({onActivate:i,onRename:o,panes:t}),y=(x,L)=>{c(L),x.dataTransfer.effectAllowed="move",x.dataTransfer.setData("text/plain",L);const E=x.currentTarget.closest(".chat-terminal-view__manager-item");E instanceof HTMLElement&&x.dataTransfer.setDragImage(E,12,14)},w=(x,L)=>{if(x.preventDefault(),x.dataTransfer.dropEffect="move",l===L){u(null);return}const E=x.currentTarget.getBoundingClientRect(),I=x.clientY<E.top+E.height/2?"before":"after";u(M=>(M==null?void 0:M.terminalId)===L&&M.placement===I?M:{terminalId:L,placement:I})},S=(x,L)=>{x.preventDefault();const E=l??x.dataTransfer.getData("text/plain"),I=(d==null?void 0:d.terminalId)===L?d.placement:"before";c(null),u(null),E!==""&&E!==L&&r(E,L,I)};return v.jsx("aside",{className:"chat-terminal-view__manager","aria-label":a("chat.terminal.manageTerminals"),onDragLeave:x=>{(!(x.relatedTarget instanceof Node)||!x.currentTarget.contains(x.relatedTarget))&&u(null)},children:t.map(x=>{const L=e[x.id],E=x.id===g,I=(L==null?void 0:L.shellLabel)??a(`chat.terminal.shell.${x.shellKind}`),M=(L==null?void 0:L.isExited)===!0?a("chat.terminal.shellTooltipExited",{shell:I}):a("chat.terminal.shellTooltip",{shell:I});return v.jsxs("div",{className:`chat-terminal-view__manager-item ${x.id===n?"is-active":""} ${x.id===l?"is-dragging":""} ${E?"is-editing":""} ${(d==null?void 0:d.terminalId)===x.id?`is-drop-${d.placement}`:""}`,onClick:()=>i(x.id),onDragOver:N=>w(N,x.id),onDrop:N=>S(N,x.id),children:[v.jsx("button",{type:"button",className:"chat-terminal-view__manager-drag material-symbols-rounded",draggable:!0,title:a("chat.terminal.dragSession"),"aria-label":a("chat.terminal.dragSession"),onDragStart:N=>y(N,x.id),onDragEnd:()=>{c(null),u(null)},children:"drag_indicator"}),v.jsx(Qe,{title:E?null:M,placement:"top",children:v.jsx("span",{className:"chat-terminal-view__manager-title-wrap",children:E?v.jsxs(v.Fragment,{children:[v.jsx("span",{className:"chat-terminal-view__manager-edit-icon material-symbols-rounded",children:"edit"}),v.jsx("input",{ref:f,className:"chat-terminal-view__manager-title-input",value:m,"aria-label":a("chat.terminal.renameSession",{title:x.title}),onBlur:p,onChange:N=>_(N.target.value),onClick:N=>N.stopPropagation(),onDoubleClick:N=>N.stopPropagation(),onKeyDown:N=>{if(N.key==="Enter"){p();return}N.key==="Escape"&&h()}})]}):v.jsx("span",{className:"chat-terminal-view__manager-title-text",onDoubleClick:N=>{N.stopPropagation(),b(x)},children:x.title})})}),v.jsx(qe,{type:"text",className:"chat-terminal-view__manager-close","data-dock-panel-no-resize":"true",icon:v.jsx("span",{className:"material-symbols-rounded",children:"close"}),title:a("chat.terminal.closeNamedSession",{title:x.title}),"aria-label":a("chat.terminal.closeNamedSession",{title:x.title}),onClick:N=>{N.stopPropagation(),s(x.id)}})]},x.id)})})}/**
1512
+ `),interactions:i.interactions}}const N7n=(n,e)=>e?{...n,mainStart:"启动",mainEnd:"结束",startTasks:"任务",allTasksDone:"完成",askUserQuestion:"提问",resumeTask:"继续",userPrompt:"提示",userAnswer:"回答",receiveReply:"回复",taskStart:"开始",taskEnd:"结束",ganttMainSection:"主"}:{...n,mainStart:"Start",mainEnd:"End",startTasks:"Tasks",allTasksDone:"Done",askUserQuestion:"Ask",resumeTask:"Resume",userPrompt:"Prompt",userAnswer:"Answer",receiveReply:"Reply",taskStart:"Start",taskEnd:"End",ganttMainSection:"Main"};function NR(n){const{task:e,viewMode:t,className:i,style:s}=n,r=te.useRef(null),{t:o,i18n:a}=ht(),{isCompactLayout:l}=Mr(),c=te.useMemo(()=>({mainStart:o("chat.timeline.mainStart"),mainEnd:o("chat.timeline.mainEnd"),startTasks:o("chat.timeline.startTasks"),allTasksDone:o("chat.timeline.allTasksDone"),askUserQuestion:o("chat.timeline.askUserQuestion"),edit:o("chat.timeline.edit"),resumeTask:o("chat.timeline.resumeTask"),userPrompt:o("chat.timeline.userPrompt"),userAnswer:o("chat.timeline.userAnswer"),receiveReply:o("chat.timeline.receiveReply"),taskStart:o("chat.timeline.taskStart"),taskEnd:o("chat.timeline.taskEnd"),ganttTitle:o("chat.timeline.ganttTitle"),ganttMainSection:o("chat.timeline.ganttMainSection"),ganttTasksSection:o("chat.timeline.ganttTasksSection")}),[o]),d=te.useMemo(()=>{var p;return l?N7n(c,((p=a.resolvedLanguage)==null?void 0:p.startsWith("zh"))===!0):c},[a.resolvedLanguage,l,c]),u=te.useMemo(()=>t==="gantt"?S7n(e,d,{compact:l}):M7n(e,d),[d,l,e,t]),h=te.useId(),f=te.useMemo(()=>h.replace(/\W/g,"_"),[h]),g=te.useRef(new Map),m=te.useMemo(()=>u.code,[u.code]);return te.useEffect(()=>{let p=!1;return(async()=>{const y=(await re(()=>import("./mermaid.core-DgAHGSOR.js").then(I=>I.b5),[])).default,w=getComputedStyle(document.body).fontFamily;if(y.initialize({startOnLoad:!1,securityLevel:"loose",themeVariables:{fontFamily:w,fontSize:l?"12px":"14px"},gitGraph:l?{rotateCommitLabel:!1,showBranches:!1}:{},gantt:{topAxis:!0,displayMode:"compact",gridLineStartPadding:0,leftPadding:l?8:16,rightPadding:l?8:16,topPadding:l?28:36,barHeight:l?16:20,barGap:l?3:4,fontSize:l?10:11,sectionFontSize:l?10:11}}),p)return;const S=r.current;if(!S)return;const{svg:x,bindFunctions:L}=await y.render(f,m);if(p)return;S.innerHTML=x;const E=S.querySelector("svg");if(E){E.classList.add("session-timeline-mermaid__svg");for(const I of u.interactions){const M=E.querySelector(`#${CSS.escape(I.id)}`);M&&(M.classList.add("session-timeline-mermaid__interactive"),M.addEventListener("click",()=>{const N=g.current.get(I.id);N&&console.warn(N.payload)}))}}typeof L=="function"&&L(S)})(),()=>{p=!0}},[u.interactions,l,m,f]),te.useEffect(()=>{g.current=new Map(u.interactions.map(p=>[p.id,{label:p.label,payload:p.payload}]))},[u.interactions]),v.jsx("div",{ref:r,className:["session-timeline-panel",`session-timeline-panel--${t}`,l?"session-timeline-panel--compact":"",i??""].filter(Boolean).join(" "),style:s})}const D7n=(n,e)=>{const t=[];let i=0;const s=(o,a,l,c,d)=>{t.push({id:`${o}-${a}-${l}-${i}`,label:o,startTime:a,endTime:l,depth:c,payload:d}),i+=1},r=(o,a)=>{for(const l of o)l.type==="tool__StartTasks"?s(e.startTasks,l.startTime,l.endTime,a,l):l.type==="tool__AskUserQuestion"?s(e.askUserQuestion,l.startTime,l.endTime,a,l):l.type==="tool__Edit"?s(e.edit,l.startTime,l.endTime,a,l):l.type==="tool__ResumeTask"?s(e.resumeTask,l.startTime,l.endTime,a,l):l.type==="user__Prompt"&&s(e.userPrompt,l.startTime,l.endTime,a,l)};return s(e.mainStart,n.startTime,n.startTime,0),r(n.events??[],0),s(e.mainEnd,n.endTime,n.endTime,0),t.map((o,a)=>({...o,index:a})).sort((o,a)=>{const l=oh(o.startTime)-oh(a.startTime);return l!==0?l:o.index-a.index}).map(({index:o,...a})=>a)};function Axe({task:n}){const{t:e}=ht(),{isCompactLayout:t}=Mr(),[i,s]=te.useState(""),r=te.useRef(null),[o,a]=te.useState(240),l=te.useMemo(()=>({mainStart:e("chat.timeline.mainStart"),mainEnd:e("chat.timeline.mainEnd"),startTasks:e("chat.timeline.startTasks"),askUserQuestion:e("chat.timeline.askUserQuestion"),edit:e("chat.timeline.edit"),resumeTask:e("chat.timeline.resumeTask"),userPrompt:e("chat.timeline.userPrompt")}),[e]),c=te.useMemo(()=>D7n(n,l),[l,n]),d=te.useMemo(()=>{const g=i.trim().toLowerCase();return g?c.filter(m=>`${m.label} ${m.startTime} ${m.endTime}`.toLowerCase().includes(g)):c},[c,i]),u=e("chat.timelineEmptyValue"),h=te.useCallback(g=>{const m=$_(g.startTime),p=$_(g.endTime);return v.jsx("span",{className:"session-timeline-event-table__time",children:m===p?m:`${m} → ${p}`})},[]),f=te.useMemo(()=>t?[{title:e("chat.timelineEventName"),key:"summary",render:(g,m)=>{const p=[{key:e("chat.timelineInput"),value:m.input},{key:e("chat.timelineOutput"),value:m.output}].filter(_=>_.value!=null&&_.value!=="");return v.jsxs("div",{className:"session-timeline-event-table__summary",children:[v.jsx("span",{className:"session-timeline-event-table__label",style:{paddingLeft:`${m.depth*12}px`},children:m.label}),p.length>0&&v.jsx("div",{className:"session-timeline-event-table__detail-list",children:p.map(_=>v.jsxs("span",{className:"session-timeline-event-table__detail-item",children:[v.jsx("span",{className:"session-timeline-event-table__detail-key",children:_.key}),v.jsx("span",{className:"session-timeline-event-table__detail-text",children:_.value})]},_.key))})]})}},{title:e("chat.timelineTiming"),key:"time",width:120,render:(g,m)=>v.jsx("span",{className:"session-timeline-event-table__cell-timing",children:h(m)})}]:[{title:e("chat.timelineEventName"),key:"label",width:180,render:(g,m)=>v.jsx("span",{className:"session-timeline-event-table__label",style:{paddingLeft:`${m.depth*16}px`},children:m.label})},{title:e("chat.timelineInput"),key:"input",width:180,render:(g,m)=>v.jsx("span",{className:"session-timeline-event-table__value",children:m.input??u})},{title:e("chat.timelineOutput"),key:"output",width:180,render:(g,m)=>v.jsx("span",{className:"session-timeline-event-table__value",children:m.output??u})},{title:e("chat.timelineTiming"),key:"time",width:160,render:(g,m)=>h(m)}],[u,t,h,e]);return te.useEffect(()=>{const g=r.current;if(!g)return;const m=()=>{const _=g.querySelector(".session-timeline-event-table__header"),b=g.querySelector(".ant-table-pagination"),y=(_==null?void 0:_.offsetHeight)??0,w=(b==null?void 0:b.offsetHeight)??0,S=Math.max(160,g.clientHeight-y-w-16);a(x=>x===S?x:S)};m();const p=new ResizeObserver(m);return p.observe(g),()=>{p.disconnect()}},[]),v.jsxs("div",{ref:r,className:"session-timeline-event-table",children:[v.jsxs("div",{className:"session-timeline-event-table__header",children:[v.jsx("span",{className:"session-timeline-event-table__title",children:e("chat.timeline.eventListTitle")}),v.jsx(yn,{className:"session-timeline-event-table__search",allowClear:!0,value:i,onChange:g=>s(g.target.value),placeholder:e("chat.timeline.eventListSearch")})]}),v.jsx(Df,{className:"session-timeline-event-table__table",size:"small",columns:f,dataSource:d,rowKey:"id",onRow:g=>({onClick:()=>{g.payload&&console.warn(g.payload)}}),pagination:{pageSize:20,showSizeChanger:!t,pageSizeOptions:["10","20","50"]},scroll:{y:o},locale:{emptyText:e("chat.timelineEmpty")}})]})}const B7={startTime:"09:40:00",endTime:"11:30:48",events:[{type:"tool__StartTasks",startTime:"09:41:02",endTime:"10:10:25",tasks:{taskA:{startTime:"09:41:10",endTime:"09:55:02",description:"Task A"},taskB:{startTime:"09:41:10",endTime:"09:50:40",description:"Task B"},taskC:{startTime:"09:41:10",endTime:"10:10:20",description:"Task C",events:[{type:"tool__StartTasks",startTime:"09:48:00",endTime:"10:05:30",tasks:{taskC0:{startTime:"09:49:10",endTime:"10:05:25",events:[{type:"tool__AskUserQuestion",startTime:"09:57:00",endTime:"09:59:23"},{type:"user__Prompt",startTime:"09:58:10",endTime:"09:58:20"}]}}},{type:"tool__Edit",startTime:"09:57:10",endTime:"09:59:20"},{type:"tool__ResumeTask",startTime:"09:59:22",endTime:"10:05:30"}]}}},{type:"tool__StartTasks",startTime:"10:41:02",endTime:"11:10:25",tasks:{taskA1:{startTime:"10:41:10",endTime:"10:55:02",description:"Task A1"},taskB1:{startTime:"10:41:10",endTime:"10:50:40",description:"Task B1"},taskC1:{startTime:"10:41:10",endTime:"11:10:20",description:"Task C1",events:[{type:"tool__StartTasks",startTime:"10:48:00",endTime:"11:05:30",tasks:{taskC10:{startTime:"10:49:10",endTime:"11:05:25",events:[{type:"tool__AskUserQuestion",startTime:"10:57:00",endTime:"10:59:23"},{type:"user__Prompt",startTime:"10:58:10",endTime:"10:58:20"}]}}},{type:"tool__Edit",startTime:"10:57:10",endTime:"10:59:20"},{type:"tool__ResumeTask",startTime:"10:59:22",endTime:"11:05:30"}]}}}]};function T7n({messages:n}){const{t:e}=ht(),{isCompactLayout:t}=Mr(),[i,s]=te.useState("events");if(t){const r=[{key:"events",label:e("chat.timeline.eventListTitle")},{key:"gantt",label:e("chat.timeline.viewGantt")},{key:"git",label:e("chat.timeline.viewGit")}];return v.jsxs("div",{className:"chat-timeline-view chat-timeline-view--compact",children:[v.jsx("div",{className:"chat-timeline-view__tabs",role:"tablist","aria-label":e("chat.timelineTiming"),children:r.map(o=>v.jsx("button",{type:"button",role:"tab","aria-selected":i===o.key,className:`chat-timeline-view__tab ${i===o.key?"is-active":""}`,onClick:()=>s(o.key),children:o.label},o.key))}),v.jsxs("section",{className:`chat-timeline-view__panel ${i==="events"?"chat-timeline-view__panel--events":"chat-timeline-view__panel--diagram"}`,children:[i==="events"&&v.jsx(Axe,{task:B7}),i==="gantt"&&v.jsx(NR,{task:B7,viewMode:"gantt"}),i==="git"&&v.jsx(NR,{task:B7,viewMode:"git"})]})]})}return v.jsxs("div",{className:"chat-timeline-view",children:[v.jsx("section",{className:"session-timeline-section session-timeline-section--fixed",children:v.jsx(NR,{task:B7,viewMode:"gantt"})}),v.jsxs("section",{className:"session-timeline-section session-timeline-section--flex session-timeline-section--row",children:[v.jsx("div",{className:"session-timeline-column session-timeline-column--graph",children:v.jsx(NR,{task:B7,viewMode:"git"})}),v.jsx("div",{className:"session-timeline-column session-timeline-column--events",children:v.jsx(Axe,{task:B7})})]})]})}const Oxe=(n,e=!1)=>({icon:"settings_suggest",id:e?"mock-model-unavailable":"model-unavailable",isMock:e,message:n("chat.modelConfigRequired"),detail:n("chat.modelConfigRequiredHelp"),tone:"warning",title:n("chat.modelConfigRequiredTitle")}),vY=(n,e,t=!1)=>{const i=e.reason==="closed";return{action:t?void 0:"retry-connection",detail:n(i?"chat.connectionClosedHelp":"chat.connectionErrorHelp"),icon:i?"wifi_off":"cloud_off",id:t?i?"mock-connection-closed":"mock-connection-error":i?"connection-closed":"connection-error",isMock:t,message:e.message,tone:"error",title:n(i?"chat.connectionClosedTitle":"chat.connectionErrorTitle")}},Fxe=(n,e,t=!1)=>{const i=e.action==="retry-session-creation";return{...t||e.action==null?{}:{action:e.action},detail:n(i?"chat.sessionCreateFailedHelp":"chat.sessionErrorHelp"),icon:"error",id:t?"mock-session-error":i?"session-create-failed":"session-error",isMock:t,message:e.message,...!i&&e.code!=null&&e.code!==""?{meta:n("chat.sessionErrorCode",{code:e.code})}:{},tone:"error",title:n(i?"chat.sessionCreateFailedTitle":"chat.sessionErrorTitle")}},R7n=({errorState:n,isDebugMode:e,modelUnavailable:t,t:i})=>{const s=[],r=new Set;if(t&&(s.push(Oxe(i)),r.add("model-unavailable")),n!=null&&n.message.trim()!==""&&(n.kind==="session"?(s.push(Fxe(i,n)),r.add("session-error")):(s.push(vY(i,n)),r.add(n.reason==="closed"?"connection-closed":"connection-error"))),!e)return s;const o=[{scenario:"connection-error",notice:vY(i,{message:i("chat.debugMockConnectionErrorMessage"),reason:"error"},!0)},{scenario:"connection-closed",notice:vY(i,{message:i("chat.debugMockConnectionClosedMessage"),reason:"closed"},!0)},{scenario:"session-error",notice:Fxe(i,{message:i("chat.debugMockSessionErrorMessage"),code:"session_timeout"},!0)},{scenario:"model-unavailable",notice:Oxe(i,!0)}];for(const a of o)r.has(a.scenario)||s.push(a.notice);return s};function P7n({activeView:n,setActiveView:e,targetMessageId:t,targetToolUseId:i}){const s=C.useRef(""),r=i!=null&&i.trim()?`tool:${i.trim()}`:t!=null&&t.trim()?`message:${t.trim()}`:"";C.useEffect(()=>{r===""?s.current="":s.current!==r&&(s.current=r,n!=="history"&&e("history"))},[n,r,e])}const cK=n=>n!=null&&typeof n=="object"&&!Array.isArray(n)?n:{},rXe=n=>Array.isArray(n)?n.map(e=>hi(e)).filter(e=>!!e):[],hi=n=>typeof n=="string"&&n.trim()!==""?n.trim():void 0,xH=n=>n==="low"||n==="medium"||n==="high"||n==="max"?n:void 0,A7n=n=>{if(typeof n=="string"){const e=hi(n);return e?[e]:[]}return Array.isArray(n)?Array.from(new Set(n.map(e=>hi(e)).filter(e=>!!e))):[]},aM=(n,e)=>`${n},${e}`,hC=n=>{const e=hi(n);if(!e||!e.includes(","))return;const[t,i]=e.split(/,(.+)/),s=hi(t),r=hi(i);if(!(!s||!r))return{serviceKey:s,modelName:r,selectorValue:aM(s,r)}},oXe=n=>{const e=[];for(const[t,i]of Object.entries(n)){const s=hi(t);if(!s)continue;const r=i!=null&&typeof i=="object"?i:void 0,o=Array.isArray(r==null?void 0:r.models)?r.models:[];for(const a of o){const l=hi(a);l&&e.push({serviceKey:s,model:l,selectorValue:aM(s,l)})}}return e},O7n=(n,e,t)=>n.find(i=>i.serviceKey===e&&i.model===t),Nce=n=>{var r;const e=hi(n.value);if(!e)return;const t=hC(e);if(t){const o=O7n(n.serviceModels,t.serviceKey,t.modelName);return o?o.selectorValue:void 0}const i=n.serviceModels.filter(o=>o.model===e);if(i.length===0)return;const s=hi(n.preferredServiceKey);if(s){const o=i.find(a=>a.serviceKey===s);if(o)return o.selectorValue}return(r=i[0])==null?void 0:r.selectorValue},q2e=n=>{const e=hi(n.value);if(!e)return;const t=new Set(Array.from(n.builtinModels??[]).map(r=>hi(r)).filter(r=>!!r));if(t.has(e))return e;const i=Nce({value:e,serviceModels:n.serviceModels,preferredServiceKey:n.preferredServiceKey});if(i)return i;const s=hC(e);return s!=null&&s.modelName&&t.has(s.modelName)?s.modelName:n.preserveUnknown===!1?void 0:e},F7n=n=>{var s;const e=Array.from(n.builtinModels??[]).map(r=>hi(r)).filter(r=>!!r),t=hi(n.defaultModel);if(t){const r=hC(t),o=q2e({value:t,builtinModels:e,serviceModels:n.serviceModels,preferredServiceKey:(r==null?void 0:r.serviceKey)??n.defaultModelService,preserveUnknown:n.preserveUnknownDefaultModel});if(o)return o}const i=hi(n.defaultModelService);if(i){const r=n.serviceModels.find(o=>o.serviceKey===i);if(r)return r.selectorValue}return e.length>0?e[0]:(s=n.serviceModels[0])==null?void 0:s.selectorValue},aXe=n=>{var s;const e=hi(n.model);if(!e)return;const t=hC(e),i=t==null?[e]:[t.selectorValue,t.modelName,t.serviceKey];for(const r of i){const o=(s=n.models)==null?void 0:s[r];if(o!=null&&typeof o=="object"&&!Array.isArray(o))return o}},B7n=n=>{var s;const e=hi(n.model);if(!e)return;const t=hC(e),i=t==null?[e]:[t.selectorValue,t.modelName];for(const r of i){const o=(s=n.models)==null?void 0:s[r];if(o!=null&&typeof o=="object"&&!Array.isArray(o))return o}},G2e=n=>{const e=B7n(n);if(!e)return;const t=A7n(e.alias),i=hi(e.title),s=hi(e.description);if(!(t.length===0&&!i&&!s))return{aliases:t,title:i,description:s}},$7n=n=>{var e;return hi((e=aXe(n))==null?void 0:e.defaultAdapter)},H7n=n=>{var e;return xH((e=aXe(n))==null?void 0:e.effort)},X2e=n=>{const e=cK(n);return hi(e.defaultModel)??hi(e.model)},V7n=n=>xH(cK(n).effort),Bxe=n=>rXe(cK(n).includeModels),$xe=n=>rXe(cK(n).excludeModels),lXe=n=>{const e=X2e(n.adapterConfig);return q2e({value:e,builtinModels:n.builtinModels,serviceModels:n.serviceModels,preferredServiceKey:n.preferredServiceKey,preserveUnknown:n.preserveUnknown})},j7n=n=>{const e=xH(n.explicitEffort);if(e!=null)return{effort:e,source:"explicit"};const t=H7n({model:n.model,models:n.models});if(t!=null)return{effort:t,source:"model"};const i=V7n(n.adapterConfig);if(i!=null)return{effort:i,source:"adapter"};const s=xH(n.configEffort);return s!=null?{effort:s,source:"config"}:{effort:void 0,source:void 0}},Hxe=n=>{const e=hi(n.model),t=hi(n.selector);if(!e||!t)return!1;const i=hC(e),s=hC(t);return i?s?i.serviceKey===s.serviceKey&&i.modelName===s.modelName:i.serviceKey===t||i.modelName===t||e===t:e===t},Vxe=n=>{const e=hi(n.model);if(!e||e==="default")return{allowed:!0,includeModels:Bxe(n.adapterConfig),excludeModels:$xe(n.adapterConfig)};const t=Bxe(n.adapterConfig),i=$xe(n.adapterConfig),s=e===X2e(n.adapterConfig);return i.some(r=>Hxe({model:e,selector:r}))?{allowed:!1,reason:"excluded",includeModels:t,excludeModels:i}:!s&&t.length>0&&!t.some(r=>Hxe({model:e,selector:r}))?{allowed:!1,reason:"not_included",includeModels:t,excludeModels:i}:{allowed:!0,includeModels:t,excludeModels:i}},Dce=n=>{const e=hi(n.model);if(!e)return{model:e};const t=Vxe({model:e,adapterConfig:n.adapterConfig});if(t.allowed)return{model:e};const i=lXe({adapterConfig:n.adapterConfig,builtinModels:n.builtinModels,serviceModels:n.serviceModels,preferredServiceKey:n.preferredServiceKey,preserveUnknown:n.preserveUnknownDefaultModel});if(!i)return{error:{type:"missing_default_model",adapter:n.adapter,requestedModel:e,defaultModel:X2e(n.adapterConfig),reason:t.reason??"not_included",includeModels:t.includeModels.length>0?t.includeModels:void 0,excludeModels:t.excludeModels.length>0?t.excludeModels:void 0}};const s=Vxe({model:i,adapterConfig:n.adapterConfig});return s.allowed?{model:i,warning:{type:"adapter_model_fallback",adapter:n.adapter,requestedModel:e,resolvedModel:i,reason:t.reason??"not_included",includeModels:t.includeModels.length>0?t.includeModels:void 0,excludeModels:t.excludeModels.length>0?t.excludeModels:void 0}}:{error:{type:"default_model_not_allowed",adapter:n.adapter,requestedModel:e,defaultModel:i,reason:s.reason??"not_included",includeModels:s.includeModels.length>0?s.includeModels:void 0,excludeModels:s.excludeModels.length>0?s.excludeModels:void 0}}},Y2e=n=>{var e;return hi((e=n.service)==null?void 0:e.title)??n.serviceKey},cXe=n=>q2e({value:n.value,builtinModels:n.builtinModels,serviceModels:n.serviceModels,preferredServiceKey:n.defaultModelService,preserveUnknown:n.preserveUnknown}),Q2e=n=>F7n({defaultModel:n.defaultModel,defaultModelService:n.defaultModelService,builtinModels:n.builtinModels,serviceModels:n.serviceModels,preserveUnknownDefaultModel:n.preserveUnknownDefaultModel}),J2e=n=>{const e=hi(n.value),t=Array.from(n.availableAdapters),i=new Set(t),s=hi(n.defaultAdapter);return e&&(i.has(e)||n.preserveUnknown===!0)?e:s&&i.has(s)?s:t[0]},W7n=(n,e)=>{const t=hi(n);return t?Object.entries(e).filter(([,i])=>Array.isArray(i)&&i.some(s=>(s==null?void 0:s.value)===t)).map(([i])=>i):[]},z7n=n=>{const e=Array.from(n.availableAdapters),t=new Set(e),i=$7n({model:n.model,models:n.modelMetadata});if(i&&t.has(i))return i;const s=W7n(n.model,n.adapterBuiltinModels??{}),r=hi(n.defaultAdapter);return r&&s.includes(r)?r:s.length>0?s[0]:J2e({availableAdapters:e,defaultAdapter:n.defaultAdapter})},dXe=n=>{var t;const e=lXe({adapterConfig:n.adapter!=null?(t=n.adapters)==null?void 0:t[n.adapter]:void 0,builtinModels:n.builtinModels,serviceModels:n.serviceModels,preferredServiceKey:n.defaultModelService,preserveUnknown:!1});return e||Q2e({defaultModel:n.defaultModel,defaultModelService:n.defaultModelService,builtinModels:n.builtinModels??n.fallbackBuiltinModels,serviceModels:n.serviceModels,preserveUnknownDefaultModel:!1})},uXe="vf_chat_adapter_account:",U7n=n=>{const e=hi(n.label)??hi(n.id.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").trim().replace(/\b\w/g,i=>i.toUpperCase())),t=hi(n.value);return e!=null&&t!=null?`${e}: ${t}`:t??e},K7n=n=>{const e=((n==null?void 0:n.metrics)??[]).slice().sort((i,s)=>+(s.primary===!0)-+(i.primary===!0)).map(U7n).filter(i=>i!=null&&i!=="");if(e.length>0)return e.slice(0,2).join(" · ");const t=hi(n==null?void 0:n.summary);return t==null?void 0:`Quota: ${t}`},jxe=n=>{const e=hi(n);if(e!=null)try{const t=localStorage.getItem(`${uXe}${e}`);return t==null||t.trim()===""?void 0:t.trim()}catch{return}};function Z7n({adapter:n,model:e}){const t=hi(n),[i,s]=C.useState(()=>jxe(n));C.useEffect(()=>{s(jxe(t))},[t]);const{data:r}=Gn(t==null?null:["/api/adapters",t,e??""],t==null?null:()=>G3e(t,{model:e})),o=C.useMemo(()=>((r==null?void 0:r.accounts)??[]).filter(d=>d.status!=="missing").map(d=>({value:d.key,label:d.title,hint:d.description,meta:K7n(d.quota)})),[r==null?void 0:r.accounts]),a=C.useCallback((d,u=!1)=>{var m;const h=hi(d),f=new Set(o.map(p=>p.value));if(h!=null&&(f.has(h)||u))return h;const g=hi(r==null?void 0:r.defaultAccount);return g!=null&&f.has(g)?g:(m=o[0])==null?void 0:m.value},[o,r==null?void 0:r.defaultAccount]);C.useEffect(()=>{if(t==null){s(void 0);return}const d=a(i);s(u=>u===d?u:d)},[t,a,i]),C.useEffect(()=>{if(t!=null)try{const d=`${uXe}${t}`;i==null||i.trim()===""?localStorage.removeItem(d):localStorage.setItem(d,i)}catch{}},[t,i]);const l=C.useCallback(d=>{const u=a(d.account,!0)??hi(d.account);s(h=>h===u?h:u)},[a]),c=C.useCallback(d=>{const u=a(d);s(h=>h===u?h:u)},[a]);return{accountOptions:o,selectedAccount:a(i,!0)??i,setSelectedAccount:c,applySessionSelection:l,showAccountSelector:t!=null&&o.length>0}}const Wxe="vf_chat_effort",zxe=n=>n==="default"||n==="low"||n==="medium"||n==="high"||n==="max";function hXe(){const[n,e]=C.useState("default"),t=s=>{if(s!=null&&zxe(s)){e(s);return}e("default")};C.useEffect(()=>{try{const s=localStorage.getItem(Wxe);s&&zxe(s)&&t(s)}catch{}},[]),C.useEffect(()=>{try{localStorage.setItem(Wxe,n)}catch{}},[n]);const i=C.useMemo(()=>[{value:"default",label:"默认"},{value:"low",label:"低"},{value:"medium",label:"中"},{value:"high",label:"高"},{value:"max",label:"最高"}],[]);return{effort:n,setEffort:t,effortOptions:i}}function q7n({sessionId:n}){const[e,t]=C.useState(null),i=C.useCallback((s,r)=>{n&&kvt(n,s,r).then(()=>{t(o=>(o==null?void 0:o.id)===s?null:o)}).catch(o=>{console.error("Failed to submit interaction response:",o)})},[n]);return{interactionRequest:e,setInteractionRequest:t,handleInteractionResponse:i}}const G7n=n=>[...n].sort((e,t)=>{const i=e.displayLabel.localeCompare(t.displayLabel,void 0,{sensitivity:"base"});if(i!==0)return i;const s=e.modelName.localeCompare(t.modelName,void 0,{sensitivity:"base"});return s!==0?s:e.value.localeCompare(t.value,void 0,{sensitivity:"base"})}),e0e=n=>{var s;const e=(s=n.description)==null?void 0:s.trim(),t=Array.from(new Set((n.aliases??[]).filter(Boolean))),i=[...t.filter(r=>r!==n.title),n.modelName!==n.title?n.modelName:void 0,e].filter(r=>!!r);return{value:n.value,title:n.title,description:e,aliases:t,modelName:n.modelName,tooltipLines:i,serviceKey:n.serviceKey,serviceTitle:n.serviceTitle,searchText:[n.title,n.modelName,n.value,n.serviceTitle,n.serviceKey,e,...t,...n.searchTerms??[]].filter(Boolean).join(" "),displayLabel:n.title}},X7n=n=>Object.entries(n.mergedModelServices).map(([e,t])=>{var a;const i=t!=null&&typeof t=="object"?t:void 0,s=Y2e({serviceKey:e,service:i}),r=(s==null?void 0:s.trim())!==""?s:e,o=Array.isArray(i==null?void 0:i.models)?i.models.filter(l=>typeof l=="string"):[];return o.length===0?null:{key:`service:${e}`,title:r,description:((a=i==null?void 0:i.description)==null?void 0:a.trim())||void 0,options:o.map(l=>{const c=aM(e,l),d=G2e({model:c,models:n.mergedModels});return e0e({value:c,title:(d==null?void 0:d.title)??(d==null?void 0:d.aliases[0])??l,modelName:l,description:d==null?void 0:d.description,aliases:d==null?void 0:d.aliases,serviceKey:e,serviceTitle:s,searchTerms:[l,...(d==null?void 0:d.aliases)??[],d==null?void 0:d.title]})})}}).filter(e=>e!=null),Y7n=n=>Object.entries(n.activeBuiltinModels).map(([e,t])=>!Array.isArray(t)||t.length===0?null:{key:`builtin:${e}`,title:n.builtinGroupTitle(e),options:t.map(i=>{const s=G2e({model:i.value,models:n.mergedModels});return e0e({value:i.value,title:(s==null?void 0:s.title)??(s==null?void 0:s.aliases[0])??i.title,modelName:i.value,description:(s==null?void 0:s.description)??i.description,aliases:s==null?void 0:s.aliases,searchTerms:[i.value,...(s==null?void 0:s.aliases)??[],s==null?void 0:s.title]})})}).filter(e=>e!=null),Q7n=n=>n.recommendedModels.filter(e=>e.placement&&e.placement!=="modelSelector"?!1:Nce({value:e.service?aM(e.service,e.model):e.model,serviceModels:n.availableServiceModels,preferredServiceKey:e.service??n.defaultModelService})!=null).map(e=>{var c,d,u,h;const t=e.service?n.mergedModelServices[e.service]:void 0,i=e.service?Y2e({serviceKey:e.service,service:t}):(c=n.modelToService.get(e.model))==null?void 0:c.title,s=e.service?aM(e.service,e.model):e.model,r=G2e({model:s,models:n.mergedModels}),o=(d=e.title)==null?void 0:d.trim(),a=(u=e.description)==null?void 0:u.trim(),l=Nce({value:s,serviceModels:n.availableServiceModels,preferredServiceKey:e.service??n.defaultModelService})??e.model;return e0e({value:l,title:o||(r==null?void 0:r.title)||(r==null?void 0:r.aliases[0])||e.model,modelName:e.model,description:a||(r==null?void 0:r.description),aliases:r==null?void 0:r.aliases,serviceKey:e.service??((h=n.modelToService.get(e.model))==null?void 0:h.key),serviceTitle:i,searchTerms:[e.model,...(r==null?void 0:r.aliases)??[],r==null?void 0:r.title]})}),fXe=n=>{const e=new Map;for(const u of n.availableServiceModels){const h=n.mergedModelServices[u.serviceKey],f=Y2e({serviceKey:u.serviceKey,service:h});e.has(u.model)||e.set(u.model,{key:u.serviceKey,title:f})}const t=X7n({mergedModelServices:n.mergedModelServices,mergedModels:n.mergedModels}),i=Y7n({activeBuiltinModels:n.activeBuiltinModels,builtinGroupTitle:n.builtinGroupTitle,mergedModels:n.mergedModels}),s=Q7n({availableServiceModels:n.availableServiceModels,defaultModelService:n.defaultModelService,mergedModels:n.mergedModels,mergedModelServices:n.mergedModelServices,recommendedModels:n.recommendedModels,modelToService:e}),r=t.map(u=>u.options[0]??null).filter(u=>u!=null),o=G7n(s),a=[];r.length>0&&a.push({key:"service-preview",title:n.servicePreviewGroupTitle,options:r}),o.length>0&&a.push({key:"recommended",title:n.recommendedGroupTitle,options:o});const l=[...i,...t];a.push(...l);const c=new Map;for(const u of[...o,...r,...l.flatMap(h=>h.options)])c.has(u.value)||c.set(u.value,u);const d=Array.from(c.values());return{servicePreviewOptions:r,recommendedOptions:o,moreModelGroups:l,flatGroups:a,searchOptions:d}},gXe="modelSelector",J7n=n=>n!=null&&typeof n=="object"&&typeof n.model=="string"&&n.model.trim()!=="",LH=n=>n.placement==null||n.placement===gXe,tb=({model:n,service:e})=>`${e??""}::${n}`,e_n=({currentGeneral:n,recommendedModels:e})=>({...n??{},recommendedModels:e.length>0?e:void 0}),t_n=({currentRecommendedModels:n,nextRecommendedModel:e})=>{const t=Array.isArray(n)?n.filter(J7n):[],i=tb(e),s=t.some(r=>LH(r)&&tb(r)===i);return{isCurrentlyRecommended:s,recommendedModels:s?t.filter(r=>!(LH(r)&&tb(r)===i)):[{service:e.service,model:e.model,placement:gXe},...t]}},bY="vf_chat_adapter",yY="vf_chat_selected_model",mXe="vf_chat_selection_driver",Tce=n=>{try{const e=localStorage.getItem(n);return e==null||e.trim()===""?void 0:e}catch{return}},n_n=()=>Tce(mXe)==="model"?"model":"adapter",$7=n=>Array.isArray(n)?n.map(e=>e.value):[];function pXe({adapterLocked:n=!1}={}){var J,le,be,ae,ce,oe,he,ye,ke,Ce,Se,we,ve,Ee,me,xe,Oe,We,Ke,ze,Ve,Ne,Ie,Ge,Fe;const{t:e}=ht(),[t,i]=C.useState(()=>Tce(bY)),[s,r]=C.useState(()=>Tce(yY)),[o,a]=C.useState(()=>n_n()),[l,c]=C.useState(),{data:d,mutate:u}=Gn("/api/config",Z0),h=C.useMemo(()=>{var Re,Je;return((Je=(Re=d==null?void 0:d.sources)==null?void 0:Re.merged)==null?void 0:Je.adapters)??{}},[(le=(J=d==null?void 0:d.sources)==null?void 0:J.merged)==null?void 0:le.adapters]),f=C.useMemo(()=>{var Re,Je;return((Je=(Re=d==null?void 0:d.sources)==null?void 0:Re.merged)==null?void 0:Je.models)??{}},[(ae=(be=d==null?void 0:d.sources)==null?void 0:be.merged)==null?void 0:ae.models]),g=C.useMemo(()=>{var Re,Je;return((Je=(Re=d==null?void 0:d.sources)==null?void 0:Re.merged)==null?void 0:Je.modelServices)??{}},[(oe=(ce=d==null?void 0:d.sources)==null?void 0:ce.merged)==null?void 0:oe.modelServices]),m=C.useMemo(()=>{var Je,vt,$t;const Re=($t=(vt=(Je=d==null?void 0:d.sources)==null?void 0:Je.merged)==null?void 0:vt.general)==null?void 0:$t.recommendedModels;return Array.isArray(Re)?Re.filter(en=>en!=null&&typeof en=="object"&&typeof en.model=="string"&&en.model.trim()!==""):[]},[(ke=(ye=(he=d==null?void 0:d.sources)==null?void 0:he.merged)==null?void 0:ye.general)==null?void 0:ke.recommendedModels]),p=C.useMemo(()=>{var Je,vt,$t;const Re=($t=(vt=(Je=d==null?void 0:d.sources)==null?void 0:Je.user)==null?void 0:vt.general)==null?void 0:$t.recommendedModels;return Array.isArray(Re)?Re.filter(en=>en!=null&&typeof en=="object"&&typeof en.model=="string"&&en.model.trim()!==""):[]},[(we=(Se=(Ce=d==null?void 0:d.sources)==null?void 0:Ce.user)==null?void 0:Se.general)==null?void 0:we.recommendedModels]),_=C.useMemo(()=>new Set(p.filter(LH).map(Re=>tb({model:Re.model,service:Re.service}))),[p]),b=C.useMemo(()=>new Set(m.filter(LH).map(Re=>tb({model:Re.model,service:Re.service}))),[m]),y=C.useMemo(()=>{var Re,Je;return((Je=(Re=d==null?void 0:d.sources)==null?void 0:Re.merged)==null?void 0:Je.adapterBuiltinModels)??{}},[(Ee=(ve=d==null?void 0:d.sources)==null?void 0:ve.merged)==null?void 0:Ee.adapterBuiltinModels]),w=hi((Oe=(xe=(me=d==null?void 0:d.sources)==null?void 0:me.merged)==null?void 0:xe.general)==null?void 0:Oe.defaultAdapter),S=hi((ze=(Ke=(We=d==null?void 0:d.sources)==null?void 0:We.merged)==null?void 0:Ke.general)==null?void 0:ze.defaultModelService),x=hi((Ie=(Ne=(Ve=d==null?void 0:d.sources)==null?void 0:Ve.merged)==null?void 0:Ne.general)==null?void 0:Ie.defaultModel),L=C.useMemo(()=>Object.keys(h),[h]),E=C.useMemo(()=>oXe(g),[g]),I=C.useMemo(()=>Object.values(y).flatMap(Re=>$7(Re)),[y]),M=C.useMemo(()=>t&&y[t]?{[t]:y[t]}:y,[y,t]),N=C.useMemo(()=>Object.values(M).flatMap(Re=>$7(Re)),[M]),T=E.length>0||N.length>0,D=C.useCallback(Re=>J2e({value:Re,availableAdapters:L,defaultAdapter:w}),[L,w]),P=C.useCallback((Re,Je,vt=!1)=>cXe({value:Re,builtinModels:Je,serviceModels:E,defaultModelService:S,preserveUnknown:vt}),[E,S]),R=C.useCallback(Re=>{const Je=$7(Re!=null?y[Re]:void 0),vt=dXe({adapter:Re,adapters:h,defaultModel:x,defaultModelService:S,builtinModels:Je,fallbackBuiltinModels:I,serviceModels:E});return!Re||!vt?vt:Dce({adapter:Re,model:vt,adapterConfig:h[Re],builtinModels:Je,serviceModels:E,preferredServiceKey:S,preserveUnknownDefaultModel:!1}).model??vt},[y,I,E,x,S,h]),A=C.useCallback((Re,Je)=>!Re||!Je?Je:Dce({adapter:Re,model:Je,adapterConfig:h[Re],builtinModels:$7(y[Re]),serviceModels:E,preferredServiceKey:S,preserveUnknownDefaultModel:!1}).model??Je,[y,E,S,h]),O=C.useCallback(Re=>z7n({model:Re,availableAdapters:L,defaultAdapter:w,adapterBuiltinModels:y,modelMetadata:f}),[y,L,w,f]),F=C.useMemo(()=>Q2e({defaultModel:x,defaultModelService:S,builtinModels:I,serviceModels:E,preserveUnknownDefaultModel:!1}),[I,E,x,S]);C.useEffect(()=>{if(n)return;if(L.length===0){i(void 0),T||r(void 0);return}if(!T){r(void 0),i(vt=>D(vt));return}if(o==="model"){const vt=P(s,I,!1)??F,$t=O(vt)??D(t),en=A($t,vt);r(gt=>gt===en?gt:en),i(gt=>gt===$t?gt:$t);return}const Re=D(t),Je=R(Re);i(vt=>vt===Re?vt:Re),r(vt=>vt===Je?vt:Je)},[n,I,L.length,T,O,A,D,R,P,F,t,s,o]),C.useEffect(()=>{try{t==null||t.trim()===""?localStorage.removeItem(bY):localStorage.setItem(bY,t)}catch{}},[t]),C.useEffect(()=>{try{s==null||s.trim()===""?localStorage.removeItem(yY):localStorage.setItem(yY,s)}catch{}},[s]),C.useEffect(()=>{try{localStorage.setItem(mXe,o)}catch{}},[o]);const $=C.useCallback(Re=>{const Je=n?$7(t!=null?y[t]:void 0):I,vt=P(Re,Je,!1);if(!vt)return;a("model");const $t=n?t:O(vt)??D(t),en=A($t,vt);r(gt=>gt===en?gt:en),!n&&i(gt=>gt===$t?gt:$t)},[y,n,I,A,O,D,P,t]),B=C.useCallback(Re=>{const Je=D(Re);if(a("adapter"),i($t=>$t===Je?$t:Je),n)return;const vt=R(Je);r($t=>$t===vt?$t:vt)},[n,D,R]),V=C.useCallback(Re=>{const Je=hi(Re.adapter)??D(void 0),vt=$7(Je!=null?y[Je]:void 0),$t=P(Re.model,vt,!0)??P(Re.model,I,!0)??hi(Re.model)??R(Je);i(en=>en===Je?en:Je),r(en=>en===$t?en:$t)},[y,I,D,R,P]),W=C.useMemo(()=>P(s,N,!0)??s,[N,P,s]),H=C.useMemo(()=>L.map(Re=>{const Je=tw(Re);return{value:Re,label:C.createElement("span",{className:"adapter-option"},[Je.icon!=null?C.createElement("img",{key:"icon",className:"adapter-option__icon",src:Je.icon,alt:"","aria-hidden":!0}):C.createElement("span",{key:"fallback-icon",className:"adapter-option__icon adapter-option__icon--fallback material-symbols-rounded","aria-hidden":!0},"deployed_code"),C.createElement("span",{key:"text",className:"adapter-option__text"},Je.title)])}}),[L]),U=C.useCallback(async Re=>{var $t,en,gt,Ht,at,ft;const Je=($t=Re.serviceKey)==null?void 0:$t.trim(),vt=Re.modelName.trim();if(!((d==null?void 0:d.sources)==null||!Je||vt===""||l===Re.value)){c(Re.value);try{const{recommendedModels:Tt}=t_n({currentRecommendedModels:(Ht=(gt=(en=d==null?void 0:d.sources)==null?void 0:en.user)==null?void 0:gt.general)==null?void 0:Ht.recommendedModels,nextRecommendedModel:{service:Je,model:vt,placement:"modelSelector"}}),hn=e_n({currentGeneral:(ft=(at=d==null?void 0:d.sources)==null?void 0:at.user)==null?void 0:ft.general,recommendedModels:Tt});await Y3e("user","general",hn),await u()}catch(Tt){console.error("[chat] failed to update recommended models",Tt)}finally{c(void 0)}}},[(Fe=(Ge=d==null?void 0:d.sources)==null?void 0:Ge.user)==null?void 0:Fe.general,u,l]),Z=C.useCallback(Re=>{const Je=Re.serviceKey==null?void 0:tb({model:Re.modelName,service:Re.serviceKey}),vt={...Re,canToggleRecommendation:Re.serviceKey!=null&&Re.modelName.trim()!=="",isRecommended:Je!=null&&b.has(Je),isUserRecommended:Je!=null&&_.has(Je),label:null};return vt.label=v.jsx(CH,{option:vt,onToggleRecommendedModel:U,updatingRecommendedModelValue:l}),vt},[b,U,l,_]),G=C.useMemo(()=>fXe({activeBuiltinModels:M,availableServiceModels:E,defaultModelService:S,mergedModels:f,mergedModelServices:g,recommendedModels:m,recommendedGroupTitle:e("chat.modelGroupRecommended",{defaultValue:"推荐模型"}),servicePreviewGroupTitle:e("chat.modelGroupServices",{defaultValue:"模型服务"}),builtinGroupTitle:Re=>e("chat.modelGroupBuiltin",{adapter:Re,defaultValue:`${Re} (Default)`})}),[M,E,S,f,g,m,e]),q=C.useMemo(()=>G.searchOptions.map(Z),[Z,G.searchOptions]),K=C.useMemo(()=>G.recommendedOptions.map(Z),[Z,G.recommendedOptions]),X=C.useMemo(()=>G.servicePreviewOptions.map(Z),[Z,G.servicePreviewOptions]),ie=C.useMemo(()=>G.moreModelGroups.map(Re=>({...Re,options:Re.options.map(Z)})),[Z,G.moreModelGroups]),se=C.useMemo(()=>G.flatGroups.map(Re=>({key:Re.key,label:v.jsxs("div",{className:"model-group-label",children:[v.jsx("div",{className:"model-group-title",children:Re.title}),Re.description&&v.jsx("div",{className:"model-group-desc",children:Re.description})]}),options:Re.options.map(Z)})),[Z,G.flatGroups]);return{adapterOptions:H,applySessionSelection:V,hasAvailableModels:T,modelMenuGroups:ie,modelOptions:se,modelSearchOptions:q,recommendedModelOptions:K,servicePreviewModelOptions:X,selectedAdapter:t,selectedModel:s,selectedModelWithService:W,setSelectedAdapter:B,setSelectedModel:$,toggleRecommendedModel:U,updatingRecommendedModelValue:l}}const Uxe="vf_chat_permission_mode",Kxe=n=>n==="default"||n==="acceptEdits"||n==="plan"||n==="dontAsk"||n==="bypassPermissions";function CXe(){const[n,e]=C.useState("default"),t=s=>{if(s!=null&&Kxe(s)){e(s);return}e("default")};C.useEffect(()=>{try{const s=localStorage.getItem(Uxe);s&&Kxe(s)&&t(s)}catch{}},[]),C.useEffect(()=>{try{localStorage.setItem(Uxe,n)}catch{}},[n]);const i=C.useMemo(()=>[{value:"default",label:"默认"},{value:"acceptEdits",label:"接受编辑"},{value:"plan",label:"计划"},{value:"dontAsk",label:"不询问"},{value:"bypassPermissions",label:"跳过权限"}],[]);return{permissionMode:n,setPermissionMode:t,permissionModeOptions:i}}const i_n=27,s_n=n=>{let e="",t=0;for(;t<n.length;){if(n.charCodeAt(t)===i_n&&n[t+1]==="["){for(t+=2;t<n.length;){const i=n.charCodeAt(t);if(i>=64&&i<=126){t+=1;break}t+=1}continue}e+=n[t],t+=1}return e},Zxe=n=>s_n(n).trim(),_Xe=n=>{if((n==null?void 0:n.type)!=="error"||n.data!=null&&typeof n.data=="object"&&"fatal"in n.data&&n.data.fatal===!1)return null;const e=n.data!=null&&typeof n.data=="object"&&"code"in n.data&&typeof n.data.code=="string"&&n.data.code.trim()!==""?n.data.code:void 0;if(n.data!=null&&typeof n.data=="object"&&"message"in n.data){const t=n.data.message;if(typeof t=="string"){const i=Zxe(t);if(i!=="")return{message:i,code:e}}}if(typeof n.message=="string"){const t=Zxe(n.message);if(t!=="")return{message:t,code:e}}return null},vXe=(n,e)=>{if(e.type==="interaction_request")return{id:e.id,payload:e.payload};if(e.type==="interaction_response")return(n==null?void 0:n.id)===e.id||n==null?null:n;if(e.type==="session_updated"){const t=e.session;if("isDeleted"in t||t.status!=="waiting_input")return null}return e.type==="error"&&e.data!=null&&typeof e.data=="object"&&"fatal"in e.data&&e.data.fatal!==!1?null:n},r_n=(n,e,t)=>{let i=null;for(const s of n)i=vXe(i,s);return i??(t==="waiting_input"?e:null)},o_n=n=>{for(let e=n.length-1;e>=0;e-=1){const t=_Xe(n[e]);if(t!=null)return t}return null},a_n=20,kH=n=>({creationProgress:(n==null?void 0:n.creationProgress)??[],messages:(n==null?void 0:n.messages)??[],sessionInfo:(n==null?void 0:n.sessionInfo)??null,queuedMessages:(n==null?void 0:n.queuedMessages)??{steer:[],next:[]},errorState:(n==null?void 0:n.errorState)??null,interactionRequest:(n==null?void 0:n.interactionRequest)??null,isHydrated:(n==null?void 0:n.isHydrated)??!1}),l_n=(n,e)=>kH({...kH(n),...e}),c_n=n=>{const e=kH(n),t=e.isHydrated===!0?e:kH();return{creationProgress:t.creationProgress,messages:t.messages,sessionInfo:t.sessionInfo,queuedMessages:t.queuedMessages,errorState:t.errorState,interactionRequest:t.interactionRequest,isReady:t.isHydrated}},d_n=(n,e,t)=>{const i=l_n(n.get(e),t);for(n.has(e)&&n.delete(e),n.set(e,i);n.size>a_n;){const s=n.keys().next().value;if(s==null)break;n.delete(s)}return i},u_n=(n,e)=>{n.delete(e)},DR={steer:[],next:[]},h_n=n=>n==="user"||n==="assistant"||n==="system",qxe=n=>{const e=typeof n.createdAt=="number"?n.createdAt:n.ts;return typeof e=="number"?e:Date.now()},f_n=n=>n.type!=="message"?null:"message"in n&&n.message!=null?n.message:!h_n(n.role)||typeof n.content!="string"&&!Array.isArray(n.content)?null:{id:typeof n.id=="string"&&n.id!==""?n.id:`runtime-message-${qxe(n)}`,role:n.role,content:n.content,model:typeof n.model=="string"?n.model:void 0,createdAt:qxe(n)},g_n=(n,e)=>!e||(n==null?void 0:n.id)==null||n.id===""||n.parentSessionId!=null&&n.parentSessionId!==""?!1:n.status==="waiting_input",Gxe=(n,e)=>{const t=f_n(e);return t==null?n:n.find(s=>s.id===t.id)!=null?n.map(s=>s.id===t.id?t:s):[...n,t]},m_n=n=>{var e;return((e=n.toolCall)==null?void 0:e.id)??n.id},Xxe=(n,e)=>{if(e.type!=="tool_result")return n;const t=e.isError===!0?"error":"success";return n.map(i=>i.toolCall!=null&&m_n(i)===e.toolCallId?{...i,toolCall:{...i.toolCall,status:t,output:e.output}}:i)},Yxe=(n,e)=>e.type!=="session_creation_progress"?n:[...n,e.progress];function p_n({session:n,modelForQuery:e,effort:t,permissionMode:i,adapter:s,account:r,optimisticCreation:o,setInteractionRequest:a}){const{t:l}=ht(),{mutate:c}=Jy(),[d,u]=C.useState([]),[h,f]=C.useState([]),[g,m]=C.useState(null),[p,_]=C.useState({steer:[],next:[]}),[b,y]=C.useState(!1),[w,S]=C.useState(null),[x,L]=C.useState(0),E=C.useRef(!0),I=C.useRef(void 0),M=C.useRef(void 0),N=C.useRef(void 0),T=C.useRef(void 0),D=C.useRef(void 0),P=C.useRef(n==null?void 0:n.status),R=C.useRef(!1),A=C.useRef(null),O=C.useRef(n==null?void 0:n.id),F=C.useRef(0),$=C.useRef([]),B=C.useRef(new Map);O.current=n==null?void 0:n.id;const V=C.useCallback((K,X)=>d_n(B.current,K,X),[]),W=C.useCallback(K=>{u_n(B.current,K)},[]),H=C.useCallback(K=>{u(X=>{const ie=typeof K=="function"?K(X):K,se=O.current;if(se!=null&&se!==""){const J=B.current.get(se);V(se,{messages:ie,isHydrated:(J==null?void 0:J.isHydrated)===!0})}return ie})},[V]),U=C.useCallback(()=>{for(const K of $.current)clearTimeout(K);$.current=[]},[]),Z=C.useCallback(async(K={})=>{var se,J;const X=O.current;if(X==null||X==="")return;const ie=++F.current;try{const le=await XAe(X);if(O.current!==X||F.current!==ie)return;const be=le.messages;le.session&&Nee(c,le.session);let ae=[],ce=[],oe=null;const he=r_n(be,le.interaction??null,(se=le.session)==null?void 0:se.status),ye=o_n(be),ke=he==null&&((J=le.session)==null?void 0:J.status)==="failed"&&ye!=null?{kind:"session",message:ye.message,code:ye.code}:null,Ce=le.queuedMessages??DR;A.current=he,a(he),_(Ce),S(ke);for(const Se of be)ae=Gxe(ae,Se),ae=Xxe(ae,Se),ce=Yxe(ce,Se),Se.type==="session_info"&&Se.info!=null&&Se.info.type!=="summary"&&(oe=Se.info);V(X,{messages:ae,creationProgress:ce,sessionInfo:oe,queuedMessages:Ce,errorState:ke,interactionRequest:he,isHydrated:!0}),H(ae),f(ce),m(oe),K.updateReadiness!==!1&&setTimeout(()=>{O.current!==X||F.current!==ie||(y(!0),E.current=!1)},100)}catch(le){console.error("Failed to fetch history messages:",le)}},[c,a,H,V]),G=C.useCallback(()=>{U();for(const K of[0,800,2400,5e3,9e3,15e3]){const X=globalThis.setTimeout(()=>{Z({updateReadiness:!1})},K);$.current.push(X)}},[U,Z]),q=C.useCallback(()=>{(n==null?void 0:n.id)==null||n.id===""||(R.current=!0,S(null),V(n.id,{errorState:null}),E2.close(n.id),L(K=>K+1))},[n==null?void 0:n.id,V]);return C.useEffect(()=>{if((n==null?void 0:n.id)==null||n.id===""){u([]),f([]),m(null),_(DR),y(!0),S(null),a(null),A.current=null,E.current=!0,I.current=void 0,M.current=void 0,N.current=void 0,T.current=void 0,D.current=void 0,U();return}if(o!=null){U(),F.current+=1;const X=[o.message],ie=o.status==="failed"?{action:"retry-session-creation",code:"session_create_failed",kind:"session",message:o.errorMessage??l("chat.sessionCreateFailedMessage")}:null;A.current=null,a(null),u(X),m(null),_(DR),S(ie),y(!0),E.current=!1,V(n.id,{messages:X,sessionInfo:null,queuedMessages:DR,errorState:ie,interactionRequest:null,isHydrated:!0});return}const K=c_n(B.current.get(n.id));return u(K.messages),f(K.creationProgress),m(K.sessionInfo),_(K.queuedMessages),S(K.errorState),a(K.interactionRequest),A.current=K.interactionRequest,y(K.isReady),E.current=!K.isReady,Z(),Z(),()=>{U()}},[U,o,Z,n==null?void 0:n.id,a,l,V]),C.useEffect(()=>{if((n==null?void 0:n.id)==null||n.id===""){P.current=void 0;return}if(o!=null){P.current=n.status;return}const K=P.current;P.current=n.status,!(K==null||K===n.status)&&Z({updateReadiness:!1})},[o,Z,n==null?void 0:n.id,n==null?void 0:n.status]),C.useEffect(()=>{if((n==null?void 0:n.id)==null||n.id==="")return;if(o!=null){R.current=!0,E2.close(n.id);return}let K=!1,X;const ie=e??"",se=e!=null&&I.current!=null&&ie!==I.current&&(n==null?void 0:n.status)!=="running",J=t==="default"?"":t,le=M.current!=null&&J!==M.current&&(n==null?void 0:n.status)!=="running",be=i??"",ae=i!=null&&N.current!=null&&be!==N.current&&(n==null?void 0:n.status)!=="running",ce=s??"",oe=s!=null&&T.current!=null&&ce!==T.current&&(n==null?void 0:n.status)!=="running",he=r??"",ye=r!=null&&D.current!=null&&he!==D.current&&(n==null?void 0:n.status)!=="running",Ce=g_n(n,se||le||ae||oe||ye);Ce&&(R.current=!0,S(null),E2.send(n.id,{type:"terminate_session"}),E2.close(n.id)),I.current=ie,M.current=J,N.current=be,T.current=ce,D.current=he;const Se=setTimeout(()=>{if(K)return;const we={};e&&(we.model=e),t!=="default"&&(we.effort=t),i&&(we.permissionMode=i),s&&(we.adapter=s),r&&(we.account=r),X=E2.connect(n.id,{onOpen(){R.current=!1,S(ve=>{const Ee=(ve==null?void 0:ve.kind)==="session"?ve:null;return V(n.id,{errorState:Ee}),Ee})},onMessage(ve){if(K)return;const Ee=vXe(A.current,ve);if(Ee!==A.current&&(A.current=Ee,a(Ee),V(n.id,{interactionRequest:Ee}),Ee!=null&&(S(null),V(n.id,{errorState:null}))),ve.type==="interaction_response"){G();return}if(ve.type==="error"){const me=_Xe(ve);if(me!=null){const xe={kind:"session",message:me.message,code:me.code};S(xe),V(n.id,{errorState:xe})}return}if(ve.type==="session_updated"){const me=ve.session;she(me)&&W(me.id),Nee(c,me);return}if(ve.type==="session_queue_updated"){_(ve.queue),V(n.id,{queuedMessages:ve.queue});return}if(ve.type==="message"){H(me=>Gxe(me,ve));return}if(ve.type==="session_creation_progress"){f(me=>{const xe=Yxe(me,ve);return V(n.id,{creationProgress:xe}),xe});return}if(ve.type==="session_info"){ve.info!=null&&ve.info.type==="summary"?c("/api/sessions"):(m(ve.info??null),V(n.id,{sessionInfo:ve.info??null}),E.current&&setTimeout(()=>{K||E.current&&(y(!0),E.current=!1)},100));return}if(ve.type==="tool_result"){H(me=>Xxe(me,ve));return}ve.type==="interaction_request"&&(A.current=ve,a(ve),V(n.id,{interactionRequest:ve}))},onError(){if(K)return;const ve={kind:"connection",message:l("chat.connectionError"),reason:"error"};S(ve),V(n.id,{errorState:ve})},onClose(){if(!K){if(R.current){R.current=!1;return}S(ve=>{const Ee=ve??{kind:"connection",message:l("chat.connectionClosed"),reason:"closed"};return V(n.id,{errorState:Ee}),Ee})}}},Object.keys(we).length>0?we:void 0)},Ce?200:100);return()=>{K=!0,clearTimeout(Se),X==null||X()}},[s,r,U,t,e,c,o,i,G,x,Z,n==null?void 0:n.id,n==null?void 0:n.status,a,l,W,V]),{messages:d,creationProgress:h,setMessages:H,sessionInfo:g,queuedMessages:p,isReady:b,errorState:w,retryConnection:q,reconcileAfterInteraction:G}}const C_n=n=>n==="timeline"||n==="settings"||n==="history"?n:"history";function __n(){const{values:n,update:e}=Rf({keys:["view","terminal"],defaults:{view:"history",terminal:""},omit:{view:a=>a==="history",terminal:a=>a===""||a==="false"}}),t=n.view==="terminal",i=C_n(t?"history":n.view),s=n.terminal==="true"||t,r=C.useCallback(a=>{e({view:a})},[e]),o=C.useCallback(a=>{e({terminal:a?"true":"false"})},[e]);return C.useEffect(()=>{i!==n.view&&e({view:i})},[i,n.view,e]),C.useEffect(()=>{t&&e({view:"history",terminal:"true"})},[t,e]),{activeView:i,isTerminalOpen:s,setActiveView:r,setIsTerminalOpen:o}}function v_n({session:n}){const{t:e}=ht(),t=Su(Fb),i=(n==null?void 0:n.id)==null||n.id===""?void 0:t[n.id],{adapterOptions:s,applySessionSelection:r,modelMenuGroups:o,selectedAdapter:a,selectedModel:l,selectedModelWithService:c,setSelectedModel:d,setSelectedAdapter:u,modelSearchOptions:h,recommendedModelOptions:f,servicePreviewModelOptions:g,toggleRecommendedModel:m,updatingRecommendedModelValue:p,hasAvailableModels:_}=pXe({adapterLocked:(n==null?void 0:n.id)!=null}),{accountOptions:b,selectedAccount:y,setSelectedAccount:w,applySessionSelection:S,showAccountSelector:x}=Z7n({adapter:a,model:c}),{permissionMode:L,setPermissionMode:E,permissionModeOptions:I}=CXe(),{effort:M,setEffort:N,effortOptions:T}=hXe(),{activeView:D,isTerminalOpen:P,setActiveView:R,setIsTerminalOpen:A}=__n(),{interactionRequest:O,setInteractionRequest:F,handleInteractionResponse:$}=q7n({sessionId:n==null?void 0:n.id}),{creationProgress:B,messages:V,setMessages:W,sessionInfo:H,queuedMessages:U,isReady:Z,errorState:G,retryConnection:q,reconcileAfterInteraction:K}=p_n({session:n,modelForQuery:c,effort:M,permissionMode:L,adapter:a,account:y,optimisticCreation:i,setInteractionRequest:F}),X=C.useCallback((J,le)=>{K(),$(J,le)},[K,$]),ie=C.useRef(null),se=(n==null?void 0:n.status)==="running";return C.useEffect(()=>{if((n==null?void 0:n.id)==null||n.id===""){ie.current=null;return}const J=ie.current,le=(J==null?void 0:J.id)!==n.id;(le||(J==null?void 0:J.model)!==n.model||(J==null?void 0:J.adapter)!==n.adapter)&&r({model:n.model,adapter:n.adapter}),(le||(J==null?void 0:J.account)!==n.account)&&S({account:n.account}),(le||(J==null?void 0:J.permissionMode)!==n.permissionMode)&&E(n.permissionMode),(le||(J==null?void 0:J.effort)!==n.effort)&&N(n.effort),ie.current={id:n.id,model:n.model,permissionMode:n.permissionMode,adapter:n.adapter,account:n.account,effort:n.effort}},[S,n==null?void 0:n.adapter,n==null?void 0:n.account,n==null?void 0:n.effort,n==null?void 0:n.id,n==null?void 0:n.model,n==null?void 0:n.permissionMode,r,N,E]),{creationProgress:B,messages:V,sessionInfo:H,queuedMessages:U,interactionRequest:O,isReady:Z,errorState:G,retryConnection:q,isThinking:se,activeView:D,isTerminalOpen:P,setActiveView:R,setIsTerminalOpen:A,handleInteractionResponse:X,setMessages:W,placeholder:n!=null&&n.id?void 0:e("chat.newSessionPlaceholder"),modelMenuGroups:o,modelSearchOptions:h,recommendedModelOptions:f,servicePreviewModelOptions:g,toggleRecommendedModel:m,updatingRecommendedModelValue:p,selectedModel:l,modelForQuery:c,setSelectedModel:d,effort:M,setEffort:N,effortOptions:T,permissionMode:L,setPermissionMode:E,permissionModeOptions:I,selectedAdapter:a,setSelectedAdapter:u,selectedAccount:y,setSelectedAccount:w,accountOptions:b,showAccountSelector:x,adapterOptions:s,hasAvailableModels:_,modelUnavailable:!_}}const b_n=n=>{var e,t;return n.role!=="agent"?!1:n.kind==="attention"||((e=n.run)==null?void 0:e.status)==="waiting"||((t=n.member)==null?void 0:t.status)==="waiting"};function y_n(n){var s;const e=xOe(n),t=new Set,i=[];for(let r=e.messages.length-1;r>=0;r-=1){const o=e.messages[r];if(!b_n(o))continue;const a=((s=o.run)==null?void 0:s.runKey)??o.id;t.has(a)||(t.add(a),i.push(o))}return i.reverse()}const w_n=[{key:"folders",icon:"account_tree",labelKey:"chat.workspaceDrawerChangedFolders"},{key:"flat",icon:"view_list",labelKey:"chat.workspaceDrawerChangedFlat"}],S_n={type:"divider"},wY=n=>v.jsx("span",{className:"material-symbols-rounded chat-workspace-drawer__menu-icon",children:n});function x_n({activeView:n,agentApprovals:e,agentRoster:t,changedFilesCount:i,changedLayout:s,onActiveViewChange:r,onChangedLayoutChange:o,onChangedTreeCommand:a,onForceSync:l,onWorkspaceTreeCommand:c,selectedFilePath:d}){const{t:u}=ht(),h=C.useMemo(()=>[{key:"tree",icon:"folder",label:u("chat.workspaceDrawerTree")},{key:"changes",icon:"difference",label:u("chat.workspaceDrawerChangedFiles"),count:i},...e==null?[]:[{key:"approvals",icon:"approval",label:u("chat.workspaceDrawerApprovals"),count:e.count}],...t==null?[]:[{key:"agents",icon:"groups",label:u("chat.workspaceDrawerAgents"),count:t.pendingCount>0?t.pendingCount:t.memberCount}]],[e,t,i,u]),f=C.useMemo(()=>[{key:"force-sync",label:u("chat.workspaceDrawerForceSync"),icon:wY("sync"),onClick:l},...n==="changes"?[S_n,{key:"display-mode",label:u("chat.workspaceDrawerDisplayMode"),icon:wY("view_module"),children:w_n.map(b=>({key:`layout:${b.key}`,label:u(b.labelKey),icon:wY(s===b.key?"check":b.icon),onClick:()=>o(b.key)}))}]:[]],[n,s,o,l,u]),g=d!=null&&d!=="",m=n!=="agents"&&n!=="approvals",p=()=>{if(n==="tree"){c("expand");return}a("expand")},_=()=>{if(n==="tree"){c("collapse");return}a("collapse")};return v.jsxs("div",{className:"chat-workspace-drawer__toolbar",children:[v.jsx("div",{className:"chat-workspace-drawer__view-actions",children:h.map(b=>v.jsx(Qe,{title:b.label,children:v.jsxs(qe,{type:"text",className:`chat-workspace-drawer__view-btn ${n===b.key?"is-active":""}`,"aria-label":b.label,"aria-pressed":n===b.key,onClick:()=>r(b.key),children:[v.jsx("span",{className:"material-symbols-rounded",children:b.icon}),b.count!=null&&b.count>0&&v.jsx("span",{className:"chat-workspace-drawer__view-count",children:b.count})]})},b.key))}),m&&v.jsxs("div",{className:"chat-workspace-drawer__toolbar-actions",children:[v.jsx(Qe,{title:u("chat.workspaceDrawerLocateFile"),children:v.jsx("span",{className:"chat-workspace-drawer__toolbar-button-wrap",children:v.jsx(qe,{type:"text",className:"chat-workspace-drawer__icon-btn","aria-label":u("chat.workspaceDrawerLocateFile"),disabled:!g,onClick:()=>c("locate",d??void 0),children:v.jsx("span",{className:"material-symbols-rounded",children:"my_location"})})})}),v.jsx(Qe,{title:u("chat.workspaceDrawerExpandAll"),children:v.jsx(qe,{type:"text",className:"chat-workspace-drawer__icon-btn","aria-label":u("chat.workspaceDrawerExpandAll"),onClick:p,children:v.jsx("span",{className:"material-symbols-rounded",children:"unfold_more"})})}),v.jsx(Qe,{title:u("chat.workspaceDrawerCollapseAll"),children:v.jsx(qe,{type:"text",className:"chat-workspace-drawer__icon-btn","aria-label":u("chat.workspaceDrawerCollapseAll"),onClick:_,children:v.jsx("span",{className:"material-symbols-rounded",children:"unfold_less"})})}),v.jsx(Wo,{menu:{items:f},overlayClassName:"chat-workspace-drawer-more-dropdown",placement:"bottomRight",trigger:["click"],children:v.jsx(qe,{type:"text",className:"chat-workspace-drawer__icon-btn","aria-label":u("common.moreActions"),title:u("common.moreActions"),children:v.jsx("span",{className:"material-symbols-rounded",children:"more_vert"})})})]})]})}const L_n=n=>(n==null?void 0:n.trim().replace(/^@+/,""))??"";function k_n({approvals:n,onOpenRun:e}){const{t}=ht();return n.length===0?v.jsx("div",{className:"chat-workspace-drawer__approvals-empty",children:v.jsx(jn,{image:jn.PRESENTED_IMAGE_SIMPLE,description:t("agentRoom.approvals.empty")})}):v.jsx("div",{className:"chat-workspace-drawer__approvals","aria-label":t("chat.workspaceDrawerApprovals"),children:n.map(i=>{var c,d;const s=L_n((c=i.member)==null?void 0:c.label),r=s!==""?s:t("agentRoom.message.agent"),o=i.run,a=(d=i.run)==null?void 0:d.title,l=t("agentRoom.approvals.waitingForInput");return v.jsxs("article",{className:"chat-workspace-drawer__approval-card","aria-label":l,children:[v.jsxs("div",{className:"chat-workspace-drawer__approval-head",children:[v.jsxs("div",{className:"chat-workspace-drawer__approval-context",children:[v.jsx("span",{className:"chat-workspace-drawer__approval-agent",children:r}),a!=null&&a!==""&&v.jsx("span",{className:"chat-workspace-drawer__approval-run",children:a})]}),v.jsx("span",{className:"chat-workspace-drawer__approval-status",children:l})]}),v.jsx("div",{className:"chat-workspace-drawer__approval-message",children:i.content}),v.jsx("div",{className:"chat-workspace-drawer__approval-note",children:t("agentRoom.approvals.waitingDescription")}),o!=null&&e!=null&&v.jsxs("button",{type:"button",className:"chat-workspace-drawer__approval-open-run",onClick:()=>e(o),children:[v.jsx("span",{className:"material-symbols-rounded","aria-hidden":"true",children:"open_in_new"}),v.jsx("span",{children:t("agentRoom.actions.openRun")})]})]},i.id)})})}const bXe=n=>[...n].sort((e,t)=>e.file.path.localeCompare(t.file.path)),yXe=n=>n.split("/").pop()??n,E_n=n=>{const e=yXe(n);return n===e?"":n.slice(0,Math.max(0,n.length-e.length-1))},I_n=n=>{const e=[];return n.staged&&e.push({file:n,key:`${n.path}:staged`,scope:"staged"}),n.unstaged&&!n.untracked&&e.push({file:n,key:`${n.path}:tracked`,scope:"tracked"}),n.untracked&&e.push({file:n,key:`${n.path}:untracked`,scope:"untracked"}),e},M_n=n=>{const e=n.flatMap(I_n),t=[{scope:"staged",entries:[],count:0},{scope:"tracked",entries:[],count:0},{scope:"untracked",entries:[],count:0}];for(const i of t)i.entries=bXe(e.filter(s=>s.scope===i.scope)),i.count=i.entries.length;return t.filter(i=>i.count>0)},N_n=(n,e,t)=>{const i=n.children.find(r=>r.path===t);if(i!=null)return i;const s={name:e,path:t,children:[],entries:[]};return n.children.push(s),s},wXe=n=>{n.children.sort((e,t)=>e.name.localeCompare(t.name)),n.entries=bXe(n.entries);for(const e of n.children)wXe(e)},Qxe=n=>{const e={name:"",path:"",children:[],entries:[]};for(const t of n){const i=t.file.path.split("/").filter(Boolean);if(i.pop()==null)continue;let r=e,o="";for(const a of i)o=o===""?a:`${o}/${a}`,r=N_n(r,a,o);r.entries.push(t)}return wXe(e),e},Rce=n=>{const e=n.path===""?[]:[n.path];for(const t of n.children)e.push(...Rce(t));return e},SXe=(n,e)=>{if(n.path===e)return n;for(const t of n.children){const i=SXe(t,e);if(i!=null)return i}return null},xXe=n=>n.trim().toLowerCase(),D_n=n=>{const e=xXe(n),t=e.lastIndexOf(".");return t<=0?"":e.slice(t+1)},LXe=n=>{const e=xXe(n),t=D_n(n);return e==="package.json"?{icon:"inventory_2",tone:"package"}:e.includes("lock")?{icon:"lock",tone:"lock"}:e.startsWith(".env")?{icon:"key",tone:"env"}:e.includes("config")?{icon:"tune",tone:"config"}:e.includes("readme")||t==="md"||t==="mdx"?{icon:"article",tone:"docs"}:e.includes("gitignore")||e.includes("dockerignore")?{icon:"hide_source",tone:"ignore"}:t==="ts"||t==="tsx"?{icon:"data_object",tone:"typescript"}:t==="js"||t==="jsx"||t==="mjs"||t==="cjs"?{icon:"javascript",tone:"javascript"}:t==="json"?{icon:"data_object",tone:"json"}:t==="scss"||t==="sass"||t==="css"?{icon:"palette",tone:"style"}:t==="html"?{icon:"language",tone:"html"}:["png","jpg","jpeg","gif","webp","svg","ico"].includes(t)?{icon:"image",tone:"image"}:["yml","yaml","toml"].includes(t)?{icon:"settings",tone:"config"}:["sh","bash","zsh"].includes(t)?{icon:"terminal",tone:"script"}:{icon:"draft",tone:"file"}},T_n=(n,e)=>{const t=n.file.submodule;return t==null?[]:[t.commitChanged?e("chat.workspaceDrawerSubmoduleCommit"):null,t.trackedChanges?e("chat.workspaceDrawerSubmoduleTracked"):null,t.untrackedChanges?e("chat.workspaceDrawerSubmoduleUntracked"):null].filter(i=>i!=null)};function kXe({entry:n,onOpenFile:e,selectedFilePath:t,showDirectory:i=!0}){const{t:s}=ht(),r=yXe(n.file.path),o=E_n(n.file.path),a=n.file.submodule!=null?{icon:"folder_special",tone:"submodule"}:LXe(r),l=C.useMemo(()=>{const c=T_n(n,s),d=s(`chat.workspaceDrawerFileStatus.${n.scope}`);return c.length===0?d:`${d} · ${s("chat.workspaceDrawerSubmodule")}: ${c.join(", ")}`},[n,s]);return v.jsxs("button",{type:"button",className:`chat-workspace-drawer__changed-file ${t===n.file.path?"is-selected":""}`,title:n.file.path,onClick:()=>e==null?void 0:e(n.file.path),children:[v.jsx("span",{className:`material-symbols-rounded chat-workspace-drawer__changed-icon is-${a.tone}`,children:a.icon}),v.jsxs("span",{className:"chat-workspace-drawer__changed-copy",children:[v.jsx("span",{className:"chat-workspace-drawer__changed-name",children:r}),i&&o!==""&&v.jsx("span",{className:"chat-workspace-drawer__changed-path",children:o})]}),v.jsx(Qe,{title:l,children:v.jsx("span",{className:`chat-workspace-drawer__changed-status-dot is-${n.scope}`,"aria-label":l})})]})}const Jxe=n=>({"--changed-folder-depth":n}),R_n=n=>{const e=[n.name];let t=n;for(;t.entries.length===0&&t.children.length===1;)t=t.children[0],e.push(t.name);return{label:e.join("/"),node:t}};function EXe({depth:n,expandedPaths:e,node:t,onOpenFile:i,onSelectFolder:s,onToggleFolder:r,selectedFilePath:o,selectedFolder:a,scope:l}){const c=t.path==="",d=c?{label:"",node:t}:R_n(t),u=d.node,h=c||e.has(u.path),f=(a==null?void 0:a.scope)===l&&a.path===u.path;return v.jsxs("div",{className:"chat-workspace-drawer__changed-folder-node",children:[!c&&v.jsxs("button",{type:"button",className:`chat-workspace-drawer__changed-folder ${h?"is-expanded":""} ${f?"is-selected":""}`,style:Jxe(n),"aria-expanded":h,"aria-pressed":f,title:u.path,onClick:()=>{s(u.path),r(u.path)},children:[v.jsx("span",{className:"material-symbols-rounded chat-workspace-drawer__changed-folder-icon",children:h?"folder_open":"folder"}),v.jsx("span",{className:"chat-workspace-drawer__changed-folder-name",children:d.label})]}),v.jsx("div",{className:`chat-workspace-drawer__changed-folder-children ${h?"is-expanded":"is-collapsed"}`,children:v.jsxs("div",{className:"chat-workspace-drawer__changed-folder-children-inner",children:[u.children.map(g=>v.jsx(EXe,{depth:n+1,expandedPaths:e,node:g,selectedFilePath:o,onOpenFile:i,onSelectFolder:s,onToggleFolder:r,selectedFolder:a,scope:l},g.path)),u.entries.map(g=>v.jsx("div",{className:"chat-workspace-drawer__changed-folder-entry",style:Jxe(u.path===""?0:n+1),children:v.jsx(kXe,{entry:g,selectedFilePath:o,showDirectory:!1,onOpenFile:i})},g.key))]})})]})}function P_n({command:n,onOpenFile:e,onSelectFolder:t,root:i,scope:s,selectedFilePath:r,selectedFolder:o}){const a=C.useMemo(()=>Rce(i),[i]),[l,c]=C.useState(()=>new Set(a));C.useEffect(()=>{c(new Set(a))},[a]),C.useEffect(()=>{if(n==null)return;const u=(o==null?void 0:o.scope)===s?o.path:null,h=u==null?i:SXe(i,u),f=h==null?a:Rce(h),g=u==null?f:[u,...f];c(m=>{if(n.action==="expand")return new Set([...m,...g]);const p=new Set(m);for(const _ of g)p.delete(_);return p})},[a,n,i,s,o]);const d=u=>{c(h=>{const f=new Set(h);return f.has(u)?f.delete(u):f.add(u),f})};return v.jsx(EXe,{depth:0,expandedPaths:l,node:i,selectedFilePath:r,onOpenFile:e,onSelectFolder:u=>t({scope:s,path:u}),onToggleFolder:d,selectedFolder:o,scope:s})}function A_n({command:n,isLoading:e,layout:t,onOpenFile:i,repoState:s,selectedFilePath:r}){const{t:o}=ht(),[a,l]=C.useState(new Set),[c,d]=C.useState(null),u=C.useMemo(()=>(s==null?void 0:s.available)!==!0?[]:s.changedFiles??[],[s]),h=C.useMemo(()=>M_n(u),[u]),f=C.useMemo(()=>h.map(p=>p.scope),[h]),g=C.useMemo(()=>new Map(h.map(p=>[p.scope,Qxe(p.entries)])),[h]);C.useEffect(()=>{l(p=>new Set(Array.from(p).filter(_=>f.includes(_))))},[f]),C.useEffect(()=>{t!=="folders"&&d(null)},[t]),C.useEffect(()=>{if(n!=null){if(c==null){l(n.action==="expand"?new Set:new Set(f));return}n.action==="expand"&&l(p=>{const _=new Set(p);return _.delete(c.scope),_})}},[n,f,c]);const m=p=>{l(_=>{const b=new Set(_);return b.has(p)?b.delete(p):b.add(p),b})};return e?v.jsxs("div",{className:"chat-workspace-drawer__loading",children:[v.jsx(el,{size:"small"}),v.jsx("span",{children:o("chat.workspaceDrawerLoadingGit")})]}):s!=null&&s.available!==!0?v.jsx(jn,{image:jn.PRESENTED_IMAGE_SIMPLE,description:o("chat.workspaceDrawerGitUnavailable")}):h.length===0?v.jsx(jn,{image:jn.PRESENTED_IMAGE_SIMPLE,description:o("chat.workspaceDrawerNoChangedFiles")}):v.jsx("div",{className:"chat-workspace-drawer__changed-list",children:v.jsx("div",{className:"chat-workspace-drawer__changed-sections",children:h.map(p=>{const _=a.has(p.scope);return v.jsxs("section",{className:"chat-workspace-drawer__changed-section",children:[v.jsxs("div",{className:"chat-workspace-drawer__changed-section-header",children:[v.jsx("span",{children:o(`chat.workspaceDrawerChangedSection.${p.scope}`)}),v.jsxs("span",{className:"chat-workspace-drawer__changed-section-meta",children:[v.jsx("span",{children:p.count}),v.jsx(qe,{type:"text",className:"chat-workspace-drawer__changed-section-toggle","aria-label":o("chat.workspaceDrawerToggleSection"),"aria-expanded":!_,onClick:()=>m(p.scope),children:v.jsx("span",{className:"material-symbols-rounded",children:_?"expand_more":"expand_less"})})]})]}),v.jsx("div",{className:`chat-workspace-drawer__changed-section-body ${_?"is-collapsed":"is-expanded"}`,children:v.jsx("div",{className:"chat-workspace-drawer__changed-section-body-inner",children:t==="folders"?v.jsx(P_n,{command:n,root:g.get(p.scope)??Qxe([]),scope:p.scope,selectedFolder:c,selectedFilePath:r,onOpenFile:i,onSelectFolder:d}):p.entries.map(b=>v.jsx(kXe,{entry:b,selectedFilePath:r,onOpenFile:i},b.key))})})]},p.scope)})})})}function O_n({command:n,onOpenFile:e,onReferencePaths:t,refreshKey:i,selectedFilePath:s,sessionId:r}){return v.jsx($Be,{activePath:s,className:"chat-workspace-drawer__tree",command:n,refreshKey:i,selectableTypes:"all",selectionMode:"multiple",sessionId:r,showContextMenu:!0,onOpenFile:e,onReferenceNodes:o=>t==null?void 0:t(o.map(DBe))})}function F_n({activeView:n,agentApprovals:e,agentRoster:t,approvalMessages:i,changedLayout:s,changedTreeCommand:r,isGitLoading:o,onOpenFile:a,onReferencePaths:l,repoState:c,selectedFilePath:d,sessionId:u,treeRefreshKey:h,workspaceTreeCommand:f}){return n==="approvals"&&e!=null?v.jsx(k_n,{approvals:i,onOpenRun:e.onOpenRun}):n==="agents"&&t!=null?v.jsx("div",{className:"chat-workspace-drawer__agents-panel",children:v.jsx(Myt,{layout:"desktop",members:t.members,showHeader:!1,onOpenRun:t.onOpenRun})}):n==="tree"?v.jsx(O_n,{command:f,refreshKey:h,selectedFilePath:d,sessionId:u,onOpenFile:a,onReferencePaths:l}):v.jsx(A_n,{command:r,isLoading:o,layout:s,repoState:c,selectedFilePath:d,onOpenFile:a})}function B_n({agentApprovals:n,agentRoster:e,defaultView:t="tree",onOpenFile:i,onReferencePaths:s,selectedFilePath:r,sessionId:o}){var B;const{t:a}=ht(),l=n!=null,c=e!=null,[d,u]=C.useState("folders"),[h,f]=C.useState(null),[g,m]=C.useState(null),[p,_]=C.useState(0),b=o!=null&&o!==""?["chat-workspace-drawer-git",o]:"chat-workspace-drawer-git",{data:y,isLoading:w,mutate:S}=Gn(b,()=>o!=null&&o!==""?KAe(o):ZAe(),{refreshInterval:3e3,revalidateOnFocus:!0}),x=(y==null?void 0:y.available)===!0?((B=y.changedFiles)==null?void 0:B.length)??0:0,L=C.useMemo(()=>n==null?[]:y_n(n.room),[n]),E=L.length>0,I=t==="approvals"&&!E&&c?"agents":t,M=c?"agents":"tree",N=I==="agents"&&!c||I==="approvals"&&!l,[T,D]=C.useState(()=>N?M:I),P=C.useMemo(()=>{if(e!=null)return{memberCount:e.members.length,pendingCount:e.members.reduce((V,W)=>V+W.pendingCount,0)}},[e]),R=T==="agents"&&!c||T==="approvals"&&!l;C.useEffect(()=>{R&&D(M)},[M,R]);const A=R?M:T,O=()=>{S(),_(V=>V+1)},F=V=>{D("changes"),u("folders"),f(W=>({action:V,id:((W==null?void 0:W.id)??0)+1}))},$=(V,W)=>{D("tree"),m(H=>({action:V,id:((H==null?void 0:H.id)??0)+1,path:W}))};return v.jsxs("aside",{className:"chat-workspace-drawer","aria-label":a("chat.workspaceDrawerTitle"),children:[v.jsx(x_n,{activeView:A,agentApprovals:l?{count:L.length}:void 0,agentRoster:P,changedFilesCount:x,changedLayout:d,onActiveViewChange:D,onChangedLayoutChange:u,onChangedTreeCommand:F,onForceSync:O,onWorkspaceTreeCommand:$,selectedFilePath:r}),v.jsx("div",{className:"chat-workspace-drawer__body",children:v.jsx("div",{className:"chat-workspace-drawer__view-panel",children:v.jsx(F_n,{activeView:A,agentApprovals:n,agentRoster:e,approvalMessages:L,changedLayout:d,changedTreeCommand:h,isGitLoading:w,repoState:y,selectedFilePath:r,sessionId:o,treeRefreshKey:p,workspaceTreeCommand:g,onOpenFile:i,onReferencePaths:s})},A)})]})}const Pce=n=>{const e=[],t=new Set;for(const i of n){const s=i==null?void 0:i.trim();s==null||s===""||t.has(s)||(t.add(s),e.push(s))}return e},SY=n=>{var s;const e=((s=n==null?void 0:n.selectedPath)==null?void 0:s.trim())||null,t=Pce([...(n==null?void 0:n.openPaths)??[],e]),i=e!=null&&t.includes(e)?e:t.at(0)??null;return{openPaths:t,selectedPath:i,isOpen:(n==null?void 0:n.isOpen)===!0&&i!=null}},$_n=n=>({openPaths:n.openPaths,...n.selectedPath==null?{}:{selectedPath:n.selectedPath},isOpen:n.isOpen});function H_n({isTerminalOpen:n,session:e,setIsTerminalOpen:t}){const i=SY(e==null?void 0:e.workspaceFileState),[s,r]=C.useState("terminal"),[o,a]=C.useState(i.selectedPath),[l,c]=C.useState(i.openPaths),[d,u]=C.useState(i.isOpen),h=n&&s==="terminal",f=d&&o!=null&&s==="file",g=h||f,m=JSON.stringify((e==null?void 0:e.workspaceFileState)??null);C.useEffect(()=>{const M=SY(e==null?void 0:e.workspaceFileState);c(M.openPaths),a(M.selectedPath),u(M.isOpen),r(N=>M.isOpen&&M.selectedPath!=null?"file":N==="file"?"terminal":N)},[m,e==null?void 0:e.id]);const p=M=>{const N=SY(M);c(N.openPaths),a(N.selectedPath),u(N.isOpen),(e==null?void 0:e.id)!=null&&f1(e.id,{workspaceFileState:$_n(N)}).catch(T=>{console.error("[chat] failed to persist workspace file state:",T)})};return{handleCloseAllWorkspaceFileTabs:()=>{p({openPaths:[],selectedPath:null,isOpen:!1}),n&&r("terminal")},handleCloseTerminal:()=>{t(!1),d&&o!=null&&r("file")},handleCloseWorkspaceFile:()=>{p({openPaths:l,selectedPath:o,isOpen:!1}),n&&r("terminal")},handleCloseOtherWorkspaceFileTabs:M=>{l.includes(M)&&(p({openPaths:[M],selectedPath:M,isOpen:!0}),r("file"))},handleCloseWorkspaceFileTab:M=>{const N=l.filter(P=>P!==M),T=l.indexOf(M),D=o===M?N[Math.min(Math.max(T-1,0),N.length-1)]??null:o;p({openPaths:N,selectedPath:D,isOpen:d&&D!=null}),D==null&&n&&r("terminal")},handleCloseWorkspaceFileTabsToRight:M=>{const N=l.indexOf(M);if(N<0)return;const T=l.slice(0,N+1),D=o!=null&&T.includes(o)?o:M;p({openPaths:T,selectedPath:D,isOpen:d&&D!=null})},handleOpenWorkspaceFile:M=>{p({openPaths:Pce([...l,M]),selectedPath:M,isOpen:!0}),r("file")},handleSelectWorkspaceFile:M=>{p({openPaths:Pce([...l,M]),selectedPath:M,isOpen:!0}),r("file")},handleToggleTerminal:()=>{if(s!=="terminal"){r("terminal"),t(!0);return}t(!n)},openWorkspaceFilePaths:l,selectedWorkspaceFilePath:o,shouldShowBottomPanel:g,shouldShowFileEditor:f,shouldShowTerminal:h}}const V_n=240;function j_n(n){const[e,t]=C.useState(n),[i,s]=C.useState(n);return C.useEffect(()=>{if(n){t(!0);const o=window.setTimeout(()=>{s(!0)},0);return()=>{window.clearTimeout(o)}}if(s(!1),!e)return;const r=window.setTimeout(()=>{t(!1)},V_n);return()=>{window.clearTimeout(r)}},[n,e]),{isRendered:e,isVisible:i}}const W_n=n=>n==="workspace"?n:void 0;function z_n(){const{values:n,update:e}=Rf({keys:["layout"],defaults:{layout:""},omit:{layout:i=>i===""}}),t=W_n(n.layout);return{activeLayout:t,isWorkspaceDrawerOpen:t==="workspace",setWorkspaceDrawerOpen:i=>e({layout:i?"workspace":""})}}function U_n({actions:n,closeLabel:e,fullscreenEnterLabel:t,fullscreenExitLabel:i,isFullscreen:s,meta:r,onClose:o,onToggleFullscreen:a,title:l}){const c=s?i:t;return v.jsxs("div",{className:"dock-panel__header",children:[v.jsxs("div",{className:"dock-panel__header-main",children:[v.jsx("span",{className:"dock-panel__title",children:l}),r!=null&&v.jsx("span",{className:"dock-panel__meta",children:r})]}),v.jsx("div",{className:"dock-panel__header-spacer"}),(n!=null||a!=null||o!=null)&&v.jsxs("div",{className:"dock-panel__header-actions",children:[n,a!=null&&c!=null&&v.jsx(qe,{type:"text",className:"dock-panel__close-btn dock-panel__fullscreen-btn","data-dock-panel-no-resize":"true",icon:v.jsx("span",{className:"material-symbols-rounded",children:s?"fullscreen_exit":"fullscreen"}),title:c,"aria-label":c,onClick:a}),o!=null&&e!=null&&v.jsx(qe,{type:"text",className:"dock-panel__close-btn","data-dock-panel-no-resize":"true",icon:v.jsx("span",{className:"material-symbols-rounded",children:"close"}),title:e,"aria-label":e,onClick:o})]})]})}const K_n=180;function Z_n(){const[n,e]=C.useState(!1),[t,i]=C.useState(!1),s=C.useRef(null),r=C.useCallback(()=>{s.current!=null&&(window.clearTimeout(s.current),s.current=null)},[]),o=C.useCallback(()=>{r(),i(!1),e(!0)},[r]),a=C.useCallback(()=>{r(),i(!0),s.current=window.setTimeout(()=>{e(!1),i(!1),s.current=null},K_n)},[r]),l=C.useCallback(()=>{if(n&&!t){a();return}o()},[o,a,n,t]);return C.useEffect(()=>r,[r]),{isFullscreen:n,isFullscreenExiting:t,toggleFullscreen:l}}const q_n=240,xY=(n,e,t)=>Math.min(Math.max(n,e),Math.max(e,t)),G_n=n=>(n==null?void 0:n.closest('button, a, input, textarea, select, option, [role="button"], [data-dock-panel-no-resize="true"]'))!=null;function IXe({enterMotion:n="slide-up",allowResize:e=!0,allowFullscreen:t=!1,children:i,className:s,closeLabel:r,defaultHeight:o=q_n,footer:a,fullscreenEnterLabel:l,fullscreenExitLabel:c,isResizeDisabled:d=!1,isOpen:u=!0,maxHeight:h=520,meta:f,minHeight:g=180,onClose:m,resizeLabel:p,storageKey:_,title:b,actions:y}){const w=C.useRef(null),S=C.useRef(null),[x,L]=C.useState(!1),{isFullscreen:E,isFullscreenExiting:I,toggleFullscreen:M}=Z_n(),[N,T]=C.useState(()=>{const A=Number(localStorage.getItem(_));return Number.isFinite(A)&&A>0?xY(A,g,h):xY(o,g,h)}),D=e&&!d&&!E;C.useEffect(()=>{localStorage.setItem(_,String(N))},[N,_]),C.useEffect(()=>()=>{document.body.style.cursor="",document.body.style.userSelect=""},[]),C.useEffect(()=>{if(!D||!x)return;const A=F=>{const $=S.current;if($==null)return;const B=xY($.startHeight+$.startY-F.clientY,g,$.maxHeight);T(B)},O=()=>{S.current=null,L(!1),document.body.style.cursor="",document.body.style.userSelect=""};return window.addEventListener("pointermove",A),window.addEventListener("pointerup",O),window.addEventListener("pointercancel",O),()=>{window.removeEventListener("pointermove",A),window.removeEventListener("pointerup",O),window.removeEventListener("pointercancel",O)}},[x,g,D]);const P=A=>{if(!D||G_n(A.target))return;A.preventDefault();const O=w.current,F=O==null?void 0:O.parentElement,$=F==null?void 0:F.getBoundingClientRect().height;S.current={startY:A.clientY,startHeight:(O==null?void 0:O.getBoundingClientRect().height)??N,maxHeight:$!=null?Math.min(h,$-96):h},L(!0),document.body.style.cursor="row-resize",document.body.style.userSelect="none"},R=C.useMemo(()=>({"--dock-panel-height":`${N}px`,"--dock-panel-max-height":`${h}px`,"--dock-panel-min-height":`${g}px`}),[h,g,N]);return v.jsxs("div",{ref:w,className:`dock-panel ${u&&n==="slide-up"?"is-entering-slide-up":""} ${u?"is-open":"is-closing"} ${s??""} ${x?"is-resizing":""} ${D?"is-resizable":"is-static"} ${d||E?"is-resize-disabled":""} ${E?"is-fullscreen":""} ${I?"is-fullscreen-exiting":""}`,style:R,children:[D&&v.jsx("div",{className:"dock-panel__resize-strip",title:p,onPointerDown:P}),v.jsx(U_n,{actions:y,closeLabel:r,fullscreenEnterLabel:l,fullscreenExitLabel:c,isFullscreen:E,meta:f,title:b,onClose:m,onToggleFullscreen:t?M:void 0}),v.jsx("div",{className:"dock-panel__body",children:i}),a!=null&&v.jsx("div",{className:"dock-panel__footer",children:a})]})}const MXe=320,NXe="chatBottomDockHeight",DXe=620,TXe=220;function X_n({onActivate:n,onRename:e,panes:t}){const[i,s]=C.useState(null),[r,o]=C.useState(""),a=C.useRef(null),l=C.useRef(null);C.useEffect(()=>{i!=null&&window.requestAnimationFrame(()=>{var h,f;(h=a.current)==null||h.focus(),(f=a.current)==null||f.select()})},[i]),C.useEffect(()=>{i!=null&&t.every(h=>h.id!==i)&&(l.current=null,s(null),o(""))},[i,t]);const c=h=>{n(h.id),l.current=h.id,s(h.id),o(h.title)},d=()=>{l.current=null,s(null),o("")};return{cancelEditing:d,editingInputRef:a,editingTerminalId:i,editingTitle:r,finishEditing:()=>{const h=l.current;if(h!=null){const f=r.trim();f!==""&&e(h,f)}d()},setEditingTitle:o,startEditing:c}}function Y_n({activeTerminalId:n,infoById:e,panes:t,onActivate:i,onClose:s,onMove:r,onRename:o}){const{t:a}=ht(),[l,c]=C.useState(null),[d,u]=C.useState(null),{cancelEditing:h,editingInputRef:f,editingTerminalId:g,editingTitle:m,finishEditing:p,setEditingTitle:_,startEditing:b}=X_n({onActivate:i,onRename:o,panes:t}),y=(x,L)=>{c(L),x.dataTransfer.effectAllowed="move",x.dataTransfer.setData("text/plain",L);const E=x.currentTarget.closest(".chat-terminal-view__manager-item");E instanceof HTMLElement&&x.dataTransfer.setDragImage(E,12,14)},w=(x,L)=>{if(x.preventDefault(),x.dataTransfer.dropEffect="move",l===L){u(null);return}const E=x.currentTarget.getBoundingClientRect(),I=x.clientY<E.top+E.height/2?"before":"after";u(M=>(M==null?void 0:M.terminalId)===L&&M.placement===I?M:{terminalId:L,placement:I})},S=(x,L)=>{x.preventDefault();const E=l??x.dataTransfer.getData("text/plain"),I=(d==null?void 0:d.terminalId)===L?d.placement:"before";c(null),u(null),E!==""&&E!==L&&r(E,L,I)};return v.jsx("aside",{className:"chat-terminal-view__manager","aria-label":a("chat.terminal.manageTerminals"),onDragLeave:x=>{(!(x.relatedTarget instanceof Node)||!x.currentTarget.contains(x.relatedTarget))&&u(null)},children:t.map(x=>{const L=e[x.id],E=x.id===g,I=(L==null?void 0:L.shellLabel)??a(`chat.terminal.shell.${x.shellKind}`),M=(L==null?void 0:L.isExited)===!0?a("chat.terminal.shellTooltipExited",{shell:I}):a("chat.terminal.shellTooltip",{shell:I});return v.jsxs("div",{className:`chat-terminal-view__manager-item ${x.id===n?"is-active":""} ${x.id===l?"is-dragging":""} ${E?"is-editing":""} ${(d==null?void 0:d.terminalId)===x.id?`is-drop-${d.placement}`:""}`,onClick:()=>i(x.id),onDragOver:N=>w(N,x.id),onDrop:N=>S(N,x.id),children:[v.jsx("button",{type:"button",className:"chat-terminal-view__manager-drag material-symbols-rounded",draggable:!0,title:a("chat.terminal.dragSession"),"aria-label":a("chat.terminal.dragSession"),onDragStart:N=>y(N,x.id),onDragEnd:()=>{c(null),u(null)},children:"drag_indicator"}),v.jsx(Qe,{title:E?null:M,placement:"top",children:v.jsx("span",{className:"chat-terminal-view__manager-title-wrap",children:E?v.jsxs(v.Fragment,{children:[v.jsx("span",{className:"chat-terminal-view__manager-edit-icon material-symbols-rounded",children:"edit"}),v.jsx("input",{ref:f,className:"chat-terminal-view__manager-title-input",value:m,"aria-label":a("chat.terminal.renameSession",{title:x.title}),onBlur:p,onChange:N=>_(N.target.value),onClick:N=>N.stopPropagation(),onDoubleClick:N=>N.stopPropagation(),onKeyDown:N=>{if(N.key==="Enter"){p();return}N.key==="Escape"&&h()}})]}):v.jsx("span",{className:"chat-terminal-view__manager-title-text",onDoubleClick:N=>{N.stopPropagation(),b(x)},children:x.title})})}),v.jsx(qe,{type:"text",className:"chat-terminal-view__manager-close","data-dock-panel-no-resize":"true",icon:v.jsx("span",{className:"material-symbols-rounded",children:"close"}),title:a("chat.terminal.closeNamedSession",{title:x.title}),"aria-label":a("chat.terminal.closeNamedSession",{title:x.title}),onClick:N=>{N.stopPropagation(),s(x.id)}})]},x.id)})})}/**
1513
1513
  * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
1514
1514
  * @license MIT
1515
1515
  *