@jait/gateway 0.1.402 → 0.1.403

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 (68) hide show
  1. package/dist/tools/agent-loop.d.ts.map +1 -1
  2. package/dist/tools/agent-loop.js +8 -0
  3. package/dist/tools/agent-loop.js.map +1 -1
  4. package/dist/tools/index.d.ts +1 -1
  5. package/dist/tools/index.d.ts.map +1 -1
  6. package/dist/tools/index.js +3 -7
  7. package/dist/tools/index.js.map +1 -1
  8. package/dist/tools/prompts/shared-sections.d.ts +1 -1
  9. package/dist/tools/prompts/shared-sections.d.ts.map +1 -1
  10. package/dist/tools/prompts/shared-sections.js +5 -5
  11. package/package.json +1 -1
  12. package/web-dist/assets/{_basePickBy-Bi27T7vv.js → _basePickBy-CEm9SyNJ.js} +1 -1
  13. package/web-dist/assets/{_baseUniq-C29ZGEj4.js → _baseUniq-CDiAe9gc.js} +1 -1
  14. package/web-dist/assets/{arc-i0FlbMD5.js → arc-DkWaCLt8.js} +1 -1
  15. package/web-dist/assets/{architectureDiagram-2XIMDMQ5-DPyr9jtt.js → architectureDiagram-2XIMDMQ5-BPT9bslh.js} +1 -1
  16. package/web-dist/assets/{blockDiagram-WCTKOSBZ-CXFQaxle.js → blockDiagram-WCTKOSBZ-DhDmwNyU.js} +1 -1
  17. package/web-dist/assets/{c4Diagram-IC4MRINW-Do_Z7oy0.js → c4Diagram-IC4MRINW-Biyq01Qv.js} +1 -1
  18. package/web-dist/assets/channel-BdldIupa.js +1 -0
  19. package/web-dist/assets/{chunk-4BX2VUAB-HvProA3u.js → chunk-4BX2VUAB-BQLHaGaF.js} +1 -1
  20. package/web-dist/assets/{chunk-55IACEB6-CDDj23_j.js → chunk-55IACEB6-DPZyUmiz.js} +1 -1
  21. package/web-dist/assets/{chunk-FMBD7UC4-G-aaV1_e.js → chunk-FMBD7UC4-VX8qTbf4.js} +1 -1
  22. package/web-dist/assets/{chunk-JSJVCQXG-B8loXEof.js → chunk-JSJVCQXG-CcOwiKOD.js} +1 -1
  23. package/web-dist/assets/{chunk-KX2RTZJC-vivRdXU2.js → chunk-KX2RTZJC-DWA8I-sW.js} +1 -1
  24. package/web-dist/assets/{chunk-NQ4KR5QH-DEal8r_G.js → chunk-NQ4KR5QH-AmRTAF5M.js} +1 -1
  25. package/web-dist/assets/{chunk-QZHKN3VN-Du9IVO0i.js → chunk-QZHKN3VN-BtxsXQhz.js} +1 -1
  26. package/web-dist/assets/{chunk-WL4C6EOR-CuaVGyol.js → chunk-WL4C6EOR-CYmVRePV.js} +1 -1
  27. package/web-dist/assets/classDiagram-VBA2DB6C-Dh3VdYAd.js +1 -0
  28. package/web-dist/assets/classDiagram-v2-RAHNMMFH-Dh3VdYAd.js +1 -0
  29. package/web-dist/assets/clone-Cx6RmwoN.js +1 -0
  30. package/web-dist/assets/{cose-bilkent-S5V4N54A-PIq9GA_z.js → cose-bilkent-S5V4N54A-DeLKhCEG.js} +1 -1
  31. package/web-dist/assets/{dagre-KLK3FWXG-CdBUYO5m.js → dagre-KLK3FWXG-5ctXXPAz.js} +1 -1
  32. package/web-dist/assets/{diagram-E7M64L7V-BO8oSjk1.js → diagram-E7M64L7V-DSUO8HTw.js} +1 -1
  33. package/web-dist/assets/{diagram-IFDJBPK2-C2ncQSCW.js → diagram-IFDJBPK2-DOjAWgtk.js} +1 -1
  34. package/web-dist/assets/{diagram-P4PSJMXO-Coqal_sp.js → diagram-P4PSJMXO-BJmxkBPz.js} +1 -1
  35. package/web-dist/assets/{erDiagram-INFDFZHY-CjDNUYfv.js → erDiagram-INFDFZHY-XEdLHc6o.js} +1 -1
  36. package/web-dist/assets/{flowDiagram-PKNHOUZH-D8XxQE92.js → flowDiagram-PKNHOUZH-C2Hxrf84.js} +1 -1
  37. package/web-dist/assets/{ganttDiagram-A5KZAMGK-BIiwpSX7.js → ganttDiagram-A5KZAMGK-CcjivEhc.js} +1 -1
  38. package/web-dist/assets/{gitGraphDiagram-K3NZZRJ6-DbzlY20l.js → gitGraphDiagram-K3NZZRJ6-BHAvoWtT.js} +1 -1
  39. package/web-dist/assets/{graph-BtgtY1ao.js → graph-sj0HvDAW.js} +1 -1
  40. package/web-dist/assets/{index-6CZK0zgk.js → index-DeZT2FMn.js} +1 -1
  41. package/web-dist/assets/index-Dq2kwFDU.css +32 -0
  42. package/web-dist/assets/{index-Dy0PkHlz.js → index-Q3IVZa9M.js} +6 -6
  43. package/web-dist/assets/{index-D9vjmwPQ.js → index-lEfiShbN.js} +1 -1
  44. package/web-dist/assets/{infoDiagram-LFFYTUFH-hWFaETvV.js → infoDiagram-LFFYTUFH-wgpuajZI.js} +1 -1
  45. package/web-dist/assets/{ishikawaDiagram-PHBUUO56-BHc8OreU.js → ishikawaDiagram-PHBUUO56-DTcNwdbm.js} +1 -1
  46. package/web-dist/assets/{journeyDiagram-4ABVD52K-CiBVxxlY.js → journeyDiagram-4ABVD52K-BNueoCiS.js} +1 -1
  47. package/web-dist/assets/{kanban-definition-K7BYSVSG-C1rgcn_F.js → kanban-definition-K7BYSVSG-ktueNo2t.js} +1 -1
  48. package/web-dist/assets/{layout-CdKg_Rwl.js → layout-Cpne_R2e.js} +1 -1
  49. package/web-dist/assets/{linear-Xiu1sDLO.js → linear-BNLDbVjk.js} +1 -1
  50. package/web-dist/assets/{mindmap-definition-YRQLILUH-D8tU-mIN.js → mindmap-definition-YRQLILUH-CkCVQqrV.js} +1 -1
  51. package/web-dist/assets/{pieDiagram-SKSYHLDU-BIyAMXQI.js → pieDiagram-SKSYHLDU-B7GJE-Uz.js} +1 -1
  52. package/web-dist/assets/{quadrantDiagram-337W2JSQ-CAbfknvr.js → quadrantDiagram-337W2JSQ-CLs2IB5o.js} +1 -1
  53. package/web-dist/assets/{requirementDiagram-Z7DCOOCP-B8MganhZ.js → requirementDiagram-Z7DCOOCP-rtQqZo8t.js} +1 -1
  54. package/web-dist/assets/{sankeyDiagram-WA2Y5GQK-DalR8qS4.js → sankeyDiagram-WA2Y5GQK-PTcro8ap.js} +1 -1
  55. package/web-dist/assets/{sequenceDiagram-2WXFIKYE-C8vLzNPh.js → sequenceDiagram-2WXFIKYE-BxtY9s9j.js} +1 -1
  56. package/web-dist/assets/{stateDiagram-RAJIS63D-CiiDRSPH.js → stateDiagram-RAJIS63D-C-spqu7H.js} +1 -1
  57. package/web-dist/assets/stateDiagram-v2-FVOUBMTO-D6a1M8Bm.js +1 -0
  58. package/web-dist/assets/{timeline-definition-YZTLITO2-dy3ZTjT7.js → timeline-definition-YZTLITO2-DLGMvBG8.js} +1 -1
  59. package/web-dist/assets/{treemap-KZPCXAKY-DVzH0TpM.js → treemap-KZPCXAKY-V1NFoP7P.js} +1 -1
  60. package/web-dist/assets/{vennDiagram-LZ73GAT5-BWieJ8xA.js → vennDiagram-LZ73GAT5-BHoBtPNv.js} +1 -1
  61. package/web-dist/assets/{xychartDiagram-JWTSCODW-BsyQrQwu.js → xychartDiagram-JWTSCODW-BsU88Xtd.js} +1 -1
  62. package/web-dist/index.html +2 -2
  63. package/web-dist/assets/channel-CjTeEU-H.js +0 -1
  64. package/web-dist/assets/classDiagram-VBA2DB6C-DO7cTnFq.js +0 -1
  65. package/web-dist/assets/classDiagram-v2-RAHNMMFH-DO7cTnFq.js +0 -1
  66. package/web-dist/assets/clone-dHd_f5ky.js +0 -1
  67. package/web-dist/assets/index-RGcLShkH.css +0 -32
  68. package/web-dist/assets/stateDiagram-v2-FVOUBMTO-COllwQIm.js +0 -1
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./angular-html-DA-rfuFy.js","./html-pp8916En.js","./javascript-wDzz0qaB.js","./css-CLj8gQPS.js","./angular-ts-BrjP3tb8.js","./scss-D5BDwBP9.js","./astro-HNnZUWAn.js","./json-Cp-IABpG.js","./typescript-BPQ3VLAy.js","./postcss-CXtECtnM.js","./tsx-COt5Ahok.js","./blade-BjGOyj-B.js","./html-derivative-DlHx6ybY.js","./xml-sdJ4AIDG.js","./java-CylS5w8V.js","./sql-BLtJtn59.js","./coffee-Ch7k5sss.js","./cpp-CofmeUqb.js","./regexp-CDVJQ6XC.js","./glsl-DplSGwfg.js","./c-BIGW1oBm.js","./graphql-ChdNCCLP.js","./jsx-g9-lgVsj.js","./haml-D5jkg6IW.js","./handlebars-BpdQsYii.js","./yaml-Buea-lGh.js","./http-jrhK8wxY.js","./shellscript-Yzrsuije.js","./hurl-irOxFIW8.js","./csv-fuZLfV_i.js","./jinja-f2NsQr07.js","./jison-wvAkD_A8.js","./julia-CxzCAyBv.js","./python-B6aJPvgy.js","./r-Dspwwk_N.js","./marko-DjSrsDqO.js","./less-B1dDrJ26.js","./mdc-DTYItulj.js","./markdown-Cvjx9yec.js","./php-R6g_5hLQ.js","./pug-DKIMFp6K.js","./svelte-Cy7k_4gC.js","./ts-tags-DQrlYJgV.js","./vue-D2xRrEX4.js","./vue-html-AaS7Mt5G.js","./vue-vine-BoDAl6tE.js","./stylus-BEDo0Tqx.js","./dagre-KLK3FWXG-CdBUYO5m.js","./graph-BtgtY1ao.js","./_baseUniq-C29ZGEj4.js","./layout-CdKg_Rwl.js","./_basePickBy-Bi27T7vv.js","./clone-dHd_f5ky.js","./cose-bilkent-S5V4N54A-PIq9GA_z.js","./cytoscape.esm-BQaXIfA_.js","./c4Diagram-IC4MRINW-Do_Z7oy0.js","./chunk-JSJVCQXG-B8loXEof.js","./flowDiagram-PKNHOUZH-D8XxQE92.js","./chunk-FMBD7UC4-G-aaV1_e.js","./chunk-55IACEB6-CDDj23_j.js","./chunk-KX2RTZJC-vivRdXU2.js","./channel-CjTeEU-H.js","./erDiagram-INFDFZHY-CjDNUYfv.js","./gitGraphDiagram-K3NZZRJ6-DbzlY20l.js","./chunk-4BX2VUAB-HvProA3u.js","./chunk-QZHKN3VN-Du9IVO0i.js","./treemap-KZPCXAKY-DVzH0TpM.js","./ganttDiagram-A5KZAMGK-BIiwpSX7.js","./linear-Xiu1sDLO.js","./defaultLocale-DX6XiGOO.js","./infoDiagram-LFFYTUFH-hWFaETvV.js","./pieDiagram-SKSYHLDU-BIyAMXQI.js","./arc-i0FlbMD5.js","./quadrantDiagram-337W2JSQ-CAbfknvr.js","./xychartDiagram-JWTSCODW-BsyQrQwu.js","./requirementDiagram-Z7DCOOCP-B8MganhZ.js","./sequenceDiagram-2WXFIKYE-C8vLzNPh.js","./classDiagram-VBA2DB6C-DO7cTnFq.js","./chunk-WL4C6EOR-CuaVGyol.js","./classDiagram-v2-RAHNMMFH-DO7cTnFq.js","./stateDiagram-RAJIS63D-CiiDRSPH.js","./chunk-NQ4KR5QH-DEal8r_G.js","./stateDiagram-v2-FVOUBMTO-COllwQIm.js","./journeyDiagram-4ABVD52K-CiBVxxlY.js","./timeline-definition-YZTLITO2-dy3ZTjT7.js","./mindmap-definition-YRQLILUH-D8tU-mIN.js","./kanban-definition-K7BYSVSG-C1rgcn_F.js","./diagram-P4PSJMXO-Coqal_sp.js","./diagram-IFDJBPK2-C2ncQSCW.js","./blockDiagram-WCTKOSBZ-CXFQaxle.js","./architectureDiagram-2XIMDMQ5-DPyr9jtt.js","./diagram-E7M64L7V-BO8oSjk1.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./angular-html-DA-rfuFy.js","./html-pp8916En.js","./javascript-wDzz0qaB.js","./css-CLj8gQPS.js","./angular-ts-BrjP3tb8.js","./scss-D5BDwBP9.js","./astro-HNnZUWAn.js","./json-Cp-IABpG.js","./typescript-BPQ3VLAy.js","./postcss-CXtECtnM.js","./tsx-COt5Ahok.js","./blade-BjGOyj-B.js","./html-derivative-DlHx6ybY.js","./xml-sdJ4AIDG.js","./java-CylS5w8V.js","./sql-BLtJtn59.js","./coffee-Ch7k5sss.js","./cpp-CofmeUqb.js","./regexp-CDVJQ6XC.js","./glsl-DplSGwfg.js","./c-BIGW1oBm.js","./graphql-ChdNCCLP.js","./jsx-g9-lgVsj.js","./haml-D5jkg6IW.js","./handlebars-BpdQsYii.js","./yaml-Buea-lGh.js","./http-jrhK8wxY.js","./shellscript-Yzrsuije.js","./hurl-irOxFIW8.js","./csv-fuZLfV_i.js","./jinja-f2NsQr07.js","./jison-wvAkD_A8.js","./julia-CxzCAyBv.js","./python-B6aJPvgy.js","./r-Dspwwk_N.js","./marko-DjSrsDqO.js","./less-B1dDrJ26.js","./mdc-DTYItulj.js","./markdown-Cvjx9yec.js","./php-R6g_5hLQ.js","./pug-DKIMFp6K.js","./svelte-Cy7k_4gC.js","./ts-tags-DQrlYJgV.js","./vue-D2xRrEX4.js","./vue-html-AaS7Mt5G.js","./vue-vine-BoDAl6tE.js","./stylus-BEDo0Tqx.js","./dagre-KLK3FWXG-5ctXXPAz.js","./graph-sj0HvDAW.js","./_baseUniq-CDiAe9gc.js","./layout-Cpne_R2e.js","./_basePickBy-CEm9SyNJ.js","./clone-Cx6RmwoN.js","./cose-bilkent-S5V4N54A-DeLKhCEG.js","./cytoscape.esm-BQaXIfA_.js","./c4Diagram-IC4MRINW-Biyq01Qv.js","./chunk-JSJVCQXG-CcOwiKOD.js","./flowDiagram-PKNHOUZH-C2Hxrf84.js","./chunk-FMBD7UC4-VX8qTbf4.js","./chunk-55IACEB6-DPZyUmiz.js","./chunk-KX2RTZJC-DWA8I-sW.js","./channel-BdldIupa.js","./erDiagram-INFDFZHY-XEdLHc6o.js","./gitGraphDiagram-K3NZZRJ6-BHAvoWtT.js","./chunk-4BX2VUAB-BQLHaGaF.js","./chunk-QZHKN3VN-BtxsXQhz.js","./treemap-KZPCXAKY-V1NFoP7P.js","./ganttDiagram-A5KZAMGK-CcjivEhc.js","./linear-BNLDbVjk.js","./defaultLocale-DX6XiGOO.js","./infoDiagram-LFFYTUFH-wgpuajZI.js","./pieDiagram-SKSYHLDU-B7GJE-Uz.js","./arc-DkWaCLt8.js","./quadrantDiagram-337W2JSQ-CLs2IB5o.js","./xychartDiagram-JWTSCODW-BsU88Xtd.js","./requirementDiagram-Z7DCOOCP-rtQqZo8t.js","./sequenceDiagram-2WXFIKYE-BxtY9s9j.js","./classDiagram-VBA2DB6C-Dh3VdYAd.js","./chunk-WL4C6EOR-CYmVRePV.js","./classDiagram-v2-RAHNMMFH-Dh3VdYAd.js","./stateDiagram-RAJIS63D-C-spqu7H.js","./chunk-NQ4KR5QH-AmRTAF5M.js","./stateDiagram-v2-FVOUBMTO-D6a1M8Bm.js","./journeyDiagram-4ABVD52K-BNueoCiS.js","./timeline-definition-YZTLITO2-DLGMvBG8.js","./mindmap-definition-YRQLILUH-CkCVQqrV.js","./kanban-definition-K7BYSVSG-ktueNo2t.js","./diagram-P4PSJMXO-BJmxkBPz.js","./diagram-IFDJBPK2-DOjAWgtk.js","./blockDiagram-WCTKOSBZ-DhDmwNyU.js","./architectureDiagram-2XIMDMQ5-BPT9bslh.js","./diagram-E7M64L7V-DSUO8HTw.js"])))=>i.map(i=>d[i]);
2
2
  var uhe=Object.defineProperty;var dhe=(e,r,n)=>r in e?uhe(e,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[r]=n;var De=(e,r,n)=>dhe(e,typeof r!="symbol"?r+"":r,n);function hhe(e,r){for(var n=0;n<r.length;n++){const i=r[n];if(typeof i!="string"&&!Array.isArray(i)){for(const s in i)if(s!=="default"&&!(s in e)){const o=Object.getOwnPropertyDescriptor(i,s);o&&Object.defineProperty(e,s,o.get?o:{enumerable:!0,get:()=>i[s]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))i(s);new MutationObserver(s=>{for(const o of s)if(o.type==="childList")for(const a of o.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&i(a)}).observe(document,{childList:!0,subtree:!0});function n(s){const o={};return s.integrity&&(o.integrity=s.integrity),s.referrerPolicy&&(o.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?o.credentials="include":s.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function i(s){if(s.ep)return;s.ep=!0;const o=n(s);fetch(s.href,o)}})();function ey(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function Wyt(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var r=e.default;if(typeof r=="function"){var n=function i(){return this instanceof i?Reflect.construct(r,arguments,this.constructor):r.apply(this,arguments)};n.prototype=r.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(i){var s=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(n,i,s.get?s:{enumerable:!0,get:function(){return e[i]}})}),n}var uN={exports:{}},sb={};/**
3
3
  * @license React
4
4
  * react-jsx-runtime.production.js
@@ -876,7 +876,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
876
876
  monaco.config({ paths: { vs: '...' } })
877
877
 
878
878
  For more please check the link https://github.com/suren-atoyan/monaco-loader#config
879
- `},FB=l9e(h9e)(AQ),f9e={config:u9e},p9e=function(){for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];return function(s){return n.reduceRight(function(o,a){return a(o)},s)}};function OQ(e,r){return Object.keys(r).forEach(function(n){r[n]instanceof Object&&e[n]&&Object.assign(r[n],OQ(e[n],r[n]))}),IB(IB({},e),r)}var m9e={type:"cancelation",msg:"operation is manually canceled"};function PT(e){var r=!1,n=new Promise(function(i,s){e.then(function(o){return r?s(m9e):i(o)}),e.catch(s)});return n.cancel=function(){return r=!0},n}var g9e=["monaco"],y9e=o9e.create({config:a9e,isInitialized:!1,resolve:null,reject:null,monaco:null}),RQ=HOe(y9e,2),RS=RQ[0],Dj=RQ[1];function v9e(e){var r=f9e.config(e),n=r.monaco,i=zOe(r,g9e);Dj(function(s){return{config:OQ(s.config,i),monaco:n}})}function x9e(){var e=RS(function(r){var n=r.monaco,i=r.isInitialized,s=r.resolve;return{monaco:n,isInitialized:i,resolve:s}});if(!e.isInitialized){if(Dj({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),PT(LT);if(window.monaco&&window.monaco.editor)return MQ(window.monaco),e.resolve(window.monaco),PT(LT);p9e(b9e,w9e)(S9e)}return PT(LT)}function b9e(e){return document.body.appendChild(e)}function _9e(e){var r=document.createElement("script");return e&&(r.src=e),r}function w9e(e){var r=RS(function(i){var s=i.config,o=i.reject;return{config:s,reject:o}}),n=_9e("".concat(r.config.paths.vs,"/loader.js"));return n.onload=function(){return e()},n.onerror=r.reject,n}function S9e(){var e=RS(function(n){var i=n.config,s=n.resolve,o=n.reject;return{config:i,resolve:s,reject:o}}),r=window.require;r.config(e.config),r(["vs/editor/editor.main"],function(n){var i=n.m||n;MQ(i),e.resolve(i)},function(n){e.reject(n)})}function MQ(e){RS().monaco||Dj({monaco:e})}function k9e(){return RS(function(e){var r=e.monaco;return r})}var LT=new Promise(function(e,r){return Dj({resolve:e,reject:r})}),YR={config:v9e,init:x9e,__getMonacoInstance:k9e};const PQ=Object.freeze(JSON.parse('{"colors":{"actionBar.toggledBackground":"#383a49","activityBarBadge.background":"#007ACC","checkbox.border":"#6B6B6B","editor.background":"#1E1E1E","editor.foreground":"#D4D4D4","editor.inactiveSelectionBackground":"#3A3D41","editor.selectionHighlightBackground":"#ADD6FF26","editorIndentGuide.activeBackground1":"#707070","editorIndentGuide.background1":"#404040","input.placeholderForeground":"#A6A6A6","list.activeSelectionIconForeground":"#FFF","list.dropBackground":"#383B3D","menu.background":"#252526","menu.border":"#454545","menu.foreground":"#CCCCCC","menu.selectionBackground":"#0078d4","menu.separatorBackground":"#454545","ports.iconRunningProcessForeground":"#369432","sideBarSectionHeader.background":"#0000","sideBarSectionHeader.border":"#ccc3","sideBarTitle.foreground":"#BBBBBB","statusBarItem.remoteBackground":"#16825D","statusBarItem.remoteForeground":"#FFF","tab.lastPinnedBorder":"#ccc3","tab.selectedBackground":"#222222","tab.selectedForeground":"#ffffffa0","terminal.inactiveSelectionBackground":"#3A3D41","widget.border":"#303031"},"displayName":"Dark Plus","name":"dark-plus","semanticHighlighting":true,"semanticTokenColors":{"customLiteral":"#DCDCAA","newOperator":"#C586C0","numberLiteral":"#b5cea8","stringLiteral":"#ce9178"},"tokenColors":[{"scope":["meta.embedded","source.groovy.embedded","string meta.image.inline.markdown","variable.legacy.builtin.python"],"settings":{"foreground":"#D4D4D4"}},{"scope":"emphasis","settings":{"fontStyle":"italic"}},{"scope":"strong","settings":{"fontStyle":"bold"}},{"scope":"header","settings":{"foreground":"#000080"}},{"scope":"comment","settings":{"foreground":"#6A9955"}},{"scope":"constant.language","settings":{"foreground":"#569cd6"}},{"scope":["constant.numeric","variable.other.enummember","keyword.operator.plus.exponent","keyword.operator.minus.exponent"],"settings":{"foreground":"#b5cea8"}},{"scope":"constant.regexp","settings":{"foreground":"#646695"}},{"scope":"entity.name.tag","settings":{"foreground":"#569cd6"}},{"scope":["entity.name.tag.css","entity.name.tag.less"],"settings":{"foreground":"#d7ba7d"}},{"scope":"entity.other.attribute-name","settings":{"foreground":"#9cdcfe"}},{"scope":["entity.other.attribute-name.class.css","source.css entity.other.attribute-name.class","entity.other.attribute-name.id.css","entity.other.attribute-name.parent-selector.css","entity.other.attribute-name.parent.less","source.css entity.other.attribute-name.pseudo-class","entity.other.attribute-name.pseudo-element.css","source.css.less entity.other.attribute-name.id","entity.other.attribute-name.scss"],"settings":{"foreground":"#d7ba7d"}},{"scope":"invalid","settings":{"foreground":"#f44747"}},{"scope":"markup.underline","settings":{"fontStyle":"underline"}},{"scope":"markup.bold","settings":{"fontStyle":"bold","foreground":"#569cd6"}},{"scope":"markup.heading","settings":{"fontStyle":"bold","foreground":"#569cd6"}},{"scope":"markup.italic","settings":{"fontStyle":"italic"}},{"scope":"markup.strikethrough","settings":{"fontStyle":"strikethrough"}},{"scope":"markup.inserted","settings":{"foreground":"#b5cea8"}},{"scope":"markup.deleted","settings":{"foreground":"#ce9178"}},{"scope":"markup.changed","settings":{"foreground":"#569cd6"}},{"scope":"punctuation.definition.quote.begin.markdown","settings":{"foreground":"#6A9955"}},{"scope":"punctuation.definition.list.begin.markdown","settings":{"foreground":"#6796e6"}},{"scope":"markup.inline.raw","settings":{"foreground":"#ce9178"}},{"scope":"punctuation.definition.tag","settings":{"foreground":"#808080"}},{"scope":["meta.preprocessor","entity.name.function.preprocessor"],"settings":{"foreground":"#569cd6"}},{"scope":"meta.preprocessor.string","settings":{"foreground":"#ce9178"}},{"scope":"meta.preprocessor.numeric","settings":{"foreground":"#b5cea8"}},{"scope":"meta.structure.dictionary.key.python","settings":{"foreground":"#9cdcfe"}},{"scope":"meta.diff.header","settings":{"foreground":"#569cd6"}},{"scope":"storage","settings":{"foreground":"#569cd6"}},{"scope":"storage.type","settings":{"foreground":"#569cd6"}},{"scope":["storage.modifier","keyword.operator.noexcept"],"settings":{"foreground":"#569cd6"}},{"scope":["string","meta.embedded.assembly"],"settings":{"foreground":"#ce9178"}},{"scope":"string.tag","settings":{"foreground":"#ce9178"}},{"scope":"string.value","settings":{"foreground":"#ce9178"}},{"scope":"string.regexp","settings":{"foreground":"#d16969"}},{"scope":["punctuation.definition.template-expression.begin","punctuation.definition.template-expression.end","punctuation.section.embedded"],"settings":{"foreground":"#569cd6"}},{"scope":["meta.template.expression"],"settings":{"foreground":"#d4d4d4"}},{"scope":["support.type.vendored.property-name","support.type.property-name","source.css variable","source.coffee.embedded"],"settings":{"foreground":"#9cdcfe"}},{"scope":"keyword","settings":{"foreground":"#569cd6"}},{"scope":"keyword.control","settings":{"foreground":"#569cd6"}},{"scope":"keyword.operator","settings":{"foreground":"#d4d4d4"}},{"scope":["keyword.operator.new","keyword.operator.expression","keyword.operator.cast","keyword.operator.sizeof","keyword.operator.alignof","keyword.operator.typeid","keyword.operator.alignas","keyword.operator.instanceof","keyword.operator.logical.python","keyword.operator.wordlike"],"settings":{"foreground":"#569cd6"}},{"scope":"keyword.other.unit","settings":{"foreground":"#b5cea8"}},{"scope":["punctuation.section.embedded.begin.php","punctuation.section.embedded.end.php"],"settings":{"foreground":"#569cd6"}},{"scope":"support.function.git-rebase","settings":{"foreground":"#9cdcfe"}},{"scope":"constant.sha.git-rebase","settings":{"foreground":"#b5cea8"}},{"scope":["storage.modifier.import.java","variable.language.wildcard.java","storage.modifier.package.java"],"settings":{"foreground":"#d4d4d4"}},{"scope":"variable.language","settings":{"foreground":"#569cd6"}},{"scope":["entity.name.function","support.function","support.constant.handlebars","source.powershell variable.other.member","entity.name.operator.custom-literal"],"settings":{"foreground":"#DCDCAA"}},{"scope":["support.class","support.type","entity.name.type","entity.name.namespace","entity.other.attribute","entity.name.scope-resolution","entity.name.class","storage.type.numeric.go","storage.type.byte.go","storage.type.boolean.go","storage.type.string.go","storage.type.uintptr.go","storage.type.error.go","storage.type.rune.go","storage.type.cs","storage.type.generic.cs","storage.type.modifier.cs","storage.type.variable.cs","storage.type.annotation.java","storage.type.generic.java","storage.type.java","storage.type.object.array.java","storage.type.primitive.array.java","storage.type.primitive.java","storage.type.token.java","storage.type.groovy","storage.type.annotation.groovy","storage.type.parameters.groovy","storage.type.generic.groovy","storage.type.object.array.groovy","storage.type.primitive.array.groovy","storage.type.primitive.groovy"],"settings":{"foreground":"#4EC9B0"}},{"scope":["meta.type.cast.expr","meta.type.new.expr","support.constant.math","support.constant.dom","support.constant.json","entity.other.inherited-class","punctuation.separator.namespace.ruby"],"settings":{"foreground":"#4EC9B0"}},{"scope":["keyword.control","source.cpp keyword.operator.new","keyword.operator.delete","keyword.other.using","keyword.other.directive.using","keyword.other.operator","entity.name.operator"],"settings":{"foreground":"#C586C0"}},{"scope":["variable","meta.definition.variable.name","support.variable","entity.name.variable","constant.other.placeholder"],"settings":{"foreground":"#9CDCFE"}},{"scope":["variable.other.constant","variable.other.enummember"],"settings":{"foreground":"#4FC1FF"}},{"scope":["meta.object-literal.key"],"settings":{"foreground":"#9CDCFE"}},{"scope":["support.constant.property-value","support.constant.font-name","support.constant.media-type","support.constant.media","constant.other.color.rgb-value","constant.other.rgb-value","support.constant.color"],"settings":{"foreground":"#CE9178"}},{"scope":["punctuation.definition.group.regexp","punctuation.definition.group.assertion.regexp","punctuation.definition.character-class.regexp","punctuation.character.set.begin.regexp","punctuation.character.set.end.regexp","keyword.operator.negation.regexp","support.other.parenthesis.regexp"],"settings":{"foreground":"#CE9178"}},{"scope":["constant.character.character-class.regexp","constant.other.character-class.set.regexp","constant.other.character-class.regexp","constant.character.set.regexp"],"settings":{"foreground":"#d16969"}},{"scope":["keyword.operator.or.regexp","keyword.control.anchor.regexp"],"settings":{"foreground":"#DCDCAA"}},{"scope":"keyword.operator.quantifier.regexp","settings":{"foreground":"#d7ba7d"}},{"scope":["constant.character","constant.other.option"],"settings":{"foreground":"#569cd6"}},{"scope":"constant.character.escape","settings":{"foreground":"#d7ba7d"}},{"scope":"entity.name.label","settings":{"foreground":"#C8C8C8"}}],"type":"dark"}')),C9e=Object.freeze(Object.defineProperty({__proto__:null,default:PQ},Symbol.toStringTag,{value:"Module"})),j9e=["editor theme","vscode theme","monaco theme","workbench colors"],$T=new Set,H2="dark-plus",HB=new WeakSet,WB=PQ,N9e={"editor.background":"#0B0C0E","editorGutter.background":"#0B0C0E","editorStickyScroll.background":"#0B0C0E","editorStickyScrollGutter.background":"#0B0C0E","minimap.background":"#0B0C0E","editor.lineHighlightBackground":"#151922","editorWidget.background":"#16181D","editorHoverWidget.background":"#16181D","editorWidget.border":"#363B44","editorHoverWidget.border":"#363B44","editorGroupHeader.tabsBackground":"#0B0C0E"},T9e={base:"vs-dark",inherit:!1,rules:[...$Q(WB.tokenColors??[]),...L9e()],colors:{...DQ(WB.colors??{}),...N9e}};function E9e(){return j9e}function LQ(e){var r,n;(n=(r=e==null?void 0:e.editor)==null?void 0:r.defineTheme)==null||n.call(r,H2,T9e)}function A9e(e){!e||typeof e!="object"||HB.has(e)||(HB.add(e),Promise.all([Ve(()=>import("./index-D9vjmwPQ.js"),[],import.meta.url),Ve(()=>import("./index-6CZK0zgk.js"),[],import.meta.url)]).then(async([{shikiToMonaco:r},{createHighlighter:n}])=>{var l,d,u;const i=e.languages,s=new Set(((l=i==null?void 0:i.getLanguages)==null?void 0:l.call(i).map(f=>f.id))??[]);for(const f of["javascript","typescript","json","css","html","markdown","python","yaml","diff"])s.has(f)||((d=i==null?void 0:i.register)==null||d.call(i,{id:f}),s.add(f));const o=await n({themes:["dark-plus"],langs:["javascript","typescript","jsx","tsx","json","css","html","markdown","python","yaml","diff"]});r(o,e),LQ(e);const a=e.editor;typeof document<"u"&&document.documentElement.dataset.monacoTheme===H2&&((u=a==null?void 0:a.setTheme)==null||u.call(a,H2))}).catch(r=>{console.error("Failed to initialize Shiki Monaco Dark Plus theme:",r)}))}function O9e(e){var a;const r=R9e(e.text),n=DQ(r.colors??{}),i=D9e(r,n),s=((a=r.name)==null?void 0:a.trim())||e.sourceLabel.trim()||"Imported Theme",o=`jait-vscode-${U9e(s)}-${e.id}`;return{id:e.id,name:s,sourceLabel:e.sourceLabel,importedAt:e.importedAt??new Date().toISOString(),colorMode:i,monacoThemeName:o,monacoThemeData:{base:i==="dark"?"vs-dark":"vs",inherit:!0,rules:$Q(r.tokenColors??[]),colors:n},cssVariables:$9e(n),rawColors:n,hasInclude:typeof r.include=="string"&&r.include.trim().length>0}}function R9e(e){const r=W9e(H9e(e)),n=JSON.parse(r);if(!n||typeof n!="object"||Array.isArray(n))throw new Error("Theme file must contain a JSON object.");return n}function M9e(e,r){var n;!r||!((n=e==null?void 0:e.editor)!=null&&n.defineTheme)||e.editor.defineTheme(r.monacoThemeName,r.monacoThemeData)}function P9e(e){if(typeof document>"u")return;const r=document.documentElement;r.classList.toggle("dark",e.colorMode==="dark"),r.dataset.monacoTheme=e.monacoThemeName;for(const n of $T)r.style.removeProperty(n);if($T.clear(),!!e.theme)for(const[n,i]of Object.entries(e.theme.cssVariables))r.style.setProperty(n,i),$T.add(n)}function $Q(e){var n;const r=[];for(const i of e){const s=i.settings??{},o=I9e(i.scope);if(o.length===0)continue;const a=VB(s.foreground),l=VB(s.background),d=((n=s.fontStyle)==null?void 0:n.trim())||void 0;for(const u of o)r.push({token:u,foreground:a,background:l,fontStyle:d})}return r}function L9e(){return[{token:"",foreground:"D4D4D4",background:"1E1E1E"},{token:"invalid",foreground:"F44747"},{token:"emphasis",fontStyle:"italic"},{token:"strong",fontStyle:"bold"},{token:"comment",foreground:"6A9955"},{token:"constant",foreground:"569CD6"},{token:"number",foreground:"B5CEA8"},{token:"regexp",foreground:"D16969"},{token:"string",foreground:"CE9178"},{token:"string.key.json",foreground:"9CDCFE"},{token:"string.value.json",foreground:"CE9178"},{token:"keyword",foreground:"569CD6"},{token:"keyword.flow",foreground:"C586C0"},{token:"keyword.operator",foreground:"D4D4D4"},{token:"keyword.operator.new",foreground:"C586C0"},{token:"operator",foreground:"D4D4D4"},{token:"type",foreground:"4EC9B0"},{token:"type.identifier",foreground:"4EC9B0"},{token:"class",foreground:"4EC9B0"},{token:"interface",foreground:"4EC9B0"},{token:"enum",foreground:"4EC9B0"},{token:"namespace",foreground:"4EC9B0"},{token:"identifier",foreground:"9CDCFE"},{token:"identifier.function",foreground:"DCDCAA"},{token:"function",foreground:"DCDCAA"},{token:"member",foreground:"DCDCAA"},{token:"method",foreground:"DCDCAA"},{token:"property",foreground:"9CDCFE"},{token:"variable",foreground:"9CDCFE"},{token:"variable.parameter",foreground:"9CDCFE"},{token:"parameter",foreground:"9CDCFE"},{token:"delimiter",foreground:"D4D4D4"},{token:"delimiter.html",foreground:"808080"},{token:"delimiter.xml",foreground:"808080"},{token:"tag",foreground:"569CD6"},{token:"attribute.name",foreground:"9CDCFE"},{token:"attribute.value",foreground:"CE9178"}]}function $9e(e){const r={},n=ei(e,["editor.background","sideBar.background","panel.background"]),i=ei(e,["editor.foreground","foreground"]),s=ei(e,["sideBar.background","panel.background","editorWidget.background"]),o=ei(e,["panel.background","tab.inactiveBackground","editorGroupHeader.tabsBackground"]),a=ei(e,["list.hoverBackground","tab.activeBackground","editor.lineHighlightBackground"]),l=ei(e,["button.background","focusBorder","textLink.foreground"]),d=ei(e,["widget.border","panel.border","sideBar.border","contrastBorder"]);Si(r,"--background",n),Si(r,"--foreground",i),Si(r,"--card",s),Si(r,"--card-foreground",ei(e,["sideBar.foreground","foreground"])??i),Si(r,"--popover",ei(e,["editorWidget.background","panel.background"])??s),Si(r,"--popover-foreground",ei(e,["editorWidget.foreground","foreground"])??i),Si(r,"--primary",l),Si(r,"--primary-foreground",UB(l)),Si(r,"--secondary",ei(e,["tab.inactiveBackground","panel.background"])??o),Si(r,"--secondary-foreground",ei(e,["tab.inactiveForeground","foreground"])??i),Si(r,"--muted",o),Si(r,"--muted-foreground",ei(e,["descriptionForeground","input.placeholderForeground","disabledForeground"])),Si(r,"--accent",a),Si(r,"--accent-foreground",ei(e,["list.activeSelectionForeground","foreground"])??i),Si(r,"--destructive",ei(e,["inputValidation.errorBackground","errorForeground","list.errorForeground"])),Si(r,"--destructive-foreground",UB(ei(e,["inputValidation.errorBackground","errorForeground"]))),Si(r,"--border",d),Si(r,"--input",ei(e,["input.background","editorWidget.background","dropdown.background"])??d),Si(r,"--ring",ei(e,["focusBorder","button.background","textLink.foreground"])??l),Si(r,"--scrollbar-track",ei(e,["editor.background","sideBar.background","panel.background"])??n),Si(r,"--scrollbar-thumb",ei(e,["scrollbarSlider.background","scrollbar.shadow"])),Si(r,"--scrollbar-thumb-hover",ei(e,["scrollbarSlider.hoverBackground","scrollbarSlider.activeBackground","scrollbarSlider.background"])),Si(r,"--toast-bg",ei(e,["notifications.background","editorWidget.background","panel.background"])??s,!0),Si(r,"--toast-border",ei(e,["notifications.border","widget.border","panel.border"])??d,!0),Si(r,"--toast-success-accent",ei(e,["testing.iconPassed","terminal.ansiGreen"])),Si(r,"--toast-info-accent",ei(e,["textLink.foreground","focusBorder"])??l),Si(r,"--toast-warning-accent",ei(e,["editorWarning.foreground","terminal.ansiYellow"])),Si(r,"--toast-error-accent",ei(e,["editorError.foreground","terminal.ansiRed"]));const u=ei(e,["editorGroupHeader.tabsBackground","tab.inactiveBackground","sideBar.background"]);u&&(r["--tab-bg"]=u);const f=ei(e,["activityBarBadge.background","button.background","focusBorder"]),p=ei(e,["textLink.foreground","terminal.ansiBlue"]),g=ei(e,["editorWarning.foreground","terminal.ansiYellow"]),v=ei(e,["terminal.ansiMagenta","badge.background"]);return f&&(r["--ctx-system"]=f),p&&(r["--ctx-history"]=p),g&&(r["--ctx-tool-results"]=g),v&&(r["--ctx-tools"]=v),r}function Si(e,r,n,i=!1){if(!n)return;const s=B9e(n,i);s&&(e[r]=s)}function UB(e){const r=XR(e);return r?(.2126*r.r+.7152*r.g+.0722*r.b)/255>.55?"0 0% 7%":"0 0% 100%":null}function D9e(e,r){if(e.type==="light"||e.type==="hc-light")return"light";if(e.type==="dark"||e.type==="hc-dark")return"dark";const n=XR(r["editor.background"]??r["sideBar.background"]??"");return n&&(.2126*n.r+.7152*n.g+.0722*n.b)/255>.55?"light":"dark"}function DQ(e){const r={};for(const[n,i]of Object.entries(e))typeof i=="string"&&i.trim()&&(r[n]=i.trim());return r}function I9e(e){return Array.isArray(e)?e.flatMap(r=>r.split(",")).map(r=>r.trim()).filter(Boolean):typeof e!="string"?[]:e.split(",").map(r=>r.trim()).filter(Boolean)}function VB(e){if(!e)return;const r=e.trim();if(r.startsWith("#"))return IQ(r).slice(1)}function ei(e,r){for(const n of r){const i=e[n];if(typeof i=="string"&&i.trim())return i.trim()}return null}function B9e(e,r=!1){const n=XR(e);if(!n)return null;const i=n.r/255,s=n.g/255,o=n.b/255,a=Math.max(i,s,o),l=Math.min(i,s,o),d=a-l,u=(a+l)/2;let f=0;d!==0&&(a===i?f=(s-o)/d%6:a===s?f=(o-i)/d+2:f=(i-s)/d+4,f*=60),f<0&&(f+=360);const p=d===0?0:d/(1-Math.abs(2*u-1)),g=`${Math.round(f)} ${Math.round(p*100)}% ${Math.round(u*100)}%`;return r&&n.a<1?`${g} / ${Number(n.a.toFixed(3))}`:g}function XR(e){if(!e)return null;const r=e.trim();if(!r)return null;if(r.startsWith("#"))return z9e(r);const n=r.match(/^rgba?\(([^)]+)\)$/i);if(!n)return null;const i=n[1].split(",").map(d=>d.trim());if(i.length<3)return null;const s=DT(i[0]),o=DT(i[1]),a=DT(i[2]),l=i[3]==null?1:F9e(i[3]);return s==null||o==null||a==null||l==null?null:{r:s,g:o,b:a,a:l}}function z9e(e){const r=IQ(e).slice(1);return r.length===6?{r:Number.parseInt(r.slice(0,2),16),g:Number.parseInt(r.slice(2,4),16),b:Number.parseInt(r.slice(4,6),16),a:1}:r.length===8?{r:Number.parseInt(r.slice(0,2),16),g:Number.parseInt(r.slice(2,4),16),b:Number.parseInt(r.slice(4,6),16),a:Number.parseInt(r.slice(6,8),16)/255}:null}function DT(e){if(e.endsWith("%")){const n=Number.parseFloat(e.slice(0,-1));return Number.isFinite(n)?qB(Math.round(n/100*255)):null}const r=Number.parseFloat(e);return Number.isFinite(r)?qB(Math.round(r)):null}function F9e(e){const r=Number.parseFloat(e);return Number.isFinite(r)?Math.max(0,Math.min(1,r)):null}function qB(e){return Math.max(0,Math.min(255,e))}function IQ(e){const r=e.trim().slice(1);return r.length===3||r.length===4?`#${r.split("").map(n=>`${n}${n}`).join("").toLowerCase()}`:`#${r.toLowerCase()}`}function H9e(e){let r="",n=!1,i=!1,s=!1,o=!1;for(let a=0;a<e.length;a+=1){const l=e[a],d=e[a+1];if(i){l===`
879
+ `},FB=l9e(h9e)(AQ),f9e={config:u9e},p9e=function(){for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];return function(s){return n.reduceRight(function(o,a){return a(o)},s)}};function OQ(e,r){return Object.keys(r).forEach(function(n){r[n]instanceof Object&&e[n]&&Object.assign(r[n],OQ(e[n],r[n]))}),IB(IB({},e),r)}var m9e={type:"cancelation",msg:"operation is manually canceled"};function PT(e){var r=!1,n=new Promise(function(i,s){e.then(function(o){return r?s(m9e):i(o)}),e.catch(s)});return n.cancel=function(){return r=!0},n}var g9e=["monaco"],y9e=o9e.create({config:a9e,isInitialized:!1,resolve:null,reject:null,monaco:null}),RQ=HOe(y9e,2),RS=RQ[0],Dj=RQ[1];function v9e(e){var r=f9e.config(e),n=r.monaco,i=zOe(r,g9e);Dj(function(s){return{config:OQ(s.config,i),monaco:n}})}function x9e(){var e=RS(function(r){var n=r.monaco,i=r.isInitialized,s=r.resolve;return{monaco:n,isInitialized:i,resolve:s}});if(!e.isInitialized){if(Dj({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),PT(LT);if(window.monaco&&window.monaco.editor)return MQ(window.monaco),e.resolve(window.monaco),PT(LT);p9e(b9e,w9e)(S9e)}return PT(LT)}function b9e(e){return document.body.appendChild(e)}function _9e(e){var r=document.createElement("script");return e&&(r.src=e),r}function w9e(e){var r=RS(function(i){var s=i.config,o=i.reject;return{config:s,reject:o}}),n=_9e("".concat(r.config.paths.vs,"/loader.js"));return n.onload=function(){return e()},n.onerror=r.reject,n}function S9e(){var e=RS(function(n){var i=n.config,s=n.resolve,o=n.reject;return{config:i,resolve:s,reject:o}}),r=window.require;r.config(e.config),r(["vs/editor/editor.main"],function(n){var i=n.m||n;MQ(i),e.resolve(i)},function(n){e.reject(n)})}function MQ(e){RS().monaco||Dj({monaco:e})}function k9e(){return RS(function(e){var r=e.monaco;return r})}var LT=new Promise(function(e,r){return Dj({resolve:e,reject:r})}),YR={config:v9e,init:x9e,__getMonacoInstance:k9e};const PQ=Object.freeze(JSON.parse('{"colors":{"actionBar.toggledBackground":"#383a49","activityBarBadge.background":"#007ACC","checkbox.border":"#6B6B6B","editor.background":"#1E1E1E","editor.foreground":"#D4D4D4","editor.inactiveSelectionBackground":"#3A3D41","editor.selectionHighlightBackground":"#ADD6FF26","editorIndentGuide.activeBackground1":"#707070","editorIndentGuide.background1":"#404040","input.placeholderForeground":"#A6A6A6","list.activeSelectionIconForeground":"#FFF","list.dropBackground":"#383B3D","menu.background":"#252526","menu.border":"#454545","menu.foreground":"#CCCCCC","menu.selectionBackground":"#0078d4","menu.separatorBackground":"#454545","ports.iconRunningProcessForeground":"#369432","sideBarSectionHeader.background":"#0000","sideBarSectionHeader.border":"#ccc3","sideBarTitle.foreground":"#BBBBBB","statusBarItem.remoteBackground":"#16825D","statusBarItem.remoteForeground":"#FFF","tab.lastPinnedBorder":"#ccc3","tab.selectedBackground":"#222222","tab.selectedForeground":"#ffffffa0","terminal.inactiveSelectionBackground":"#3A3D41","widget.border":"#303031"},"displayName":"Dark Plus","name":"dark-plus","semanticHighlighting":true,"semanticTokenColors":{"customLiteral":"#DCDCAA","newOperator":"#C586C0","numberLiteral":"#b5cea8","stringLiteral":"#ce9178"},"tokenColors":[{"scope":["meta.embedded","source.groovy.embedded","string meta.image.inline.markdown","variable.legacy.builtin.python"],"settings":{"foreground":"#D4D4D4"}},{"scope":"emphasis","settings":{"fontStyle":"italic"}},{"scope":"strong","settings":{"fontStyle":"bold"}},{"scope":"header","settings":{"foreground":"#000080"}},{"scope":"comment","settings":{"foreground":"#6A9955"}},{"scope":"constant.language","settings":{"foreground":"#569cd6"}},{"scope":["constant.numeric","variable.other.enummember","keyword.operator.plus.exponent","keyword.operator.minus.exponent"],"settings":{"foreground":"#b5cea8"}},{"scope":"constant.regexp","settings":{"foreground":"#646695"}},{"scope":"entity.name.tag","settings":{"foreground":"#569cd6"}},{"scope":["entity.name.tag.css","entity.name.tag.less"],"settings":{"foreground":"#d7ba7d"}},{"scope":"entity.other.attribute-name","settings":{"foreground":"#9cdcfe"}},{"scope":["entity.other.attribute-name.class.css","source.css entity.other.attribute-name.class","entity.other.attribute-name.id.css","entity.other.attribute-name.parent-selector.css","entity.other.attribute-name.parent.less","source.css entity.other.attribute-name.pseudo-class","entity.other.attribute-name.pseudo-element.css","source.css.less entity.other.attribute-name.id","entity.other.attribute-name.scss"],"settings":{"foreground":"#d7ba7d"}},{"scope":"invalid","settings":{"foreground":"#f44747"}},{"scope":"markup.underline","settings":{"fontStyle":"underline"}},{"scope":"markup.bold","settings":{"fontStyle":"bold","foreground":"#569cd6"}},{"scope":"markup.heading","settings":{"fontStyle":"bold","foreground":"#569cd6"}},{"scope":"markup.italic","settings":{"fontStyle":"italic"}},{"scope":"markup.strikethrough","settings":{"fontStyle":"strikethrough"}},{"scope":"markup.inserted","settings":{"foreground":"#b5cea8"}},{"scope":"markup.deleted","settings":{"foreground":"#ce9178"}},{"scope":"markup.changed","settings":{"foreground":"#569cd6"}},{"scope":"punctuation.definition.quote.begin.markdown","settings":{"foreground":"#6A9955"}},{"scope":"punctuation.definition.list.begin.markdown","settings":{"foreground":"#6796e6"}},{"scope":"markup.inline.raw","settings":{"foreground":"#ce9178"}},{"scope":"punctuation.definition.tag","settings":{"foreground":"#808080"}},{"scope":["meta.preprocessor","entity.name.function.preprocessor"],"settings":{"foreground":"#569cd6"}},{"scope":"meta.preprocessor.string","settings":{"foreground":"#ce9178"}},{"scope":"meta.preprocessor.numeric","settings":{"foreground":"#b5cea8"}},{"scope":"meta.structure.dictionary.key.python","settings":{"foreground":"#9cdcfe"}},{"scope":"meta.diff.header","settings":{"foreground":"#569cd6"}},{"scope":"storage","settings":{"foreground":"#569cd6"}},{"scope":"storage.type","settings":{"foreground":"#569cd6"}},{"scope":["storage.modifier","keyword.operator.noexcept"],"settings":{"foreground":"#569cd6"}},{"scope":["string","meta.embedded.assembly"],"settings":{"foreground":"#ce9178"}},{"scope":"string.tag","settings":{"foreground":"#ce9178"}},{"scope":"string.value","settings":{"foreground":"#ce9178"}},{"scope":"string.regexp","settings":{"foreground":"#d16969"}},{"scope":["punctuation.definition.template-expression.begin","punctuation.definition.template-expression.end","punctuation.section.embedded"],"settings":{"foreground":"#569cd6"}},{"scope":["meta.template.expression"],"settings":{"foreground":"#d4d4d4"}},{"scope":["support.type.vendored.property-name","support.type.property-name","source.css variable","source.coffee.embedded"],"settings":{"foreground":"#9cdcfe"}},{"scope":"keyword","settings":{"foreground":"#569cd6"}},{"scope":"keyword.control","settings":{"foreground":"#569cd6"}},{"scope":"keyword.operator","settings":{"foreground":"#d4d4d4"}},{"scope":["keyword.operator.new","keyword.operator.expression","keyword.operator.cast","keyword.operator.sizeof","keyword.operator.alignof","keyword.operator.typeid","keyword.operator.alignas","keyword.operator.instanceof","keyword.operator.logical.python","keyword.operator.wordlike"],"settings":{"foreground":"#569cd6"}},{"scope":"keyword.other.unit","settings":{"foreground":"#b5cea8"}},{"scope":["punctuation.section.embedded.begin.php","punctuation.section.embedded.end.php"],"settings":{"foreground":"#569cd6"}},{"scope":"support.function.git-rebase","settings":{"foreground":"#9cdcfe"}},{"scope":"constant.sha.git-rebase","settings":{"foreground":"#b5cea8"}},{"scope":["storage.modifier.import.java","variable.language.wildcard.java","storage.modifier.package.java"],"settings":{"foreground":"#d4d4d4"}},{"scope":"variable.language","settings":{"foreground":"#569cd6"}},{"scope":["entity.name.function","support.function","support.constant.handlebars","source.powershell variable.other.member","entity.name.operator.custom-literal"],"settings":{"foreground":"#DCDCAA"}},{"scope":["support.class","support.type","entity.name.type","entity.name.namespace","entity.other.attribute","entity.name.scope-resolution","entity.name.class","storage.type.numeric.go","storage.type.byte.go","storage.type.boolean.go","storage.type.string.go","storage.type.uintptr.go","storage.type.error.go","storage.type.rune.go","storage.type.cs","storage.type.generic.cs","storage.type.modifier.cs","storage.type.variable.cs","storage.type.annotation.java","storage.type.generic.java","storage.type.java","storage.type.object.array.java","storage.type.primitive.array.java","storage.type.primitive.java","storage.type.token.java","storage.type.groovy","storage.type.annotation.groovy","storage.type.parameters.groovy","storage.type.generic.groovy","storage.type.object.array.groovy","storage.type.primitive.array.groovy","storage.type.primitive.groovy"],"settings":{"foreground":"#4EC9B0"}},{"scope":["meta.type.cast.expr","meta.type.new.expr","support.constant.math","support.constant.dom","support.constant.json","entity.other.inherited-class","punctuation.separator.namespace.ruby"],"settings":{"foreground":"#4EC9B0"}},{"scope":["keyword.control","source.cpp keyword.operator.new","keyword.operator.delete","keyword.other.using","keyword.other.directive.using","keyword.other.operator","entity.name.operator"],"settings":{"foreground":"#C586C0"}},{"scope":["variable","meta.definition.variable.name","support.variable","entity.name.variable","constant.other.placeholder"],"settings":{"foreground":"#9CDCFE"}},{"scope":["variable.other.constant","variable.other.enummember"],"settings":{"foreground":"#4FC1FF"}},{"scope":["meta.object-literal.key"],"settings":{"foreground":"#9CDCFE"}},{"scope":["support.constant.property-value","support.constant.font-name","support.constant.media-type","support.constant.media","constant.other.color.rgb-value","constant.other.rgb-value","support.constant.color"],"settings":{"foreground":"#CE9178"}},{"scope":["punctuation.definition.group.regexp","punctuation.definition.group.assertion.regexp","punctuation.definition.character-class.regexp","punctuation.character.set.begin.regexp","punctuation.character.set.end.regexp","keyword.operator.negation.regexp","support.other.parenthesis.regexp"],"settings":{"foreground":"#CE9178"}},{"scope":["constant.character.character-class.regexp","constant.other.character-class.set.regexp","constant.other.character-class.regexp","constant.character.set.regexp"],"settings":{"foreground":"#d16969"}},{"scope":["keyword.operator.or.regexp","keyword.control.anchor.regexp"],"settings":{"foreground":"#DCDCAA"}},{"scope":"keyword.operator.quantifier.regexp","settings":{"foreground":"#d7ba7d"}},{"scope":["constant.character","constant.other.option"],"settings":{"foreground":"#569cd6"}},{"scope":"constant.character.escape","settings":{"foreground":"#d7ba7d"}},{"scope":"entity.name.label","settings":{"foreground":"#C8C8C8"}}],"type":"dark"}')),C9e=Object.freeze(Object.defineProperty({__proto__:null,default:PQ},Symbol.toStringTag,{value:"Module"})),j9e=["editor theme","vscode theme","monaco theme","workbench colors"],$T=new Set,H2="dark-plus",HB=new WeakSet,WB=PQ,N9e={"editor.background":"#0B0C0E","editorGutter.background":"#0B0C0E","editorStickyScroll.background":"#0B0C0E","editorStickyScrollGutter.background":"#0B0C0E","minimap.background":"#0B0C0E","editor.lineHighlightBackground":"#151922","editorWidget.background":"#16181D","editorHoverWidget.background":"#16181D","editorWidget.border":"#363B44","editorHoverWidget.border":"#363B44","editorGroupHeader.tabsBackground":"#0B0C0E"},T9e={base:"vs-dark",inherit:!1,rules:[...$Q(WB.tokenColors??[]),...L9e()],colors:{...DQ(WB.colors??{}),...N9e}};function E9e(){return j9e}function LQ(e){var r,n;(n=(r=e==null?void 0:e.editor)==null?void 0:r.defineTheme)==null||n.call(r,H2,T9e)}function A9e(e){!e||typeof e!="object"||HB.has(e)||(HB.add(e),Promise.all([Ve(()=>import("./index-lEfiShbN.js"),[],import.meta.url),Ve(()=>import("./index-DeZT2FMn.js"),[],import.meta.url)]).then(async([{shikiToMonaco:r},{createHighlighter:n}])=>{var l,d,u;const i=e.languages,s=new Set(((l=i==null?void 0:i.getLanguages)==null?void 0:l.call(i).map(f=>f.id))??[]);for(const f of["javascript","typescript","json","css","html","markdown","python","yaml","diff"])s.has(f)||((d=i==null?void 0:i.register)==null||d.call(i,{id:f}),s.add(f));const o=await n({themes:["dark-plus"],langs:["javascript","typescript","jsx","tsx","json","css","html","markdown","python","yaml","diff"]});r(o,e),LQ(e);const a=e.editor;typeof document<"u"&&document.documentElement.dataset.monacoTheme===H2&&((u=a==null?void 0:a.setTheme)==null||u.call(a,H2))}).catch(r=>{console.error("Failed to initialize Shiki Monaco Dark Plus theme:",r)}))}function O9e(e){var a;const r=R9e(e.text),n=DQ(r.colors??{}),i=D9e(r,n),s=((a=r.name)==null?void 0:a.trim())||e.sourceLabel.trim()||"Imported Theme",o=`jait-vscode-${U9e(s)}-${e.id}`;return{id:e.id,name:s,sourceLabel:e.sourceLabel,importedAt:e.importedAt??new Date().toISOString(),colorMode:i,monacoThemeName:o,monacoThemeData:{base:i==="dark"?"vs-dark":"vs",inherit:!0,rules:$Q(r.tokenColors??[]),colors:n},cssVariables:$9e(n),rawColors:n,hasInclude:typeof r.include=="string"&&r.include.trim().length>0}}function R9e(e){const r=W9e(H9e(e)),n=JSON.parse(r);if(!n||typeof n!="object"||Array.isArray(n))throw new Error("Theme file must contain a JSON object.");return n}function M9e(e,r){var n;!r||!((n=e==null?void 0:e.editor)!=null&&n.defineTheme)||e.editor.defineTheme(r.monacoThemeName,r.monacoThemeData)}function P9e(e){if(typeof document>"u")return;const r=document.documentElement;r.classList.toggle("dark",e.colorMode==="dark"),r.dataset.monacoTheme=e.monacoThemeName;for(const n of $T)r.style.removeProperty(n);if($T.clear(),!!e.theme)for(const[n,i]of Object.entries(e.theme.cssVariables))r.style.setProperty(n,i),$T.add(n)}function $Q(e){var n;const r=[];for(const i of e){const s=i.settings??{},o=I9e(i.scope);if(o.length===0)continue;const a=VB(s.foreground),l=VB(s.background),d=((n=s.fontStyle)==null?void 0:n.trim())||void 0;for(const u of o)r.push({token:u,foreground:a,background:l,fontStyle:d})}return r}function L9e(){return[{token:"",foreground:"D4D4D4",background:"1E1E1E"},{token:"invalid",foreground:"F44747"},{token:"emphasis",fontStyle:"italic"},{token:"strong",fontStyle:"bold"},{token:"comment",foreground:"6A9955"},{token:"constant",foreground:"569CD6"},{token:"number",foreground:"B5CEA8"},{token:"regexp",foreground:"D16969"},{token:"string",foreground:"CE9178"},{token:"string.key.json",foreground:"9CDCFE"},{token:"string.value.json",foreground:"CE9178"},{token:"keyword",foreground:"569CD6"},{token:"keyword.flow",foreground:"C586C0"},{token:"keyword.operator",foreground:"D4D4D4"},{token:"keyword.operator.new",foreground:"C586C0"},{token:"operator",foreground:"D4D4D4"},{token:"type",foreground:"4EC9B0"},{token:"type.identifier",foreground:"4EC9B0"},{token:"class",foreground:"4EC9B0"},{token:"interface",foreground:"4EC9B0"},{token:"enum",foreground:"4EC9B0"},{token:"namespace",foreground:"4EC9B0"},{token:"identifier",foreground:"9CDCFE"},{token:"identifier.function",foreground:"DCDCAA"},{token:"function",foreground:"DCDCAA"},{token:"member",foreground:"DCDCAA"},{token:"method",foreground:"DCDCAA"},{token:"property",foreground:"9CDCFE"},{token:"variable",foreground:"9CDCFE"},{token:"variable.parameter",foreground:"9CDCFE"},{token:"parameter",foreground:"9CDCFE"},{token:"delimiter",foreground:"D4D4D4"},{token:"delimiter.html",foreground:"808080"},{token:"delimiter.xml",foreground:"808080"},{token:"tag",foreground:"569CD6"},{token:"attribute.name",foreground:"9CDCFE"},{token:"attribute.value",foreground:"CE9178"}]}function $9e(e){const r={},n=ei(e,["editor.background","sideBar.background","panel.background"]),i=ei(e,["editor.foreground","foreground"]),s=ei(e,["sideBar.background","panel.background","editorWidget.background"]),o=ei(e,["panel.background","tab.inactiveBackground","editorGroupHeader.tabsBackground"]),a=ei(e,["list.hoverBackground","tab.activeBackground","editor.lineHighlightBackground"]),l=ei(e,["button.background","focusBorder","textLink.foreground"]),d=ei(e,["widget.border","panel.border","sideBar.border","contrastBorder"]);Si(r,"--background",n),Si(r,"--foreground",i),Si(r,"--card",s),Si(r,"--card-foreground",ei(e,["sideBar.foreground","foreground"])??i),Si(r,"--popover",ei(e,["editorWidget.background","panel.background"])??s),Si(r,"--popover-foreground",ei(e,["editorWidget.foreground","foreground"])??i),Si(r,"--primary",l),Si(r,"--primary-foreground",UB(l)),Si(r,"--secondary",ei(e,["tab.inactiveBackground","panel.background"])??o),Si(r,"--secondary-foreground",ei(e,["tab.inactiveForeground","foreground"])??i),Si(r,"--muted",o),Si(r,"--muted-foreground",ei(e,["descriptionForeground","input.placeholderForeground","disabledForeground"])),Si(r,"--accent",a),Si(r,"--accent-foreground",ei(e,["list.activeSelectionForeground","foreground"])??i),Si(r,"--destructive",ei(e,["inputValidation.errorBackground","errorForeground","list.errorForeground"])),Si(r,"--destructive-foreground",UB(ei(e,["inputValidation.errorBackground","errorForeground"]))),Si(r,"--border",d),Si(r,"--input",ei(e,["input.background","editorWidget.background","dropdown.background"])??d),Si(r,"--ring",ei(e,["focusBorder","button.background","textLink.foreground"])??l),Si(r,"--scrollbar-track",ei(e,["editor.background","sideBar.background","panel.background"])??n),Si(r,"--scrollbar-thumb",ei(e,["scrollbarSlider.background","scrollbar.shadow"])),Si(r,"--scrollbar-thumb-hover",ei(e,["scrollbarSlider.hoverBackground","scrollbarSlider.activeBackground","scrollbarSlider.background"])),Si(r,"--toast-bg",ei(e,["notifications.background","editorWidget.background","panel.background"])??s,!0),Si(r,"--toast-border",ei(e,["notifications.border","widget.border","panel.border"])??d,!0),Si(r,"--toast-success-accent",ei(e,["testing.iconPassed","terminal.ansiGreen"])),Si(r,"--toast-info-accent",ei(e,["textLink.foreground","focusBorder"])??l),Si(r,"--toast-warning-accent",ei(e,["editorWarning.foreground","terminal.ansiYellow"])),Si(r,"--toast-error-accent",ei(e,["editorError.foreground","terminal.ansiRed"]));const u=ei(e,["editorGroupHeader.tabsBackground","tab.inactiveBackground","sideBar.background"]);u&&(r["--tab-bg"]=u);const f=ei(e,["activityBarBadge.background","button.background","focusBorder"]),p=ei(e,["textLink.foreground","terminal.ansiBlue"]),g=ei(e,["editorWarning.foreground","terminal.ansiYellow"]),v=ei(e,["terminal.ansiMagenta","badge.background"]);return f&&(r["--ctx-system"]=f),p&&(r["--ctx-history"]=p),g&&(r["--ctx-tool-results"]=g),v&&(r["--ctx-tools"]=v),r}function Si(e,r,n,i=!1){if(!n)return;const s=B9e(n,i);s&&(e[r]=s)}function UB(e){const r=XR(e);return r?(.2126*r.r+.7152*r.g+.0722*r.b)/255>.55?"0 0% 7%":"0 0% 100%":null}function D9e(e,r){if(e.type==="light"||e.type==="hc-light")return"light";if(e.type==="dark"||e.type==="hc-dark")return"dark";const n=XR(r["editor.background"]??r["sideBar.background"]??"");return n&&(.2126*n.r+.7152*n.g+.0722*n.b)/255>.55?"light":"dark"}function DQ(e){const r={};for(const[n,i]of Object.entries(e))typeof i=="string"&&i.trim()&&(r[n]=i.trim());return r}function I9e(e){return Array.isArray(e)?e.flatMap(r=>r.split(",")).map(r=>r.trim()).filter(Boolean):typeof e!="string"?[]:e.split(",").map(r=>r.trim()).filter(Boolean)}function VB(e){if(!e)return;const r=e.trim();if(r.startsWith("#"))return IQ(r).slice(1)}function ei(e,r){for(const n of r){const i=e[n];if(typeof i=="string"&&i.trim())return i.trim()}return null}function B9e(e,r=!1){const n=XR(e);if(!n)return null;const i=n.r/255,s=n.g/255,o=n.b/255,a=Math.max(i,s,o),l=Math.min(i,s,o),d=a-l,u=(a+l)/2;let f=0;d!==0&&(a===i?f=(s-o)/d%6:a===s?f=(o-i)/d+2:f=(i-s)/d+4,f*=60),f<0&&(f+=360);const p=d===0?0:d/(1-Math.abs(2*u-1)),g=`${Math.round(f)} ${Math.round(p*100)}% ${Math.round(u*100)}%`;return r&&n.a<1?`${g} / ${Number(n.a.toFixed(3))}`:g}function XR(e){if(!e)return null;const r=e.trim();if(!r)return null;if(r.startsWith("#"))return z9e(r);const n=r.match(/^rgba?\(([^)]+)\)$/i);if(!n)return null;const i=n[1].split(",").map(d=>d.trim());if(i.length<3)return null;const s=DT(i[0]),o=DT(i[1]),a=DT(i[2]),l=i[3]==null?1:F9e(i[3]);return s==null||o==null||a==null||l==null?null:{r:s,g:o,b:a,a:l}}function z9e(e){const r=IQ(e).slice(1);return r.length===6?{r:Number.parseInt(r.slice(0,2),16),g:Number.parseInt(r.slice(2,4),16),b:Number.parseInt(r.slice(4,6),16),a:1}:r.length===8?{r:Number.parseInt(r.slice(0,2),16),g:Number.parseInt(r.slice(2,4),16),b:Number.parseInt(r.slice(4,6),16),a:Number.parseInt(r.slice(6,8),16)/255}:null}function DT(e){if(e.endsWith("%")){const n=Number.parseFloat(e.slice(0,-1));return Number.isFinite(n)?qB(Math.round(n/100*255)):null}const r=Number.parseFloat(e);return Number.isFinite(r)?qB(Math.round(r)):null}function F9e(e){const r=Number.parseFloat(e);return Number.isFinite(r)?Math.max(0,Math.min(1,r)):null}function qB(e){return Math.max(0,Math.min(255,e))}function IQ(e){const r=e.trim().slice(1);return r.length===3||r.length===4?`#${r.split("").map(n=>`${n}${n}`).join("").toLowerCase()}`:`#${r.toLowerCase()}`}function H9e(e){let r="",n=!1,i=!1,s=!1,o=!1;for(let a=0;a<e.length;a+=1){const l=e[a],d=e[a+1];if(i){l===`
880
880
  `&&(i=!1,r+=l);continue}if(s){l==="*"&&d==="/"&&(s=!1,a+=1);continue}if(n){r+=l,o?o=!1:l==="\\"?o=!0:l==='"'&&(n=!1);continue}if(l==='"'){n=!0,r+=l;continue}if(l==="/"&&d==="/"){i=!0,a+=1;continue}if(l==="/"&&d==="*"){s=!0,a+=1;continue}r+=l}return r}function W9e(e){return e.replace(/,\s*([}\]])/g,"$1")}function U9e(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40)||"theme"}function GB(){if(typeof document>"u")return"vs";const e=document.documentElement;return e.dataset.monacoTheme??(e.classList.contains("dark")?H2:"vs")}function Ij(){const[e,r]=y.useState(GB);return y.useEffect(()=>{if(typeof document>"u")return;const n=document.documentElement,i=()=>r(GB());i();const s=new MutationObserver(i);return s.observe(n,{attributes:!0,attributeFilter:["class","data-monaco-theme"]}),()=>s.disconnect()},[]),e}const ZR="jait:vscode-theme-store",NC=new Set;let Ed=BQ(),KB=!1;function BQ(){if(typeof window>"u"||!window.localStorage)return{importedThemes:[],activeThemeId:null};const e=window.localStorage.getItem(ZR);if(!e)return{importedThemes:[],activeThemeId:null};try{const r=JSON.parse(e),n=Array.isArray(r.importedThemes)?r.importedThemes.filter(s=>!!(s&&typeof s.id=="string"&&typeof s.monacoThemeName=="string")):[],i=typeof r.activeThemeId=="string"?r.activeThemeId:null;return{importedThemes:n,activeThemeId:n.some(s=>s.id===i)?i:null}}catch{return{importedThemes:[],activeThemeId:null}}}function JR(e){Ed=e,typeof window<"u"&&window.localStorage&&window.localStorage.setItem(ZR,JSON.stringify(e));for(const r of NC)r()}function V9e(e){return!KB&&typeof window<"u"&&(KB=!0,window.addEventListener("storage",r=>{if(r.key===ZR){Ed=BQ();for(const n of NC)n()}})),NC.add(e),()=>NC.delete(e)}function YB(){return Ed}function zQ(){const e=y.useSyncExternalStore(V9e,YB,YB);return{...e,activeTheme:e.importedThemes.find(r=>r.id===e.activeThemeId)??null}}function FQ(){return Ed.importedThemes.find(e=>e.id===Ed.activeThemeId)??null}function q9e(e,r){const n=`${Date.now().toString(36)}-${Y9e(e+r)}`,i=O9e({id:n,sourceLabel:e,text:r});return JR({importedThemes:[...Ed.importedThemes.filter(s=>s.id!==n),i],activeThemeId:n}),i}function A5(e){JR({...Ed,activeThemeId:e&&Ed.importedThemes.some(r=>r.id===e)?e:null})}function G9e(e){JR({importedThemes:Ed.importedThemes.filter(r=>r.id!==e),activeThemeId:Ed.activeThemeId===e?null:Ed.activeThemeId})}function K9e(e){LQ(e);const r=FQ();r?M9e(e,r):A9e(e)}function wu(e,r){var n,i;K9e(e),r&&((i=(n=e==null?void 0:e.editor)==null?void 0:n.setTheme)==null||i.call(n,r))}function Y9e(e){let r=0;for(let n=0;n<e.length;n+=1)r=(r<<5)-r+e.charCodeAt(n)|0;return Math.abs(r).toString(36)}function m1(e,r){return Math.max(1,e||r||1)}function W2({original:e,modified:r,language:n,modelKey:i,className:s,editorClassName:o,renderSideBySide:a=!1,emptyMessage:l="Files are identical.",options:d}){const u=y.useRef(null),f=y.useRef(null),p=y.useRef(null),g=y.useRef(null),v=y.useRef({original:null,modified:null}),[b,_]=y.useState(!1),[S,k]=y.useState([]),[C,j]=y.useState(0),E=Ij(),N=y.useRef(E);y.useEffect(()=>{N.current=E},[E]);const A=y.useMemo(()=>`inmemory://jait-diff/${encodeURIComponent(i??`${n}:${e.length}:${r.length}`)}`,[n,i,r.length,e.length]),M=y.useMemo(()=>({readOnly:!0,renderSideBySide:a,minimap:{enabled:!1},"semanticHighlighting.enabled":!0,fontSize:13,automaticLayout:!0,scrollBeyondLastLine:!1,renderOverviewRuler:!0,ignoreTrimWhitespace:!1,...d}),[d,a]),B=y.useCallback(()=>{var H;const W=f.current;if(!W)return;const U=((H=W.getLineChanges)==null?void 0:H.call(W))??[];k(U.map(R=>({originalStartLineNumber:R.originalStartLineNumber,originalEndLineNumber:R.originalEndLineNumber,modifiedStartLineNumber:R.modifiedStartLineNumber,modifiedEndLineNumber:R.modifiedEndLineNumber})))},[]);y.useEffect(()=>{let W=!1;const U=YR.init();return U.then(H=>{if(W||!u.current)return;p.current=H,wu(H,N.current);const R=H.editor.createDiffEditor(u.current,{automaticLayout:!0,...M});f.current=R,g.current=R.onDidUpdateDiff(()=>B()),_(!0),B()}).catch(H=>{!W&&(H==null?void 0:H.type)!=="cancelation"&&console.error("Monaco initialization: error:",H)}),()=>{var I,L,z,G,X,F;W=!0,(I=g.current)==null||I.dispose(),g.current=null;const H=f.current,R=v.current;try{H==null||H.setModel(null)}catch{}(L=H==null?void 0:H.dispose)==null||L.call(H),(G=(z=R.original)==null?void 0:z.dispose)==null||G.call(z),(F=(X=R.modified)==null?void 0:X.dispose)==null||F.call(X),v.current={original:null,modified:null},f.current=null,p.current=null,_(!1),U.cancel()}},[B]),y.useEffect(()=>{j(0)},[e,r,n]),y.useEffect(()=>{var G,X;const W=f.current,U=p.current;if(!b||!W||!U)return;const H=v.current,R=U.Uri.parse(`${A}.original`),I=U.Uri.parse(`${A}.modified`);(G=U.editor.getModel(R))==null||G.dispose(),(X=U.editor.getModel(I))==null||X.dispose();const L=U.editor.createModel(e,n,R),z=U.editor.createModel(r,n,I);return W.setModel({original:L,modified:z}),v.current={original:L,modified:z},B(),()=>{var F,V,Q,q;try{W.setModel(null)}catch{}(V=(F=H.original)==null?void 0:F.dispose)==null||V.call(F),(q=(Q=H.modified)==null?void 0:Q.dispose)==null||q.call(Q),L.dispose(),z.dispose(),(v.current.original===L||v.current.modified===z)&&(v.current={original:null,modified:null})}},[b,n,A,r,e,B]),y.useEffect(()=>{const W=p.current;W&&wu(W,E)},[E]),y.useEffect(()=>{var W,U;(U=(W=f.current)==null?void 0:W.updateOptions)==null||U.call(W,M)},[M]),y.useEffect(()=>{S.length!==0&&j(W=>Math.min(W,S.length-1))},[S]),y.useEffect(()=>{const W=f.current;if(!W||S.length===0)return;const U=S[C];if(!U)return;const H=W.getModifiedEditor(),R=W.getOriginalEditor();try{U.modifiedStartLineNumber>0||U.modifiedEndLineNumber>0?H.revealLineInCenter(m1(U.modifiedStartLineNumber,U.modifiedEndLineNumber)):R.revealLineInCenter(m1(U.originalStartLineNumber,U.originalEndLineNumber))}catch{}},[C,S]),y.useEffect(()=>{const W=f.current,U=p.current;if(!W||!U||S.length===0)return;const H=S[C];if(!H)return;const R=[];(H.originalStartLineNumber>0||H.originalEndLineNumber>0)&&R.push({editor:W.getOriginalEditor(),range:new U.Range(m1(H.originalStartLineNumber,H.originalEndLineNumber),1,m1(H.originalEndLineNumber,H.originalStartLineNumber),1)}),(H.modifiedStartLineNumber>0||H.modifiedEndLineNumber>0)&&R.push({editor:W.getModifiedEditor(),range:new U.Range(m1(H.modifiedStartLineNumber,H.modifiedEndLineNumber),1,m1(H.modifiedEndLineNumber,H.modifiedStartLineNumber),1)});const I=R.map(({editor:L,range:z})=>L.deltaDecorations([],[{range:z,options:{isWholeLine:!0,className:"diff-change-active"}}]));return()=>{var L;for(let z=0;z<R.length;z++)try{(L=R[z])==null||L.editor.deltaDecorations(I[z]??[],[])}catch{}}},[C,S]);const P=y.useCallback(()=>{j(W=>Math.max(W-1,0))},[]),D=y.useCallback(()=>{j(W=>Math.min(W+1,S.length-1))},[S.length]);return c.jsxs("div",{className:Fe("relative min-h-0",s),children:[c.jsx("div",{className:Fe("h-full min-h-0",o),children:c.jsx("div",{ref:u,className:"h-full min-h-0"})}),!b&&c.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-sm text-muted-foreground",children:"Loading diff..."}),S.length>1&&c.jsxs("div",{className:"absolute right-3 top-1/2 z-10 flex -translate-y-1/2 flex-col gap-1.5",children:[c.jsx(_e,{size:"sm",variant:"secondary",className:"h-9 w-9 rounded-full border bg-background/90 p-0 shadow-lg backdrop-blur-sm hover:bg-background",onClick:P,disabled:C===0,title:"Previous change",children:c.jsx(N9,{className:"h-5 w-5"})}),c.jsxs("span",{className:"text-center font-medium tabular-nums text-2xs text-muted-foreground",children:[C+1,"/",S.length]}),c.jsx(_e,{size:"sm",variant:"secondary",className:"h-9 w-9 rounded-full border bg-background/90 p-0 shadow-lg backdrop-blur-sm hover:bg-background",onClick:D,disabled:C===S.length-1,title:"Next change",children:c.jsx(vl,{className:"h-5 w-5"})})]}),S.length===0&&e===r&&b&&c.jsx("div",{className:"pointer-events-none absolute inset-x-3 bottom-3 rounded-md border bg-background/90 px-3 py-2 text-center text-xs text-muted-foreground shadow-sm",children:l}),c.jsx("style",{children:`
881
881
  .diff-change-active { outline: 1px solid rgba(99, 102, 241, 0.5); outline-offset: -1px; }
882
882
  `})]})}var X9e={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},IT=X9e,Z9e={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},J9e=Z9e;function Q9e({children:e}){return Lt.createElement("div",{style:J9e.container},e)}var eRe=Q9e,tRe=eRe;function rRe({width:e,height:r,isEditorReady:n,loading:i,_ref:s,className:o,wrapperProps:a}){return Lt.createElement("section",{style:{...IT.wrapper,width:e,height:r},...a},!n&&Lt.createElement(tRe,null,i),Lt.createElement("div",{ref:s,style:{...IT.fullWidth,...!n&&IT.hide},className:o}))}var nRe=rRe,HQ=y.memo(nRe);function iRe(e){y.useEffect(e,[])}var WQ=iRe;function sRe(e,r,n=!0){let i=y.useRef(!0);y.useEffect(i.current||!n?()=>{i.current=!1}:e,r)}var jc=sRe;function $_(){}function L1(e,r,n,i){return oRe(e,i)||aRe(e,r,n,i)}function oRe(e,r){return e.editor.getModel(UQ(e,r))}function aRe(e,r,n,i){return e.editor.createModel(r,n,i?UQ(e,i):void 0)}function UQ(e,r){return e.Uri.parse(r)}function lRe({original:e,modified:r,language:n,originalLanguage:i,modifiedLanguage:s,originalModelPath:o,modifiedModelPath:a,keepCurrentOriginalModel:l=!1,keepCurrentModifiedModel:d=!1,theme:u="light",loading:f="Loading...",options:p={},height:g="100%",width:v="100%",className:b,wrapperProps:_={},beforeMount:S=$_,onMount:k=$_}){let[C,j]=y.useState(!1),[E,N]=y.useState(!0),A=y.useRef(null),M=y.useRef(null),B=y.useRef(null),P=y.useRef(k),D=y.useRef(S),W=y.useRef(!1);WQ(()=>{let I=YR.init();return I.then(L=>(M.current=L)&&N(!1)).catch(L=>(L==null?void 0:L.type)!=="cancelation"&&console.error("Monaco initialization: error:",L)),()=>A.current?R():I.cancel()}),jc(()=>{if(A.current&&M.current){let I=A.current.getOriginalEditor(),L=L1(M.current,e||"",i||n||"text",o||"");L!==I.getModel()&&I.setModel(L)}},[o],C),jc(()=>{if(A.current&&M.current){let I=A.current.getModifiedEditor(),L=L1(M.current,r||"",s||n||"text",a||"");L!==I.getModel()&&I.setModel(L)}},[a],C),jc(()=>{let I=A.current.getModifiedEditor();I.getOption(M.current.editor.EditorOption.readOnly)?I.setValue(r||""):r!==I.getValue()&&(I.executeEdits("",[{range:I.getModel().getFullModelRange(),text:r||"",forceMoveMarkers:!0}]),I.pushUndoStop())},[r],C),jc(()=>{var I,L;(L=(I=A.current)==null?void 0:I.getModel())==null||L.original.setValue(e||"")},[e],C),jc(()=>{let{original:I,modified:L}=A.current.getModel();M.current.editor.setModelLanguage(I,i||n||"text"),M.current.editor.setModelLanguage(L,s||n||"text")},[n,i,s],C),jc(()=>{var I;(I=M.current)==null||I.editor.setTheme(u)},[u],C),jc(()=>{var I;(I=A.current)==null||I.updateOptions(p)},[p],C);let U=y.useCallback(()=>{var z;if(!M.current)return;D.current(M.current);let I=L1(M.current,e||"",i||n||"text",o||""),L=L1(M.current,r||"",s||n||"text",a||"");(z=A.current)==null||z.setModel({original:I,modified:L})},[n,r,s,e,i,o,a]),H=y.useCallback(()=>{var I;!W.current&&B.current&&(A.current=M.current.editor.createDiffEditor(B.current,{automaticLayout:!0,...p}),U(),(I=M.current)==null||I.editor.setTheme(u),j(!0),W.current=!0)},[p,u,U]);y.useEffect(()=>{C&&P.current(A.current,M.current)},[C]),y.useEffect(()=>{!E&&!C&&H()},[E,C,H]);function R(){var L,z,G,X;let I=(L=A.current)==null?void 0:L.getModel();l||((z=I==null?void 0:I.original)==null||z.dispose()),d||((G=I==null?void 0:I.modified)==null||G.dispose()),(X=A.current)==null||X.dispose()}return Lt.createElement(HQ,{width:v,height:g,isEditorReady:C,loading:f,_ref:B,className:b,wrapperProps:_})}var cRe=lRe,uRe=y.memo(cRe);function dRe(e){let r=y.useRef();return y.useEffect(()=>{r.current=e},[e]),r.current}var hRe=dRe,w3=new Map;function fRe({defaultValue:e,defaultLanguage:r,defaultPath:n,value:i,language:s,path:o,theme:a="light",line:l,loading:d="Loading...",options:u={},overrideServices:f={},saveViewState:p=!0,keepCurrentModel:g=!1,width:v="100%",height:b="100%",className:_,wrapperProps:S={},beforeMount:k=$_,onMount:C=$_,onChange:j,onValidate:E=$_}){let[N,A]=y.useState(!1),[M,B]=y.useState(!0),P=y.useRef(null),D=y.useRef(null),W=y.useRef(null),U=y.useRef(C),H=y.useRef(k),R=y.useRef(),I=y.useRef(i),L=hRe(o),z=y.useRef(!1),G=y.useRef(!1);WQ(()=>{let V=YR.init();return V.then(Q=>(P.current=Q)&&B(!1)).catch(Q=>(Q==null?void 0:Q.type)!=="cancelation"&&console.error("Monaco initialization: error:",Q)),()=>D.current?F():V.cancel()}),jc(()=>{var Q,q,ee,ne;let V=L1(P.current,e||i||"",r||s||"",o||n||"");V!==((Q=D.current)==null?void 0:Q.getModel())&&(p&&w3.set(L,(q=D.current)==null?void 0:q.saveViewState()),(ee=D.current)==null||ee.setModel(V),p&&((ne=D.current)==null||ne.restoreViewState(w3.get(o))))},[o],N),jc(()=>{var V;(V=D.current)==null||V.updateOptions(u)},[u],N),jc(()=>{!D.current||i===void 0||(D.current.getOption(P.current.editor.EditorOption.readOnly)?D.current.setValue(i):i!==D.current.getValue()&&(G.current=!0,D.current.executeEdits("",[{range:D.current.getModel().getFullModelRange(),text:i,forceMoveMarkers:!0}]),D.current.pushUndoStop(),G.current=!1))},[i],N),jc(()=>{var Q,q;let V=(Q=D.current)==null?void 0:Q.getModel();V&&s&&((q=P.current)==null||q.editor.setModelLanguage(V,s))},[s],N),jc(()=>{var V;l!==void 0&&((V=D.current)==null||V.revealLine(l))},[l],N),jc(()=>{var V;(V=P.current)==null||V.editor.setTheme(a)},[a],N);let X=y.useCallback(()=>{var V;if(!(!W.current||!P.current)&&!z.current){H.current(P.current);let Q=o||n,q=L1(P.current,i||e||"",r||s||"",Q||"");D.current=(V=P.current)==null?void 0:V.editor.create(W.current,{model:q,automaticLayout:!0,...u},f),p&&D.current.restoreViewState(w3.get(Q)),P.current.editor.setTheme(a),l!==void 0&&D.current.revealLine(l),A(!0),z.current=!0}},[e,r,n,i,s,o,u,f,p,a,l]);y.useEffect(()=>{N&&U.current(D.current,P.current)},[N]),y.useEffect(()=>{!M&&!N&&X()},[M,N,X]),I.current=i,y.useEffect(()=>{var V,Q;N&&j&&((V=R.current)==null||V.dispose(),R.current=(Q=D.current)==null?void 0:Q.onDidChangeModelContent(q=>{G.current||j(D.current.getValue(),q)}))},[N,j]),y.useEffect(()=>{if(N){let V=P.current.editor.onDidChangeMarkers(Q=>{var ee;let q=(ee=D.current.getModel())==null?void 0:ee.uri;if(q&&Q.find(ne=>ne.path===q.path)){let ne=P.current.editor.getModelMarkers({resource:q});E==null||E(ne)}});return()=>{V==null||V.dispose()}}return()=>{}},[N,E]);function F(){var V,Q;(V=R.current)==null||V.dispose(),g?p&&w3.set(o,D.current.saveViewState()):(Q=D.current.getModel())==null||Q.dispose(),D.current.dispose()}return Lt.createElement(HQ,{width:v,height:b,isEditorReady:N,loading:d,_ref:W,className:_,wrapperProps:S})}var pRe=fRe,mRe=y.memo(pRe),Bj=mRe;const gRe=Hn();function yRe(){return N0()}function vRe(e=!1){const r={};e&&(r["Content-Type"]="application/json");const n=yRe();return n&&(r.Authorization=`Bearer ${n}`),r}async function Bi(e,r){const n=await fetch(`${gRe}/api/git/${e}`,{method:"POST",headers:vRe(!0),body:JSON.stringify(r)});if(!n.ok){const i=await n.json().catch(()=>({}));throw new Error(i.error||`Git ${e} failed: ${n.statusText}`)}return n.json()}const _o={status(e,r){return Bi("status",{cwd:e,...r?{branch:r}:{}})},listBranches(e){return Bi("branches",{cwd:e})},pull(e){return Bi("pull",{cwd:e})},sync(e){return Bi("sync",{cwd:e})},fetch(e,r=!1){return Bi("fetch",{cwd:e,all:r})},runStackedAction(e,r,n){return Bi("run-stacked-action",{cwd:e,action:r,...n!=null&&n.commitMessage?{commitMessage:n.commitMessage}:{},...n!=null&&n.featureBranch?{featureBranch:!0}:{},...n!=null&&n.baseBranch?{baseBranch:n.baseBranch}:{}})},checkout(e,r){return Bi("checkout",{cwd:e,branch:r})},createBranch(e,r,n){return Bi("create-branch",{cwd:e,branch:r,baseBranch:n})},discard(e,r){return Bi("discard",{cwd:e,paths:r})},stage(e,r){return Bi("stage",{cwd:e,paths:r})},unstage(e,r){return Bi("unstage",{cwd:e,paths:r})},init(e){return Bi("init",{cwd:e})},diff(e){return Bi("diff",{cwd:e})},diffStats(e,r,n){return Bi("diff-stats",{cwd:e,...r?{baseBranch:r}:{},...n?{branch:n}:{}})},fileDiffs(e,r,n){return Bi("file-diffs",{cwd:e,...r?{baseBranch:r}:{},...n?{branch:n}:{}}).then(i=>i.files)},createWorktree(e,r,n,i){return Bi("create-worktree",{cwd:e,baseBranch:r,newBranch:n,...i?{path:i}:{}})},removeWorktree(e,r,n=!1){return Bi("remove-worktree",{cwd:e,path:r,force:n})},ghStatus(e){return Bi("gh-status",{...e?{cwd:e}:{}})},ghAuth(e,r){return Bi("gh-auth",{token:e,...r?{cwd:r}:{}})},forgeStatus(e,r){return Bi("forge-status",{...e?{cwd:e}:{},...r?{remoteUrl:r}:{}})},forgeAuth(e,r,n){return Bi("forge-auth",{token:e,...r?{cwd:r}:{},...n?{remoteUrl:n}:{}})},forgePrChecks(e,r,n){return Bi("forge-pr-checks",{cwd:e,branch:r,...n?{remoteUrl:n}:{}})},identity(e){return Bi("identity",{cwd:e})},setIdentity(e,r,n){return Bi("identity",{cwd:e,name:r,email:n})},prChecks(e,r){return Bi("pr-checks",{cwd:e,branch:r})},generateCommitMessage(e,r,n){return Bi("generate-commit-message",{cwd:e,...r?{provider:r}:{},...n?{model:n}:{}})}};var VQ=Object.defineProperty,Y=(e,r)=>VQ(e,"name",{value:r,configurable:!0}),xRe=(e,r)=>{for(var n in r)VQ(e,n,{get:r[n],enumerable:!0})},Lf={trace:0,debug:1,info:2,warn:3,error:4,fatal:5},jt={trace:Y((...e)=>{},"trace"),debug:Y((...e)=>{},"debug"),info:Y((...e)=>{},"info"),warn:Y((...e)=>{},"warn"),error:Y((...e)=>{},"error"),fatal:Y((...e)=>{},"fatal")},QR=Y(function(e="fatal"){let r=Lf.fatal;typeof e=="string"?e.toLowerCase()in Lf&&(r=Lf[e]):typeof e=="number"&&(r=e),jt.trace=()=>{},jt.debug=()=>{},jt.info=()=>{},jt.warn=()=>{},jt.error=()=>{},jt.fatal=()=>{},r<=Lf.fatal&&(jt.fatal=console.error?console.error.bind(console,nu("FATAL"),"color: orange"):console.log.bind(console,"\x1B[35m",nu("FATAL"))),r<=Lf.error&&(jt.error=console.error?console.error.bind(console,nu("ERROR"),"color: orange"):console.log.bind(console,"\x1B[31m",nu("ERROR"))),r<=Lf.warn&&(jt.warn=console.warn?console.warn.bind(console,nu("WARN"),"color: orange"):console.log.bind(console,"\x1B[33m",nu("WARN"))),r<=Lf.info&&(jt.info=console.info?console.info.bind(console,nu("INFO"),"color: lightblue"):console.log.bind(console,"\x1B[34m",nu("INFO"))),r<=Lf.debug&&(jt.debug=console.debug?console.debug.bind(console,nu("DEBUG"),"color: lightgreen"):console.log.bind(console,"\x1B[32m",nu("DEBUG"))),r<=Lf.trace&&(jt.trace=console.debug?console.debug.bind(console,nu("TRACE"),"color: lightgreen"):console.log.bind(console,"\x1B[32m",nu("TRACE")))},"setLogLevel"),nu=Y(e=>`%c${yEe().format("ss.SSS")} : ${e} : `,"format");const TC={min:{r:0,g:0,b:0,s:0,l:0,a:0},max:{r:255,g:255,b:255,h:360,s:100,l:100,a:1},clamp:{r:e=>e>=255?255:e<0?0:e,g:e=>e>=255?255:e<0?0:e,b:e=>e>=255?255:e<0?0:e,h:e=>e%360,s:e=>e>=100?100:e<0?0:e,l:e=>e>=100?100:e<0?0:e,a:e=>e>=1?1:e<0?0:e},toLinear:e=>{const r=e/255;return e>.03928?Math.pow((r+.055)/1.055,2.4):r/12.92},hue2rgb:(e,r,n)=>(n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(r-e)*6*n:n<1/2?r:n<2/3?e+(r-e)*(2/3-n)*6:e),hsl2rgb:({h:e,s:r,l:n},i)=>{if(!r)return n*2.55;e/=360,r/=100,n/=100;const s=n<.5?n*(1+r):n+r-n*r,o=2*n-s;switch(i){case"r":return TC.hue2rgb(o,s,e+1/3)*255;case"g":return TC.hue2rgb(o,s,e)*255;case"b":return TC.hue2rgb(o,s,e-1/3)*255}},rgb2hsl:({r:e,g:r,b:n},i)=>{e/=255,r/=255,n/=255;const s=Math.max(e,r,n),o=Math.min(e,r,n),a=(s+o)/2;if(i==="l")return a*100;if(s===o)return 0;const l=s-o,d=a>.5?l/(2-s-o):l/(s+o);if(i==="s")return d*100;switch(s){case e:return((r-n)/l+(r<n?6:0))*60;case r:return((n-e)/l+2)*60;case n:return((e-r)/l+4)*60;default:return-1}}},bRe={clamp:(e,r,n)=>r>n?Math.min(r,Math.max(n,e)):Math.min(n,Math.max(r,e)),round:e=>Math.round(e*1e10)/1e10},_Re={dec2hex:e=>{const r=Math.round(e).toString(16);return r.length>1?r:`0${r}`}},nn={channel:TC,lang:bRe,unit:_Re},km={};for(let e=0;e<=255;e++)km[e]=nn.unit.dec2hex(e);const ja={ALL:0,RGB:1,HSL:2};class wRe{constructor(){this.type=ja.ALL}get(){return this.type}set(r){if(this.type&&this.type!==r)throw new Error("Cannot change both RGB and HSL channels at the same time");this.type=r}reset(){this.type=ja.ALL}is(r){return this.type===r}}class SRe{constructor(r,n){this.color=n,this.changed=!1,this.data=r,this.type=new wRe}set(r,n){return this.color=n,this.changed=!1,this.data=r,this.type.type=ja.ALL,this}_ensureHSL(){const r=this.data,{h:n,s:i,l:s}=r;n===void 0&&(r.h=nn.channel.rgb2hsl(r,"h")),i===void 0&&(r.s=nn.channel.rgb2hsl(r,"s")),s===void 0&&(r.l=nn.channel.rgb2hsl(r,"l"))}_ensureRGB(){const r=this.data,{r:n,g:i,b:s}=r;n===void 0&&(r.r=nn.channel.hsl2rgb(r,"r")),i===void 0&&(r.g=nn.channel.hsl2rgb(r,"g")),s===void 0&&(r.b=nn.channel.hsl2rgb(r,"b"))}get r(){const r=this.data,n=r.r;return!this.type.is(ja.HSL)&&n!==void 0?n:(this._ensureHSL(),nn.channel.hsl2rgb(r,"r"))}get g(){const r=this.data,n=r.g;return!this.type.is(ja.HSL)&&n!==void 0?n:(this._ensureHSL(),nn.channel.hsl2rgb(r,"g"))}get b(){const r=this.data,n=r.b;return!this.type.is(ja.HSL)&&n!==void 0?n:(this._ensureHSL(),nn.channel.hsl2rgb(r,"b"))}get h(){const r=this.data,n=r.h;return!this.type.is(ja.RGB)&&n!==void 0?n:(this._ensureRGB(),nn.channel.rgb2hsl(r,"h"))}get s(){const r=this.data,n=r.s;return!this.type.is(ja.RGB)&&n!==void 0?n:(this._ensureRGB(),nn.channel.rgb2hsl(r,"s"))}get l(){const r=this.data,n=r.l;return!this.type.is(ja.RGB)&&n!==void 0?n:(this._ensureRGB(),nn.channel.rgb2hsl(r,"l"))}get a(){return this.data.a}set r(r){this.type.set(ja.RGB),this.changed=!0,this.data.r=r}set g(r){this.type.set(ja.RGB),this.changed=!0,this.data.g=r}set b(r){this.type.set(ja.RGB),this.changed=!0,this.data.b=r}set h(r){this.type.set(ja.HSL),this.changed=!0,this.data.h=r}set s(r){this.type.set(ja.HSL),this.changed=!0,this.data.s=r}set l(r){this.type.set(ja.HSL),this.changed=!0,this.data.l=r}set a(r){this.changed=!0,this.data.a=r}}const zj=new SRe({r:0,g:0,b:0,a:0},"transparent"),q1={re:/^#((?:[a-f0-9]{2}){2,4}|[a-f0-9]{3})$/i,parse:e=>{if(e.charCodeAt(0)!==35)return;const r=e.match(q1.re);if(!r)return;const n=r[1],i=parseInt(n,16),s=n.length,o=s%4===0,a=s>4,l=a?1:17,d=a?8:4,u=o?0:-1,f=a?255:15;return zj.set({r:(i>>d*(u+3)&f)*l,g:(i>>d*(u+2)&f)*l,b:(i>>d*(u+1)&f)*l,a:o?(i&f)*l/255:1},e)},stringify:e=>{const{r,g:n,b:i,a:s}=e;return s<1?`#${km[Math.round(r)]}${km[Math.round(n)]}${km[Math.round(i)]}${km[Math.round(s*255)]}`:`#${km[Math.round(r)]}${km[Math.round(n)]}${km[Math.round(i)]}`}},x0={re:/^hsla?\(\s*?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e-?\d+)?(?:deg|grad|rad|turn)?)\s*?(?:,|\s)\s*?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e-?\d+)?%)\s*?(?:,|\s)\s*?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e-?\d+)?%)(?:\s*?(?:,|\/)\s*?\+?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e-?\d+)?(%)?))?\s*?\)$/i,hueRe:/^(.+?)(deg|grad|rad|turn)$/i,_hue2deg:e=>{const r=e.match(x0.hueRe);if(r){const[,n,i]=r;switch(i){case"grad":return nn.channel.clamp.h(parseFloat(n)*.9);case"rad":return nn.channel.clamp.h(parseFloat(n)*180/Math.PI);case"turn":return nn.channel.clamp.h(parseFloat(n)*360)}}return nn.channel.clamp.h(parseFloat(e))},parse:e=>{const r=e.charCodeAt(0);if(r!==104&&r!==72)return;const n=e.match(x0.re);if(!n)return;const[,i,s,o,a,l]=n;return zj.set({h:x0._hue2deg(i),s:nn.channel.clamp.s(parseFloat(s)),l:nn.channel.clamp.l(parseFloat(o)),a:a?nn.channel.clamp.a(l?parseFloat(a)/100:parseFloat(a)):1},e)},stringify:e=>{const{h:r,s:n,l:i,a:s}=e;return s<1?`hsla(${nn.lang.round(r)}, ${nn.lang.round(n)}%, ${nn.lang.round(i)}%, ${s})`:`hsl(${nn.lang.round(r)}, ${nn.lang.round(n)}%, ${nn.lang.round(i)}%)`}},D_={colors:{aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyanaqua:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",transparent:"#00000000",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"},parse:e=>{e=e.toLowerCase();const r=D_.colors[e];if(r)return q1.parse(r)},stringify:e=>{const r=q1.stringify(e);for(const n in D_.colors)if(D_.colors[n]===r)return n}},c_={re:/^rgba?\(\s*?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e\d+)?(%?))\s*?(?:,|\s)\s*?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e\d+)?(%?))\s*?(?:,|\s)\s*?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e\d+)?(%?))(?:\s*?(?:,|\/)\s*?\+?(-?(?:\d+(?:\.\d+)?|(?:\.\d+))(?:e\d+)?(%?)))?\s*?\)$/i,parse:e=>{const r=e.charCodeAt(0);if(r!==114&&r!==82)return;const n=e.match(c_.re);if(!n)return;const[,i,s,o,a,l,d,u,f]=n;return zj.set({r:nn.channel.clamp.r(s?parseFloat(i)*2.55:parseFloat(i)),g:nn.channel.clamp.g(a?parseFloat(o)*2.55:parseFloat(o)),b:nn.channel.clamp.b(d?parseFloat(l)*2.55:parseFloat(l)),a:u?nn.channel.clamp.a(f?parseFloat(u)/100:parseFloat(u)):1},e)},stringify:e=>{const{r,g:n,b:i,a:s}=e;return s<1?`rgba(${nn.lang.round(r)}, ${nn.lang.round(n)}, ${nn.lang.round(i)}, ${nn.lang.round(s)})`:`rgb(${nn.lang.round(r)}, ${nn.lang.round(n)}, ${nn.lang.round(i)})`}},Wh={format:{keyword:D_,hex:q1,rgb:c_,rgba:c_,hsl:x0,hsla:x0},parse:e=>{if(typeof e!="string")return e;const r=q1.parse(e)||c_.parse(e)||x0.parse(e)||D_.parse(e);if(r)return r;throw new Error(`Unsupported color format: "${e}"`)},stringify:e=>!e.changed&&e.color?e.color:e.type.is(ja.HSL)||e.data.r===void 0?x0.stringify(e):e.a<1||!Number.isInteger(e.r)||!Number.isInteger(e.g)||!Number.isInteger(e.b)?c_.stringify(e):q1.stringify(e)},qQ=(e,r)=>{const n=Wh.parse(e);for(const i in r)n[i]=nn.channel.clamp[i](r[i]);return Wh.stringify(n)},I_=(e,r,n=0,i=1)=>{if(typeof e!="number")return qQ(e,{a:r});const s=zj.set({r:nn.channel.clamp.r(e),g:nn.channel.clamp.g(r),b:nn.channel.clamp.b(n),a:nn.channel.clamp.a(i)});return Wh.stringify(s)},kRe=e=>{const{r,g:n,b:i}=Wh.parse(e),s=.2126*nn.channel.toLinear(r)+.7152*nn.channel.toLinear(n)+.0722*nn.channel.toLinear(i);return nn.lang.round(s)},CRe=e=>kRe(e)>=.5,MS=e=>!CRe(e),GQ=(e,r,n)=>{const i=Wh.parse(e),s=i[r],o=nn.channel.clamp[r](s+n);return s!==o&&(i[r]=o),Wh.stringify(i)},yr=(e,r)=>GQ(e,"l",r),Br=(e,r)=>GQ(e,"l",-r),Ee=(e,r)=>{const n=Wh.parse(e),i={};for(const s in r)r[s]&&(i[s]=n[s]+r[s]);return qQ(e,i)},jRe=(e,r,n=50)=>{const{r:i,g:s,b:o,a}=Wh.parse(e),{r:l,g:d,b:u,a:f}=Wh.parse(r),p=n/100,g=p*2-1,v=a-f,_=((g*v===-1?g:(g+v)/(1+g*v))+1)/2,S=1-_,k=i*_+l*S,C=s*_+d*S,j=o*_+u*S,E=a*p+f*(1-p);return I_(k,C,j,E)},tr=(e,r=100)=>{const n=Wh.parse(e);return n.r=255-n.r,n.g=255-n.g,n.b=255-n.b,jRe(n,e,r)};/*! @license DOMPurify 3.3.2 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.2/LICENSE */const{entries:KQ,setPrototypeOf:XB,isFrozen:NRe,getPrototypeOf:TRe,getOwnPropertyDescriptor:ERe}=Object;let{freeze:gl,seal:Nu,create:EC}=Object,{apply:SA,construct:kA}=typeof Reflect<"u"&&Reflect;gl||(gl=function(r){return r});Nu||(Nu=function(r){return r});SA||(SA=function(r,n){for(var i=arguments.length,s=new Array(i>2?i-2:0),o=2;o<i;o++)s[o-2]=arguments[o];return r.apply(n,s)});kA||(kA=function(r){for(var n=arguments.length,i=new Array(n>1?n-1:0),s=1;s<n;s++)i[s-1]=arguments[s];return new r(...i)});const S3=yl(Array.prototype.forEach),ARe=yl(Array.prototype.lastIndexOf),ZB=yl(Array.prototype.pop),xb=yl(Array.prototype.push),ORe=yl(Array.prototype.splice),AC=yl(String.prototype.toLowerCase),BT=yl(String.prototype.toString),zT=yl(String.prototype.match),bb=yl(String.prototype.replace),RRe=yl(String.prototype.indexOf),MRe=yl(String.prototype.trim),Cc=yl(Object.prototype.hasOwnProperty),il=yl(RegExp.prototype.test),_b=PRe(TypeError);function yl(e){return function(r){r instanceof RegExp&&(r.lastIndex=0);for(var n=arguments.length,i=new Array(n>1?n-1:0),s=1;s<n;s++)i[s-1]=arguments[s];return SA(e,r,i)}}function PRe(e){return function(){for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];return kA(e,n)}}function jn(e,r){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:AC;XB&&XB(e,null);let i=r.length;for(;i--;){let s=r[i];if(typeof s=="string"){const o=n(s);o!==s&&(NRe(r)||(r[i]=o),s=o)}e[s]=!0}return e}function LRe(e){for(let r=0;r<e.length;r++)Cc(e,r)||(e[r]=null);return e}function xh(e){const r=EC(null);for(const[n,i]of KQ(e))Cc(e,n)&&(Array.isArray(i)?r[n]=LRe(i):i&&typeof i=="object"&&i.constructor===Object?r[n]=xh(i):r[n]=i);return r}function wb(e,r){for(;e!==null;){const i=ERe(e,r);if(i){if(i.get)return yl(i.get);if(typeof i.value=="function")return yl(i.value)}e=TRe(e)}function n(){return null}return n}const JB=gl(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),FT=gl(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),HT=gl(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),$Re=gl(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),WT=gl(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),DRe=gl(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),QB=gl(["#text"]),ez=gl(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),UT=gl(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),tz=gl(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),k3=gl(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),IRe=Nu(/\{\{[\w\W]*|[\w\W]*\}\}/gm),BRe=Nu(/<%[\w\W]*|[\w\W]*%>/gm),zRe=Nu(/\$\{[\w\W]*/gm),FRe=Nu(/^data-[\-\w.\u00B7-\uFFFF]+$/),HRe=Nu(/^aria-[\-\w]+$/),YQ=Nu(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),WRe=Nu(/^(?:\w+script|data):/i),URe=Nu(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),XQ=Nu(/^html$/i),VRe=Nu(/^[a-z][.\w]*(-[.\w]+)+$/i);var rz=Object.freeze({__proto__:null,ARIA_ATTR:HRe,ATTR_WHITESPACE:URe,CUSTOM_ELEMENT:VRe,DATA_ATTR:FRe,DOCTYPE_NAME:XQ,ERB_EXPR:BRe,IS_ALLOWED_URI:YQ,IS_SCRIPT_OR_DATA:WRe,MUSTACHE_EXPR:IRe,TMPLIT_EXPR:zRe});const Sb={element:1,text:3,progressingInstruction:7,comment:8,document:9},qRe=function(){return typeof window>"u"?null:window},GRe=function(r,n){if(typeof r!="object"||typeof r.createPolicy!="function")return null;let i=null;const s="data-tt-policy-suffix";n&&n.hasAttribute(s)&&(i=n.getAttribute(s));const o="dompurify"+(i?"#"+i:"");try{return r.createPolicy(o,{createHTML(a){return a},createScriptURL(a){return a}})}catch{return console.warn("TrustedTypes policy "+o+" could not be created."),null}},nz=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function ZQ(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:qRe();const r=Ot=>ZQ(Ot);if(r.version="3.3.2",r.removed=[],!e||!e.document||e.document.nodeType!==Sb.document||!e.Element)return r.isSupported=!1,r;let{document:n}=e;const i=n,s=i.currentScript,{DocumentFragment:o,HTMLTemplateElement:a,Node:l,Element:d,NodeFilter:u,NamedNodeMap:f=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:p,DOMParser:g,trustedTypes:v}=e,b=d.prototype,_=wb(b,"cloneNode"),S=wb(b,"remove"),k=wb(b,"nextSibling"),C=wb(b,"childNodes"),j=wb(b,"parentNode");if(typeof a=="function"){const Ot=n.createElement("template");Ot.content&&Ot.content.ownerDocument&&(n=Ot.content.ownerDocument)}let E,N="";const{implementation:A,createNodeIterator:M,createDocumentFragment:B,getElementsByTagName:P}=n,{importNode:D}=i;let W=nz();r.isSupported=typeof KQ=="function"&&typeof j=="function"&&A&&A.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:U,ERB_EXPR:H,TMPLIT_EXPR:R,DATA_ATTR:I,ARIA_ATTR:L,IS_SCRIPT_OR_DATA:z,ATTR_WHITESPACE:G,CUSTOM_ELEMENT:X}=rz;let{IS_ALLOWED_URI:F}=rz,V=null;const Q=jn({},[...JB,...FT,...HT,...WT,...QB]);let q=null;const ee=jn({},[...ez,...UT,...tz,...k3]);let ne=Object.seal(EC(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),le=null,de=null;const te=Object.seal(EC(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let ie=!0,pe=!0,be=!1,me=!0,Je=!1,ce=!0,Ge=!1,Xe=!1,Le=!1,je=!1,Qe=!1,kt=!1,Vt=!0,Re=!1;const Ze="user-content-";let ft=!0,It=!1,Se={},ke=null;const Et=jn({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let St=null;const Ne=jn({},["audio","video","img","source","image","track"]);let lt=null;const $e=jn({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),it="http://www.w3.org/1998/Math/MathML",Ct="http://www.w3.org/2000/svg",Ie="http://www.w3.org/1999/xhtml";let Ke=Ie,st=!1,gt=null;const Nt=jn({},[it,Ct,Ie],BT);let ct=jn({},["mi","mo","mn","ms","mtext"]),ut=jn({},["annotation-xml"]);const zt=jn({},["title","style","font","a","script"]);let Pt=null;const ot=["application/xhtml+xml","text/html"],Bt="text/html";let Zt=null,et=null;const Qt=n.createElement("form"),Xt=function(ye){return ye instanceof RegExp||ye instanceof Function},sn=function(){let ye=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(et&&et===ye)){if((!ye||typeof ye!="object")&&(ye={}),ye=xh(ye),Pt=ot.indexOf(ye.PARSER_MEDIA_TYPE)===-1?Bt:ye.PARSER_MEDIA_TYPE,Zt=Pt==="application/xhtml+xml"?BT:AC,V=Cc(ye,"ALLOWED_TAGS")?jn({},ye.ALLOWED_TAGS,Zt):Q,q=Cc(ye,"ALLOWED_ATTR")?jn({},ye.ALLOWED_ATTR,Zt):ee,gt=Cc(ye,"ALLOWED_NAMESPACES")?jn({},ye.ALLOWED_NAMESPACES,BT):Nt,lt=Cc(ye,"ADD_URI_SAFE_ATTR")?jn(xh($e),ye.ADD_URI_SAFE_ATTR,Zt):$e,St=Cc(ye,"ADD_DATA_URI_TAGS")?jn(xh(Ne),ye.ADD_DATA_URI_TAGS,Zt):Ne,ke=Cc(ye,"FORBID_CONTENTS")?jn({},ye.FORBID_CONTENTS,Zt):Et,le=Cc(ye,"FORBID_TAGS")?jn({},ye.FORBID_TAGS,Zt):xh({}),de=Cc(ye,"FORBID_ATTR")?jn({},ye.FORBID_ATTR,Zt):xh({}),Se=Cc(ye,"USE_PROFILES")?ye.USE_PROFILES:!1,ie=ye.ALLOW_ARIA_ATTR!==!1,pe=ye.ALLOW_DATA_ATTR!==!1,be=ye.ALLOW_UNKNOWN_PROTOCOLS||!1,me=ye.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Je=ye.SAFE_FOR_TEMPLATES||!1,ce=ye.SAFE_FOR_XML!==!1,Ge=ye.WHOLE_DOCUMENT||!1,je=ye.RETURN_DOM||!1,Qe=ye.RETURN_DOM_FRAGMENT||!1,kt=ye.RETURN_TRUSTED_TYPE||!1,Le=ye.FORCE_BODY||!1,Vt=ye.SANITIZE_DOM!==!1,Re=ye.SANITIZE_NAMED_PROPS||!1,ft=ye.KEEP_CONTENT!==!1,It=ye.IN_PLACE||!1,F=ye.ALLOWED_URI_REGEXP||YQ,Ke=ye.NAMESPACE||Ie,ct=ye.MATHML_TEXT_INTEGRATION_POINTS||ct,ut=ye.HTML_INTEGRATION_POINTS||ut,ne=ye.CUSTOM_ELEMENT_HANDLING||{},ye.CUSTOM_ELEMENT_HANDLING&&Xt(ye.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(ne.tagNameCheck=ye.CUSTOM_ELEMENT_HANDLING.tagNameCheck),ye.CUSTOM_ELEMENT_HANDLING&&Xt(ye.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(ne.attributeNameCheck=ye.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),ye.CUSTOM_ELEMENT_HANDLING&&typeof ye.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(ne.allowCustomizedBuiltInElements=ye.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Je&&(pe=!1),Qe&&(je=!0),Se&&(V=jn({},QB),q=EC(null),Se.html===!0&&(jn(V,JB),jn(q,ez)),Se.svg===!0&&(jn(V,FT),jn(q,UT),jn(q,k3)),Se.svgFilters===!0&&(jn(V,HT),jn(q,UT),jn(q,k3)),Se.mathMl===!0&&(jn(V,WT),jn(q,tz),jn(q,k3))),Cc(ye,"ADD_TAGS")||(te.tagCheck=null),Cc(ye,"ADD_ATTR")||(te.attributeCheck=null),ye.ADD_TAGS&&(typeof ye.ADD_TAGS=="function"?te.tagCheck=ye.ADD_TAGS:(V===Q&&(V=xh(V)),jn(V,ye.ADD_TAGS,Zt))),ye.ADD_ATTR&&(typeof ye.ADD_ATTR=="function"?te.attributeCheck=ye.ADD_ATTR:(q===ee&&(q=xh(q)),jn(q,ye.ADD_ATTR,Zt))),ye.ADD_URI_SAFE_ATTR&&jn(lt,ye.ADD_URI_SAFE_ATTR,Zt),ye.FORBID_CONTENTS&&(ke===Et&&(ke=xh(ke)),jn(ke,ye.FORBID_CONTENTS,Zt)),ye.ADD_FORBID_CONTENTS&&(ke===Et&&(ke=xh(ke)),jn(ke,ye.ADD_FORBID_CONTENTS,Zt)),ft&&(V["#text"]=!0),Ge&&jn(V,["html","head","body"]),V.table&&(jn(V,["tbody"]),delete le.tbody),ye.TRUSTED_TYPES_POLICY){if(typeof ye.TRUSTED_TYPES_POLICY.createHTML!="function")throw _b('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof ye.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw _b('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');E=ye.TRUSTED_TYPES_POLICY,N=E.createHTML("")}else E===void 0&&(E=GRe(v,s)),E!==null&&typeof N=="string"&&(N=E.createHTML(""));gl&&gl(ye),et=ye}},rt=jn({},[...FT,...HT,...$Re]),nt=jn({},[...WT,...DRe]),$t=function(ye){let Tt=j(ye);(!Tt||!Tt.tagName)&&(Tt={namespaceURI:Ke,tagName:"template"});const Wt=AC(ye.tagName),dr=AC(Tt.tagName);return gt[ye.namespaceURI]?ye.namespaceURI===Ct?Tt.namespaceURI===Ie?Wt==="svg":Tt.namespaceURI===it?Wt==="svg"&&(dr==="annotation-xml"||ct[dr]):!!rt[Wt]:ye.namespaceURI===it?Tt.namespaceURI===Ie?Wt==="math":Tt.namespaceURI===Ct?Wt==="math"&&ut[dr]:!!nt[Wt]:ye.namespaceURI===Ie?Tt.namespaceURI===Ct&&!ut[dr]||Tt.namespaceURI===it&&!ct[dr]?!1:!nt[Wt]&&(zt[Wt]||!rt[Wt]):!!(Pt==="application/xhtml+xml"&&gt[ye.namespaceURI]):!1},sr=function(ye){xb(r.removed,{element:ye});try{j(ye).removeChild(ye)}catch{S(ye)}},_t=function(ye,Tt){try{xb(r.removed,{attribute:Tt.getAttributeNode(ye),from:Tt})}catch{xb(r.removed,{attribute:null,from:Tt})}if(Tt.removeAttribute(ye),ye==="is")if(je||Qe)try{sr(Tt)}catch{}else try{Tt.setAttribute(ye,"")}catch{}},nr=function(ye){let Tt=null,Wt=null;if(Le)ye="<remove></remove>"+ye;else{const Be=zT(ye,/^[\r\n\t ]+/);Wt=Be&&Be[0]}Pt==="application/xhtml+xml"&&Ke===Ie&&(ye='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+ye+"</body></html>");const dr=E?E.createHTML(ye):ye;if(Ke===Ie)try{Tt=new g().parseFromString(dr,Pt)}catch{}if(!Tt||!Tt.documentElement){Tt=A.createDocument(Ke,"template",null);try{Tt.documentElement.innerHTML=st?N:dr}catch{}}const Oe=Tt.body||Tt.documentElement;return ye&&Wt&&Oe.insertBefore(n.createTextNode(Wt),Oe.childNodes[0]||null),Ke===Ie?P.call(Tt,Ge?"html":"body")[0]:Ge?Tt.documentElement:Oe},tn=function(ye){return M.call(ye.ownerDocument||ye,ye,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},Gr=function(ye){return ye instanceof p&&(typeof ye.nodeName!="string"||typeof ye.textContent!="string"||typeof ye.removeChild!="function"||!(ye.attributes instanceof f)||typeof ye.removeAttribute!="function"||typeof ye.setAttribute!="function"||typeof ye.namespaceURI!="string"||typeof ye.insertBefore!="function"||typeof ye.hasChildNodes!="function")},At=function(ye){return typeof l=="function"&&ye instanceof l};function pt(Ot,ye,Tt){S3(Ot,Wt=>{Wt.call(r,ye,Tt,et)})}const Ln=function(ye){let Tt=null;if(pt(W.beforeSanitizeElements,ye,null),Gr(ye))return sr(ye),!0;const Wt=Zt(ye.nodeName);if(pt(W.uponSanitizeElement,ye,{tagName:Wt,allowedTags:V}),ce&&ye.hasChildNodes()&&!At(ye.firstElementChild)&&il(/<[/\w!]/g,ye.innerHTML)&&il(/<[/\w!]/g,ye.textContent)||ye.nodeType===Sb.progressingInstruction||ce&&ye.nodeType===Sb.comment&&il(/<[/\w]/g,ye.data))return sr(ye),!0;if(!(te.tagCheck instanceof Function&&te.tagCheck(Wt))&&(!V[Wt]||le[Wt])){if(!le[Wt]&&li(Wt)&&(ne.tagNameCheck instanceof RegExp&&il(ne.tagNameCheck,Wt)||ne.tagNameCheck instanceof Function&&ne.tagNameCheck(Wt)))return!1;if(ft&&!ke[Wt]){const dr=j(ye)||ye.parentNode,Oe=C(ye)||ye.childNodes;if(Oe&&dr){const Be=Oe.length;for(let Ut=Be-1;Ut>=0;--Ut){const pr=_(Oe[Ut],!0);pr.__removalCount=(ye.__removalCount||0)+1,dr.insertBefore(pr,k(ye))}}}return sr(ye),!0}return ye instanceof d&&!$t(ye)||(Wt==="noscript"||Wt==="noembed"||Wt==="noframes")&&il(/<\/no(script|embed|frames)/i,ye.innerHTML)?(sr(ye),!0):(Je&&ye.nodeType===Sb.text&&(Tt=ye.textContent,S3([U,H,R],dr=>{Tt=bb(Tt,dr," ")}),ye.textContent!==Tt&&(xb(r.removed,{element:ye.cloneNode()}),ye.textContent=Tt)),pt(W.afterSanitizeElements,ye,null),!1)},wr=function(ye,Tt,Wt){if(de[Tt]||Vt&&(Tt==="id"||Tt==="name")&&(Wt in n||Wt in Qt))return!1;if(!(pe&&!de[Tt]&&il(I,Tt))){if(!(ie&&il(L,Tt))){if(!(te.attributeCheck instanceof Function&&te.attributeCheck(Tt,ye))){if(!q[Tt]||de[Tt]){if(!(li(ye)&&(ne.tagNameCheck instanceof RegExp&&il(ne.tagNameCheck,ye)||ne.tagNameCheck instanceof Function&&ne.tagNameCheck(ye))&&(ne.attributeNameCheck instanceof RegExp&&il(ne.attributeNameCheck,Tt)||ne.attributeNameCheck instanceof Function&&ne.attributeNameCheck(Tt,ye))||Tt==="is"&&ne.allowCustomizedBuiltInElements&&(ne.tagNameCheck instanceof RegExp&&il(ne.tagNameCheck,Wt)||ne.tagNameCheck instanceof Function&&ne.tagNameCheck(Wt))))return!1}else if(!lt[Tt]){if(!il(F,bb(Wt,G,""))){if(!((Tt==="src"||Tt==="xlink:href"||Tt==="href")&&ye!=="script"&&RRe(Wt,"data:")===0&&St[ye])){if(!(be&&!il(z,bb(Wt,G,"")))){if(Wt)return!1}}}}}}}return!0},li=function(ye){return ye!=="annotation-xml"&&zT(ye,X)},ds=function(ye){pt(W.beforeSanitizeAttributes,ye,null);const{attributes:Tt}=ye;if(!Tt||Gr(ye))return;const Wt={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:q,forceKeepAttr:void 0};let dr=Tt.length;for(;dr--;){const Oe=Tt[dr],{name:Be,namespaceURI:Ut,value:pr}=Oe,rr=Zt(Be),Ur=pr;let dt=Be==="value"?Ur:MRe(Ur);if(Wt.attrName=rr,Wt.attrValue=dt,Wt.keepAttr=!0,Wt.forceKeepAttr=void 0,pt(W.uponSanitizeAttribute,ye,Wt),dt=Wt.attrValue,Re&&(rr==="id"||rr==="name")&&(_t(Be,ye),dt=Ze+dt),ce&&il(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,dt)){_t(Be,ye);continue}if(rr==="attributename"&&zT(dt,"href")){_t(Be,ye);continue}if(Wt.forceKeepAttr)continue;if(!Wt.keepAttr){_t(Be,ye);continue}if(!me&&il(/\/>/i,dt)){_t(Be,ye);continue}Je&&S3([U,H,R],ur=>{dt=bb(dt,ur," ")});const Mr=Zt(ye.nodeName);if(!wr(Mr,rr,dt)){_t(Be,ye);continue}if(E&&typeof v=="object"&&typeof v.getAttributeType=="function"&&!Ut)switch(v.getAttributeType(Mr,rr)){case"TrustedHTML":{dt=E.createHTML(dt);break}case"TrustedScriptURL":{dt=E.createScriptURL(dt);break}}if(dt!==Ur)try{Ut?ye.setAttributeNS(Ut,Be,dt):ye.setAttribute(Be,dt),Gr(ye)?sr(ye):ZB(r.removed)}catch{_t(Be,ye)}}pt(W.afterSanitizeAttributes,ye,null)},Ls=function Ot(ye){let Tt=null;const Wt=tn(ye);for(pt(W.beforeSanitizeShadowDOM,ye,null);Tt=Wt.nextNode();)pt(W.uponSanitizeShadowNode,Tt,null),Ln(Tt),ds(Tt),Tt.content instanceof o&&Ot(Tt.content);pt(W.afterSanitizeShadowDOM,ye,null)};return r.sanitize=function(Ot){let ye=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},Tt=null,Wt=null,dr=null,Oe=null;if(st=!Ot,st&&(Ot="<!-->"),typeof Ot!="string"&&!At(Ot))if(typeof Ot.toString=="function"){if(Ot=Ot.toString(),typeof Ot!="string")throw _b("dirty is not a string, aborting")}else throw _b("toString is not a function");if(!r.isSupported)return Ot;if(Xe||sn(ye),r.removed=[],typeof Ot=="string"&&(It=!1),It){if(Ot.nodeName){const pr=Zt(Ot.nodeName);if(!V[pr]||le[pr])throw _b("root node is forbidden and cannot be sanitized in-place")}}else if(Ot instanceof l)Tt=nr("<!---->"),Wt=Tt.ownerDocument.importNode(Ot,!0),Wt.nodeType===Sb.element&&Wt.nodeName==="BODY"||Wt.nodeName==="HTML"?Tt=Wt:Tt.appendChild(Wt);else{if(!je&&!Je&&!Ge&&Ot.indexOf("<")===-1)return E&&kt?E.createHTML(Ot):Ot;if(Tt=nr(Ot),!Tt)return je?null:kt?N:""}Tt&&Le&&sr(Tt.firstChild);const Be=tn(It?Ot:Tt);for(;dr=Be.nextNode();)Ln(dr),ds(dr),dr.content instanceof o&&Ls(dr.content);if(It)return Ot;if(je){if(Qe)for(Oe=B.call(Tt.ownerDocument);Tt.firstChild;)Oe.appendChild(Tt.firstChild);else Oe=Tt;return(q.shadowroot||q.shadowrootmode)&&(Oe=D.call(i,Oe,!0)),Oe}let Ut=Ge?Tt.outerHTML:Tt.innerHTML;return Ge&&V["!doctype"]&&Tt.ownerDocument&&Tt.ownerDocument.doctype&&Tt.ownerDocument.doctype.name&&il(XQ,Tt.ownerDocument.doctype.name)&&(Ut="<!DOCTYPE "+Tt.ownerDocument.doctype.name+`>
@@ -1121,8 +1121,8 @@ Please report this to https://github.com/markedjs/marked.`,r){let s="<p>An error
1121
1121
  node : x:${e.x} y:${e.y} w:${e.width} h:${e.height}`);const i=e.x,s=e.y,o=Math.abs(i-n.x),a=e.width/2;let l=n.x<r.x?a-o:a+o;const d=e.height/2,u=Math.abs(r.y-n.y),f=Math.abs(r.x-n.x);if(Math.abs(s-r.y)*a>Math.abs(i-r.x)*d){let p=n.y<r.y?r.y-d-s:s-d-r.y;l=f*p/u;const g={x:n.x<r.x?n.x+l:n.x-f+l,y:n.y<r.y?n.y+u-p:n.y-u+p};return l===0&&(g.x=r.x,g.y=r.y),f===0&&(g.x=r.x),u===0&&(g.y=r.y),jt.debug(`abc89 top/bottom calc, Q ${u}, q ${p}, R ${f}, r ${l}`,g),g}else{n.x<r.x?l=r.x-a-i:l=i-a-r.x;let p=u*l/f,g=n.x<r.x?n.x+f-l:n.x-f+l,v=n.y<r.y?n.y+p:n.y-p;return jt.debug(`sides calc abc89, Q ${u}, q ${p}, R ${f}, r ${l}`,{_x:g,_y:v}),l===0&&(g=r.x,v=r.y),f===0&&(g=r.x),u===0&&(v=r.y),{x:g,y:v}}},"intersection"),CF=Y((e,r)=>{jt.warn("abc88 cutPathAtIntersect",e,r);let n=[],i=e[0],s=!1;return e.forEach(o=>{if(jt.info("abc88 checking point",o,r),!hUe(r,o)&&!s){const a=fUe(r,i,o);jt.debug("abc88 inside",o,i,a),jt.debug("abc88 intersection",a,r);let l=!1;n.forEach(d=>{l=l||d.x===a.x&&d.y===a.y}),n.some(d=>d.x===a.x&&d.y===a.y)?jt.warn("abc88 no intersect",a,n):n.push(a),s=!0}else jt.warn("abc88 outside",o,i),i=o,s||n.push(o)}),jt.debug("returning points",n),n},"cutPathAtIntersect");function vse(e){const r=[],n=[];for(let i=1;i<e.length-1;i++){const s=e[i-1],o=e[i],a=e[i+1];(s.x===o.x&&o.y===a.y&&Math.abs(o.x-a.x)>5&&Math.abs(o.y-s.y)>5||s.y===o.y&&o.x===a.x&&Math.abs(o.x-s.x)>5&&Math.abs(o.y-a.y)>5)&&(r.push(o),n.push(i))}return{cornerPoints:r,cornerPointPositions:n}}Y(vse,"extractCornerPoints");var jF=Y(function(e,r,n){const i=r.x-e.x,s=r.y-e.y,o=Math.sqrt(i*i+s*s),a=n/o;return{x:r.x-a*i,y:r.y-a*s}},"findAdjacentPoint"),pUe=Y(function(e){const{cornerPointPositions:r}=vse(e),n=[];for(let i=0;i<e.length;i++)if(r.includes(i)){const s=e[i-1],o=e[i+1],a=e[i],l=jF(s,a,5),d=jF(o,a,5),u=d.x-l.x,f=d.y-l.y;n.push(l);const p=Math.sqrt(2)*2;let g={x:a.x,y:a.y};if(Math.abs(o.x-s.x)>10&&Math.abs(o.y-s.y)>=10){jt.debug("Corner point fixing",Math.abs(o.x-s.x),Math.abs(o.y-s.y));const v=5;a.x===l.x?g={x:u<0?l.x-v+p:l.x+v-p,y:f<0?l.y-p:l.y+p}:g={x:u<0?l.x-p:l.x+p,y:f<0?l.y-v+p:l.y+v-p}}else jt.debug("Corner point skipping fixing",Math.abs(o.x-s.x),Math.abs(o.y-s.y));n.push(g,d)}else n.push(e[i]);return n},"fixCorners"),mUe=Y((e,r,n)=>{const i=e-r-n,s=2,o=2,a=s+o,l=Math.floor(i/a),d=Array(l).fill(`${s} ${o}`).join(" ");return`0 ${r} ${d} ${n}`},"generateDashArray"),gUe=Y(function(e,r,n,i,s,o,a,l=!1){var L;const{handDrawnSeed:d}=ai();let u=r.points,f=!1;const p=s;var g=o;const v=[];for(const z in r.cssCompiledStyles)vne(z)||v.push(r.cssCompiledStyles[z]);jt.debug("UIO intersect check",r.points,g.x,p.x),g.intersect&&p.intersect&&!l&&(u=u.slice(1,r.points.length-1),u.unshift(p.intersect(u[0])),jt.debug("Last point UIO",r.start,"-->",r.end,u[u.length-1],g,g.intersect(u[u.length-1])),u.push(g.intersect(u[u.length-1])));const b=btoa(JSON.stringify(u));r.toCluster&&(jt.info("to cluster abc88",n.get(r.toCluster)),u=CF(r.points,n.get(r.toCluster).node),f=!0),r.fromCluster&&(jt.debug("from cluster abc88",n.get(r.fromCluster),JSON.stringify(u,null,2)),u=CF(u.reverse(),n.get(r.fromCluster).node).reverse(),f=!0);let _=u.filter(z=>!Number.isNaN(z.y));const S=cUe(r.curve);S!=="rounded"&&(_=pUe(_));let k=F_;switch(S){case"linear":k=F_;break;case"basis":k=zA;break;case"cardinal":k=Jee;break;case"bumpX":k=Gee;break;case"bumpY":k=Kee;break;case"catmullRom":k=ete;break;case"monotoneX":k=ote;break;case"monotoneY":k=ate;break;case"natural":k=cte;break;case"step":k=ute;break;case"stepAfter":k=hte;break;case"stepBefore":k=dte;break;case"rounded":k=F_;break;default:k=zA}const{x:C,y:j}=hBe(r),E=HDe().x(C).y(j).curve(k);let N;switch(r.thickness){case"normal":N="edge-thickness-normal";break;case"thick":N="edge-thickness-thick";break;case"invisible":N="edge-thickness-invisible";break;default:N="edge-thickness-normal"}switch(r.pattern){case"solid":N+=" edge-pattern-solid";break;case"dotted":N+=" edge-pattern-dotted";break;case"dashed":N+=" edge-pattern-dashed";break;default:N+=" edge-pattern-solid"}let A,M=S==="rounded"?xse(bse(_,r),5):E(_);const B=Array.isArray(r.style)?r.style:[r.style];let P=B.find(z=>z==null?void 0:z.startsWith("stroke:")),D="";r.animate&&(D="edge-animation-fast"),r.animation&&(D="edge-animation-"+r.animation);let W=!1;if(r.look==="handDrawn"){const z=_r.svg(e);Object.assign([],_);const G=z.path(M,{roughness:.3,seed:d});N+=" transition",A=Hr(G).select("path").attr("id",r.id).attr("class"," "+N+(r.classes?" "+r.classes:"")+(D?" "+D:"")).attr("style",B?B.reduce((F,V)=>F+";"+V,""):"");let X=A.attr("d");A.attr("d",X),e.node().appendChild(A.node())}else{const z=v.join(";"),G=B?B.reduce((ee,ne)=>ee+ne+";",""):"",X=(z?z+";"+G+";":G)+";"+(B?B.reduce((ee,ne)=>ee+";"+ne,""):"");A=e.append("path").attr("d",M).attr("id",r.id).attr("class"," "+N+(r.classes?" "+r.classes:"")+(D?" "+D:"")).attr("style",X),P=(L=X.match(/stroke:([^;]+)/))==null?void 0:L[1],W=r.animate===!0||!!r.animation||z.includes("animation");const F=A.node(),V=typeof F.getTotalLength=="function"?F.getTotalLength():0,Q=Fz[r.arrowTypeStart]||0,q=Fz[r.arrowTypeEnd]||0;if(r.look==="neo"&&!W){const ne=`stroke-dasharray: ${r.pattern==="dotted"||r.pattern==="dashed"?mUe(V,Q,q):`0 ${Q} ${V-Q-q} ${q}`}; stroke-dashoffset: 0;`;A.attr("style",ne+A.attr("style"))}}A.attr("data-edge",!0),A.attr("data-et","edge"),A.attr("data-id",r.id),A.attr("data-points",b),r.showPoints&&_.forEach(z=>{e.append("circle").style("stroke","red").style("fill","red").attr("r",1).attr("cx",z.x).attr("cy",z.y)});let U="";(ai().flowchart.arrowMarkerAbsolute||ai().state.arrowMarkerAbsolute)&&(U=window.location.protocol+"//"+window.location.host+window.location.pathname+window.location.search,U=U.replace(/\(/g,"\\(").replace(/\)/g,"\\)")),jt.info("arrowTypeStart",r.arrowTypeStart),jt.info("arrowTypeEnd",r.arrowTypeEnd),aUe(A,r,U,a,i,P);const H=Math.floor(u.length/2),R=u[H];vd.isLabelCoordinateInPath(R,A.attr("d"))||(f=!0);let I={};return f&&(I.updatedPath=u),I.originalPath=r.points,I},"insertEdge");function xse(e,r){if(e.length<2)return"";let n="";const i=e.length,s=1e-5;for(let o=0;o<i;o++){const a=e[o],l=e[o-1],d=e[o+1];if(o===0)n+=`M${a.x},${a.y}`;else if(o===i-1)n+=`L${a.x},${a.y}`;else{const u=a.x-l.x,f=a.y-l.y,p=d.x-a.x,g=d.y-a.y,v=Math.hypot(u,f),b=Math.hypot(p,g);if(v<s||b<s){n+=`L${a.x},${a.y}`;continue}const _=u/v,S=f/v,k=p/b,C=g/b,j=_*k+S*C,E=Math.max(-1,Math.min(1,j)),N=Math.acos(E);if(N<s||Math.abs(Math.PI-N)<s){n+=`L${a.x},${a.y}`;continue}const A=Math.min(r/Math.sin(N/2),v/2,b/2),M=a.x-_*A,B=a.y-S*A,P=a.x+k*A,D=a.y+C*A;n+=`L${M},${B}`,n+=`Q${a.x},${a.y} ${P},${D}`}}return n}Y(xse,"generateRoundedPath");function p7(e,r){if(!e||!r)return{angle:0,deltaX:0,deltaY:0};const n=r.x-e.x,i=r.y-e.y;return{angle:Math.atan2(i,n),deltaX:n,deltaY:i}}Y(p7,"calculateDeltaAndAngle");function bse(e,r){const n=e.map(s=>({...s}));if(e.length>=2&&Na[r.arrowTypeStart]){const s=Na[r.arrowTypeStart],o=e[0],a=e[1],{angle:l}=p7(o,a),d=s*Math.cos(l),u=s*Math.sin(l);n[0].x=o.x+d,n[0].y=o.y+u}const i=e.length;if(i>=2&&Na[r.arrowTypeEnd]){const s=Na[r.arrowTypeEnd],o=e[i-1],a=e[i-2],{angle:l}=p7(a,o),d=s*Math.cos(l),u=s*Math.sin(l);n[i-1].x=o.x-d,n[i-1].y=o.y-u}return n}Y(bse,"applyMarkerOffsetsToPoints");var yUe=Y((e,r,n,i)=>{r.forEach(s=>{MUe[s](e,n,i)})},"insertMarkers"),vUe=Y((e,r,n)=>{jt.trace("Making markers for ",n),e.append("defs").append("marker").attr("id",n+"_"+r+"-extensionStart").attr("class","marker extension "+r).attr("refX",18).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("path").attr("d","M 1,7 L18,13 V 1 Z"),e.append("defs").append("marker").attr("id",n+"_"+r+"-extensionEnd").attr("class","marker extension "+r).attr("refX",1).attr("refY",7).attr("markerWidth",20).attr("markerHeight",28).attr("orient","auto").append("path").attr("d","M 1,1 V 13 L18,7 Z")},"extension"),xUe=Y((e,r,n)=>{e.append("defs").append("marker").attr("id",n+"_"+r+"-compositionStart").attr("class","marker composition "+r).attr("refX",18).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L1,7 L9,1 Z"),e.append("defs").append("marker").attr("id",n+"_"+r+"-compositionEnd").attr("class","marker composition "+r).attr("refX",1).attr("refY",7).attr("markerWidth",20).attr("markerHeight",28).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L1,7 L9,1 Z")},"composition"),bUe=Y((e,r,n)=>{e.append("defs").append("marker").attr("id",n+"_"+r+"-aggregationStart").attr("class","marker aggregation "+r).attr("refX",18).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L1,7 L9,1 Z"),e.append("defs").append("marker").attr("id",n+"_"+r+"-aggregationEnd").attr("class","marker aggregation "+r).attr("refX",1).attr("refY",7).attr("markerWidth",20).attr("markerHeight",28).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L1,7 L9,1 Z")},"aggregation"),_Ue=Y((e,r,n)=>{e.append("defs").append("marker").attr("id",n+"_"+r+"-dependencyStart").attr("class","marker dependency "+r).attr("refX",6).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("path").attr("d","M 5,7 L9,13 L1,7 L9,1 Z"),e.append("defs").append("marker").attr("id",n+"_"+r+"-dependencyEnd").attr("class","marker dependency "+r).attr("refX",13).attr("refY",7).attr("markerWidth",20).attr("markerHeight",28).attr("orient","auto").append("path").attr("d","M 18,7 L9,13 L14,7 L9,1 Z")},"dependency"),wUe=Y((e,r,n)=>{e.append("defs").append("marker").attr("id",n+"_"+r+"-lollipopStart").attr("class","marker lollipop "+r).attr("refX",13).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("circle").attr("fill","transparent").attr("cx",7).attr("cy",7).attr("r",6),e.append("defs").append("marker").attr("id",n+"_"+r+"-lollipopEnd").attr("class","marker lollipop "+r).attr("refX",1).attr("refY",7).attr("markerWidth",190).attr("markerHeight",240).attr("orient","auto").append("circle").attr("fill","transparent").attr("cx",7).attr("cy",7).attr("r",6)},"lollipop"),SUe=Y((e,r,n)=>{e.append("marker").attr("id",n+"_"+r+"-pointEnd").attr("class","marker "+r).attr("viewBox","0 0 10 10").attr("refX",5).attr("refY",5).attr("markerUnits","userSpaceOnUse").attr("markerWidth",8).attr("markerHeight",8).attr("orient","auto").append("path").attr("d","M 0 0 L 10 5 L 0 10 z").attr("class","arrowMarkerPath").style("stroke-width",1).style("stroke-dasharray","1,0"),e.append("marker").attr("id",n+"_"+r+"-pointStart").attr("class","marker "+r).attr("viewBox","0 0 10 10").attr("refX",4.5).attr("refY",5).attr("markerUnits","userSpaceOnUse").attr("markerWidth",8).attr("markerHeight",8).attr("orient","auto").append("path").attr("d","M 0 5 L 10 10 L 10 0 z").attr("class","arrowMarkerPath").style("stroke-width",1).style("stroke-dasharray","1,0")},"point"),kUe=Y((e,r,n)=>{e.append("marker").attr("id",n+"_"+r+"-circleEnd").attr("class","marker "+r).attr("viewBox","0 0 10 10").attr("refX",11).attr("refY",5).attr("markerUnits","userSpaceOnUse").attr("markerWidth",11).attr("markerHeight",11).attr("orient","auto").append("circle").attr("cx","5").attr("cy","5").attr("r","5").attr("class","arrowMarkerPath").style("stroke-width",1).style("stroke-dasharray","1,0"),e.append("marker").attr("id",n+"_"+r+"-circleStart").attr("class","marker "+r).attr("viewBox","0 0 10 10").attr("refX",-1).attr("refY",5).attr("markerUnits","userSpaceOnUse").attr("markerWidth",11).attr("markerHeight",11).attr("orient","auto").append("circle").attr("cx","5").attr("cy","5").attr("r","5").attr("class","arrowMarkerPath").style("stroke-width",1).style("stroke-dasharray","1,0")},"circle"),CUe=Y((e,r,n)=>{e.append("marker").attr("id",n+"_"+r+"-crossEnd").attr("class","marker cross "+r).attr("viewBox","0 0 11 11").attr("refX",12).attr("refY",5.2).attr("markerUnits","userSpaceOnUse").attr("markerWidth",11).attr("markerHeight",11).attr("orient","auto").append("path").attr("d","M 1,1 l 9,9 M 10,1 l -9,9").attr("class","arrowMarkerPath").style("stroke-width",2).style("stroke-dasharray","1,0"),e.append("marker").attr("id",n+"_"+r+"-crossStart").attr("class","marker cross "+r).attr("viewBox","0 0 11 11").attr("refX",-1).attr("refY",5.2).attr("markerUnits","userSpaceOnUse").attr("markerWidth",11).attr("markerHeight",11).attr("orient","auto").append("path").attr("d","M 1,1 l 9,9 M 10,1 l -9,9").attr("class","arrowMarkerPath").style("stroke-width",2).style("stroke-dasharray","1,0")},"cross"),jUe=Y((e,r,n)=>{e.append("defs").append("marker").attr("id",n+"_"+r+"-barbEnd").attr("refX",19).attr("refY",7).attr("markerWidth",20).attr("markerHeight",14).attr("markerUnits","userSpaceOnUse").attr("orient","auto").append("path").attr("d","M 19,7 L9,13 L14,7 L9,1 Z")},"barb"),NUe=Y((e,r,n)=>{e.append("defs").append("marker").attr("id",n+"_"+r+"-onlyOneStart").attr("class","marker onlyOne "+r).attr("refX",0).attr("refY",9).attr("markerWidth",18).attr("markerHeight",18).attr("orient","auto").append("path").attr("d","M9,0 L9,18 M15,0 L15,18"),e.append("defs").append("marker").attr("id",n+"_"+r+"-onlyOneEnd").attr("class","marker onlyOne "+r).attr("refX",18).attr("refY",9).attr("markerWidth",18).attr("markerHeight",18).attr("orient","auto").append("path").attr("d","M3,0 L3,18 M9,0 L9,18")},"only_one"),TUe=Y((e,r,n)=>{const i=e.append("defs").append("marker").attr("id",n+"_"+r+"-zeroOrOneStart").attr("class","marker zeroOrOne "+r).attr("refX",0).attr("refY",9).attr("markerWidth",30).attr("markerHeight",18).attr("orient","auto");i.append("circle").attr("fill","white").attr("cx",21).attr("cy",9).attr("r",6),i.append("path").attr("d","M9,0 L9,18");const s=e.append("defs").append("marker").attr("id",n+"_"+r+"-zeroOrOneEnd").attr("class","marker zeroOrOne "+r).attr("refX",30).attr("refY",9).attr("markerWidth",30).attr("markerHeight",18).attr("orient","auto");s.append("circle").attr("fill","white").attr("cx",9).attr("cy",9).attr("r",6),s.append("path").attr("d","M21,0 L21,18")},"zero_or_one"),EUe=Y((e,r,n)=>{e.append("defs").append("marker").attr("id",n+"_"+r+"-oneOrMoreStart").attr("class","marker oneOrMore "+r).attr("refX",18).attr("refY",18).attr("markerWidth",45).attr("markerHeight",36).attr("orient","auto").append("path").attr("d","M0,18 Q 18,0 36,18 Q 18,36 0,18 M42,9 L42,27"),e.append("defs").append("marker").attr("id",n+"_"+r+"-oneOrMoreEnd").attr("class","marker oneOrMore "+r).attr("refX",27).attr("refY",18).attr("markerWidth",45).attr("markerHeight",36).attr("orient","auto").append("path").attr("d","M3,9 L3,27 M9,18 Q27,0 45,18 Q27,36 9,18")},"one_or_more"),AUe=Y((e,r,n)=>{const i=e.append("defs").append("marker").attr("id",n+"_"+r+"-zeroOrMoreStart").attr("class","marker zeroOrMore "+r).attr("refX",18).attr("refY",18).attr("markerWidth",57).attr("markerHeight",36).attr("orient","auto");i.append("circle").attr("fill","white").attr("cx",48).attr("cy",18).attr("r",6),i.append("path").attr("d","M0,18 Q18,0 36,18 Q18,36 0,18");const s=e.append("defs").append("marker").attr("id",n+"_"+r+"-zeroOrMoreEnd").attr("class","marker zeroOrMore "+r).attr("refX",39).attr("refY",18).attr("markerWidth",57).attr("markerHeight",36).attr("orient","auto");s.append("circle").attr("fill","white").attr("cx",9).attr("cy",18).attr("r",6),s.append("path").attr("d","M21,18 Q39,0 57,18 Q39,36 21,18")},"zero_or_more"),OUe=Y((e,r,n)=>{e.append("defs").append("marker").attr("id",n+"_"+r+"-requirement_arrowEnd").attr("refX",20).attr("refY",10).attr("markerWidth",20).attr("markerHeight",20).attr("orient","auto").append("path").attr("d",`M0,0
1122
1122
  L20,10
1123
1123
  M20,10
1124
- L0,20`)},"requirement_arrow"),RUe=Y((e,r,n)=>{const i=e.append("defs").append("marker").attr("id",n+"_"+r+"-requirement_containsStart").attr("refX",0).attr("refY",10).attr("markerWidth",20).attr("markerHeight",20).attr("orient","auto").append("g");i.append("circle").attr("cx",10).attr("cy",10).attr("r",9).attr("fill","none"),i.append("line").attr("x1",1).attr("x2",19).attr("y1",10).attr("y2",10),i.append("line").attr("y1",1).attr("y2",19).attr("x1",10).attr("x2",10)},"requirement_contains"),MUe={extension:vUe,composition:xUe,aggregation:bUe,dependency:_Ue,lollipop:wUe,point:SUe,circle:kUe,cross:CUe,barb:jUe,only_one:NUe,zero_or_one:TUe,one_or_more:EUe,zero_or_more:AUe,requirement_arrow:OUe,requirement_contains:RUe},PUe=yUe,LUe={common:LS,getConfig:Ma,insertCluster:FWe,insertEdge:gUe,insertEdgeLabel:uUe,insertMarkers:PUe,insertNode:yse,interpolateToCurve:MM,labelHelper:Zr,log:jt,positionEdgeLabel:dUe},nw={},_se=Y(e=>{for(const r of e)nw[r.name]=r},"registerLayoutLoaders"),$Ue=Y(()=>{_se([{name:"dagre",loader:Y(async()=>await Ve(()=>import("./dagre-KLK3FWXG-CdBUYO5m.js"),__vite__mapDeps([47,48,49,50,51,52]),import.meta.url),"loader")},{name:"cose-bilkent",loader:Y(async()=>await Ve(()=>import("./cose-bilkent-S5V4N54A-PIq9GA_z.js"),__vite__mapDeps([53,54]),import.meta.url),"loader")}])},"registerDefaultLayoutLoaders");$Ue();var F1t=Y(async(e,r)=>{if(!(e.layoutAlgorithm in nw))throw new Error(`Unknown layout algorithm: ${e.layoutAlgorithm}`);const n=nw[e.layoutAlgorithm];return(await n.loader()).render(e,r,LUe,{algorithm:n.algorithm})},"render"),H1t=Y((e="",{fallback:r="dagre"}={})=>{if(e in nw)return e;if(r in nw)return jt.warn(`Layout algorithm ${e} is not registered. Using ${r} as fallback.`),r;throw new Error(`Both layout algorithms ${e} and ${r} are not registered.`)},"getRegisteredLayoutAlgorithm"),DUe=Zre(Object.keys,Object),IUe=Object.prototype,BUe=IUe.hasOwnProperty;function zUe(e){if(!e6(e))return DUe(e);var r=[];for(var n in Object(e))BUe.call(e,n)&&n!="constructor"&&r.push(n);return r}var m7=hy(Fd,"DataView"),g7=hy(Fd,"Promise"),y7=hy(Fd,"Set"),v7=hy(Fd,"WeakMap"),NF="[object Map]",FUe="[object Object]",TF="[object Promise]",EF="[object Set]",AF="[object WeakMap]",OF="[object DataView]",HUe=dy(m7),WUe=dy(tw),UUe=dy(g7),VUe=dy(y7),qUe=dy(v7),d0=uy;(m7&&d0(new m7(new ArrayBuffer(1)))!=OF||tw&&d0(new tw)!=NF||g7&&d0(g7.resolve())!=TF||y7&&d0(new y7)!=EF||v7&&d0(new v7)!=AF)&&(d0=function(e){var r=uy(e),n=r==FUe?e.constructor:void 0,i=n?dy(n):"";if(i)switch(i){case HUe:return OF;case WUe:return NF;case UUe:return TF;case VUe:return EF;case qUe:return AF}return r});var GUe="[object Map]",KUe="[object Set]",YUe=Object.prototype,XUe=YUe.hasOwnProperty;function RF(e){if(e==null)return!0;if(t6(e)&&(e4(e)||typeof e=="string"||typeof e.splice=="function"||OM(e)||RM(e)||Q5(e)))return!e.length;var r=d0(e);if(r==GUe||r==KUe)return!e.size;if(e6(e))return!zUe(e).length;for(var n in e)if(XUe.call(e,n))return!1;return!0}var wse="c4",ZUe=Y(e=>/^\s*C4Context|C4Container|C4Component|C4Dynamic|C4Deployment/.test(e),"detector"),JUe=Y(async()=>{const{diagram:e}=await Ve(async()=>{const{diagram:r}=await import("./c4Diagram-IC4MRINW-Do_Z7oy0.js");return{diagram:r}},__vite__mapDeps([55,56]),import.meta.url);return{id:wse,diagram:e}},"loader"),QUe={id:wse,detector:ZUe,loader:JUe},eVe=QUe,Sse="flowchart",tVe=Y((e,r)=>{var n,i;return((n=r==null?void 0:r.flowchart)==null?void 0:n.defaultRenderer)==="dagre-wrapper"||((i=r==null?void 0:r.flowchart)==null?void 0:i.defaultRenderer)==="elk"?!1:/^\s*graph/.test(e)},"detector"),rVe=Y(async()=>{const{diagram:e}=await Ve(async()=>{const{diagram:r}=await import("./flowDiagram-PKNHOUZH-D8XxQE92.js");return{diagram:r}},__vite__mapDeps([57,58,56,59,60,61]),import.meta.url);return{id:Sse,diagram:e}},"loader"),nVe={id:Sse,detector:tVe,loader:rVe},iVe=nVe,kse="flowchart-v2",sVe=Y((e,r)=>{var n,i,s;return((n=r==null?void 0:r.flowchart)==null?void 0:n.defaultRenderer)==="dagre-d3"?!1:(((i=r==null?void 0:r.flowchart)==null?void 0:i.defaultRenderer)==="elk"&&(r.layout="elk"),/^\s*graph/.test(e)&&((s=r==null?void 0:r.flowchart)==null?void 0:s.defaultRenderer)==="dagre-wrapper"?!0:/^\s*flowchart/.test(e))},"detector"),oVe=Y(async()=>{const{diagram:e}=await Ve(async()=>{const{diagram:r}=await import("./flowDiagram-PKNHOUZH-D8XxQE92.js");return{diagram:r}},__vite__mapDeps([57,58,56,59,60,61]),import.meta.url);return{id:kse,diagram:e}},"loader"),aVe={id:kse,detector:sVe,loader:oVe},lVe=aVe,Cse="er",cVe=Y(e=>/^\s*erDiagram/.test(e),"detector"),uVe=Y(async()=>{const{diagram:e}=await Ve(async()=>{const{diagram:r}=await import("./erDiagram-INFDFZHY-CjDNUYfv.js");return{diagram:r}},__vite__mapDeps([62,59,60,61]),import.meta.url);return{id:Cse,diagram:e}},"loader"),dVe={id:Cse,detector:cVe,loader:uVe},hVe=dVe,jse="gitGraph",fVe=Y(e=>/^\s*gitGraph/.test(e),"detector"),pVe=Y(async()=>{const{diagram:e}=await Ve(async()=>{const{diagram:r}=await import("./gitGraphDiagram-K3NZZRJ6-DbzlY20l.js");return{diagram:r}},__vite__mapDeps([63,64,65,66,49,51,52]),import.meta.url);return{id:jse,diagram:e}},"loader"),mVe={id:jse,detector:fVe,loader:pVe},gVe=mVe,Nse="gantt",yVe=Y(e=>/^\s*gantt/.test(e),"detector"),vVe=Y(async()=>{const{diagram:e}=await Ve(async()=>{const{diagram:r}=await import("./ganttDiagram-A5KZAMGK-BIiwpSX7.js");return{diagram:r}},__vite__mapDeps([67,68,69]),import.meta.url);return{id:Nse,diagram:e}},"loader"),xVe={id:Nse,detector:yVe,loader:vVe},bVe=xVe,Tse="info",_Ve=Y(e=>/^\s*info/.test(e),"detector"),wVe=Y(async()=>{const{diagram:e}=await Ve(async()=>{const{diagram:r}=await import("./infoDiagram-LFFYTUFH-hWFaETvV.js");return{diagram:r}},__vite__mapDeps([70,66,49,51,52]),import.meta.url);return{id:Tse,diagram:e}},"loader"),SVe={id:Tse,detector:_Ve,loader:wVe},Ese="pie",kVe=Y(e=>/^\s*pie/.test(e),"detector"),CVe=Y(async()=>{const{diagram:e}=await Ve(async()=>{const{diagram:r}=await import("./pieDiagram-SKSYHLDU-BIyAMXQI.js");return{diagram:r}},__vite__mapDeps([71,64,66,49,51,52,72]),import.meta.url);return{id:Ese,diagram:e}},"loader"),jVe={id:Ese,detector:kVe,loader:CVe},Ase="quadrantChart",NVe=Y(e=>/^\s*quadrantChart/.test(e),"detector"),TVe=Y(async()=>{const{diagram:e}=await Ve(async()=>{const{diagram:r}=await import("./quadrantDiagram-337W2JSQ-CAbfknvr.js");return{diagram:r}},__vite__mapDeps([73,68,69]),import.meta.url);return{id:Ase,diagram:e}},"loader"),EVe={id:Ase,detector:NVe,loader:TVe},AVe=EVe,Ose="xychart",OVe=Y(e=>/^\s*xychart(-beta)?/.test(e),"detector"),RVe=Y(async()=>{const{diagram:e}=await Ve(async()=>{const{diagram:r}=await import("./xychartDiagram-JWTSCODW-BsyQrQwu.js");return{diagram:r}},__vite__mapDeps([74,68,69]),import.meta.url);return{id:Ose,diagram:e}},"loader"),MVe={id:Ose,detector:OVe,loader:RVe},PVe=MVe,Rse="requirement",LVe=Y(e=>/^\s*requirement(Diagram)?/.test(e),"detector"),$Ve=Y(async()=>{const{diagram:e}=await Ve(async()=>{const{diagram:r}=await import("./requirementDiagram-Z7DCOOCP-B8MganhZ.js");return{diagram:r}},__vite__mapDeps([75,59,60]),import.meta.url);return{id:Rse,diagram:e}},"loader"),DVe={id:Rse,detector:LVe,loader:$Ve},IVe=DVe,Mse="sequence",BVe=Y(e=>/^\s*sequenceDiagram/.test(e),"detector"),zVe=Y(async()=>{const{diagram:e}=await Ve(async()=>{const{diagram:r}=await import("./sequenceDiagram-2WXFIKYE-C8vLzNPh.js");return{diagram:r}},__vite__mapDeps([76,56,65]),import.meta.url);return{id:Mse,diagram:e}},"loader"),FVe={id:Mse,detector:BVe,loader:zVe},HVe=FVe,Pse="class",WVe=Y((e,r)=>{var n;return((n=r==null?void 0:r.class)==null?void 0:n.defaultRenderer)==="dagre-wrapper"?!1:/^\s*classDiagram/.test(e)},"detector"),UVe=Y(async()=>{const{diagram:e}=await Ve(async()=>{const{diagram:r}=await import("./classDiagram-VBA2DB6C-DO7cTnFq.js");return{diagram:r}},__vite__mapDeps([77,78,58,56,59,60]),import.meta.url);return{id:Pse,diagram:e}},"loader"),VVe={id:Pse,detector:WVe,loader:UVe},qVe=VVe,Lse="classDiagram",GVe=Y((e,r)=>{var n;return/^\s*classDiagram/.test(e)&&((n=r==null?void 0:r.class)==null?void 0:n.defaultRenderer)==="dagre-wrapper"?!0:/^\s*classDiagram-v2/.test(e)},"detector"),KVe=Y(async()=>{const{diagram:e}=await Ve(async()=>{const{diagram:r}=await import("./classDiagram-v2-RAHNMMFH-DO7cTnFq.js");return{diagram:r}},__vite__mapDeps([79,78,58,56,59,60]),import.meta.url);return{id:Lse,diagram:e}},"loader"),YVe={id:Lse,detector:GVe,loader:KVe},XVe=YVe,$se="state",ZVe=Y((e,r)=>{var n;return((n=r==null?void 0:r.state)==null?void 0:n.defaultRenderer)==="dagre-wrapper"?!1:/^\s*stateDiagram/.test(e)},"detector"),JVe=Y(async()=>{const{diagram:e}=await Ve(async()=>{const{diagram:r}=await import("./stateDiagram-RAJIS63D-CiiDRSPH.js");return{diagram:r}},__vite__mapDeps([80,81,59,60,48,49,50,51]),import.meta.url);return{id:$se,diagram:e}},"loader"),QVe={id:$se,detector:ZVe,loader:JVe},eqe=QVe,Dse="stateDiagram",tqe=Y((e,r)=>{var n;return!!(/^\s*stateDiagram-v2/.test(e)||/^\s*stateDiagram/.test(e)&&((n=r==null?void 0:r.state)==null?void 0:n.defaultRenderer)==="dagre-wrapper")},"detector"),rqe=Y(async()=>{const{diagram:e}=await Ve(async()=>{const{diagram:r}=await import("./stateDiagram-v2-FVOUBMTO-COllwQIm.js");return{diagram:r}},__vite__mapDeps([82,81,59,60]),import.meta.url);return{id:Dse,diagram:e}},"loader"),nqe={id:Dse,detector:tqe,loader:rqe},iqe=nqe,Ise="journey",sqe=Y(e=>/^\s*journey/.test(e),"detector"),oqe=Y(async()=>{const{diagram:e}=await Ve(async()=>{const{diagram:r}=await import("./journeyDiagram-4ABVD52K-CiBVxxlY.js");return{diagram:r}},__vite__mapDeps([83,58,56,72]),import.meta.url);return{id:Ise,diagram:e}},"loader"),aqe={id:Ise,detector:sqe,loader:oqe},lqe=aqe,cqe=Y((e,r,n)=>{jt.debug(`rendering svg for syntax error
1125
- `);const i=iIe(r),s=i.append("g");i.attr("viewBox","0 0 2412 512"),fee(i,100,512,!0),s.append("path").attr("class","error-icon").attr("d","m411.313,123.313c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32-9.375,9.375-20.688-20.688c-12.484-12.5-32.766-12.5-45.25,0l-16,16c-1.261,1.261-2.304,2.648-3.31,4.051-21.739-8.561-45.324-13.426-70.065-13.426-105.867,0-192,86.133-192,192s86.133,192 192,192 192-86.133 192-192c0-24.741-4.864-48.327-13.426-70.065 1.402-1.007 2.79-2.049 4.051-3.31l16-16c12.5-12.492 12.5-32.758 0-45.25l-20.688-20.688 9.375-9.375 32.001-31.999zm-219.313,100.687c-52.938,0-96,43.063-96,96 0,8.836-7.164,16-16,16s-16-7.164-16-16c0-70.578 57.422-128 128-128 8.836,0 16,7.164 16,16s-7.164,16-16,16z"),s.append("path").attr("class","error-icon").attr("d","m459.02,148.98c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l16,16c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16.001-16z"),s.append("path").attr("class","error-icon").attr("d","m340.395,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16-16c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l15.999,16z"),s.append("path").attr("class","error-icon").attr("d","m400,64c8.844,0 16-7.164 16-16v-32c0-8.836-7.156-16-16-16-8.844,0-16,7.164-16,16v32c0,8.836 7.156,16 16,16z"),s.append("path").attr("class","error-icon").attr("d","m496,96.586h-32c-8.844,0-16,7.164-16,16 0,8.836 7.156,16 16,16h32c8.844,0 16-7.164 16-16 0-8.836-7.156-16-16-16z"),s.append("path").attr("class","error-icon").attr("d","m436.98,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688l32-32c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32c-6.251,6.25-6.251,16.375-0.001,22.625z"),s.append("text").attr("class","error-text").attr("x",1440).attr("y",250).attr("font-size","150px").style("text-anchor","middle").text("Syntax error in text"),s.append("text").attr("class","error-text").attr("x",1250).attr("y",400).attr("font-size","100px").style("text-anchor","middle").text(`mermaid version ${n}`)},"draw"),Bse={draw:cqe},uqe=Bse,dqe={db:{},renderer:Bse,parser:{parse:Y(()=>{},"parse")}},hqe=dqe,zse="flowchart-elk",fqe=Y((e,r={})=>{var n;return/^\s*flowchart-elk/.test(e)||/^\s*(flowchart|graph)/.test(e)&&((n=r==null?void 0:r.flowchart)==null?void 0:n.defaultRenderer)==="elk"?(r.layout="elk",!0):!1},"detector"),pqe=Y(async()=>{const{diagram:e}=await Ve(async()=>{const{diagram:r}=await import("./flowDiagram-PKNHOUZH-D8XxQE92.js");return{diagram:r}},__vite__mapDeps([57,58,56,59,60,61]),import.meta.url);return{id:zse,diagram:e}},"loader"),mqe={id:zse,detector:fqe,loader:pqe},gqe=mqe,Fse="timeline",yqe=Y(e=>/^\s*timeline/.test(e),"detector"),vqe=Y(async()=>{const{diagram:e}=await Ve(async()=>{const{diagram:r}=await import("./timeline-definition-YZTLITO2-dy3ZTjT7.js");return{diagram:r}},__vite__mapDeps([84,72]),import.meta.url);return{id:Fse,diagram:e}},"loader"),xqe={id:Fse,detector:yqe,loader:vqe},bqe=xqe,Hse="mindmap",_qe=Y(e=>/^\s*mindmap/.test(e),"detector"),wqe=Y(async()=>{const{diagram:e}=await Ve(async()=>{const{diagram:r}=await import("./mindmap-definition-YRQLILUH-D8tU-mIN.js");return{diagram:r}},__vite__mapDeps([85,59,60]),import.meta.url);return{id:Hse,diagram:e}},"loader"),Sqe={id:Hse,detector:_qe,loader:wqe},kqe=Sqe,Wse="kanban",Cqe=Y(e=>/^\s*kanban/.test(e),"detector"),jqe=Y(async()=>{const{diagram:e}=await Ve(async()=>{const{diagram:r}=await import("./kanban-definition-K7BYSVSG-C1rgcn_F.js");return{diagram:r}},__vite__mapDeps([86,58]),import.meta.url);return{id:Wse,diagram:e}},"loader"),Nqe={id:Wse,detector:Cqe,loader:jqe},Tqe=Nqe,Use="sankey",Eqe=Y(e=>/^\s*sankey(-beta)?/.test(e),"detector"),Aqe=Y(async()=>{const{diagram:e}=await Ve(async()=>{const{diagram:r}=await import("./sankeyDiagram-WA2Y5GQK-DalR8qS4.js");return{diagram:r}},[],import.meta.url);return{id:Use,diagram:e}},"loader"),Oqe={id:Use,detector:Eqe,loader:Aqe},Rqe=Oqe,Vse="packet",Mqe=Y(e=>/^\s*packet(-beta)?/.test(e),"detector"),Pqe=Y(async()=>{const{diagram:e}=await Ve(async()=>{const{diagram:r}=await import("./diagram-P4PSJMXO-Coqal_sp.js");return{diagram:r}},__vite__mapDeps([87,64,66,49,51,52]),import.meta.url);return{id:Vse,diagram:e}},"loader"),Lqe={id:Vse,detector:Mqe,loader:Pqe},qse="radar",$qe=Y(e=>/^\s*radar-beta/.test(e),"detector"),Dqe=Y(async()=>{const{diagram:e}=await Ve(async()=>{const{diagram:r}=await import("./diagram-IFDJBPK2-C2ncQSCW.js");return{diagram:r}},__vite__mapDeps([88,64,66,49,51,52]),import.meta.url);return{id:qse,diagram:e}},"loader"),Iqe={id:qse,detector:$qe,loader:Dqe},Gse="block",Bqe=Y(e=>/^\s*block(-beta)?/.test(e),"detector"),zqe=Y(async()=>{const{diagram:e}=await Ve(async()=>{const{diagram:r}=await import("./blockDiagram-WCTKOSBZ-CXFQaxle.js");return{diagram:r}},__vite__mapDeps([89,58,52,49,48,61]),import.meta.url);return{id:Gse,diagram:e}},"loader"),Fqe={id:Gse,detector:Bqe,loader:zqe},Hqe=Fqe,Kse="architecture",Wqe=Y(e=>/^\s*architecture/.test(e),"detector"),Uqe=Y(async()=>{const{diagram:e}=await Ve(async()=>{const{diagram:r}=await import("./architectureDiagram-2XIMDMQ5-DPyr9jtt.js");return{diagram:r}},__vite__mapDeps([90,64,66,49,51,52,54]),import.meta.url);return{id:Kse,diagram:e}},"loader"),Vqe={id:Kse,detector:Wqe,loader:Uqe},qqe=Vqe,Yse="ishikawa",Gqe=Y(e=>/^\s*ishikawa(-beta)?\b/i.test(e),"detector"),Kqe=Y(async()=>{const{diagram:e}=await Ve(async()=>{const{diagram:r}=await import("./ishikawaDiagram-PHBUUO56-BHc8OreU.js");return{diagram:r}},[],import.meta.url);return{id:Yse,diagram:e}},"loader"),Yqe={id:Yse,detector:Gqe,loader:Kqe},Xse="venn",Xqe=Y(e=>/^\s*venn-beta/.test(e),"detector"),Zqe=Y(async()=>{const{diagram:e}=await Ve(async()=>{const{diagram:r}=await import("./vennDiagram-LZ73GAT5-BWieJ8xA.js");return{diagram:r}},[],import.meta.url);return{id:Xse,diagram:e}},"loader"),Jqe={id:Xse,detector:Xqe,loader:Zqe},Qqe=Jqe,Zse="treemap",eGe=Y(e=>/^\s*treemap/.test(e),"detector"),tGe=Y(async()=>{const{diagram:e}=await Ve(async()=>{const{diagram:r}=await import("./diagram-E7M64L7V-BO8oSjk1.js");return{diagram:r}},__vite__mapDeps([91,60,64,66,49,51,52,69]),import.meta.url);return{id:Zse,diagram:e}},"loader"),rGe={id:Zse,detector:eGe,loader:tGe},MF=!1,c6=Y(()=>{MF||(MF=!0,L5("error",hqe,e=>e.toLowerCase().trim()==="error"),L5("---",{db:{clear:Y(()=>{},"clear")},styles:{},renderer:{draw:Y(()=>{},"draw")},parser:{parse:Y(()=>{throw new Error("Diagrams beginning with --- are not valid. If you were trying to use a YAML front-matter, please ensure that you've correctly opened and closed the YAML front-matter with un-indented `---` blocks")},"parse")},init:Y(()=>null,"init")},e=>e.toLowerCase().trimStart().startsWith("---")),CA(gqe,kqe,qqe),CA(eVe,Tqe,XVe,qVe,hVe,bVe,SVe,jVe,IVe,HVe,lVe,iVe,bqe,gVe,iqe,eqe,lqe,AVe,Rqe,Lqe,PVe,Hqe,Iqe,Yqe,rGe,Qqe))},"addDiagrams"),nGe=Y(async()=>{jt.debug("Loading registered diagrams");const r=(await Promise.allSettled(Object.entries(z0).map(async([n,{detector:i,loader:s}])=>{if(s)try{EA(n)}catch{try{const{diagram:o,id:a}=await s();L5(a,o,i)}catch(o){throw jt.error(`Failed to load external diagram with key ${n}. Removing from detectors.`),delete z0[n],o}}}))).filter(n=>n.status==="rejected");if(r.length>0){jt.error(`Failed to load ${r.length} external diagrams`);for(const n of r)jt.error(n);throw new Error(`Failed to load ${r.length} external diagrams`)}},"loadRegisteredDiagrams"),iGe="graphics-document document";function Jse(e,r){e.attr("role",iGe),r!==""&&e.attr("aria-roledescription",r)}Y(Jse,"setA11yDiagramInfo");function Qse(e,r,n,i){if(e.insert!==void 0){if(n){const s=`chart-desc-${i}`;e.attr("aria-describedby",s),e.insert("desc",":first-child").attr("id",s).text(n)}if(r){const s=`chart-title-${i}`;e.attr("aria-labelledby",s),e.insert("title",":first-child").attr("id",s).text(r)}}}Y(Qse,"addSVGa11yTitleDescription");var R0,x7=(R0=class{constructor(r,n,i,s,o){this.type=r,this.text=n,this.db=i,this.parser=s,this.renderer=o}static async fromText(r,n={}){var u,f;const i=Ma(),s=eM(r,i);r=aHe(r)+`
1124
+ L0,20`)},"requirement_arrow"),RUe=Y((e,r,n)=>{const i=e.append("defs").append("marker").attr("id",n+"_"+r+"-requirement_containsStart").attr("refX",0).attr("refY",10).attr("markerWidth",20).attr("markerHeight",20).attr("orient","auto").append("g");i.append("circle").attr("cx",10).attr("cy",10).attr("r",9).attr("fill","none"),i.append("line").attr("x1",1).attr("x2",19).attr("y1",10).attr("y2",10),i.append("line").attr("y1",1).attr("y2",19).attr("x1",10).attr("x2",10)},"requirement_contains"),MUe={extension:vUe,composition:xUe,aggregation:bUe,dependency:_Ue,lollipop:wUe,point:SUe,circle:kUe,cross:CUe,barb:jUe,only_one:NUe,zero_or_one:TUe,one_or_more:EUe,zero_or_more:AUe,requirement_arrow:OUe,requirement_contains:RUe},PUe=yUe,LUe={common:LS,getConfig:Ma,insertCluster:FWe,insertEdge:gUe,insertEdgeLabel:uUe,insertMarkers:PUe,insertNode:yse,interpolateToCurve:MM,labelHelper:Zr,log:jt,positionEdgeLabel:dUe},nw={},_se=Y(e=>{for(const r of e)nw[r.name]=r},"registerLayoutLoaders"),$Ue=Y(()=>{_se([{name:"dagre",loader:Y(async()=>await Ve(()=>import("./dagre-KLK3FWXG-5ctXXPAz.js"),__vite__mapDeps([47,48,49,50,51,52]),import.meta.url),"loader")},{name:"cose-bilkent",loader:Y(async()=>await Ve(()=>import("./cose-bilkent-S5V4N54A-DeLKhCEG.js"),__vite__mapDeps([53,54]),import.meta.url),"loader")}])},"registerDefaultLayoutLoaders");$Ue();var F1t=Y(async(e,r)=>{if(!(e.layoutAlgorithm in nw))throw new Error(`Unknown layout algorithm: ${e.layoutAlgorithm}`);const n=nw[e.layoutAlgorithm];return(await n.loader()).render(e,r,LUe,{algorithm:n.algorithm})},"render"),H1t=Y((e="",{fallback:r="dagre"}={})=>{if(e in nw)return e;if(r in nw)return jt.warn(`Layout algorithm ${e} is not registered. Using ${r} as fallback.`),r;throw new Error(`Both layout algorithms ${e} and ${r} are not registered.`)},"getRegisteredLayoutAlgorithm"),DUe=Zre(Object.keys,Object),IUe=Object.prototype,BUe=IUe.hasOwnProperty;function zUe(e){if(!e6(e))return DUe(e);var r=[];for(var n in Object(e))BUe.call(e,n)&&n!="constructor"&&r.push(n);return r}var m7=hy(Fd,"DataView"),g7=hy(Fd,"Promise"),y7=hy(Fd,"Set"),v7=hy(Fd,"WeakMap"),NF="[object Map]",FUe="[object Object]",TF="[object Promise]",EF="[object Set]",AF="[object WeakMap]",OF="[object DataView]",HUe=dy(m7),WUe=dy(tw),UUe=dy(g7),VUe=dy(y7),qUe=dy(v7),d0=uy;(m7&&d0(new m7(new ArrayBuffer(1)))!=OF||tw&&d0(new tw)!=NF||g7&&d0(g7.resolve())!=TF||y7&&d0(new y7)!=EF||v7&&d0(new v7)!=AF)&&(d0=function(e){var r=uy(e),n=r==FUe?e.constructor:void 0,i=n?dy(n):"";if(i)switch(i){case HUe:return OF;case WUe:return NF;case UUe:return TF;case VUe:return EF;case qUe:return AF}return r});var GUe="[object Map]",KUe="[object Set]",YUe=Object.prototype,XUe=YUe.hasOwnProperty;function RF(e){if(e==null)return!0;if(t6(e)&&(e4(e)||typeof e=="string"||typeof e.splice=="function"||OM(e)||RM(e)||Q5(e)))return!e.length;var r=d0(e);if(r==GUe||r==KUe)return!e.size;if(e6(e))return!zUe(e).length;for(var n in e)if(XUe.call(e,n))return!1;return!0}var wse="c4",ZUe=Y(e=>/^\s*C4Context|C4Container|C4Component|C4Dynamic|C4Deployment/.test(e),"detector"),JUe=Y(async()=>{const{diagram:e}=await Ve(async()=>{const{diagram:r}=await import("./c4Diagram-IC4MRINW-Biyq01Qv.js");return{diagram:r}},__vite__mapDeps([55,56]),import.meta.url);return{id:wse,diagram:e}},"loader"),QUe={id:wse,detector:ZUe,loader:JUe},eVe=QUe,Sse="flowchart",tVe=Y((e,r)=>{var n,i;return((n=r==null?void 0:r.flowchart)==null?void 0:n.defaultRenderer)==="dagre-wrapper"||((i=r==null?void 0:r.flowchart)==null?void 0:i.defaultRenderer)==="elk"?!1:/^\s*graph/.test(e)},"detector"),rVe=Y(async()=>{const{diagram:e}=await Ve(async()=>{const{diagram:r}=await import("./flowDiagram-PKNHOUZH-C2Hxrf84.js");return{diagram:r}},__vite__mapDeps([57,58,56,59,60,61]),import.meta.url);return{id:Sse,diagram:e}},"loader"),nVe={id:Sse,detector:tVe,loader:rVe},iVe=nVe,kse="flowchart-v2",sVe=Y((e,r)=>{var n,i,s;return((n=r==null?void 0:r.flowchart)==null?void 0:n.defaultRenderer)==="dagre-d3"?!1:(((i=r==null?void 0:r.flowchart)==null?void 0:i.defaultRenderer)==="elk"&&(r.layout="elk"),/^\s*graph/.test(e)&&((s=r==null?void 0:r.flowchart)==null?void 0:s.defaultRenderer)==="dagre-wrapper"?!0:/^\s*flowchart/.test(e))},"detector"),oVe=Y(async()=>{const{diagram:e}=await Ve(async()=>{const{diagram:r}=await import("./flowDiagram-PKNHOUZH-C2Hxrf84.js");return{diagram:r}},__vite__mapDeps([57,58,56,59,60,61]),import.meta.url);return{id:kse,diagram:e}},"loader"),aVe={id:kse,detector:sVe,loader:oVe},lVe=aVe,Cse="er",cVe=Y(e=>/^\s*erDiagram/.test(e),"detector"),uVe=Y(async()=>{const{diagram:e}=await Ve(async()=>{const{diagram:r}=await import("./erDiagram-INFDFZHY-XEdLHc6o.js");return{diagram:r}},__vite__mapDeps([62,59,60,61]),import.meta.url);return{id:Cse,diagram:e}},"loader"),dVe={id:Cse,detector:cVe,loader:uVe},hVe=dVe,jse="gitGraph",fVe=Y(e=>/^\s*gitGraph/.test(e),"detector"),pVe=Y(async()=>{const{diagram:e}=await Ve(async()=>{const{diagram:r}=await import("./gitGraphDiagram-K3NZZRJ6-BHAvoWtT.js");return{diagram:r}},__vite__mapDeps([63,64,65,66,49,51,52]),import.meta.url);return{id:jse,diagram:e}},"loader"),mVe={id:jse,detector:fVe,loader:pVe},gVe=mVe,Nse="gantt",yVe=Y(e=>/^\s*gantt/.test(e),"detector"),vVe=Y(async()=>{const{diagram:e}=await Ve(async()=>{const{diagram:r}=await import("./ganttDiagram-A5KZAMGK-CcjivEhc.js");return{diagram:r}},__vite__mapDeps([67,68,69]),import.meta.url);return{id:Nse,diagram:e}},"loader"),xVe={id:Nse,detector:yVe,loader:vVe},bVe=xVe,Tse="info",_Ve=Y(e=>/^\s*info/.test(e),"detector"),wVe=Y(async()=>{const{diagram:e}=await Ve(async()=>{const{diagram:r}=await import("./infoDiagram-LFFYTUFH-wgpuajZI.js");return{diagram:r}},__vite__mapDeps([70,66,49,51,52]),import.meta.url);return{id:Tse,diagram:e}},"loader"),SVe={id:Tse,detector:_Ve,loader:wVe},Ese="pie",kVe=Y(e=>/^\s*pie/.test(e),"detector"),CVe=Y(async()=>{const{diagram:e}=await Ve(async()=>{const{diagram:r}=await import("./pieDiagram-SKSYHLDU-B7GJE-Uz.js");return{diagram:r}},__vite__mapDeps([71,64,66,49,51,52,72]),import.meta.url);return{id:Ese,diagram:e}},"loader"),jVe={id:Ese,detector:kVe,loader:CVe},Ase="quadrantChart",NVe=Y(e=>/^\s*quadrantChart/.test(e),"detector"),TVe=Y(async()=>{const{diagram:e}=await Ve(async()=>{const{diagram:r}=await import("./quadrantDiagram-337W2JSQ-CLs2IB5o.js");return{diagram:r}},__vite__mapDeps([73,68,69]),import.meta.url);return{id:Ase,diagram:e}},"loader"),EVe={id:Ase,detector:NVe,loader:TVe},AVe=EVe,Ose="xychart",OVe=Y(e=>/^\s*xychart(-beta)?/.test(e),"detector"),RVe=Y(async()=>{const{diagram:e}=await Ve(async()=>{const{diagram:r}=await import("./xychartDiagram-JWTSCODW-BsU88Xtd.js");return{diagram:r}},__vite__mapDeps([74,68,69]),import.meta.url);return{id:Ose,diagram:e}},"loader"),MVe={id:Ose,detector:OVe,loader:RVe},PVe=MVe,Rse="requirement",LVe=Y(e=>/^\s*requirement(Diagram)?/.test(e),"detector"),$Ve=Y(async()=>{const{diagram:e}=await Ve(async()=>{const{diagram:r}=await import("./requirementDiagram-Z7DCOOCP-rtQqZo8t.js");return{diagram:r}},__vite__mapDeps([75,59,60]),import.meta.url);return{id:Rse,diagram:e}},"loader"),DVe={id:Rse,detector:LVe,loader:$Ve},IVe=DVe,Mse="sequence",BVe=Y(e=>/^\s*sequenceDiagram/.test(e),"detector"),zVe=Y(async()=>{const{diagram:e}=await Ve(async()=>{const{diagram:r}=await import("./sequenceDiagram-2WXFIKYE-BxtY9s9j.js");return{diagram:r}},__vite__mapDeps([76,56,65]),import.meta.url);return{id:Mse,diagram:e}},"loader"),FVe={id:Mse,detector:BVe,loader:zVe},HVe=FVe,Pse="class",WVe=Y((e,r)=>{var n;return((n=r==null?void 0:r.class)==null?void 0:n.defaultRenderer)==="dagre-wrapper"?!1:/^\s*classDiagram/.test(e)},"detector"),UVe=Y(async()=>{const{diagram:e}=await Ve(async()=>{const{diagram:r}=await import("./classDiagram-VBA2DB6C-Dh3VdYAd.js");return{diagram:r}},__vite__mapDeps([77,78,58,56,59,60]),import.meta.url);return{id:Pse,diagram:e}},"loader"),VVe={id:Pse,detector:WVe,loader:UVe},qVe=VVe,Lse="classDiagram",GVe=Y((e,r)=>{var n;return/^\s*classDiagram/.test(e)&&((n=r==null?void 0:r.class)==null?void 0:n.defaultRenderer)==="dagre-wrapper"?!0:/^\s*classDiagram-v2/.test(e)},"detector"),KVe=Y(async()=>{const{diagram:e}=await Ve(async()=>{const{diagram:r}=await import("./classDiagram-v2-RAHNMMFH-Dh3VdYAd.js");return{diagram:r}},__vite__mapDeps([79,78,58,56,59,60]),import.meta.url);return{id:Lse,diagram:e}},"loader"),YVe={id:Lse,detector:GVe,loader:KVe},XVe=YVe,$se="state",ZVe=Y((e,r)=>{var n;return((n=r==null?void 0:r.state)==null?void 0:n.defaultRenderer)==="dagre-wrapper"?!1:/^\s*stateDiagram/.test(e)},"detector"),JVe=Y(async()=>{const{diagram:e}=await Ve(async()=>{const{diagram:r}=await import("./stateDiagram-RAJIS63D-C-spqu7H.js");return{diagram:r}},__vite__mapDeps([80,81,59,60,48,49,50,51]),import.meta.url);return{id:$se,diagram:e}},"loader"),QVe={id:$se,detector:ZVe,loader:JVe},eqe=QVe,Dse="stateDiagram",tqe=Y((e,r)=>{var n;return!!(/^\s*stateDiagram-v2/.test(e)||/^\s*stateDiagram/.test(e)&&((n=r==null?void 0:r.state)==null?void 0:n.defaultRenderer)==="dagre-wrapper")},"detector"),rqe=Y(async()=>{const{diagram:e}=await Ve(async()=>{const{diagram:r}=await import("./stateDiagram-v2-FVOUBMTO-D6a1M8Bm.js");return{diagram:r}},__vite__mapDeps([82,81,59,60]),import.meta.url);return{id:Dse,diagram:e}},"loader"),nqe={id:Dse,detector:tqe,loader:rqe},iqe=nqe,Ise="journey",sqe=Y(e=>/^\s*journey/.test(e),"detector"),oqe=Y(async()=>{const{diagram:e}=await Ve(async()=>{const{diagram:r}=await import("./journeyDiagram-4ABVD52K-BNueoCiS.js");return{diagram:r}},__vite__mapDeps([83,58,56,72]),import.meta.url);return{id:Ise,diagram:e}},"loader"),aqe={id:Ise,detector:sqe,loader:oqe},lqe=aqe,cqe=Y((e,r,n)=>{jt.debug(`rendering svg for syntax error
1125
+ `);const i=iIe(r),s=i.append("g");i.attr("viewBox","0 0 2412 512"),fee(i,100,512,!0),s.append("path").attr("class","error-icon").attr("d","m411.313,123.313c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32-9.375,9.375-20.688-20.688c-12.484-12.5-32.766-12.5-45.25,0l-16,16c-1.261,1.261-2.304,2.648-3.31,4.051-21.739-8.561-45.324-13.426-70.065-13.426-105.867,0-192,86.133-192,192s86.133,192 192,192 192-86.133 192-192c0-24.741-4.864-48.327-13.426-70.065 1.402-1.007 2.79-2.049 4.051-3.31l16-16c12.5-12.492 12.5-32.758 0-45.25l-20.688-20.688 9.375-9.375 32.001-31.999zm-219.313,100.687c-52.938,0-96,43.063-96,96 0,8.836-7.164,16-16,16s-16-7.164-16-16c0-70.578 57.422-128 128-128 8.836,0 16,7.164 16,16s-7.164,16-16,16z"),s.append("path").attr("class","error-icon").attr("d","m459.02,148.98c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l16,16c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16.001-16z"),s.append("path").attr("class","error-icon").attr("d","m340.395,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16-16c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l15.999,16z"),s.append("path").attr("class","error-icon").attr("d","m400,64c8.844,0 16-7.164 16-16v-32c0-8.836-7.156-16-16-16-8.844,0-16,7.164-16,16v32c0,8.836 7.156,16 16,16z"),s.append("path").attr("class","error-icon").attr("d","m496,96.586h-32c-8.844,0-16,7.164-16,16 0,8.836 7.156,16 16,16h32c8.844,0 16-7.164 16-16 0-8.836-7.156-16-16-16z"),s.append("path").attr("class","error-icon").attr("d","m436.98,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688l32-32c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32c-6.251,6.25-6.251,16.375-0.001,22.625z"),s.append("text").attr("class","error-text").attr("x",1440).attr("y",250).attr("font-size","150px").style("text-anchor","middle").text("Syntax error in text"),s.append("text").attr("class","error-text").attr("x",1250).attr("y",400).attr("font-size","100px").style("text-anchor","middle").text(`mermaid version ${n}`)},"draw"),Bse={draw:cqe},uqe=Bse,dqe={db:{},renderer:Bse,parser:{parse:Y(()=>{},"parse")}},hqe=dqe,zse="flowchart-elk",fqe=Y((e,r={})=>{var n;return/^\s*flowchart-elk/.test(e)||/^\s*(flowchart|graph)/.test(e)&&((n=r==null?void 0:r.flowchart)==null?void 0:n.defaultRenderer)==="elk"?(r.layout="elk",!0):!1},"detector"),pqe=Y(async()=>{const{diagram:e}=await Ve(async()=>{const{diagram:r}=await import("./flowDiagram-PKNHOUZH-C2Hxrf84.js");return{diagram:r}},__vite__mapDeps([57,58,56,59,60,61]),import.meta.url);return{id:zse,diagram:e}},"loader"),mqe={id:zse,detector:fqe,loader:pqe},gqe=mqe,Fse="timeline",yqe=Y(e=>/^\s*timeline/.test(e),"detector"),vqe=Y(async()=>{const{diagram:e}=await Ve(async()=>{const{diagram:r}=await import("./timeline-definition-YZTLITO2-DLGMvBG8.js");return{diagram:r}},__vite__mapDeps([84,72]),import.meta.url);return{id:Fse,diagram:e}},"loader"),xqe={id:Fse,detector:yqe,loader:vqe},bqe=xqe,Hse="mindmap",_qe=Y(e=>/^\s*mindmap/.test(e),"detector"),wqe=Y(async()=>{const{diagram:e}=await Ve(async()=>{const{diagram:r}=await import("./mindmap-definition-YRQLILUH-CkCVQqrV.js");return{diagram:r}},__vite__mapDeps([85,59,60]),import.meta.url);return{id:Hse,diagram:e}},"loader"),Sqe={id:Hse,detector:_qe,loader:wqe},kqe=Sqe,Wse="kanban",Cqe=Y(e=>/^\s*kanban/.test(e),"detector"),jqe=Y(async()=>{const{diagram:e}=await Ve(async()=>{const{diagram:r}=await import("./kanban-definition-K7BYSVSG-ktueNo2t.js");return{diagram:r}},__vite__mapDeps([86,58]),import.meta.url);return{id:Wse,diagram:e}},"loader"),Nqe={id:Wse,detector:Cqe,loader:jqe},Tqe=Nqe,Use="sankey",Eqe=Y(e=>/^\s*sankey(-beta)?/.test(e),"detector"),Aqe=Y(async()=>{const{diagram:e}=await Ve(async()=>{const{diagram:r}=await import("./sankeyDiagram-WA2Y5GQK-PTcro8ap.js");return{diagram:r}},[],import.meta.url);return{id:Use,diagram:e}},"loader"),Oqe={id:Use,detector:Eqe,loader:Aqe},Rqe=Oqe,Vse="packet",Mqe=Y(e=>/^\s*packet(-beta)?/.test(e),"detector"),Pqe=Y(async()=>{const{diagram:e}=await Ve(async()=>{const{diagram:r}=await import("./diagram-P4PSJMXO-BJmxkBPz.js");return{diagram:r}},__vite__mapDeps([87,64,66,49,51,52]),import.meta.url);return{id:Vse,diagram:e}},"loader"),Lqe={id:Vse,detector:Mqe,loader:Pqe},qse="radar",$qe=Y(e=>/^\s*radar-beta/.test(e),"detector"),Dqe=Y(async()=>{const{diagram:e}=await Ve(async()=>{const{diagram:r}=await import("./diagram-IFDJBPK2-DOjAWgtk.js");return{diagram:r}},__vite__mapDeps([88,64,66,49,51,52]),import.meta.url);return{id:qse,diagram:e}},"loader"),Iqe={id:qse,detector:$qe,loader:Dqe},Gse="block",Bqe=Y(e=>/^\s*block(-beta)?/.test(e),"detector"),zqe=Y(async()=>{const{diagram:e}=await Ve(async()=>{const{diagram:r}=await import("./blockDiagram-WCTKOSBZ-DhDmwNyU.js");return{diagram:r}},__vite__mapDeps([89,58,52,49,48,61]),import.meta.url);return{id:Gse,diagram:e}},"loader"),Fqe={id:Gse,detector:Bqe,loader:zqe},Hqe=Fqe,Kse="architecture",Wqe=Y(e=>/^\s*architecture/.test(e),"detector"),Uqe=Y(async()=>{const{diagram:e}=await Ve(async()=>{const{diagram:r}=await import("./architectureDiagram-2XIMDMQ5-BPT9bslh.js");return{diagram:r}},__vite__mapDeps([90,64,66,49,51,52,54]),import.meta.url);return{id:Kse,diagram:e}},"loader"),Vqe={id:Kse,detector:Wqe,loader:Uqe},qqe=Vqe,Yse="ishikawa",Gqe=Y(e=>/^\s*ishikawa(-beta)?\b/i.test(e),"detector"),Kqe=Y(async()=>{const{diagram:e}=await Ve(async()=>{const{diagram:r}=await import("./ishikawaDiagram-PHBUUO56-DTcNwdbm.js");return{diagram:r}},[],import.meta.url);return{id:Yse,diagram:e}},"loader"),Yqe={id:Yse,detector:Gqe,loader:Kqe},Xse="venn",Xqe=Y(e=>/^\s*venn-beta/.test(e),"detector"),Zqe=Y(async()=>{const{diagram:e}=await Ve(async()=>{const{diagram:r}=await import("./vennDiagram-LZ73GAT5-BHoBtPNv.js");return{diagram:r}},[],import.meta.url);return{id:Xse,diagram:e}},"loader"),Jqe={id:Xse,detector:Xqe,loader:Zqe},Qqe=Jqe,Zse="treemap",eGe=Y(e=>/^\s*treemap/.test(e),"detector"),tGe=Y(async()=>{const{diagram:e}=await Ve(async()=>{const{diagram:r}=await import("./diagram-E7M64L7V-DSUO8HTw.js");return{diagram:r}},__vite__mapDeps([91,60,64,66,49,51,52,69]),import.meta.url);return{id:Zse,diagram:e}},"loader"),rGe={id:Zse,detector:eGe,loader:tGe},MF=!1,c6=Y(()=>{MF||(MF=!0,L5("error",hqe,e=>e.toLowerCase().trim()==="error"),L5("---",{db:{clear:Y(()=>{},"clear")},styles:{},renderer:{draw:Y(()=>{},"draw")},parser:{parse:Y(()=>{throw new Error("Diagrams beginning with --- are not valid. If you were trying to use a YAML front-matter, please ensure that you've correctly opened and closed the YAML front-matter with un-indented `---` blocks")},"parse")},init:Y(()=>null,"init")},e=>e.toLowerCase().trimStart().startsWith("---")),CA(gqe,kqe,qqe),CA(eVe,Tqe,XVe,qVe,hVe,bVe,SVe,jVe,IVe,HVe,lVe,iVe,bqe,gVe,iqe,eqe,lqe,AVe,Rqe,Lqe,PVe,Hqe,Iqe,Yqe,rGe,Qqe))},"addDiagrams"),nGe=Y(async()=>{jt.debug("Loading registered diagrams");const r=(await Promise.allSettled(Object.entries(z0).map(async([n,{detector:i,loader:s}])=>{if(s)try{EA(n)}catch{try{const{diagram:o,id:a}=await s();L5(a,o,i)}catch(o){throw jt.error(`Failed to load external diagram with key ${n}. Removing from detectors.`),delete z0[n],o}}}))).filter(n=>n.status==="rejected");if(r.length>0){jt.error(`Failed to load ${r.length} external diagrams`);for(const n of r)jt.error(n);throw new Error(`Failed to load ${r.length} external diagrams`)}},"loadRegisteredDiagrams"),iGe="graphics-document document";function Jse(e,r){e.attr("role",iGe),r!==""&&e.attr("aria-roledescription",r)}Y(Jse,"setA11yDiagramInfo");function Qse(e,r,n,i){if(e.insert!==void 0){if(n){const s=`chart-desc-${i}`;e.attr("aria-describedby",s),e.insert("desc",":first-child").attr("id",s).text(n)}if(r){const s=`chart-title-${i}`;e.attr("aria-labelledby",s),e.insert("title",":first-child").attr("id",s).text(r)}}}Y(Qse,"addSVGa11yTitleDescription");var R0,x7=(R0=class{constructor(r,n,i,s,o){this.type=r,this.text=n,this.db=i,this.parser=s,this.renderer=o}static async fromText(r,n={}){var u,f;const i=Ma(),s=eM(r,i);r=aHe(r)+`
1126
1126
  `;try{EA(s)}catch{const p=YRe(s);if(!p)throw new QQ(`Diagram ${s} not found.`);const{id:g,diagram:v}=await p();L5(g,v)}const{db:o,parser:a,renderer:l,init:d}=EA(s);return a.parser&&(a.parser.yy=o),(u=o.clear)==null||u.call(o),d==null||d(i),n.title&&((f=o.setDiagramTitle)==null||f.call(o,n.title)),await a.parse(r),new R0(s,r,o,a,l)}async render(r,n){await this.renderer.draw(this.text,r,n,this)}getParser(){return this.parser}getType(){return this.type}},Y(R0,"Diagram"),R0),PF=[],sGe=Y(()=>{PF.forEach(e=>{e()}),PF=[]},"attachFunctions"),oGe=Y(e=>e.replace(/^\s*%%(?!{)[^\n]+\n?/gm,"").trimStart(),"cleanupComments");function eoe(e){const r=e.match(JQ);if(!r)return{text:e,metadata:{}};let n=dBe(r[1],{schema:uBe})??{};n=typeof n=="object"&&!Array.isArray(n)?n:{};const i={};return n.displayMode&&(i.displayMode=n.displayMode.toString()),n.title&&(i.title=n.title.toString()),n.config&&(i.config=n.config),{text:e.slice(r[0].length),metadata:i}}Y(eoe,"extractFrontMatter");var aGe=Y(e=>e.replace(/\r\n?/g,`
1127
1127
  `).replace(/<(\w+)([^>]*)>/g,(r,n,i)=>"<"+n+i.replace(/="([^"]*)"/g,"='$1'")+">"),"cleanupText"),lGe=Y(e=>{const{text:r,metadata:n}=eoe(e),{displayMode:i,title:s,config:o={}}=n;return i&&(o.gantt||(o.gantt={}),o.gantt.displayMode=i),{title:s,config:o,text:r}},"processFrontmatter"),cGe=Y(e=>{const r=vd.detectInit(e)??{},n=vd.detectDirective(e,"wrap");return Array.isArray(n)?r.wrap=n.some(({type:i})=>i==="wrap"):(n==null?void 0:n.type)==="wrap"&&(r.wrap=!0),{text:KFe(e),directive:r}},"processDirectives");function eP(e){const r=aGe(e),n=lGe(r),i=cGe(n.text),s=IM(n.config,i.directive);return e=oGe(i.text),{code:e,title:n.title,config:s}}Y(eP,"preprocessDiagram");function toe(e){const r=new TextEncoder().encode(e),n=Array.from(r,i=>String.fromCodePoint(i)).join("");return btoa(n)}Y(toe,"toBase64");var uGe=5e4,dGe="graph TB;a[Maximum text size in diagram exceeded];style a fill:#faa",hGe="sandbox",fGe="loose",pGe="http://www.w3.org/2000/svg",mGe="http://www.w3.org/1999/xlink",gGe="http://www.w3.org/1999/xhtml",yGe="100%",vGe="100%",xGe="border:0;margin:0;",bGe="margin:0",_Ge="allow-top-navigation-by-user-activation allow-popups",wGe='The "iframe" tag is not supported by your browser.',SGe=["foreignobject"],kGe=["dominant-baseline"];function tP(e){const r=eP(e);return M5(),dMe(r.config??{}),r}Y(tP,"processAndSetConfigs");async function roe(e,r){c6();try{const{code:n,config:i}=tP(e);return{diagramType:(await ioe(n)).type,config:i}}catch(n){if(r!=null&&r.suppressErrors)return!1;throw n}}Y(roe,"parse");var LF=Y((e,r,n=[])=>`
1128
1128
  .${e} ${r} { ${n.join(" !important; ")} !important; }`,"cssImportantStyles"),CGe=Y((e,r=new Map)=>{let n="";if(e.themeCSS!==void 0&&(n+=`
@@ -1144,7 +1144,7 @@ ${e.themeCSS}`),e.fontFamily!==void 0&&(n+=`
1144
1144
  `),n.split(`
1145
1145
  `),g);await l(P)}finally{k(!1)}}},[N,g,l,i,n]);y.useEffect(()=>{if(!N||!l)return;const P=window.setTimeout(()=>{A()},600);return()=>window.clearTimeout(P)},[N,l,A]),y.useEffect(()=>{j()},[j]);const M=y.useCallback((P,D)=>{v(W=>W.map((U,H)=>H===P?{...U,state:D}:U))},[]);y.useEffect(()=>{const P=f.current;P&&wu(P,s)},[s]);const B=y.useCallback(()=>{var R,I;const P=u.current,D=(R=P==null?void 0:P.getModel)==null?void 0:R.call(P),W=(I=P==null?void 0:P.getSelection)==null?void 0:I.call(P);if(!P||!D||!W||W.isEmpty()){p.current=null;return}const U=D.getValueInRange(W).trim();if(!U){p.current=null;return}const H=`${W.startLineNumber}:${W.endLineNumber}:${U}`;p.current!==H&&(p.current=H,d==null||d(U,W.startLineNumber,W.endLineNumber))},[d]);return c.jsxs("div",{className:"relative h-full",children:[c.jsx(Bj,{height:"100%",beforeMount:P=>wu(P,s),theme:s,path:e,language:r,value:n,onChange:a,onMount:(P,D)=>{u.current=P,f.current=D,wu(D,s);const W=[P.onDidScrollChange(()=>j()),P.onDidLayoutChange(()=>j()),P.onDidContentSizeChange(()=>j()),P.onMouseUp(()=>window.setTimeout(B,0)),P.onKeyUp(()=>window.setTimeout(B,0))];window.setTimeout(j,0),P.__jaitReviewDisposables=W},options:{readOnly:o,minimap:{enabled:!1},"semanticHighlighting.enabled":!0,fontSize:13,automaticLayout:!0}},e),b.length>0&&!o&&c.jsx("div",{className:"pointer-events-none absolute inset-0 z-20",children:b.map(({hunkIndex:P,top:D})=>{const W=g[P];return!W||W.state!=="undecided"?null:c.jsxs("div",{className:"pointer-events-auto absolute right-3 flex items-center gap-1 rounded-md border bg-background/95 p-1 shadow-md backdrop-blur-sm",style:{top:D},children:[c.jsxs(_e,{size:"sm",variant:"ghost",className:"h-7 px-2 text-xs text-green-600 hover:bg-green-500/10 hover:text-green-500",onClick:()=>M(P,"accepted"),children:[c.jsx(_s,{className:"mr-1 h-3 w-3"}),"Keep"]}),c.jsxs(_e,{size:"sm",variant:"ghost",className:"h-7 px-2 text-xs text-red-600 hover:bg-red-500/10 hover:text-red-500",onClick:()=>M(P,"rejected"),children:[c.jsx(Ah,{className:"mr-1 h-3 w-3"}),"Undo"]})]},`review-${P}`)})}),C&&!o&&c.jsxs("div",{className:"absolute bottom-3 left-1/2 z-20 flex -translate-x-1/2 items-center gap-2 rounded-full border bg-background/95 px-3 py-1.5 text-xs shadow-md backdrop-blur-sm",children:[c.jsxs("span",{className:"font-medium",children:[E," pending"]}),N&&c.jsx("span",{className:"text-muted-foreground",children:S?"Applying...":"Applying review..."})]})]})}const ZGe="jait:detached-workspace-tab:";function rP(e){return`${ZGe}${e}`}function JGe(e){try{localStorage.setItem(rP(e.id),JSON.stringify(e))}catch{}}function VF(e){const r=rP(e);let n=null;try{n=localStorage.getItem(r)}catch{return null}if(!n)return null;try{return JSON.parse(n)}catch{try{localStorage.removeItem(r)}catch{}return null}}function QGe(e){try{localStorage.removeItem(rP(e))}catch{}}const eKe=new Set([".git","node_modules","dist","build",".next",".turbo",".idea",".vscode"]);async function tKe(e,r,n,i,s=eKe){const o=r.trim().toLowerCase();if(!o||n<1)return[];const a=[],l=1024*1024,d=(f,p)=>{const g=p.split(`
1146
1146
  `);for(let v=0;v<g.length;v+=1){if(i!=null&&i.aborted||a.length>=n)return;const b=g[v]??"";b.toLowerCase().includes(o)&&a.push({file:f,line:v+1,content:b.trim()})}},u=async(f,p)=>{if(i!=null&&i.aborted||a.length>=n)return!0;try{for await(const g of f.values()){if(i!=null&&i.aborted||a.length>=n)return!0;const v=g.name,b=p?`${p}/${v}`:v;if(g.kind==="directory"){if(s.has(v))continue;if(await u(g,b))return!0;continue}try{const _=await g.getFile();if(_.size>l)continue;const S=await _.text();if(S.includes("\0"))continue;d(b,S)}catch{}}}catch{}return(i==null?void 0:i.aborted)===!0||a.length>=n};return await u(e,""),a}function j7(e){return e!=null&&e.hasUpstream?(e.aheadCount??0)>0||(e.behindCount??0)>0:!1}function rKe(e,r){return e>0?!0:((r==null?void 0:r.aheadCount)??0)>0}function nKe(e,r){return e>0?"commit":j7(r)?"sync":"commit"}function iKe({showTree:e,showEditor:r,panelSize:n,treeSize:i,maxCollapsed:s}){const o=!e&&!r?0:e?r?n:i:Math.max(n-i,300);return s?{width:"100%",maxWidth:"100%"}:{width:o,maxWidth:"70vw"}}function sKe(e){const r=!e.tree;return{tree:r,editor:r?e.editor:!0}}function $3(e){return e.replace(/\\/g,"/").replace(/\/+/g,"/")}function oKe(e,r,n){if(r.length===0)return e;const i=new Map(e.map(l=>[$3(l.path),l])),s=new Set(n.map(l=>$3(l.path))),o=new Set,a=[];for(const l of r){const d=$3(l.path),u=i.get(d);if(u){o.add(d),a.push(u);continue}s.has(d)||(o.add(d),a.push({path:l.path,insertions:0,deletions:0,status:l.status}))}for(const l of e){const d=$3(l.path);o.has(d)||a.push(l)}return a}function aKe(e,r){return e.length+r.length}function U_(e){return e.replace(/\\/g,"/").replace(/\/+/g,"/").replace(/\/$/,"")}function lKe(e){return e.startsWith("/")||/^[a-zA-Z]:\//.test(e)}function qF(e,r){const n=U_(e),i=U_(r);return/^[a-zA-Z]:\//.test(n)||/^[a-zA-Z]:\//.test(i)?n.toLowerCase()===i.toLowerCase():n===i}function cKe(e,r,n){if(!e||!r||!n)return!1;const i=U_(r),s=U_(n);for(const o of e.changes){const a=U_(o.path);if(a){if(lKe(a)){if(qF(a,s))return!0;continue}if(qF(`${i}/${a.replace(/^\.\//,"")}`,s))return!0}}return!1}function Ul(e,r="ms"){if(e==null||!Number.isFinite(e))return"n/a";if(r==="ms")return`${Math.round(e)} ms`;if(r==="bytes"){if(e>=1024*1024)return`${(e/(1024*1024)).toFixed(1)} MB`;if(e>=1024)return`${(e/1024).toFixed(1)} KB`}return r==="count"?`${Math.round(e)}`:String(e)}function poe({metrics:e}){var r,n,i,s,o,a,l,d,u,f,p,g,v,b,_;return e?c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"rounded border bg-muted/30 p-2",children:[c.jsx("div",{className:"font-medium text-foreground",children:e.title||"(untitled)"}),c.jsx("div",{className:"mt-1 break-all text-muted-foreground",children:c.jsx("code",{children:e.url})}),c.jsxs("div",{className:"mt-1 text-xs text-muted-foreground",children:["Sampled ",new Date(e.sampledAt).toLocaleTimeString()]})]}),c.jsxs("div",{className:"grid gap-2 md:grid-cols-3",children:[c.jsxs("div",{className:"rounded border p-2",children:[c.jsx("div",{className:"font-medium text-foreground",children:"Web Vitals"}),c.jsxs("div",{className:"mt-1 space-y-1 text-muted-foreground",children:[c.jsxs("div",{children:["LCP: ",Ul((r=e.webVitals)==null?void 0:r.lcpMs,"ms")]}),c.jsxs("div",{children:["CLS: ",((n=e.webVitals)==null?void 0:n.cls)!=null?e.webVitals.cls.toFixed(3):"n/a"]}),c.jsxs("div",{children:["INP: ",Ul((i=e.webVitals)==null?void 0:i.inpMs,"ms")]})]})]}),c.jsxs("div",{className:"rounded border p-2",children:[c.jsx("div",{className:"font-medium text-foreground",children:"Load"}),c.jsxs("div",{className:"mt-1 space-y-1 text-muted-foreground",children:[c.jsxs("div",{children:["DOMContentLoaded: ",Ul((s=e.navigation)==null?void 0:s.domContentLoadedMs,"ms")]}),c.jsxs("div",{children:["Load: ",Ul((o=e.navigation)==null?void 0:o.loadMs,"ms")]}),c.jsxs("div",{children:["FCP: ",Ul((a=e.paint)==null?void 0:a.firstContentfulPaintMs,"ms")]})]})]}),c.jsxs("div",{className:"rounded border p-2",children:[c.jsx("div",{className:"font-medium text-foreground",children:"Memory"}),c.jsxs("div",{className:"mt-1 space-y-1 text-muted-foreground",children:[c.jsxs("div",{children:["Used JS heap: ",Ul((l=e.memory)==null?void 0:l.usedJsHeapSize,"bytes")]}),c.jsxs("div",{children:["Total JS heap: ",Ul((d=e.memory)==null?void 0:d.totalJsHeapSize,"bytes")]}),c.jsxs("div",{children:["Heap limit: ",Ul((u=e.memory)==null?void 0:u.jsHeapSizeLimit,"bytes")]})]})]})]}),c.jsxs("div",{className:"rounded border p-2",children:[c.jsx("div",{className:"font-medium text-foreground",children:"Resources"}),c.jsxs("div",{className:"mt-1 grid gap-1 text-muted-foreground md:grid-cols-3",children:[c.jsxs("div",{children:["Total: ",Ul((f=e.resources)==null?void 0:f.total,"count")]}),c.jsxs("div",{children:["Scripts: ",Ul((p=e.resources)==null?void 0:p.scripts,"count")]}),c.jsxs("div",{children:["Stylesheets: ",Ul((g=e.resources)==null?void 0:g.stylesheets,"count")]}),c.jsxs("div",{children:["Images: ",Ul((v=e.resources)==null?void 0:v.images,"count")]}),c.jsxs("div",{children:["Fonts: ",Ul((b=e.resources)==null?void 0:b.fonts,"count")]}),c.jsxs("div",{children:["Largest transfer: ",Ul((_=e.resources)==null?void 0:_.largestTransferSize,"bytes")]})]})]})]}):c.jsx("div",{className:"text-muted-foreground",children:"No preview metrics available yet."})}function uKe({inspectState:e,loading:r=!1,error:n=null,onInsertElementReference:i}){var s,o,a,l,d,u,f,p;return n?c.jsx("div",{className:"rounded border border-destructive/30 bg-destructive/5 px-2 py-1.5 text-destructive",children:n}):r?c.jsx("div",{className:"text-muted-foreground",children:"Inspecting preview…"}):e!=null&&e.captureSuppressed?c.jsx("div",{className:"rounded border border-amber-500/30 bg-amber-500/5 px-2 py-1.5 text-amber-700",children:e.suppressionReason??"Preview inspection is currently suppressed."}):e?c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"rounded border bg-muted/30 p-2",children:[c.jsx("div",{className:"font-medium text-foreground",children:((s=e.page)==null?void 0:s.title)||"(untitled)"}),c.jsx("div",{className:"mt-1 break-all text-muted-foreground",children:c.jsx("code",{children:e.url??((o=e.page)==null?void 0:o.url)??"Unknown URL"})})]}),c.jsxs("div",{className:"rounded border p-2",children:[c.jsx("div",{className:"font-medium text-foreground",children:"Active Element"}),(a=e.page)!=null&&a.activeElement?c.jsxs("div",{className:"mt-1 space-y-1 text-muted-foreground",children:[c.jsx("div",{children:[e.page.activeElement.role??e.page.activeElement.tagName??"element",e.page.activeElement.name].filter(Boolean).join(" - ")}),e.page.activeElement.selector?c.jsx("div",{children:c.jsx("code",{children:e.page.activeElement.selector})}):null,e.page.activeElement.selector&&i?c.jsx(_e,{type:"button",variant:"outline",size:"sm",className:"mt-2 h-7 px-2 text-xs",onClick:()=>i(e.page.activeElement),children:"Insert Into Chat"}):null]}):c.jsx("div",{className:"mt-1 text-muted-foreground",children:"No active input detected."})]}),c.jsxs("div",{className:"rounded border p-2",children:[c.jsx("div",{className:"font-medium text-foreground",children:"Dialogs"}),(d=(l=e.page)==null?void 0:l.dialogs)!=null&&d.length?c.jsx("div",{className:"mt-1 space-y-1 text-muted-foreground",children:e.page.dialogs.map((g,v)=>c.jsxs("div",{className:"rounded bg-muted/40 px-2 py-1",children:[c.jsx("div",{children:g.title||g.name||g.role||"dialog"}),g.selector?c.jsx("div",{children:c.jsx("code",{children:g.selector})}):null]},`${g.selector??g.title??v}`))}):c.jsx("div",{className:"mt-1 text-muted-foreground",children:"No visible dialogs detected."})]}),c.jsxs("div",{className:"rounded border p-2",children:[c.jsx("div",{className:"font-medium text-foreground",children:"Obstruction"}),(u=e.page)!=null&&u.obstruction?c.jsxs("div",{className:"mt-1 space-y-1 text-muted-foreground",children:[c.jsxs("div",{children:["Modal: ",e.page.obstruction.hasModal?"yes":"no"," · Dialogs: ",e.page.obstruction.dialogCount]}),e.page.obstruction.activeDialogTitle?c.jsxs("div",{children:["Active dialog: ",e.page.obstruction.activeDialogTitle]}):null,e.page.obstruction.notes.map((g,v)=>c.jsx("div",{children:g},`${g}:${v}`))]}):c.jsx("div",{className:"mt-1 text-muted-foreground",children:"No obstruction diagnostics available."})]}),e.target?c.jsxs("div",{className:"rounded border p-2",children:[c.jsx("div",{className:"font-medium text-foreground",children:"Selector Diagnosis"}),c.jsxs("div",{className:"mt-1 space-y-1 text-muted-foreground",children:[c.jsx("div",{children:c.jsx("code",{children:e.target.selector})}),c.jsxs("div",{children:["Found: ",e.target.found?"yes":"no"]}),e.target.obscured!=null?c.jsxs("div",{children:["Obscured: ",e.target.obscured?"yes":"no"]}):null,e.target.offscreen!=null?c.jsxs("div",{children:["Offscreen: ",e.target.offscreen?"yes":"no"]}):null,e.target.dialogTitle?c.jsxs("div",{children:["Dialog: ",e.target.dialogTitle]}):null,e.target.obstructionReason?c.jsx("div",{children:e.target.obstructionReason}):null,e.target.interceptedBy?c.jsxs("div",{children:["Intercepted by ",e.target.interceptedBy.role??e.target.interceptedBy.tagName??"element",e.target.interceptedBy.selector?` (${e.target.interceptedBy.selector})`:""]}):null,e.target.selector&&i?c.jsx(_e,{type:"button",variant:"outline",size:"sm",className:"mt-2 h-7 px-2 text-xs",onClick:()=>i(e.target),children:"Insert Into Chat"}):null]})]}):null,c.jsxs("div",{className:"rounded border p-2",children:[c.jsx("div",{className:"font-medium text-foreground",children:"Interactive Elements"}),(p=(f=e.page)==null?void 0:f.elements)!=null&&p.length?c.jsx("div",{className:"mt-2 space-y-2",children:e.page.elements.map((g,v)=>{const b=[g.role??g.tagName??"element",g.name||g.text].filter(Boolean).join(" - ");return c.jsxs("div",{className:"rounded bg-muted/40 px-2 py-1.5 text-muted-foreground",children:[c.jsx("div",{className:"font-medium text-foreground",children:b||"Unnamed element"}),g.selector?c.jsx("div",{className:"mt-1 break-all",children:c.jsx("code",{children:g.selector})}):null,g.placeholder?c.jsxs("div",{className:"mt-1",children:["Placeholder: ",g.placeholder]}):null,g.value?c.jsxs("div",{className:"mt-1",children:["Value: ",g.value]}):null,c.jsxs("div",{className:"mt-1 text-2xs",children:[g.disabled?"Disabled":"Enabled",g.active?" · Active":""]}),g.selector&&i?c.jsx(_e,{type:"button",variant:"outline",size:"sm",className:"mt-2 h-7 px-2 text-xs",onClick:()=>i(g),children:"Insert Into Chat"}):null]},`${g.selector??b??"element"}:${v}`)})}):c.jsx("div",{className:"mt-1 text-muted-foreground",children:"No interactive elements captured."})]}),c.jsxs("div",{className:"rounded border p-2",children:[c.jsx("div",{className:"font-medium text-foreground",children:"Metrics"}),c.jsx("div",{className:"mt-2",children:c.jsx(poe,{metrics:e.metrics})})]})]}):c.jsx("div",{className:"text-muted-foreground",children:"No inspection data available yet."})}function D3(e){var r;return e.length>0?((r=e[e.length-1])==null?void 0:r.id)??null:null}function dKe(e,r){return((e==null?void 0:e.containerName)??null)===((r==null?void 0:r.containerName)??null)&&((e==null?void 0:e.novncUrl)??null)===((r==null?void 0:r.novncUrl)??null)&&((e==null?void 0:e.novncPort)??null)===((r==null?void 0:r.novncPort)??null)&&((e==null?void 0:e.vncPort)??null)===((r==null?void 0:r.vncPort)??null)&&((e==null?void 0:e.startedAt)??null)===((r==null?void 0:r.startedAt)??null)}function hKe(e){const r=e==null?void 0:e.trim();return r?`${r}::managed-preview`:null}function I3(e,r){return e===r?!0:!e||!r?!1:e.id===r.id&&e.status===r.status&&e.mode===r.mode&&e.target===r.target&&e.command===r.command&&e.port===r.port&&e.url===r.url&&e.browserId===r.browserId&&e.processId===r.processId&&e.containerId===r.containerId&&dKe(e.remoteBrowser,r.remoteBrowser)&&e.lastError===r.lastError&&e.updatedAt===r.updatedAt&&e.logs.length===r.logs.length&&D3(e.logs)===D3(r.logs)&&e.browserEvents.length===r.browserEvents.length&&D3(e.browserEvents)===D3(r.browserEvents)}const N7=new Set;function fKe(e){return N7.add(e),()=>{N7.delete(e)}}function pKe(e){for(const r of N7)try{r(e)}catch(n){console.error("Failed to deliver preview session event.",n)}}const V_=new Set(["node_modules",".git",".hg",".svn","dist","build","out",".next",".nuxt",".output",".cache","__pycache__",".tox",".venv","venv","env",".idea",".vscode",".DS_Store","coverage",".turbo",".parcel-cache","target"]);function Sa(e){var i;const r=(i=e.split(".").pop())==null?void 0:i.toLowerCase();return r?{ts:"typescript",tsx:"typescript",js:"javascript",jsx:"javascript",json:"json",md:"markdown",css:"css",scss:"scss",less:"less",html:"html",py:"python",yml:"yaml",yaml:"yaml",rs:"rust",go:"go",java:"java",c:"c",cpp:"cpp",h:"c",hpp:"cpp",sh:"shell",bash:"shell",zsh:"shell",sql:"sql",xml:"xml",toml:"toml",ini:"ini",dockerfile:"dockerfile",graphql:"graphql"}[r]??"plaintext":"plaintext"}function q_(e){return Sa(e)}const moe="jait.git.autofetch",mKe="jait.git.autofetchPeriod",GF=180;function gKe(){if(typeof window>"u")return!1;const e=window.localStorage.getItem(moe);return e==="true"?!0:e==="all"?"all":!1}function yKe(){if(typeof window>"u")return GF;const e=window.localStorage.getItem(mKe),r=e?Number.parseInt(e,10):Number.NaN;return!Number.isFinite(r)||r<10?GF:r}function KF(e){return e==="all"?"Auto-fetch: all remotes":e===!0?"Auto-fetch: default remote":"Auto-fetch: off"}function vKe(e){return JSON.stringify(e)}const YF=25;async function B3(e,r){const n=[],i=[];for await(const s of e.values()){const o=s.name,a=r?`${r}/${o}`:o;if(s.kind==="directory"){if(V_.has(o))continue;n.push({kind:"dir",name:o,path:a,handle:s,children:null})}else i.push({kind:"file",name:o,path:a,handle:s})}return n.sort((s,o)=>s.name.localeCompare(o.name)),i.sort((s,o)=>s.name.localeCompare(o.name)),[...n,...i]}async function v1(e){const r=await e.getFile();return r.size>2*1024*1024?"// File too large to preview":r.text()}function Ca(e){return e.replace(/\\/g,"/").replace(/\/+$/,"")}function XF(e,r){const n=Ca(e),i=Ca(r);return i===n||i.startsWith(`${n}/`)}const Ta=Hn();async function bc(e,r){let n=`${Ta}/api/workspace/list?path=${encodeURIComponent(e)}`;r&&(n+=`&surfaceId=${encodeURIComponent(r)}`);const i=await fetch(n);if(!i.ok)throw new Error(`Failed to list directory: ${i.statusText}`);const s=await i.json(),o=[],a=[];for(const l of s.entries){const d=l.endsWith("/"),u=d?l.slice(0,-1):l;if(V_.has(u))continue;const f=e.replace(/[\\/]$/,"")+"/"+u;d?o.push({kind:"dir",name:u,path:f,handle:null,children:null}):a.push({kind:"file",name:u,path:f,handle:null})}return o.sort((l,d)=>l.name.localeCompare(d.name)),a.sort((l,d)=>l.name.localeCompare(d.name)),[...o,...a]}async function sd(e,r){const n=async o=>{let a=`${Ta}/api/workspace/read?path=${encodeURIComponent(e)}`;return o&&(a+=`&surfaceId=${encodeURIComponent(o)}`),fetch(a)};let i=await n(r);if(!i.ok&&r&&(i=await n()),!i.ok)throw new Error(`Failed to read file: ${i.statusText}`);const s=await i.json();return s.size>2*1024*1024?"// File too large to preview":s.content}async function xKe(e,r,n){const i=await fetch(`${Ta}/api/workspace/write`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e,content:r,surfaceId:n})});if(!i.ok){const s=await i.json().catch(()=>({}));throw new Error(s.message||`Failed to write file: ${i.statusText}`)}}async function bKe(e,r){let n=`${Ta}/api/workspace/backup?path=${encodeURIComponent(e)}`;r&&(n+=`&surfaceId=${encodeURIComponent(r)}`);const i=await fetch(n);return i.ok?(await i.json()).originalContent:null}async function ZF(e,r){let n=`${Ta}/api/workspace/stat?path=${encodeURIComponent(e)}`;r&&(n+=`&surfaceId=${encodeURIComponent(r)}`);try{const i=await fetch(n);return i.ok?(await i.json()).modified??null:null}catch{return null}}const _Ke={A:"text-green-500",M:"text-yellow-500",D:"text-red-500",R:"text-blue-500","?":"text-green-400"},T7={A:"Added",M:"Modified",D:"Deleted",R:"Renamed","?":"Untracked"},z3=16;function g_({status:e,className:r=""}){const n=e==="?"?"U":e;return c.jsx("span",{className:`text-2xs font-bold leading-none shrink-0 ${_Ke[e]??"text-muted-foreground"} ${r}`,title:T7[e]??e,children:n})}function wKe(e){const r=new Set;for(const n of e.keys()){const i=n.replace(/\\/g,"/").split("/");for(let s=1;s<i.length;s++)r.add(i.slice(0,s).join("/"))}return r}function SKe(e,r){if(r.size===0)return!1;const n=e.replace(/\\/g,"/");let i=0;for(;;){const s=n.indexOf("/",i);if(s===-1)break;const o=n.slice(s+1);if(o&&r.has(o))return!0;i=s+1}return r.has(n)}function kKe(e){const r=new Map;for(const[n,i]of e){r.set(n,i);const s=n.replace(/\\/g,"/");s!==n&&r.set(s,i)}return r}function JF(e){const r={children:[]};for(const i of e){const s=i.path.replace(/\\/g,"/"),o=s.split("/").filter(Boolean);if(o.length===0)continue;let a=r;for(let l=0;l<o.length;l++){const d=o[l],u=o.slice(0,l+1).join("/");if(l===o.length-1){a.children.push({kind:"file",name:d,path:s,entry:i});continue}let p=a.children.find(g=>g.kind==="dir"&&g.path===u);p||(p={kind:"dir",name:d,path:u,children:[]},a.children.push(p)),a=p}}const n=i=>[...i].sort((s,o)=>s.kind!==o.kind?s.kind==="dir"?-1:1:s.name.localeCompare(o.name)).map(s=>s.kind==="dir"?{...s,children:n(s.children)}:s);return n(r.children)}function goe(e){const r=[];for(const n of e){if(n.kind==="file"){r.push(n.path);continue}r.push(...goe(n.children))}return r}const sl=_o;function Mb(e){return!!(e&&e.type==="file"&&e.id.startsWith("file:"))}function n0(e){if(e.type==="architecture")return e.label||"Architecture";if(e.type==="preview")return e.label||"Preview";if(e.type!=="diff")return e.label;const r=e.label||(e.path.split(/[\\/]/).pop()??e.path);return`${r} <-> ${r}`}function Pb(e){return e?{Authorization:`Bearer ${e}`,"Content-Type":"application/json"}:{"Content-Type":"application/json"}}function QF(e){const r=e==null?void 0:e.trim();return r||"Live Preview"}function F3(e){const r=e==null?void 0:e.trim();return r?/^wss?:\/\//i.test(r)?r:/\/(?:noVNC\/)?vnc(?:_lite)?\.html(?:[?#].*)?$/i.test(r)?r.startsWith("/")?`${Ta}${r}`:r:null:null}function eH(e){const r=(e==null?void 0:e.trim())||"";return r&&r!=="__preview__"?r:null}function H3(e,r){var n;if(e instanceof HTMLElement&&(n=e.hasPointerCapture)!=null&&n.call(e,r))try{e.releasePointerCapture(r)}catch{}}function ph(e,r){e(n=>n===r?n:r)}function Lb(e,r){e(n=>n===r?n:r)}function tH(e,r,n,i="horizontal",s,o){const a=(o==null?void 0:o.snapCollapse)??!1,l=(o==null?void 0:o.snapMaxCollapse)??!1,d=(o==null?void 0:o.snapMaxSize)??n,u=(o==null?void 0:o.minStoredSize)??r,[f,p]=y.useState(()=>{if(!s||typeof window>"u")return e;const H=window.localStorage.getItem(s),R=H?Number.parseInt(H,10):Number.NaN;return Number.isFinite(R)?Math.min(n,Math.max(r,u,R)):e}),[g,v]=y.useState(!1),[b,_]=y.useState(!1),S=y.useRef(e),k=y.useRef(!1),[C,j]=y.useState(!1),E=y.useRef(null),N=y.useRef(null),A=-1,M=-2;y.useEffect(()=>{!g&&!b&&f>=r&&(S.current=f)},[f,g,b,r]),y.useEffect(()=>{!g&&!b&&p(H=>{const R=Math.min(n,Math.max(r,H));return H===R?H:R})},[r,n,g,b]);const B=y.useRef(null);y.useEffect(()=>()=>{var H;(H=B.current)==null||H.call(B),E.current!==null&&window.cancelAnimationFrame(E.current)},[]);const P=y.useCallback(()=>{const H=Math.min(n,Math.max(r,S.current));Lb(p,H),ph(v,!1),ph(_,!1)},[r,n]),D=y.useCallback(()=>{g||(S.current=f,ph(v,!0),ph(_,!1),Lb(p,0))},[g,f]),W=y.useCallback(H=>{H!==null&&(H===A?(ph(v,!0),ph(_,!1),Lb(p,0)):H===M?(ph(_,!0),ph(v,!1),Lb(p,d)):(ph(v,!1),ph(_,!1),Lb(p,H)))},[d]),U=y.useCallback(H=>{var ne,le;H.preventDefault(),k.current=!0,j(!0);const R=H.pointerId,I=H.currentTarget;(ne=B.current)==null||ne.call(B),(le=I.setPointerCapture)==null||le.call(I,R);const L=i==="horizontal"?H.clientX:H.clientY,z=g?0:b?d:f,G=r/2,X=n+(d-n)/2,F=de=>{if(!k.current)return;const ie=(i==="horizontal"?de.clientX:de.clientY)-L,pe=z+ie;a&&pe<G?N.current=A:l&&pe>X?N.current=M:N.current=Math.min(n,Math.max(r,pe)),E.current===null&&(E.current=window.requestAnimationFrame(()=>{E.current=null,W(N.current)}))},V=()=>{var de,te;k.current=!1,j(!1),(de=I.hasPointerCapture)!=null&&de.call(I,R)&&((te=I.releasePointerCapture)==null||te.call(I,R)),E.current!==null&&(window.cancelAnimationFrame(E.current),E.current=null),N.current!==null&&(W(N.current),N.current=null),document.removeEventListener("pointermove",F),document.removeEventListener("pointerup",Q),document.removeEventListener("pointercancel",Q),I.removeEventListener("lostpointercapture",q),window.removeEventListener("blur",ee),document.body.style.cursor="",document.body.style.userSelect="",B.current=null},Q=()=>{V()},q=()=>{V()},ee=()=>{V()};document.body.style.cursor=i==="horizontal"?"col-resize":"row-resize",document.body.style.userSelect="none",B.current=V,document.addEventListener("pointermove",F),document.addEventListener("pointerup",Q),document.addEventListener("pointercancel",Q),I.addEventListener("lostpointercapture",q),window.addEventListener("blur",ee)},[f,r,n,i,a,l,d,g,b,W]);return y.useEffect(()=>{!s||typeof window>"u"||!g&&!b&&window.localStorage.setItem(s,String(f))},[f,s,g,b]),{size:f,collapsed:g,maxCollapsed:b,onPointerDown:U,isDragging:C,restore:P,collapse:D}}function x1({text:e,query:r}){if(!r)return c.jsx(c.Fragment,{children:e});const n=e.toLowerCase(),i=r.toLowerCase(),s=[];let o=0,a=n.indexOf(i,o);for(;a!==-1;)a>o&&s.push(e.slice(o,a)),s.push(c.jsx("span",{className:"bg-yellow-300/40 dark:bg-yellow-500/30 text-foreground rounded-sm px-px",children:e.slice(a,a+r.length)},a)),o=a+r.length,a=n.indexOf(i,o);return o<e.length&&s.push(e.slice(o)),c.jsx(c.Fragment,{children:s})}const rH=y.memo(function e({node:r,depth:n,activeFilePath:i,expandedDirs:s,onToggleDir:o,onSelectFile:a,onContextFile:l,onTreeContextMenu:d,onMoveNode:u,onMobilePointerStart:f,isMobile:p,normStatusMap:g,dirChangesSet:v,mobileDragTargetPath:b}){var B;const _=p?6+n*12:8+n*14,[S,k]=y.useState(!1),C=y.useCallback(P=>{const D=P.getBoundingClientRect();d(r,D.right-8,D.bottom+4)},[r,d]),j=y.useCallback(P=>{P.stopPropagation(),P.pointerType!=="mouse"&&(P.preventDefault(),C(P.currentTarget))},[C]),E=y.useCallback(P=>{P.preventDefault(),P.stopPropagation(),C(P.currentTarget)},[C]);if(r.kind==="dir"){const P=s.has(r.path),D=r.childrenLoading,W=v?SKe(r.path,v):!1;return c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:`group flex items-center gap-1.5 rounded px-1 cursor-pointer hover:bg-muted active:bg-muted ${p?"py-2 text-sm":"py-1 [font-size:0.9rem]"} ${S||b===r.path?"bg-primary/15 ring-1 ring-primary/40":""}`,style:{paddingLeft:_},"data-tree-path":r.path,"data-tree-drop-dir":r.path,onClick:()=>o(r),onContextMenu:U=>{U.preventDefault(),U.stopPropagation(),d(r,U.clientX,U.clientY)},onPointerDown:U=>f==null?void 0:f(r,U),onDragOver:U=>{U.dataTransfer.types.includes("text/jait-tree-node")&&(U.preventDefault(),U.dataTransfer.dropEffect="move",k(!0))},onDragEnter:U=>{U.dataTransfer.types.includes("text/jait-tree-node")&&(U.preventDefault(),k(!0))},onDragLeave:()=>k(!1),onDrop:U=>{k(!1);const H=U.dataTransfer.getData("text/jait-tree-node");if(!H)return;U.preventDefault(),U.stopPropagation();const R=JSON.parse(H);R.path!==r.path&&u(R.path,r.path)},draggable:!p,onDragStart:U=>{const H=JSON.stringify({path:r.path,name:r.name,kind:"dir"});U.dataTransfer.setData("text/jait-tree-node",H),U.dataTransfer.setData("text/jait-file",JSON.stringify({path:r.path,name:r.name})),U.dataTransfer.effectAllowed="copyMove"},children:[D?c.jsx(ir,{className:`${p?"h-4 w-4":"h-3 w-3"} shrink-0 text-muted-foreground animate-spin`}):c.jsx(ko,{className:`${p?"h-4 w-4":"h-3 w-3"} shrink-0 text-muted-foreground transition-transform duration-150 ${P?"rotate-90":""}`}),c.jsx(Oj,{name:r.name,open:P,className:`${p?"h-4 w-4":"h-3.5 w-3.5"} shrink-0`}),c.jsx("span",{className:`truncate flex-1 ${W?"text-yellow-600 dark:text-yellow-400":""}`,children:r.name}),W&&c.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-yellow-500 shrink-0",title:"Contains modified files"}),p&&c.jsx("button",{type:"button",className:"rounded p-2 hover:bg-background touch-manipulation",onPointerDown:j,onClick:E,title:"More actions",children:c.jsx(t5,{className:"h-3.5 w-3.5"})}),!p&&c.jsx("button",{type:"button",className:"opacity-0 group-hover:opacity-100 p-0.5 rounded hover:bg-background",onClick:U=>{U.stopPropagation(),l(r)},title:"Add to chat",children:c.jsx(Ho,{className:"h-3 w-3"})})]}),P&&((B=r.children)==null?void 0:B.map(U=>c.jsx(e,{node:U,depth:n+1,activeFilePath:i,expandedDirs:s,onToggleDir:o,onSelectFile:a,onContextFile:l,onTreeContextMenu:d,onMoveNode:u,onMobilePointerStart:f,isMobile:p,normStatusMap:g,dirChangesSet:v,mobileDragTargetPath:b},U.path)))]})}const N=i===r.path,A=r.path.replace(/\\/g,"/"),M=(g==null?void 0:g.get(r.name))??(g==null?void 0:g.get(r.path))??(g==null?void 0:g.get(A));return c.jsxs("div",{className:`group flex items-center gap-1.5 rounded px-1 cursor-pointer ${p?"py-2 text-sm":"py-1 [font-size:0.9rem]"} ${N?"bg-primary/15 text-foreground":"hover:bg-muted active:bg-muted"}`,style:{paddingLeft:_+(p?12:14)},"data-tree-path":r.path,onClick:()=>a(r),onContextMenu:P=>{P.preventDefault(),P.stopPropagation(),d(r,P.clientX,P.clientY)},onPointerDown:P=>f==null?void 0:f(r,P),draggable:!p,onDragStart:P=>{P.dataTransfer.setData("text/jait-file",JSON.stringify({path:r.path,name:r.name})),P.dataTransfer.setData("text/jait-tree-node",JSON.stringify({path:r.path,name:r.name,kind:"file"})),P.dataTransfer.effectAllowed="copyMove"},children:[c.jsx($o,{filename:r.name,className:`${p?"h-4 w-4":"h-3.5 w-3.5"}`}),c.jsx("span",{className:`truncate flex-1 ${M==="D"?"line-through text-muted-foreground":""}`,title:r.path,children:r.name}),M&&c.jsx(g_,{status:M}),p?c.jsx("button",{type:"button",className:"rounded p-2 hover:bg-background touch-manipulation",onPointerDown:j,onClick:E,title:"More actions",children:c.jsx(t5,{className:"h-3.5 w-3.5"})}):c.jsx("button",{type:"button",className:"opacity-0 group-hover:opacity-100 p-0.5 rounded hover:bg-background",onClick:P=>{P.stopPropagation(),l(r)},title:"Add to chat",children:c.jsx(Ho,{className:"h-3 w-3"})})]})}),nH=y.forwardRef(function({files:r,activeFileId:n,onActiveFileChange:i,onFileDrop:s,onReferenceFile:o,onReferenceSelection:a,onAvailableFilesChange:l,autoOpenRemotePath:d,surfaceId:u,isMobile:f,showTree:p=!0,showEditor:g=!0,onToggleTree:v,onToggleEditor:b,onReferencePreviewElement:_,treeTab:S,onTreeTabChange:k,changedPaths:C,fsWatcherVersion:j,fsWatcherPayload:E,sourceControlRefreshSignal:N,savedTabsState:A,stateReady:M,onTabsStateChange:B,onApplyDiff:P,provider:D,cliModel:W,previewRequest:U,onPreviewOpenChange:H,previewSessionId:R,previewToken:I,previewWorkspaceRoot:L,previewInitialTarget:z,architectureDiagram:G,architectureGenerating:X,architectureRequest:F,onArchitectureOpenChange:V,onGenerateArchitecture:Q,onArchitectureRenderResult:q,onCollapsedChange:ee,onMaxCollapsedChange:ne,restoreRef:le},de){var cc,Qa,gs,eh,wg,Lp,Sg,kg,Di,pf,uc;const te=iy(),ie=doe(),pe=Ij(),be=y.useRef(null),[me,Je]=y.useState(null),[ce,Ge]=y.useState(!1),[Xe,Le]=y.useState(null),je=y.useRef(null),Qe=y.useRef(null),kt=304,Vt=310,Re=200,Ze=typeof window<"u"?window.innerWidth:1200,ft=Math.max(400,Ze-kt-Vt),It=Math.max(ft,Ze-kt),Se=ft,ke=tH(Se,400,ft,"horizontal","workspacePanelWidth",{snapCollapse:!0,snapMaxCollapse:!0,snapMaxSize:It,minStoredSize:Se});y.useLayoutEffect(()=>{ee==null||ee(ke.collapsed)},[ke.collapsed,ee]),y.useLayoutEffect(()=>{ne==null||ne(ke.maxCollapsed)},[ke.maxCollapsed,ne]),y.useEffect(()=>{le&&(le.current=ke.restore)},[le,ke.restore]);const Et=Math.max(240,ke.size-Re),St=tH(260,240,Et,"horizontal","workspaceTreePaneWidth",{snapCollapse:!0}),[Ne,lt]=y.useState([]),[$e,it]=y.useState(()=>new Set),[Ct,Ie]=y.useState(null),[Ke,st]=y.useState(null),[gt,Nt]=y.useState("plaintext"),[ct,ut]=y.useState(null),[zt,Pt]=y.useState(!1),ot=y.useRef(null),[Bt,Zt]=y.useState(0),et=y.useCallback(()=>Zt(K=>K+1),[]),Qt=y.useRef(null),[Xt,sn]=y.useState(!1),[rt,nt]=y.useState(null),[$t,sr]=y.useState(!1),[_t,nr]=y.useState([]),tn=y.useRef(0),Gr=y.useMemo(()=>{if(!rt)return new Map;const K=new Map;for(const se of rt.index.files)K.set(se.path,se.status??"M");for(const se of rt.workingTree.files)K.set(se.path,se.status??"M");return K},[rt]),At=y.useMemo(()=>wKe(Gr),[Gr]),pt=y.useMemo(()=>kKe(Gr),[Gr]),[Ln,wr]=y.useState("files"),li=S??Ln,ds=y.useCallback(K=>{wr(K),k==null||k(K)},[k]);y.useEffect(()=>{S&&wr(S)},[S]);const[Ls,Ot]=y.useState("list"),[ye,Tt]=y.useState(new Set),[Wt,dr]=y.useState(null),[Oe,Be]=y.useState(!1),[Ut,pr]=y.useState(""),[rr,Ur]=y.useState(!1),[dt,Mr]=y.useState(!1),[ur,Tr]=y.useState(null),[Pr,Xn]=y.useState(()=>gKe()),[zr]=y.useState(()=>yKe()),Bn=y.useRef(dt),za=y.useRef($t),[Kr,dn]=y.useState([]),[vn,Pi]=y.useState(null),ze=y.useMemo(()=>Kr.find(K=>K.id===vn)??null,[Kr,vn]),ws=Mb(ze),Ou=!!ze,Jh=p&&!Xt&&!ke.collapsed&&!St.collapsed,Ru=(g||Xt)&&!ke.collapsed,yi=y.useCallback(()=>{!g&&b&&b()},[b,g]);y.useEffect(()=>{ze||sn(!1)},[ze]);const[Ic,ua]=y.useState(null),[Hi,Hd]=y.useState(null),[er,Gn]=y.useState(null),[No,Qh]=y.useState(null),Wd=y.useRef(null),[si,Wi]=y.useState(null),[Mu,Bc]=y.useState(""),[Ui,Qi]=y.useState(null),[Cl,Fa]=y.useState(""),[Tn,Ss]=y.useState(null),[pi,da]=y.useState(null),Vs=y.useRef(null),ha=y.useRef(null),jl=y.useRef(null),Vo=y.useRef(null),zc=y.useRef(!1),fa=y.useCallback(()=>zc.current?(zc.current=!1,!0):!1,[]),Ha=y.useCallback(()=>{ha.current!==null&&(window.clearTimeout(ha.current),ha.current=null),jl.current!==null&&(window.clearTimeout(jl.current),jl.current=null)},[]),[ks,ci]=y.useState(""),[Li,ef]=y.useState("files"),[zn,qs]=y.useState(null),[To,tc]=y.useState(!1),rc=y.useRef(null),[Ft,Wa]=y.useState(null),[Ud,tf]=y.useState((z==null?void 0:z.trim())||""),[rf,nf]=y.useState(""),[bp,lx]=y.useState(""),[_p,Cs]=y.useState(null),[io,Rt]=y.useState(null),[wp,Pu]=y.useState(!1),[cx,nc]=y.useState(!1),[fg,hs]=y.useState(!1),[Eo,by]=y.useState("controls"),[Ua,Sp]=y.useState(null),[fs,sf]=y.useState(""),[kp,qo]=y.useState(!1),[Va,pg]=y.useState(null),_y=y.useRef(null),wy=y.useRef(null),wn=y.useMemo(()=>Kr.find(K=>K.type==="preview")??null,[Kr]),yt=y.useMemo(()=>(Ft==null?void 0:Ft.browserEvents.filter(K=>K.type==="console"))??[],[Ft]),Vi=y.useMemo(()=>(Ft==null?void 0:Ft.browserEvents.filter(K=>K.type==="pageerror"||K.type==="requestfailed"||K.type==="response"&&(K.status??0)>=400))??[],[Ft]),Un=hKe(R),qa=y.useMemo(()=>{var K;return((K=Ft==null?void 0:Ft.remoteBrowser)==null?void 0:K.novncUrl)??(wn==null?void 0:wn.previewSrc)??F3(Ft==null?void 0:Ft.url)??F3(wn==null?void 0:wn.previewTarget)??null},[wn==null?void 0:wn.previewSrc,wn==null?void 0:wn.previewTarget,(cc=Ft==null?void 0:Ft.remoteBrowser)==null?void 0:cc.novncUrl,Ft==null?void 0:Ft.url]),mg=y.useRef(null),of=y.useRef(!1),Cp=y.useRef(!1),Nl=y.useRef(""),ic=y.useRef(null),Sy=y.useRef(null),Tl=y.useCallback((K,se=!1)=>{const re=Kr.find(ue=>ue.type==="preview")??null,fe=K(re);dn(ue=>{const Me=ue.findIndex(Ae=>Ae.type==="preview");if(!fe)return Me<0?ue:ue.filter(Ae=>Ae.type!=="preview");if(Me>=0){const Ae=ue[Me];if(Ae.label===fe.label&&Ae.previewTarget===fe.previewTarget&&Ae.previewSrc===fe.previewSrc&&Ae.path===fe.path)return ue;const qe=[...ue];return qe[Me]=fe,qe}return[...ue,fe]}),se&&fe&&(Pi(fe.id),dr(null),Ie(null),st(null),ut(fe.previewTarget??fe.path),Nt("plaintext"),i(""))},[i,Kr]),Vd=y.useCallback(async K=>{if(Un&&I)try{await fetch(`${Ta}/api/preview/stop`,{method:"POST",headers:Pb(I),body:JSON.stringify({sessionId:Un})})}catch{}Wa(null),Pu(!1),nc(!1),Cs(null),K&&Tl(se=>se?{...se,label:se.previewTarget||"Preview",previewSrc:null,previewMode:null}:{id:"preview",type:"preview",path:"__preview__",label:"Preview",previewSrc:null,previewMode:null})},[Un,I,Tl]),qd=y.useCallback(async()=>{if(!Un||!I)return null;try{const K=await fetch(`${Ta}/api/preview/session/${Un}`,{headers:Pb(I)});if(!K.ok)return Wa(null),null;const se=await K.json();return Wa(re=>I3(re,se.session)?re:se.session),se.session}catch{return null}},[Un,I]),Lu=y.useCallback(async K=>{if(!Un||!I)return null;qo(!0),pg(null);try{const se=new URLSearchParams;K!=null&&K.trim()&&se.set("selector",K.trim());const re=await fetch(`${Ta}/api/preview/inspect/${Un}${se.size?`?${se.toString()}`:""}`,{headers:Pb(I)}),fe=await re.json().catch(()=>({}));if(!re.ok)throw new Error(fe.error||"Failed to inspect preview");if(fe.suppressed){const ue={status:(Ft==null?void 0:Ft.status)??"ready",url:(Ft==null?void 0:Ft.url)??null,page:null,snapshot:null,target:null,captureSuppressed:!0,suppressionReason:fe.reason};return Sp(ue),ue}return Sp(fe.inspect??null),fe.inspect??null}catch(se){return pg(se instanceof Error?se.message:"Failed to inspect preview"),null}finally{qo(!1)}},[Un,Ft==null?void 0:Ft.status,Ft==null?void 0:Ft.url,I]);y.useEffect(()=>{if(!vn)return;const K=Qe.current;if(!K)return;const se=K.querySelector(`[data-tab-id="${CSS.escape(vn)}"]`);if(!se)return;const{scrollLeft:re,clientWidth:fe}=K,ue=se.offsetLeft,Me=ue+se.offsetWidth;ue<re?K.scrollLeft=ue:Me>re+fe&&(K.scrollLeft=Me-fe)},[vn,Kr.length]),y.useEffect(()=>{const K=z==null?void 0:z.trim();K&&tf(K)},[z]),y.useEffect(()=>{qd()},[qd]),y.useEffect(()=>{if(Un)return fKe(K=>{K.sessionId===Un&&Wa(se=>I3(se,K)?se:K)})},[Un]),y.useEffect(()=>{var K;Eo==="logs"&&((K=_y.current)==null||K.scrollIntoView({behavior:"smooth"}))},[Eo,Ft==null?void 0:Ft.logs.length]),y.useEffect(()=>{var K;Eo==="console"&&((K=wy.current)==null||K.scrollIntoView({behavior:"smooth"}))},[Eo,yt.length]),y.useEffect(()=>{Eo==="inspect"&&(!wn&&!Ft||Lu(fs))},[wn,Lu,Ft,fs,Eo]),y.useEffect(()=>{Ft&&Tl(K=>{var re;if(!K)return K;const se=Ft.target??K.previewTarget;return{...K,label:QF(se??Ft.url),previewTarget:se,previewSrc:((re=Ft.remoteBrowser)==null?void 0:re.novncUrl)??F3(Ft.url??se),previewMode:"managed"}})},[Ft,Tl]),y.useEffect(()=>{if(!me||!A||A.remoteRoot!==me||mg.current===me||(mg.current=me,Cp.current=A.activePreview===!0,A.activePreview&&Pi("preview"),A.tabs.length===0))return;let K=!1;return of.current=!0,(async()=>{var Me;const re=[];for(const Ae of A.tabs)try{const qe=await sd(Ae.path,u);if(K)return;re.push({id:`file:${Ae.path}`,type:"file",path:Ae.path,label:Ae.label||(Ae.path.split("/").pop()??Ae.path),content:qe,savedContent:qe,language:Sa(Ae.path)})}catch{}if(K||re.length===0)return;dn(Ae=>{const qe=new Set(Ae.map(Gt=>Gt.id)),Mt=re.filter(Gt=>!qe.has(Gt.id));return Mt.length>0?[...Ae,...Mt]:Ae});const fe=A.activePath?`file:${A.activePath}`:null,ue=fe&&re.some(Ae=>Ae.id===fe)?fe:((Me=re[re.length-1])==null?void 0:Me.id)??null;if(ue&&!A.activePreview){const Ae=re.find(qe=>qe.id===ue);Pi(ue),Ae&&(Ie(Ae.path),ut(Ae.path),Nt(Ae.language??"plaintext"),st(Ae.content??null),i(""))}})().finally(()=>{of.current=!1}),()=>{K=!0,of.current=!1}},[me,A,u,i]),y.useEffect(()=>{if(!B||of.current||!M)return;const K=Kr.some(qe=>qe.type==="preview");if(Cp.current){if(!K||vn!=="preview")return;Cp.current=!1}if(!me){Nl.current!==""&&(Nl.current="",B(null));return}const se=Kr.filter(qe=>qe.type==="file"&&qe.id.startsWith("file:")).map(qe=>({path:qe.path,label:qe.label})),re=ze&&ze.type==="file"&&ze.id.startsWith("file:")?ze.path:null,fe=Kr.find(qe=>qe.type==="preview")??null,ue=vn==="preview"&&!!eH(fe==null?void 0:fe.previewTarget),Me={remoteRoot:me,tabs:se,activePath:re,activePreview:ue},Ae=JSON.stringify(Me);Ae!==Nl.current&&(Nl.current=Ae,B(Me))},[Kr,ze,vn,me,M,B]);const $u=y.useRef("");y.useEffect(()=>{if(!H)return;const K=Kr.find(ue=>ue.type==="preview")??null,se=K!==null,re=eH(K==null?void 0:K.previewTarget),fe=`${se}:${re??""}`;fe!==$u.current&&($u.current=fe,H({open:se,target:re}))},[Kr,H]),y.useEffect(()=>{V&&V(Kr.some(K=>K.type==="architecture"))},[Kr,V]),y.useEffect(()=>{if(!Hi)return;const K=()=>Hd(null);return window.addEventListener("pointerdown",K),()=>window.removeEventListener("pointerdown",K)},[Hi]);const Lr=y.useCallback(async()=>{if(!me)return;const K=++tn.current;sr(!0);try{const[se,re]=await Promise.all([sl.status(me),sl.fileDiffs(me).catch(()=>[])]);K===tn.current&&(nt(se),nr(re))}catch{K===tn.current&&(nt(null),nr([]))}finally{K===tn.current&&sr(!1)}},[me]),El=y.useCallback(K=>{Xn(K),!(typeof window>"u")&&window.localStorage.setItem(moe,K===!1?"false":K==="all"?"all":"true")},[]),Gd=y.useCallback(K=>{El(K==="all"?"all":K==="true")},[El]);y.useEffect(()=>{Bn.current=dt},[dt]),y.useEffect(()=>{za.current=$t},[$t]),y.useEffect(()=>{me&&Lr()},[me,j,Lr]);const gn=y.useRef(N??0);y.useEffect(()=>{N!=null&&N!==gn.current&&(gn.current=N,me&&Lr())},[N,me,Lr]),y.useEffect(()=>{if(!me||Pr===!1)return;let K=!1,se=null;const re=async()=>{for(;!K;){const ue=typeof document<"u"&&document.visibilityState==="visible"&&document.hasFocus();if(!Bn.current&&!za.current&&ue)return!0;await new Promise(Me=>{se=window.setTimeout(Me,1e3)})}return!1};return(async()=>{for(;!K;){if(!await re()||K)return;try{await sl.fetch(me,Pr==="all"),await Lr()}catch{}if(K)return;await new Promise(Me=>{se=window.setTimeout(Me,zr*1e3)})}})(),()=>{K=!0,se!==null&&window.clearTimeout(se)}},[me,Pr,zr,Lr]);const He=y.useRef(new Set);y.useEffect(()=>{if(!(C!=null&&C.length)){He.current=new Set;return}const K=He.current,se=C.filter(re=>!K.has(re));if(He.current=new Set(C),se.length!==0){et();for(const re of se){const fe=Kr.find(ue=>ue.type==="file"&&Ca(ue.path)===Ca(re));fe&&Ol(fe.id,fe.path)}me&&Lr()}},[C]);const Al=y.useRef(j??0);y.useEffect(()=>{if(j==null||j===Al.current)return;Al.current=j,(re=>{for(const fe of re)fe.kind==="dir"&&fe.children&&$e.has(fe.path)&&(fe.children=null)})(Ne),et(),(async()=>{const re=[...$e];for(const fe of re){const ue=Ae=>{for(const qe of Ae){if(qe.kind==="dir"&&qe.path===fe)return qe;if(qe.kind==="dir"&&qe.children){const Mt=ue(qe.children);if(Mt)return Mt}}return null},Me=ue(Ne);if(Me&&Me.children===null){const Ae=Me.handle?await B3(Me.handle,Me.path):await bc(Me.path,u);Me.children=Ae}}et()})().catch(()=>{}),Ct&&me&&cKe(E,me,Ct)&&sd(Ct,u).then(re=>{st(re),dn(fe=>fe.map(ue=>ue.id!==`file:${Ct}`||ue.isDirty?ue:{...ue,content:re,savedContent:re,saveError:null}))}).catch(()=>{})},[j]),y.useEffect(()=>{if(!Ct||!me)return;const K=Ae=>Ae.replace(/\\/g,"/"),se=K(me).replace(/\/$/,""),re=K(Ct);if(!re.startsWith(se+"/"))return;const fe=re.slice(se.length+1).split("/");if(fe.length<2){requestAnimationFrame(()=>{const Ae=document.querySelector(`[data-tree-path="${CSS.escape(Ct)}"]`);Ae==null||Ae.scrollIntoView({block:"nearest",behavior:"smooth"})});return}const ue=fe.slice(0,-1);let Me=!1;return(async()=>{let Ae=se,qe=Ne;const Mt=[];for(const Gt of ue){Ae=Ae+"/"+Gt;const cr=qe.find(mr=>mr.kind==="dir"&&K(mr.path)===Ae);if(!cr)break;if(Mt.push(cr.path),cr.children===null){cr.childrenLoading=!0,et();const mr=await bc(cr.path,u);if(Me)return;cr.children=mr,cr.childrenLoading=!1,et()}qe=cr.children}Me||(Mt.length&&it(Gt=>{const cr=new Set(Gt);for(const mr of Mt)cr.add(mr);return cr}),requestAnimationFrame(()=>{const Gt=document.querySelector(`[data-tree-path="${CSS.escape(Ct)}"]`);Gt==null||Gt.scrollIntoView({block:"nearest",behavior:"smooth"})}))})(),()=>{Me=!0}},[Ct]);const js=y.useRef(null);y.useEffect(()=>{js.current=null},[Ct]),y.useEffect(()=>{if(!Ct||!me)return;const K=Ct,se=u;let re=!1;js.current||ZF(K,se).then(ue=>{!re&&ue&&(js.current=ue)});const fe=setInterval(async()=>{if(re||typeof document<"u"&&document.hidden)return;const ue=await ZF(K,se);if(!(re||!ue))if(js.current&&ue!==js.current){js.current=ue,et();try{const Me=await sd(K,se);re||(st(Me),dn(Ae=>Ae.map(qe=>qe.id!==`file:${K}`||qe.isDirty?qe:{...qe,content:Me,savedContent:Me,saveError:null})))}catch{}}else js.current||(js.current=ue)},2e3);return()=>{re=!0,clearInterval(fe)}},[Ct,me,u]),y.useEffect(()=>{if(!l){Qt.current=null;return}const K=[],se=ue=>{for(const Me of ue)Me.kind==="file"?K.push({path:Me.path,name:Me.name,kind:"file"}):Me.kind==="dir"&&(K.push({path:Me.path,name:Me.name,kind:"dir"}),Me.children&&se(Me.children))};se(Ne);for(const ue of r)K.some(Me=>Me.path===ue.path)||K.push({path:ue.path,name:ue.name});const re=vKe(K),fe=Qt.current;(fe==null?void 0:fe.callback)===l&&fe.signature===re||(Qt.current={callback:l,signature:re},l(K))},[Ne,Bt,r,l]);const Kd=y.useMemo(()=>r.find(K=>K.id===n)??null,[r,n]),jp=y.useCallback(K=>{const se=re=>{for(const fe of re){if(fe.kind==="file"&&fe.path===K)return fe;if(fe.kind==="dir"&&fe.children){const ue=se(fe.children);if(ue)return ue}}return null};return se(Ne)},[Ne]),Du=y.useCallback((K,se)=>{dn(re=>re.map(fe=>fe.id===K?{...fe,content:se,modifiedContent:se,savedContent:se,isDirty:!1,isSaving:!1,saveError:null}:fe))},[]),gg=y.useCallback((K,se)=>{dn(re=>re.map(fe=>fe.id===K?{...fe,originalContent:se,modifiedContent:fe.content??fe.modifiedContent??null}:fe))},[]),Ol=y.useCallback(async(K,se)=>{if(!u)return;const re=await bKe(se,u).catch(()=>null);gg(K,re)},[gg,u]),yg=y.useCallback((K,se)=>{dn(re=>re.map(fe=>{if(fe.id!==K||!Mb(fe))return fe;const ue=se??"",Me=fe.savedContent??"";return{...fe,content:ue,modifiedContent:ue,isDirty:ue!==Me,saveError:null}})),vn===K&&Ct&&st(se??"")},[Ct,vn]),Np=y.useCallback(async K=>{const se=Kr.find(fe=>fe.id===K);if(!se||!Mb(se))return;const re=se.content??"";dn(fe=>fe.map(ue=>ue.id===K?{...ue,isSaving:!0,saveError:null}:ue));try{if(me)await xKe(se.path,re,u);else{const fe=jp(se.path);if(!(fe!=null&&fe.handle))throw new Error("Local file handle is unavailable");const ue=await fe.handle.createWritable();await ue.write(re),await ue.close()}dn(fe=>fe.map(ue=>ue.id===K?{...ue,content:re,savedContent:re,isDirty:!1,isSaving:!1,saveError:null}:ue)),vn===K&&st(re),et(),me&&Lr()}catch(fe){const ue=fe instanceof Error?fe.message:"Failed to save file";dn(Me=>Me.map(Ae=>Ae.id===K?{...Ae,isSaving:!1,saveError:ue}:Ae))}},[vn,et,Lr,jp,Kr,me,u]);y.useEffect(()=>{const K=se=>{!(se.metaKey||se.ctrlKey)||se.key.toLowerCase()!=="s"||!ws||!vn||(se.preventDefault(),Np(vn))};return window.addEventListener("keydown",K),()=>window.removeEventListener("keydown",K)},[ws,vn,Np]);const Fn=(ze==null?void 0:ze.type)==="file"?{path:ze.path,language:ze.language??"plaintext",content:ze.content??""}:Ct?{path:ct??"",language:gt,content:Ke??""}:Kd?{path:Kd.path,language:Kd.language,content:Kd.content}:null,af=()=>c.jsxs("div",{className:"absolute inset-y-0 right-0 z-20 flex w-full max-w-[360px] flex-col border-l bg-background/95 shadow-2xl backdrop-blur",children:[c.jsxs("div",{className:"flex items-center gap-2 border-b px-3 py-2 shrink-0",children:[c.jsxs("div",{className:"min-w-0 flex-1 overflow-hidden",children:[c.jsxs("div",{className:"flex items-center gap-2 whitespace-nowrap overflow-hidden",children:[c.jsx(NN,{className:"h-4 w-4 text-muted-foreground shrink-0"}),c.jsx("span",{className:"text-sm font-medium truncate",children:"Preview Controls"}),Ft&&c.jsx("span",{className:"rounded bg-muted px-2 py-0.5 text-2xs uppercase tracking-wide text-muted-foreground",children:Ft.status})]}),wn!=null&&wn.label?c.jsx("div",{className:"truncate text-xs text-muted-foreground",title:wn.label,children:wn.label}):null]}),c.jsx("button",{type:"button",className:"rounded p-1.5 text-muted-foreground hover:bg-muted hover:text-foreground",onClick:()=>hs(!1),title:"Hide preview controls",children:c.jsx(ti,{className:"h-3.5 w-3.5"})})]}),c.jsx("div",{className:"flex items-center gap-1 border-b px-2 py-1.5 text-xs",children:["controls","inspect","logs","console","issues","metrics"].map(K=>c.jsx("button",{type:"button",className:`rounded px-2 py-1 transition-colors ${Eo===K?"bg-muted text-foreground":"text-muted-foreground hover:text-foreground"}`,onClick:()=>by(K),children:K==="controls"?"Controls":K==="inspect"?"Inspect":K==="logs"?"Logs":K==="console"?`Console${yt.length?` (${yt.length})`:""}`:K==="issues"?`Issues${Vi.length?` (${Vi.length})`:""}`:"Metrics"},K))}),Eo==="controls"?c.jsxs("div",{className:"flex-1 space-y-3 overflow-auto p-3",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(Vn,{value:Ud,onChange:K=>tf(K.target.value),placeholder:"Optional target override such as 3000 or http://127.0.0.1:3000/",className:"h-8"}),c.jsx(Vn,{value:rf,onChange:K=>nf(K.target.value),placeholder:"Optional command override",className:"h-8",disabled:!L}),c.jsx(Vn,{value:bp,onChange:K=>lx(K.target.value),placeholder:"Preferred port",className:"h-8",disabled:!L}),c.jsxs(_e,{type:"button",size:"sm",className:"h-8 w-full",onClick:Ns,disabled:wp,children:[c.jsx(J4,{className:"mr-1 h-3 w-3"}),"Start Live Preview"]})]}),c.jsxs("div",{className:"flex flex-wrap gap-2",children:[c.jsxs(_e,{type:"button",variant:"ghost",size:"sm",className:"h-8 px-2 text-xs",onClick:Ya,children:[c.jsx(sa,{className:"mr-1 h-3 w-3"}),"Refresh"]}),Ft&&c.jsxs(c.Fragment,{children:[c.jsxs(_e,{type:"button",variant:"ghost",size:"sm",className:"h-8 px-2 text-xs",onClick:()=>{Wu()},disabled:wp,children:[c.jsx(sa,{className:"mr-1 h-3 w-3"}),"Restart"]}),c.jsxs(_e,{type:"button",variant:"ghost",size:"sm",className:"h-8 px-2 text-xs",onClick:()=>{Uu()},disabled:wp,children:[c.jsx(av,{className:"mr-1 h-3 w-3"}),"Stop"]})]}),Vu&&c.jsx("a",{href:Vu,target:"_blank",rel:"noreferrer",className:"inline-flex",children:c.jsxs(_e,{type:"button",variant:"ghost",size:"sm",className:"h-8 px-2 text-xs",children:[c.jsx(sp,{className:"mr-1 h-3 w-3"}),"Open"]})})]}),L?c.jsxs("div",{className:"rounded border bg-muted/30 px-2 py-1.5 text-xs text-muted-foreground",children:["Workspace: ",c.jsx("code",{children:L})]}):null,Ft!=null&&Ft.remoteBrowser?c.jsxs("div",{className:"rounded border bg-muted/30 px-2 py-1.5 text-xs text-muted-foreground",children:["Live view: ",c.jsx("code",{children:Ft.remoteBrowser.novncUrl})]}):null,Ft!=null&&Ft.lastError?c.jsxs("div",{className:"flex items-start gap-2 rounded border border-destructive/30 bg-destructive/5 px-2 py-1.5 text-xs text-destructive",children:[c.jsx(Oa,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),c.jsx("span",{children:Ft.lastError})]}):null,_p?c.jsxs("div",{className:"flex items-start gap-2 rounded border border-destructive/30 bg-destructive/5 px-2 py-1.5 text-xs text-destructive",children:[c.jsx(Oa,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),c.jsx("span",{children:_p})]}):null,io?c.jsxs("div",{className:"flex items-start gap-2 rounded border border-amber-500/30 bg-amber-500/5 px-2 py-1.5 text-xs text-amber-700",children:[c.jsx(Oa,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),c.jsx("span",{children:io})]}):null]}):Eo==="inspect"?c.jsxs("div",{className:"flex-1 space-y-3 overflow-auto p-3 text-xs",children:[c.jsxs("div",{className:"flex gap-2",children:[c.jsx(Vn,{value:fs,onChange:K=>sf(K.target.value),placeholder:"Optional selector to diagnose",className:"h-8"}),c.jsxs(_e,{type:"button",variant:"ghost",size:"sm",className:"h-8 px-2 text-xs",onClick:()=>{Lu(fs)},disabled:kp,children:[c.jsx(pl,{className:"mr-1 h-3 w-3"}),"Diagnose"]})]}),c.jsx(uKe,{inspectState:Ua,loading:kp,error:Va,onInsertElementReference:_})]}):Eo==="logs"?c.jsxs("div",{className:"flex-1 overflow-auto bg-zinc-950 px-3 py-2 font-mono text-xs text-zinc-100",children:[Ft!=null&&Ft.logs.length?Ft.logs.map(K=>c.jsxs("div",{className:"mb-1 whitespace-pre-wrap break-words",children:[c.jsxs("span",{className:K.stream==="stderr"?"text-red-400":K.stream==="system"?"text-sky-300":"text-zinc-100",children:["[",K.stream,"]"]})," ",K.text]},K.id)):c.jsx("div",{className:"text-zinc-400",children:"No preview logs yet."}),c.jsx("div",{ref:_y})]}):Eo==="console"?c.jsxs("div",{className:"flex-1 overflow-auto bg-zinc-950 px-3 py-2 font-mono text-xs text-zinc-100",children:[yt.length?yt.map(K=>c.jsxs("div",{className:"mb-1 whitespace-pre-wrap break-words",children:[c.jsxs("span",{className:K.level==="error"?"text-red-400":K.level==="warning"||K.level==="warn"?"text-yellow-400":K.level==="info"?"text-sky-300":"text-zinc-300",children:["[",K.level??"log","]"]})," ",K.text]},K.id)):c.jsx("div",{className:"text-zinc-400",children:"No console messages yet."}),c.jsx("div",{ref:wy})]}):Eo==="metrics"?c.jsx("div",{className:"flex-1 overflow-auto p-3 text-xs",children:c.jsx(poe,{metrics:Ft==null?void 0:Ft.metrics})}):c.jsx("div",{className:"flex-1 overflow-auto p-3 text-xs",children:Vi.length?Vi.map(K=>c.jsxs("div",{className:"mb-2 rounded border bg-background px-2 py-1.5",children:[c.jsxs("div",{className:"font-medium",children:[K.type,K.status?` (${K.status})`:"",K.level?` · ${K.level}`:""]}),K.text?c.jsx("div",{className:"mt-0.5 whitespace-pre-wrap break-words text-muted-foreground",children:K.text}):null,K.url?c.jsxs("div",{className:"mt-0.5 break-all text-xs text-muted-foreground",children:[K.method?`${K.method} `:"",K.url]}):null]},K.id)):c.jsx("div",{className:"flex h-full items-center justify-center text-sm text-muted-foreground",children:"No browser issues captured yet."})})]}),vg=K=>c.jsxs("div",{className:"relative h-full bg-muted/5 overflow-hidden",children:[cx&&c.jsx("div",{className:"absolute inset-x-0 top-0 z-10 h-1 overflow-hidden bg-transparent",children:c.jsx("div",{className:"h-full w-full animate-pulse bg-primary/80"})}),qa?c.jsx(YGe,{source:qa,title:(ze==null?void 0:ze.label)??"Live preview",className:"h-full w-full bg-white",onLoad:()=>nc(!1)},`${qa}:${(ze==null?void 0:ze.version)??0}`):(Ft==null?void 0:Ft.status)==="starting"?c.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center text-sm text-muted-foreground",children:"Starting preview session…"}):(Ft==null?void 0:Ft.status)==="ready"?c.jsxs("div",{className:"flex h-full flex-col items-center justify-center gap-2 px-6 text-center text-sm text-muted-foreground",children:[c.jsx("p",{children:"Preview is running but the VNC viewer could not connect."}),c.jsxs("p",{className:"text-xs",children:["Check that Docker is running and the ",c.jsx("code",{children:"jait/sandbox-browser"})," image is available."]})]}):c.jsx("div",{className:"flex h-full items-center justify-center px-6 text-center text-sm text-muted-foreground",children:K}),fg&&af()]}),Tp=y.useCallback(async K=>{let se=K;if(!se){if(typeof window>"u")return;const fe=window;if(!fe.showDirectoryPicker){window.alert("Directory picker is not supported in this browser.");return}try{se=await fe.showDirectoryPicker()}catch{return}}const re=await B3(se,"");be.current=se,Je(null),lt(re),it(new Set),Ie(null),st(null)},[]),Iu=y.useCallback(async K=>{const se=`${K}::${u??""}`;je.current=se,Ge(!0),Le(null);try{let re;try{re=await bc(K,u)}catch(fe){if(!u)throw fe;re=await bc(K)}be.current=null,Je(K),lt(re),it(new Set),Ie(null),st(null)}catch(re){console.error("Failed to open remote workspace:",re),Je(K),lt([]),Le(re instanceof Error?re.message:"Failed to open workspace")}finally{Ge(!1)}},[u]);y.useEffect(()=>{if(!d){me&&Je(null),je.current=null,Ge(!1),Le(null);return}if(me===d&&Ne.length>0)return;const K=`${d}::${u??""}`;je.current===K&&(ce||me===d)||Iu(d)},[d,Iu,Ne.length,me,ce,u]);const lf=y.useCallback(async K=>{const se=Ae=>{for(const qe of Ae){if(qe.kind==="file"&&qe.path===K)return qe;if(qe.kind==="dir"&&qe.children){const Mt=se(qe.children);if(Mt)return Mt}}return null},re=se(Ne);if(re)try{const Ae=re.handle?await v1(re.handle):await sd(re.path,u);return{id:re.path,name:re.name,path:re.path,content:Ae,language:Sa(re.path)}}catch{return null}if(me)try{const Ae=await sd(K,u),qe=K.split("/").pop()??K;return{id:K,name:qe,path:K,content:Ae,language:Sa(K)}}catch{return null}const fe=be.current;if(!fe)return null;const ue=K.split("/");let Me=fe;try{for(let Gt=0;Gt<ue.length-1;Gt++)Me=await Me.getDirectoryHandle(ue[Gt]);const Ae=await Me.getFileHandle(ue[ue.length-1]),qe=await v1(Ae),Mt=ue[ue.length-1];return{id:K,name:Mt,path:K,content:qe,language:Sa(K)}}catch{return null}},[Ne,me,u]),Ep=y.useCallback(async K=>{const se=Ca(K),re=[],fe=async(mr,Xr)=>{try{const di=Xr?await v1(Xr):await sd(mr,u);return{id:mr,name:mr.split("/").pop()??mr,path:mr,content:di,language:Sa(mr)}}catch{return null}},ue=async(mr,Xr)=>{for await(const di of mr.values()){if(re.length>=YF)return;const Ro=di.name,Dl=Xr?`${Xr}/${Ro}`:Ro;if(di.kind==="directory"){if(V_.has(Ro))continue;await ue(di,Dl);continue}const $p=await fe(Dl,di);$p&&re.push($p)}},Me=async mr=>{const Xr=await bc(mr,u);for(const di of Xr){if(re.length>=YF)return;if(di.kind==="dir"){await Me(di.path);continue}const Ro=await fe(di.path);Ro&&re.push(Ro)}},Ae=mr=>{for(const Xr of mr){if(Ca(Xr.path)===se)return Xr;if(Xr.kind==="dir"&&Xr.children){const di=Ae(Xr.children);if(di)return di}}return null},qe=Ae(Ne);if((qe==null?void 0:qe.kind)==="file"){const mr=await fe(qe.path,qe.handle);return mr?[mr]:[]}if((qe==null?void 0:qe.kind)==="dir")return qe.handle?await ue(qe.handle,qe.path):await Me(qe.path),re;const Mt=await lf(se);if(Mt)return[Mt];if(me){try{await Me(se)}catch{return[]}return re}const Gt=be.current;if(!Gt)return[];const cr=se.split("/").filter(Boolean);try{let mr=Gt;for(const Xr of cr)mr=await mr.getDirectoryHandle(Xr);return await ue(mr,se),re}catch{return[]}},[lf,Ne,me,u]),Ap=y.useCallback(async(K,se,re)=>{if(!K)return[];const fe=[],ue=K.toLowerCase(),Me=qe=>{for(const Mt of qe){if(re!=null&&re.aborted||fe.length>=se)return;Mt.name.toLowerCase().includes(ue)&&fe.push({path:Mt.path,name:Mt.name,kind:Mt.kind==="dir"?"dir":"file"}),Mt.kind==="dir"&&Mt.children&&Me(Mt.children)}};if(Me(Ne),fe.length>=se||re!=null&&re.aborted)return fe;const Ae=be.current;if(Ae&&!me){const qe=async(Mt,Gt)=>{if(re!=null&&re.aborted)return!0;try{for await(const cr of Mt.values()){if(re!=null&&re.aborted||fe.length>=se)return!0;const mr=cr.name,Xr=Gt?`${Gt}/${mr}`:mr;if(cr.kind==="directory"){if(V_.has(mr))continue;if(mr.toLowerCase().includes(ue)&&!fe.some(Ro=>Ro.path===Xr)&&(fe.push({path:Xr,name:mr,kind:"dir"}),fe.length>=se)||await qe(cr,Xr))return!0}else if(mr.toLowerCase().includes(ue)&&!fe.some(di=>di.path===Xr)&&(fe.push({path:Xr,name:mr,kind:"file"}),fe.length>=se))return!0}}catch{}return!1};await qe(Ae,"")}return fe},[Ne,me]),Bu=y.useCallback(async(K,se,re)=>{if(!K.trim())return[];const fe=be.current;return!fe||me?[]:tKe(fe,K,se,re,V_)},[me]),so=y.useCallback(async K=>{const se=Ca(K);yi();const re=me?Ca(me):null,fe=re&&(se===re||se.startsWith(`${re}/`))?se.slice(re.length).replace(/^\/+/,"").split("/").filter(Boolean):se.split("/").filter(Boolean);if(fe.length===0)return!1;let ue=Ne,Me=re??"";const Ae=[];for(const Gt of fe.slice(0,-1)){Me=Me?`${Me}/${Gt}`:Gt;const cr=ue.find(mr=>mr.kind==="dir"&&Ca(mr.path)===Me);if(!cr)return!1;cr.children===null&&(cr.childrenLoading=!0,et(),cr.children=cr.handle?await B3(cr.handle,cr.path):await bc(cr.path,u),cr.childrenLoading=!1,et()),Ae.push(Me),ue=cr.children??[]}Ae.length>0&&it(Gt=>{const cr=new Set(Gt);for(const mr of Ae)cr.add(mr);return cr});const qe=ue.find(Gt=>Gt.kind==="file"&&Ca(Gt.path)===se);if(!qe)return!1;const Mt=`file:${qe.path}`;dn(Gt=>{if(Gt.find(Xr=>Xr.id===Mt))return Gt;const mr={id:Mt,type:"file",path:qe.path,label:qe.name,content:null,savedContent:null,language:Sa(qe.path)};return[...Gt,mr]}),Pi(Mt),i(""),Ie(qe.path),ut(qe.path),Nt(Sa(qe.path)),Pt(!0);try{const Gt=qe.handle?await v1(qe.handle):await sd(qe.path,u);st(Gt),Du(Mt,Gt),Ol(Mt,qe.path)}catch{st("// Failed to read file"),Du(Mt,"// Failed to read file")}return Pt(!1),!0},[et,yi,Ne,Ol,i,me,Du,u]),zu=y.useCallback(async K=>{if($e.has(K.path)){it(re=>{const fe=new Set(re);return fe.delete(K.path),fe});return}if(K.children===null){K.childrenLoading=!0,et();const re=K.handle?await B3(K.handle,K.path):await bc(K.path,u);K.children=re,K.childrenLoading=!1,et()}it(re=>{const fe=new Set(re);return fe.add(K.path),fe})},[$e,et,u]),hr=y.useCallback(K=>{fa()||zu(K)},[fa,zu]),sc=y.useCallback(async K=>{yi();const se=`file:${K.path}`;dn(re=>{if(re.find(Me=>Me.id===se))return re;const ue={id:se,type:"file",path:K.path,label:K.name,content:null,savedContent:null,language:Sa(K.path)};return[...re,ue]}),Pi(se),i(""),Ie(K.path),ut(K.path),Nt(Sa(K.path)),Pt(!0);try{const re=K.handle?await v1(K.handle):await sd(K.path,u);st(re),Du(se,re),Ol(se,K.path)}catch{st("// Failed to read file"),Du(se,"// Failed to read file")}Pt(!1)},[yi,Ol,i,Du,u]),Rl=y.useCallback(K=>{fa()||sc(K)},[fa,sc]),Go=y.useCallback(async K=>{if(K.kind==="dir"){o({id:K.path,name:K.name.endsWith("/")?K.name:`${K.name}/`,path:K.path,content:"",language:"plaintext"});return}try{const se=K.handle?await v1(K.handle):await sd(K.path,u);o({id:K.path,name:K.name,path:K.path,content:se,language:Sa(K.path)})}catch{}},[o,u]),Fu=y.useCallback((K,se,re)=>{Qh(null),Gn({node:K,x:se,y:re})},[]);y.useLayoutEffect(()=>{if(!er){Qh(null);return}const K=()=>{const se=Wd.current;if(!se)return;const re=se.getBoundingClientRect(),fe=8,ue=Math.max(fe,Math.min(er.x,window.innerWidth-re.width-fe)),Me=Math.max(fe,Math.min(er.y,window.innerHeight-re.height-fe));Qh(Ae=>Ae&&Ae.left===ue&&Ae.top===Me?Ae:{left:ue,top:Me})};return K(),window.addEventListener("resize",K),()=>window.removeEventListener("resize",K)},[er]),y.useEffect(()=>{if(!er)return;const K=()=>Gn(null);return window.addEventListener("pointerdown",K),()=>window.removeEventListener("pointerdown",K)},[er]);const Hu=y.useCallback(async(K,se)=>{if(!me)return;const re=Ca(K),fe=Ca(se),ue=Ca(me);if(!(!re||!fe||re===fe)&&!XF(re,fe))try{if(!(await fetch(`${Ta}/api/workspace/move`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({srcPath:re,destDir:fe,surfaceId:u})})).ok)throw new Error("Move failed");const Ae=(cr,mr)=>{for(const Xr of cr){if(Xr.kind==="dir"&&Xr.path===mr)return Xr;if(Xr.kind==="dir"&&Xr.children){const di=Ae(Xr.children,mr);if(di)return di}}return null},qe=fe===ue?null:Ae(Ne,fe);qe&&(qe.children=null,$e.has(qe.path)&&(qe.children=await bc(qe.path,u)));const Mt=re.includes("/")?re.slice(0,re.lastIndexOf("/")):ue,Gt=Mt===ue?null:Ae(Ne,Mt);Gt&&(Gt.children=null,$e.has(Gt.path)&&(Gt.children=await bc(Gt.path,u))),(Mt===ue||fe===ue)&&lt(await bc(me,u)),et(),Lr()}catch{}},[me,u,Ne,$e,et,Lr]),Ga=y.useCallback((K,se)=>{var Me,Ae;if(!f||!me||se.pointerType==="mouse")return;const re=se.target;if(re!=null&&re.closest("button"))return;Ha(),(Ae=(Me=se.currentTarget).setPointerCapture)==null||Ae.call(Me,se.pointerId),Vo.current=se.currentTarget;const fe=se.currentTarget.getBoundingClientRect(),ue={node:K,pointerId:se.pointerId,startX:se.clientX,startY:se.clientY,x:se.clientX,y:se.clientY,ready:!1,active:!1,dropDir:null};Vs.current=ue,da(ue),ha.current=window.setTimeout(()=>{da(qe=>{if(!qe||qe.pointerId!==se.pointerId)return qe;const Mt={...qe,ready:!0};return Vs.current=Mt,Mt}),ha.current=null},180),jl.current=window.setTimeout(()=>{const qe=Vs.current;!qe||qe.pointerId!==se.pointerId||qe.active||(zc.current=!0,Ha(),H3(Vo.current,se.pointerId),Vo.current=null,Vs.current=null,da(null),Fu(K,fe.right-8,fe.top+12))},350)},[Ha,Fu,f,me]);y.useEffect(()=>{if(!pi||!me)return;const K=(Me,Ae)=>{var cr;const qe=document.elementFromPoint(Me,Ae),Mt=qe==null?void 0:qe.closest("[data-tree-drop-dir], [data-tree-drop-root]");let Gt=null;return(Mt==null?void 0:Mt.dataset.treeDropRoot)==="true"?Gt=me:Mt!=null&&Mt.dataset.treeDropDir&&(Gt=Mt.dataset.treeDropDir),Gt&&XF(((cr=Vs.current)==null?void 0:cr.node.path)??"",Gt)&&(Gt=null),Gt},se=Me=>{const Ae=Vs.current;if(!Ae||Me.pointerId!==Ae.pointerId)return;const qe=Me.clientX-Ae.startX,Mt=Me.clientY-Ae.startY,Gt=Math.hypot(qe,Mt);if(!Ae.ready){Gt>12&&(Ha(),H3(Vo.current,Me.pointerId),Vo.current=null,Vs.current=null,da(null));return}const cr=Ae.active||Gt>=10;cr&&jl.current!==null&&(window.clearTimeout(jl.current),jl.current=null);const mr=cr?K(Me.clientX,Me.clientY):null;cr&&Me.cancelable&&Me.preventDefault();const Xr={...Ae,x:Me.clientX,y:Me.clientY,active:cr,dropDir:mr};Vs.current=Xr,da(Xr)},re=Me=>{const Ae=Vs.current;!Ae||Ae.pointerId!==Me||(Ha(),H3(Vo.current,Me),Vo.current=null,Ae.active&&(zc.current=!0,Ae.dropDir&&Hu(Ae.node.path,Ae.dropDir)),Vs.current=null,da(null))},fe=Me=>re(Me.pointerId),ue=Me=>re(Me.pointerId);return window.addEventListener("pointermove",se,{passive:!1}),window.addEventListener("pointerup",fe),window.addEventListener("pointercancel",ue),()=>{var Ae;Ha();const Me=(Ae=Vs.current)==null?void 0:Ae.pointerId;Me!=null&&H3(Vo.current,Me),Vo.current=null,window.removeEventListener("pointermove",se),window.removeEventListener("pointerup",fe),window.removeEventListener("pointercancel",ue)}},[Ha,pi,me,Hu]);const oc=y.useCallback(async K=>{if(!(!me||!await te({title:K.kind==="dir"?"Delete folder":"Delete file",description:`Delete "${K.name}"${K.kind==="dir"?" and all its contents":""}?`,confirmLabel:"Delete",variant:"destructive"})))try{if(await fetch(`${Ta}/api/workspace/delete`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:K.path,isDirectory:K.kind==="dir",surfaceId:u})}),K.kind==="file"){const ue=`file:${K.path}`;dn(Me=>Me.filter(Ae=>Ae.id!==ue))}et();const re=K.path.includes("/")?K.path.slice(0,K.path.lastIndexOf("/")):me,fe=ue=>{for(const Me of ue){if(Me.kind==="dir"&&Me.path===re)return Me.children=null,!0;if(Me.kind==="dir"&&Me.children&&fe(Me.children))return!0}return!1};fe(Ne)||lt(await bc(me,u)),et(),Lr()}catch{}},[te,me,u,et,Ne,Lr]),cf=y.useCallback(async()=>{if(!me||!si||!Mu.trim()){Wi(null);return}const K=Mu.trim();if(K===si.name){Wi(null);return}try{if(!(await fetch(`${Ta}/api/workspace/rename`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:si.path,newName:K,surfaceId:u})})).ok)throw new Error("Rename failed");const re=`file:${si.path}`;dn(Me=>Me.filter(Ae=>Ae.id!==re));const fe=si.path.includes("/")?si.path.slice(0,si.path.lastIndexOf("/")):me,ue=Me=>{for(const Ae of Me){if(Ae.kind==="dir"&&Ae.path===fe)return Ae.children=null,!0;if(Ae.kind==="dir"&&Ae.children&&ue(Ae.children))return!0}return!1};ue(Ne)||lt(await bc(me,u)),et(),Lr()}catch{}Wi(null)},[me,si,Mu,u,et,Ne,Lr]),Fc=y.useCallback(async()=>{if(!me||!Ui||!Cl.trim()){Qi(null);return}const K=Cl.trim(),se=`${Ui.parentDir}/${K}`;try{const re=Ui.kind==="dir"?"create-directory":"create-file";if(!(await fetch(`${Ta}/api/workspace/${re}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:se,surfaceId:u})})).ok)throw new Error("Create failed");const ue=Ui.parentDir,Me=Ae=>{for(const qe of Ae){if(qe.kind==="dir"&&qe.path===ue)return qe.children=null,!0;if(qe.kind==="dir"&&qe.children&&Me(qe.children))return!0}return!1};Me(Ne)||lt(await bc(me,u)),et(),it(Ae=>{const qe=new Set(Ae);return qe.add(ue),qe}),Lr()}catch{}Qi(null)},[me,Ui,Cl,u,et,Ne,Lr]),ky=y.useCallback(async(K,se)=>{var re;if((re=rc.current)==null||re.abort(),!K.trim()){qs(null),tc(!1);return}if(me){const fe=new AbortController;rc.current=fe,tc(!0);try{let ue=`${Ta}/api/workspace/search?query=${encodeURIComponent(K)}&mode=${se}&limit=50`;u&&(ue+=`&surfaceId=${encodeURIComponent(u)}`);const Me=await fetch(ue,{signal:fe.signal});if(!Me.ok)throw new Error("Search failed");const Ae=await Me.json();fe.signal.aborted||qs(Ae)}catch(ue){(ue==null?void 0:ue.name)!=="AbortError"&&qs(se==="content"?{matches:[]}:{files:[]})}finally{fe.signal.aborted||tc(!1)}}else if(se==="files"){tc(!0);const fe=new AbortController;rc.current=fe;try{const ue=await Ap(K,50,fe.signal);fe.signal.aborted||qs({files:ue})}catch{}fe.signal.aborted||tc(!1)}else{tc(!0);const fe=new AbortController;rc.current=fe;try{const ue=await Bu(K,50,fe.signal);fe.signal.aborted||qs({matches:ue})}catch{}fe.signal.aborted||tc(!1)}},[me,u,Ap,Bu]),Yd=y.useRef(null);y.useEffect(()=>(Yd.current&&clearTimeout(Yd.current),Yd.current=setTimeout(()=>{ky(ks,Li)},250),()=>{Yd.current&&clearTimeout(Yd.current)}),[ks,Li,ky]);const xg=y.useCallback(K=>{navigator.clipboard.writeText(K.path)},[]),pa=y.useCallback(K=>{if(!me)return void navigator.clipboard.writeText(K.path);const se=K.path.replace(/\\/g,"/").replace(me.replace(/\\/g,"/"),"").replace(/^\/+/,"");navigator.clipboard.writeText(se)},[me]),ps=y.useCallback(async K=>{if(!me)return;const se=`git-diff:${K}`;Be(!0);try{const re=Ca(K),fe=Ca(me),ue=re===fe?"":re.startsWith(`${fe}/`)?re.slice(fe.length+1):re,Me=Mt=>Mt.find(Gt=>{const cr=Ca(Gt.path);return cr===re||cr===ue||re.endsWith(`/${cr}`)||cr.endsWith(`/${ue}`)});let Ae=Me(_t);if(!Ae){const Mt=await sl.fileDiffs(me).catch(()=>[]);Mt.length>0&&(nr(Mt),Ae=Me(Mt))}const qe=(Mt,Gt)=>{dr(Gt),dn(cr=>{const mr=cr.findIndex(Ro=>Ro.id===se);if(mr===-1)return[...cr,Mt];const Xr=cr[mr],di=[...cr];return di[mr]={...Xr,...Mt,version:(Xr.version??0)+1},di}),Pi(se),Ie(null),st(null),ut(Mt.path),Nt(Mt.language??"plaintext"),!g&&b&&b()};if(Ae){const Mt=K.split("/").pop()??K,Gt={id:se,type:"diff",path:K,label:Mt,diffMode:"git",language:Sa(K),originalContent:Ae.original,modifiedContent:Ae.modified,diffEntry:Ae};qe(Gt,Ae)}else{const Mt=ue?`${fe}/${ue}`:re;let Gt="";try{Gt=await sd(Mt,u)}catch{try{Gt=await sd(re,u)}catch{Gt=""}}const cr=K.split("/").pop()??K,mr={id:se,type:"diff",path:Mt,label:cr,diffMode:"git",language:Sa(K),originalContent:Gt,modifiedContent:Gt};qe(mr,null)}}catch{}Be(!1)},[b,me,g,u,_t]),Ka=y.useCallback(async({path:K,originalContent:se,modifiedContent:re,language:fe})=>{const ue=`review-diff:${K}`,Me=K.split(/[\\/]/).pop()??K,Ae={id:ue,type:"diff",path:K,label:Me,version:1,diffMode:"review",language:fe??Sa(K),originalContent:se,modifiedContent:re};return dn(qe=>qe.find(Gt=>Gt.id===ue)?qe.map(Gt=>Gt.id===ue?{...Gt,...Ae,version:(Gt.version??0)+1}:Gt):[...qe,Ae]),Pi(ue),dr(null),Ie(null),st(null),ut(K),Nt(fe??Sa(K)),!0},[]),es=y.useCallback(K=>{var re;const se=(K==null?void 0:K.trim())??"";if(Ft){const fe=((re=Ft.target)==null?void 0:re.trim())??"";se&&fe&&se===fe||Vd(!1)}return tf(se||Ud),Cs(null),Rt(null),nc(!1),by("controls"),Tl(fe=>({id:"preview",type:"preview",path:se||"__preview__",label:QF(se),previewTarget:se||void 0,previewSrc:(fe==null?void 0:fe.previewSrc)??F3(se),previewMode:null}),!0),!0},[Ft,Ud,Vd,Tl]),Ko=y.useCallback(()=>{const K="architecture",se={id:K,type:"architecture",path:"__architecture__",label:"Architecture"};dn(re=>re.find(ue=>ue.id===K)?re.map(ue=>ue.id===K?{...ue,...se}:ue):[...re,se]),Pi(K),dr(null),Ie(null),st(null),ut("__architecture__"),Nt("plaintext"),i("")},[i]),Yo=y.useCallback(()=>{dn(K=>{const se=K.findIndex(ue=>ue.type==="architecture");if(se<0)return K;const re=K[se],fe=K.filter(ue=>ue.id!==(re==null?void 0:re.id));if((re==null?void 0:re.id)===vn){const ue=fe[Math.min(se,fe.length-1)],Me=(ue==null?void 0:ue.id)??null;setTimeout(()=>{Pi(Me),Me?(ue==null?void 0:ue.type)==="file"?(Ie(ue.path),st(ue.content??null),Nt(ue.language??"plaintext"),ut(ue.path),dr(null)):(ue==null?void 0:ue.type)==="preview"?(Ie(null),st(null),Nt("plaintext"),ut(ue.previewTarget??ue.path),dr(null)):(ue==null?void 0:ue.type)==="architecture"?(Ie(null),st(null),Nt("plaintext"),ut("__architecture__"),dr(null)):(ue==null?void 0:ue.type)==="diff"&&dr(ue.diffMode==="git"?ue.diffEntry??null:null):(Ie(null),st(null),dr(null))},0)}return fe})},[vn]),Hc=y.useCallback(()=>{hs(!1),dn(K=>{const se=K.findIndex(ue=>ue.type==="preview");if(se<0)return K;const re=K[se],fe=K.filter(ue=>ue.id!==(re==null?void 0:re.id));if((re==null?void 0:re.id)===vn){const ue=fe[Math.min(se,fe.length-1)],Me=(ue==null?void 0:ue.id)??null;setTimeout(()=>{Pi(Me),Me?(ue==null?void 0:ue.type)==="file"?(Ie(ue.path),st(ue.content??null),Nt(ue.language??"plaintext"),ut(ue.path),dr(null)):(ue==null?void 0:ue.type)==="preview"?(Ie(null),st(null),Nt("plaintext"),ut(ue.previewTarget??ue.path),dr(null)):(ue==null?void 0:ue.type)==="architecture"?(Ie(null),st(null),Nt("plaintext"),ut("__architecture__"),dr(null)):(ue==null?void 0:ue.type)==="diff"&&dr(ue.diffMode==="git"?ue.diffEntry??null:null):(Ie(null),st(null),dr(null))},0)}return fe}),H==null||H({open:!1,target:null})},[vn,H]),Ya=y.useCallback(()=>{nc(!0),qd(),dn(K=>K.map(se=>se.type==="preview"?{...se,version:(se.version??0)+1}:se))},[qd]),ts=y.useCallback(async({target:K,command:se,port:re,resetTab:fe=!0})=>{if(!Un||!I){Cs("Login is required to start a live preview session.");return}Pu(!0),Cs(null),Rt(null),nc(!0),fe&&es(null);try{const ue=await fetch(`${Ta}/api/preview/start`,{method:"POST",headers:Pb(I),body:JSON.stringify({sessionId:Un,workspaceRoot:L,target:(K==null?void 0:K.trim())||null,command:(se==null?void 0:se.trim())||null,port:typeof re=="number"?re:null})}),Me=await ue.json().catch(()=>({}));if(!ue.ok||!Me.session)throw new Error(Me.error||"Failed to start preview");Wa(Ae=>I3(Ae,Me.session??null)?Ae:Me.session??null),by("controls")}catch(ue){Cs(ue instanceof Error?ue.message:"Failed to start preview"),nc(!1)}finally{Pu(!1)}},[Un,es,I,L]),Ns=y.useCallback(()=>{const K=Ud.trim();ts({target:K||null,command:rf.trim()||null,port:bp.trim()?Number.parseInt(bp.trim(),10):null})},[rf,Ud,bp,ts]),Wu=y.useCallback(async()=>{if(!(!Un||!I)){Pu(!0),Cs(null),nc(!0);try{const K=await fetch(`${Ta}/api/preview/restart`,{method:"POST",headers:Pb(I),body:JSON.stringify({sessionId:Un})}),se=await K.json().catch(()=>({}));if(!K.ok||!se.session)throw new Error(se.error||"Failed to restart preview");Wa(re=>I3(re,se.session??null)?re:se.session??null)}catch(K){Cs(K instanceof Error?K.message:"Failed to restart preview"),nc(!1)}finally{Pu(!1)}}},[Un,I]),Uu=y.useCallback(async()=>{Pu(!0),await Vd(!0)},[Vd]),Vu=((Qa=Ft==null?void 0:Ft.remoteBrowser)==null?void 0:Qa.novncUrl)??(Ft==null?void 0:Ft.url)??(wn==null?void 0:wn.previewTarget)??null;y.useImperativeHandle(de,()=>({openDirectory:Tp,openRemoteWorkspace:Iu,openFileByPath:so,readFileByPath:lf,readReferencePath:Ep,openReviewDiff:Ka,openPreviewTarget:es,closePreviewTarget:Hc,refreshPreviewTarget:Ya,openArchitectureTab:Ko,closeArchitectureTab:Yo,searchFiles:Ap}),[Tp,Iu,so,lf,Ep,Ka,es,Hc,Ya,Ko,Yo,Ap]),y.useEffect(()=>{var fe,ue;if(!U||ic.current===U.key)return;ic.current=U.key,es(U.target);const K=((fe=U.target)==null?void 0:fe.trim())||"";if(!K||!Un||!I)return;const se=((ue=Ft==null?void 0:Ft.target)==null?void 0:ue.trim())||"",re=Ft==null?void 0:Ft.status;se===K&&(re==="starting"||re==="ready")||ts({target:K,resetTab:!1})},[Un,es,Ft==null?void 0:Ft.status,Ft==null?void 0:Ft.target,U,I,ts]),y.useEffect(()=>{F&&Sy.current!==F.key&&(Sy.current=F.key,Ko())},[F,Ko]);const oo=y.useCallback(async K=>{if(!(!me||dt)){Mr(!0),Tr(null);try{await sl.runStackedAction(me,K,{commitMessage:Ut.trim()||void 0}),pr(""),dr(null),dn(se=>se.filter(fe=>fe.type!=="diff")),Pi(se=>{var fe;const re=Kr.filter(ue=>ue.type!=="diff");return se&&re.some(ue=>ue.id===se)?se:((fe=re[re.length-1])==null?void 0:fe.id)??null}),await Lr()}catch(se){Tr(se instanceof Error?se.message:"Git action failed")}Mr(!1)}},[me,dt,Ut,Lr,Kr]),Wc=y.useCallback(async()=>{if(!(!me||dt)){Mr(!0),Tr(null);try{await sl.pull(me),await Lr(),et()}catch(K){Tr(K instanceof Error?K.message:"Pull failed")}Mr(!1)}},[me,dt,Lr,et]),Op=y.useCallback(async()=>{if(!(!me||dt)){Mr(!0),Tr(null);try{await sl.sync(me),await Lr(),et()}catch(K){Tr(K instanceof Error?K.message:"Sync failed")}Mr(!1)}},[me,dt,Lr,et]),Gs=y.useCallback(async()=>{const K=new Set([...(rt==null?void 0:rt.index.files.map(se=>se.path))??[],...(rt==null?void 0:rt.workingTree.files.map(se=>se.path))??[]]).size;if(!(!me||dt||K===0)){Mr(!0),Tr(null);try{await sl.discard(me),Ss(null),dr(null),dn(se=>se.filter(re=>re.type!=="diff")),await Lr(),et()}catch(se){Tr(se instanceof Error?se.message:"Discard failed")}Mr(!1)}},[me,dt,rt,Lr,et]),Xd=y.useCallback(async K=>{if(!(!me||dt)){Mr(!0),Tr(null);try{await sl.discard(me,[K]),Ss(null);const se=`git-diff:${K}`;dn(re=>re.filter(fe=>fe.id!==se)),(Wt==null?void 0:Wt.path)===K&&dr(null),await Lr(),et()}catch(se){Tr(se instanceof Error?se.message:"Discard failed")}Mr(!1)}},[me,dt,Wt,Lr,et]),Ml=y.useCallback(async K=>{if(!me||dt||K.length===0)return;const se=[...new Set(K)];Mr(!0),Tr(null);try{await sl.discard(me,se),Ss(null),dn(re=>re.filter(fe=>fe.type!=="diff"||!se.includes(fe.path))),Wt!=null&&Wt.path&&se.includes(Wt.path)&&dr(null),await Lr(),et()}catch(re){Tr(re instanceof Error?re.message:"Discard failed")}Mr(!1)},[me,dt,Wt,Lr,et]),uf=y.useCallback(async K=>{if(!(!me||dt||K.length===0))try{await sl.stage(me,[...new Set(K)]),await Lr()}catch{}},[me,dt,Lr]),Xa=y.useCallback(async K=>{await uf([K])},[uf]),ma=y.useCallback(async K=>{if(!(!me||dt||K.length===0))try{await sl.unstage(me,[...new Set(K)]),await Lr()}catch{}},[me,dt,Lr]),Rp=y.useCallback(async K=>{await ma([K])},[ma]),bg=y.useCallback(async()=>{if(!(!me||dt||((rt==null?void 0:rt.workingTree.files.length)??0)===0))try{await sl.stage(me),await Lr()}catch{}},[me,dt,rt,Lr]),ac=y.useCallback(async()=>{if(!(!me||dt||((rt==null?void 0:rt.index.files.length)??0)===0))try{await sl.unstage(me),await Lr()}catch{}},[me,dt,rt,Lr]),Zd=y.useCallback(K=>{const se=r.find(fe=>fe.id===K);if(!se)return;yi();const re=`ext:${K}`;dn(fe=>{if(fe.find(Ae=>Ae.id===re))return fe;const Me={id:re,type:"file",path:se.path,label:se.name,content:se.content,savedContent:se.content,language:se.language};return[...fe,Me]}),Pi(re),Ie(null),st(null),i(K)},[yi,i,r]),ms=y.useCallback((K,se)=>{const re=Kr.find(fe=>fe.id===K)??null;(re==null?void 0:re.type)==="preview"&&!(se!=null&&se.preserveManagedPreview)&&hs(!1),dn(fe=>{const ue=fe.findIndex(Ae=>Ae.id===K);if(ue<0)return fe;const Me=fe.filter(Ae=>Ae.id!==K);if(K===vn){const Ae=Me[Math.min(ue,Me.length-1)],qe=(Ae==null?void 0:Ae.id)??null;setTimeout(()=>{Pi(qe),qe?(Ae==null?void 0:Ae.type)==="file"?(Ie(Ae.path),st(Ae.content??null),Nt(Ae.language??"plaintext"),ut(Ae.path),dr(null)):(Ae==null?void 0:Ae.type)==="preview"?(Ie(null),st(null),Nt("plaintext"),ut(Ae.previewTarget??Ae.path),dr(null)):(Ae==null?void 0:Ae.type)==="diff"&&dr(Ae.diffMode==="git"?Ae.diffEntry??null:null):(Ie(null),st(null),dr(null))},0)}return Me})},[vn,Kr]),Uc=y.useCallback(async K=>{var Ae,qe;const se=Kr.find(Mt=>Mt.id===K)??null;if(!se||se.type==="preview")return!1;const re=`detached-${se.id}-${Date.now()}`,fe={id:re,title:se.label||n0(se),theme:ie,surfaceId:u,tab:{id:se.id,type:se.type,path:se.path,label:se.label,language:se.language,content:se.content??null,originalContent:se.originalContent??null,modifiedContent:se.modifiedContent??null,diffMode:se.diffMode,previewTarget:se.previewTarget,previewSrc:se.previewSrc??null,previewMode:se.previewMode??null},architectureDiagram:se.type==="architecture"?G??null:null,architectureGenerating:se.type==="architecture"?X:!1,createdAt:Date.now()};JGe(fe);const ue=`${window.location.origin}${window.location.pathname}?detachedWorkspaceTab=${encodeURIComponent(re)}`;let Me=!1;try{if((Ae=window.jaitDesktop)!=null&&Ae.openWorkspaceWindow){const Mt=await window.jaitDesktop.openWorkspaceWindow({url:ue,title:se.label||n0(se)});Me=!!(Mt!=null&&Mt.ok)}else{const Mt=window.open(ue,`jait-detached-${se.id}`,"popup=yes,width=1280,height=860,resizable=yes,scrollbars=yes");Me=!!Mt,(qe=Mt==null?void 0:Mt.focus)==null||qe.call(Mt)}}catch{Me=!1}return Me?(ms(K,{preserveManagedPreview:!0}),!0):!1},[G,X,ms,Kr,ie,u]),Jd=y.useCallback((K,se)=>{ua(null);const re=K.clientX<=z3||K.clientY<=z3||K.clientX>=window.innerWidth-z3||K.clientY>=window.innerHeight-z3,fe=K.dataTransfer.dropEffect==="none"&&(K.clientX===0||K.clientY===0);!re&&!fe||Uc(se)},[Uc]),Pl=y.useCallback(K=>{const se=Kr.find(re=>re.id===K);se&&(Pi(K),se.type==="file"?(Ie(se.path),st(se.content??null),Nt(se.language??"plaintext"),ut(se.path),dr(null),i(se.id.startsWith("ext:")?se.id.slice(4):"")):se.type==="preview"?(Ie(null),st(null),Nt("plaintext"),ut(se.previewTarget??se.path),dr(null),i("")):se.type==="architecture"?(Ie(null),st(null),Nt("plaintext"),ut("__architecture__"),dr(null),i("")):se.type==="diff"&&dr(se.diffMode==="git"?se.diffEntry??null:null))},[Kr,i]),Qd=y.useCallback(()=>{dn([]),Pi(null),Ie(null),st(null),dr(null),Hd(null)},[]),$s=y.useCallback(K=>{dn(se=>se.filter(re=>re.id===K)),Pi(K),Hd(null)},[]),Ao=y.useCallback(K=>{dn(se=>{const re=se.findIndex(fe=>fe.id===K);return re<0?se:se.slice(0,re+1)}),Hd(null)},[]),Ll=y.useCallback((K,se)=>{K!==se&&dn(re=>{const fe=re.findIndex(qe=>qe.id===K),ue=re.findIndex(qe=>qe.id===se);if(fe<0||ue<0||fe===ue)return re;const Me=[...re],[Ae]=Me.splice(fe,1);return Me.splice(ue,0,Ae),Me})},[]),ao=Ne.length>0,ui=r.length>0,[$i,Ds]=y.useState("files");y.useEffect(()=>{f&&(p&&S==="files"?Ds("files"):p&&S==="git"?Ds("git"):g&&!p&&Ds("editor"))},[f,S,p,g]),y.useEffect(()=>{f&&g&&(ze==null?void 0:ze.type)==="diff"&&Ds("editor")},[ze==null?void 0:ze.id,ze==null?void 0:ze.type,f,g]);const Za=(rt==null?void 0:rt.index.files)??[],lc=y.useMemo(()=>{const K=(rt==null?void 0:rt.workingTree.files)??[];return oKe(K,_t,Za)},[rt==null?void 0:rt.workingTree.files,Za,_t]),df=y.useMemo(()=>JF(Za.map(K=>({path:K.path,status:K.status,insertions:K.insertions,deletions:K.deletions}))),[Za]),rs=y.useMemo(()=>JF(lc.map(K=>({path:K.path,status:K.status,insertions:K.insertions,deletions:K.deletions}))),[lc]),Yr=y.useMemo(()=>aKe(Za,lc),[Za,lc]),$r=y.useCallback(async()=>{if(!(!me||Yr===0||rr||dt)){Ur(!0),Tr(null);try{const{message:K}=await sl.generateCommitMessage(me,D,W);K&&pr(K)}catch(K){Tr(K instanceof Error?K.message:"Failed to generate commit message")}Ur(!1)}},[me,Yr,rr,dt,D,W]),lo=Yr>0&&!rr&&!dt,Ts=Hi?Kr.findIndex(K=>K.id===Hi.tabId):-1,Mp=!dt&&(Yr>0||j7(rt)),Ja=!dt&&Yr>0,_g=!dt&&rKe(Yr,rt),Pp=!dt&&j7(rt),$l=nKe(Yr,rt),Vc=(K=!1)=>c.jsxs("div",{className:"ml-auto inline-flex items-center rounded-md border border-input bg-background/90 p-0.5 shadow-sm",children:[c.jsx("button",{type:"button",className:Fe("inline-flex items-center justify-center rounded-sm text-muted-foreground transition-colors hover:text-foreground",K?"h-7 w-7":"h-6 w-6",Ls==="list"&&"bg-accent text-accent-foreground shadow-sm"),onClick:()=>Ot("list"),title:"List view","aria-label":"List view","aria-pressed":Ls==="list",children:c.jsx(A0e,{className:"h-3.5 w-3.5"})}),c.jsx("button",{type:"button",className:Fe("inline-flex items-center justify-center rounded-sm text-muted-foreground transition-colors hover:text-foreground",K?"h-7 w-7":"h-6 w-6",Ls==="tree"&&"bg-accent text-accent-foreground shadow-sm"),onClick:()=>Ot("tree"),title:"Tree view","aria-label":"Tree view","aria-pressed":Ls==="tree",children:c.jsx(Q$,{className:"h-3.5 w-3.5"})})]}),hf=(K=!1)=>c.jsxs("div",{className:Fe("flex items-center",K?"gap-1.5":"overflow-hidden rounded-md shadow-sm"),children:[c.jsxs(_e,{size:"sm",className:Fe(K?"h-8 rounded-md px-2.5 text-xs":"h-6 gap-1 rounded-r-none px-2 text-xs shadow-none"),onClick:()=>{if($l==="sync"){Op();return}oo("commit")},disabled:!Mp,title:$l==="sync"?`Synchronize changes with Git${rt?` (Behind ${rt.behindCount}, Ahead ${rt.aheadCount})`:""}`:"Commit all changes (Ctrl+Enter)",children:[dt?c.jsx(ir,{className:"h-3 w-3 animate-spin"}):$l==="sync"?c.jsx(sa,{className:"h-3 w-3"}):c.jsx(eD,{className:"h-3 w-3"}),$l==="sync"?"Sync":"Commit"]}),c.jsxs(yu,{children:[c.jsx(vu,{asChild:!0,children:c.jsx(_e,{variant:K?"secondary":"default",size:"sm",className:Fe(K?"h-8 rounded-md px-2":"h-6 w-6 rounded-l-none border-l border-primary-foreground/25 px-0 shadow-none"),disabled:dt,title:"More commit actions","aria-label":"More commit actions",children:c.jsx(vl,{className:"h-3.5 w-3.5"})})}),c.jsxs(Ac,{side:"bottom",align:"end",sideOffset:4,className:"w-44",children:[c.jsxs(Ji,{onSelect:()=>{oo("commit")},className:"gap-2",disabled:!Ja,children:[c.jsx(eD,{className:"h-3.5 w-3.5"}),"Commit"]}),c.jsxs(Ji,{onSelect:()=>{oo("commit_push")},className:"gap-2",disabled:!_g,children:[c.jsx($ge,{className:"h-3.5 w-3.5"}),"Commit & Push"]}),c.jsxs(Ji,{onSelect:()=>{Op()},className:"gap-2",disabled:!Pp,children:[c.jsx(sa,{className:"h-3.5 w-3.5"}),"Sync Changes"]})]})]})]}),ve=y.useCallback(K=>{Tt(se=>{const re=new Set(se);return re.has(K)?re.delete(K):re.add(K),re})},[]);y.useEffect(()=>{Vs.current=pi},[pi]);const qu=y.useCallback((K,se,re=!1)=>c.jsxs("span",{className:`flex shrink-0 items-center justify-end gap-0.5 ${re?"opacity-100":"opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100"}`,children:[se==="stage"?c.jsx("button",{type:"button",className:"rounded p-0.5 text-muted-foreground hover:bg-background hover:text-foreground",onClick:fe=>{fe.stopPropagation(),Xa(K)},title:"Stage file (git add)",children:c.jsx(Ho,{className:"h-3 w-3"})}):c.jsx("button",{type:"button",className:"rounded p-0.5 text-muted-foreground hover:bg-background hover:text-foreground",onClick:fe=>{fe.stopPropagation(),Rp(K)},title:"Unstage file",children:c.jsx(mC,{className:"h-3 w-3"})}),c.jsx("button",{type:"button",className:"rounded p-0.5 text-muted-foreground hover:bg-background hover:text-red-500",onClick:fe=>{fe.stopPropagation(),Ss(ue=>(ue==null?void 0:ue.kind)==="file"&&ue.path===K?null:{kind:"file",path:K})},title:"Discard changes",children:c.jsx(Ah,{className:"h-3 w-3"})})]}),[Xa,Rp]),qc=y.useCallback((K,se,re,fe=!1)=>{if(se.length===0)return null;const ue=[...new Set(se)];return c.jsxs("span",{className:`flex shrink-0 items-center justify-end gap-0.5 ${fe?"opacity-100":"opacity-0 transition-opacity group-hover:opacity-100 group-focus-within:opacity-100"}`,children:[re==="stage"?c.jsx("button",{type:"button",className:"rounded p-0.5 text-muted-foreground hover:bg-background hover:text-foreground",onClick:Me=>{Me.stopPropagation(),uf(ue)},title:"Stage folder",children:c.jsx(Ho,{className:"h-3 w-3"})}):c.jsx("button",{type:"button",className:"rounded p-0.5 text-muted-foreground hover:bg-background hover:text-foreground",onClick:Me=>{Me.stopPropagation(),ma(ue)},title:"Unstage folder",children:c.jsx(mC,{className:"h-3 w-3"})}),c.jsx("button",{type:"button",className:"rounded p-0.5 text-muted-foreground hover:bg-background hover:text-red-500",onClick:Me=>{Me.stopPropagation(),Ss(Ae=>(Ae==null?void 0:Ae.kind)==="folder"&&Ae.path===K?null:{kind:"folder",path:K,paths:ue})},title:"Discard changes in folder",children:c.jsx(Ah,{className:"h-3 w-3"})})]})},[uf,ma]),Es=y.useCallback((K,se=!1)=>Fe("group w-full rounded-md text-left transition-colors",se?"text-sm":"text-xs",K?"bg-accent text-accent-foreground":"hover:bg-accent/60 hover:text-accent-foreground"),[]),co=y.useCallback((K,se,re=!1,fe=0)=>K.map(ue=>{if(ue.kind==="dir"){const Gt=!ye.has(ue.path),cr=goe(ue.children);return c.jsxs("div",{children:[c.jsxs("div",{className:Fe(Es(!1,re),"grid grid-cols-[minmax(0,1fr)_auto] items-center gap-1.5 px-2 py-1.5"),style:{paddingLeft:8+fe*14},children:[c.jsxs("button",{type:"button",className:"flex min-w-0 items-center gap-1.5 text-left",onClick:()=>ve(ue.path),children:[c.jsx(ko,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform ${Gt?"rotate-90":""}`}),c.jsx(Oj,{name:ue.name,open:Gt,className:"h-3.5 w-3.5 shrink-0"}),c.jsx("span",{className:"truncate",children:ue.name})]}),qc(ue.path,cr,se,re)]}),(Tn==null?void 0:Tn.kind)==="folder"&&Tn.path===ue.path&&c.jsxs("div",{className:"ml-6 mt-1 flex items-center gap-1 rounded border border-red-500/30 bg-red-500/5 px-2 py-1 text-2xs",children:[c.jsxs("span",{className:"flex-1 text-red-500",children:["Discard changes in ",ue.name,"?"]}),c.jsx(_e,{size:"sm",variant:"destructive",className:"h-5 px-1.5 text-2xs",onClick:()=>void Ml(Tn.paths),disabled:dt,children:"Discard"}),c.jsx(_e,{size:"sm",variant:"ghost",className:"h-5 px-1.5 text-2xs",onClick:()=>Ss(null),disabled:dt,children:"Cancel"})]}),Gt?co(ue.children,se,re,fe+1):null]},`${se}:dir:${ue.path}`)}const Me=ue.entry.status??"M",Ae=ue.name,qe=ue.path.includes("/")?ue.path.slice(0,ue.path.lastIndexOf("/")):"",Mt=(Wt==null?void 0:Wt.path)===ue.path;return c.jsxs("div",{children:[c.jsxs("button",{type:"button",className:Fe(Es(Mt,re),"grid grid-cols-[auto_minmax(0,1fr)_auto_auto] items-center gap-1.5 px-2 py-1.5"),style:{paddingLeft:22+fe*14},onClick:()=>{ps(ue.path),re&&Ds("editor")},title:`${ue.path} — ${T7[Me]??Me}`,children:[c.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[c.jsx(g_,{status:Me,className:re?"text-2xs":void 0}),c.jsx($o,{filename:Ae,className:`${re?"h-4 w-4":"h-3.5 w-3.5"} shrink-0`})]}),c.jsxs("div",{className:"flex min-w-0 items-baseline gap-1.5 overflow-hidden",children:[c.jsx("span",{className:`truncate ${Me==="D"?"line-through text-muted-foreground":""}`,children:Ae}),qe?c.jsx("span",{className:"truncate text-2xs text-muted-foreground",children:qe}):null]}),c.jsxs("span",{className:"w-16 shrink-0 text-right text-2xs text-muted-foreground",children:[ue.entry.insertions>0&&c.jsxs("span",{className:"text-green-500",children:["+",ue.entry.insertions]}),ue.entry.deletions>0&&c.jsxs("span",{className:"ml-0.5 text-red-500",children:["-",ue.entry.deletions]})]}),qu(ue.path,se,re)]}),(Tn==null?void 0:Tn.kind)==="file"&&Tn.path===ue.path&&c.jsxs("div",{className:"ml-6 mt-1 flex items-center gap-1 rounded border border-red-500/30 bg-red-500/5 px-2 py-1 text-2xs",children:[c.jsxs("span",{className:"flex-1 text-red-500",children:["Discard changes in ",Ae,"?"]}),c.jsx(_e,{size:"sm",variant:"destructive",className:"h-5 px-1.5 text-2xs",onClick:()=>void Xd(ue.path),disabled:dt,children:"Discard"}),c.jsx(_e,{size:"sm",variant:"ghost",className:"h-5 px-1.5 text-2xs",onClick:()=>Ss(null),disabled:dt,children:"Cancel"})]})]},`${se}:file:${ue.path}`)}),[ye,Tn,Es,dt,Xd,Ml,ps,qu,qc,ve,Wt==null?void 0:Wt.path]),Oo=y.useCallback((K,se,re,fe,ue,Me=!1)=>{if(se.length===0)return null;const Ae=Fe("rounded p-0.5 text-muted-foreground transition-[background-color,color,opacity] hover:bg-background",Me?"opacity-100":"opacity-0 group-hover:opacity-100 group-focus-within:opacity-100");return c.jsxs("div",{className:"mt-1",children:[c.jsxs("div",{className:"group flex items-center justify-between gap-2 px-2 py-1 text-2xs font-medium uppercase tracking-wider text-muted-foreground",children:[c.jsxs("div",{children:[K," (",se.length,")",c.jsxs("span",{className:"ml-1 normal-case tracking-normal",children:[c.jsxs("span",{className:"text-green-500",children:["+",fe.insertions]})," ",c.jsxs("span",{className:"text-red-500",children:["-",fe.deletions]})]})]}),c.jsx("div",{className:Fe("flex items-center gap-1 transition-opacity",Me?"opacity-100":"opacity-0 group-hover:opacity-100 group-focus-within:opacity-100"),children:ue==="stage"?c.jsxs(c.Fragment,{children:[c.jsx("button",{type:"button",className:Fe(Ae,"text-red-600 hover:text-red-700 disabled:pointer-events-none disabled:opacity-40 dark:text-red-400"),onClick:()=>Ss({kind:"all"}),disabled:dt||se.length===0,title:"Discard all changes","aria-label":"Discard all changes",children:c.jsx(Ah,{className:"h-3 w-3"})}),c.jsx("button",{type:"button",className:Fe(Ae,"hover:text-foreground disabled:pointer-events-none disabled:opacity-40"),onClick:()=>void bg(),disabled:dt||se.length===0,title:"Stage all changes","aria-label":"Stage all changes",children:c.jsx(Ho,{className:"h-3 w-3"})})]}):c.jsxs(c.Fragment,{children:[c.jsx("button",{type:"button",className:Fe(Ae,"text-red-600 hover:text-red-700 disabled:pointer-events-none disabled:opacity-40 dark:text-red-400"),onClick:()=>Ss({kind:"all"}),disabled:dt||Yr===0,title:"Discard all changes","aria-label":"Discard all changes",children:c.jsx(Ah,{className:"h-3 w-3"})}),c.jsx("button",{type:"button",className:Fe(Ae,"hover:text-foreground disabled:pointer-events-none disabled:opacity-40"),onClick:()=>void ac(),disabled:dt||se.length===0,title:"Unstage all files","aria-label":"Unstage all files",children:c.jsx(mC,{className:"h-3 w-3"})})]})})]}),(Tn==null?void 0:Tn.kind)==="all"&&Yr>0&&c.jsxs("div",{className:"mx-2 mb-1 flex items-center gap-1 rounded border border-red-500/30 bg-red-500/5 px-2 py-1 text-2xs",children:[c.jsx("span",{className:"flex-1 text-red-500",children:"Discard all changes?"}),c.jsx(_e,{size:"sm",variant:"destructive",className:"h-5 px-1.5 text-2xs",onClick:()=>void Gs(),disabled:dt,children:"Discard"}),c.jsx(_e,{size:"sm",variant:"ghost",className:"h-5 px-1.5 text-2xs",onClick:()=>Ss(null),disabled:dt,children:"Cancel"})]}),c.jsx("div",{className:"mt-1 space-y-1",children:Ls==="tree"?co(re,ue,Me):se.map(qe=>{const Mt=qe.status??"M",Gt=qe.path.split("/").pop()??qe.path,cr=qe.path.includes("/")?qe.path.slice(0,qe.path.lastIndexOf("/")):"",mr=(Wt==null?void 0:Wt.path)===qe.path;return c.jsxs("div",{children:[c.jsxs("div",{className:Fe(Es(mr,Me),"grid w-full cursor-pointer grid-cols-[auto_minmax(0,1fr)_auto_auto] items-center gap-1.5 px-2 py-1.5"),draggable:!Me,onClick:()=>{ps(qe.path),Me&&Ds("editor")},onDragStart:Xr=>{Me||(Xr.dataTransfer.effectAllowed="copy",Xr.dataTransfer.setData("text/jait-file",JSON.stringify({path:qe.path,name:Gt})))},title:`${qe.path} — ${T7[Mt]??Mt}`,children:[c.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[c.jsx(g_,{status:Mt,className:Me?"text-2xs":void 0}),c.jsx($o,{filename:Gt,className:`${Me?"h-4 w-4":"h-3.5 w-3.5"} shrink-0`})]}),c.jsxs("div",{className:"flex min-w-0 items-baseline gap-1.5 overflow-hidden",children:[c.jsx("span",{className:`truncate ${Mt==="D"?"line-through text-muted-foreground":""}`,children:Gt}),cr?c.jsx("span",{className:"truncate text-2xs text-muted-foreground",children:cr}):null]}),c.jsxs("span",{className:"w-16 shrink-0 text-right text-2xs text-muted-foreground",children:[qe.insertions>0&&c.jsxs("span",{className:"text-green-500",children:["+",qe.insertions]}),qe.deletions>0&&c.jsxs("span",{className:"ml-0.5 text-red-500",children:["-",qe.deletions]})]}),qu(qe.path,ue,Me)]}),(Tn==null?void 0:Tn.kind)==="file"&&Tn.path===qe.path&&c.jsxs("div",{className:"ml-6 mt-1 flex items-center gap-1 rounded border border-red-500/30 bg-red-500/5 px-2 py-1 text-2xs",children:[c.jsxs("span",{className:"flex-1 text-red-500",children:["Discard changes in ",Gt,"?"]}),c.jsx(_e,{size:"sm",variant:"destructive",className:"h-5 px-1.5 text-2xs",onClick:()=>void Xd(qe.path),disabled:dt,children:"Discard"}),c.jsx(_e,{size:"sm",variant:"ghost",className:"h-5 px-1.5 text-2xs",onClick:()=>Ss(null),disabled:dt,children:"Cancel"})]})]},`${ue}:${qe.path}`)})})]})},[Yr,Tn==null?void 0:Tn.kind,(Tn==null?void 0:Tn.kind)==="file"||(Tn==null?void 0:Tn.kind)==="folder"?Tn.path:null,Es,dt,Gs,Xd,ps,bg,ac,qu,co,Wt==null?void 0:Wt.path,Ls]),uo=y.useCallback(async K=>{fa()||(await sc(K),f&&Ds("editor"))},[fa,sc,f]),ff=y.useCallback(K=>{Zd(K),f&&Ds("editor")},[Zd,f]),qi=y.useCallback((K,se,re,fe)=>{const ue=se.trim();if(!ue){ot.current=null;return}const Me=`${K.path}:${re}:${fe}:${ue}`;ot.current!==Me&&(ot.current=Me,a==null||a(K,ue,re,fe))},[a]);if(f){const K=($i==="files"||$i==="git")&&!p?"editor":$i==="editor"&&!g?"files":$i,se=re=>{Ds(re)};return!p&&!g?null:c.jsxs("div",{className:"flex flex-col h-full min-h-0",children:[g&&c.jsxs("div",{"data-testid":"mobile-workspace-tabbar",className:"flex items-center h-[35px] border-b bg-muted/30 shrink-0 px-1 gap-0.5",children:[g&&(Kr.length>0?c.jsxs(yu,{onOpenChange:re=>{re&&se("editor")},children:[c.jsx(vu,{asChild:!0,children:c.jsxs("button",{className:`flex items-center gap-1 px-2.5 py-1 rounded text-xs font-medium transition-colors min-w-0 ${K==="editor"?"bg-background text-foreground shadow-sm":"text-muted-foreground"}`,children:[c.jsx("span",{className:"shrink-0",children:"Editor"}),Kr.length>1&&c.jsx("span",{className:"rounded-full bg-primary/15 px-1.5 text-2xs font-bold leading-tight text-primary",children:Kr.length}),(ze??Fn)&&c.jsxs("span",{className:"truncate text-2xs text-muted-foreground max-w-[120px]",children:["—"," ",ze?n0(ze):Fn==null?void 0:Fn.path.split("/").pop()]})]})}),c.jsxs(Ac,{align:"start",className:"w-[min(20rem,calc(100vw-1rem))]",children:[c.jsx(y0,{children:"Open tabs"}),Kr.map(re=>{const fe=re.id===vn;return c.jsxs(Ji,{disabled:fe,onSelect:()=>{fe||(Pl(re.id),se("editor"))},className:Fe("gap-2",fe&&"bg-muted/55 text-muted-foreground"),children:[re.type==="diff"&&re.diffMode==="git"&&re.diffEntry?c.jsx(g_,{status:re.diffEntry.status,className:"text-2xs"}):re.type==="architecture"?c.jsx(n2,{className:"h-3.5 w-3.5 shrink-0"}):re.type==="preview"?c.jsx(Ci,{className:"h-3.5 w-3.5 shrink-0"}):c.jsx($o,{filename:re.path,className:"h-3.5 w-3.5 shrink-0"}),c.jsx("span",{className:"min-w-0 flex-1 truncate",children:n0(re)}),fe&&c.jsx("span",{className:"text-2xs font-medium text-muted-foreground/90",children:"Current"})]},re.id)}),ze&&c.jsxs(c.Fragment,{children:[c.jsx(dd,{}),c.jsxs(Ji,{onSelect:()=>ms(ze.id),className:"gap-2 text-red-600 focus:text-red-600 dark:text-red-400 dark:focus:text-red-400",children:[c.jsx(ti,{className:"h-3.5 w-3.5 shrink-0"}),c.jsx("span",{className:"truncate",children:"Close current tab"})]})]})]})]}):c.jsxs("button",{className:`flex items-center gap-1 px-2.5 py-1 rounded text-xs font-medium transition-colors ${K==="editor"?"bg-background text-foreground shadow-sm":"text-muted-foreground"}`,onClick:()=>se("editor"),children:["Editor",Fn&&c.jsxs("span",{className:"text-2xs text-muted-foreground truncate max-w-[120px]",children:["—"," ",Fn.path.split("/").pop()]})]})),K==="editor"&&(ze==null?void 0:ze.type)==="preview"&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"flex-1"}),c.jsx("button",{type:"button",onClick:Ya,className:"flex items-center text-xs text-muted-foreground hover:text-foreground px-1.5 shrink-0",title:"Refresh preview",children:c.jsx(sa,{className:"h-3 w-3"})}),c.jsx("button",{type:"button",onClick:()=>hs(re=>!re),className:"flex items-center text-xs text-muted-foreground hover:text-foreground px-1.5 shrink-0",title:"Preview controls",children:c.jsx(NN,{className:"h-3 w-3"})})]})]}),K==="files"&&p&&c.jsxs(c.Fragment,{children:[!S&&c.jsx("div",{className:"flex items-center justify-end h-7 px-2 shrink-0 border-b bg-muted/10",children:v&&c.jsx("button",{onClick:v,className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors rounded px-1.5 py-0.5 hover:bg-muted",children:c.jsx(pd,{className:"h-3 w-3"})})}),c.jsxs("div",{className:"flex items-center gap-1 px-1.5 py-1 border-b shrink-0",children:[c.jsx(pl,{className:"h-3 w-3 text-muted-foreground shrink-0"}),c.jsx("input",{type:"text",placeholder:Li==="content"?"Search in files…":"Search file names…",value:ks,onChange:re=>ci(re.target.value),className:"min-w-0 flex-1 h-7 bg-transparent text-sm outline-none placeholder:text-muted-foreground/60"}),ks&&c.jsx("button",{onClick:()=>{ci(""),qs(null)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground",children:c.jsx(ti,{className:"h-3.5 w-3.5"})}),c.jsx("button",{onClick:()=>ef(re=>re==="files"?"content":"files"),className:`px-1.5 h-6 rounded text-2xs font-medium shrink-0 ${Li==="content"?"bg-primary/20 text-primary":"text-muted-foreground hover:bg-muted"}`,title:Li==="files"?"Switch to content search":"Switch to filename search",children:Li==="files"?"Name":"Content"})]}),ks.trim()?c.jsx(Th,{className:"flex-1 min-h-0",children:c.jsxs("div",{className:"p-1",children:[To&&c.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-2 text-sm text-muted-foreground",children:[c.jsx(ir,{className:"h-3.5 w-3.5 animate-spin"})," Searching…"]}),!To&&(zn==null?void 0:zn.files)&&zn.files.length>0&&zn.files.map(re=>c.jsxs("div",{className:"flex items-center gap-1.5 rounded px-1 py-2 cursor-pointer text-sm hover:bg-muted active:bg-muted",style:{paddingLeft:8},onClick:()=>{const fe=me?`${me.replace(/\\/g,"/")}/${re.path}`:re.path;so(fe),f&&Ds("editor"),ci(""),qs(null)},children:[c.jsx($o,{filename:re.name,className:"h-4 w-4 shrink-0"}),c.jsx("span",{className:"truncate flex-1",title:re.path,children:c.jsx(x1,{text:re.path,query:ks})})]},re.path)),!To&&(zn==null?void 0:zn.matches)&&zn.matches.length>0&&zn.matches.map((re,fe)=>c.jsxs("div",{className:"flex flex-col gap-0 rounded px-1 py-2 cursor-pointer text-sm hover:bg-muted active:bg-muted",style:{paddingLeft:8},onClick:()=>{const ue=me?`${me.replace(/\\/g,"/")}/${re.file}`:re.file;so(ue),f&&Ds("editor"),ci(""),qs(null)},children:[c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx($o,{filename:re.file.split("/").pop()||re.file,className:"h-4 w-4 shrink-0"}),c.jsx("span",{className:"truncate text-foreground",title:re.file,children:c.jsx(x1,{text:re.file,query:ks})}),c.jsxs("span",{className:"text-muted-foreground shrink-0",children:[":",re.line]})]}),c.jsx("span",{className:"truncate text-muted-foreground pl-6",children:c.jsx(x1,{text:re.content,query:ks})})]},`${re.file}:${re.line}:${fe}`)),!To&&zn&&!((gs=zn.files)!=null&&gs.length)&&!((eh=zn.matches)!=null&&eh.length)&&c.jsx("div",{className:"text-sm text-muted-foreground px-2 py-2",children:"No results found."})]})}):c.jsx(Th,{className:"flex-1 min-h-0",children:c.jsxs("div",{className:"p-1",children:[ao&&Ne.map(re=>c.jsx(rH,{node:re,depth:0,activeFilePath:Ct,expandedDirs:$e,onToggleDir:hr,onSelectFile:uo,onContextFile:Go,onTreeContextMenu:Fu,onMoveNode:Hu,onMobilePointerStart:Ga,isMobile:!0,normStatusMap:pt,dirChangesSet:At,mobileDragTargetPath:(pi==null?void 0:pi.dropDir)??null},re.path)),ui&&c.jsxs(c.Fragment,{children:[ao&&c.jsx("div",{className:"text-xs uppercase tracking-wider text-muted-foreground px-2 pt-3 pb-1 font-medium",children:"Dropped files"}),r.map(re=>c.jsxs("div",{onClick:()=>ff(re.id),className:`group flex items-center gap-1.5 rounded px-1 py-2 cursor-pointer text-sm ${!Ct&&n===re.id?"bg-primary/15 text-foreground":"hover:bg-muted active:bg-muted"}`,style:{paddingLeft:18},children:[c.jsx($o,{filename:re.name,className:"h-4 w-4"}),c.jsx("span",{className:"truncate flex-1",title:re.path,children:re.path})]},re.id))]}),!ao&&!ui&&c.jsx("div",{className:"p-3 flex flex-col items-center gap-2",children:c.jsx("p",{className:"text-sm text-muted-foreground text-center",children:ce?"Loading workspace files...":Xe?`Could not load files: ${Xe}`:"No files loaded yet. The workspace opens automatically when the agent works with files."})})]})})]}),K==="git"&&p&&c.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[c.jsxs("div",{className:"flex items-center gap-1.5 h-7 px-2 border-b bg-muted/10 shrink-0",children:[(rt==null?void 0:rt.branch)&&c.jsxs("span",{className:"text-xs text-muted-foreground truncate flex-1",children:[c.jsx(Xf,{className:"h-3 w-3 inline mr-0.5 -mt-px"}),rt.branch]}),me&&c.jsxs("select",{className:"h-6 rounded border bg-background px-1.5 text-2xs text-muted-foreground",value:String(Pr),onChange:re=>Gd(re.target.value),title:`${KF(Pr)}. Interval: ${zr}s`,children:[c.jsx("option",{value:"false",children:"Auto-fetch off"}),c.jsx("option",{value:"true",children:"Auto-fetch origin"}),c.jsx("option",{value:"all",children:"Auto-fetch all"})]}),c.jsx("button",{className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground",onClick:Lr,disabled:$t,children:c.jsx(sa,{className:`h-3.5 w-3.5 ${$t?"animate-spin":""}`})}),rt!=null&&rt.behindCount?c.jsxs("button",{className:"relative p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground",onClick:Wc,disabled:dt,title:`Pull ${rt.behindCount} commit${rt.behindCount>1?"s":""}`,children:[c.jsx(Im,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"absolute -right-1 -top-1 min-w-[14px] rounded-full bg-primary px-1 text-2xs font-semibold leading-[14px] text-primary-foreground",children:rt.behindCount})]}):null,rt!=null&&rt.aheadCount?c.jsxs("button",{className:"relative p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground",onClick:()=>oo("commit_push"),disabled:dt,title:`Push ${rt.aheadCount} commit${rt.aheadCount>1?"s":""}`,children:[c.jsx(oD,{className:"h-3.5 w-3.5"}),c.jsx("span",{className:"absolute -right-1 -top-1 min-w-[14px] rounded-full bg-primary px-1 text-2xs font-semibold leading-[14px] text-primary-foreground",children:rt.aheadCount})]}):null]}),me&&rt&&c.jsxs("div",{className:"px-2 py-2 border-b bg-muted/5 shrink-0 space-y-2",children:[c.jsxs("div",{className:"relative",children:[c.jsx("textarea",{className:"w-full text-sm bg-background border rounded px-2 py-1.5 pr-8 resize-none placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-primary/50",rows:2,placeholder:"Commit message",value:Ut,onChange:re=>pr(re.target.value),disabled:dt||rr}),c.jsx("button",{className:"absolute top-1.5 right-1.5 p-0.5 rounded text-muted-foreground hover:text-primary transition-colors disabled:opacity-40 disabled:cursor-not-allowed",onClick:$r,disabled:!lo,title:"Generate commit message with AI",children:rr?c.jsx(ir,{className:"h-3.5 w-3.5 animate-spin"}):c.jsx(s2,{className:"h-3.5 w-3.5"})})]}),c.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[hf(!0),Vc(!0)]}),ur&&c.jsx("div",{className:"text-xs text-red-500",children:ur})]}),c.jsxs(Th,{className:"flex-1 min-h-0",children:[$t&&!rt&&c.jsxs("div",{className:"flex items-center justify-center gap-2 p-4 text-sm text-muted-foreground",children:[c.jsx(ir,{className:"h-4 w-4 animate-spin"}),"Loading..."]}),rt&&Yr===0&&c.jsx("div",{className:"p-4 text-sm text-muted-foreground text-center",children:"No changes detected."}),rt&&Yr>0&&c.jsxs("div",{className:"p-1",children:[c.jsxs("div",{className:"text-xs text-muted-foreground px-2 py-1.5 font-medium",children:["Source Control (",Yr,")",c.jsxs("span",{className:"ml-1",children:[c.jsxs("span",{className:"text-green-500",children:["+",rt.index.insertions+rt.workingTree.insertions]})," ",c.jsxs("span",{className:"text-red-500",children:["-",rt.index.deletions+rt.workingTree.deletions]})]})]}),Oo("Staged",Za,df,rt.index,"unstage",!0),Oo("Changes",lc,rs,rt.workingTree,"stage",!0)]}),!me&&c.jsx("div",{className:"p-4 text-sm text-muted-foreground text-center",children:"Open a workspace to see git changes."})]})]}),K==="editor"&&g&&c.jsx("div",{className:"flex-1 flex flex-col min-h-0",children:c.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:Oe?c.jsxs("div",{className:"h-full flex items-center justify-center text-sm text-muted-foreground gap-2",children:[c.jsx(ir,{className:"h-4 w-4 animate-spin"}),"Loading diff..."]}):(ze==null?void 0:ze.type)==="diff"&&ze.diffMode==="review"?c.jsx(zF,{filePath:ze.path,originalContent:ze.originalContent??"",modifiedContent:ze.modifiedContent??"",language:ze.language??"plaintext",onClose:()=>ms(ze.id),onApply:re=>{P==null||P(ze.path,re)}}):(ze==null?void 0:ze.type)==="diff"&&ze.diffMode==="git"?c.jsx(W2,{className:"h-full",editorClassName:"h-full",original:ze.originalContent??((wg=ze.diffEntry)==null?void 0:wg.original)??"",modified:ze.modifiedContent??((Lp=ze.diffEntry)==null?void 0:Lp.modified)??"",language:ze.language??"plaintext",modelKey:`${ze.id}:${ze.version??0}`,renderSideBySide:!1,options:{minimap:{enabled:!1},"semanticHighlighting.enabled":!0,lineNumbers:"on",wordWrap:"on",scrollBeyondLastLine:!1}},`${ze.id}:${ze.version??0}`):(ze==null?void 0:ze.type)==="preview"?vg("Open or start a preview from the side controls."):(ze==null?void 0:ze.type)==="architecture"?c.jsx(S7,{diagram:G??null,isGenerating:X,onGenerate:Q,onRegenerate:Q,theme:ie,onRenderResult:q}):zt?c.jsxs("div",{className:"h-full flex items-center justify-center text-sm text-muted-foreground gap-2",children:[c.jsx(ir,{className:"h-4 w-4 animate-spin"}),"Loading..."]}):(ze==null?void 0:ze.type)==="file"?c.jsx(C7,{path:ze.path,language:ze.language??"plaintext",value:ze.content??"",originalContent:ze.originalContent,theme:pe,readOnly:!Mb(ze),onChange:re=>yg(ze.id,re),onReferenceSelection:(re,fe,ue)=>qi({id:ze.id,name:n0(ze),path:ze.path,content:ze.content??"",language:ze.language??"plaintext"},re,fe,ue),onApplyReview:async re=>{await(P==null?void 0:P(ze.path,re)),dn(fe=>fe.map(ue=>ue.id===ze.id?{...ue,content:re,modifiedContent:re,savedContent:re,originalContent:null,isDirty:!1}:ue))}},ze.id):Fn?c.jsx("pre",{className:"text-xs leading-relaxed p-2 font-mono whitespace-pre overflow-x-auto text-foreground",children:c.jsx("code",{children:Fn.content})}):c.jsx("div",{className:"h-full flex items-center justify-center text-xs text-muted-foreground px-4 text-center",children:"Tap a file in the Files tab to view it here."})})}),er&&c.jsx("div",{className:"fixed inset-0 z-50",onPointerDown:()=>Gn(null),children:c.jsxs("div",{ref:Wd,className:"ui-panel-surface absolute max-h-[70vh] w-48 overflow-auto rounded-lg border p-1 shadow-lg",style:No?{left:No.left,top:No.top}:{opacity:0,left:er.x,top:er.y},onPointerDown:re=>re.stopPropagation(),children:[c.jsx("div",{className:"px-2 py-1.5 text-xs font-medium text-muted-foreground truncate",children:er.node.name}),c.jsxs("button",{className:"ui-menu-item",onClick:()=>{Go(er.node),Gn(null)},children:[c.jsx(Ho,{className:"h-3 w-3"}),"Add to Chat"]}),er.node.kind==="file"&&c.jsx("button",{className:"ui-menu-item",onClick:()=>{const re=er.node;sc(re),Gn(null)},children:"Open"}),c.jsx("div",{className:"my-1 h-px bg-border"}),c.jsxs("button",{className:"ui-menu-item",onClick:()=>{const re=er.node.kind==="dir"?er.node.path:er.node.path.includes("/")?er.node.path.slice(0,er.node.path.lastIndexOf("/")):me??"";Qi({parentDir:re,kind:"file"}),Fa(""),Gn(null)},children:[c.jsx(fC,{className:"h-3 w-3"}),"New File"]}),c.jsxs("button",{className:"ui-menu-item",onClick:()=>{const re=er.node.kind==="dir"?er.node.path:er.node.path.includes("/")?er.node.path.slice(0,er.node.path.lastIndexOf("/")):me??"";Qi({parentDir:re,kind:"dir"}),Fa(""),Gn(null)},children:[c.jsx(CN,{className:"h-3 w-3"}),"New Folder"]}),c.jsx("div",{className:"my-1 h-px bg-border"}),c.jsxs("button",{className:"ui-menu-item",onClick:()=>{Wi({path:er.node.path,name:er.node.name,kind:er.node.kind==="dir"?"dir":"file"}),Bc(er.node.name),Gn(null)},children:[c.jsx(jN,{className:"h-3 w-3"}),"Rename"]}),c.jsxs("button",{className:"ui-menu-item text-red-500 hover:text-red-600",onClick:()=>{oc(er.node),Gn(null)},children:[c.jsx(Lh,{className:"h-3 w-3"}),"Delete"]}),c.jsx("div",{className:"my-1 h-px bg-border"}),c.jsxs("button",{className:"ui-menu-item",onClick:()=>{xg(er.node),Gn(null)},children:[c.jsx(Nc,{className:"h-3 w-3"}),"Copy Path"]}),c.jsxs("button",{className:"ui-menu-item",onClick:()=>{pa(er.node),Gn(null)},children:[c.jsx(Nc,{className:"h-3 w-3"}),"Copy Relative Path"]})]})}),si&&c.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/30",onPointerDown:()=>Wi(null),children:c.jsxs("div",{className:"ui-panel-surface min-w-[280px] max-w-[calc(100vw-2rem)] p-4",onPointerDown:re=>re.stopPropagation(),children:[c.jsxs("div",{className:"mb-2 text-sm font-medium",children:["Rename “",si.name,"”"]}),c.jsx(Vn,{className:"h-10 text-sm",autoFocus:!0,value:Mu,onChange:re=>Bc(re.target.value),onKeyDown:re=>{re.key==="Enter"&&cf(),re.key==="Escape"&&Wi(null)}}),c.jsxs("div",{className:"mt-3 flex justify-end gap-1.5",children:[c.jsx(_e,{variant:"ghost",size:"sm",className:"h-8 rounded-md px-3 text-xs",onClick:()=>Wi(null),children:"Cancel"}),c.jsx(_e,{size:"sm",className:"h-8 rounded-md px-3 text-xs",onClick:()=>void cf(),children:"Rename"})]})]})}),Ui&&c.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/30",onPointerDown:()=>Qi(null),children:c.jsxs("div",{className:"ui-panel-surface min-w-[280px] max-w-[calc(100vw-2rem)] p-4",onPointerDown:re=>re.stopPropagation(),children:[c.jsxs("div",{className:"mb-2 text-sm font-medium",children:["New ",Ui.kind==="dir"?"Folder":"File"]}),c.jsx(Vn,{className:"h-10 text-sm",autoFocus:!0,placeholder:Ui.kind==="dir"?"folder-name":"filename.ext",value:Cl,onChange:re=>Fa(re.target.value),onKeyDown:re=>{re.key==="Enter"&&Fc(),re.key==="Escape"&&Qi(null)}}),c.jsxs("div",{className:"mt-3 flex justify-end gap-1.5",children:[c.jsx(_e,{variant:"ghost",size:"sm",className:"h-8 rounded-md px-3 text-xs",onClick:()=>Qi(null),children:"Cancel"}),c.jsx(_e,{size:"sm",className:"h-8 rounded-md px-3 text-xs",onClick:()=>void Fc(),children:"Create"})]})]})})]})}return c.jsxs("aside",{className:Fe("relative bg-muted/20 flex min-h-0",ke.maxCollapsed?"flex-1":"shrink-0",Xt?"z-30 border-r shadow-2xl":!ke.maxCollapsed&&g&&"border-r"),style:iKe({showTree:p,showEditor:g,panelSize:ke.size,treeSize:St.size,maxCollapsed:ke.maxCollapsed}),children:[p&&!Xt&&!ke.collapsed&&c.jsx("div",{className:Fe("border-r bg-background transition-colors flex flex-col overflow-hidden",g?"shrink-0":"flex-1 min-w-0"),style:g?{width:St.collapsed?0:St.size}:void 0,children:Jh&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center h-[35px] border-b bg-muted/20 shrink-0 px-1 gap-0.5 overflow-hidden",children:[c.jsxs("button",{className:`flex h-7 items-center gap-1 px-2 rounded text-xs font-medium transition-colors whitespace-nowrap shrink-0 ${li==="files"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,onClick:()=>{ds("files"),dr(null)},children:[c.jsx(Ph,{className:"h-3 w-3 shrink-0"}),"Files"]}),c.jsxs("button",{className:`flex h-7 items-center gap-1 px-2 rounded text-xs font-medium transition-colors whitespace-nowrap shrink-0 ${li==="git"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,onClick:()=>{ds("git"),dr(null)},children:[c.jsx(Xf,{className:"h-3 w-3 shrink-0"}),"Source Control",Yr>0&&c.jsx("span",{className:"ml-0.5 text-2xs bg-primary/20 text-primary rounded-full px-1.5 leading-tight font-bold",children:Yr})]}),c.jsx("div",{className:"flex-1"}),c.jsx("button",{onClick:()=>{if(v){v();return}!g&&b&&b(),St.collapse()},className:"flex h-7 items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors rounded px-1 hover:bg-muted",children:c.jsx(pd,{className:"h-3 w-3"})})]}),li==="files"&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center gap-1 px-1.5 py-1 border-b shrink-0",children:[c.jsx(pl,{className:"h-3 w-3 text-muted-foreground shrink-0"}),c.jsx("input",{type:"text",placeholder:Li==="content"?"Search in files…":"Search file names…",value:ks,onChange:K=>ci(K.target.value),className:"min-w-0 flex-1 h-6 bg-transparent [font-size:0.9rem] outline-none placeholder:text-muted-foreground/60"}),ks&&c.jsx("button",{onClick:()=>{ci(""),qs(null)},className:"p-0.5 rounded hover:bg-muted text-muted-foreground",children:c.jsx(ti,{className:"h-3 w-3"})}),c.jsx("button",{onClick:()=>ef(K=>K==="files"?"content":"files"),className:`px-1.5 h-5 rounded text-2xs font-medium shrink-0 ${Li==="content"?"bg-primary/20 text-primary":"text-muted-foreground hover:bg-muted"}`,title:Li==="files"?"Switch to content search":"Switch to filename search",children:Li==="files"?"Name":"Content"})]}),ks.trim()?c.jsx(Th,{className:"flex-1 min-h-0",children:c.jsxs("div",{className:"p-1",children:[To&&c.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-2 text-xs text-muted-foreground",children:[c.jsx(ir,{className:"h-3 w-3 animate-spin"})," Searching…"]}),!To&&(zn==null?void 0:zn.files)&&zn.files.length>0&&zn.files.map(K=>c.jsxs("div",{className:"flex items-center gap-1 rounded px-1 py-1 cursor-pointer text-xs hover:bg-muted",style:{paddingLeft:8},onClick:()=>{const se=me?`${me.replace(/\\/g,"/")}/${K.path}`:K.path;so(se),ci(""),qs(null)},children:[c.jsx($o,{filename:K.name,className:"h-3.5 w-3.5 shrink-0"}),c.jsx("span",{className:"truncate flex-1",title:K.path,children:c.jsx(x1,{text:K.path,query:ks})})]},K.path)),!To&&(zn==null?void 0:zn.matches)&&zn.matches.length>0&&zn.matches.map((K,se)=>c.jsxs("div",{className:"flex flex-col gap-0 rounded px-1 py-1 cursor-pointer text-xs hover:bg-muted",style:{paddingLeft:8},onClick:()=>{const re=me?`${me.replace(/\\/g,"/")}/${K.file}`:K.file;so(re),ci(""),qs(null)},children:[c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx($o,{filename:K.file.split("/").pop()||K.file,className:"h-3.5 w-3.5 shrink-0"}),c.jsx("span",{className:"truncate text-foreground",title:K.file,children:c.jsx(x1,{text:K.file,query:ks})}),c.jsxs("span",{className:"text-muted-foreground shrink-0",children:[":",K.line]})]}),c.jsx("span",{className:"truncate text-muted-foreground pl-5",children:c.jsx(x1,{text:K.content,query:ks})})]},`${K.file}:${K.line}:${se}`)),!To&&zn&&!((Sg=zn.files)!=null&&Sg.length)&&!((kg=zn.matches)!=null&&kg.length)&&c.jsx("div",{className:"text-xs text-muted-foreground px-2 py-2",children:"No results found."})]})}):c.jsx(Th,{className:"flex-1 min-h-0",children:c.jsxs("div",{className:"p-1",children:[ao&&Ne.map(K=>c.jsx(rH,{node:K,depth:0,activeFilePath:Ct,expandedDirs:$e,onToggleDir:hr,onSelectFile:Rl,onContextFile:Go,onTreeContextMenu:Fu,onMoveNode:Hu,normStatusMap:pt,dirChangesSet:At,mobileDragTargetPath:(pi==null?void 0:pi.dropDir)??null},K.path)),ui&&c.jsxs(c.Fragment,{children:[ao&&c.jsx("div",{className:"text-2xs uppercase tracking-wider text-muted-foreground px-2 pt-3 pb-1 font-medium",children:"Dropped files"}),r.map(K=>c.jsxs("div",{onClick:()=>Zd(K.id),onContextMenu:se=>{se.preventDefault(),o(K)},className:`group flex items-center gap-1 rounded px-1 py-1 cursor-pointer text-xs ${!Ct&&n===K.id?"bg-primary/15 text-foreground":"hover:bg-muted"}`,style:{paddingLeft:22},children:[c.jsx($o,{filename:K.name,className:"h-3.5 w-3.5"}),c.jsx("span",{className:"truncate flex-1",title:K.path,children:K.path}),c.jsx("button",{type:"button",className:"opacity-0 group-hover:opacity-100 p-0.5 rounded hover:bg-background",onClick:se=>{se.stopPropagation(),o(K)},title:"Add to chat",children:c.jsx(Ho,{className:"h-3 w-3"})})]},K.id))]}),!ao&&!ui&&c.jsx("div",{className:"p-3 flex flex-col items-center gap-2",children:c.jsx("p",{className:"text-xs text-muted-foreground",children:ce?"Loading workspace files...":Xe?`Could not load files: ${Xe}`:"No files loaded yet. The workspace opens automatically when the agent works with files."})})]})})]}),li==="git"&&c.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",children:[c.jsxs("div",{className:"flex h-[35px] items-center gap-1.5 px-2 border-b bg-muted/10 shrink-0 min-w-0",children:[(rt==null?void 0:rt.branch)&&c.jsxs("span",{className:"ui-caption truncate flex-1 min-w-0",title:rt.branch,children:[c.jsx(Xf,{className:"h-3 w-3 inline mr-0.5 -mt-px"}),rt.branch]}),!(rt!=null&&rt.branch)&&c.jsx("span",{className:"ui-caption flex-1 min-w-0",children:"No repo"}),me&&c.jsxs("select",{className:"h-7 rounded-md border border-input bg-background/90 px-2 text-xs text-muted-foreground shadow-sm shrink-0",value:String(Pr),onChange:K=>Gd(K.target.value),title:`${KF(Pr)}. Interval: ${zr}s`,children:[c.jsx("option",{value:"false",children:"Auto-fetch off"}),c.jsx("option",{value:"true",children:"Auto-fetch origin"}),c.jsx("option",{value:"all",children:"Auto-fetch all"})]}),c.jsx("button",{className:"ui-inline-action p-1",onClick:Lr,disabled:$t,title:"Refresh git status",children:c.jsx(sa,{className:`h-3 w-3 ${$t?"animate-spin":""}`})}),rt!=null&&rt.behindCount?c.jsxs("button",{className:"relative ui-inline-action p-1",onClick:Wc,disabled:dt,title:`Pull ${rt.behindCount} commit${rt.behindCount>1?"s":""}`,children:[c.jsx(Im,{className:"h-3 w-3"}),c.jsx("span",{className:"absolute -right-1 -top-1 min-w-[14px] rounded-full bg-primary px-1 text-2xs font-semibold leading-[14px] text-primary-foreground",children:rt.behindCount})]}):null,rt!=null&&rt.aheadCount?c.jsxs("button",{className:"relative ui-inline-action p-1",onClick:()=>oo("commit_push"),disabled:dt,title:`Push ${rt.aheadCount} commit${rt.aheadCount>1?"s":""}`,children:[c.jsx(oD,{className:"h-3 w-3"}),c.jsx("span",{className:"absolute -right-1 -top-1 min-w-[14px] rounded-full bg-primary px-1 text-2xs font-semibold leading-[14px] text-primary-foreground",children:rt.aheadCount})]}):null]}),me&&rt&&c.jsxs("div",{className:"px-2 py-1.5 border-b bg-muted/5 shrink-0 space-y-1.5",children:[c.jsxs("div",{className:"relative",children:[c.jsx(h4,{className:"min-h-[68px] resize-none pr-9 text-sm",rows:2,placeholder:"Commit message",value:Ut,onChange:K=>pr(K.target.value),onKeyDown:K=>{K.key==="Enter"&&(K.ctrlKey||K.metaKey)&&(K.preventDefault(),$l==="sync"?Op():Yr>0&&oo("commit"))},disabled:dt||rr}),c.jsx("button",{className:"absolute top-2 right-2 rounded-md p-1 text-muted-foreground transition-colors hover:bg-accent hover:text-primary disabled:cursor-not-allowed disabled:opacity-40",onClick:$r,disabled:!lo,title:"Generate commit message with AI",children:rr?c.jsx(ir,{className:"h-3 w-3 animate-spin"}):c.jsx(s2,{className:"h-3 w-3"})})]}),c.jsxs("div",{className:"flex items-center gap-1 flex-wrap min-w-0",children:[hf(),Vc()]}),ur&&c.jsx("div",{className:"ui-caption px-0.5 text-red-500",children:ur})]}),c.jsxs(Th,{className:"flex-1 min-h-0",children:[$t&&!rt&&c.jsxs("div",{className:"flex items-center justify-center gap-2 p-4 text-xs text-muted-foreground",children:[c.jsx(ir,{className:"h-3 w-3 animate-spin"}),"Loading..."]}),rt&&Yr===0&&c.jsx("div",{className:"p-3 text-xs text-muted-foreground text-center",children:"No changes detected."}),rt&&Yr>0&&c.jsxs("div",{className:"p-1",children:[c.jsxs("div",{className:"ui-eyebrow px-2 py-1",children:["Source Control (",Yr,")",c.jsxs("span",{className:"normal-case tracking-normal ml-1",children:[c.jsxs("span",{className:"text-green-500",children:["+",rt.index.insertions+rt.workingTree.insertions]})," ",c.jsxs("span",{className:"text-red-500",children:["-",rt.index.deletions+rt.workingTree.deletions]})]})]}),Oo("Staged",Za,df,rt.index,"unstage"),Oo("Changes",lc,rs,rt.workingTree,"stage")]}),!me&&c.jsx("div",{className:"p-3 text-xs text-muted-foreground text-center",children:"Open a workspace to see git changes."})]})]})]})}),p&&!Xt&&!ke.collapsed&&Ru&&c.jsx("div",{className:"relative w-2 -mx-0.5 shrink-0 cursor-col-resize touch-none sash-handle",onPointerDown:St.onPointerDown,onDoubleClick:St.collapsed?()=>St.restore():void 0,children:c.jsx("div",{className:`absolute inset-y-0 left-1/2 w-px -translate-x-1/2 transition-[background-color] duration-100 ease-out ${St.isDragging?"bg-primary/50":"bg-border/60"}`})}),Ru&&c.jsxs("div",{className:Xt?"absolute inset-0 z-20 flex flex-col bg-background":"flex-1 min-w-0 min-h-0 flex flex-col",children:[c.jsxs("div",{className:"flex items-center h-[35px] bg-[var(--tab-bg,hsl(var(--muted)/0.3))] border-b shrink-0 min-w-0",children:[!Jh&&(p||v)&&c.jsx("button",{onClick:()=>{St.collapsed?St.restore():v&&v()},className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors rounded px-1.5 py-0.5 hover:bg-muted shrink-0 ml-1",title:"Show Files",children:c.jsx(Q$,{className:"h-3 w-3"})}),c.jsx("div",{ref:Qe,className:"flex items-center flex-1 min-w-0 overflow-x-auto scrollbar-none",onWheel:K=>{K.deltaY!==0&&(K.preventDefault(),Qe.current&&(Qe.current.scrollLeft+=K.deltaY))},children:Kr.map(K=>{const se=K.id===vn,re=K.type==="diff"&&K.diffMode==="git"&&K.diffEntry?K.diffEntry.status:void 0,fe=K.type!=="preview";return c.jsxs("div",{"data-tab-id":K.id,className:`group relative flex items-center gap-1.5 h-[35px] px-3 border-r border-border/40 cursor-pointer shrink-0 text-xs select-none transition-colors ${se?"bg-background text-foreground":"text-muted-foreground hover:bg-muted/50"}`,onClick:()=>Pl(K.id),onContextMenu:ue=>{ue.preventDefault(),Hd({tabId:K.id,x:ue.clientX,y:ue.clientY})},onMouseDown:ue=>{ue.button===1&&(ue.preventDefault(),ms(K.id))},draggable:fe,onDragStart:ue=>{if(!fe){ue.preventDefault();return}ua(K.id),ue.dataTransfer.effectAllowed=K.type==="file"?"copyMove":"move",ue.dataTransfer.setData("text/jait-tab",K.id),K.type==="file"&&ue.dataTransfer.setData("text/jait-file",JSON.stringify({path:K.path,name:K.label}))},onDragEnd:ue=>{fe&&Jd(ue,K.id)},onDragOver:ue=>{!Ic||Ic===K.id||(ue.preventDefault(),ue.dataTransfer.dropEffect="move")},onDrop:ue=>{ue.preventDefault();const Me=ue.dataTransfer.getData("text/jait-tab")||Ic;Me&&(Ll(Me,K.id),ua(null))},onDragEnter:ue=>{!Ic||Ic===K.id||(ue.preventDefault(),Ll(Ic,K.id))},title:K.path,children:[se&&c.jsx("div",{className:"absolute left-0 right-0 top-0 h-[2px] bg-primary"}),Ic===K.id&&c.jsx("div",{className:"absolute inset-0 border border-primary/60 pointer-events-none"}),re?c.jsx(g_,{status:re,className:"text-2xs"}):K.type==="architecture"?c.jsx(n2,{className:"h-3.5 w-3.5 shrink-0"}):K.type==="preview"?c.jsx(Ci,{className:"h-3.5 w-3.5 shrink-0"}):c.jsx($o,{filename:K.path,className:"h-3.5 w-3.5 shrink-0"}),K.isDirty&&c.jsx("span",{className:"shrink-0 text-2xs leading-none text-primary",children:"*"}),c.jsx("span",{className:"truncate max-w-[220px]",children:n0(K)}),c.jsx("button",{className:`p-0.5 rounded-sm hover:bg-foreground/10 shrink-0 transition-opacity ${se?"opacity-50 hover:opacity-100":"opacity-0 group-hover:opacity-50 hover:!opacity-100"}`,onClick:ue=>{ue.stopPropagation(),ms(K.id)},title:"Close (Middle-click)",children:c.jsx(ti,{className:"h-3 w-3"})})]},K.id)})}),(ws||(ze==null?void 0:ze.type)==="preview"||b||Ou)&&c.jsxs("div",{className:"flex items-center shrink-0",children:[Ou&&c.jsx("button",{onClick:()=>sn(K=>!K),className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors rounded px-1.5 py-0.5 hover:bg-muted shrink-0",title:Xt?"Restore tab size":"Maximize active tab",children:Xt?c.jsx(O9,{className:"h-3 w-3"}):c.jsx(Vge,{className:"h-3 w-3"})}),ws&&c.jsx("button",{onClick:()=>{vn&&Np(vn)},className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors rounded px-1.5 py-0.5 hover:bg-muted shrink-0",title:ze!=null&&ze.isSaving?"Saving...":"Save file (Ctrl/Cmd+S)",disabled:ze==null?void 0:ze.isSaving,children:c.jsx(M9,{className:`h-3 w-3 ${ze!=null&&ze.isSaving?"animate-pulse":""}`})}),(ze==null?void 0:ze.type)==="preview"&&c.jsxs(c.Fragment,{children:[c.jsx("button",{onClick:Ya,className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors rounded px-1.5 py-0.5 hover:bg-muted shrink-0",title:"Refresh preview",children:c.jsx(sa,{className:"h-3 w-3"})}),c.jsx("button",{onClick:()=>hs(K=>!K),className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors rounded px-1.5 py-0.5 hover:bg-muted shrink-0",title:"Preview controls",children:c.jsx(NN,{className:"h-3 w-3"})})]}),b&&!ke.collapsed&&!ke.maxCollapsed&&c.jsx("button",{onClick:b,className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors rounded px-1.5 py-0.5 hover:bg-muted shrink-0 mx-1",children:c.jsx(pd,{className:"h-3 w-3"})}),ke.maxCollapsed&&c.jsx("button",{onClick:ke.restore,className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors rounded px-1.5 py-0.5 hover:bg-muted shrink-0",title:"Show Chat",children:c.jsx(Rm,{className:"h-3 w-3"})})]})]}),ws&&(ze==null?void 0:ze.saveError)&&c.jsx("div",{className:"border-b bg-destructive/5 px-3 py-1 text-xs text-destructive shrink-0",children:ze.saveError}),c.jsx("div",{className:"flex-1 min-h-0",children:Oe?c.jsxs("div",{className:"h-full flex items-center justify-center text-sm text-muted-foreground gap-2",children:[c.jsx(ir,{className:"h-4 w-4 animate-spin"}),"Loading diff..."]}):(ze==null?void 0:ze.type)==="diff"&&ze.diffMode==="review"?c.jsx(zF,{filePath:ze.path,originalContent:ze.originalContent??"",modifiedContent:ze.modifiedContent??"",language:ze.language??"plaintext",onClose:()=>ms(ze.id),onApply:K=>{P==null||P(ze.path,K)}}):(ze==null?void 0:ze.type)==="diff"&&ze.diffMode==="git"?c.jsx(W2,{className:"h-full",editorClassName:"h-full",original:ze.originalContent??((Di=ze.diffEntry)==null?void 0:Di.original)??"",modified:ze.modifiedContent??((pf=ze.diffEntry)==null?void 0:pf.modified)??"",language:ze.language??Sa(ze.path),modelKey:`${ze.id}:${ze.version??0}`,renderSideBySide:!f,options:{minimap:{enabled:!1}}},`${ze.id}:${ze.version??0}`):(ze==null?void 0:ze.type)==="preview"?vg("Open or start a preview from the side controls."):(ze==null?void 0:ze.type)==="architecture"?c.jsx(S7,{diagram:G??null,isGenerating:X,onGenerate:Q,onRegenerate:Q,theme:ie,onRenderResult:q}):zt&&(ze==null?void 0:ze.id)===vn?c.jsxs("div",{className:"h-full flex items-center justify-center text-sm text-muted-foreground gap-2",children:[c.jsx(ir,{className:"h-4 w-4 animate-spin"}),"Loading..."]}):(ze==null?void 0:ze.type)==="file"?c.jsx(C7,{path:ze.path,language:ze.language??"plaintext",value:ze.content??"",originalContent:ze.originalContent,theme:pe,readOnly:!Mb(ze),onChange:K=>yg(ze.id,K),onReferenceSelection:(K,se,re)=>qi({id:ze.id,name:n0(ze),path:ze.path,content:ze.content??"",language:ze.language??"plaintext"},K,se,re),onApplyReview:async K=>{await(P==null?void 0:P(ze.path,K)),dn(se=>se.map(re=>re.id===ze.id?{...re,content:K,modifiedContent:K,savedContent:K,originalContent:null,isDirty:!1}:re))}},ze.id):Fn?c.jsx(Bj,{height:"100%",beforeMount:K=>wu(K,pe),theme:pe,path:Fn.path,language:Fn.language,value:Fn.content,onMount:(K,se)=>{wu(se,pe);const re=()=>{var qe,Mt;const fe=(qe=K.getModel)==null?void 0:qe.call(K),ue=(Mt=K.getSelection)==null?void 0:Mt.call(K);if(!fe||!ue||ue.isEmpty()){ot.current=null;return}const Me=fe.getValueInRange(ue).trim();if(!Me){ot.current=null;return}const Ae=`${Fn.path}:${ue.startLineNumber}:${ue.endLineNumber}:${Me}`;ot.current!==Ae&&(ot.current=Ae,a==null||a({id:Fn.path,name:Fn.path.split("/").pop()??Fn.path,path:Fn.path,content:Fn.content,language:Fn.language},Me,ue.startLineNumber,ue.endLineNumber))};K.onMouseUp(()=>window.setTimeout(re,0)),K.onKeyUp(()=>window.setTimeout(re,0))},options:{readOnly:!0,minimap:{enabled:!1},"semanticHighlighting.enabled":!0,fontSize:13,automaticLayout:!0}}):c.jsx("div",{className:"h-full flex items-center justify-center text-sm text-muted-foreground text-center",children:"Open a file from the explorer to preview it here."})})]}),(pi==null?void 0:pi.active)&&c.jsxs("div",{className:"pointer-events-none fixed z-50 rounded-md border bg-background/95 px-2 py-1 text-xs shadow-lg",style:{left:pi.x+12,top:pi.y+12},children:["Move ",pi.node.name]}),Hi&&c.jsxs("div",{className:"ui-panel-surface fixed z-50 min-w-[170px] py-1",style:{left:Hi.x,top:Hi.y},onPointerDown:K=>K.stopPropagation(),children:[c.jsx("button",{className:"ui-menu-item",onClick:()=>ms(Hi.tabId),children:"Close"}),c.jsx("button",{className:"ui-menu-item",disabled:((uc=Kr.find(K=>K.id===Hi.tabId))==null?void 0:uc.type)==="preview",onClick:()=>{Uc(Hi.tabId)},children:"Move to New Window"}),c.jsx("button",{className:"ui-menu-item",disabled:Kr.length<=1,onClick:()=>$s(Hi.tabId),children:"Close Others"}),c.jsx("button",{className:"ui-menu-item",disabled:Ts<0||Ts>=Kr.length-1,onClick:()=>Ao(Hi.tabId),children:"Close to the Right"}),c.jsx("div",{className:"my-1 h-px bg-border"}),c.jsx("button",{className:"ui-menu-item",disabled:Kr.length===0,onClick:Qd,children:"Close All"})]}),er&&(f?c.jsxs("div",{className:"fixed inset-0 z-50",onPointerDown:()=>Gn(null),children:[c.jsx("div",{className:"absolute inset-0 bg-black/30"}),c.jsxs("div",{ref:Wd,className:"ui-panel-surface absolute inset-x-3 bottom-3 max-h-[70vh] overflow-auto rounded-2xl p-2",onPointerDown:K=>K.stopPropagation(),children:[c.jsx("div",{className:"px-3 py-2 text-xs font-medium uppercase tracking-[0.08em] text-muted-foreground",children:er.node.name}),c.jsxs("button",{className:"ui-menu-item",onClick:()=>{Go(er.node),Gn(null)},children:[c.jsx(Ho,{className:"h-3 w-3"}),"Add to Chat"]}),er.node.kind==="file"&&c.jsx("button",{className:"ui-menu-item",onClick:()=>{const K=er.node;sc(K),Gn(null)},children:"Open"}),c.jsx("div",{className:"my-1 h-px bg-border"}),c.jsxs("button",{className:"ui-menu-item",onClick:()=>{const K=er.node.kind==="dir"?er.node.path:er.node.path.includes("/")?er.node.path.slice(0,er.node.path.lastIndexOf("/")):me??"";Qi({parentDir:K,kind:"file"}),Fa(""),Gn(null)},children:[c.jsx(fC,{className:"h-3 w-3"}),"New File"]}),c.jsxs("button",{className:"ui-menu-item",onClick:()=>{const K=er.node.kind==="dir"?er.node.path:er.node.path.includes("/")?er.node.path.slice(0,er.node.path.lastIndexOf("/")):me??"";Qi({parentDir:K,kind:"dir"}),Fa(""),Gn(null)},children:[c.jsx(CN,{className:"h-3 w-3"}),"New Folder"]}),c.jsx("div",{className:"my-1 h-px bg-border"}),c.jsxs("button",{className:"ui-menu-item",onClick:()=>{Wi({path:er.node.path,name:er.node.name,kind:er.node.kind==="dir"?"dir":"file"}),Bc(er.node.name),Gn(null)},children:[c.jsx(jN,{className:"h-3 w-3"}),"Rename"]}),c.jsxs("button",{className:"ui-menu-item text-red-500 hover:text-red-600",onClick:()=>{oc(er.node),Gn(null)},children:[c.jsx(Lh,{className:"h-3 w-3"}),"Delete"]}),c.jsx("div",{className:"my-1 h-px bg-border"}),c.jsxs("button",{className:"ui-menu-item",onClick:()=>{xg(er.node),Gn(null)},children:[c.jsx(Nc,{className:"h-3 w-3"}),"Copy Path"]}),c.jsxs("button",{className:"ui-menu-item",onClick:()=>{pa(er.node),Gn(null)},children:[c.jsx(Nc,{className:"h-3 w-3"}),"Copy Relative Path"]})]})]}):c.jsxs("div",{ref:Wd,className:"ui-panel-surface fixed z-50 min-w-[180px] py-1",style:{left:(No==null?void 0:No.left)??er.x,top:(No==null?void 0:No.top)??er.y,visibility:No?"visible":"hidden"},onPointerDown:K=>K.stopPropagation(),children:[c.jsxs("button",{className:"ui-menu-item",onClick:()=>{Go(er.node),Gn(null)},children:[c.jsx(Ho,{className:"h-3 w-3"}),"Add to Chat"]}),er.node.kind==="file"&&c.jsx("button",{className:"ui-menu-item",onClick:()=>{const K=er.node;sc(K),Gn(null)},children:"Open"}),c.jsx("div",{className:"my-1 h-px bg-border"}),c.jsxs("button",{className:"ui-menu-item",onClick:()=>{const K=er.node.kind==="dir"?er.node.path:er.node.path.includes("/")?er.node.path.slice(0,er.node.path.lastIndexOf("/")):me??"";Qi({parentDir:K,kind:"file"}),Fa(""),Gn(null)},children:[c.jsx(fC,{className:"h-3 w-3"}),"New File"]}),c.jsxs("button",{className:"ui-menu-item",onClick:()=>{const K=er.node.kind==="dir"?er.node.path:er.node.path.includes("/")?er.node.path.slice(0,er.node.path.lastIndexOf("/")):me??"";Qi({parentDir:K,kind:"dir"}),Fa(""),Gn(null)},children:[c.jsx(CN,{className:"h-3 w-3"}),"New Folder"]}),c.jsx("div",{className:"my-1 h-px bg-border"}),c.jsxs("button",{className:"ui-menu-item",onClick:()=>{Wi({path:er.node.path,name:er.node.name,kind:er.node.kind==="dir"?"dir":"file"}),Bc(er.node.name),Gn(null)},children:[c.jsx(jN,{className:"h-3 w-3"}),"Rename"]}),c.jsxs("button",{className:"ui-menu-item text-red-500 hover:text-red-600",onClick:()=>{oc(er.node),Gn(null)},children:[c.jsx(Lh,{className:"h-3 w-3"}),"Delete"]}),c.jsx("div",{className:"my-1 h-px bg-border"}),c.jsxs("button",{className:"ui-menu-item",onClick:()=>{xg(er.node),Gn(null)},children:[c.jsx(Nc,{className:"h-3 w-3"}),"Copy Path"]}),c.jsxs("button",{className:"ui-menu-item",onClick:()=>{pa(er.node),Gn(null)},children:[c.jsx(Nc,{className:"h-3 w-3"}),"Copy Relative Path"]})]})),si&&c.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/30",onPointerDown:()=>Wi(null),children:c.jsxs("div",{className:"ui-panel-surface min-w-[320px] p-4",onPointerDown:K=>K.stopPropagation(),children:[c.jsxs("div",{className:"mb-2 text-sm font-medium",children:['Rename "',si.name,'"']}),c.jsx(Vn,{className:"h-10 text-sm",autoFocus:!0,value:Mu,onChange:K=>Bc(K.target.value),onKeyDown:K=>{K.key==="Enter"&&cf(),K.key==="Escape"&&Wi(null)}}),c.jsxs("div",{className:"mt-3 flex justify-end gap-1.5",children:[c.jsx(_e,{variant:"ghost",size:"sm",className:"h-8 rounded-md px-3 text-xs",onClick:()=>Wi(null),children:"Cancel"}),c.jsx(_e,{size:"sm",className:"h-8 rounded-md px-3 text-xs",onClick:()=>void cf(),children:"Rename"})]})]})}),Ui&&c.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/30",onPointerDown:()=>Qi(null),children:c.jsxs("div",{className:"ui-panel-surface min-w-[320px] p-4",onPointerDown:K=>K.stopPropagation(),children:[c.jsxs("div",{className:"mb-2 text-sm font-medium",children:["New ",Ui.kind==="dir"?"Folder":"File"]}),c.jsx(Vn,{className:"h-10 text-sm",autoFocus:!0,placeholder:Ui.kind==="dir"?"folder-name":"filename.ext",value:Cl,onChange:K=>Fa(K.target.value),onKeyDown:K=>{K.key==="Enter"&&Fc(),K.key==="Escape"&&Qi(null)}}),c.jsxs("div",{className:"mt-3 flex justify-end gap-1.5",children:[c.jsx(_e,{variant:"ghost",size:"sm",className:"h-8 rounded-md px-3 text-xs",onClick:()=>Qi(null),children:"Cancel"}),c.jsx(_e,{size:"sm",className:"h-8 rounded-md px-3 text-xs",onClick:()=>void Fc(),children:"Create"})]})]})}),(g||p)&&c.jsxs("div",{className:`${!g||Xt&&!ke.collapsed?"absolute right-0 inset-y-0 w-2 z-30":ke.collapsed?"absolute left-0 inset-y-0 w-2 z-30":"relative w-2 -mx-0.5 shrink-0"} cursor-col-resize touch-none sash-handle`,onPointerDown:ke.onPointerDown,onDoubleClick:ke.collapsed||ke.maxCollapsed?ke.restore:void 0,children:[c.jsx("div",{className:`absolute inset-y-0 left-1/2 w-px -translate-x-1/2 transition-[background-color] duration-100 ease-out ${ke.isDragging?"bg-primary/50":"bg-border/60"}`}),c.jsx("style",{children:`.sash-handle:hover > div { background-color: hsl(var(--primary) / 0.4) !important; transition-delay: 300ms; }
1147
- .sash-handle:active > div { background-color: hsl(var(--primary) / 0.5) !important; transition-delay: 0ms; }`})]})]})});function CKe({filePath:e,oldText:r,newText:n,writtenContent:i,isNewFile:s,className:o}){const a=e.split("/").pop()??e,l=q_(e),d=y.useMemo(()=>r!=null&&n!=null?{original:r,modified:n}:i!=null?{original:"",modified:i}:null,[r,n,i,s]);return d?c.jsxs("div",{className:Fe("rounded-md border bg-background overflow-hidden",o),children:[c.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-muted/40 border-b",children:[c.jsx($o,{filename:a,className:"h-3.5 w-3.5 shrink-0"}),c.jsx("span",{className:"text-xs font-mono text-muted-foreground truncate",children:e})]}),c.jsx(W2,{original:d.original,modified:d.modified,language:l,className:"h-80",editorClassName:"h-full",emptyMessage:s?"New file contents.":"No visible changes.",options:{renderSideBySide:!1,lineNumbers:"on",wordWrap:"on"}})]}):null}const jKe=/\.(?:png|jpe?g|gif|webp)$/i;function NKe(e){return/^[a-z][a-z0-9+.-]*:/i.test(e)}function TKe(e){return e.startsWith("/api/browser/screenshot")||e.startsWith("/api/dev-proxy/")}function EKe(e){return jKe.test(e)&&(e.startsWith("/")||e.startsWith("./")||e.startsWith("../")||e.includes("/")||e.includes("\\"))}function yoe(e,r=Hn()){const n=e.trim();return n?n.startsWith("data:image/")||n.startsWith("blob:")||/^https?:\/\//i.test(n)?n:TKe(n)?`${r}${n.startsWith("/")?"":"/"}${n}`:NKe(n)?null:EKe(n)?`${r}/api/browser/screenshot?path=${encodeURIComponent(n)}`:null:null}function pu(...e){for(const r of e)if(typeof r=="string"&&r.trim())return r}function Om(...e){for(const r of e)if(r&&typeof r=="object"&&!Array.isArray(r))return r}function i0(e){if(typeof e=="string")try{const r=JSON.parse(e);if(r&&typeof r=="object"&&!Array.isArray(r))return r}catch{}}function AKe(e,r=80){const n=e.trim();return n.length<=r?n:`${n.slice(0,r-1)}…`}function OKe(e){if(typeof e=="string"){const r=e.trim();return r?AKe(r,48):void 0}if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e))return`${e.length} item${e.length===1?"":"s"}`;if(e&&typeof e=="object")return"object"}function RKe(e){return e.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").trim().toLowerCase()}function voe(e){const r=e.trim();if(!r)return null;const n=r.match(/(?:^|[\s:(['"`])((?:\/|\.\/|\.\.\/)?(?:[\w.@-]+\/)+[\w.@-]+(?:\.[\w-]+)?)/);if(n!=null&&n[1])return n[1];const i=r.match(/(?:^|[\s:(['"`])((?:\/|\.\/|\.\.\/)?[\w.@-]+(?:\/[\w.@-]+)*\.[\w-]+)/);return i!=null&&i[1]?i[1]:null}function lE(e){return/\.(?:png|jpe?g|gif|webp)$/i.test(e.trim())}function iH(e){if(Array.isArray(e))for(const r of e){if(!r||typeof r!="object")continue;const n=pu(r.path,r.file_path,r.filePath,r.file,r.filename);if(n)return n}}function u6(e,r){var n,i,s,o;return Om(e.action,e.input,e.arguments,i0(e.action),i0(e.input),i0(e.arguments),r==null?void 0:r.result,r,r==null?void 0:r.input,r==null?void 0:r.arguments,i0(r==null?void 0:r.input),i0(r==null?void 0:r.arguments),(n=Om(r==null?void 0:r.result))==null?void 0:n.input,(i=Om(r==null?void 0:r.result))==null?void 0:i.arguments,i0((s=Om(r==null?void 0:r.result))==null?void 0:s.input),i0((o=Om(r==null?void 0:r.result))==null?void 0:o.arguments))}function xoe(e,r){const n=new Set((r==null?void 0:r.excludeKeys)??[]),i=(r==null?void 0:r.maxEntries)??3,s=Object.entries(e).filter(([o,a])=>!n.has(o)&&a!==void 0&&a!==null&&a!=="").slice(0,i).flatMap(([o,a])=>{const l=OKe(a);return l?[`${RKe(o)}: ${l}`]:[]});return s.length>0?s.join(" • "):null}function nP(e,r){const n=u6(e,r),i=pu(e.recipient_name,e.recipientName,e.tool,e.toolName,e.name,n==null?void 0:n.recipient_name,n==null?void 0:n.recipientName,n==null?void 0:n.tool,n==null?void 0:n.toolName,n==null?void 0:n.name)??null,o=xoe(n??e,{excludeKeys:["recipient_name","recipientName","tool","toolName","name"],maxEntries:4});return{title:i,details:o}}function E7(e,r,n,i){const s=py(e);if(s!=="edit"&&s!=="file.write"&&s!=="file.patch"&&s!=="read"&&s!=="file.read")return null;const o=xu(s,r,n),a=pu(o.path,o.file_path,o.filePath,o.file,o.filename,o.target_file,o.targetFile,o.relative_path,o.name,o.title,iH(o.changes));if(a)return a;const l=u6(r,n),d=pu(l==null?void 0:l.path,l==null?void 0:l.file_path,l==null?void 0:l.filePath,l==null?void 0:l.file,l==null?void 0:l.filename,l==null?void 0:l.target_file,l==null?void 0:l.targetFile,l==null?void 0:l.relative_path,l==null?void 0:l.name,l==null?void 0:l.title,iH(l==null?void 0:l.changes));return d||(i?voe(i):null)}function boe(e,r,n,i){var f,p,g;const s=py(e),o=xu(s,r,n),a=u6(r,n),l=pu(n==null?void 0:n.path,(f=Om(n==null?void 0:n.result))==null?void 0:f.path,o.path,o.file_path,o.filePath,o.file,o.filename,a==null?void 0:a.path,a==null?void 0:a.file_path,a==null?void 0:a.filePath,a==null?void 0:a.file,a==null?void 0:a.filename);if(l&&lE(l))return l;const d=pu(n==null?void 0:n.output,n==null?void 0:n.content,(p=Om(n==null?void 0:n.result))==null?void 0:p.output,(g=Om(n==null?void 0:n.result))==null?void 0:g.content);if(d&&lE(d))return d;const u=i?voe(i):null;return u&&lE(u)?u:null}function py(e){const r=e.indexOf("_");return r===-1?e:e.slice(0,r)+"."+e.slice(r+1)}function xu(e,r,n){const i=py(e),s={...r},o=u6(r,n);return(i==="edit"||i==="file.write"||i==="file.patch"||i==="read"||i==="file.read")&&(s.path=pu(s.path,s.file_path,s.filePath,s.file,s.filename,s.target_file,s.targetFile,s.relative_path,s.name,s.title,o==null?void 0:o.path,o==null?void 0:o.file_path,o==null?void 0:o.filePath,o==null?void 0:o.file,o==null?void 0:o.filename,o==null?void 0:o.target_file,o==null?void 0:o.targetFile,o==null?void 0:o.relative_path,o==null?void 0:o.name,o==null?void 0:o.title)??s.path),(i==="edit"||i==="file.patch")&&(s.search=pu(s.search,s.old_string,s.oldString,s.old_text,s.oldText,o==null?void 0:o.search,o==null?void 0:o.old_string,o==null?void 0:o.oldString,o==null?void 0:o.old_text,o==null?void 0:o.oldText)??s.search,s.replace=pu(s.replace,s.new_string,s.newString,s.new_text,s.newText,s.replacement,o==null?void 0:o.replace,o==null?void 0:o.new_string,o==null?void 0:o.newString,o==null?void 0:o.new_text,o==null?void 0:o.newText,o==null?void 0:o.replacement)??s.replace,s.content=pu(s.content,s.new_file_contents,s.newFileContents,s.writtenContent,o==null?void 0:o.content,o==null?void 0:o.new_file_contents,o==null?void 0:o.newFileContents,o==null?void 0:o.writtenContent)??s.content),(i==="web"||i==="web.search"||i==="browser.search"||i==="browser.fetch"||i==="web.fetch")&&(s.query=pu(s.query,s.search_query,s.searchQuery,s.q,o==null?void 0:o.query,o==null?void 0:o.search_query,o==null?void 0:o.searchQuery,o==null?void 0:o.q)??s.query,s.url=pu(s.url,s.uri,s.href,o==null?void 0:o.url,o==null?void 0:o.uri,o==null?void 0:o.href)??s.url),s}function MKe(e,r){const n=py(e),i=xu(n,r);return n==="file.write"?i.content!=null:n==="file.patch"?i.search!=null&&i.replace!=null:n==="edit"?i.content!=null||i.search!=null&&i.replace!=null:!1}function _oe(e){const r=py(e.tool),n=r.startsWith("terminal.")||r==="execute";return e.status==="pending"?"pending":n?"terminal":r==="browser.snapshot"&&e.snapshotText?"browserSnapshot":e.screenshotPath?"browserScreenshot":r==="agent"?"subagent":e.status==="success"&&MKe(r,e.args)?"editDiff":e.displayOutput?"output":e.status==="running"?"runningHint":"none"}function sH(e){const r=y.useRef(null);return y.useEffect(()=>{const n=r.current;n&&(n.scrollTop=n.scrollHeight)},[e]),r}function Ba(e){return py(e)}const woe={read:{icon:Gl,label:"Read",color:"text-blue-500"},edit:{icon:Gl,label:"Edit",color:"text-blue-500"},execute:{icon:Wo,label:"Execute",color:"text-yellow-500"},search:{icon:pl,label:"Search",color:"text-emerald-500"},web:{icon:Ci,label:"Web",color:"text-cyan-500"},agent:{icon:sK,label:"Agent",color:"text-purple-500"},todo:{icon:T0e,label:"Todo",color:"text-orange-500"},jait:{icon:vK,label:"Jait",color:"text-indigo-500"},"mcp-tool":{icon:xo,label:"MCP Tool",color:"text-purple-500"},skill:{icon:e5,label:"Skill",color:"text-violet-500"},"ssh.run":{icon:Wo,label:"SSH",color:"text-yellow-500"},"ssh.session.start":{icon:Wo,label:"SSH",color:"text-yellow-500"},"ssh.session.run":{icon:Wo,label:"SSH",color:"text-yellow-500"},"ssh.session.close":{icon:Wo,label:"SSH",color:"text-yellow-500"},"terminal.run":{icon:Wo,label:"Terminal",color:"text-yellow-500"},"terminal.stream":{icon:Wo,label:"Terminal",color:"text-yellow-500"},"file.read":{icon:Gl,label:"Read File",color:"text-blue-500"},"file.write":{icon:Gl,label:"Write File",color:"text-blue-500"},"file.patch":{icon:Gl,label:"Patch File",color:"text-blue-500"},"file.list":{icon:Gl,label:"List Files",color:"text-blue-500"},"file.stat":{icon:Gl,label:"File Info",color:"text-blue-500"},"image.view":{icon:Ci,label:"Image",color:"text-cyan-500"},"os.query":{icon:Ra,label:"System",color:"text-green-500"},"os.install":{icon:Ra,label:"Install",color:"text-green-500"},"surfaces.list":{icon:xo,label:"Surfaces",color:"text-purple-500"},"surfaces.start":{icon:xo,label:"Surfaces",color:"text-purple-500"},"surfaces.stop":{icon:xo,label:"Surfaces",color:"text-purple-500"},"memory.save":{icon:Gl,label:"Save Memory",color:"text-amber-500"},"memory.search":{icon:Gl,label:"Search Memory",color:"text-amber-500"},"memory.forget":{icon:Gl,label:"Forget Memory",color:"text-amber-500"},"cron.add":{icon:xo,label:"Add Cron",color:"text-violet-500"},"cron.list":{icon:xo,label:"List Cron",color:"text-violet-500"},"cron.update":{icon:xo,label:"Update Cron",color:"text-violet-500"},"cron.remove":{icon:xo,label:"Remove Cron",color:"text-violet-500"},"web.search":{icon:Ci,label:"Search",color:"text-cyan-500"},"web.fetch":{icon:Ci,label:"Fetch",color:"text-cyan-500"},"browser.navigate":{icon:Ci,label:"Navigate",color:"text-cyan-500"},"browser.snapshot":{icon:Ci,label:"Snapshot",color:"text-cyan-500"},"browser.click":{icon:Ci,label:"Click",color:"text-cyan-500"},"browser.type":{icon:Ci,label:"Type",color:"text-cyan-500"},"browser.scroll":{icon:Ci,label:"Scroll",color:"text-cyan-500"},"browser.select":{icon:Ci,label:"Select",color:"text-cyan-500"},"browser.wait":{icon:Ci,label:"Wait",color:"text-cyan-500"},"browser.screenshot":{icon:Ci,label:"Screenshot",color:"text-cyan-500"},"browser.search":{icon:Ci,label:"Search",color:"text-cyan-500"},"browser.fetch":{icon:Ci,label:"Fetch",color:"text-cyan-500"},"preview.open":{icon:Ci,label:"Preview",color:"text-cyan-500"}};function Soe(e){const r=Ba(e);return woe[r]??{icon:Wo,label:r,color:"text-muted-foreground"}}function PKe(e,r,n,i){const s=Ba(e),o=xu(s,r),a=(()=>{const u=qr(o.path??o.file);return u?iP(u):""})(),l=qr(o.query??o.pattern??o.q);if(s==="read"||s==="file.read")return{running:`Reading ${a||"file"}`,done:`Read ${a||"file"}`};if(s==="edit"||s==="file.patch")return{running:`Editing ${a||"file"}`,done:`Edited ${a||"file"}`};if(s==="file.write")return{running:`Writing ${a||"file"}`,done:`Created ${a||"file"}`};if(s==="file.list")return{running:"Listing files",done:"Listed files"};if(s==="file.stat")return{running:`Inspecting ${a||"file"}`,done:`Inspected ${a||"file"}`};if(s==="execute"||s.startsWith("terminal."))return{running:"Running command",done:"Ran command"};if(s==="search"){const u=qr(o.mode??r.mode,"content"),f=l?` "${xd(l,40)}"`:"";return u==="files"?{running:`Finding files${f}`,done:`Found files${f}`}:{running:`Searching${f}`,done:`Searched${f}`}}if(s==="web"||s==="web.search"||s==="browser.search"){if(qr(o.mode??o.type)==="fetch"){const p=ep(o.url);return{running:`Fetching ${p||"page"}`,done:`Fetched ${p||"page"}`}}const f=l?` "${xd(l,40)}"`:"";return{running:`Searching web${f}`,done:`Searched web${f}`}}if(s==="web.fetch"||s==="browser.fetch"){const u=ep(o.url);return{running:`Fetching ${u||"page"}`,done:`Fetched ${u||"page"}`}}if(s==="browser.navigate"){const u=ep(o.url);return{running:`Navigating to ${u||"page"}`,done:`Navigated to ${u||"page"}`}}if(s==="browser.snapshot")return{running:"Taking snapshot",done:"Took snapshot"};if(s==="browser.click")return{running:"Clicking element",done:"Clicked element"};if(s==="browser.type")return{running:"Typing text",done:"Typed text"};if(s==="browser.screenshot")return{running:"Taking screenshot",done:"Took screenshot"};if(s==="agent"){const u=xd(qr(r.description??r.prompt),60);return{running:`Running agent: ${u}`,done:`Agent completed: ${u}`}}if(s==="todo")return{running:"Updating tasks",done:"Updated tasks"};if(s==="skill"){const u=qr(r.skills);return{running:`Using skills ${u||""}`.trim(),done:`Using skills ${u||""}`.trim()}}if(s==="memory.save")return{running:"Saving to memory",done:"Saved to memory"};if(s==="memory.search")return{running:"Searching memory",done:"Searched memory"};if(s==="memory.forget")return{running:"Removing memory",done:"Removed memory"};if(s==="os.query")return{running:"Querying system",done:"Queried system"};if(s==="os.install")return{running:`Installing ${qr(r.package)||"package"}`,done:`Installed ${qr(r.package)||"package"}`};if(s.startsWith("cron.")){const u=s.split(".")[1]??"manage",f=u==="add"?"Adding":u==="update"?"Updating":u==="remove"?"Removing":"Listing",p=u==="add"?"Added":u==="update"?"Updated":u==="remove"?"Removed":"Listed";return{running:`${f} cron job`,done:`${p} cron job`}}if(s.startsWith("surfaces.")){const u=s.split(".")[1]??"manage";return u==="start"?{running:"Starting surface",done:"Started surface"}:u==="stop"?{running:"Stopping surface",done:"Stopped surface"}:{running:"Listing surfaces",done:"Listed surfaces"}}if(s.startsWith("ssh."))return{running:"Running SSH command",done:"Ran SSH command"};if(s==="image.view")return{running:"Viewing image",done:"Viewed image"};if(s==="preview.open")return{running:"Opening preview",done:"Opened preview"};if(s==="jait"){const u=qr(r.action);return{running:`Jait: ${u||"working"}`,done:`Jait: ${u||"done"}`}}if(s==="mcp-tool"){const f=nP(o,n).title||"MCP Tool";return{running:`Running ${f}`,done:`Ran ${f}`}}const d=Soe(e);return{running:d.label,done:d.label}}function LKe(e){if(!e)return null;const r=e.toLowerCase().replace(/^mcp__/,"").replace(/__/g,".");if(r.startsWith("ssh"))return{label:"SSH",icon:Wo,color:"text-yellow-500"};if(r.startsWith("git"))return{label:"Git",icon:Wo,color:"text-orange-500"};if(r.startsWith("docker")||r.startsWith("container"))return{label:"Docker",icon:xo,color:"text-blue-500"};if(r.startsWith("github"))return{label:"GitHub",icon:Ci,color:"text-purple-500"};if(r.startsWith("postgres")||r.startsWith("mysql")||r.startsWith("sqlite")||r.startsWith("db")||r.startsWith("sql"))return{label:"Database",icon:xo,color:"text-emerald-500"};if(r.startsWith("fs")||r.startsWith("file")||r.startsWith("read")||r.startsWith("write"))return{label:"File",icon:Gl,color:"text-blue-500"};if(r.startsWith("browser")||r.startsWith("web")||r.startsWith("http")||r.startsWith("fetch"))return{label:"Web",icon:Ci,color:"text-cyan-500"};if(r.startsWith("shell")||r.startsWith("exec")||r.startsWith("bash")||r.startsWith("terminal")||r.startsWith("command"))return{label:"Terminal",icon:Wo,color:"text-yellow-500"};if(r.startsWith("memory")||r.startsWith("knowledge"))return{label:"Memory",icon:Gl,color:"text-amber-500"};const i=(r.split(".")[0]??r).replace(/[._-]+/g," ").replace(/\b\w/g,s=>s.toUpperCase()).trim();return i?{label:i,icon:xo,color:"text-purple-500"}:null}function qr(e,r=""){if(e==null)return r;if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e))return`${e.length} item(s)`;if(typeof e=="object"){const n=e;for(const s of["text","content","message","name","path","value","description"])if(typeof n[s]=="string"&&n[s])return n[s];const i=Object.keys(n);return i.length>0?`{${i.slice(0,3).join(", ")}${i.length>3?", …":""}}`:r}return r}function xd(e,r=64){const n=e.trim();return n.length<=r?n:`${n.slice(0,r-1)}…`}function W3(e){return e?e.split(`
1147
+ .sash-handle:active > div { background-color: hsl(var(--primary) / 0.5) !important; transition-delay: 0ms; }`})]})]})});function CKe({filePath:e,oldText:r,newText:n,writtenContent:i,isNewFile:s,className:o}){const a=e.split("/").pop()??e,l=q_(e),d=y.useMemo(()=>r!=null&&n!=null?{original:r,modified:n}:i!=null?{original:"",modified:i}:null,[r,n,i,s]);return d?c.jsxs("div",{className:Fe("rounded-md border bg-background overflow-hidden",o),children:[c.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 bg-muted/40 border-b",children:[c.jsx($o,{filename:a,className:"h-3.5 w-3.5 shrink-0"}),c.jsx("span",{className:"text-xs font-mono text-muted-foreground truncate",children:e})]}),c.jsx(W2,{original:d.original,modified:d.modified,language:l,className:"h-80",editorClassName:"h-full",emptyMessage:s?"New file contents.":"No visible changes.",options:{renderSideBySide:!1,lineNumbers:"on",wordWrap:"on"}})]}):null}const jKe=/\.(?:png|jpe?g|gif|webp)$/i;function NKe(e){return/^[a-z][a-z0-9+.-]*:/i.test(e)}function TKe(e){return e.startsWith("/api/browser/screenshot")||e.startsWith("/api/dev-proxy/")}function EKe(e){return jKe.test(e)&&(e.startsWith("/")||e.startsWith("./")||e.startsWith("../")||e.includes("/")||e.includes("\\"))}function yoe(e,r=Hn()){const n=e.trim();return n?n.startsWith("data:image/")||n.startsWith("blob:")||/^https?:\/\//i.test(n)?n:TKe(n)?`${r}${n.startsWith("/")?"":"/"}${n}`:NKe(n)?null:EKe(n)?`${r}/api/browser/screenshot?path=${encodeURIComponent(n)}`:null:null}function pu(...e){for(const r of e)if(typeof r=="string"&&r.trim())return r}function Om(...e){for(const r of e)if(r&&typeof r=="object"&&!Array.isArray(r))return r}function i0(e){if(typeof e=="string")try{const r=JSON.parse(e);if(r&&typeof r=="object"&&!Array.isArray(r))return r}catch{}}function AKe(e,r=80){const n=e.trim();return n.length<=r?n:`${n.slice(0,r-1)}…`}function OKe(e){if(typeof e=="string"){const r=e.trim();return r?AKe(r,48):void 0}if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e))return`${e.length} item${e.length===1?"":"s"}`;if(e&&typeof e=="object")return"object"}function RKe(e){return e.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").trim().toLowerCase()}function voe(e){const r=e.trim();if(!r)return null;const n=r.match(/(?:^|[\s:(['"`])((?:\/|\.\/|\.\.\/)?(?:[\w.@-]+\/)+[\w.@-]+(?:\.[\w-]+)?)/);if(n!=null&&n[1])return n[1];const i=r.match(/(?:^|[\s:(['"`])((?:\/|\.\/|\.\.\/)?[\w.@-]+(?:\/[\w.@-]+)*\.[\w-]+)/);return i!=null&&i[1]?i[1]:null}function lE(e){return/\.(?:png|jpe?g|gif|webp)$/i.test(e.trim())}function iH(e){if(Array.isArray(e))for(const r of e){if(!r||typeof r!="object")continue;const n=pu(r.path,r.file_path,r.filePath,r.file,r.filename);if(n)return n}}function u6(e,r){var n,i,s,o;return Om(e.action,e.input,e.arguments,i0(e.action),i0(e.input),i0(e.arguments),r==null?void 0:r.result,r,r==null?void 0:r.input,r==null?void 0:r.arguments,i0(r==null?void 0:r.input),i0(r==null?void 0:r.arguments),(n=Om(r==null?void 0:r.result))==null?void 0:n.input,(i=Om(r==null?void 0:r.result))==null?void 0:i.arguments,i0((s=Om(r==null?void 0:r.result))==null?void 0:s.input),i0((o=Om(r==null?void 0:r.result))==null?void 0:o.arguments))}function xoe(e,r){const n=new Set((r==null?void 0:r.excludeKeys)??[]),i=(r==null?void 0:r.maxEntries)??3,s=Object.entries(e).filter(([o,a])=>!n.has(o)&&a!==void 0&&a!==null&&a!=="").slice(0,i).flatMap(([o,a])=>{const l=OKe(a);return l?[`${RKe(o)}: ${l}`]:[]});return s.length>0?s.join(" • "):null}function nP(e,r){const n=u6(e,r),i=pu(e.recipient_name,e.recipientName,e.tool,e.toolName,e.name,n==null?void 0:n.recipient_name,n==null?void 0:n.recipientName,n==null?void 0:n.tool,n==null?void 0:n.toolName,n==null?void 0:n.name)??null,o=xoe(n??e,{excludeKeys:["recipient_name","recipientName","tool","toolName","name"],maxEntries:4});return{title:i,details:o}}function E7(e,r,n,i){const s=py(e);if(s!=="edit"&&s!=="file.write"&&s!=="file.patch"&&s!=="read"&&s!=="file.read")return null;const o=xu(s,r,n),a=pu(o.path,o.file_path,o.filePath,o.file,o.filename,o.target_file,o.targetFile,o.relative_path,o.name,o.title,iH(o.changes));if(a)return a;const l=u6(r,n),d=pu(l==null?void 0:l.path,l==null?void 0:l.file_path,l==null?void 0:l.filePath,l==null?void 0:l.file,l==null?void 0:l.filename,l==null?void 0:l.target_file,l==null?void 0:l.targetFile,l==null?void 0:l.relative_path,l==null?void 0:l.name,l==null?void 0:l.title,iH(l==null?void 0:l.changes));return d||(i?voe(i):null)}function boe(e,r,n,i){var f,p,g;const s=py(e),o=xu(s,r,n),a=u6(r,n),l=pu(n==null?void 0:n.path,(f=Om(n==null?void 0:n.result))==null?void 0:f.path,o.path,o.file_path,o.filePath,o.file,o.filename,a==null?void 0:a.path,a==null?void 0:a.file_path,a==null?void 0:a.filePath,a==null?void 0:a.file,a==null?void 0:a.filename);if(l&&lE(l))return l;const d=pu(n==null?void 0:n.output,n==null?void 0:n.content,(p=Om(n==null?void 0:n.result))==null?void 0:p.output,(g=Om(n==null?void 0:n.result))==null?void 0:g.content);if(d&&lE(d))return d;const u=i?voe(i):null;return u&&lE(u)?u:null}function py(e){if(e==="browser_sandbox_start")return"browser.sandbox.start";if(e==="ssh_session_start")return"ssh.session.start";if(e==="ssh_session_run")return"ssh.session.run";if(e==="ssh_session_close")return"ssh.session.close";const r=e.indexOf("_");return r===-1?e:e.slice(0,r)+"."+e.slice(r+1)}function xu(e,r,n){const i=py(e),s={...r},o=u6(r,n);return(i==="edit"||i==="file.write"||i==="file.patch"||i==="read"||i==="file.read")&&(s.path=pu(s.path,s.file_path,s.filePath,s.file,s.filename,s.target_file,s.targetFile,s.relative_path,s.name,s.title,o==null?void 0:o.path,o==null?void 0:o.file_path,o==null?void 0:o.filePath,o==null?void 0:o.file,o==null?void 0:o.filename,o==null?void 0:o.target_file,o==null?void 0:o.targetFile,o==null?void 0:o.relative_path,o==null?void 0:o.name,o==null?void 0:o.title)??s.path),(i==="edit"||i==="file.patch")&&(s.search=pu(s.search,s.old_string,s.oldString,s.old_text,s.oldText,o==null?void 0:o.search,o==null?void 0:o.old_string,o==null?void 0:o.oldString,o==null?void 0:o.old_text,o==null?void 0:o.oldText)??s.search,s.replace=pu(s.replace,s.new_string,s.newString,s.new_text,s.newText,s.replacement,o==null?void 0:o.replace,o==null?void 0:o.new_string,o==null?void 0:o.newString,o==null?void 0:o.new_text,o==null?void 0:o.newText,o==null?void 0:o.replacement)??s.replace,s.content=pu(s.content,s.new_file_contents,s.newFileContents,s.writtenContent,o==null?void 0:o.content,o==null?void 0:o.new_file_contents,o==null?void 0:o.newFileContents,o==null?void 0:o.writtenContent)??s.content),(i==="web"||i==="web.search"||i==="browser.search"||i==="browser.fetch"||i==="web.fetch")&&(s.query=pu(s.query,s.search_query,s.searchQuery,s.q,o==null?void 0:o.query,o==null?void 0:o.search_query,o==null?void 0:o.searchQuery,o==null?void 0:o.q)??s.query,s.url=pu(s.url,s.uri,s.href,o==null?void 0:o.url,o==null?void 0:o.uri,o==null?void 0:o.href)??s.url),s}function MKe(e,r){const n=py(e),i=xu(n,r);return n==="file.write"?i.content!=null:n==="file.patch"?i.search!=null&&i.replace!=null:n==="edit"?i.content!=null||i.search!=null&&i.replace!=null:!1}function _oe(e){const r=py(e.tool),n=r.startsWith("terminal.")||r==="execute";return e.status==="pending"?"pending":n?"terminal":r==="browser.snapshot"&&e.snapshotText?"browserSnapshot":e.screenshotPath?"browserScreenshot":r==="agent"?"subagent":e.status==="success"&&MKe(r,e.args)?"editDiff":e.displayOutput?"output":e.status==="running"?"runningHint":"none"}function sH(e){const r=y.useRef(null);return y.useEffect(()=>{const n=r.current;n&&(n.scrollTop=n.scrollHeight)},[e]),r}function Ba(e){return py(e)}const woe={read:{icon:Gl,label:"Read",color:"text-blue-500"},edit:{icon:Gl,label:"Edit",color:"text-blue-500"},execute:{icon:Wo,label:"Execute",color:"text-yellow-500"},search:{icon:pl,label:"Search",color:"text-emerald-500"},web:{icon:Ci,label:"Web",color:"text-cyan-500"},agent:{icon:sK,label:"Agent",color:"text-purple-500"},todo:{icon:T0e,label:"Todo",color:"text-orange-500"},jait:{icon:vK,label:"Jait",color:"text-indigo-500"},"mcp-tool":{icon:xo,label:"MCP Tool",color:"text-purple-500"},skill:{icon:e5,label:"Skill",color:"text-violet-500"},"ssh.run":{icon:Wo,label:"SSH",color:"text-yellow-500"},"ssh.session.start":{icon:Wo,label:"SSH",color:"text-yellow-500"},"ssh.session.run":{icon:Wo,label:"SSH",color:"text-yellow-500"},"ssh.session.close":{icon:Wo,label:"SSH",color:"text-yellow-500"},"terminal.run":{icon:Wo,label:"Terminal",color:"text-yellow-500"},"terminal.stream":{icon:Wo,label:"Terminal",color:"text-yellow-500"},"file.read":{icon:Gl,label:"Read File",color:"text-blue-500"},"file.write":{icon:Gl,label:"Write File",color:"text-blue-500"},"file.patch":{icon:Gl,label:"Patch File",color:"text-blue-500"},"file.list":{icon:Gl,label:"List Files",color:"text-blue-500"},"file.stat":{icon:Gl,label:"File Info",color:"text-blue-500"},"image.view":{icon:Ci,label:"Image",color:"text-cyan-500"},"os.query":{icon:Ra,label:"System",color:"text-green-500"},"os.install":{icon:Ra,label:"Install",color:"text-green-500"},"surfaces.list":{icon:xo,label:"Surfaces",color:"text-purple-500"},"surfaces.start":{icon:xo,label:"Surfaces",color:"text-purple-500"},"surfaces.stop":{icon:xo,label:"Surfaces",color:"text-purple-500"},"memory.save":{icon:Gl,label:"Save Memory",color:"text-amber-500"},"memory.search":{icon:Gl,label:"Search Memory",color:"text-amber-500"},"memory.forget":{icon:Gl,label:"Forget Memory",color:"text-amber-500"},"cron.add":{icon:xo,label:"Add Cron",color:"text-violet-500"},"cron.list":{icon:xo,label:"List Cron",color:"text-violet-500"},"cron.update":{icon:xo,label:"Update Cron",color:"text-violet-500"},"cron.remove":{icon:xo,label:"Remove Cron",color:"text-violet-500"},"web.search":{icon:Ci,label:"Search",color:"text-cyan-500"},"web.fetch":{icon:Ci,label:"Fetch",color:"text-cyan-500"},"browser.navigate":{icon:Ci,label:"Navigate",color:"text-cyan-500"},"browser.snapshot":{icon:Ci,label:"Snapshot",color:"text-cyan-500"},"browser.click":{icon:Ci,label:"Click",color:"text-cyan-500"},"browser.type":{icon:Ci,label:"Type",color:"text-cyan-500"},"browser.scroll":{icon:Ci,label:"Scroll",color:"text-cyan-500"},"browser.select":{icon:Ci,label:"Select",color:"text-cyan-500"},"browser.wait":{icon:Ci,label:"Wait",color:"text-cyan-500"},"browser.screenshot":{icon:Ci,label:"Screenshot",color:"text-cyan-500"},"browser.search":{icon:Ci,label:"Search",color:"text-cyan-500"},"browser.fetch":{icon:Ci,label:"Fetch",color:"text-cyan-500"},"preview.open":{icon:Ci,label:"Preview",color:"text-cyan-500"}};function Soe(e){const r=Ba(e);return woe[r]??{icon:Wo,label:r,color:"text-muted-foreground"}}function PKe(e,r,n,i){const s=Ba(e),o=xu(s,r),a=(()=>{const u=qr(o.path??o.file);return u?iP(u):""})(),l=qr(o.query??o.pattern??o.q);if(s==="read"||s==="file.read")return{running:`Reading ${a||"file"}`,done:`Read ${a||"file"}`};if(s==="edit"||s==="file.patch")return{running:`Editing ${a||"file"}`,done:`Edited ${a||"file"}`};if(s==="file.write")return{running:`Writing ${a||"file"}`,done:`Created ${a||"file"}`};if(s==="file.list")return{running:"Listing files",done:"Listed files"};if(s==="file.stat")return{running:`Inspecting ${a||"file"}`,done:`Inspected ${a||"file"}`};if(s==="execute"||s.startsWith("terminal."))return{running:"Running command",done:"Ran command"};if(s==="search"){const u=qr(o.mode??r.mode,"content"),f=l?` "${xd(l,40)}"`:"";return u==="files"?{running:`Finding files${f}`,done:`Found files${f}`}:{running:`Searching${f}`,done:`Searched${f}`}}if(s==="web"||s==="web.search"||s==="browser.search"){if(qr(o.mode??o.type)==="fetch"){const p=ep(o.url);return{running:`Fetching ${p||"page"}`,done:`Fetched ${p||"page"}`}}const f=l?` "${xd(l,40)}"`:"";return{running:`Searching web${f}`,done:`Searched web${f}`}}if(s==="web.fetch"||s==="browser.fetch"){const u=ep(o.url);return{running:`Fetching ${u||"page"}`,done:`Fetched ${u||"page"}`}}if(s==="browser.navigate"){const u=ep(o.url);return{running:`Navigating to ${u||"page"}`,done:`Navigated to ${u||"page"}`}}if(s==="browser.snapshot")return{running:"Taking snapshot",done:"Took snapshot"};if(s==="browser.click")return{running:"Clicking element",done:"Clicked element"};if(s==="browser.type")return{running:"Typing text",done:"Typed text"};if(s==="browser.screenshot")return{running:"Taking screenshot",done:"Took screenshot"};if(s==="agent"){const u=xd(qr(r.description??r.prompt),60);return{running:`Running agent: ${u}`,done:`Agent completed: ${u}`}}if(s==="todo")return{running:"Updating tasks",done:"Updated tasks"};if(s==="skill"){const u=qr(r.skills);return{running:`Using skills ${u||""}`.trim(),done:`Using skills ${u||""}`.trim()}}if(s==="memory.save")return{running:"Saving to memory",done:"Saved to memory"};if(s==="memory.search")return{running:"Searching memory",done:"Searched memory"};if(s==="memory.forget")return{running:"Removing memory",done:"Removed memory"};if(s==="os.query")return{running:"Querying system",done:"Queried system"};if(s==="os.install")return{running:`Installing ${qr(r.package)||"package"}`,done:`Installed ${qr(r.package)||"package"}`};if(s.startsWith("cron.")){const u=s.split(".")[1]??"manage",f=u==="add"?"Adding":u==="update"?"Updating":u==="remove"?"Removing":"Listing",p=u==="add"?"Added":u==="update"?"Updated":u==="remove"?"Removed":"Listed";return{running:`${f} cron job`,done:`${p} cron job`}}if(s.startsWith("surfaces.")){const u=s.split(".")[1]??"manage";return u==="start"?{running:"Starting surface",done:"Started surface"}:u==="stop"?{running:"Stopping surface",done:"Stopped surface"}:{running:"Listing surfaces",done:"Listed surfaces"}}if(s.startsWith("ssh."))return{running:"Running SSH command",done:"Ran SSH command"};if(s==="image.view")return{running:"Viewing image",done:"Viewed image"};if(s==="preview.open")return{running:"Opening preview",done:"Opened preview"};if(s==="jait"){const u=qr(r.action);return{running:`Jait: ${u||"working"}`,done:`Jait: ${u||"done"}`}}if(s==="mcp-tool"){const f=nP(o,n).title||"MCP Tool";return{running:`Running ${f}`,done:`Ran ${f}`}}const d=Soe(e);return{running:d.label,done:d.label}}function LKe(e){if(!e)return null;const r=e.toLowerCase().replace(/^mcp__/,"").replace(/__/g,".");if(r.startsWith("ssh"))return{label:"SSH",icon:Wo,color:"text-yellow-500"};if(r.startsWith("git"))return{label:"Git",icon:Wo,color:"text-orange-500"};if(r.startsWith("docker")||r.startsWith("container"))return{label:"Docker",icon:xo,color:"text-blue-500"};if(r.startsWith("github"))return{label:"GitHub",icon:Ci,color:"text-purple-500"};if(r.startsWith("postgres")||r.startsWith("mysql")||r.startsWith("sqlite")||r.startsWith("db")||r.startsWith("sql"))return{label:"Database",icon:xo,color:"text-emerald-500"};if(r.startsWith("fs")||r.startsWith("file")||r.startsWith("read")||r.startsWith("write"))return{label:"File",icon:Gl,color:"text-blue-500"};if(r.startsWith("browser")||r.startsWith("web")||r.startsWith("http")||r.startsWith("fetch"))return{label:"Web",icon:Ci,color:"text-cyan-500"};if(r.startsWith("shell")||r.startsWith("exec")||r.startsWith("bash")||r.startsWith("terminal")||r.startsWith("command"))return{label:"Terminal",icon:Wo,color:"text-yellow-500"};if(r.startsWith("memory")||r.startsWith("knowledge"))return{label:"Memory",icon:Gl,color:"text-amber-500"};const i=(r.split(".")[0]??r).replace(/[._-]+/g," ").replace(/\b\w/g,s=>s.toUpperCase()).trim();return i?{label:i,icon:xo,color:"text-purple-500"}:null}function qr(e,r=""){if(e==null)return r;if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e))return`${e.length} item(s)`;if(typeof e=="object"){const n=e;for(const s of["text","content","message","name","path","value","description"])if(typeof n[s]=="string"&&n[s])return n[s];const i=Object.keys(n);return i.length>0?`{${i.slice(0,3).join(", ")}${i.length>3?", …":""}}`:r}return r}function xd(e,r=64){const n=e.trim();return n.length<=r?n:`${n.slice(0,r-1)}…`}function W3(e){return e?e.split(`
1148
1148
  `).length:0}function iP(e){const r=e.replace(/\\/g,"/").trim();if(!r)return"";const n=r.split("/");return n[n.length-1]??r}function ep(e){if(typeof e!="string")return null;try{return new URL(e).host||null}catch{return null}}function $Ke(e){const r=e.map(i=>ep(i)).filter(i=>!!i);if(r.length===0)return null;const n=Array.from(new Set(r));return n.length===1?n[0]:n.length===2?`${n[0]} + ${n[1]}`:`${n[0]} +${n.length-1} more`}function DKe(...e){for(const r of e)if(typeof r=="string"&&r.trim())return r;return null}function cE(e){if(!e)return null;const r=e.match(/https?:\/\/[^\s)`\]]+/i);if(r!=null&&r[0])return ep(r[0]);const n=e.match(/`([a-z0-9.-]+\.[a-z]{2,})`/i);if(n!=null&&n[1])return n[1];const i=e.match(/\b([a-z0-9.-]+\.[a-z]{2,})\b/i);return i!=null&&i[1]?i[1]:null}function IKe(e){const r=Ba(e);return r==="edit"||r==="file.write"||r==="file.patch"}function A7(e,r){const n=Ba(e),i=xu(n,r),s=typeof i.search=="string"?i.search:"",o=typeof i.replace=="string"?i.replace:"",a=typeof i.content=="string"?i.content:"";if(n==="file.write"){const l=W3(a);return l>0?`+${l}`:null}if(n==="file.patch"||n==="edit"){if(s||o){const l=W3(s);return`+${W3(o)} -${l}`}if(a){const l=W3(a);return l>0?`+${l}`:null}}return null}function BKe(e){const r=Ba(e);return r==="execute"||r.startsWith("terminal.")?"terminal":r==="edit"||r==="file.write"||r==="file.patch"?"edit":r==="read"||r==="file.read"?"read":r==="search"||r==="web.search"||r==="browser.search"?"search":r==="web"||r==="web.fetch"?"web":r.startsWith("browser.")?"browser":r.startsWith("memory.")?"memory":r.startsWith("cron.")?"cron":r.startsWith("surfaces.")?"surface":r.startsWith("os.")?"system":r==="agent"?"agent":r==="todo"?"todo":r==="jait"?"jait":r==="mcp-tool"?"mcp tool":r.startsWith("ssh.")?"ssh":r.replace(/[._-]+/g," ").trim()||"tool"}function O7(e){if(e.length===0)return"0 tool calls";const r=new Map;for(const i of e){const s=BKe(i.tool);r.set(s,(r.get(s)??0)+1)}const n=Array.from(r.entries()).map(([i,s])=>`${s} ${i}`);return n.length===1?`${n[0]} tool call${e.length===1?"":"s"}`:`${e.length} tool calls: ${n.join(", ")}`}function zKe(e){let r=!1,n=!1;for(const i of e){const s=Ba(i.tool);if(s==="execute"||s.startsWith("terminal."))return"terminal";s==="mcp-tool"&&(r=!0),(s==="web"||s.startsWith("web.")||s.startsWith("browser.")||s.startsWith("preview."))&&(n=!0)}return r?"mcp":n?"web":"generic"}function koe(e){const r=zKe(e);return r==="terminal"?Wo:r==="mcp"?xo:r==="web"?Ci:xo}function FKe(e,r,n,i){const s=Ba(e),o=xu(s,r);if(s==="read")return qr(o.path);if(s==="edit"){const l=qr(o.path),d=iP(l),u=A7(s,o);return o.search?`${d}${u?` (${u})`:" (patch)"}`:u?`${d} (${u})`:d}if(s==="execute")return qr(o.command??r.command);if(s==="search"){const l=qr(o.pattern??r.pattern);return qr(o.mode??r.mode,"content")==="files"?`Find: ${l}`:l}if(s==="web"){if(o.url)return ep(o.url)??qr(o.url);if(Array.isArray(o.urls))return $Ke(o.urls)??`${o.urls.length} URLs`;const l=cE(DKe(i,typeof(n==null?void 0:n.url)=="string"?n.url:void 0,typeof(n==null?void 0:n.finalUrl)=="string"?n.finalUrl:void 0,typeof(n==null?void 0:n.content)=="string"?n.content:void 0));return l||qr(o.query)}if(s==="agent")return xd(qr(r.description??r.prompt),80);if(s==="todo"){const l=r.todoList;if(!l)return"Track tasks";const d=l.filter(u=>u.status==="in-progress");return d.length?xd(d[0].title,60):`${l.length} task(s)`}if(s==="jait"){const l=qr(r.action);return l.startsWith("memory.")?`${l}: ${xd(qr(r.query??r.content),60)}`:l.startsWith("cron.")?`${l}: ${xd(qr(r.name??r.id),40)}`:l||"jait"}if(s==="mcp-tool"){const l=nP(o);if(l.title&&l.details)return`${l.title} • ${l.details}`;if(l.title)return l.title;if(l.details)return l.details}if(s.startsWith("terminal."))return qr(o.command??r.command);if(s==="file.write"||s==="file.patch"){const l=qr(o.path),d=A7(s,o);return d?`${l} (${d})`:l}if(s.startsWith("file."))return qr(o.path);if(s==="memory.save"){const l=qr(r.scope,"memory"),d=qr(r.content).trim();return d?`${l}: ${xd(d,80)}`:`scope: ${l}`}if(s==="memory.search")return qr(r.query);if(s==="memory.forget")return qr(r.id);if(s==="cron.add"){const l=qr(r.name,"job"),d=qr(r.cron),u=qr(r.toolName);return d&&u?`${l} (${d}) -> ${u}`:d?`${l} (${d})`:l}if(s==="cron.update"){const l=qr(r.id,"job"),d=qr(r.cron);return d?`${l} (${d})`:l}if(s==="cron.remove")return qr(r.id);if(s==="cron.list")return"List cron jobs";if(e==="os.query")return qr(r.query);if(e==="os.install")return qr(r.package);if(s==="browser.navigate")return ep(o.url)??qr(o.url);if(s==="browser.snapshot")return"Describe page";if(s==="browser.click")return qr(r.selector);if(s==="browser.type")return`${qr(r.selector)} ← ${qr(r.text)}`;if(s==="browser.scroll")return`x:${qr(r.x,"0")} y:${qr(r.y,"0")}`;if(s==="browser.select")return`${qr(r.selector)} = ${qr(r.value)}`;if(s==="browser.wait")return`${qr(r.selector)} (${qr(r.timeoutMs,"10000")}ms)`;if(s==="browser.screenshot")return qr(r.path,"auto path");if(s==="browser.search")return qr(o.query)||cE(i)||"search";if(s==="browser.fetch")return ep(o.url)??cE(i)??qr(o.url);if(s==="preview.open")return qr(o.target??r.target);if(s==="surfaces.start")return`Start ${qr(r.type,"surface")}`;if(s==="surfaces.stop")return`Stop ${qr(r.surfaceId,"surface")}`;if(s==="surfaces.list")return"List surfaces";const a=xoe(o);return a||`${Object.keys(r??{}).length} argument(s)`}function HKe(e){const r=[],n=s=>`${s} GB`,i=(s,o,a)=>{e[o]!=null&&r.push(`${s}: ${a?a(e[o]):e[o]}`)};if(i("OS","osEdition"),!e.osEdition){const s=[e.type,e.platform,e.release].filter(Boolean);s.length&&r.push(`OS: ${s.join(" ")}`)}return i("Host","hostname"),i("User","user"),i("Arch","arch"),i("CPU","cpuModel",s=>`${s} (${e.cpus??"?"} cores)`),i("Memory","totalMemoryGB",s=>`${n(e.freeMemoryGB)} free / ${n(s)} total`),i("Disk","diskFreeGB",s=>`${n(s)} free / ${n(+(Number(e.diskUsedGB??0)+Number(s)))} total`),i("Uptime","uptimeHours",s=>`${s}h`),r.push(""),i("CWD","cwd"),i("Node","nodeVersion"),i("Bun","bunVersion"),i("Shell","shellVersion"),i("Git","gitBranch",s=>{const o=e.gitDirtyFiles;return o?`${s} (${o} dirty)`:String(s)}),r.join(`
1149
1149
  `)}function WKe(e){const r=e.results;if(!Array.isArray(r)||r.length===0)return null;const n=[],i=typeof e.summary=="string"?e.summary.trim():"";i&&(n.push(i),n.push(""));const s=r.filter(o=>typeof o=="object"&&o!==null).slice(0,5);for(let o=0;o<s.length;o++){const a=s[o],l=typeof a.title=="string"?a.title.trim():"",d=typeof a.url=="string"?a.url.trim():"",u=typeof a.snippet=="string"?a.snippet.trim():"";n.push(`${o+1}. ${l||d||"Result"}`),d&&n.push(` ${d}`),u&&n.push(` ${u}`),o<s.length-1&&n.push("")}return n.join(`
1150
1150
  `).trim()||null}function UKe(e){const r=e.results;if(!Array.isArray(r)||r.length===0)return null;const n=r.filter(s=>typeof s=="object"&&s!==null).slice(0,5),i=[];for(let s=0;s<n.length;s++){const o=n[s],a=typeof o.url=="string"?o.url.trim():"",l=typeof o.message=="string"?o.message.trim():"",d=typeof o.content=="string"?o.content.trim():"";i.push(`${s+1}. ${a||`Result ${s+1}`}`),l&&i.push(` ${l}`),d&&i.push(` ${xd(d,240)}`),s<n.length-1&&i.push("")}return i.join(`
@@ -1157,7 +1157,7 @@ ${e.themeCSS}`),e.fontFamily!==void 0&&(n+=`
1157
1157
  `),n=(u=r.find(p=>p.startsWith("URL: ")))==null?void 0:u.replace("URL: ","").trim(),i=(f=r.find(p=>p.startsWith("Title: ")))==null?void 0:f.replace("Title: ","").trim(),s=r.findIndex(p=>p.trim()==="Interactive elements:"),o=s>=0?r.slice(0,s):r,a=o.findIndex(p=>p.trim()==="Text:"),l=a>=0?o.slice(a+1).join(`
1158
1158
  `).trim():"",d=s>=0?r.slice(s+1).map(p=>p.trim()).filter(Boolean):[];return c.jsxs("div",{className:"space-y-2 rounded-md border bg-muted/20 p-3 text-xs",children:[c.jsxs("div",{children:[c.jsx("div",{className:"font-semibold text-foreground/90",children:"Browser snapshot"}),i?c.jsx("div",{className:"text-muted-foreground",children:i}):null,n?c.jsx("div",{className:"font-mono text-xs break-all",children:n}):null]}),c.jsxs("div",{children:[c.jsx("div",{className:"mb-1 text-xs uppercase tracking-wide text-muted-foreground",children:"Text"}),c.jsx("pre",{className:"max-h-40 overflow-auto whitespace-pre-wrap rounded bg-background p-2 font-mono text-xs leading-5",children:l||"(no textual content)"})]}),c.jsxs("div",{children:[c.jsx("div",{className:"mb-1 text-xs uppercase tracking-wide text-muted-foreground",children:"Interactive elements"}),d.length?c.jsx("ul",{className:"max-h-40 space-y-1 overflow-auto rounded bg-background p-2 font-mono text-xs",children:d.map((p,g)=>c.jsx("li",{className:"break-all",children:p},`${p}-${g}`))}):c.jsx("div",{className:"rounded bg-background p-2 text-muted-foreground",children:"No interactive elements found."})]})]})}function QKe({path:e}){const[r,n]=y.useState(!1),[i,s]=y.useState(!1),o=e.trim(),a=yoe(o)??`${Hn()}/api/browser/screenshot?path=${encodeURIComponent(o)}`;return c.jsxs("div",{className:"space-y-2 rounded-md bg-muted/30 p-3 text-xs",children:[c.jsxs("div",{className:"text-xs text-muted-foreground",children:["Screenshot path: ",c.jsx("span",{className:"font-mono break-all",children:o})]}),c.jsxs("div",{className:"group relative overflow-hidden rounded-md bg-background/90 ring-1 ring-inset ring-border/35",children:[c.jsx("img",{src:a,alt:"Browser screenshot",className:"max-h-80 w-full cursor-pointer object-contain transition-opacity group-hover:opacity-80",onLoad:()=>n(!0),onError:()=>n(!1),onClick:()=>r&&s(!0)}),r&&c.jsx("div",{className:"pointer-events-none absolute inset-0 flex items-center justify-center opacity-0 transition-opacity group-hover:opacity-100",children:c.jsx("span",{className:"rounded-full bg-black/60 px-3 py-1.5 text-xs font-medium text-white",children:"Click to expand"})})]}),!r&&c.jsx("div",{className:"rounded bg-background p-2 text-muted-foreground",children:"Preview unavailable in browser. Open the screenshot path directly from the host environment."}),i&&c.jsx(Bd,{open:!0,onOpenChange:l=>!l&&s(!1),children:c.jsx(Eu,{className:"max-w-[90vw] max-h-[90vh] p-2",showCloseButton:!0,children:c.jsx("img",{src:a,alt:"Browser screenshot",className:"max-h-[85vh] w-full object-contain"})})})]})}function zC(e){var i;const r=typeof e.args.terminalId=="string"?e.args.terminalId:null;if(r)return r;const n=(i=e.result)==null?void 0:i.data;if(n&&typeof n=="object"){const s=n,o=typeof s.terminalId=="string"?s.terminalId:null;if(o)return o;const a=typeof s.id=="string"?s.id:null;if(a)return a;const l=typeof s.surfaceId=="string"?s.surfaceId:null;if(l)return l}return null}function eYe(e){var n;const r=Ba(e.tool);if(r==="surfaces.start"){if(e.args.type==="terminal")return zC(e)!==null;const i=(n=e.result)==null?void 0:n.data;return i&&typeof i=="object"&&i.type==="terminal"?zC(e)!==null:!1}return r==="execute"||r.startsWith("terminal.")?zC(e)!==null:!1}function joe(e){if(!e)return null;const r=e.match(/"command"\s*:\s*"((?:[^"\\]|\\.)*)/);return r?r[1].replace(/\\n/g,`
1159
1159
  `).replace(/\\t/g," ").replace(/\\"/g,'"').replace(/\\\\/g,"\\"):null}function du(e,r){if(!e)return null;const n=r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),i=new RegExp(`"${n}"\\s*:\\s*"((?:[^"\\\\]|\\\\.)*)`),s=e.match(i);return s?s[1].replace(/\\n/g,`
1160
- `).replace(/\\t/g," ").replace(/\\"/g,'"').replace(/\\\\/g,"\\"):null}function Noe(e){if(!e)return null;const r=du(e,"url")??du(e,"uri")??du(e,"href")??du(e,"query")??du(e,"q");if(r)return ep(r)??r;const n=du(e,"type"),i=du(e,"action");return n==="webSearch"||i==="webSearch"?"web search":n==="fetch"||i==="fetch"?"website":null}function tYe({tool:e,streamingArgs:r}){const n=Ba(e),i=woe[n],s=n.startsWith("terminal."),o=s?joe(r):null,a=n==="web"||n==="web.search"||n==="web.fetch"||n==="browser.search"||n==="browser.fetch",l=a?Noe(r):null;return i&&s&&o?c.jsxs("span",{className:"inline-flex max-w-full min-w-0 items-center gap-1.5 text-foreground",children:[c.jsx("span",{className:"shrink-0 text-xs text-emerald-500 dark:text-emerald-400 font-mono",children:"$"}),c.jsx("code",{className:"min-w-0 truncate text-xs font-mono",children:o}),c.jsx("span",{className:"inline-block w-1 h-3.5 bg-blue-400 animate-pulse ml-0.5 align-text-bottom"})]}):i&&a&&l?c.jsxs("span",{className:"inline-flex max-w-full min-w-0 items-center gap-1.5 text-foreground",children:[c.jsxs("span",{children:[i.label,":"]}),c.jsx("code",{className:"min-w-0 truncate text-xs font-mono",children:l}),c.jsx("span",{className:"inline-block w-1 h-3.5 bg-blue-400 animate-pulse ml-0.5 align-text-bottom"})]}):i?c.jsxs("span",{className:"text-blue-400",children:[i.label,c.jsx("span",{className:"inline-block w-1 h-3 bg-blue-400 animate-pulse ml-1 align-text-bottom"})]}):e?c.jsxs("span",{className:"text-blue-400",children:[c.jsx("code",{className:"text-xs font-mono",children:e}),c.jsx("span",{className:"inline-block w-1 h-3 bg-blue-400 animate-pulse ml-0.5 align-text-bottom"})]}):c.jsx("span",{className:"text-muted-foreground",children:"Preparing..."})}function rYe({tool:e,streamingArgs:r,scrollRef:n}){const i=Ba(e),s=i.startsWith("terminal."),o=s?joe(r):null,a=i==="web"||i==="web.search"||i==="web.fetch"||i==="browser.search"||i==="browser.fetch",l=a?Noe(r):null;if(s&&o)return c.jsxs("pre",{ref:n,className:Fe("text-xs font-mono leading-5 rounded-md px-3 py-2 overflow-x-auto max-h-64 overflow-y-auto whitespace-pre-wrap break-all","bg-muted/40 text-foreground"),children:[c.jsx("span",{className:"text-emerald-400",children:"$ "}),o,c.jsx("span",{className:"inline-block w-1.5 h-3.5 bg-blue-400 animate-pulse ml-0.5 align-text-bottom"})]});if(a&&l){const d=i==="web.search"||i==="browser.search"?"Searching":"Fetching";return c.jsx("div",{className:Fe("rounded-md border px-3 py-2 text-xs","bg-muted/40 text-foreground"),children:c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(ir,{className:"h-3 w-3 animate-spin text-blue-400"}),c.jsxs("span",{children:[d," ",l,"..."]})]})})}if(i==="memory.save"){const d=du(r,"scope")??"memory",u=du(r,"content");return c.jsxs("div",{className:Fe("rounded-md border px-3 py-2 text-xs","bg-muted/40 text-foreground"),children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(ir,{className:"h-3 w-3 animate-spin text-blue-400"}),c.jsxs("span",{children:["Saving memory (",d,")..."]})]}),u?c.jsxs("div",{className:"mt-1 opacity-80",children:['"',xd(u,120),'"']}):null]})}if(i==="cron.add"){const d=du(r,"name"),u=du(r,"cron"),f=du(r,"toolName");return c.jsxs("div",{className:Fe("rounded-md border px-3 py-2 text-xs","bg-muted/40 text-foreground"),children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(ir,{className:"h-3 w-3 animate-spin text-blue-400"}),c.jsxs("span",{children:["Creating cron job",d?`: ${d}`:"..."]})]}),(u||f)&&c.jsxs("div",{className:"mt-1 opacity-80",children:[u?`schedule ${u}`:"",u&&f?" • ":"",f?`tool ${f}`:""]})]})}return r?c.jsxs("pre",{ref:n,className:Fe("text-xs font-mono leading-5 rounded-md px-3 py-2 overflow-x-auto max-h-36 overflow-y-auto whitespace-pre-wrap break-all","bg-muted/40 text-muted-foreground"),children:[r,c.jsx("span",{className:"inline-block w-1.5 h-3.5 bg-blue-400 animate-pulse ml-0.5 align-text-bottom"})]}):c.jsx("div",{className:Fe("rounded-md border px-3 py-2 text-xs","bg-muted/40 text-foreground"),children:c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(ir,{className:"h-3 w-3 animate-spin text-blue-400"}),c.jsx("span",{children:"Preparing..."})]})})}function Toe(e){const r=new Map,n=new Set,i=new Map(e.map(s=>[s.callId,s]));for(const s of e){if(!s.parentCallId||!i.has(s.parentCallId))continue;const o=r.get(s.parentCallId)??[];r.set(s.parentCallId,[...o,s]),n.add(s.callId)}for(let s=0;s<e.length;s++){const o=e[s];if(Ba(o.tool)!=="agent")continue;const a=[];for(let l=s+1;l<e.length;l++){const d=e[l];if(n.has(d.callId))continue;const u=o.status==="running"||o.status==="pending",f=o.completedAt!=null&&d.startedAt<=o.completedAt;if(u||f)a.push(d),n.add(d.callId);else break}if(a.length>0){const l=r.get(o.callId)??[];r.set(o.callId,[...l,...a])}}return{childMap:r,parentSet:n}}function Eoe(e){return e==="browserScreenshot"}function Aoe(e){var o,a;const r=Ba(e.tool),n=(o=e.result)!=null&&o.data&&typeof e.result.data=="object"?e.result.data:void 0,i=xu(r,e.args,n),s=boe(r,i,n,(a=e.result)==null?void 0:a.message);return Eoe(_oe({tool:r,args:i,status:e.status,displayOutput:Coe(e.result,r)||e.streamingOutput||"",snapshotText:typeof(n==null?void 0:n.snapshot)=="string"?n.snapshot:null,screenshotPath:s}))}function nYe({path:e,onOpenDiff:r,disabled:n}){const i=iP(e),s=!!r&&!n,o=c.jsxs(c.Fragment,{children:[c.jsx($o,{filename:i,className:"h-3.5 w-3.5 shrink-0"}),c.jsx("span",{className:"max-w-[220px] truncate",children:i})]});return s?c.jsx("span",{role:"button",tabIndex:0,className:"inline-flex max-w-full items-center gap-1.5 rounded-md border border-border/70 bg-muted/45 px-2 py-1 text-xs font-medium leading-none text-foreground transition-colors hover:bg-muted cursor-pointer",title:`Open diff for ${e}`,onClick:a=>{a.preventDefault(),a.stopPropagation(),r(e)},onKeyDown:a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),a.stopPropagation(),r(e))},children:o}):c.jsx("span",{className:"inline-flex max-w-full items-center gap-1.5 rounded-md border border-border/70 bg-muted/45 px-2 py-1 text-xs font-medium leading-none text-foreground",title:e,children:o})}function iYe({call:e,childCalls:r,onOpenTerminal:n,onOpenDiff:i,inlineSecretPrompt:s,renderInlineSecretPrompt:o,hideTopConnector:a=!1,hideBottomConnector:l=!1}){var ce,Ge,Xe,Le,je,Qe,kt,Vt,Re;const d=Aoe(e),[u,f]=y.useState(e.status==="running"||e.status==="pending"||d),[p,g]=y.useState(()=>Date.now()),v=y.useRef(e.status),b=Ba(e.tool),_=(ce=e.result)!=null&&ce.data&&typeof e.result.data=="object"?e.result.data:void 0,S=xu(b,e.args,_),k=b==="mcp-tool"?nP(S,_):null,C=k?LKe(k.title):null,j=Soe(b),E=(C==null?void 0:C.icon)??j.icon,N=(C==null?void 0:C.color)??j.color,A=FKe(b,S,_,(Ge=e.result)==null?void 0:Ge.message),M=A7(b,S),P=Coe(e.result,b)||e.streamingOutput||"",D=typeof(_==null?void 0:_.snapshot)=="string"?_.snapshot:null,W=boe(b,S,_,(Xe=e.result)==null?void 0:Xe.message),U=b.startsWith("terminal.")||b==="execute",H=XKe(e),R=eYe(e),I=R?zC(e):null,L=KKe(b,S),z=s??(o==null?void 0:o(e))??null,G=z!=null,X=e.status==="pending",F=((je=E7(b,S,_,(Le=e.result)==null?void 0:Le.message))==null?void 0:je.trim())??"",V=!!F&&IKe(b),Q=sH(P),q=sH(e.streamingArgs),ee=_oe({tool:b,args:S,status:e.status,displayOutput:P,snapshotText:D,screenshotPath:W}),ne=Eoe(ee),le=ee==="terminal"?!0:ee!=="none"&&!ne,de=e.status==="pending"||e.status==="running"?ir:e.status==="success"?ml:Fh,te=e.status==="pending"?"text-blue-400":e.status==="running"?"text-muted-foreground":e.status==="success"?"text-green-500":"text-red-500";y.useEffect(()=>{const Ze=v.current;!ne&&(Ze==="running"||Ze==="pending")&&e.status!=="running"&&e.status!=="pending"&&f(!1),(e.status==="pending"||e.status==="running"||ne)&&f(!0),v.current=e.status},[e.status,ne]),y.useEffect(()=>{var Ze;b!=="web"&&b!=="web.search"&&b!=="web.fetch"&&b!=="browser.search"&&b!=="browser.fetch"||console.debug("[tool-call-card:web]",{tool:e.tool,normalizedTool:b,callId:e.callId,status:e.status,rawArgs:e.args,normalizedArgs:S,resultMessage:(Ze=e.result)==null?void 0:Ze.message,resultData:_,streamingArgs:e.streamingArgs})},[e.args,e.callId,(Qe=e.result)==null?void 0:Qe.message,e.status,e.streamingArgs,e.tool,S,b,_]),y.useEffect(()=>{if(e.status!=="running"&&e.status!=="pending")return;const Ze=window.setInterval(()=>g(Date.now()),250);return()=>window.clearInterval(Ze)},[e.status]);const ie=PKe(b,S,_,(kt=e.result)==null?void 0:kt.message),be=e.status==="running"||e.status==="pending"?ie.running:ie.done,me=c.jsxs(c.Fragment,{children:[c.jsx(de,{className:Fe("h-4 w-4 shrink-0",te,(e.status==="running"||e.status==="pending")&&"animate-spin")}),c.jsx("span",{className:"flex-1 truncate text-[13px] font-medium text-muted-foreground",children:X?c.jsx(tYe,{tool:e.tool,streamingArgs:e.streamingArgs}):U?c.jsxs("span",{className:"inline-flex max-w-full min-w-0 items-center gap-1.5 text-foreground",children:[c.jsx("span",{className:"shrink-0 text-xs text-emerald-500 dark:text-emerald-400 font-mono",children:"$"}),c.jsx("code",{className:"min-w-0 truncate text-xs font-mono",title:A,children:A})]}):V?c.jsxs("span",{className:"inline-flex min-w-0 max-w-full items-center gap-2",children:[c.jsxs("span",{children:[be,":"]}),c.jsx(nYe,{path:F,onOpenDiff:i,disabled:e.status!=="success"})]}):k&&(k.title||k.details)?c.jsxs("span",{className:"inline-flex min-w-0 max-w-full items-center gap-2",children:[c.jsxs("span",{children:[be,":"]}),c.jsxs("span",{className:"min-w-0 truncate",children:[k.title?c.jsx("code",{className:"text-[11px] font-mono",children:k.title}):null,k.title&&k.details?c.jsx("span",{className:"text-muted-foreground",children:" • "}):null,k.details?c.jsx("span",{className:"text-xs text-muted-foreground",children:k.details}):null]})]}):c.jsxs("span",{children:[be,": ",c.jsx("code",{className:"text-[11px] font-mono",children:A})]})}),c.jsx("span",{className:"text-xs text-muted-foreground/60 tabular-nums shrink-0",children:c.jsx(R7,{startedAt:e.startedAt,completedAt:e.completedAt,now:p})}),M&&c.jsx("span",{className:"rounded border border-blue-500/25 bg-blue-500/10 px-1.5 py-0.5 text-2xs font-semibold tabular-nums text-blue-500 shrink-0",children:M}),H&&c.jsx("span",{className:Fe("rounded border px-1.5 py-0.5 text-2xs font-semibold uppercase tracking-wide shrink-0",H.className),children:H.label})]}),Je=ee==="pending"?c.jsx(rYe,{tool:e.tool,streamingArgs:e.streamingArgs,scrollRef:q}):ee==="terminal"?c.jsxs("pre",{ref:Q,className:Fe("text-xs font-mono leading-5 rounded-md px-3 py-2 overflow-x-auto max-h-64 overflow-y-auto whitespace-pre-wrap break-all","bg-muted/40 text-foreground",e.result&&!e.result.ok&&"text-red-500 dark:text-red-400"),children:[!P&&e.status!=="running"&&c.jsxs("span",{className:"text-muted-foreground",children:[c.jsx("span",{className:"text-emerald-500 dark:text-emerald-400",children:"$ "}),A]}),P,e.status==="running"&&!P&&c.jsx("span",{className:"text-muted-foreground",children:"Running..."}),e.status==="running"&&c.jsx("span",{className:"inline-block w-1.5 h-3.5 bg-foreground animate-pulse ml-0.5 align-text-bottom"})]}):ee==="browserSnapshot"?c.jsx(JKe,{snapshot:D}):ee==="browserScreenshot"?c.jsx(QKe,{path:W}):ee==="subagent"?r&&r.length>0?c.jsxs("div",{className:"rounded-lg border border-purple-500/20 bg-purple-500/[0.03] text-xs",children:[(e.status==="running"||e.status==="pending")&&r.length>0&&c.jsxs("div",{className:"flex items-center justify-end gap-2 border-b border-purple-500/15 px-3 py-2 text-xs text-muted-foreground",children:[c.jsx(ir,{className:"h-3 w-3 animate-spin text-purple-500"}),c.jsxs("span",{children:[r.length," tool",r.length!==1?"s":""]})]}),(e.status==="running"||e.status==="pending")&&r.length===0&&c.jsx("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"Agent is working..."}),c.jsx("div",{className:"divide-y divide-border/30",children:r.map(Ze=>c.jsx(tp,{call:Ze,onOpenTerminal:n,onOpenDiff:i,renderInlineSecretPrompt:o},Ze.callId))}),((Vt=e.result)==null?void 0:Vt.message)&&(e.status==="success"||e.status==="error")&&c.jsxs("div",{className:"border-t border-purple-500/15 px-3 py-2",children:[c.jsx("div",{className:"mb-1 text-xs font-medium text-muted-foreground",children:"Result"}),c.jsx("pre",{className:"max-h-48 overflow-auto whitespace-pre-wrap rounded bg-background/60 p-2 font-mono text-xs leading-5",children:e.result.message})]})]}):c.jsx(ZKe,{data:_??{},message:(Re=e.result)==null?void 0:Re.message,status:e.status}):ee==="editDiff"?c.jsx(CKe,{filePath:String(S.path??""),oldText:b==="file.patch"||b==="edit"&&S.search!=null?String(S.search??""):void 0,newText:b==="file.patch"||b==="edit"&&S.replace!=null?String(S.replace??""):void 0,writtenContent:b==="file.write"||b==="edit"&&S.content!=null?String(S.content??""):void 0,isNewFile:b==="file.write"}):ee==="output"?c.jsxs("pre",{className:Fe("text-xs font-mono leading-5 rounded-md px-3 py-2 overflow-x-auto max-h-64 overflow-y-auto whitespace-pre-wrap break-all","bg-muted/40 text-foreground",e.result&&!e.result.ok&&"text-red-500 dark:text-red-400"),children:[P,e.status==="running"&&c.jsx("span",{className:"inline-block w-1.5 h-3.5 bg-foreground animate-pulse ml-0.5 align-text-bottom"})]}):ee==="runningHint"?c.jsxs("div",{className:Fe("rounded-md border px-3 py-2 text-xs","bg-muted/40 text-foreground"),children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(ir,{className:"h-3 w-3 animate-spin"}),c.jsx("span",{children:L})]}),c.jsxs("div",{className:"mt-1 text-xs opacity-75",children:["Elapsed: ",c.jsx(R7,{startedAt:e.startedAt,completedAt:e.completedAt,now:p})]})]}):null;return c.jsxs(NS,{open:le?u:!1,onOpenChange:f,children:[c.jsxs("div",{className:"relative pl-7",children:[!a&&c.jsx("span",{className:"absolute left-[10.5px] top-0 h-6 w-px bg-border/60",style:{maskImage:"linear-gradient(to bottom, transparent 0 22px, #000 22px 100%)"},"aria-hidden":"true"}),!l&&c.jsx("span",{className:"absolute left-[10.5px] top-0 bottom-0 w-px bg-border/60",style:{maskImage:"linear-gradient(to bottom, #000 0 5px, transparent 5px 23px, #000 23px 100%)"},"aria-hidden":"true"}),l&&!a&&c.jsx("span",{className:"absolute left-[10.5px] top-0 bottom-0 w-px bg-border/60",style:{maskImage:"linear-gradient(to bottom, #000 0 5px, transparent 5px 100%)"},"aria-hidden":"true"}),c.jsx("div",{className:"absolute left-[5px] top-[9px] z-10 flex h-3 w-3 items-center justify-center",children:c.jsx(E,{className:Fe("h-3 w-3 shrink-0",N)})}),c.jsx("div",{className:"group pb-1",children:c.jsxs("div",{className:"flex items-center gap-2 rounded-sm px-1 py-1.5 transition-colors hover:bg-muted/20",children:[le?c.jsxs(TS,{className:"flex min-w-0 flex-1 items-center gap-2 text-left",children:[c.jsx(ko,{className:Fe("h-3 w-3 shrink-0 text-muted-foreground transition-transform duration-200",u&&"rotate-90")}),me]}):c.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 text-left",children:[c.jsx("span",{className:"h-3 w-3 shrink-0"}),me]}),R&&n&&c.jsxs(fn,{children:[c.jsx(ln,{asChild:!0,children:c.jsx(_e,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:Ze=>{Ze.preventDefault(),Ze.stopPropagation(),n(I)},children:c.jsx(sp,{className:"h-3.5 w-3.5"})})}),c.jsx(cn,{side:"top",children:"Open terminal"})]}),ee==="editDiff"&&i&&e.status==="success"&&F&&c.jsxs(fn,{children:[c.jsx(ln,{asChild:!0,children:c.jsx(_e,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:Ze=>{Ze.preventDefault(),Ze.stopPropagation(),i(F)},children:c.jsx(sp,{className:"h-3.5 w-3.5"})})}),c.jsx(cn,{side:"top",children:"Open diff in editor"})]})]})})]}),le&&c.jsx(ES,{children:c.jsx("div",{className:"ml-7 mr-3 mb-2 border-l border-border/40 pl-4",children:Je})}),ne&&c.jsx("div",{className:"ml-7 mr-3 mb-2 border-l border-border/40 pl-4",children:Je}),G&&c.jsx("div",{className:"ml-7 mr-3 mb-2 border-l border-border/40 pl-4",children:c.jsx("div",{className:"rounded-lg border border-yellow-500/25 bg-yellow-500/[0.04] p-3",children:z})})]})}const tp=y.memo(iYe);tp.displayName="ToolCallCard";const Ooe=3,Y1=6;function sYe(e,r){if(!r||e.some(Aoe))return!1;const n=e.filter(i=>i.status!=="running"&&i.status!=="pending");return n.length>=Ooe&&n.length===e.length}function oYe({calls:e,collapsible:r,onOpenTerminal:n,onOpenDiff:i,renderInlineSecretPrompt:s}){const[o,a]=y.useState(!1),[l,d]=y.useState(()=>!sYe(e,r)),u=y.useRef(!1),{childMap:f,parentSet:p}=y.useMemo(()=>Toe(e),[e]),g=y.useMemo(()=>e.filter(P=>!p.has(P.callId)),[e,p]),v=g.filter(P=>P.status==="running"||P.status==="pending"),b=g.filter(P=>P.status!=="running"&&P.status!=="pending"),_=v.length===0&&b.length>0,S=r&&_&&b.length>=Ooe;if(y.useEffect(()=>{S&&!u.current&&d(!1),u.current=_},[_,S]),e.length===0)return null;const k=b.filter(P=>P.status==="success").length,C=b.filter(P=>P.status==="error").length,j=koe(b);if(S&&!l)return c.jsx("div",{className:"my-2",children:c.jsxs("button",{type:"button",onClick:()=>d(!0),className:"flex w-full items-center gap-2 rounded-md px-2 py-2 text-xs text-muted-foreground transition-colors hover:bg-muted/35",children:[c.jsx(ko,{className:"h-3.5 w-3.5 shrink-0"}),c.jsx(j,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),c.jsx("span",{className:"font-medium",children:O7(b)}),k>0&&c.jsxs("span",{className:"inline-flex items-center gap-0.5 text-green-500",children:[c.jsx(ml,{className:"h-3 w-3"})," ",k]}),C>0&&c.jsxs("span",{className:"inline-flex items-center gap-0.5 text-red-500",children:[c.jsx(Fh,{className:"h-3 w-3"})," ",C]})]})});const E=!o&&b.length>Y1,N=E?b.length-Y1:0,A=E?b.slice(-Y1):b,M=E?b.slice(0,N).filter(P=>P.status==="success").length:0,B=N-M;return c.jsxs("div",{className:"my-2",children:[S&&c.jsxs("button",{type:"button",onClick:()=>d(!1),className:"mb-1 flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-xs text-muted-foreground transition-colors hover:bg-muted/35",children:[c.jsx(ko,{className:"h-3 w-3 rotate-90 transition-transform"}),c.jsxs("span",{children:["Collapse ",O7(b)]})]}),E&&c.jsxs("button",{type:"button",onClick:()=>a(!0),className:"mb-1 flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-xs text-muted-foreground transition-colors hover:bg-muted/35",children:[c.jsx(ko,{className:"h-3 w-3"}),c.jsxs("span",{children:[N," earlier tool call",N!==1?"s":"",M>0&&c.jsxs("span",{className:"text-green-500 ml-1",children:["(",M," passed)"]}),B>0&&c.jsxs("span",{className:"text-red-500 ml-1",children:["(",B," failed)"]})]})]}),o&&b.slice(0,N).map((P,D,W)=>c.jsx(tp,{call:P,childCalls:f.get(P.callId),onOpenTerminal:n,onOpenDiff:i,renderInlineSecretPrompt:s,hideTopConnector:D===0,hideBottomConnector:D===W.length-1&&A.length===0&&v.length===0},P.callId)),A.map((P,D)=>c.jsx(tp,{call:P,childCalls:f.get(P.callId),onOpenTerminal:n,onOpenDiff:i,renderInlineSecretPrompt:s,hideTopConnector:o?!1:D===0,hideBottomConnector:D===A.length-1&&v.length===0},P.callId)),v.map((P,D)=>c.jsx(tp,{call:P,childCalls:f.get(P.callId),onOpenTerminal:n,onOpenDiff:i,renderInlineSecretPrompt:s,hideTopConnector:b.length===0&&D===0,hideBottomConnector:D===v.length-1},P.callId))]})}function Roe(e,r){if(e===r)return!0;if(e.length!==r.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==r[n])return!1;return!0}const M7=y.memo(oYe,(e,r)=>e.onOpenTerminal===r.onOpenTerminal&&e.onOpenDiff===r.onOpenDiff&&e.renderInlineSecretPrompt===r.renderInlineSecretPrompt&&e.collapsible===r.collapsible&&Roe(e.calls,r.calls));M7.displayName="ToolCallGroup";function aH(e,r){return r?!1:e.length>0&&e.every(n=>n.status!=="running"&&n.status!=="pending")}function aYe({provider:e,calls:r,isStreaming:n,onOpenTerminal:i,onOpenDiff:s,renderInlineSecretPrompt:o}){const[a,l]=y.useState(()=>!aH(r,n)),[d,u]=y.useState(!1),[f,p]=y.useState(()=>Date.now()),g=y.useRef(!aH(r,n)),v=!!n||r.some(H=>H.status==="running"||H.status==="pending"),b=r.filter(H=>H.status==="success").length,_=r.filter(H=>H.status==="error").length,S=r.length>0?Math.min(...r.map(H=>H.startedAt)):Date.now(),k=!v&&r.length>0?Math.max(...r.map(H=>H.completedAt??H.startedAt)):void 0,C=koe(r),{childMap:j,parentSet:E}=y.useMemo(()=>Toe(r),[r]),N=y.useMemo(()=>r.filter(H=>!E.has(H.callId)),[r,E]),A=N.filter(H=>H.status==="running"||H.status==="pending"),M=N.filter(H=>H.status!=="running"&&H.status!=="pending"),B=!d&&M.length>Y1,P=B?M.length-Y1:0,D=B?M.slice(-Y1):M,W=B?M.slice(0,P).filter(H=>H.status==="success").length:0,U=P-W;return y.useEffect(()=>{g.current&&!v&&r.length>0&&l(!1),g.current=v},[v,r.length]),y.useEffect(()=>{if(!v)return;const H=window.setInterval(()=>p(Date.now()),250);return()=>window.clearInterval(H)},[v]),r.length===0?null:c.jsx(NS,{open:a,onOpenChange:l,children:c.jsxs("div",{className:"my-2",children:[c.jsxs(TS,{className:"flex w-full items-center gap-2 rounded-md px-2 py-2 text-left transition-colors hover:bg-muted/35",children:[c.jsx(ko,{className:Fe("h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform duration-200",a&&"rotate-90")}),v?c.jsx(ir,{className:"h-4 w-4 shrink-0 text-muted-foreground animate-spin"}):c.jsx(C,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),c.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:O7(r)}),c.jsxs("div",{className:"flex items-center gap-2 ml-auto text-xs text-muted-foreground tabular-nums shrink-0",children:[!v&&_>0&&c.jsxs("span",{className:"text-red-500",children:[_," failed"]}),c.jsx(R7,{startedAt:S,completedAt:k,now:f})]}),!v&&_===0&&b>0&&c.jsx(ml,{className:"h-3.5 w-3.5 shrink-0 text-green-500"}),!v&&_>0&&c.jsx(Fh,{className:"h-3.5 w-3.5 shrink-0 text-red-500"})]}),c.jsx(ES,{children:c.jsxs("div",{className:"mt-1",children:[B&&c.jsxs("button",{type:"button",onClick:()=>u(!0),className:"mb-1 flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-xs text-muted-foreground transition-colors hover:bg-muted/35",children:[c.jsx(ko,{className:"h-3 w-3"}),c.jsxs("span",{children:[P," earlier tool call",P!==1?"s":"",W>0&&c.jsxs("span",{className:"text-green-500 ml-1",children:["(",W," passed)"]}),U>0&&c.jsxs("span",{className:"text-red-500 ml-1",children:["(",U," failed)"]})]})]}),d&&M.slice(0,P).map((H,R,I)=>c.jsx(tp,{call:H,childCalls:j.get(H.callId),onOpenTerminal:i,onOpenDiff:s,renderInlineSecretPrompt:o,hideTopConnector:R===0,hideBottomConnector:R===I.length-1&&D.length===0&&A.length===0},H.callId)),D.map((H,R)=>c.jsx(tp,{call:H,childCalls:j.get(H.callId),onOpenTerminal:i,onOpenDiff:s,renderInlineSecretPrompt:o,hideTopConnector:d?!1:R===0,hideBottomConnector:R===D.length-1&&A.length===0},H.callId)),A.map((H,R)=>c.jsx(tp,{call:H,childCalls:j.get(H.callId),onOpenTerminal:i,onOpenDiff:s,renderInlineSecretPrompt:o,hideTopConnector:M.length===0&&R===0,hideBottomConnector:R===A.length-1},H.callId))]})})]})})}const P7=y.memo(aYe,(e,r)=>e.provider===r.provider&&e.isStreaming===r.isStreaming&&e.onOpenTerminal===r.onOpenTerminal&&e.onOpenDiff===r.onOpenDiff&&e.renderInlineSecretPrompt===r.renderInlineSecretPrompt&&Roe(e.calls,r.calls));P7.displayName="AgentToolCallWrapper";function lH(e){switch(e){case"system":return"border-red-500/35 bg-red-500/10 text-red-700 dark:text-red-300";case"user":return"border-blue-500/35 bg-blue-500/10 text-blue-700 dark:text-blue-300";case"assistant":return"border-emerald-500/35 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300";case"tool":return"border-amber-500/35 bg-amber-500/10 text-amber-700 dark:text-amber-300";default:return"border-border bg-muted text-muted-foreground"}}function rp(e){if(e==null)return"";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);try{return JSON.stringify(e,null,2)}catch{return String(e)}}function lYe(e){return"content"in e?rp(e.content):rp(e)}function cYe(e){return(Array.isArray(e.tool_calls)?e.tool_calls:Array.isArray(e.toolCalls)?e.toolCalls:[]).map((n,i)=>{const s=n&&typeof n=="object"?n:{},o=s.function&&typeof s.function=="object"?s.function:{};return{id:rp(s.id||s.call_id||s.tool_call_id||`tool-call-${i+1}`),name:rp(o.name||s.name||s.tool||"tool"),args:rp(o.arguments||s.arguments||s.args||{})}})}function uYe(e,r){const n=e&&typeof e=="object"?e:{},i=n.function&&typeof n.function=="object"?n.function:{};return{name:rp(i.name||n.name||`tool_${r+1}`),description:typeof i.description=="string"?i.description:typeof n.description=="string"?n.description:void 0,raw:e}}function Moe(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function Nm(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function cH({badge:e,meta:r,preview:n,children:i,tone:s="default",defaultOpen:o=!1,onOpenChange:a}){const[l,d]=y.useState(o);return c.jsx(NS,{open:l,onOpenChange:u=>{d(u),a==null||a()},children:c.jsxs("div",{className:Fe("rounded-md border p-3",s==="assistant"?"border-emerald-500/25 bg-emerald-500/10":"border-border/80 bg-background"),children:[c.jsxs("div",{className:"flex items-start gap-2",children:[c.jsxs(TS,{className:"mt-0.5 rounded-sm p-0.5 text-muted-foreground transition-colors hover:bg-background/70 hover:text-foreground",children:[c.jsx(ko,{className:Fe("h-4 w-4 transition-transform",l&&"rotate-90")}),c.jsx("span",{className:"sr-only",children:l?"Collapse section":"Expand section"})]}),c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[e,r]}),n?c.jsx("div",{className:"mt-1 text-xs text-muted-foreground/70",children:n}):null]})]}),c.jsx(ES,{className:"pl-6",children:c.jsx("div",{className:"pt-3",children:i})})]})})}function dYe({flow:e}){const r=e.rounds;if(!r.some(p=>p.metrics))return null;let i=0,s=0,o=0,a=0,l,d=0,u=0;for(const p of r){const g=p.metrics;g&&(i+=g.durationMs,g.promptTokens&&(s+=g.promptTokens),g.completionTokens&&(o+=g.completionTokens),g.totalTokens&&(a+=g.totalTokens),g.tokensPerSecond&&g.completionTokens&&(d+=g.tokensPerSecond*g.completionTokens,u+=g.completionTokens),g.contextUsage&&(l=g.contextUsage))}const f=u>0?Math.round(d/u*10)/10:void 0;return c.jsxs("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-4",children:[c.jsxs("div",{className:"rounded-md border border-border bg-muted/30 px-2.5 py-2",children:[c.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[c.jsx(sg,{className:"h-3 w-3"}),"Total Duration"]}),c.jsx("div",{className:"mt-0.5 text-sm font-semibold text-foreground",children:Moe(i)}),c.jsxs("div",{className:"text-xs text-muted-foreground",children:[r.length," round",r.length!==1?"s":""]})]}),c.jsxs("div",{className:"rounded-md border border-border bg-muted/30 px-2.5 py-2",children:[c.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[c.jsx(P8,{className:"h-3 w-3"}),"Tokens"]}),c.jsx("div",{className:"mt-0.5 text-sm font-semibold text-foreground",children:a>0?Nm(a):s+o>0?Nm(s+o):"—"}),c.jsxs("div",{className:"text-xs text-muted-foreground",children:[s>0?`${Nm(s)} in`:"",s>0&&o>0?" · ":"",o>0?`${Nm(o)} out`:"",s===0&&o===0?"estimated":""]})]}),c.jsxs("div",{className:"rounded-md border border-border bg-muted/30 px-2.5 py-2",children:[c.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[c.jsx(vK,{className:"h-3 w-3"}),"Speed"]}),c.jsx("div",{className:"mt-0.5 text-sm font-semibold text-foreground",children:f?`${f} tok/s`:"—"}),c.jsx("div",{className:"text-xs text-muted-foreground",children:"completion tokens/sec"})]}),c.jsxs("div",{className:"rounded-md border border-border bg-muted/30 px-2.5 py-2",children:[c.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[c.jsx(zge,{className:"h-3 w-3"}),"Context Window"]}),l?c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"mt-0.5 text-sm font-semibold text-foreground",children:[Math.round(l.ratio*100),"%"]}),c.jsxs("div",{className:"text-xs text-muted-foreground",children:[Nm(l.total)," / ",Nm(l.limit)," tokens",l.pruned?" (pruned)":""]})]}):c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"mt-0.5 text-sm font-semibold text-foreground",children:"—"}),c.jsx("div",{className:"text-xs text-muted-foreground",children:"no data"})]})]})]})}function hYe({metrics:e}){return e?c.jsxs("div",{className:"mt-2 flex flex-wrap gap-x-3 gap-y-1 text-xs text-muted-foreground",children:[c.jsx("span",{title:"LLM request duration",children:Moe(e.durationMs)}),e.promptTokens!=null&&c.jsxs("span",{title:"Prompt tokens",children:[Nm(e.promptTokens)," prompt"]}),e.completionTokens!=null&&c.jsxs("span",{title:"Completion tokens",children:[Nm(e.completionTokens)," completion"]}),e.tokensPerSecond!=null&&c.jsxs("span",{title:"Completion tokens per second",className:"font-medium text-foreground/80",children:[e.tokensPerSecond," tok/s"]}),e.contextUsage&&c.jsxs("span",{title:"Context window utilisation",children:["ctx ",Math.round(e.contextUsage.ratio*100),"%",e.contextUsage.pruned?" (pruned)":""]})]}):null}function fYe(e,r){const n=[];if(!e)return r?[{id:"assistant-response",kind:"response",content:r}]:n;e.rounds.some(i=>i.metrics)&&n.push({id:"summary",kind:"summary",flow:e});for(const i of e.rounds){const s=Array.isArray(i.messages)?i.messages:[],o=Array.isArray(i.tools)?i.tools.map(uYe):[];n.push({id:`round-${i.round}`,kind:"round",round:i,messageCount:s.length,toolCount:o.length}),s.forEach((a,l)=>{const d=a&&typeof a=="object"?a:{content:a};n.push({id:`round-${i.round}-message-${l}`,kind:"message",roundNumber:i.round,index:l,role:rp(d.role||"message"),content:lYe(d),raw:a,toolCalls:cYe(d)})}),o.length>0&&n.push({id:`round-${i.round}-tools`,kind:"tools",roundNumber:i.round,tools:o})}return r&&n.push({id:"assistant-response",kind:"response",content:r}),n}function pYe({row:e,onExpandChange:r}){if(e.kind==="summary")return c.jsx(dYe,{flow:e.flow});if(e.kind==="round")return c.jsxs("div",{className:"min-w-0 overflow-hidden rounded-md border border-border bg-background px-3 py-2",children:[c.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[c.jsxs("span",{className:"rounded-md bg-foreground px-2 py-1 text-xs font-semibold text-background",children:["Round ",e.round.round]}),c.jsx("span",{className:"min-w-0 break-words text-xs text-muted-foreground",children:e.round.model}),c.jsx("span",{className:"min-w-0 break-words text-xs text-muted-foreground",children:new Date(e.round.createdAt).toLocaleString()})]}),c.jsxs("div",{className:"mt-2 flex min-w-0 flex-wrap gap-2 text-xs text-muted-foreground",children:[c.jsxs("span",{children:[e.messageCount," messages sent"]}),c.jsxs("span",{children:[e.toolCount," tool schemas available"]}),e.round.tool_choice?c.jsxs("span",{className:"min-w-0 break-words",children:["tool_choice: ",e.round.tool_choice]}):null]}),c.jsx(hYe,{metrics:e.round.metrics})]});if(e.kind==="tools")return c.jsxs("div",{className:"relative ml-2 sm:ml-4 border-l border-border pl-2 sm:pl-4",children:[c.jsx("div",{className:"absolute -left-1.5 top-3 h-3 w-3 rounded-full border border-border bg-background"}),c.jsxs("div",{className:"rounded-md border border-border/80 bg-muted/25 p-3",children:[c.jsxs("div",{className:"mb-2 flex items-center gap-2 text-xs font-medium text-foreground",children:[c.jsx(P9,{className:"h-3.5 w-3.5"}),"Tools offered to model in round ",e.roundNumber]}),c.jsx("div",{className:"grid gap-2 sm:grid-cols-2",children:e.tools.map(i=>c.jsxs("details",{className:"rounded-md border border-border/70 bg-background/70 p-2",children:[c.jsx("summary",{className:"cursor-pointer text-xs font-medium text-foreground",children:i.name}),i.description?c.jsx("p",{className:"mt-1 text-xs leading-relaxed text-muted-foreground",children:i.description}):null,c.jsx("pre",{className:"mt-2 max-h-40 overflow-auto whitespace-pre-wrap break-words rounded bg-muted/40 p-2 font-mono text-xs leading-5",children:rp(i.raw)})]},i.name))})]})]});if(e.kind==="response")return c.jsxs("div",{className:"relative ml-2 sm:ml-4 border-l border-border pl-2 sm:pl-4",children:[c.jsx("div",{className:"absolute -left-1.5 top-3 h-3 w-3 rounded-full border border-emerald-500/40 bg-background"}),c.jsx(cH,{tone:"assistant",defaultOpen:!1,onOpenChange:r,badge:c.jsx("span",{className:Fe("rounded-md border px-2 py-0.5 text-xs font-semibold",lH("assistant")),children:"assistant response"}),meta:c.jsx("span",{className:"text-xs text-muted-foreground",children:"rendered chat answer"}),preview:c.jsx("span",{className:"block truncate",children:e.content||"(empty response)"}),children:c.jsx("pre",{className:"max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-md bg-background/70 p-3 font-mono text-xs leading-5 text-foreground [overflow-wrap:anywhere]",children:e.content||"(empty response)"})})]});const n=e.content?e.content.length>80?e.content.slice(0,80)+"...":e.content:"(empty content)";return c.jsxs("div",{className:"relative ml-2 sm:ml-4 border-l border-border pl-2 sm:pl-4",children:[c.jsx("div",{className:"absolute -left-1.5 top-3 h-3 w-3 rounded-full border border-border bg-background"}),c.jsxs(cH,{defaultOpen:!1,onOpenChange:r,badge:c.jsx("span",{className:Fe("rounded-md border px-2 py-0.5 text-xs font-semibold",lH(e.role)),children:e.role}),meta:c.jsxs(c.Fragment,{children:[c.jsxs("span",{className:"text-xs text-muted-foreground",children:["round ",e.roundNumber," / message ",e.index+1]}),e.toolCalls.length>0?c.jsxs("span",{className:"text-xs text-amber-600 dark:text-amber-400",children:[e.toolCalls.length," tool call",e.toolCalls.length!==1?"s":""]}):null]}),preview:c.jsx("span",{className:"block truncate",children:n}),children:[c.jsx("pre",{className:"max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-md bg-muted/35 p-3 font-mono text-xs leading-5 text-foreground [overflow-wrap:anywhere]",children:e.content||"(empty content)"}),e.toolCalls.length>0?c.jsx("div",{className:"mt-3 space-y-2",children:e.toolCalls.map(i=>c.jsxs("details",{className:"rounded-md border border-amber-500/25 bg-amber-500/10 p-2",children:[c.jsxs("summary",{className:"cursor-pointer text-xs font-medium text-amber-800 dark:text-amber-200",children:["Tool call: ",i.name," ",c.jsxs("span",{className:"font-normal text-muted-foreground",children:["(",i.id,")"]})]}),c.jsx("pre",{className:"mt-2 max-h-48 overflow-auto whitespace-pre-wrap break-words rounded bg-background/70 p-2 font-mono text-xs leading-5",children:i.args||"{}"})]},i.id))}):null,c.jsxs("details",{className:"mt-2",children:[c.jsx("summary",{className:"cursor-pointer text-xs text-muted-foreground",children:"Raw message JSON"}),c.jsx("pre",{className:"mt-2 max-h-48 overflow-auto whitespace-pre-wrap break-words rounded bg-muted/35 p-2 font-mono text-xs leading-5",children:rp(e.raw)})]})]})]})}function mYe({open:e,onOpenChange:r,contextFlow:n,responseContent:i}){const[s,o]=y.useState("trace"),[a,l]=y.useState(!1),d=y.useRef(null),u=y.useMemo(()=>fYe(n,i),[n,i]),f=y.useMemo(()=>n?JSON.stringify(n,null,2):"",[n]),p=rR({count:u.length,getScrollElement:()=>d.current,estimateSize:b=>{const _=u[b];return _?_.kind==="summary"?110:_.kind==="round"?120:_.kind==="tools"?Math.min(420,110+_.tools.length*72):_.kind==="response"?72:52:120},overscan:5,enabled:e&&s==="trace"});y.useEffect(()=>{if(!e||s!=="trace")return;const b=window.requestAnimationFrame(()=>{p.measure()});return()=>window.cancelAnimationFrame(b)},[e,s,u.length,p]);const g=async()=>{f&&(await navigator.clipboard.writeText(f),l(!0),window.setTimeout(()=>l(!1),1200))},v=()=>{window.requestAnimationFrame(()=>{p.measure()})};return c.jsx(Bd,{open:e,onOpenChange:r,children:c.jsxs(Eu,{showCloseButton:!1,className:"grid h-[95vh] max-w-[min(1200px,96vw)] grid-rows-[auto_minmax(0,1fr)] overflow-hidden p-0 sm:h-[85vh]",children:[c.jsx(Md,{className:"border-b px-3 py-2",children:c.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[c.jsx(Cu,{className:"shrink-0 text-sm font-semibold",children:"LLM Context Flow"}),c.jsx(Vm,{className:"min-w-0 flex-1 truncate text-xs",children:n?`${n.provider}${n.model?` / ${n.model}`:""} · ${n.rounds.length} round${n.rounds.length===1?"":"s"}`:"No context snapshot available"}),c.jsxs("div",{className:"-my-1 ml-auto flex shrink-0 items-center gap-1 p-1",children:[c.jsx(_e,{type:"button",variant:s==="trace"?"default":"outline",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>o("trace"),children:"Trace"}),c.jsx(_e,{type:"button",variant:s==="raw"?"default":"outline",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>o("raw"),children:"Raw"}),c.jsxs(_e,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2 text-xs",onClick:g,disabled:!f,children:[a?c.jsx(_s,{className:"h-3 w-3 sm:mr-1"}):c.jsx(Nc,{className:"h-3 w-3 sm:mr-1"}),c.jsx("span",{className:"hidden sm:inline",children:a?"Copied":"Copy"}),c.jsx("span",{className:"sr-only",children:a?"Copied":"Copy raw trace"})]}),c.jsxs(eK,{className:"ml-1 rounded-sm p-1 opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",children:[c.jsx(ti,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}),s==="trace"?c.jsxs("div",{className:"min-h-0 px-3 pb-3 pt-2",children:[n!=null&&n.note?c.jsx("p",{className:"mb-2 rounded-md border border-border/70 bg-muted/40 px-2.5 py-1.5 text-xs text-muted-foreground",children:n.note}):null,u.length>0?c.jsx("div",{ref:d,className:"h-full min-h-0 overflow-auto pr-2",children:c.jsx("div",{className:"relative w-full",style:{height:`${p.getTotalSize()}px`},children:p.getVirtualItems().map(b=>{const _=u[b.index];return _?c.jsx("div",{"data-index":b.index,ref:p.measureElement,className:"absolute left-0 top-0 w-full pb-3",style:{transform:`translateY(${b.start}px)`},children:c.jsx(pYe,{row:_,onExpandChange:v})},_.id):null})})}):c.jsxs("div",{className:"flex h-full items-center justify-center rounded-md border border-dashed border-border text-sm text-muted-foreground",children:[c.jsx(Rm,{className:"mr-2 h-4 w-4"}),"No context snapshot is available for this message."]})]}):c.jsx("div",{className:"min-h-0 overflow-auto px-3 pb-3 pt-2",children:c.jsx("pre",{className:"min-h-full whitespace-pre-wrap break-words rounded-md border border-border/70 bg-muted/35 p-3 font-mono text-xs leading-relaxed text-foreground [overflow-wrap:anywhere]",children:f||"No context snapshot is available for this message."})})]})})}const L7=/^[A-Za-z]:[\\/]/,gYe=/^\//;function uH(e){return e.replace(/\\/g,"/").replace(/\/+$/,"")}function yYe(e){const r=e.pathname||"/",n=/^\/[A-Za-z]:\//.test(r)?r.slice(1):r;return!e.hostname||e.hostname==="localhost"?n:`//${e.hostname}${n}`}function Poe(e){return L7.test(e)||gYe.test(e)}function Loe(e,r){const n=e.replace(/\\/g,"/");if(!n||n==="/")return!1;if(/^L\d+(?:C\d+)?$/i.test(r))return!0;const i=n.split("/").pop()??"";return/\.[A-Za-z0-9]+(?::\d+(?::\d+)?)?$/.test(i)}function vYe(e,r){if(r)return null;const n=e.replace(/\\/g,"/"),i=n.lastIndexOf("/"),o=(i>=0?n.slice(i+1):n).match(/^(.*?):(\d+)(?::(\d+))?$/);if(!o)return null;const a=i>=0?`${e.slice(0,i+1)}${o[1]??""}`:o[1]??"";if(!Poe(a)||!Loe(a,`L${o[2]}`))return null;const l={path:a,line:Number.parseInt(o[2],10)};return o[3]&&(l.column=Number.parseInt(o[3],10)),l}function xYe(e){if(!e)return null;const r=e.trim();if(!r)return null;let n=r,i="";try{const d=new URL(r);if(d.protocol==="http:"||d.protocol==="https:"){if(n=d.pathname,i=d.hash.startsWith("#")?d.hash.slice(1):d.hash,!Loe(n,i))return null}else if(d.protocol==="file:")n=yYe(d),i=d.hash.startsWith("#")?d.hash.slice(1):d.hash;else{const u=r.indexOf("#");u>=0&&(n=r.slice(0,u),i=r.slice(u+1))}}catch{const d=r.indexOf("#");d>=0&&(n=r.slice(0,d),i=r.slice(d+1))}let s;try{s=decodeURIComponent(n)}catch{return null}const o=vYe(s,i);if(o)return o;if(!Poe(s))return null;const a={path:s},l=i.match(/^L(\d+)(?:C(\d+))?$/i);return l&&(a.line=Number.parseInt(l[1],10),l[2]&&(a.column=Number.parseInt(l[2],10))),a}function dH(e,r){if(!r)return!1;const n=uH(e),i=uH(r);if(!n||!i)return!1;const s=L7.test(n)?n.toLowerCase():n,o=L7.test(i)?i.toLowerCase():i;return s===o||s.startsWith(`${o}/`)}function bYe(e){return e.content.length>0||e.userDisplayText.length>0||e.userDisplaySegments.length>0||e.imageAttachmentCount>0}const _Ye=3;function hH(e,r){return!!(e&&e!=="jait"&&r.length>=_Ye)}const fH=/<pre[^>]*><code>([\s\S]*)<\/code><\/pre>/;function pH(){return c.jsx("span",{className:"inline-flex items-center gap-1",children:[0,1,2].map(e=>c.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current animate-pulse",style:{animationDelay:`${e*160}ms`}},e))})}function wYe(e){const r=e.toLowerCase();return!r||r==="text"||r==="plain"?"txt":r==="shell"||r==="sh"?"bash":r}function SYe({code:e,language:r,className:n}){const[i,s]=y.useState(null);return y.useEffect(()=>{let o=!1;const a=setTimeout(()=>{(async()=>{var f,p;const d=document.documentElement.classList.contains("dark")?"github-dark":"github-light",u=wYe(r);try{const g=await VI(e,{lang:u,theme:d});if(o)return;s(((f=g.match(fH))==null?void 0:f[1])??null)}catch{try{const g=await VI(e,{lang:"txt",theme:d});if(o)return;s(((p=g.match(fH))==null?void 0:p[1])??null)}catch{o||s(null)}}})()},150);return()=>{o=!0,clearTimeout(a)}},[e,r]),i?c.jsx("code",{className:Fe(n,"whitespace-pre"),dangerouslySetInnerHTML:{__html:i}}):c.jsx("code",{className:Fe(n,"whitespace-pre"),children:e})}function $oe(e){return"prose dark:prose-invert max-w-none break-words [overflow-wrap:anywhere] prose-pre:bg-muted prose-pre:border prose-pre:max-w-full prose-pre:overflow-x-auto prose-code:before:content-none prose-code:after:content-none prose-p:leading-relaxed [font-size:0.9rem]"}function kYe(e){const r=e.replace(/\\/g,"/"),n=r.split("/");return n[n.length-1]??r}function CYe({href:e,target:r,onOpenPath:n}){const i=kYe(r.path),s=r.line?`L${r.line}${r.column?`:${r.column}`:""}`:null;return c.jsxs("a",{href:e,className:Fe("not-prose inline-flex max-w-full items-center gap-1.5 rounded-md border border-border/70 bg-muted/45 px-2 py-1 align-middle text-xs font-medium leading-none text-foreground no-underline transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"),title:r.path,onClick:o=>{o.preventDefault(),n(r.path,r.line,r.column)},children:[c.jsx($o,{filename:i,className:"h-3.5 w-3.5 shrink-0"}),c.jsx("span",{className:"max-w-[220px] truncate",children:i}),s?c.jsx("span",{className:"shrink-0 rounded bg-background/80 px-1 py-0.5 text-2xs text-muted-foreground",children:s}):null]})}function Doe(e){return{pre:({children:r})=>c.jsx(c.Fragment,{children:r}),code:({node:r,className:n,children:i,ref:s,...o})=>{var l,d;if(!(((l=r==null?void 0:r.position)==null?void 0:l.start.line)===((d=r==null?void 0:r.position)==null?void 0:d.end.line)&&!n)){const u=typeof n=="string"&&n.replace(/^language-/,"").split(" ")[0]||"text",f=String(i??"").replace(/\n$/,"");return c.jsxs(dTe,{code:f,language:u,children:[c.jsxs(hTe,{children:[c.jsx(fTe,{children:c.jsx(pTe,{children:u})}),c.jsx(mTe,{children:c.jsx(gTe,{})})]}),c.jsx("div",{className:"overflow-x-auto px-3 py-2 text-sm",children:c.jsx(SYe,{code:f,language:u,className:n})})]})}return c.jsx("code",{className:Fe("not-prose inline-flex max-w-full items-baseline rounded-md border border-border/70 bg-muted/45 px-2 py-1 align-middle font-mono text-xs font-medium leading-[1.2] text-foreground","shadow-[inset_0_1px_0_hsl(var(--background)/0.55)]"),...o,children:c.jsx("span",{className:"max-w-[32rem] truncate sm:max-w-[40rem]",children:i})})},a:({href:r,ref:n,...i})=>{if(!e)return c.jsx("a",{href:r,...i,children:i.children});const s=xYe(r);return s?c.jsx(CYe,{href:r,target:s,onOpenPath:e}):c.jsx("a",{href:r,...i,children:i.children})},img:({src:r,alt:n,ref:i,...s})=>{const o=typeof r=="string"?yoe(r):null;return o?c.jsx("a",{href:o,target:"_blank",rel:"noreferrer",className:"not-prose block overflow-hidden rounded-xl border border-border/60 bg-muted/20 no-underline",children:c.jsx("img",{src:o,alt:n??"Chat image",loading:"lazy",className:"max-h-[28rem] w-full object-contain bg-background/80",...s})}):c.jsx("span",{className:"inline-flex rounded-md border border-dashed border-border/70 px-2 py-1 text-xs text-muted-foreground",children:"image unavailable"})}}}function jYe({content:e,compact:r,onOpenPath:n}){const i=y.useMemo(()=>Doe(n),[n]);return c.jsx("div",{className:$oe(),children:c.jsx(zZ,{remarkPlugins:[FZ],components:i,children:e})})}function NYe({content:e,compact:r,onOpenPath:n}){const i=y.useMemo(()=>Doe(n),[n]),s=({blockMatch:a})=>c.jsx(zZ,{remarkPlugins:[FZ],components:i,children:a.output}),{blockMatches:o}=r5e({llmOutput:e,blocks:[],fallbackBlock:{component:s,lookBack:VCe()},isStreamFinished:!1});return c.jsx("div",{className:$oe(),children:o.map((a,l)=>{const d=a.block.component;return c.jsx(d,{blockMatch:a},l)})})}const $7=y.memo(function({content:r,compact:n,isStreaming:i,preferLlmUi:s,onOpenPath:o}){return s&&i?c.jsx(NYe,{content:r,compact:n,onOpenPath:o}):c.jsx(jYe,{content:r,compact:n,onOpenPath:o})});$7.displayName="AssistantMarkdown";function TYe({messageId:e,messageIndex:r,messageFromEnd:n,role:i,content:s,contextFlow:o,displayContent:a,referencedFiles:l,displaySegments:d,attachments:u,thinking:f,thinkingDuration:p,toolCalls:g,segments:v,isStreaming:b,compact:_,preferLlmUi:S,provider:k,onOpenTerminal:C,renderInlineSecretPrompt:j,onEditMessage:E,editComposer:N,onOpenPath:A,onOpenDiff:M}){const B=i==="user",{userDisplayText:P,userDisplaySegments:D}=y.useMemo(()=>{if(!B)return{userDisplayText:s,userDisplaySegments:[]};if(d!=null&&d.length)return{userDisplayText:hv(d),userDisplaySegments:d};if(a){const lt=k5(a,l);return{userDisplayText:a,userDisplaySegments:lt}}const Ne=PJ(s);return{userDisplayText:Ne.text,userDisplaySegments:Ne.displaySegments}},[B,s,a,l,d]),[W,U]=y.useState(!1),[H,R]=y.useState(!1),[I,L]=y.useState(!1),[z,G]=y.useState(!1),[X,F]=y.useState(!1),[V,Q]=y.useState(!1),[q,ee]=y.useState(""),[ne,le]=y.useState([]),[de,te]=y.useState(null),[ie,pe]=y.useState(null),be=y.useMemo(()=>{if(!B)return[];const Ne=Ws(ie??D).flatMap(lt=>lt.type==="image"?[{name:lt.name,mimeType:lt.mimeType,data:lt.data,preview:`data:${lt.mimeType};base64,${lt.data}`}]:[]);return Ne.length>0?Ne:u??[]},[u,B,ie,D]),me=B&&bYe({content:s,userDisplayText:de??P,userDisplaySegments:ie??D,imageAttachmentCount:be.length}),Je=y.useRef(null),ce=y.useRef(null),Ge=y.useRef(null);y.useEffect(()=>()=>{Je.current!==null&&window.clearTimeout(Je.current)},[]),y.useEffect(()=>{I||(ee(P),le(D))},[I,D,P]),y.useEffect(()=>{if(!ie&&de==null)return;const Ne=de===P,lt=ie===D||JSON.stringify(ie??[])===JSON.stringify(D);Ne&&lt&&(te(null),pe(null))},[ie,de,D,P]),y.useEffect(()=>{var lt;if(!I){G(!1);return}const Ne=window.requestAnimationFrame(()=>{G(!0)});return(lt=Ge.current)==null||lt.focus(),()=>window.cancelAnimationFrame(Ne)},[I]);const Xe=()=>{var lt;const Ne=[];if(g&&g.length>0)for(const $e of g){const it=$e.tool.replace(/_/g,"."),Ct=Object.entries($e.args).filter(([,st])=>st!=null&&st!=="").map(([st,gt])=>`${st}: ${typeof gt=="string"?gt:JSON.stringify(gt)}`).join(", "),Ie=$e.status==="success"?"✓":$e.status==="error"?"✗":"…",Ke=$e.completedAt&&$e.startedAt?`${(($e.completedAt-$e.startedAt)/1e3).toFixed(1)}s`:"";if(Ne.push(`[${Ie} ${it}] ${Ct}`),(lt=$e.result)!=null&&lt.message){const st=$e.result.message.length>500?$e.result.message.slice(0,500)+"…":$e.result.message;Ne.push(st)}Ke&&Ne.push(`Duration: ${Ke}`),Ne.push("")}return s&&Ne.push(B?LJ(D)||P:s),Ne.join(`
1160
+ `).replace(/\\t/g," ").replace(/\\"/g,'"').replace(/\\\\/g,"\\"):null}function Noe(e){if(!e)return null;const r=du(e,"url")??du(e,"uri")??du(e,"href")??du(e,"query")??du(e,"q");if(r)return ep(r)??r;const n=du(e,"type"),i=du(e,"action");return n==="webSearch"||i==="webSearch"?"web search":n==="fetch"||i==="fetch"?"website":null}function tYe({tool:e,streamingArgs:r}){const n=Ba(e),i=woe[n],s=n.startsWith("terminal."),o=s?joe(r):null,a=n==="web"||n==="web.search"||n==="web.fetch"||n==="browser.search"||n==="browser.fetch",l=a?Noe(r):null;return i&&s&&o?c.jsxs("span",{className:"inline-flex max-w-full min-w-0 items-center gap-1.5 text-foreground",children:[c.jsx("span",{className:"shrink-0 text-xs text-emerald-500 dark:text-emerald-400 font-mono",children:"$"}),c.jsx("code",{className:"min-w-0 truncate text-xs font-mono",children:o}),c.jsx("span",{className:"inline-block w-1 h-3.5 bg-blue-400 animate-pulse ml-0.5 align-text-bottom"})]}):i&&a&&l?c.jsxs("span",{className:"inline-flex max-w-full min-w-0 items-center gap-1.5 text-foreground",children:[c.jsxs("span",{children:[i.label,":"]}),c.jsx("code",{className:"min-w-0 truncate text-xs font-mono",children:l}),c.jsx("span",{className:"inline-block w-1 h-3.5 bg-blue-400 animate-pulse ml-0.5 align-text-bottom"})]}):i?c.jsxs("span",{className:"text-blue-400",children:[i.label,c.jsx("span",{className:"inline-block w-1 h-3 bg-blue-400 animate-pulse ml-1 align-text-bottom"})]}):e?c.jsxs("span",{className:"text-blue-400",children:[c.jsx("code",{className:"text-xs font-mono",children:e}),c.jsx("span",{className:"inline-block w-1 h-3 bg-blue-400 animate-pulse ml-0.5 align-text-bottom"})]}):c.jsx("span",{className:"text-muted-foreground",children:"Preparing..."})}function rYe({tool:e,streamingArgs:r,scrollRef:n}){const i=Ba(e),s=i.startsWith("terminal."),o=s?joe(r):null,a=i==="web"||i==="web.search"||i==="web.fetch"||i==="browser.search"||i==="browser.fetch",l=a?Noe(r):null;if(s&&o)return c.jsxs("pre",{ref:n,className:Fe("text-xs font-mono leading-5 rounded-md px-3 py-2 overflow-x-auto max-h-64 overflow-y-auto whitespace-pre-wrap break-all","bg-muted/40 text-foreground"),children:[c.jsx("span",{className:"text-emerald-400",children:"$ "}),o,c.jsx("span",{className:"inline-block w-1.5 h-3.5 bg-blue-400 animate-pulse ml-0.5 align-text-bottom"})]});if(a&&l){const d=i==="web.search"||i==="browser.search"?"Searching":"Fetching";return c.jsx("div",{className:Fe("rounded-md border px-3 py-2 text-xs","bg-muted/40 text-foreground"),children:c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(ir,{className:"h-3 w-3 animate-spin text-blue-400"}),c.jsxs("span",{children:[d," ",l,"..."]})]})})}if(i==="memory.save"){const d=du(r,"scope")??"memory",u=du(r,"content");return c.jsxs("div",{className:Fe("rounded-md border px-3 py-2 text-xs","bg-muted/40 text-foreground"),children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(ir,{className:"h-3 w-3 animate-spin text-blue-400"}),c.jsxs("span",{children:["Saving memory (",d,")..."]})]}),u?c.jsxs("div",{className:"mt-1 opacity-80",children:['"',xd(u,120),'"']}):null]})}if(i==="cron.add"){const d=du(r,"name"),u=du(r,"cron"),f=du(r,"toolName");return c.jsxs("div",{className:Fe("rounded-md border px-3 py-2 text-xs","bg-muted/40 text-foreground"),children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(ir,{className:"h-3 w-3 animate-spin text-blue-400"}),c.jsxs("span",{children:["Creating cron job",d?`: ${d}`:"..."]})]}),(u||f)&&c.jsxs("div",{className:"mt-1 opacity-80",children:[u?`schedule ${u}`:"",u&&f?" • ":"",f?`tool ${f}`:""]})]})}return r?c.jsxs("pre",{ref:n,className:Fe("text-xs font-mono leading-5 rounded-md px-3 py-2 overflow-x-auto max-h-36 overflow-y-auto whitespace-pre-wrap break-all","bg-muted/40 text-muted-foreground"),children:[r,c.jsx("span",{className:"inline-block w-1.5 h-3.5 bg-blue-400 animate-pulse ml-0.5 align-text-bottom"})]}):c.jsx("div",{className:Fe("rounded-md border px-3 py-2 text-xs","bg-muted/40 text-foreground"),children:c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(ir,{className:"h-3 w-3 animate-spin text-blue-400"}),c.jsx("span",{children:"Preparing..."})]})})}function Toe(e){const r=new Map,n=new Set,i=new Map(e.map(s=>[s.callId,s]));for(const s of e){if(!s.parentCallId||!i.has(s.parentCallId))continue;const o=r.get(s.parentCallId)??[];r.set(s.parentCallId,[...o,s]),n.add(s.callId)}for(let s=0;s<e.length;s++){const o=e[s];if(Ba(o.tool)!=="agent")continue;const a=[];for(let l=s+1;l<e.length;l++){const d=e[l];if(n.has(d.callId))continue;const u=o.status==="running"||o.status==="pending",f=o.completedAt!=null&&d.startedAt<=o.completedAt;if(u||f)a.push(d),n.add(d.callId);else break}if(a.length>0){const l=r.get(o.callId)??[];r.set(o.callId,[...l,...a])}}return{childMap:r,parentSet:n}}function Eoe(e){return e==="browserScreenshot"}function Aoe(e){var o,a;const r=Ba(e.tool),n=(o=e.result)!=null&&o.data&&typeof e.result.data=="object"?e.result.data:void 0,i=xu(r,e.args,n),s=boe(r,i,n,(a=e.result)==null?void 0:a.message);return Eoe(_oe({tool:r,args:i,status:e.status,displayOutput:Coe(e.result,r)||e.streamingOutput||"",snapshotText:typeof(n==null?void 0:n.snapshot)=="string"?n.snapshot:null,screenshotPath:s}))}function nYe({path:e,onOpenDiff:r,disabled:n}){const i=iP(e),s=!!r&&!n,o=c.jsxs(c.Fragment,{children:[c.jsx($o,{filename:i,className:"h-3.5 w-3.5 shrink-0"}),c.jsx("span",{className:"max-w-[220px] truncate",children:i})]});return s?c.jsx("span",{role:"button",tabIndex:0,className:"inline-flex max-w-full items-center gap-1.5 rounded-md border border-border/70 bg-muted/45 px-2 py-1 text-xs font-medium leading-none text-foreground transition-colors hover:bg-muted cursor-pointer",title:`Open diff for ${e}`,onClick:a=>{a.preventDefault(),a.stopPropagation(),r(e)},onKeyDown:a=>{(a.key==="Enter"||a.key===" ")&&(a.preventDefault(),a.stopPropagation(),r(e))},children:o}):c.jsx("span",{className:"inline-flex max-w-full items-center gap-1.5 rounded-md border border-border/70 bg-muted/45 px-2 py-1 text-xs font-medium leading-none text-foreground",title:e,children:o})}function iYe({call:e,childCalls:r,onOpenTerminal:n,onOpenDiff:i,inlineSecretPrompt:s,renderInlineSecretPrompt:o,hideTopConnector:a=!1,hideBottomConnector:l=!1}){var ce,Ge,Xe,Le,je,Qe,kt,Vt,Re;const d=Aoe(e),[u,f]=y.useState(e.status==="running"||e.status==="pending"||d),[p,g]=y.useState(()=>Date.now()),v=y.useRef(e.status),b=Ba(e.tool),_=(ce=e.result)!=null&&ce.data&&typeof e.result.data=="object"?e.result.data:void 0,S=xu(b,e.args,_),k=b==="mcp-tool"?nP(S,_):null,C=k?LKe(k.title):null,j=Soe(b),E=(C==null?void 0:C.icon)??j.icon,N=(C==null?void 0:C.color)??j.color,A=FKe(b,S,_,(Ge=e.result)==null?void 0:Ge.message),M=A7(b,S),P=Coe(e.result,b)||e.streamingOutput||"",D=typeof(_==null?void 0:_.snapshot)=="string"?_.snapshot:null,W=boe(b,S,_,(Xe=e.result)==null?void 0:Xe.message),U=b.startsWith("terminal.")||b==="execute",H=XKe(e),R=eYe(e),I=R?zC(e):null,L=KKe(b,S),z=s??(o==null?void 0:o(e))??null,G=z!=null,X=e.status==="pending",F=((je=E7(b,S,_,(Le=e.result)==null?void 0:Le.message))==null?void 0:je.trim())??"",V=!!F&&IKe(b),Q=sH(P),q=sH(e.streamingArgs),ee=_oe({tool:b,args:S,status:e.status,displayOutput:P,snapshotText:D,screenshotPath:W}),ne=Eoe(ee),le=ee==="terminal"?!0:ee!=="none"&&!ne,de=e.status==="pending"||e.status==="running"?ir:e.status==="success"?ml:Fh,te=e.status==="pending"?"text-blue-400":e.status==="running"?"text-muted-foreground":e.status==="success"?"text-green-500":"text-red-500";y.useEffect(()=>{const Ze=v.current;!ne&&(Ze==="running"||Ze==="pending")&&e.status!=="running"&&e.status!=="pending"&&f(!1),(e.status==="pending"||e.status==="running"||ne)&&f(!0),v.current=e.status},[e.status,ne]),y.useEffect(()=>{var Ze;b!=="web"&&b!=="web.search"&&b!=="web.fetch"&&b!=="browser.search"&&b!=="browser.fetch"||console.debug("[tool-call-card:web]",{tool:e.tool,normalizedTool:b,callId:e.callId,status:e.status,rawArgs:e.args,normalizedArgs:S,resultMessage:(Ze=e.result)==null?void 0:Ze.message,resultData:_,streamingArgs:e.streamingArgs})},[e.args,e.callId,(Qe=e.result)==null?void 0:Qe.message,e.status,e.streamingArgs,e.tool,S,b,_]),y.useEffect(()=>{if(e.status!=="running"&&e.status!=="pending")return;const Ze=window.setInterval(()=>g(Date.now()),250);return()=>window.clearInterval(Ze)},[e.status]);const ie=PKe(b,S,_,(kt=e.result)==null?void 0:kt.message),be=e.status==="running"||e.status==="pending"?ie.running:ie.done,me=c.jsxs(c.Fragment,{children:[c.jsx(de,{className:Fe("h-4 w-4 shrink-0",te,(e.status==="running"||e.status==="pending")&&"animate-spin")}),c.jsx("span",{className:"flex-1 truncate text-[13px] font-medium text-muted-foreground",children:X?c.jsx(tYe,{tool:e.tool,streamingArgs:e.streamingArgs}):U?c.jsxs("span",{className:"inline-flex max-w-full min-w-0 items-center gap-1.5 text-foreground",children:[c.jsx("span",{className:"shrink-0 text-xs text-emerald-500 dark:text-emerald-400 font-mono",children:"$"}),c.jsx("code",{className:"min-w-0 truncate text-xs font-mono",title:A,children:A})]}):V?c.jsxs("span",{className:"inline-flex min-w-0 max-w-full items-center gap-2",children:[c.jsxs("span",{children:[be,":"]}),c.jsx(nYe,{path:F,onOpenDiff:i,disabled:e.status!=="success"})]}):k&&(k.title||k.details)?c.jsxs("span",{className:"inline-flex min-w-0 max-w-full items-center gap-2",children:[c.jsxs("span",{children:[be,":"]}),c.jsxs("span",{className:"min-w-0 truncate",children:[k.title?c.jsx("code",{className:"text-[11px] font-mono",children:k.title}):null,k.title&&k.details?c.jsx("span",{className:"text-muted-foreground",children:" • "}):null,k.details?c.jsx("span",{className:"text-xs text-muted-foreground",children:k.details}):null]})]}):c.jsxs("span",{children:[be,": ",c.jsx("code",{className:"text-[11px] font-mono",children:A})]})}),c.jsx("span",{className:"text-xs text-muted-foreground/60 tabular-nums shrink-0",children:c.jsx(R7,{startedAt:e.startedAt,completedAt:e.completedAt,now:p})}),M&&c.jsx("span",{className:"rounded border border-blue-500/25 bg-blue-500/10 px-1.5 py-0.5 text-2xs font-semibold tabular-nums text-blue-500 shrink-0",children:M}),H&&c.jsx("span",{className:Fe("rounded border px-1.5 py-0.5 text-2xs font-semibold uppercase tracking-wide shrink-0",H.className),children:H.label})]}),Je=ee==="pending"?c.jsx(rYe,{tool:e.tool,streamingArgs:e.streamingArgs,scrollRef:q}):ee==="terminal"?c.jsxs("pre",{ref:Q,className:Fe("text-xs font-mono leading-5 rounded-md px-3 py-2 overflow-x-auto max-h-64 overflow-y-auto whitespace-pre-wrap break-all","bg-muted/40 text-foreground",e.result&&!e.result.ok&&"text-red-500 dark:text-red-400"),children:[!P&&e.status!=="running"&&c.jsxs("span",{className:"text-muted-foreground",children:[c.jsx("span",{className:"text-emerald-500 dark:text-emerald-400",children:"$ "}),A]}),P,e.status==="running"&&!P&&c.jsx("span",{className:"text-muted-foreground",children:"Running..."}),e.status==="running"&&c.jsx("span",{className:"inline-block w-1.5 h-3.5 bg-foreground animate-pulse ml-0.5 align-text-bottom"})]}):ee==="browserSnapshot"?c.jsx(JKe,{snapshot:D}):ee==="browserScreenshot"?c.jsx(QKe,{path:W}):ee==="subagent"?r&&r.length>0?c.jsxs("div",{className:"rounded-lg border border-purple-500/20 bg-purple-500/[0.03] text-xs",children:[(e.status==="running"||e.status==="pending")&&r.length>0&&c.jsxs("div",{className:"flex items-center justify-end gap-2 border-b border-purple-500/15 px-3 py-2 text-xs text-muted-foreground",children:[c.jsx(ir,{className:"h-3 w-3 animate-spin text-purple-500"}),c.jsxs("span",{children:[r.length," tool",r.length!==1?"s":""]})]}),(e.status==="running"||e.status==="pending")&&r.length===0&&c.jsx("div",{className:"px-3 py-2 text-xs text-muted-foreground",children:"Agent is working..."}),c.jsx("div",{className:"divide-y divide-border/30",children:r.map(Ze=>c.jsx(tp,{call:Ze,onOpenTerminal:n,onOpenDiff:i,renderInlineSecretPrompt:o},Ze.callId))}),((Vt=e.result)==null?void 0:Vt.message)&&(e.status==="success"||e.status==="error")&&c.jsxs("div",{className:"border-t border-purple-500/15 px-3 py-2",children:[c.jsx("div",{className:"mb-1 text-xs font-medium text-muted-foreground",children:"Result"}),c.jsx("pre",{className:"max-h-48 overflow-auto whitespace-pre-wrap rounded bg-background/60 p-2 font-mono text-xs leading-5",children:e.result.message})]})]}):c.jsx(ZKe,{data:_??{},message:(Re=e.result)==null?void 0:Re.message,status:e.status}):ee==="editDiff"?c.jsx(CKe,{filePath:String(S.path??""),oldText:b==="file.patch"||b==="edit"&&S.search!=null?String(S.search??""):void 0,newText:b==="file.patch"||b==="edit"&&S.replace!=null?String(S.replace??""):void 0,writtenContent:b==="file.write"||b==="edit"&&S.content!=null?String(S.content??""):void 0,isNewFile:b==="file.write"}):ee==="output"?c.jsxs("pre",{className:Fe("text-xs font-mono leading-5 rounded-md px-3 py-2 overflow-x-auto max-h-64 overflow-y-auto whitespace-pre-wrap break-all","bg-muted/40 text-foreground",e.result&&!e.result.ok&&"text-red-500 dark:text-red-400"),children:[P,e.status==="running"&&c.jsx("span",{className:"inline-block w-1.5 h-3.5 bg-foreground animate-pulse ml-0.5 align-text-bottom"})]}):ee==="runningHint"?c.jsxs("div",{className:Fe("rounded-md border px-3 py-2 text-xs","bg-muted/40 text-foreground"),children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(ir,{className:"h-3 w-3 animate-spin"}),c.jsx("span",{children:L})]}),c.jsxs("div",{className:"mt-1 text-xs opacity-75",children:["Elapsed: ",c.jsx(R7,{startedAt:e.startedAt,completedAt:e.completedAt,now:p})]})]}):null;return c.jsxs(NS,{open:le?u:!1,onOpenChange:f,children:[c.jsxs("div",{className:"relative pl-7",children:[!a&&c.jsx("span",{className:"absolute left-[10.5px] top-0 h-6 w-px bg-border/60",style:{maskImage:"linear-gradient(to bottom, transparent 0 22px, #000 22px 100%)"},"aria-hidden":"true"}),!l&&c.jsx("span",{className:"absolute left-[10.5px] top-0 bottom-0 w-px bg-border/60",style:{maskImage:"linear-gradient(to bottom, #000 0 5px, transparent 5px 23px, #000 23px 100%)"},"aria-hidden":"true"}),l&&!a&&c.jsx("span",{className:"absolute left-[10.5px] top-0 bottom-0 w-px bg-border/60",style:{maskImage:"linear-gradient(to bottom, #000 0 5px, transparent 5px 100%)"},"aria-hidden":"true"}),c.jsx("div",{className:"absolute left-[5px] top-[9px] z-10 flex h-3 w-3 items-center justify-center",children:c.jsx(E,{className:Fe("h-3 w-3 shrink-0",N)})}),c.jsx("div",{className:"group pb-1",children:c.jsxs("div",{className:"flex items-center gap-2 rounded-sm px-1 py-1.5 transition-colors hover:bg-muted/20",children:[le?c.jsxs(TS,{className:"flex min-w-0 flex-1 items-center gap-2 text-left",children:[c.jsx(ko,{className:Fe("h-3 w-3 shrink-0 text-muted-foreground transition-transform duration-200",u&&"rotate-90")}),me]}):c.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2 text-left",children:[c.jsx("span",{className:"h-3 w-3 shrink-0"}),me]}),R&&n&&c.jsxs(fn,{children:[c.jsx(ln,{asChild:!0,children:c.jsx(_e,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:Ze=>{Ze.preventDefault(),Ze.stopPropagation(),n(I)},children:c.jsx(sp,{className:"h-3.5 w-3.5"})})}),c.jsx(cn,{side:"top",children:"Open terminal"})]}),ee==="editDiff"&&i&&e.status==="success"&&F&&c.jsxs(fn,{children:[c.jsx(ln,{asChild:!0,children:c.jsx(_e,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:Ze=>{Ze.preventDefault(),Ze.stopPropagation(),i(F)},children:c.jsx(sp,{className:"h-3.5 w-3.5"})})}),c.jsx(cn,{side:"top",children:"Open diff in editor"})]})]})})]}),le&&c.jsx(ES,{children:c.jsx("div",{className:"ml-7 mr-3 mb-2 border-l border-border/40 pl-4",children:Je})}),ne&&c.jsx("div",{className:"ml-7 mr-3 mb-2 border-l border-border/40 pl-4",children:Je}),G&&c.jsx("div",{className:"ml-7 mr-3 mb-2 border-l border-border/40 pl-4",children:c.jsx("div",{className:"rounded-lg border border-yellow-500/25 bg-yellow-500/[0.04] p-3",children:z})})]})}const tp=y.memo(iYe);tp.displayName="ToolCallCard";const Ooe=3,Y1=6;function sYe(e,r){if(!r||e.some(Aoe))return!1;const n=e.filter(i=>i.status!=="running"&&i.status!=="pending");return n.length>=Ooe&&n.length===e.length}function oYe({calls:e,collapsible:r,onOpenTerminal:n,onOpenDiff:i,renderInlineSecretPrompt:s}){const[o,a]=y.useState(!1),[l,d]=y.useState(()=>!sYe(e,r)),u=y.useRef(!1),{childMap:f,parentSet:p}=y.useMemo(()=>Toe(e),[e]),g=y.useMemo(()=>e.filter(P=>!p.has(P.callId)),[e,p]),v=g.filter(P=>P.status==="running"||P.status==="pending"),b=g.filter(P=>P.status!=="running"&&P.status!=="pending"),_=v.length===0&&b.length>0,S=r&&_&&b.length>=Ooe;if(y.useEffect(()=>{S&&!u.current&&d(!1),u.current=_},[_,S]),e.length===0)return null;const k=b.filter(P=>P.status==="success").length,C=b.filter(P=>P.status==="error").length,j=koe(b);if(S&&!l)return c.jsx("div",{className:"my-2",children:c.jsxs("button",{type:"button",onClick:()=>d(!0),className:"flex w-full items-center gap-2 rounded-md px-2 py-2 text-xs text-muted-foreground transition-colors hover:bg-muted/35",children:[c.jsx(ko,{className:"h-3.5 w-3.5 shrink-0"}),c.jsx(j,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),c.jsx("span",{className:"font-medium",children:O7(b)}),k>0&&c.jsxs("span",{className:"inline-flex items-center gap-0.5 text-green-500",children:[c.jsx(ml,{className:"h-3 w-3"})," ",k]}),C>0&&c.jsxs("span",{className:"inline-flex items-center gap-0.5 text-red-500",children:[c.jsx(Fh,{className:"h-3 w-3"})," ",C]})]})});const E=!o&&b.length>Y1,N=E?b.length-Y1:0,A=E?b.slice(-Y1):b,M=E?b.slice(0,N).filter(P=>P.status==="success").length:0,B=N-M;return c.jsxs("div",{className:"my-2",children:[S&&c.jsxs("button",{type:"button",onClick:()=>d(!1),className:"mb-1 flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-xs text-muted-foreground transition-colors hover:bg-muted/35",children:[c.jsx(ko,{className:"h-3 w-3 rotate-90 transition-transform"}),c.jsxs("span",{children:["Collapse ",O7(b)]})]}),E&&c.jsxs("button",{type:"button",onClick:()=>a(!0),className:"mb-1 flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-xs text-muted-foreground transition-colors hover:bg-muted/35",children:[c.jsx(ko,{className:"h-3 w-3"}),c.jsxs("span",{children:[N," earlier tool call",N!==1?"s":"",M>0&&c.jsxs("span",{className:"text-green-500 ml-1",children:["(",M," passed)"]}),B>0&&c.jsxs("span",{className:"text-red-500 ml-1",children:["(",B," failed)"]})]})]}),o&&b.slice(0,N).map((P,D,W)=>c.jsx(tp,{call:P,childCalls:f.get(P.callId),onOpenTerminal:n,onOpenDiff:i,renderInlineSecretPrompt:s,hideTopConnector:D===0,hideBottomConnector:D===W.length-1&&A.length===0&&v.length===0},P.callId)),A.map((P,D)=>c.jsx(tp,{call:P,childCalls:f.get(P.callId),onOpenTerminal:n,onOpenDiff:i,renderInlineSecretPrompt:s,hideTopConnector:o?!1:D===0,hideBottomConnector:D===A.length-1&&v.length===0},P.callId)),v.map((P,D)=>c.jsx(tp,{call:P,childCalls:f.get(P.callId),onOpenTerminal:n,onOpenDiff:i,renderInlineSecretPrompt:s,hideTopConnector:b.length===0&&D===0,hideBottomConnector:D===v.length-1},P.callId))]})}function Roe(e,r){if(e===r)return!0;if(e.length!==r.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==r[n])return!1;return!0}const M7=y.memo(oYe,(e,r)=>e.onOpenTerminal===r.onOpenTerminal&&e.onOpenDiff===r.onOpenDiff&&e.renderInlineSecretPrompt===r.renderInlineSecretPrompt&&e.collapsible===r.collapsible&&Roe(e.calls,r.calls));M7.displayName="ToolCallGroup";function aH(e,r){return r?!1:e.length>0&&e.every(n=>n.status!=="running"&&n.status!=="pending")}function aYe({provider:e,calls:r,isStreaming:n,onOpenTerminal:i,onOpenDiff:s,renderInlineSecretPrompt:o}){const[a,l]=y.useState(()=>!aH(r,n)),[d,u]=y.useState(!1),[f,p]=y.useState(()=>Date.now()),g=y.useRef(!aH(r,n)),v=!!n||r.some(H=>H.status==="running"||H.status==="pending"),b=r.filter(H=>H.status==="success").length,_=r.filter(H=>H.status==="error").length,S=r.length>0?Math.min(...r.map(H=>H.startedAt)):Date.now(),k=!v&&r.length>0?Math.max(...r.map(H=>H.completedAt??H.startedAt)):void 0,C=koe(r),{childMap:j,parentSet:E}=y.useMemo(()=>Toe(r),[r]),N=y.useMemo(()=>r.filter(H=>!E.has(H.callId)),[r,E]),A=N.filter(H=>H.status==="running"||H.status==="pending"),M=N.filter(H=>H.status!=="running"&&H.status!=="pending"),B=!d&&M.length>Y1,P=B?M.length-Y1:0,D=B?M.slice(-Y1):M,W=B?M.slice(0,P).filter(H=>H.status==="success").length:0,U=P-W;return y.useEffect(()=>{g.current&&!v&&r.length>0&&l(!1),g.current=v},[v,r.length]),y.useEffect(()=>{if(!v)return;const H=window.setInterval(()=>p(Date.now()),250);return()=>window.clearInterval(H)},[v]),r.length===0?null:c.jsx(NS,{open:a,onOpenChange:l,children:c.jsxs("div",{className:"my-2",children:[c.jsxs(TS,{className:"flex w-full items-center gap-2 rounded-md px-2 py-2 text-left transition-colors hover:bg-muted/35",children:[c.jsx(ko,{className:Fe("h-3.5 w-3.5 shrink-0 text-muted-foreground transition-transform duration-200",a&&"rotate-90")}),v?c.jsx(ir,{className:"h-4 w-4 shrink-0 text-muted-foreground animate-spin"}):c.jsx(C,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),c.jsx("span",{className:"text-sm font-medium text-foreground truncate",children:O7(r)}),c.jsxs("div",{className:"flex items-center gap-2 ml-auto text-xs text-muted-foreground tabular-nums shrink-0",children:[!v&&_>0&&c.jsxs("span",{className:"text-red-500",children:[_," failed"]}),c.jsx(R7,{startedAt:S,completedAt:k,now:f})]}),!v&&_===0&&b>0&&c.jsx(ml,{className:"h-3.5 w-3.5 shrink-0 text-green-500"}),!v&&_>0&&c.jsx(Fh,{className:"h-3.5 w-3.5 shrink-0 text-red-500"})]}),c.jsx(ES,{children:c.jsxs("div",{className:"mt-1",children:[B&&c.jsxs("button",{type:"button",onClick:()=>u(!0),className:"mb-1 flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-xs text-muted-foreground transition-colors hover:bg-muted/35",children:[c.jsx(ko,{className:"h-3 w-3"}),c.jsxs("span",{children:[P," earlier tool call",P!==1?"s":"",W>0&&c.jsxs("span",{className:"text-green-500 ml-1",children:["(",W," passed)"]}),U>0&&c.jsxs("span",{className:"text-red-500 ml-1",children:["(",U," failed)"]})]})]}),d&&M.slice(0,P).map((H,R,I)=>c.jsx(tp,{call:H,childCalls:j.get(H.callId),onOpenTerminal:i,onOpenDiff:s,renderInlineSecretPrompt:o,hideTopConnector:R===0,hideBottomConnector:R===I.length-1&&D.length===0&&A.length===0},H.callId)),D.map((H,R)=>c.jsx(tp,{call:H,childCalls:j.get(H.callId),onOpenTerminal:i,onOpenDiff:s,renderInlineSecretPrompt:o,hideTopConnector:d?!1:R===0,hideBottomConnector:R===D.length-1&&A.length===0},H.callId)),A.map((H,R)=>c.jsx(tp,{call:H,childCalls:j.get(H.callId),onOpenTerminal:i,onOpenDiff:s,renderInlineSecretPrompt:o,hideTopConnector:M.length===0&&R===0,hideBottomConnector:R===A.length-1},H.callId))]})})]})})}const P7=y.memo(aYe,(e,r)=>e.provider===r.provider&&e.isStreaming===r.isStreaming&&e.onOpenTerminal===r.onOpenTerminal&&e.onOpenDiff===r.onOpenDiff&&e.renderInlineSecretPrompt===r.renderInlineSecretPrompt&&Roe(e.calls,r.calls));P7.displayName="AgentToolCallWrapper";function lH(e){switch(e){case"system":return"border-red-500/35 bg-red-500/10 text-red-700 dark:text-red-300";case"user":return"border-blue-500/35 bg-blue-500/10 text-blue-700 dark:text-blue-300";case"assistant":return"border-emerald-500/35 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300";case"tool":return"border-amber-500/35 bg-amber-500/10 text-amber-700 dark:text-amber-300";default:return"border-border bg-muted text-muted-foreground"}}function rp(e){if(e==null)return"";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean")return String(e);try{return JSON.stringify(e,null,2)}catch{return String(e)}}function lYe(e){return"content"in e?rp(e.content):rp(e)}function cYe(e){return(Array.isArray(e.tool_calls)?e.tool_calls:Array.isArray(e.toolCalls)?e.toolCalls:[]).map((n,i)=>{const s=n&&typeof n=="object"?n:{},o=s.function&&typeof s.function=="object"?s.function:{};return{id:rp(s.id||s.call_id||s.tool_call_id||`tool-call-${i+1}`),name:rp(o.name||s.name||s.tool||"tool"),args:rp(o.arguments||s.arguments||s.args||{})}})}function uYe(e,r){const n=e&&typeof e=="object"?e:{},i=n.function&&typeof n.function=="object"?n.function:{};return{name:rp(i.name||n.name||`tool_${r+1}`),description:typeof i.description=="string"?i.description:typeof n.description=="string"?n.description:void 0,raw:e}}function Moe(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}function Nm(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function cH({badge:e,meta:r,preview:n,children:i,tone:s="default",defaultOpen:o=!1,onOpenChange:a}){const[l,d]=y.useState(o);return c.jsx(NS,{open:l,onOpenChange:u=>{d(u),a==null||a()},children:c.jsxs("div",{className:Fe("rounded-md border p-3",s==="assistant"?"border-emerald-500/25 bg-emerald-500/10":"border-border/80 bg-background"),children:[c.jsxs("div",{className:"flex items-start gap-2",children:[c.jsxs(TS,{className:"mt-0.5 rounded-sm p-0.5 text-muted-foreground transition-colors hover:bg-background/70 hover:text-foreground",children:[c.jsx(ko,{className:Fe("h-4 w-4 transition-transform",l&&"rotate-90")}),c.jsx("span",{className:"sr-only",children:l?"Collapse section":"Expand section"})]}),c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[e,r]}),n?c.jsx("div",{className:"mt-1 text-xs text-muted-foreground/70",children:n}):null]})]}),c.jsx(ES,{className:"pl-6",children:c.jsx("div",{className:"pt-3",children:i})})]})})}function dYe({flow:e}){const r=e.rounds;if(!r.some(p=>p.metrics))return null;let i=0,s=0,o=0,a=0,l,d=0,u=0;for(const p of r){const g=p.metrics;g&&(i+=g.durationMs,g.promptTokens&&(s+=g.promptTokens),g.completionTokens&&(o+=g.completionTokens),g.totalTokens&&(a+=g.totalTokens),g.tokensPerSecond&&g.completionTokens&&(d+=g.tokensPerSecond*g.completionTokens,u+=g.completionTokens),g.contextUsage&&(l=g.contextUsage))}const f=u>0?Math.round(d/u*10)/10:void 0;return c.jsxs("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-4",children:[c.jsxs("div",{className:"rounded-md border border-border bg-muted/30 px-2.5 py-2",children:[c.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[c.jsx(sg,{className:"h-3 w-3"}),"Total Duration"]}),c.jsx("div",{className:"mt-0.5 text-sm font-semibold text-foreground",children:Moe(i)}),c.jsxs("div",{className:"text-xs text-muted-foreground",children:[r.length," round",r.length!==1?"s":""]})]}),c.jsxs("div",{className:"rounded-md border border-border bg-muted/30 px-2.5 py-2",children:[c.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[c.jsx(P8,{className:"h-3 w-3"}),"Tokens"]}),c.jsx("div",{className:"mt-0.5 text-sm font-semibold text-foreground",children:a>0?Nm(a):s+o>0?Nm(s+o):"—"}),c.jsxs("div",{className:"text-xs text-muted-foreground",children:[s>0?`${Nm(s)} in`:"",s>0&&o>0?" · ":"",o>0?`${Nm(o)} out`:"",s===0&&o===0?"estimated":""]})]}),c.jsxs("div",{className:"rounded-md border border-border bg-muted/30 px-2.5 py-2",children:[c.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[c.jsx(vK,{className:"h-3 w-3"}),"Speed"]}),c.jsx("div",{className:"mt-0.5 text-sm font-semibold text-foreground",children:f?`${f} tok/s`:"—"}),c.jsx("div",{className:"text-xs text-muted-foreground",children:"completion tokens/sec"})]}),c.jsxs("div",{className:"rounded-md border border-border bg-muted/30 px-2.5 py-2",children:[c.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[c.jsx(zge,{className:"h-3 w-3"}),"Context Window"]}),l?c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"mt-0.5 text-sm font-semibold text-foreground",children:[Math.round(l.ratio*100),"%"]}),c.jsxs("div",{className:"text-xs text-muted-foreground",children:[Nm(l.total)," / ",Nm(l.limit)," tokens",l.pruned?" (pruned)":""]})]}):c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"mt-0.5 text-sm font-semibold text-foreground",children:"—"}),c.jsx("div",{className:"text-xs text-muted-foreground",children:"no data"})]})]})]})}function hYe({metrics:e}){return e?c.jsxs("div",{className:"mt-2 flex flex-wrap gap-x-3 gap-y-1 text-xs text-muted-foreground",children:[c.jsx("span",{title:"LLM request duration",children:Moe(e.durationMs)}),e.promptTokens!=null&&c.jsxs("span",{title:"Prompt tokens",children:[Nm(e.promptTokens)," prompt"]}),e.completionTokens!=null&&c.jsxs("span",{title:"Completion tokens",children:[Nm(e.completionTokens)," completion"]}),e.tokensPerSecond!=null&&c.jsxs("span",{title:"Completion tokens per second",className:"font-medium text-foreground/80",children:[e.tokensPerSecond," tok/s"]}),e.contextUsage&&c.jsxs("span",{title:"Context window utilisation",children:["ctx ",Math.round(e.contextUsage.ratio*100),"%",e.contextUsage.pruned?" (pruned)":""]})]}):null}function fYe(e,r){const n=[];if(!e)return r?[{id:"assistant-response",kind:"response",content:r}]:n;e.rounds.some(i=>i.metrics)&&n.push({id:"summary",kind:"summary",flow:e});for(const i of e.rounds){const s=Array.isArray(i.messages)?i.messages:[],o=Array.isArray(i.tools)?i.tools.map(uYe):[];n.push({id:`round-${i.round}`,kind:"round",round:i,messageCount:s.length,toolCount:o.length}),s.forEach((a,l)=>{const d=a&&typeof a=="object"?a:{content:a};n.push({id:`round-${i.round}-message-${l}`,kind:"message",roundNumber:i.round,index:l,role:rp(d.role||"message"),content:lYe(d),raw:a,toolCalls:cYe(d)})}),o.length>0&&n.push({id:`round-${i.round}-tools`,kind:"tools",roundNumber:i.round,tools:o})}return r&&n.push({id:"assistant-response",kind:"response",content:r}),n}function pYe({row:e,onExpandChange:r}){if(e.kind==="summary")return c.jsx(dYe,{flow:e.flow});if(e.kind==="round")return c.jsxs("div",{className:"min-w-0 overflow-hidden rounded-md border border-border bg-background px-3 py-2",children:[c.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-2",children:[c.jsxs("span",{className:"rounded-md bg-foreground px-2 py-1 text-xs font-semibold text-background",children:["Round ",e.round.round]}),c.jsx("span",{className:"min-w-0 break-words text-xs text-muted-foreground",children:e.round.model}),c.jsx("span",{className:"min-w-0 break-words text-xs text-muted-foreground",children:new Date(e.round.createdAt).toLocaleString()})]}),c.jsxs("div",{className:"mt-2 flex min-w-0 flex-wrap gap-2 text-xs text-muted-foreground",children:[c.jsxs("span",{children:[e.messageCount," messages sent"]}),c.jsxs("span",{children:[e.toolCount," tool schemas available"]}),e.round.tool_choice?c.jsxs("span",{className:"min-w-0 break-words",children:["tool_choice: ",e.round.tool_choice]}):null]}),c.jsx(hYe,{metrics:e.round.metrics})]});if(e.kind==="tools")return c.jsxs("div",{className:"relative ml-2 sm:ml-4 border-l border-border pl-2 sm:pl-4",children:[c.jsx("div",{className:"absolute -left-1.5 top-3 h-3 w-3 rounded-full border border-border bg-background"}),c.jsxs("div",{className:"rounded-md border border-border/80 bg-muted/25 p-3",children:[c.jsxs("div",{className:"mb-2 flex items-center gap-2 text-xs font-medium text-foreground",children:[c.jsx(P9,{className:"h-3.5 w-3.5"}),"Tools offered to model in round ",e.roundNumber]}),c.jsx("div",{className:"grid gap-2 sm:grid-cols-2",children:e.tools.map(i=>c.jsxs("details",{className:"rounded-md border border-border/70 bg-background/70 p-2",children:[c.jsx("summary",{className:"cursor-pointer text-xs font-medium text-foreground",children:i.name}),i.description?c.jsx("p",{className:"mt-1 text-xs leading-relaxed text-muted-foreground",children:i.description}):null,c.jsx("pre",{className:"mt-2 max-h-40 overflow-auto whitespace-pre-wrap break-words rounded bg-muted/40 p-2 font-mono text-xs leading-5",children:rp(i.raw)})]},i.name))})]})]});if(e.kind==="response")return c.jsxs("div",{className:"relative ml-2 sm:ml-4 border-l border-border pl-2 sm:pl-4",children:[c.jsx("div",{className:"absolute -left-1.5 top-3 h-3 w-3 rounded-full border border-emerald-500/40 bg-background"}),c.jsx(cH,{tone:"assistant",defaultOpen:!1,onOpenChange:r,badge:c.jsx("span",{className:Fe("rounded-md border px-2 py-0.5 text-xs font-semibold",lH("assistant")),children:"assistant response"}),meta:c.jsx("span",{className:"text-xs text-muted-foreground",children:"rendered chat answer"}),preview:c.jsx("span",{className:"block truncate",children:e.content||"(empty response)"}),children:c.jsx("pre",{className:"max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-md bg-background/70 p-3 font-mono text-xs leading-5 text-foreground [overflow-wrap:anywhere]",children:e.content||"(empty response)"})})]});const n=e.content?e.content.length>80?e.content.slice(0,80)+"...":e.content:"(empty content)";return c.jsxs("div",{className:"relative ml-2 sm:ml-4 border-l border-border pl-2 sm:pl-4",children:[c.jsx("div",{className:"absolute -left-1.5 top-3 h-3 w-3 rounded-full border border-border bg-background"}),c.jsxs(cH,{defaultOpen:!1,onOpenChange:r,badge:c.jsx("span",{className:Fe("rounded-md border px-2 py-0.5 text-xs font-semibold",lH(e.role)),children:e.role}),meta:c.jsxs(c.Fragment,{children:[c.jsxs("span",{className:"text-xs text-muted-foreground",children:["round ",e.roundNumber," / message ",e.index+1]}),e.toolCalls.length>0?c.jsxs("span",{className:"text-xs text-amber-600 dark:text-amber-400",children:[e.toolCalls.length," tool call",e.toolCalls.length!==1?"s":""]}):null]}),preview:c.jsx("span",{className:"block truncate",children:n}),children:[c.jsx("pre",{className:"max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-md bg-muted/35 p-3 font-mono text-xs leading-5 text-foreground [overflow-wrap:anywhere]",children:e.content||"(empty content)"}),e.toolCalls.length>0?c.jsx("div",{className:"mt-3 space-y-2",children:e.toolCalls.map(i=>c.jsxs("details",{className:"rounded-md border border-amber-500/25 bg-amber-500/10 p-2",children:[c.jsxs("summary",{className:"cursor-pointer text-xs font-medium text-amber-800 dark:text-amber-200",children:["Tool call: ",i.name," ",c.jsxs("span",{className:"font-normal text-muted-foreground",children:["(",i.id,")"]})]}),c.jsx("pre",{className:"mt-2 max-h-48 overflow-auto whitespace-pre-wrap break-words rounded bg-background/70 p-2 font-mono text-xs leading-5",children:i.args||"{}"})]},i.id))}):null,c.jsxs("details",{className:"mt-2",children:[c.jsx("summary",{className:"cursor-pointer text-xs text-muted-foreground",children:"Raw message JSON"}),c.jsx("pre",{className:"mt-2 max-h-48 overflow-auto whitespace-pre-wrap break-words rounded bg-muted/35 p-2 font-mono text-xs leading-5",children:rp(e.raw)})]})]})]})}function mYe({open:e,onOpenChange:r,contextFlow:n,responseContent:i}){const[s,o]=y.useState("trace"),[a,l]=y.useState(!1),d=y.useRef(null),u=y.useMemo(()=>fYe(n,i),[n,i]),f=y.useMemo(()=>n?JSON.stringify(n,null,2):"",[n]),p=rR({count:u.length,getScrollElement:()=>d.current,estimateSize:b=>{const _=u[b];return _?_.kind==="summary"?110:_.kind==="round"?120:_.kind==="tools"?Math.min(420,110+_.tools.length*72):_.kind==="response"?72:52:120},overscan:5,enabled:e&&s==="trace"});y.useEffect(()=>{if(!e||s!=="trace")return;const b=window.requestAnimationFrame(()=>{p.measure()});return()=>window.cancelAnimationFrame(b)},[e,s,u.length,p]);const g=async()=>{f&&(await navigator.clipboard.writeText(f),l(!0),window.setTimeout(()=>l(!1),1200))},v=()=>{window.requestAnimationFrame(()=>{p.measure()})};return c.jsx(Bd,{open:e,onOpenChange:r,children:c.jsxs(Eu,{showCloseButton:!1,className:"grid h-[95vh] w-[calc(100dvw-1rem)] max-w-[1200px] grid-rows-[auto_minmax(0,1fr)] overflow-hidden p-0 sm:h-[85vh] sm:w-[96vw]",children:[c.jsx(Md,{className:"border-b px-3 py-2",children:c.jsxs("div",{className:"grid min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-2",children:[c.jsxs("div",{className:"min-w-0",children:[c.jsx(Cu,{className:"truncate text-sm font-semibold",children:"LLM Context Flow"}),c.jsx(Vm,{className:"truncate text-xs",children:n?`${n.provider}${n.model?` / ${n.model}`:""} · ${n.rounds.length} round${n.rounds.length===1?"":"s"}`:"No context snapshot available"})]}),c.jsxs("div",{className:"-my-1 flex shrink-0 items-center gap-1 p-1",children:[c.jsx(_e,{type:"button",variant:s==="trace"?"default":"outline",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>o("trace"),children:"Trace"}),c.jsx(_e,{type:"button",variant:s==="raw"?"default":"outline",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>o("raw"),children:"Raw"}),c.jsxs(_e,{type:"button",variant:"outline",size:"sm",className:"h-7 px-2 text-xs",onClick:g,disabled:!f,children:[a?c.jsx(_s,{className:"h-3 w-3 sm:mr-1"}):c.jsx(Nc,{className:"h-3 w-3 sm:mr-1"}),c.jsx("span",{className:"hidden sm:inline",children:a?"Copied":"Copy"}),c.jsx("span",{className:"sr-only",children:a?"Copied":"Copy raw trace"})]}),c.jsxs(eK,{className:"ml-1 rounded-sm p-1 opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",children:[c.jsx(ti,{className:"h-4 w-4"}),c.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}),s==="trace"?c.jsxs("div",{className:"min-h-0 px-3 pb-3 pt-2",children:[n!=null&&n.note?c.jsx("p",{className:"mb-2 rounded-md border border-border/70 bg-muted/40 px-2.5 py-1.5 text-xs text-muted-foreground",children:n.note}):null,u.length>0?c.jsx("div",{ref:d,className:"h-full min-h-0 overflow-auto pr-2",children:c.jsx("div",{className:"relative w-full",style:{height:`${p.getTotalSize()}px`},children:p.getVirtualItems().map(b=>{const _=u[b.index];return _?c.jsx("div",{"data-index":b.index,ref:p.measureElement,className:"absolute left-0 top-0 w-full pb-3",style:{transform:`translateY(${b.start}px)`},children:c.jsx(pYe,{row:_,onExpandChange:v})},_.id):null})})}):c.jsxs("div",{className:"flex h-full items-center justify-center rounded-md border border-dashed border-border text-sm text-muted-foreground",children:[c.jsx(Rm,{className:"mr-2 h-4 w-4"}),"No context snapshot is available for this message."]})]}):c.jsx("div",{className:"min-h-0 overflow-auto px-3 pb-3 pt-2",children:c.jsx("pre",{className:"min-h-full whitespace-pre-wrap break-words rounded-md border border-border/70 bg-muted/35 p-3 font-mono text-xs leading-relaxed text-foreground [overflow-wrap:anywhere]",children:f||"No context snapshot is available for this message."})})]})})}const L7=/^[A-Za-z]:[\\/]/,gYe=/^\//;function uH(e){return e.replace(/\\/g,"/").replace(/\/+$/,"")}function yYe(e){const r=e.pathname||"/",n=/^\/[A-Za-z]:\//.test(r)?r.slice(1):r;return!e.hostname||e.hostname==="localhost"?n:`//${e.hostname}${n}`}function Poe(e){return L7.test(e)||gYe.test(e)}function Loe(e,r){const n=e.replace(/\\/g,"/");if(!n||n==="/")return!1;if(/^L\d+(?:C\d+)?$/i.test(r))return!0;const i=n.split("/").pop()??"";return/\.[A-Za-z0-9]+(?::\d+(?::\d+)?)?$/.test(i)}function vYe(e,r){if(r)return null;const n=e.replace(/\\/g,"/"),i=n.lastIndexOf("/"),o=(i>=0?n.slice(i+1):n).match(/^(.*?):(\d+)(?::(\d+))?$/);if(!o)return null;const a=i>=0?`${e.slice(0,i+1)}${o[1]??""}`:o[1]??"";if(!Poe(a)||!Loe(a,`L${o[2]}`))return null;const l={path:a,line:Number.parseInt(o[2],10)};return o[3]&&(l.column=Number.parseInt(o[3],10)),l}function xYe(e){if(!e)return null;const r=e.trim();if(!r)return null;let n=r,i="";try{const d=new URL(r);if(d.protocol==="http:"||d.protocol==="https:"){if(n=d.pathname,i=d.hash.startsWith("#")?d.hash.slice(1):d.hash,!Loe(n,i))return null}else if(d.protocol==="file:")n=yYe(d),i=d.hash.startsWith("#")?d.hash.slice(1):d.hash;else{const u=r.indexOf("#");u>=0&&(n=r.slice(0,u),i=r.slice(u+1))}}catch{const d=r.indexOf("#");d>=0&&(n=r.slice(0,d),i=r.slice(d+1))}let s;try{s=decodeURIComponent(n)}catch{return null}const o=vYe(s,i);if(o)return o;if(!Poe(s))return null;const a={path:s},l=i.match(/^L(\d+)(?:C(\d+))?$/i);return l&&(a.line=Number.parseInt(l[1],10),l[2]&&(a.column=Number.parseInt(l[2],10))),a}function dH(e,r){if(!r)return!1;const n=uH(e),i=uH(r);if(!n||!i)return!1;const s=L7.test(n)?n.toLowerCase():n,o=L7.test(i)?i.toLowerCase():i;return s===o||s.startsWith(`${o}/`)}function bYe(e){return e.content.length>0||e.userDisplayText.length>0||e.userDisplaySegments.length>0||e.imageAttachmentCount>0}const _Ye=3;function hH(e,r){return!!(e&&e!=="jait"&&r.length>=_Ye)}const fH=/<pre[^>]*><code>([\s\S]*)<\/code><\/pre>/;function pH(){return c.jsx("span",{className:"inline-flex items-center gap-1",children:[0,1,2].map(e=>c.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-current animate-pulse",style:{animationDelay:`${e*160}ms`}},e))})}function wYe(e){const r=e.toLowerCase();return!r||r==="text"||r==="plain"?"txt":r==="shell"||r==="sh"?"bash":r}function SYe({code:e,language:r,className:n}){const[i,s]=y.useState(null);return y.useEffect(()=>{let o=!1;const a=setTimeout(()=>{(async()=>{var f,p;const d=document.documentElement.classList.contains("dark")?"github-dark":"github-light",u=wYe(r);try{const g=await VI(e,{lang:u,theme:d});if(o)return;s(((f=g.match(fH))==null?void 0:f[1])??null)}catch{try{const g=await VI(e,{lang:"txt",theme:d});if(o)return;s(((p=g.match(fH))==null?void 0:p[1])??null)}catch{o||s(null)}}})()},150);return()=>{o=!0,clearTimeout(a)}},[e,r]),i?c.jsx("code",{className:Fe(n,"whitespace-pre"),dangerouslySetInnerHTML:{__html:i}}):c.jsx("code",{className:Fe(n,"whitespace-pre"),children:e})}function $oe(e){return"prose dark:prose-invert max-w-none break-words [overflow-wrap:anywhere] prose-pre:bg-muted prose-pre:border prose-pre:max-w-full prose-pre:overflow-x-auto prose-code:before:content-none prose-code:after:content-none prose-p:leading-relaxed [font-size:0.9rem]"}function kYe(e){const r=e.replace(/\\/g,"/"),n=r.split("/");return n[n.length-1]??r}function CYe({href:e,target:r,onOpenPath:n}){const i=kYe(r.path),s=r.line?`L${r.line}${r.column?`:${r.column}`:""}`:null;return c.jsxs("a",{href:e,className:Fe("not-prose inline-flex max-w-full items-center gap-1.5 rounded-md border border-border/70 bg-muted/45 px-2 py-1 align-middle text-xs font-medium leading-none text-foreground no-underline transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"),title:r.path,onClick:o=>{o.preventDefault(),n(r.path,r.line,r.column)},children:[c.jsx($o,{filename:i,className:"h-3.5 w-3.5 shrink-0"}),c.jsx("span",{className:"max-w-[220px] truncate",children:i}),s?c.jsx("span",{className:"shrink-0 rounded bg-background/80 px-1 py-0.5 text-2xs text-muted-foreground",children:s}):null]})}function Doe(e){return{pre:({children:r})=>c.jsx(c.Fragment,{children:r}),code:({node:r,className:n,children:i,ref:s,...o})=>{var l,d;if(!(((l=r==null?void 0:r.position)==null?void 0:l.start.line)===((d=r==null?void 0:r.position)==null?void 0:d.end.line)&&!n)){const u=typeof n=="string"&&n.replace(/^language-/,"").split(" ")[0]||"text",f=String(i??"").replace(/\n$/,"");return c.jsxs(dTe,{code:f,language:u,children:[c.jsxs(hTe,{children:[c.jsx(fTe,{children:c.jsx(pTe,{children:u})}),c.jsx(mTe,{children:c.jsx(gTe,{})})]}),c.jsx("div",{className:"overflow-x-auto px-3 py-2 text-sm",children:c.jsx(SYe,{code:f,language:u,className:n})})]})}return c.jsx("code",{className:Fe("not-prose inline-flex max-w-full items-baseline rounded-md border border-border/70 bg-muted/45 px-2 py-1 align-middle font-mono text-xs font-medium leading-[1.2] text-foreground","shadow-[inset_0_1px_0_hsl(var(--background)/0.55)]"),...o,children:c.jsx("span",{className:"max-w-[32rem] truncate sm:max-w-[40rem]",children:i})})},a:({href:r,ref:n,...i})=>{if(!e)return c.jsx("a",{href:r,...i,children:i.children});const s=xYe(r);return s?c.jsx(CYe,{href:r,target:s,onOpenPath:e}):c.jsx("a",{href:r,...i,children:i.children})},img:({src:r,alt:n,ref:i,...s})=>{const o=typeof r=="string"?yoe(r):null;return o?c.jsx("a",{href:o,target:"_blank",rel:"noreferrer",className:"not-prose block overflow-hidden rounded-xl border border-border/60 bg-muted/20 no-underline",children:c.jsx("img",{src:o,alt:n??"Chat image",loading:"lazy",className:"max-h-[28rem] w-full object-contain bg-background/80",...s})}):c.jsx("span",{className:"inline-flex rounded-md border border-dashed border-border/70 px-2 py-1 text-xs text-muted-foreground",children:"image unavailable"})}}}function jYe({content:e,compact:r,onOpenPath:n}){const i=y.useMemo(()=>Doe(n),[n]);return c.jsx("div",{className:$oe(),children:c.jsx(zZ,{remarkPlugins:[FZ],components:i,children:e})})}function NYe({content:e,compact:r,onOpenPath:n}){const i=y.useMemo(()=>Doe(n),[n]),s=({blockMatch:a})=>c.jsx(zZ,{remarkPlugins:[FZ],components:i,children:a.output}),{blockMatches:o}=r5e({llmOutput:e,blocks:[],fallbackBlock:{component:s,lookBack:VCe()},isStreamFinished:!1});return c.jsx("div",{className:$oe(),children:o.map((a,l)=>{const d=a.block.component;return c.jsx(d,{blockMatch:a},l)})})}const $7=y.memo(function({content:r,compact:n,isStreaming:i,preferLlmUi:s,onOpenPath:o}){return s&&i?c.jsx(NYe,{content:r,compact:n,onOpenPath:o}):c.jsx(jYe,{content:r,compact:n,onOpenPath:o})});$7.displayName="AssistantMarkdown";function TYe({messageId:e,messageIndex:r,messageFromEnd:n,role:i,content:s,contextFlow:o,displayContent:a,referencedFiles:l,displaySegments:d,attachments:u,thinking:f,thinkingDuration:p,toolCalls:g,segments:v,isStreaming:b,compact:_,preferLlmUi:S,provider:k,onOpenTerminal:C,renderInlineSecretPrompt:j,onEditMessage:E,editComposer:N,onOpenPath:A,onOpenDiff:M}){const B=i==="user",{userDisplayText:P,userDisplaySegments:D}=y.useMemo(()=>{if(!B)return{userDisplayText:s,userDisplaySegments:[]};if(d!=null&&d.length)return{userDisplayText:hv(d),userDisplaySegments:d};if(a){const lt=k5(a,l);return{userDisplayText:a,userDisplaySegments:lt}}const Ne=PJ(s);return{userDisplayText:Ne.text,userDisplaySegments:Ne.displaySegments}},[B,s,a,l,d]),[W,U]=y.useState(!1),[H,R]=y.useState(!1),[I,L]=y.useState(!1),[z,G]=y.useState(!1),[X,F]=y.useState(!1),[V,Q]=y.useState(!1),[q,ee]=y.useState(""),[ne,le]=y.useState([]),[de,te]=y.useState(null),[ie,pe]=y.useState(null),be=y.useMemo(()=>{if(!B)return[];const Ne=Ws(ie??D).flatMap(lt=>lt.type==="image"?[{name:lt.name,mimeType:lt.mimeType,data:lt.data,preview:`data:${lt.mimeType};base64,${lt.data}`}]:[]);return Ne.length>0?Ne:u??[]},[u,B,ie,D]),me=B&&bYe({content:s,userDisplayText:de??P,userDisplaySegments:ie??D,imageAttachmentCount:be.length}),Je=y.useRef(null),ce=y.useRef(null),Ge=y.useRef(null);y.useEffect(()=>()=>{Je.current!==null&&window.clearTimeout(Je.current)},[]),y.useEffect(()=>{I||(ee(P),le(D))},[I,D,P]),y.useEffect(()=>{if(!ie&&de==null)return;const Ne=de===P,lt=ie===D||JSON.stringify(ie??[])===JSON.stringify(D);Ne&&lt&&(te(null),pe(null))},[ie,de,D,P]),y.useEffect(()=>{var lt;if(!I){G(!1);return}const Ne=window.requestAnimationFrame(()=>{G(!0)});return(lt=Ge.current)==null||lt.focus(),()=>window.cancelAnimationFrame(Ne)},[I]);const Xe=()=>{var lt;const Ne=[];if(g&&g.length>0)for(const $e of g){const it=$e.tool.replace(/_/g,"."),Ct=Object.entries($e.args).filter(([,st])=>st!=null&&st!=="").map(([st,gt])=>`${st}: ${typeof gt=="string"?gt:JSON.stringify(gt)}`).join(", "),Ie=$e.status==="success"?"✓":$e.status==="error"?"✗":"…",Ke=$e.completedAt&&$e.startedAt?`${(($e.completedAt-$e.startedAt)/1e3).toFixed(1)}s`:"";if(Ne.push(`[${Ie} ${it}] ${Ct}`),(lt=$e.result)!=null&&lt.message){const st=$e.result.message.length>500?$e.result.message.slice(0,500)+"…":$e.result.message;Ne.push(st)}Ke&&Ne.push(`Duration: ${Ke}`),Ne.push("")}return s&&Ne.push(B?LJ(D)||P:s),Ne.join(`
1161
1161
  `).trim()},Le=async()=>{const Ne=Xe();if(!Ne)return;const lt=B?$J(D):null;try{lt&&typeof ClipboardItem<"u"&&navigator.clipboard.write?await navigator.clipboard.write([new ClipboardItem({"text/plain":new Blob([Ne],{type:"text/plain"}),[S5]:new Blob([lt],{type:S5})})]):await navigator.clipboard.writeText(Ne)}catch{const $e=document.createElement("textarea");$e.value=Ne,$e.style.position="fixed",$e.style.opacity="0",document.body.appendChild($e),$e.focus(),$e.select(),document.execCommand("copy"),document.body.removeChild($e)}U(!0),Je.current!==null&&window.clearTimeout(Je.current),Je.current=window.setTimeout(()=>U(!1),1200)},je=B&&!!e&&!!E,Qe=je,kt=b&&!f&&!(typeof s=="string"?s:"").trim(),Vt=B||!b,Re=y.useCallback(()=>{!je||X||(ee(P),le(D),L(!0))},[je,X,D,P]),Ze=y.useCallback(()=>{ee(P),le(D),L(!1)},[D,P]),ft=()=>{var lt;!je||I||typeof window<"u"&&(lt=window.getSelection())!=null&&lt.toString().trim()||Re()},It=y.useCallback(async(Ne,lt)=>{if(!je||!e||!E||X)return;const $e=UTe(Ne??q,lt??ne);if($e){te($e.text),pe($e.displaySegments),L(!1),F(!0);try{await E(e,$e.text,r,n,{referencedFiles:$e.referencedFiles,displaySegments:$e.displaySegments})}catch(it){throw te(null),pe(null),L(!0),it}finally{F(!1)}}},[je,q,ne,X,e,n,r,E]),Se=async(Ne,lt)=>{if(!je||!e||!E)return;const $e=Ne.trim();$e&&await E(e,$e,r,n,{referencedFiles:(lt??D).filter(it=>it.type==="file").map(it=>({path:it.path,name:it.name})),displaySegments:lt??D})},ke=async()=>{if(Qe){R(!0);try{await Se(P,D)}finally{R(!1)}}},Et=Ne=>I||!Vt||!s?null:c.jsx("div",{className:Fe("absolute z-10 rounded-full border border-border/70 bg-background p-1","right-1 bottom-[.25rem]","opacity-0 transition-opacity group-hover/message:opacity-100 focus-within:opacity-100","touch-device:opacity-80",W&&"opacity-100"),children:c.jsxs(vTe,{children:[je?c.jsx(g3,{onClick:Re,"aria-label":"Edit message",tooltip:"Edit message",className:"h-6 w-6",children:c.jsx(R9,{className:"h-3.5 w-3.5"})}):null,Qe?c.jsx(g3,{onClick:lt=>{lt.preventDefault(),lt.stopPropagation(),ke()},disabled:H,"aria-label":"Retry from this message",tooltip:"Retry from this message",className:"h-6 w-6",children:c.jsx(mK,{className:Fe("h-3.5 w-3.5",H&&"animate-spin")})}):null,!B&&o?c.jsx(g3,{onClick:lt=>{lt.preventDefault(),lt.stopPropagation(),Q(!0)},"aria-label":"View LLM context",tooltip:"View LLM context",className:"h-6 w-6",children:c.jsx(Nh,{className:"h-3.5 w-3.5"})}):null,c.jsx(g3,{onClick:Le,"aria-label":W?"Copied":"Copy message",tooltip:W?"Copied":"Copy message",className:"h-6 w-6",children:W?c.jsx(_s,{className:"h-3.5 w-3.5"}):c.jsx(Nc,{className:"h-3.5 w-3.5"})})]})}),St=B?null:Et();return c.jsxs(c.Fragment,{children:[c.jsx(yTe,{from:i,className:Fe(_?"py-2":"py-4"),children:c.jsxs("div",{className:Fe("min-w-0 max-w-[85%] space-y-2",B&&"order-1"),children:[!B&&f&&c.jsx(ITe,{content:f,isStreaming:!!b&&!s,duration:p}),!B&&v&&v.length>0?c.jsxs("div",{className:"relative min-w-0 max-w-full select-text break-words [overflow-wrap:anywhere]",children:[v.map((Ne,lt)=>{if(Ne.type==="toolGroup"){const $e=(g??[]).filter(Ct=>Ne.callIds.includes(Ct.callId)),it=v.slice(lt+1).some(Ct=>Ct.type==="text"&&typeof Ct.content=="string"&&Ct.content.trim());return $e.length>0?hH(k,$e)?c.jsx(P7,{provider:k,calls:$e,isStreaming:!!b&&lt===v.length-1,onOpenTerminal:C,onOpenDiff:M,renderInlineSecretPrompt:j},`tg-${lt}`):c.jsx(M7,{calls:$e,collapsible:it,onOpenTerminal:C,onOpenDiff:M,renderInlineSecretPrompt:j},`tg-${lt}`):null}return typeof Ne.content=="string"&&Ne.content.trim()?c.jsx(uT,{"data-message-from":"assistant",className:"max-w-full bg-card/78",children:c.jsx($7,{content:Ne.content,compact:_,isStreaming:!!b&&lt===v.length-1,preferLlmUi:S,onOpenPath:A})},`ts-${lt}`):null}),b&&!s&&!v.some(Ne=>Ne.type==="text"&&typeof Ne.content=="string"&&Ne.content.trim())&&c.jsx("div",{className:"flex items-center gap-3 px-1 py-1 text-sm text-muted-foreground",children:c.jsx(pH,{})}),St]}):c.jsxs(c.Fragment,{children:[g&&g.length>0&&(hH(k,g)?c.jsx(P7,{provider:k,calls:g,isStreaming:b,onOpenTerminal:C,onOpenDiff:M,renderInlineSecretPrompt:j}):c.jsx(M7,{calls:g,collapsible:k!=="jait",onOpenTerminal:C,onOpenDiff:M,renderInlineSecretPrompt:j})),me||s?B?I?c.jsx("div",{className:"w-full max-w-3xl",onClick:Ne=>Ne.stopPropagation(),children:c.jsx("div",{className:Fe("space-y-3 origin-bottom transition-all duration-150 ease-out",z?"translate-y-0 opacity-100":"translate-y-2 opacity-0"),children:c.jsx(a_,{ref:Ge,draftStateKey:`edit:${e??"user-message"}`,value:q,segments:ne,onChange:Ne=>{var lt;ee(Ne),le(((lt=Ge.current)==null?void 0:lt.getSegments())??[])},onSubmit:(Ne,lt,$e)=>{const it=$e??[],Ct=hv(it)||q;le(it),It(Ct,it)},disabled:X,controlsDisabled:X,placeholder:"Edit message...",onVoiceInput:N==null?void 0:N.onVoiceInput,voiceRecording:N==null?void 0:N.voiceRecording,voiceLevels:N==null?void 0:N.voiceLevels,voiceTranscribing:N==null?void 0:N.voiceTranscribing,onVoiceStop:N==null?void 0:N.onVoiceStop,mode:N==null?void 0:N.mode,onModeChange:N==null?void 0:N.onModeChange,provider:N==null?void 0:N.provider,onProviderChange:N==null?void 0:N.onProviderChange,responseStyle:N==null?void 0:N.responseStyle,onResponseStyleChange:N==null?void 0:N.onResponseStyleChange,providerRuntimeMode:N==null?void 0:N.providerRuntimeMode,onProviderRuntimeModeChange:N==null?void 0:N.onProviderRuntimeModeChange,cliModel:N==null?void 0:N.cliModel,onCliModelChange:N==null?void 0:N.onCliModelChange,sessionInfo:N==null?void 0:N.sessionInfo,workspaceNodeId:N==null?void 0:N.workspaceNodeId,availableFiles:(N==null?void 0:N.availableFiles)??fv(D),onSearchFiles:N==null?void 0:N.onSearchFiles,workspaceOpen:(N==null?void 0:N.workspaceOpen)??fv(D).length>0,footerTrailingContent:c.jsx(_e,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0 rounded-lg",onClick:Ze,disabled:X,"aria-label":"Cancel editing message",title:"Cancel editing",children:c.jsx(ti,{className:"h-3.5 w-3.5"})}),className:"rounded-lg border-primary/20 bg-primary/[0.08] dark:!bg-primary/[0.08] shadow-none [&_.text-muted-foreground]:text-muted-foreground [&>div]:!bg-transparent [&_[contenteditable='true']]:!bg-transparent"},`edit-${e??"user-message"}`)})}):c.jsxs("div",{className:"relative w-fit max-w-full",children:[c.jsx(uT,{ref:ce,"data-message-from":"user",className:Fe("min-w-0 rounded-lg bg-muted px-4 py-3 break-words [overflow-wrap:anywhere]",je&&!I&&"cursor-text transition-colors hover:bg-muted/80","leading-relaxed [font-size:0.9rem]"),onClick:ft,title:je&&!I?"Click to edit message":void 0,children:c.jsxs("div",{className:"min-w-0 space-y-3",children:[c.jsx("div",{className:"min-w-0 whitespace-pre-wrap break-words [overflow-wrap:anywhere]",children:(ie??D).length>0?(ie??D).map((Ne,lt)=>Ne.type==="text"?c.jsx("span",{children:Ne.text},`text-${lt}`):Ne.type==="file"?c.jsxs("span",{className:"mx-[2px] inline-flex items-center gap-1.5 rounded-md border border-border/70 bg-muted/45 px-2 py-1 text-xs font-medium leading-none text-foreground align-middle select-none",title:Ne.path,children:[c.jsx($o,{filename:Ne.name,className:"h-3.5 w-3.5 shrink-0"}),c.jsx("span",{className:"max-w-[180px] truncate",children:Ne.lineRange?`${Ne.name}:${y2(Ne.lineRange).replace(/^lines? /,"")}`:Ne.name})]},`${Ne.path}-${lt}`):Ne.type==="workspace"?c.jsxs("span",{className:"mx-[2px] inline-flex items-center gap-1.5 rounded-md border border-border/70 bg-muted/45 px-2 py-1 text-xs font-medium leading-none text-foreground align-middle select-none",title:Ne.path,children:[c.jsx(Oj,{name:Ne.name,className:"h-3.5 w-3.5 shrink-0"}),c.jsx("span",{className:"max-w-[180px] truncate",children:Ne.name})]},`${Ne.path}-${lt}`):Ne.type==="terminal"?c.jsxs("span",{className:"mx-[2px] inline-flex items-center gap-1.5 rounded-md border border-border/70 bg-muted/45 px-2 py-1 text-xs font-medium leading-none text-foreground align-middle select-none",title:Ne.workspaceRoot?`${Ne.terminalId} · ${Ne.workspaceRoot}`:Ne.terminalId,children:[c.jsx("span",{className:"inline-flex h-3.5 w-3.5 items-center justify-center rounded-sm bg-muted-foreground/15 text-2xs font-bold uppercase text-muted-foreground",children:"T"}),c.jsx("span",{className:"max-w-[180px] truncate",children:Ne.lineRange?`${Ne.name}:${y2(Ne.lineRange).replace(/^lines? /,"")}`:Ne.name})]},`${Ne.terminalId}-${lt}`):null):de??P}),be.length>0&&c.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:be.map((Ne,lt)=>{const $e=Ne.preview??`data:${Ne.mimeType};base64,${Ne.data}`;return c.jsxs(Bd,{children:[c.jsx(a1e,{asChild:!0,children:c.jsxs("button",{type:"button",className:"group block overflow-hidden rounded-lg border border-primary/10 bg-background/65 text-left transition-colors hover:border-primary/25 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:ring-offset-background","aria-label":`Expand image ${Ne.name}`,children:[c.jsxs("span",{className:"relative block",children:[c.jsx("img",{src:$e,alt:Ne.name,className:"max-h-72 w-full object-cover transition-opacity group-hover:opacity-85"}),c.jsx("span",{className:"pointer-events-none absolute inset-0 flex items-center justify-center opacity-0 transition-opacity group-hover:opacity-100",children:c.jsx("span",{className:"rounded-full bg-black/65 px-3 py-1.5 text-xs font-medium text-white",children:"Click to expand"})})]}),c.jsx("span",{className:"block truncate border-t border-border/60 px-2 py-1 text-xs text-muted-foreground",children:Ne.name})]})}),c.jsxs(Eu,{className:"max-h-[92vh] max-w-[96vw] gap-2 overflow-hidden p-2",showCloseButton:!0,children:[c.jsx(Cu,{className:"mr-8 truncate px-1 text-sm font-medium",children:Ne.name}),c.jsx("img",{src:$e,alt:Ne.name,className:"max-h-[82vh] w-full object-contain"})]})]},`${Ne.name}-${lt}`)})})]})}),Et()]}):c.jsxs("div",{className:"relative min-w-0 max-w-full break-words [overflow-wrap:anywhere]",children:[c.jsx(uT,{"data-message-from":"assistant",className:"min-w-0 max-w-full break-words [overflow-wrap:anywhere]",children:c.jsx($7,{content:s,compact:_,isStreaming:b,preferLlmUi:S,onOpenPath:A})}),St]}):kt?c.jsx("div",{className:"flex items-center gap-3 px-1 py-1 text-sm text-muted-foreground",children:c.jsx(pH,{})}):null]})]})}),c.jsx(mYe,{open:V,onOpenChange:Q,contextFlow:o,responseContent:s})]})}const D7=y.memo(TYe,(e,r)=>{const{messageFromEnd:n,messageIndex:i,...s}=e,{messageFromEnd:o,messageIndex:a,...l}=r,d=Object.keys(l);return d.length===Object.keys(s).length&&d.every(u=>Object.is(s[u],l[u]))});D7.displayName="Message";function EYe(e){if(!(e!=null&&e.metadata))return{};try{const r=JSON.parse(e.metadata);return r&&typeof r=="object"&&!Array.isArray(r)?r:{}}catch{return{}}}function Ioe(e){const r=EYe(e),n=r.repositoryId??r.repoId;return typeof n=="string"&&n.trim()?n.trim():null}function mH(e,r){const n=Ioe(e);return n?r.find(i=>i.id===n)??null:null}function AYe(e,r){return!e||e==="gateway"?!1:!r.has(e)}function gH(e){const r=new Date(e),i=new Date().getTime()-r.getTime();return i<6e4?"just now":i<36e5?`${Math.floor(i/6e4)}m ago`:i<864e5?`${Math.floor(i/36e5)}h ago`:r.toLocaleDateString()}function OYe({platform:e}){switch(e){case"windows":case"macos":case"linux":return c.jsx(Ra,{className:"h-2.5 w-2.5"});case"android":case"ios":return c.jsx(ej,{className:"h-2.5 w-2.5"});default:return c.jsx(Ci,{className:"h-2.5 w-2.5"})}}function RYe({workspaces:e,personalSessions:r=[],activeWorkspaceId:n,activeSessionId:i,loading:s=!1,hasMoreWorkspaces:o=!1,showFewerWorkspaces:a=!1,onSelectWorkspace:l,onSelectPersonalSession:d,onNewPersonalSession:u,onCreateWorkspace:f,onRemoveWorkspace:p,onChangeDirectory:g,onAssignRepository:v,onShowMore:b,onShowFewer:_,sessionInfo:S,nodes:k=[],repositories:C=[]}){const j=y.useMemo(()=>new Set(k.filter(P=>!P.isGateway).map(P=>P.id)),[k]),[E,N]=y.useState(""),A=E.trim().toLowerCase(),M=y.useMemo(()=>A?e.filter(P=>{const D=mH(P,C),W=P.nodeId&&P.nodeId!=="gateway"?k.find(H=>H.id===P.nodeId):null;return[P.title,P.rootPath,D==null?void 0:D.name,W==null?void 0:W.name,...P.sessions.flatMap(H=>[H.name,H.workspacePath])].some(H=>H==null?void 0:H.toLowerCase().includes(A))}):e,[k,A,C,e]),B=y.useMemo(()=>A?r.filter(P=>[P.name,P.workspacePath].some(D=>D==null?void 0:D.toLowerCase().includes(A))):r,[A,r]);return c.jsxs("div",{className:"flex flex-col h-full",children:[c.jsxs("div",{className:"flex h-[35px] shrink-0 items-center gap-2 px-2.5 border-b",children:[c.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-1.5 rounded-md bg-muted/60 px-2 py-1",children:[c.jsx(pl,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),c.jsx("input",{type:"search",value:E,onChange:P=>N(P.target.value),placeholder:"Search chats and workspaces","aria-label":"Search chats and workspaces",className:"min-w-0 flex-1 bg-transparent text-xs outline-none placeholder:text-muted-foreground"})]}),c.jsxs(fn,{children:[c.jsx(ln,{asChild:!0,children:c.jsx(_e,{variant:"ghost",size:"icon",className:"h-6 w-6 shrink-0",onClick:f,children:c.jsx(Ho,{className:"h-3.5 w-3.5"})})}),c.jsx(cn,{side:"right",children:"New workspace"})]})]}),s?c.jsx("div",{className:"flex flex-1 items-center justify-center",children:c.jsx(ir,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex max-h-[50%] min-h-0 shrink-0 flex-col border-b",children:[c.jsx("div",{className:"flex h-7 shrink-0 items-center justify-between px-3",children:c.jsx("span",{className:"text-2xs font-medium text-muted-foreground",children:"Workspaces"})}),c.jsx(Th,{className:"min-h-0 flex-1",children:c.jsxs("div",{className:"space-y-0.5 px-1.5 pb-1.5",children:[e.length===0&&c.jsxs("p",{className:"text-xs text-muted-foreground text-center py-4",children:["No workspaces yet.",c.jsx("br",{}),c.jsx("button",{onClick:f,className:"underline underline-offset-2 hover:text-foreground mt-1 inline-block",children:"Choose workspace folder"})]}),e.length>0&&M.length===0&&c.jsx("p",{className:"text-xs text-muted-foreground text-center py-4",children:"No matching workspaces."}),M.map(P=>{const D=P.id===n,W=P.nodeId&&P.nodeId!=="gateway"?k.find(R=>R.id===P.nodeId):null,U=AYe(P.nodeId,j),H=mH(P,C);return c.jsxs("div",{className:`group grid w-full grid-cols-[auto,minmax(0,1fr),auto] items-start gap-1.5 px-1.5 py-1.5 text-sm transition-colors ${U||D?"cursor-default":"cursor-pointer"} ${D?"rounded-md bg-secondary/70":U?"opacity-50":"hover:rounded-md hover:bg-muted/40"}`,draggable:!!P.rootPath,onDragStart:R=>{if(!P.rootPath){R.preventDefault();return}R.dataTransfer.effectAllowed="copy",R.dataTransfer.setData(TQ,JSON.stringify(wOe(P.rootPath,P.title||void 0)))},onClick:()=>{!U&&!D&&l(P.id)},children:[D?c.jsx(Ph,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-primary"}):c.jsx(T9,{className:"mt-0.5 h-3.5 w-3.5 shrink-0 text-muted-foreground"}),c.jsxs("div",{className:"min-w-0 overflow-hidden",children:[c.jsxs("div",{className:"flex min-w-0 items-center gap-1 overflow-hidden",children:[c.jsx("span",{className:"min-w-0 truncate text-xs font-medium",children:P.title||"Untitled Workspace"}),H&&c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"shrink-0 text-2xs text-muted-foreground",children:"·"}),c.jsxs("span",{className:"flex min-w-0 items-center gap-1 text-2xs text-muted-foreground",children:[c.jsx(Xf,{className:"h-2.5 w-2.5 shrink-0"}),c.jsx("span",{className:"truncate",children:H.name})]})]})]}),c.jsxs("div",{className:"flex min-w-0 items-center gap-1 overflow-hidden text-2xs text-muted-foreground",children:[c.jsx("span",{className:"min-w-0 truncate",children:P.rootPath||"No folder linked"}),c.jsx("span",{className:"shrink-0",children:"·"}),c.jsx("span",{className:"shrink-0",children:gH(P.lastActiveAt)})]}),U&&c.jsxs("div",{className:"mt-0.5 flex items-center gap-1 text-2xs text-orange-500",children:[c.jsx(Jye,{className:"h-2.5 w-2.5 shrink-0"}),c.jsx("span",{className:"truncate",children:"Node offline"})]}),W&&!U&&c.jsx("div",{className:"mt-0.5 flex min-w-0 items-center gap-1 text-2xs",children:c.jsxs("span",{className:"inline-flex max-w-full items-center gap-0.5 rounded bg-muted px-1 py-0.5 text-muted-foreground",children:[c.jsx(OYe,{platform:W.platform}),c.jsx("span",{className:"truncate max-w-[80px]",children:W.name})]})}),D&&S&&c.jsxs("div",{className:"mt-0.5 flex min-w-0 items-center gap-1 text-2xs text-blue-500",children:[c.jsx("span",{className:"truncate",children:S.provider}),c.jsx("span",{className:"shrink-0 text-muted-foreground",children:"·"}),c.jsx(Ra,{className:"h-2.5 w-2.5 shrink-0"}),c.jsx("span",{className:"truncate",children:S.isRemote&&S.remoteNode?S.remoteNode.nodeName:"Gateway"})]})]}),c.jsxs("div",{className:"flex shrink-0 self-start gap-0.5",children:[v&&c.jsxs(fn,{children:[c.jsx(ln,{asChild:!0,children:c.jsx(_e,{variant:"ghost",size:"icon","aria-label":H?`Repository: ${H.name}`:"Assign repository",disabled:!P.rootPath,className:`h-5.5 w-5.5 shrink-0 opacity-100 transition-opacity sm:opacity-0 sm:group-hover:opacity-100 ${H?"text-primary hover:text-primary":"text-muted-foreground hover:text-foreground"}`,onClick:R=>{R.stopPropagation(),v(P.id)},children:c.jsx(Xf,{className:"h-3 w-3"})})}),c.jsx(cn,{side:"right",children:H?`Repository: ${H.name}`:"Assign repository"})]}),c.jsxs(fn,{children:[c.jsx(ln,{asChild:!0,children:c.jsx(_e,{variant:"ghost",size:"icon","aria-label":"Change directory",className:"h-5.5 w-5.5 shrink-0 opacity-100 text-muted-foreground transition-opacity hover:text-foreground sm:opacity-0 sm:group-hover:opacity-100",onClick:R=>{R.stopPropagation(),g(P.id)},children:c.jsx(s0e,{className:"h-3 w-3"})})}),c.jsx(cn,{side:"right",children:"Change directory"})]}),c.jsxs(fn,{children:[c.jsx(ln,{asChild:!0,children:c.jsx(_e,{variant:"ghost",size:"icon","aria-label":"Archive workspace",className:"h-5.5 w-5.5 shrink-0 opacity-100 text-muted-foreground transition-opacity hover:text-destructive sm:opacity-0 sm:group-hover:opacity-100",onClick:R=>{R.stopPropagation(),p(P.id)},children:c.jsx(rK,{className:"h-3 w-3"})})}),c.jsx(cn,{side:"right",children:"Archive workspace"})]})]})]},P.id)}),!A&&o&&b&&c.jsx("button",{className:"w-full px-2 py-2 text-left text-xs text-muted-foreground transition-colors hover:text-foreground",onClick:b,children:"Show more workspaces"}),!A&&a&&_&&c.jsx("button",{className:"w-full px-2 py-2 text-left text-xs text-muted-foreground transition-colors hover:text-foreground",onClick:_,children:"Show fewer workspaces"})]})})]}),c.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[c.jsxs("div",{className:"flex h-7 shrink-0 items-center justify-between px-3",children:[c.jsx("span",{className:"text-2xs font-medium text-muted-foreground",children:"Personal chats"}),u&&c.jsxs(fn,{children:[c.jsx(ln,{asChild:!0,children:c.jsx(_e,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:u,children:c.jsx(Ho,{className:"h-3 w-3"})})}),c.jsx(cn,{side:"right",children:"New personal chat"})]})]}),c.jsx(Th,{className:"min-h-0 flex-1",children:c.jsxs("div",{className:"space-y-0.5 px-1.5 pb-1.5",children:[r.length===0&&c.jsxs("p",{className:"text-xs text-muted-foreground text-center py-4",children:["No personal chats yet.",u&&c.jsxs(c.Fragment,{children:[c.jsx("br",{}),c.jsx("button",{onClick:u,className:"underline underline-offset-2 hover:text-foreground mt-1 inline-block",children:"Start a chat"})]})]}),r.length>0&&B.length===0&&c.jsx("p",{className:"text-xs text-muted-foreground text-center py-4",children:"No matching personal chats."}),B.map(P=>{const D=n===null&&P.id===i;return c.jsxs("div",{className:`group flex items-center gap-1.5 rounded-md px-1.5 py-1 transition-colors text-sm ${D?"bg-secondary/70 cursor-default":"cursor-pointer hover:bg-muted/40"}`,onClick:()=>{!D&&d&&d(P.id)},children:[c.jsx(Rm,{className:`h-3.5 w-3.5 shrink-0 ${D?"text-primary":"text-muted-foreground"}`}),c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsx("div",{className:"truncate text-xs font-medium",children:P.name||"Personal chat"}),c.jsx("div",{className:"text-2xs text-muted-foreground",children:gH(P.lastActiveAt??P.createdAt)})]})]},P.id)})]})})]})]})]})}function MYe(e){const r=new Date(e),i=new Date().getTime()-r.getTime();return i<6e4?"just now":i<36e5?`${Math.floor(i/6e4)}m ago`:i<864e5?`${Math.floor(i/36e5)}h ago`:r.toLocaleDateString()}function PYe({sessions:e,activeSessionId:r,workspaceTitle:n,onSelectSession:i,onNewSession:s,onOpenChange:o,showTitle:a=!0,triggerLabel:l=null}){const[d,u]=y.useState(!1),f=e.find(g=>g.id===r)??e[0]??null,p=g=>{u(g),o==null||o(g)};return c.jsxs("div",{className:a?"flex min-w-0 flex-1 items-center justify-between gap-1.5":"flex items-center gap-1.5",children:[a?c.jsx("span",{className:"min-w-0 truncate text-sm font-semibold leading-tight",children:f!=null&&f.name&&f.name!=="New Chat"?f.name:""}):null,c.jsxs(yu,{open:d,onOpenChange:p,children:[c.jsxs(fn,{children:[c.jsx(ln,{asChild:!0,children:c.jsx(vu,{asChild:!0,children:c.jsxs(_e,{variant:"ghost",size:l?"sm":"icon",className:l?"h-7 shrink-0 rounded-md px-2 text-xs text-muted-foreground hover:text-foreground":"h-6 w-6 shrink-0 rounded-md text-muted-foreground hover:text-foreground",children:[c.jsx(cK,{className:"h-3.5 w-3.5"}),l?c.jsx("span",{children:l}):null]})})}),c.jsx(cn,{side:"bottom",children:l??"Sessions"})]}),c.jsxs(Ac,{align:"start",className:"w-[min(28rem,calc(100vw-1rem))] p-0",children:[c.jsxs("div",{className:"flex items-center justify-between border-b px-3 py-2",children:[c.jsxs("div",{children:[c.jsx("div",{className:"text-sm font-medium",children:"Sessions"}),c.jsx("div",{className:"text-xs text-muted-foreground",children:n||"Current workspace"})]}),c.jsxs(_e,{variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>{s(),u(!1)},children:[c.jsx(B0e,{className:"mr-1 h-3 w-3"}),"New chat"]})]}),c.jsx("div",{className:"max-h-[min(28rem,70vh)] overflow-y-auto p-2",children:e.length===0?c.jsx("div",{className:"px-3 py-6 text-center text-sm text-muted-foreground",children:"No sessions yet."}):c.jsx("div",{className:"space-y-0.5",children:e.map(g=>{const v=g.id===r;return c.jsxs("button",{type:"button",className:`flex w-full items-start gap-2 rounded-md px-3 py-2 text-left transition-colors ${v?"bg-secondary text-secondary-foreground":"hover:bg-muted/50"}`,onClick:()=>{i(g.id),u(!1)},children:[v?c.jsx(_s,{className:"mt-0.5 h-3 w-3 shrink-0 text-primary"}):c.jsx("span",{className:"mt-1 h-2 w-2 shrink-0 rounded-full bg-muted-foreground/50"}),c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx("span",{className:"truncate text-xs font-medium",children:g.name||"Untitled"}),g.status==="archived"&&c.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border px-1.5 py-0 text-2xs text-muted-foreground",children:[c.jsx(rK,{className:"h-2.5 w-2.5"}),"Archived"]})]}),c.jsx("div",{className:"text-2xs text-muted-foreground",children:MYe(g.lastActiveAt)})]})]},g.id)})})})]})]})]})}function LYe({suggestions:e,onSelect:r,className:n}){return c.jsx("div",{className:Fe("flex flex-wrap gap-2 justify-center",n),children:e.map(i=>c.jsx("button",{onClick:()=>r(i),className:"px-4 py-2 text-sm rounded-full border bg-background text-muted-foreground hover:bg-accent hover:text-accent-foreground transition-colors",children:i},i))})}const $Ye=G4("inline-flex items-center rounded-md border px-2 py-0.5 text-xs font-medium leading-4 transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",secondary:"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",destructive:"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",outline:"text-foreground",success:"border-transparent bg-green-500/15 text-green-700 dark:text-green-400",warning:"border-transparent bg-yellow-500/15 text-yellow-700 dark:text-yellow-400"}},defaultVariants:{variant:"default"}});function un({className:e,variant:r,...n}){return c.jsx("div",{className:Fe($Ye({variant:r}),e),...n})}const Mn=y.forwardRef(({className:e,...r},n)=>c.jsx("div",{ref:n,className:Fe("rounded-xl border border-border/70 bg-card text-card-foreground shadow-sm",e),...r}));Mn.displayName="Card";const Boe=y.forwardRef(({className:e,...r},n)=>c.jsx("div",{ref:n,className:Fe("flex flex-col space-y-1.5 p-6",e),...r}));Boe.displayName="CardHeader";const zoe=y.forwardRef(({className:e,...r},n)=>c.jsx("h3",{ref:n,className:Fe("font-semibold leading-none tracking-tight",e),...r}));zoe.displayName="CardTitle";const DYe=y.forwardRef(({className:e,...r},n)=>c.jsx("p",{ref:n,className:Fe("text-sm text-muted-foreground",e),...r}));DYe.displayName="CardDescription";const Foe=y.forwardRef(({className:e,...r},n)=>c.jsx("div",{ref:n,className:Fe("p-6 pt-0",e),...r}));Foe.displayName="CardContent";const IYe=y.forwardRef(({className:e,...r},n)=>c.jsx("div",{ref:n,className:Fe("flex items-center p-6 pt-0",e),...r}));IYe.displayName="CardFooter";const BYe={pending:{icon:sg,label:"Pending",color:"text-muted-foreground"},approved:{icon:ir,label:"Running",color:"text-blue-500"},rejected:{icon:ti,label:"Rejected",color:"text-destructive"},executed:{icon:ml,label:"Done",color:"text-green-500"},failed:{icon:Oa,label:"Failed",color:"text-destructive"}};function zYe({action:e,expanded:r,onToggle:n}){const i=BYe[e.status],s=i.icon;return c.jsxs("div",{className:"border rounded-md",children:[c.jsxs("button",{type:"button",className:"flex items-center gap-3 w-full px-3 py-2.5 text-left hover:bg-muted/50 transition-colors",onClick:n,children:[c.jsx(s,{className:Fe("h-4 w-4 shrink-0",i.color,e.status==="approved"&&"animate-spin")}),c.jsxs("span",{className:"flex-1 min-w-0",children:[c.jsx("span",{className:"font-mono text-sm font-medium",children:e.tool}),c.jsxs("span",{className:"text-xs text-muted-foreground ml-2",children:["Step ",e.order+1]})]}),c.jsx(un,{variant:"outline",className:"text-2xs px-1.5 py-0",children:i.label}),r?c.jsx(vl,{className:"h-4 w-4 text-muted-foreground"}):c.jsx(ko,{className:"h-4 w-4 text-muted-foreground"})]}),r&&c.jsxs("div",{className:"px-3 pb-3 pt-1 border-t bg-muted/30",children:[c.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:e.description}),c.jsx("pre",{className:"text-xs bg-background rounded p-2 overflow-x-auto max-h-48",children:JSON.stringify(e.args,null,2)}),e.result&&c.jsx("div",{className:Fe("mt-2 text-xs rounded p-2",e.result.ok?"bg-green-500/10 text-green-700 dark:text-green-400":"bg-destructive/10 text-destructive"),children:e.result.message})]})]})}function FYe({plan:e,onApprove:r,onReject:n,isExecuting:i,className:s}){const[o,a]=y.useState(new Set),l=g=>{a(v=>{const b=new Set(v);return b.has(g)?b.delete(g):b.add(g),b})},d=e.actions.filter(g=>g.status==="pending").length,u=e.actions.filter(g=>g.status==="executed").length,f=e.actions.filter(g=>g.status==="failed").length,p=d===0;return c.jsxs(Mn,{className:Fe("p-4 space-y-3",s),children:[c.jsxs("div",{className:"flex items-start justify-between gap-3",children:[c.jsxs("div",{children:[c.jsxs("h3",{className:"text-sm font-medium flex items-center gap-2",children:[c.jsx(HYe,{className:"h-4 w-4"}),"Plan",c.jsxs(un,{variant:"secondary",className:"text-2xs px-1.5 py-0",children:[e.actions.length," step",e.actions.length!==1?"s":""]})]}),c.jsx("p",{className:"text-xs text-muted-foreground mt-1 line-clamp-2",children:e.summary})]}),p&&c.jsx(un,{variant:f>0?"destructive":"success",className:"shrink-0",children:f>0?`${f} failed`:"Complete"})]}),c.jsx("div",{className:"space-y-1.5",children:e.actions.map(g=>c.jsx(zYe,{action:g,expanded:o.has(g.id),onToggle:()=>l(g.id)},g.id))}),d>0&&c.jsxs("div",{className:"flex items-center gap-2 pt-1",children:[c.jsx(_e,{size:"sm",onClick:()=>r(),disabled:i,children:i?c.jsxs(c.Fragment,{children:[c.jsx(ir,{className:"h-3.5 w-3.5 mr-1.5 animate-spin"}),"Executing..."]}):c.jsxs(c.Fragment,{children:[c.jsx(J4,{className:"h-3.5 w-3.5 mr-1.5"}),"Execute all (",d,")"]})}),c.jsxs(_e,{size:"sm",variant:"outline",onClick:n,disabled:i,children:[c.jsx(ti,{className:"h-3.5 w-3.5 mr-1.5"}),"Reject"]})]}),p&&!i&&c.jsxs("p",{className:"text-xs text-muted-foreground",children:[u>0&&`${u} action${u!==1?"s":""} executed.`,f>0&&` ${f} failed.`]})]})}function HYe({className:e}){return c.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e,children:[c.jsx("rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1"}),c.jsx("path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"}),c.jsx("path",{d:"M12 11h4"}),c.jsx("path",{d:"M12 16h4"}),c.jsx("path",{d:"M8 11h.01"}),c.jsx("path",{d:"M8 16h.01"})]})}function WYe(e){return e.find(r=>r.status==="in-progress")??null}function Hoe(e){return e.length>0&&e.every(r=>r.status==="completed")}function UYe(e){const r=WYe(e),n=Hoe(e);return{headerLabel:r?r.title:n?"All tasks completed":"Tasks",showHeaderSpinner:!!r,showHeaderCompleted:!r&&n}}function uE({items:e,className:r,onClear:n}){const[i,s]=y.useState(!1),o=y.useMemo(()=>Hoe(e),[e]),a=y.useMemo(()=>UYe(e),[e]);if(e.length===0)return null;const l=e.filter(g=>g.status==="completed").length,d=e.length,u=d>0?Math.round(l/d*100):0,f=i?"Tasks":a.headerLabel,p=o?"bg-green-500":"bg-primary";return c.jsxs("div",{className:Fe("rounded-lg border bg-muted/30 p-3 space-y-2",r),children:[c.jsxs("button",{type:"button",onClick:()=>s(g=>!g),className:"flex items-center gap-2 w-full text-left",children:[c.jsx(vl,{className:Fe("h-3 w-3 shrink-0 text-muted-foreground transition-transform duration-200",!i&&"-rotate-90")}),!i&&a.showHeaderSpinner&&c.jsx(ir,{className:"h-3.5 w-3.5 shrink-0 text-primary animate-spin"}),!i&&a.showHeaderCompleted&&c.jsx(ml,{className:"h-3.5 w-3.5 shrink-0 text-green-500"}),c.jsx("span",{className:"min-w-0 truncate text-xs font-medium text-foreground",children:f}),c.jsx("div",{className:"flex-1 h-1.5 rounded-full bg-muted overflow-hidden",children:c.jsx("div",{className:Fe("h-full rounded-full transition-all duration-300",p),style:{width:`${u}%`}})}),c.jsxs("span",{className:"text-2xs text-muted-foreground tabular-nums",children:[l,"/",d]}),n&&c.jsx("button",{type:"button",onClick:g=>{g.stopPropagation(),n()},className:"shrink-0 p-0.5 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors",title:"Clear todo list",children:c.jsx(ti,{className:"h-3 w-3"})})]}),i&&c.jsx("div",{className:"space-y-1",children:e.map(g=>c.jsxs("div",{className:Fe("flex items-start gap-2 text-xs py-0.5",g.status==="completed"&&"text-muted-foreground"),children:[g.status==="completed"?c.jsx(ml,{className:"h-3.5 w-3.5 shrink-0 mt-0.5 text-green-500"}):g.status==="in-progress"?c.jsx(ir,{className:"h-3.5 w-3.5 shrink-0 mt-0.5 text-primary animate-spin"}):c.jsx(Ege,{className:"h-3.5 w-3.5 shrink-0 mt-0.5 text-muted-foreground/50"}),c.jsx("span",{className:Fe("flex-1 min-w-0",g.status==="completed"&&"line-through"),children:g.title})]},g.id))})]})}function VYe({files:e,onAccept:r,onReject:n,onAcceptAll:i,onRejectAll:s,onFileClick:o,className:a}){const l=y.useRef(null),[d,u]=y.useState(!1);if(y.useEffect(()=>{const p=l.current;if(!p||typeof ResizeObserver>"u")return;const g=()=>{u(p.clientWidth<560)};g();const v=new ResizeObserver(()=>g());return v.observe(p),()=>v.disconnect()},[]),e.length===0)return null;const f=e.filter(p=>p.state==="undecided").length;return c.jsxs("div",{ref:l,className:Fe("overflow-hidden rounded-lg border bg-muted/30",a),children:[c.jsxs("div",{className:"flex items-center justify-between gap-2 border-b bg-muted/20 px-3 py-2",children:[c.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[c.jsx(Gl,{className:"h-3.5 w-3.5 text-muted-foreground"}),c.jsxs("span",{className:"truncate text-xs font-medium",children:["Files changed (",e.length,")"]}),f>0&&c.jsxs("span",{className:"shrink-0 text-2xs text-amber-500 dark:text-amber-400",children:[f," pending"]})]}),f>0&&c.jsxs("div",{className:"ml-auto flex shrink-0 items-center gap-1",children:[c.jsxs(_e,{size:d?"icon":"sm",variant:"ghost",className:Fe("h-6 shrink-0 text-xs",d?"w-6 p-0":"px-2"),onClick:i,title:"Keep all","aria-label":"Keep all",children:[c.jsx(_s,{className:Fe("h-3 w-3 shrink-0",!d&&"mr-1")}),!d&&"Keep all"]}),c.jsxs(_e,{size:d?"icon":"sm",variant:"ghost",className:Fe("h-6 shrink-0 text-xs",d?"w-6 p-0":"px-2"),onClick:s,title:"Undo all","aria-label":"Undo all",children:[c.jsx(Ah,{className:Fe("h-3 w-3 shrink-0",!d&&"mr-1")}),!d&&"Undo all"]})]})]}),c.jsx("div",{className:"divide-y",children:e.map(p=>c.jsxs("div",{className:Fe("flex items-center gap-2 px-3 py-1.5 text-xs",p.state==="accepted"&&"bg-green-500/5",p.state==="rejected"&&"bg-red-500/5 text-muted-foreground"),children:[c.jsx($o,{filename:p.name,className:"h-3.5 w-3.5 shrink-0"}),c.jsx("button",{type:"button",className:Fe("min-w-0 flex-1 truncate text-left hover:underline cursor-pointer",p.state==="rejected"&&"line-through"),title:`Review diff for ${p.path}`,onClick:()=>o==null?void 0:o(p.path),children:p.path}),p.state==="undecided"&&c.jsxs("div",{className:"ml-auto flex items-center gap-0.5 shrink-0",children:[c.jsx("button",{type:"button",className:"p-1 rounded hover:bg-primary/10 text-primary transition-colors",onClick:()=>o==null?void 0:o(p.path),title:"Review changes",children:c.jsx(sp,{className:"h-3 w-3"})}),c.jsx("button",{type:"button",className:"p-1 rounded hover:bg-green-500/20 text-green-600 dark:text-green-400 transition-colors",onClick:()=>r==null?void 0:r(p.path),title:"Keep all changes",children:c.jsx(_s,{className:"h-3 w-3"})}),c.jsx("button",{type:"button",className:"p-1 rounded hover:bg-red-500/20 text-red-600 dark:text-red-400 transition-colors",onClick:()=>n==null?void 0:n(p.path),title:"Undo all changes",children:c.jsx(Ah,{className:"h-3 w-3"})})]}),p.state==="accepted"&&c.jsx("span",{className:"text-2xs text-green-600 dark:text-green-400 shrink-0",children:"Kept"}),p.state==="rejected"&&c.jsx("span",{className:"text-2xs text-red-500 shrink-0",children:"Undone"})]},p.path))})]})}function qYe(e,r,n,i){const s=e.findIndex(d=>d.id===r);if(s<0)return e;const o=[...e],[a]=o.splice(s,1);if(!a)return e;if(n==null)return o.push(a),o;const l=o.findIndex(d=>d.id===n);return l<0?e:(o.splice(l+(i==="after"?1:0),0,a),o)}function GYe({item:e,index:r}){return c.jsxs("div",{className:"flex items-start gap-2 rounded-lg border border-border/40 bg-background px-3 py-2 text-sm shadow-2xl ring-1 ring-primary/10",children:[c.jsx("div",{className:"mt-0.5 shrink-0 rounded p-0.5 text-muted-foreground",children:r===0?c.jsx(E9,{className:"h-3.5 w-3.5 text-primary"}):c.jsx(ko,{className:"h-3.5 w-3.5 text-muted-foreground"})}),c.jsx("div",{className:"mt-0.5 shrink-0 rounded p-0.5 text-muted-foreground",children:c.jsx(lK,{className:"h-3.5 w-3.5"})}),c.jsxs("div",{className:"min-w-0 flex-1",children:[r===0?c.jsx("span",{className:"mb-0.5 block text-2xs font-medium uppercase tracking-wider text-primary/70",children:"Next"}):c.jsxs("span",{className:"mb-0.5 block text-2xs font-medium uppercase tracking-wider text-muted-foreground",children:["Queued #",r+1]}),c.jsx("span",{className:"whitespace-pre-wrap break-words text-foreground",children:e.displayContent??e.content})]})]})}function KYe({item:e,index:r,onRemove:n,onEdit:i,onReorder:s,onSendToParallelThread:o,dragActive:a,dropBefore:l,dropAfter:d,onDragStart:u}){const[f,p]=y.useState(!1),[g,v]=y.useState(!0),[b,_]=y.useState(e.displayContent??e.content),S=y.useRef(null),k=f||!a;y.useEffect(()=>{if(f){const N=S.current;N&&(N.focus(),N.setSelectionRange(N.value.length,N.value.length))}},[f]),y.useEffect(()=>{f||_(e.displayContent??e.content)},[e.content,e.displayContent,f]);const C=y.useCallback(()=>{const N=b.trim(),A=e.displayContent??e.content;N&&N!==A&&(i==null||i(e.id,N)),p(!1)},[b,e.content,e.displayContent,e.id,i]),j=y.useCallback(()=>{_(e.displayContent??e.content),p(!1)},[e.content,e.displayContent]),E=y.useCallback(N=>{N.key==="Enter"&&!N.shiftKey?(N.preventDefault(),C()):N.key==="Escape"&&j()},[C,j]);return c.jsxs(c.Fragment,{children:[l&&c.jsx("div",{className:"relative h-0",children:c.jsx("div",{className:"absolute inset-x-2 -top-px h-0.5 rounded-full bg-primary shadow-[0_0_0_1px_hsl(var(--background))]"})}),c.jsxs("div",{"data-queue-id":e.id,className:Fe("group flex cursor-grab touch-none items-start gap-2 rounded-lg border border-border/40 bg-muted/50 px-3 py-2 text-sm transition-all duration-150 ease-out hover:bg-muted/70 active:cursor-grabbing",a&&"border-dashed border-primary/35 bg-primary/5 opacity-0"),onPointerDown:N=>{f||!s||N.target.closest('button, textarea, input, a, [data-no-drag="true"]')||u==null||u(e.id,N)},children:[c.jsx("button",{type:"button","data-no-drag":"true",className:"mt-0.5 shrink-0 rounded p-0.5 text-muted-foreground hover:bg-foreground/10 hover:text-foreground transition-colors",onClick:()=>v(N=>!N),"aria-label":g?"Expand queued message":"Collapse queued message",title:g?"Expand queued message":"Collapse queued message",children:g?c.jsx(ko,{className:"h-3.5 w-3.5"}):r===0?c.jsx(E9,{className:"h-3.5 w-3.5 text-primary"}):c.jsx(vl,{className:"h-3.5 w-3.5 text-muted-foreground"})}),s&&!f&&c.jsx("div",{className:"mt-0.5 shrink-0 rounded p-0.5 text-muted-foreground cursor-grab active:cursor-grabbing touch-none",title:"Drag to reorder","aria-label":"Drag to reorder",children:c.jsx(lK,{className:"h-3.5 w-3.5"})}),c.jsxs("div",{className:"flex-1 min-w-0",children:[r===0&&!f&&c.jsx("span",{className:"text-2xs font-medium uppercase tracking-wider text-primary/70 block mb-0.5",children:"Next"}),r>0&&!f&&c.jsxs("span",{className:"text-2xs font-medium uppercase tracking-wider text-muted-foreground block mb-0.5",children:["Queued #",r+1]}),f?c.jsx("textarea",{ref:S,value:b,onChange:N=>_(N.target.value),onKeyDown:E,onBlur:C,rows:Math.min(b.split(`
1162
1162
  `).length,5),className:"w-full resize-none rounded border border-primary/30 bg-background px-2 py-1 text-sm outline-none focus:border-primary focus:ring-1 focus:ring-primary/20"}):g?c.jsx("span",{className:"block truncate text-foreground",children:e.displayContent??e.content}):c.jsx("span",{className:"whitespace-pre-wrap break-words text-foreground",children:e.displayContent??e.content})]}),c.jsx("div",{className:Fe("mt-0.5 flex shrink-0 items-center gap-0.5 transition-opacity",k?"opacity-0 group-hover:opacity-100":"opacity-0"),children:f?c.jsxs(c.Fragment,{children:[c.jsx("button",{type:"button","data-no-drag":"true",className:"p-1 rounded hover:bg-primary/10 text-primary transition-colors",onClick:C,title:"Save",children:c.jsx(_s,{className:"h-3.5 w-3.5"})}),c.jsx("button",{type:"button","data-no-drag":"true",className:"p-1 rounded hover:bg-foreground/10 text-muted-foreground transition-colors",onClick:j,title:"Cancel",children:c.jsx(ti,{className:"h-3.5 w-3.5"})})]}):c.jsxs(c.Fragment,{children:[i&&c.jsx("button",{type:"button","data-no-drag":"true",className:"p-1 rounded hover:bg-foreground/10 text-muted-foreground transition-colors",onClick:()=>p(!0),title:"Edit message",children:c.jsx(R9,{className:"h-3 w-3"})}),o&&c.jsx("button",{type:"button","data-no-drag":"true",className:"p-1 rounded hover:bg-primary/10 text-muted-foreground hover:text-primary transition-colors",onClick:()=>o(e.id),title:"Send to parallel thread",children:c.jsx(Xf,{className:"h-3 w-3"})}),c.jsx("button",{type:"button","data-no-drag":"true",className:"p-1 rounded hover:bg-destructive/10 text-muted-foreground hover:text-destructive transition-colors",onClick:()=>n==null?void 0:n(e.id),title:"Remove from queue",children:c.jsx(ti,{className:"h-3.5 w-3.5"})})]})})]}),d&&c.jsx("div",{className:"relative h-0",children:c.jsx("div",{className:"absolute inset-x-2 -top-px h-0.5 rounded-full bg-primary shadow-[0_0_0_1px_hsl(var(--background))]"})})]})}function yH({items:e,onRemove:r,onEdit:n,onReorder:i,onSendToParallelThread:s,className:o}){const a=y.useRef(null),l=y.useRef(null),[d,u]=y.useState(null),[f,p]=y.useState(null),[g,v]=y.useState(null);y.useEffect(()=>{if(d&&!e.some(C=>C.id===d)){u(null),p(null),v(null);return}f!=null&&f.targetId&&!e.some(C=>C.id===f.targetId)&&p(d?{targetId:d,placement:"before"}:null)},[d,f,e]),y.useEffect(()=>{var M;if(!d||!g)return;document.body.style.cursor="grabbing",document.body.style.userSelect="none",document.body.style.touchAction="none";const C=(B,P)=>{var H,R;const D=Array.from(((H=a.current)==null?void 0:H.querySelectorAll("[data-queue-id]"))??[]);if(D.length===0){p(null);return}const W=D.filter(I=>I.dataset.queueId&&I.dataset.queueId!==d);if(W.length===0){p({targetId:null,placement:"after"});return}for(const I of W){const L=I.dataset.queueId;if(!L)continue;const z=I.getBoundingClientRect(),G=z.top+z.height/2;if(P<G){p({targetId:L,placement:"before"});return}}const U=((R=W[W.length-1])==null?void 0:R.dataset.queueId)??null;p(U?{targetId:U,placement:"after"}:{targetId:null,placement:"after"})},j=B=>{B.pointerId===g.pointerId&&(v(P=>P&&{...P,x:B.clientX,y:B.clientY}),C(B.clientX,B.clientY))},E=B=>{var D,W;if(B&&B.pointerId!==g.pointerId)return;d&&f&&f.targetId!==d&&(i==null||i(d,f.targetId,f.placement));const P=l.current;(D=P==null?void 0:P.hasPointerCapture)!=null&&D.call(P,g.pointerId)&&((W=P.releasePointerCapture)==null||W.call(P,g.pointerId)),l.current=null,u(null),p(null),v(null)},N=()=>{E()},A=()=>{E()};return window.addEventListener("pointermove",j),window.addEventListener("pointerup",E),window.addEventListener("pointercancel",E),window.addEventListener("blur",A),(M=l.current)==null||M.addEventListener("lostpointercapture",N),()=>{var B;document.body.style.cursor="",document.body.style.userSelect="",document.body.style.touchAction="",window.removeEventListener("pointermove",j),window.removeEventListener("pointerup",E),window.removeEventListener("pointercancel",E),window.removeEventListener("blur",A),(B=l.current)==null||B.removeEventListener("lostpointercapture",N)}},[g,d,f,i]);const b=y.useCallback((C,j)=>{var A;if(!i||j.button!==0&&j.pointerType!=="touch"&&j.pointerType!=="pen")return;j.preventDefault();const E=j.currentTarget.closest("[data-queue-id]");if(!E)return;l.current=E,(A=E.setPointerCapture)==null||A.call(E,j.pointerId);const N=E.getBoundingClientRect();u(C),p({targetId:C,placement:"before"}),v({id:C,pointerId:j.pointerId,x:j.clientX,y:j.clientY,offsetX:j.clientX-N.left,offsetY:j.clientY-N.top,width:N.width,height:N.height})},[i]);if(e.length===0)return null;const _=d&&f&&(f.targetId!==d||f.placement==="after")?qYe(e,d,f.targetId,f.placement):e,S=g?_.findIndex(C=>C.id===g.id):-1,k=S>=0?_[S]:null;return c.jsxs("div",{ref:a,className:Fe("space-y-1.5",o),children:[c.jsx("div",{className:"flex items-center gap-1.5 px-0.5",children:c.jsxs("span",{className:"text-xs font-medium text-muted-foreground",children:[e.length," queued message",e.length!==1?"s":""]})}),_.map((C,j)=>c.jsx(KYe,{item:C,index:j,onRemove:r,onEdit:n,onReorder:i,onSendToParallelThread:s,dragActive:d===C.id,dropBefore:!!(d&&(f==null?void 0:f.targetId)===C.id&&f.placement==="before"&&d!==C.id),dropAfter:!!(d&&(f==null?void 0:f.targetId)===C.id&&f.placement==="after"&&d!==C.id),onDragStart:b},C.id)),g&&k&&c.jsx("div",{className:"pointer-events-none fixed z-50",style:{left:`${g.x-g.offsetX}px`,top:`${g.y-g.offsetY}px`,width:`${g.width}px`,minHeight:`${g.height}px`},children:c.jsx("div",{className:"scale-[1.01] opacity-95",children:c.jsx(GYe,{item:k,index:S})})})]})}function YYe({usage:e}){if(!e||e.limit<=0)return null;const r=Math.round(e.ratio*100),n=y.useMemo(()=>{if(!e||e.total===0)return[];const S=e.total;return[{label:"System",tokens:e.system,pct:Math.round(e.system/S*100),color:"var(--ctx-system)"},{label:"History",tokens:e.history,pct:Math.round(e.history/S*100),color:"var(--ctx-history)"},{label:"Tool Results",tokens:e.toolResults,pct:Math.round(e.toolResults/S*100),color:"var(--ctx-tool-results)"},{label:"Tools",tokens:e.tools,pct:Math.round(e.tools/S*100),color:"var(--ctx-tools)"}].filter(k=>k.tokens>0)},[e]),i=22,s=3,o=(i-s)/2,a=2*Math.PI*o,l=y.useMemo(()=>{if(!e||e.limit<=0)return[];const S=[];let k=0;for(const C of n){const E=C.tokens/e.limit*a;S.push({offset:k,length:E,color:C.color}),k+=E}return S},[n,e,a]),d=r>=90?"text-red-500":r>=75?"text-amber-500":"text-emerald-500",u=S=>S>=1e3?`${(S/1e3).toFixed(1)}k`:String(S),[f,p]=y.useState(!1),[g,v]=y.useState(!1),b=y.useCallback(()=>p(S=>!S),[]),_=y.useCallback(S=>{v(S),!S&&!f&&p(!1)},[f]);return c.jsxs(fn,{open:f||g,onOpenChange:_,children:[c.jsx(ln,{asChild:!0,children:c.jsxs("button",{type:"button",onClick:b,className:"flex items-center gap-1.5 px-1.5 py-1 rounded-md hover:bg-muted/50 cursor-pointer transition-colors",children:[c.jsxs("svg",{width:i,height:i,viewBox:`0 0 ${i} ${i}`,className:`-rotate-90 ${d}`,children:[c.jsx("circle",{cx:i/2,cy:i/2,r:o,fill:"none",stroke:"currentColor",strokeWidth:s,opacity:.15}),l.map((S,k)=>c.jsx("circle",{cx:i/2,cy:i/2,r:o,fill:"none",stroke:S.color,strokeWidth:s,strokeDasharray:`${S.length} ${a-S.length}`,strokeDashoffset:-S.offset,strokeLinecap:"round",opacity:.85},k))]}),c.jsxs("span",{className:"text-2xs tabular-nums text-muted-foreground",children:[r,"%"]})]})}),c.jsx(cn,{side:"bottom",className:"max-w-[220px] bg-popover text-popover-foreground border shadow-md",onPointerDownOutside:()=>p(!1),children:c.jsxs("div",{className:"space-y-1.5",children:[c.jsxs("div",{className:"flex items-center justify-between text-xs font-medium",children:[c.jsx("span",{children:"Context Window"}),c.jsxs("span",{className:"tabular-nums",children:[u(e.total)," / ",u(e.limit)]})]}),c.jsx("div",{className:"w-full h-1.5 rounded-full bg-muted overflow-hidden",children:c.jsx("div",{className:`h-full rounded-full transition-all ${r>=90?"bg-red-500":r>=75?"bg-amber-500":"bg-emerald-500"}`,style:{width:`${Math.min(r,100)}%`}})}),c.jsx("div",{className:"space-y-0.5",children:n.map(S=>c.jsxs("div",{className:"flex items-center justify-between text-xs",children:[c.jsxs("div",{className:"flex items-center gap-1.5",children:[c.jsx("span",{className:"inline-block w-2 h-2 rounded-full",style:{backgroundColor:S.color}}),c.jsx("span",{className:"text-muted-foreground",children:S.label})]}),c.jsxs("span",{className:"tabular-nums text-muted-foreground",children:[S.pct,"%"]})]},S.label))}),e.pruned&&c.jsx("div",{className:"text-2xs text-amber-500 pt-0.5 border-t border-border",children:"Old messages pruned to fit context"})]})})]})}const E1=Hn(),XYe=cy();function ZYe(e){const[r,n]=y.useState([]),i=y.useRef(async()=>{}),s=y.useRef(e);s.current=e;const o=y.useCallback(async()=>{try{const u=e?`${E1}/api/consent/pending/${e}`:`${E1}/api/consent/pending`,p=await(await fetch(u)).json();n(p.requests)}catch{}},[e]);i.current=o,y.useEffect(()=>{o()},[o]),y.useEffect(()=>{let u=!1;const f=new WebSocket(XYe);return f.onmessage=p=>{if(!u)try{const g=JSON.parse(p.data);if(g.type==="consent.required"){const v=g.payload,b=s.current;(!b||v.sessionId===b)&&n(_=>[..._,v])}if(g.type==="consent.resolved"){const v=g.payload;n(b=>b.filter(_=>_.id!==v.requestId))}}catch{}},f.onopen=()=>{u||i.current()},()=>{if(u=!0,f.onopen=()=>{try{f.close()}catch{}},f.onmessage=null,f.onerror=null,f.onclose=null,f.readyState===WebSocket.OPEN)try{f.close()}catch{}}},[]);const a=y.useCallback(async u=>{try{await fetch(`${E1}/api/consent/${u}/approve`,{method:"POST"}),n(f=>f.filter(p=>p.id!==u))}catch{}},[]),l=y.useCallback(async(u,f)=>{try{await fetch(`${E1}/api/consent/${u}/reject`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({reason:f})}),n(p=>p.filter(g=>g.id!==u))}catch{}},[]),d=y.useCallback(async(u,f)=>{try{const g=await(await fetch(`${E1}/api/consent/pending/${u}/approve-all`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({reason:f})})).json(),v=new Set(g.requestIds??[]);return v.size>0?n(b=>b.filter(_=>!v.has(_.id))):n(b=>b.filter(_=>_.sessionId!==u)),!0}catch{return!1}},[]);return{queue:r,approve:a,reject:l,approveAllForSession:d,refresh:o}}function JYe(){const[e,r]=y.useState(null),n=y.useCallback(async()=>{try{const s=await(await fetch(`${E1}/api/consent/policy`)).json();r(s)}catch{r(null)}},[]);return y.useEffect(()=>{n()},[n]),{policy:e,refresh:n}}function vH({risk:e}){const r={low:"bg-green-500/10 text-green-600 dark:text-green-400",medium:"bg-yellow-500/10 text-yellow-600 dark:text-yellow-400",high:"bg-red-500/10 text-red-600 dark:text-red-400"},i={low:Q4,medium:yK,high:D8}[e];return c.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium ${r[e]}`,children:[c.jsx(i,{className:"h-3 w-3"}),e]})}function xH({level:e}){const r={none:"bg-emerald-500/10 text-emerald-600 dark:text-emerald-400",once:"bg-blue-500/10 text-blue-600 dark:text-blue-400",always:"bg-amber-500/10 text-amber-700 dark:text-amber-300",dangerous:"bg-red-500/10 text-red-600 dark:text-red-400"};return c.jsx("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium ${r[e]}`,children:e})}function bH({expiresAt:e}){const[r,n]=y.useState("");return y.useEffect(()=>{const i=()=>{const o=new Date(e).getTime()-Date.now();if(o<=0){n("expired");return}const a=Math.ceil(o/1e3);a>60?n(`${Math.ceil(a/60)}m`):n(`${a}s`)};i();const s=setInterval(i,1e3);return()=>clearInterval(s)},[e]),c.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-muted-foreground",children:[c.jsx(sg,{className:"h-3 w-3"}),r]})}function _H({toolName:e}){return e.startsWith("terminal.")?c.jsx(Wo,{className:"h-4 w-4"}):e.startsWith("file.")?c.jsx(Gl,{className:"h-4 w-4"}):c.jsx(hK,{className:"h-4 w-4"})}function QYe({preview:e,toolName:r}){const n=e.command,i=e.path,s=e.content;return n?c.jsxs("div",{className:"rounded-md bg-muted p-3 font-mono text-xs leading-relaxed overflow-x-auto",children:[c.jsx("span",{className:"text-muted-foreground",children:"$ "}),n]}):i?c.jsxs("div",{className:"rounded-md bg-muted p-3 text-xs leading-relaxed overflow-x-auto",children:[c.jsxs("div",{className:"text-muted-foreground mb-1",children:[r,": ",i]}),s&&c.jsx("pre",{className:"font-mono whitespace-pre-wrap",children:s.length>500?s.slice(0,500)+"...":s})]}):c.jsx("div",{className:"rounded-md bg-muted p-3 font-mono text-xs leading-relaxed overflow-x-auto",children:JSON.stringify(e,null,2)})}function eXe({request:e,onApprove:r,onReject:n,compact:i=!1}){const[s,o]=y.useState(!1),a=async()=>{o(!0),r(e.id)},l=async()=>{o(!0),n(e.id)};return i?c.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 rounded-lg border bg-card",children:[c.jsx(_H,{toolName:e.toolName}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-xs font-medium truncate",children:e.toolName}),c.jsx(vH,{risk:e.risk}),c.jsx(xH,{level:e.policy.consentLevel}),c.jsx(bH,{expiresAt:e.expiresAt})]}),c.jsx("p",{className:"text-xs text-muted-foreground truncate",children:e.summary})]}),c.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[c.jsxs("button",{onClick:a,disabled:s,className:"inline-flex items-center gap-1 px-2.5 py-1 rounded-md text-xs font-medium bg-green-500/10 text-green-600 dark:text-green-400 hover:bg-green-500/20 disabled:opacity-50 transition-colors",children:[c.jsx(iD,{className:"h-3 w-3"}),"Approve"]}),c.jsxs("button",{onClick:l,disabled:s,className:"inline-flex items-center gap-1 px-2.5 py-1 rounded-md text-xs font-medium bg-red-500/10 text-red-600 dark:text-red-400 hover:bg-red-500/20 disabled:opacity-50 transition-colors",children:[c.jsx(D8,{className:"h-3 w-3"}),"Reject"]})]})]}):c.jsxs("div",{className:"rounded-lg border bg-card shadow-sm overflow-hidden",children:[c.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b bg-muted/30",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(_H,{toolName:e.toolName}),c.jsx("span",{className:"text-sm font-medium",children:e.toolName}),c.jsx(vH,{risk:e.risk}),c.jsx(xH,{level:e.policy.consentLevel})]}),c.jsx(bH,{expiresAt:e.expiresAt})]}),c.jsxs("div",{className:"p-4 space-y-3",children:[c.jsx("p",{className:"text-sm text-foreground",children:e.summary}),c.jsxs("div",{className:"space-y-1",children:[c.jsx("p",{className:"text-xs text-muted-foreground",children:e.policy.description}),!e.policy.knownTool&&c.jsx("p",{className:"text-xs text-red-600 dark:text-red-400",children:"Unknown tool: blocked behind dangerous consent until added to the active profile."})]}),c.jsx(QYe,{preview:e.preview,toolName:e.toolName})]}),c.jsxs("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t bg-muted/20",children:[c.jsxs("button",{onClick:l,disabled:s,className:"inline-flex items-center gap-1.5 px-4 py-2 rounded-md text-xs font-medium bg-red-500/10 text-red-600 dark:text-red-400 hover:bg-red-500/20 disabled:opacity-50 transition-colors",children:[c.jsx(D8,{className:"h-3.5 w-3.5"}),"Reject"]}),c.jsxs("button",{onClick:a,disabled:s,className:"inline-flex items-center gap-1.5 px-4 py-2 rounded-md text-xs font-medium bg-green-500/10 text-green-600 dark:text-green-400 hover:bg-green-500/20 disabled:opacity-50 transition-colors",children:[c.jsx(iD,{className:"h-3.5 w-3.5"}),"Approve"]})]})]})}function tXe({status:e}){const r={running:{icon:ir,label:"Running",color:"bg-blue-500/10 text-blue-600 dark:text-blue-400"},"awaiting-approval":{icon:yK,label:"Awaiting Approval",color:"bg-yellow-500/10 text-yellow-600 dark:text-yellow-400"},"needs-input":{icon:sg,label:"Needs Input",color:"bg-orange-500/10 text-orange-600 dark:text-orange-400"},completed:{icon:ml,label:"Completed",color:"bg-green-500/10 text-green-600 dark:text-green-400"},failed:{icon:Fh,label:"Failed",color:"bg-red-500/10 text-red-600 dark:text-red-400"}},{icon:n,label:i,color:s}=r[e];return c.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium ${s}`,children:[c.jsx(n,{className:`h-3 w-3 ${e==="running"?"animate-spin":""}`}),i]})}function rXe({className:e="",compact:r=!1,sessionId:n,onApproveAllEnabled:i}){const{queue:s,approve:o,reject:a,approveAllForSession:l}=ZYe(n),{policy:d}=JYe(),[u,f]=y.useState(!1),p=y.useMemo(()=>n?s.filter(v=>v.sessionId===n):s,[s,n]),g=async()=>{if(!n||u)return;f(!0),await l(n)&&(i==null||i()),f(!1)};return p.length===0?null:c.jsxs("div",{className:`space-y-2 ${e}`,children:[c.jsxs("div",{className:"flex items-center justify-between px-1",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(tXe,{status:"awaiting-approval"}),c.jsxs("div",{className:"flex flex-col",children:[c.jsxs("span",{className:"text-xs text-muted-foreground",children:[p.length," pending ",p.length===1?"request":"requests"]}),d&&c.jsxs("span",{className:"text-xs text-muted-foreground",children:["Profile: ",c.jsx("span",{className:"font-medium text-foreground",children:d.activeProfileName??"custom"})," ","• ",d.toolCount," configured tools • unknown tools require dangerous consent"]})]})]}),n&&p.length>0&&c.jsx("button",{onClick:g,disabled:u,className:"text-xs text-green-600 hover:text-green-500 dark:text-green-400 dark:hover:text-green-300 disabled:opacity-50 disabled:cursor-not-allowed",children:u?"Approving...":"Approve all in this session"})]}),c.jsx("div",{className:"space-y-2",children:p.map(v=>c.jsx(eXe,{request:v,onApprove:o,onReject:a,compact:r},v.id))})]})}const wH=5e3;let nXe=0,D1=[],p4=new Set;function dE(e,r){D1.push({id:nXe++,ts:Date.now(),type:e,raw:r}),D1.length>wH&&(D1=D1.slice(-wH)),p4.forEach(n=>n())}function iXe(){D1=[],p4.forEach(e=>e())}function sXe(){const[,e]=y.useState(0);return y.useEffect(()=>{const r=()=>e(n=>n+1);return p4.add(r),()=>{p4.delete(r)}},[]),D1}const oXe={request:"text-orange-400",token:"text-gray-400",tool_call_delta:"text-blue-400",tool_start:"text-yellow-400",tool_output:"text-green-400",tool_result:"text-emerald-400",thinking:"text-purple-400",done:"text-gray-500",error:"text-red-400"},hE=20;function aXe({onClose:e}){const r=sXe(),n=y.useRef(null),[i,s]=y.useState(!0),[o,a]=y.useState(""),[l,d]=y.useState(!1),[u,f]=y.useState(new Set),p=y.useCallback(S=>{f(k=>{const C=new Set(k);return C.has(S)?C.delete(S):C.add(S),C})},[]),g=o?r.filter(S=>S.type.includes(o)||S.raw.includes(o)):r,v=rR({count:g.length,getScrollElement:()=>n.current,estimateSize:()=>hE,overscan:30}),b=()=>{const S=g.map(k=>`${new Date(k.ts).toISOString().slice(11,23)} ${k.type} ${k.raw}`).join(`
1163
1163
  `);navigator.clipboard.writeText(S),d(!0),setTimeout(()=>d(!1),1500)};y.useEffect(()=>{i&&g.length>0&&v.scrollToIndex(g.length-1,{align:"end"})},[g.length,i]);const _=y.useCallback(()=>{const S=n.current;if(!S)return;const k=S.scrollHeight-S.scrollTop-S.clientHeight<40;s(k)},[]);return c.jsxs("div",{className:"flex flex-col h-full bg-[#0d1117] text-[#c9d1d9] text-xs font-mono",children:[c.jsxs("div",{className:"flex items-center justify-between px-3 py-1.5 border-b border-zinc-700/60 shrink-0",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-xs font-semibold text-zinc-400 uppercase tracking-wider",children:"SSE Debug"}),c.jsxs("span",{className:"text-2xs text-zinc-500",children:[g.length,"/",r.length]})]}),c.jsxs("div",{className:"flex items-center gap-1",children:[c.jsx("input",{type:"text",placeholder:"Filter...",value:o,onChange:S=>a(S.target.value),className:"h-5 w-28 px-1.5 text-2xs rounded bg-zinc-800 border border-zinc-700 text-zinc-300 placeholder-zinc-500 focus:outline-none focus:border-blue-500"}),c.jsx(_e,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:b,title:"Copy all events",children:l?c.jsx(_s,{className:"h-3 w-3 text-green-400"}):c.jsx(Nc,{className:"h-3 w-3"})}),c.jsx(_e,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:iXe,children:c.jsx(Lh,{className:"h-3 w-3"})}),c.jsx(_e,{variant:"ghost",size:"icon",className:"h-5 w-5",onClick:e,children:c.jsx(ti,{className:"h-3 w-3"})})]})]}),c.jsx("div",{ref:n,onScroll:_,className:"flex-1 overflow-y-auto overflow-x-hidden",children:c.jsx("div",{style:{height:`${v.getTotalSize()}px`,position:"relative",width:"100%"},children:v.getVirtualItems().map(S=>{const k=g[S.index],C=new Date(k.ts).toISOString().slice(11,23),j=oXe[k.type]??"text-zinc-400",E=k.raw.length>120,N=u.has(k.id),A=E&&!N?k.raw.slice(0,120)+"…":k.raw;return c.jsxs("div",{"data-index":S.index,ref:v.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${S.start}px)`},className:Fe("flex gap-2 px-2 hover:bg-zinc-800/50 leading-tight cursor-pointer select-none",N?"items-start py-1 bg-zinc-800/30":"items-center"),onClick:()=>p(k.id),children:[c.jsx("span",{className:"text-zinc-600 shrink-0 w-20",style:{minHeight:hE},children:C}),c.jsx("span",{className:Fe("shrink-0 w-28 text-right",j),style:{minHeight:hE},children:k.type}),c.jsxs("span",{className:Fe("text-zinc-400 min-w-0",N?"break-all whitespace-pre-wrap":"truncate"),children:[A,E&&!N&&c.jsx("span",{className:"text-zinc-600 ml-1",children:"▸"})]})]},k.id)})})}),!i&&c.jsx("div",{className:"absolute bottom-2 right-4",children:c.jsx(_e,{variant:"outline",size:"icon",className:"h-6 w-6 rounded-full bg-zinc-800 border-zinc-600",onClick:()=>{s(!0),v.scrollToIndex(g.length-1,{align:"end"})},children:c.jsx(nK,{className:"h-3 w-3"})})})]})}function lXe(e,r=[]){let n=[];function i(o,a){const l=y.createContext(a),d=n.length;n=[...n,a];const u=p=>{var k;const{scope:g,children:v,...b}=p,_=((k=g==null?void 0:g[e])==null?void 0:k[d])||l,S=y.useMemo(()=>b,Object.values(b));return c.jsx(_.Provider,{value:S,children:v})};u.displayName=o+"Provider";function f(p,g){var _;const v=((_=g==null?void 0:g[e])==null?void 0:_[d])||l,b=y.useContext(v);if(b)return b;if(a!==void 0)return a;throw new Error(`\`${p}\` must be used within \`${o}\``)}return[u,f]}const s=()=>{const o=n.map(a=>y.createContext(a));return function(l){const d=(l==null?void 0:l[e])||o;return y.useMemo(()=>({[`__scope${e}`]:{...l,[e]:d}}),[l,d])}};return s.scopeName=e,[i,cXe(s,...r)]}function cXe(...e){const r=e[0];if(e.length===1)return r;const n=()=>{const i=e.map(s=>({useScope:s(),scopeName:s.scopeName}));return function(o){const a=i.reduce((l,{useScope:d,scopeName:u})=>{const p=d(o)[`__scope${u}`];return{...l,...p}},{});return y.useMemo(()=>({[`__scope${r.scopeName}`]:a}),[a])}};return n.scopeName=r.scopeName,n}function Woe(e){const r=y.useRef({value:e,previous:e});return y.useMemo(()=>(r.current.value!==e&&(r.current.previous=r.current.value,r.current.value=e),r.current.previous),[e])}function uXe(e){const r=dXe(e),n=y.forwardRef((i,s)=>{const{children:o,...a}=i,l=y.Children.toArray(o),d=l.find(fXe);if(d){const u=d.props.children,f=l.map(p=>p===d?y.Children.count(u)>1?y.Children.only(null):y.isValidElement(u)?u.props.children:null:p);return c.jsx(r,{...a,ref:s,children:y.isValidElement(u)?y.cloneElement(u,void 0,f):null})}return c.jsx(r,{...a,ref:s,children:o})});return n.displayName=`${e}.Slot`,n}function dXe(e){const r=y.forwardRef((n,i)=>{const{children:s,...o}=n;if(y.isValidElement(s)){const a=mXe(s),l=pXe(o,s.props);return s.type!==y.Fragment&&(l.ref=i?no(i,a):a),y.cloneElement(s,l)}return y.Children.count(s)>1?y.Children.only(null):null});return r.displayName=`${e}.SlotClone`,r}var hXe=Symbol("radix.slottable");function fXe(e){return y.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===hXe}function pXe(e,r){const n={...r};for(const i in r){const s=e[i],o=r[i];/^on[A-Z]/.test(i)?s&&o?n[i]=(...l)=>{const d=o(...l);return s(...l),d}:s&&(n[i]=s):i==="style"?n[i]={...s,...o}:i==="className"&&(n[i]=[s,o].filter(Boolean).join(" "))}return{...e,...n}}function mXe(e){var i,s;let r=(i=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:i.get,n=r&&"isReactWarning"in r&&r.isReactWarning;return n?e.ref:(r=(s=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:s.get,n=r&&"isReactWarning"in r&&r.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var gXe=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Uoe=gXe.reduce((e,r)=>{const n=uXe(`Primitive.${r}`),i=y.forwardRef((s,o)=>{const{asChild:a,...l}=s,d=a?n:r;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),c.jsx(d,{...l,ref:o})});return i.displayName=`Primitive.${r}`,{...e,[r]:i}},{}),d6="Switch",[yXe]=lXe(d6),[vXe,xXe]=yXe(d6),Voe=y.forwardRef((e,r)=>{const{__scopeSwitch:n,name:i,checked:s,defaultChecked:o,required:a,disabled:l,value:d="on",onCheckedChange:u,form:f,...p}=e,[g,v]=y.useState(null),b=ni(r,j=>v(j)),_=y.useRef(!1),S=g?f||!!g.closest("form"):!0,[k,C]=ip({prop:s,defaultProp:o??!1,onChange:u,caller:d6});return c.jsxs(vXe,{scope:n,checked:k,disabled:l,children:[c.jsx(Uoe.button,{type:"button",role:"switch","aria-checked":k,"aria-required":a,"data-state":Yoe(k),"data-disabled":l?"":void 0,disabled:l,value:d,...p,ref:b,onClick:fr(e.onClick,j=>{C(E=>!E),S&&(_.current=j.isPropagationStopped(),_.current||j.stopPropagation())})}),S&&c.jsx(Koe,{control:g,bubbles:!_.current,name:i,value:d,checked:k,required:a,disabled:l,form:f,style:{transform:"translateX(-100%)"}})]})});Voe.displayName=d6;var qoe="SwitchThumb",Goe=y.forwardRef((e,r)=>{const{__scopeSwitch:n,...i}=e,s=xXe(qoe,n);return c.jsx(Uoe.span,{"data-state":Yoe(s.checked),"data-disabled":s.disabled?"":void 0,...i,ref:r})});Goe.displayName=qoe;var bXe="SwitchBubbleInput",Koe=y.forwardRef(({__scopeSwitch:e,control:r,checked:n,bubbles:i=!0,...s},o)=>{const a=y.useRef(null),l=ni(a,o),d=Woe(n),u=WK(r);return y.useEffect(()=>{const f=a.current;if(!f)return;const p=window.HTMLInputElement.prototype,v=Object.getOwnPropertyDescriptor(p,"checked").set;if(d!==n&&v){const b=new Event("click",{bubbles:i});v.call(f,n),f.dispatchEvent(b)}},[d,n,i]),c.jsx("input",{type:"checkbox","aria-hidden":!0,defaultChecked:n,...s,tabIndex:-1,ref:l,style:{...s.style,...u,position:"absolute",pointerEvents:"none",opacity:0,margin:0}})});Koe.displayName=bXe;function Yoe(e){return e?"checked":"unchecked"}var Xoe=Voe,_Xe=Goe;const up=y.forwardRef(({className:e,...r},n)=>c.jsx(Xoe,{className:Fe("peer inline-flex h-5 w-9 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...r,ref:n,children:c.jsx(_Xe,{className:Fe("pointer-events-none block h-4 w-4 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-4 data-[state=unchecked]:translate-x-0")})}));up.displayName=Xoe.displayName;var VS="Ollama",wXe=.6,SXe=.1,Zoe="#fff",kXe=Zoe,CXe="#000",jXe=.75;function iw(e){"@babel/helpers - typeof";return iw=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},iw(e)}var NXe=["size","style"];function SH(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);r&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,i)}return n}function fE(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?SH(Object(n),!0).forEach(function(i){TXe(e,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):SH(Object(n)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(n,i))})}return e}function TXe(e,r,n){return r=EXe(r),r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function EXe(e){var r=AXe(e,"string");return iw(r)=="symbol"?r:String(r)}function AXe(e,r){if(iw(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var i=n.call(e,r);if(iw(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function OXe(e,r){if(e==null)return{};var n=RXe(e,r),i,s;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(s=0;s<o.length;s++)i=o[s],!(r.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(e,i)&&(n[i]=e[i])}return n}function RXe(e,r){if(e==null)return{};var n={},i=Object.keys(e),s,o;for(o=0;o<i.length;o++)s=i[o],!(r.indexOf(s)>=0)&&(n[s]=e[s]);return n}var sP=y.memo(function(e){var r=e.size,n=r===void 0?"1em":r,i=e.style,s=OXe(e,NXe);return c.jsxs("svg",fE(fE({fill:"currentColor",fillRule:"evenodd",height:n,style:fE({flex:"none",lineHeight:1},i),viewBox:"0 0 24 24",width:n,xmlns:"http://www.w3.org/2000/svg"},s),{},{children:[c.jsx("title",{children:VS}),c.jsx("path",{d:"M7.905 1.09c.216.085.411.225.588.41.295.306.544.744.734 1.263.191.522.315 1.1.362 1.68a5.054 5.054 0 012.049-.636l.051-.004c.87-.07 1.73.087 2.48.474.101.053.2.11.297.17.05-.569.172-1.134.36-1.644.19-.52.439-.957.733-1.264a1.67 1.67 0 01.589-.41c.257-.1.53-.118.796-.042.401.114.745.368 1.016.737.248.337.434.769.561 1.287.23.934.27 2.163.115 3.645l.053.04.026.019c.757.576 1.284 1.397 1.563 2.35.435 1.487.216 3.155-.534 4.088l-.018.021.002.003c.417.762.67 1.567.724 2.4l.002.03c.064 1.065-.2 2.137-.814 3.19l-.007.01.01.024c.472 1.157.62 2.322.438 3.486l-.006.039a.651.651 0 01-.747.536.648.648 0 01-.54-.742c.167-1.033.01-2.069-.48-3.123a.643.643 0 01.04-.617l.004-.006c.604-.924.854-1.83.8-2.72-.046-.779-.325-1.544-.8-2.273a.644.644 0 01.18-.886l.009-.006c.243-.159.467-.565.58-1.12a4.229 4.229 0 00-.095-1.974c-.205-.7-.58-1.284-1.105-1.683-.595-.454-1.383-.673-2.38-.61a.653.653 0 01-.632-.371c-.314-.665-.772-1.141-1.343-1.436a3.288 3.288 0 00-1.772-.332c-1.245.099-2.343.801-2.67 1.686a.652.652 0 01-.61.425c-1.067.002-1.893.252-2.497.703-.522.39-.878.935-1.066 1.588a4.07 4.07 0 00-.068 1.886c.112.558.331 1.02.582 1.269l.008.007c.212.207.257.53.109.785-.36.622-.629 1.549-.673 2.44-.05 1.018.186 1.902.719 2.536l.016.019a.643.643 0 01.095.69c-.576 1.236-.753 2.252-.562 3.052a.652.652 0 01-1.269.298c-.243-1.018-.078-2.184.473-3.498l.014-.035-.008-.012a4.339 4.339 0 01-.598-1.309l-.005-.019a5.764 5.764 0 01-.177-1.785c.044-.91.278-1.842.622-2.59l.012-.026-.002-.002c-.293-.418-.51-.953-.63-1.545l-.005-.024a5.352 5.352 0 01.093-2.49c.262-.915.777-1.701 1.536-2.269.06-.045.123-.09.186-.132-.159-1.493-.119-2.73.112-3.67.127-.518.314-.95.562-1.287.27-.368.614-.622 1.015-.737.266-.076.54-.059.797.042zm4.116 9.09c.936 0 1.8.313 2.446.855.63.527 1.005 1.235 1.005 1.94 0 .888-.406 1.58-1.133 2.022-.62.375-1.451.557-2.403.557-1.009 0-1.871-.259-2.493-.734-.617-.47-.963-1.13-.963-1.845 0-.707.398-1.417 1.056-1.946.668-.537 1.55-.849 2.485-.849zm0 .896a3.07 3.07 0 00-1.916.65c-.461.37-.722.835-.722 1.25 0 .428.21.829.61 1.134.455.347 1.124.548 1.943.548.799 0 1.473-.147 1.932-.426.463-.28.7-.686.7-1.257 0-.423-.246-.89-.683-1.256-.484-.405-1.14-.643-1.864-.643zm.662 1.21l.004.004c.12.151.095.37-.056.49l-.292.23v.446a.375.375 0 01-.376.373.375.375 0 01-.376-.373v-.46l-.271-.218a.347.347 0 01-.052-.49.353.353 0 01.494-.051l.215.172.22-.174a.353.353 0 01.49.051zm-5.04-1.919c.478 0 .867.39.867.871a.87.87 0 01-.868.871.87.87 0 01-.867-.87.87.87 0 01.867-.872zm8.706 0c.48 0 .868.39.868.871a.87.87 0 01-.868.871.87.87 0 01-.867-.87.87.87 0 01.867-.872zM7.44 2.3l-.003.002a.659.659 0 00-.285.238l-.005.006c-.138.189-.258.467-.348.832-.17.692-.216 1.631-.124 2.782.43-.128.899-.208 1.404-.237l.01-.001.019-.034c.046-.082.095-.161.148-.239.123-.771.022-1.692-.253-2.444-.134-.364-.297-.65-.453-.813a.628.628 0 00-.107-.09L7.44 2.3zm9.174.04l-.002.001a.628.628 0 00-.107.09c-.156.163-.32.45-.453.814-.29.794-.387 1.776-.23 2.572l.058.097.008.014h.03a5.184 5.184 0 011.466.212c.086-1.124.038-2.043-.128-2.722-.09-.365-.21-.643-.349-.832l-.004-.006a.659.659 0 00-.285-.239h-.004z"})]}))});function sw(e){"@babel/helpers - typeof";return sw=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},sw(e)}function kH(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);r&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,i)}return n}function MXe(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?kH(Object(n),!0).forEach(function(i){PXe(e,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):kH(Object(n)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(n,i))})}return e}function PXe(e,r,n){return r=LXe(r),r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function LXe(e){var r=$Xe(e,"string");return sw(r)=="symbol"?r:String(r)}function $Xe(e,r){if(sw(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var i=n.call(e,r);if(sw(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function DXe(e){if(e==null)throw new TypeError("Cannot destructure "+e)}var IXe=y.memo(function(e){var r=Object.assign({},(DXe(e),e));return c.jsx(bl,MXe({Icon:sP,"aria-label":VS,background:kXe,color:CXe,iconMultiple:jXe},r))});function ow(e){"@babel/helpers - typeof";return ow=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},ow(e)}var BXe=["size","style"];function CH(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);r&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,i)}return n}function pE(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?CH(Object(n),!0).forEach(function(i){zXe(e,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):CH(Object(n)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(n,i))})}return e}function zXe(e,r,n){return r=FXe(r),r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function FXe(e){var r=HXe(e,"string");return ow(r)=="symbol"?r:String(r)}function HXe(e,r){if(ow(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var i=n.call(e,r);if(ow(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function WXe(e,r){if(e==null)return{};var n=UXe(e,r),i,s;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(s=0;s<o.length;s++)i=o[s],!(r.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(e,i)&&(n[i]=e[i])}return n}function UXe(e,r){if(e==null)return{};var n={},i=Object.keys(e),s,o;for(o=0;o<i.length;o++)s=i[o],!(r.indexOf(s)>=0)&&(n[s]=e[s]);return n}var Joe=y.memo(function(e){var r=e.size,n=r===void 0?"1em":r,i=e.style,s=WXe(e,BXe);return c.jsxs("svg",pE(pE({fill:"currentColor",fillRule:"evenodd",height:n,style:pE({flex:"none",lineHeight:1},i),viewBox:"0 0 87 24",xmlns:"http://www.w3.org/2000/svg"},s),{},{children:[c.jsx("title",{children:VS}),c.jsx("path",{d:"M11.333 2c-2.959 0-5.272.943-6.94 2.884C2.78 6.717 2 9.09 2 12.027c0 2.911.78 5.283 2.394 7.116C6.06 21.03 8.374 22 11.333 22c2.931 0 5.244-.943 6.939-2.83 1.614-1.806 2.42-4.178 2.42-7.143s-.806-5.364-2.42-7.17C16.577 2.943 14.264 2 11.332 2zm0 2.776c1.99 0 3.523.62 4.599 1.914 1.049 1.294 1.587 3.073 1.587 5.337s-.538 4.016-1.587 5.283c-1.076 1.267-2.609 1.914-4.6 1.914-1.99 0-3.55-.674-4.625-1.995-1.05-1.294-1.56-3.019-1.56-5.202 0-2.21.51-3.935 1.56-5.23 1.102-1.347 2.636-2.02 4.626-2.02zM22.979 2v19.623h3.066V2h-3.066zm6.159 0v19.623h3.066V2h-3.066zm12.21 5.31c-1.775 0-3.173.296-4.195.943-1.21.701-1.964 1.833-2.26 3.37l3.04.242c.161-.728.564-1.267 1.156-1.617.511-.323 1.184-.458 2.044-.458 1.99 0 2.986.89 2.986 2.722v.54l-3.04.08c-2.044.054-3.63.485-4.76 1.294-1.237.835-1.829 2.048-1.829 3.612 0 1.159.43 2.102 1.29 2.857.835.728 1.964 1.105 3.417 1.105 1.21 0 2.259-.216 3.146-.62.78-.377 1.453-.89 1.99-1.59v1.833h2.852v-8.895c0-1.698-.43-2.992-1.291-3.882-.969-1.024-2.502-1.536-4.546-1.536zm2.77 7.951v.701c0 1.078-.43 1.968-1.237 2.669-.806.674-1.802 1.024-2.985 1.024-.672 0-1.21-.189-1.64-.512-.431-.324-.62-.728-.62-1.213 0-1.614 1.129-2.473 3.41-2.58l3.073-.089zM56.572 7.31c-1.344 0-2.609.593-3.765 1.806V7.687H49.74v13.936h3.066v-8.356c0-.917.269-1.725.807-2.372.538-.7 1.237-1.024 2.125-1.024 1.828 0 2.743 1.05 2.743 3.18v8.572h3.066v-8.518c0-1.024.242-1.806.78-2.372.511-.593 1.13-.862 1.883-.862 1.075 0 1.829.242 2.313.754.457.486.699 1.294.699 2.4v8.598h3.066v-9.138c0-1.536-.484-2.776-1.398-3.746-.969-.97-2.152-1.429-3.578-1.429-.941 0-1.72.162-2.34.485-.699.324-1.371.917-2.017 1.78-.887-1.51-2.34-2.265-4.384-2.265zm22.593 0c-1.775 0-3.174.296-4.196.943-1.21.701-1.963 1.833-2.26 3.37l3.04.242c.161-.728.565-1.267 1.156-1.617.511-.323 1.184-.458 2.044-.458 1.99 0 2.986.89 2.986 2.722v.54l-3.04.08c-2.043.054-3.63.485-4.76 1.294-1.237.835-1.829 2.048-1.829 3.612 0 1.159.43 2.102 1.291 2.857.834.728 1.964 1.105 3.416 1.105 1.21 0 2.26-.216 3.147-.62.78-.377 1.452-.89 1.99-1.59v1.833H85v-8.895c0-1.698-.43-2.992-1.291-3.882-.968-1.024-2.501-1.536-4.545-1.536zm2.77 7.951v.701c0 1.078-.43 1.968-1.237 2.669-.807.674-1.802 1.024-2.986 1.024-.672 0-1.21-.189-1.64-.512-.43-.324-.619-.728-.619-1.213 0-1.614 1.128-2.473 3.41-2.58l3.072-.089z"})]}))});function aw(e){"@babel/helpers - typeof";return aw=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},aw(e)}function jH(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);r&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,i)}return n}function VXe(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?jH(Object(n),!0).forEach(function(i){qXe(e,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):jH(Object(n)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(n,i))})}return e}function qXe(e,r,n){return r=GXe(r),r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function GXe(e){var r=KXe(e,"string");return aw(r)=="symbol"?r:String(r)}function KXe(e,r){if(aw(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var i=n.call(e,r);if(aw(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function YXe(e){if(e==null)throw new TypeError("Cannot destructure "+e)}var XXe=y.memo(function(e){var r=Object.assign({},(YXe(e),e));return c.jsx(_l,VXe({Icon:sP,Text:Joe,"aria-label":VS,spaceMultiple:SXe,textMultiple:wXe},r))}),my=sP;my.Text=Joe;my.Combine=XXe;my.Avatar=IXe;my.colorPrimary=Zoe;my.title=VS;var G0="Qwen",ZXe=.7,JXe=.2,Qoe="#615ced",QXe="linear-gradient(to right, #6336E7, #6F69F7)",eZe=Qoe,tZe="#fff",rZe=.75;function lw(e){"@babel/helpers - typeof";return lw=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},lw(e)}var nZe=["size","style"];function NH(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);r&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,i)}return n}function mE(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?NH(Object(n),!0).forEach(function(i){iZe(e,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):NH(Object(n)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(n,i))})}return e}function iZe(e,r,n){return r=sZe(r),r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function sZe(e){var r=oZe(e,"string");return lw(r)=="symbol"?r:String(r)}function oZe(e,r){if(lw(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var i=n.call(e,r);if(lw(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function aZe(e,r){if(e==null)return{};var n=lZe(e,r),i,s;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(s=0;s<o.length;s++)i=o[s],!(r.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(e,i)&&(n[i]=e[i])}return n}function lZe(e,r){if(e==null)return{};var n={},i=Object.keys(e),s,o;for(o=0;o<i.length;o++)s=i[o],!(r.indexOf(s)>=0)&&(n[s]=e[s]);return n}var oP=y.memo(function(e){var r=e.size,n=r===void 0?"1em":r,i=e.style,s=aZe(e,nZe);return c.jsxs("svg",mE(mE({fill:"currentColor",fillRule:"evenodd",height:n,style:mE({flex:"none",lineHeight:1},i),viewBox:"0 0 24 24",width:n,xmlns:"http://www.w3.org/2000/svg"},s),{},{children:[c.jsx("title",{children:G0}),c.jsx("path",{d:"M12.604 1.34c.393.69.784 1.382 1.174 2.075a.18.18 0 00.157.091h5.552c.174 0 .322.11.446.327l1.454 2.57c.19.337.24.478.024.837-.26.43-.513.864-.76 1.3l-.367.658c-.106.196-.223.28-.04.512l2.652 4.637c.172.301.111.494-.043.77-.437.785-.882 1.564-1.335 2.34-.159.272-.352.375-.68.37-.777-.016-1.552-.01-2.327.016a.099.099 0 00-.081.05 575.097 575.097 0 01-2.705 4.74c-.169.293-.38.363-.725.364-.997.003-2.002.004-3.017.002a.537.537 0 01-.465-.271l-1.335-2.323a.09.09 0 00-.083-.049H4.982c-.285.03-.553-.001-.805-.092l-1.603-2.77a.543.543 0 01-.002-.54l1.207-2.12a.198.198 0 000-.197 550.951 550.951 0 01-1.875-3.272l-.79-1.395c-.16-.31-.173-.496.095-.965.465-.813.927-1.625 1.387-2.436.132-.234.304-.334.584-.335a338.3 338.3 0 012.589-.001.124.124 0 00.107-.063l2.806-4.895a.488.488 0 01.422-.246c.524-.001 1.053 0 1.583-.006L11.704 1c.341-.003.724.032.9.34zm-3.432.403a.06.06 0 00-.052.03L6.254 6.788a.157.157 0 01-.135.078H3.253c-.056 0-.07.025-.041.074l5.81 10.156c.025.042.013.062-.034.063l-2.795.015a.218.218 0 00-.2.116l-1.32 2.31c-.044.078-.021.118.068.118l5.716.008c.046 0 .08.02.104.061l1.403 2.454c.046.081.092.082.139 0l5.006-8.76.783-1.382a.055.055 0 01.096 0l1.424 2.53a.122.122 0 00.107.062l2.763-.02a.04.04 0 00.035-.02.041.041 0 000-.04l-2.9-5.086a.108.108 0 010-.113l.293-.507 1.12-1.977c.024-.041.012-.062-.035-.062H9.2c-.059 0-.073-.026-.043-.077l1.434-2.505a.107.107 0 000-.114L9.225 1.774a.06.06 0 00-.053-.031zm6.29 8.02c.046 0 .058.02.034.06l-.832 1.465-2.613 4.585a.056.056 0 01-.05.029.058.058 0 01-.05-.029L8.498 9.841c-.02-.034-.01-.052.028-.054l.216-.012 6.722-.012z"})]}))});function cw(e){"@babel/helpers - typeof";return cw=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},cw(e)}function TH(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);r&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,i)}return n}function cZe(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?TH(Object(n),!0).forEach(function(i){uZe(e,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):TH(Object(n)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(n,i))})}return e}function uZe(e,r,n){return r=dZe(r),r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function dZe(e){var r=hZe(e,"string");return cw(r)=="symbol"?r:String(r)}function hZe(e,r){if(cw(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var i=n.call(e,r);if(cw(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function fZe(e){if(e==null)throw new TypeError("Cannot destructure "+e)}var pZe=y.memo(function(e){var r=Object.assign({},(fZe(e),e));return c.jsx(bl,cZe({Icon:oP,"aria-label":G0,background:eZe,color:tZe,iconMultiple:rZe},r))});function uw(e){"@babel/helpers - typeof";return uw=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},uw(e)}var mZe=["size","style"];function EH(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);r&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,i)}return n}function gE(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?EH(Object(n),!0).forEach(function(i){gZe(e,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):EH(Object(n)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(n,i))})}return e}function gZe(e,r,n){return r=yZe(r),r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function yZe(e){var r=vZe(e,"string");return uw(r)=="symbol"?r:String(r)}function vZe(e,r){if(uw(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var i=n.call(e,r);if(uw(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function xZe(e,r){if(e==null)return{};var n=bZe(e,r),i,s;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(s=0;s<o.length;s++)i=o[s],!(r.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(e,i)&&(n[i]=e[i])}return n}function bZe(e,r){if(e==null)return{};var n={},i=Object.keys(e),s,o;for(o=0;o<i.length;o++)s=i[o],!(r.indexOf(s)>=0)&&(n[s]=e[s]);return n}var eae=y.memo(function(e){var r=e.size,n=r===void 0?"1em":r,i=e.style,s=xZe(e,mZe),o=aAe(G0),a=o.id,l=o.fill;return c.jsxs("svg",gE(gE({height:n,style:gE({flex:"none",lineHeight:1},i),viewBox:"0 0 24 24",width:n,xmlns:"http://www.w3.org/2000/svg"},s),{},{children:[c.jsx("title",{children:G0}),c.jsx("path",{d:"M12.604 1.34c.393.69.784 1.382 1.174 2.075a.18.18 0 00.157.091h5.552c.174 0 .322.11.446.327l1.454 2.57c.19.337.24.478.024.837-.26.43-.513.864-.76 1.3l-.367.658c-.106.196-.223.28-.04.512l2.652 4.637c.172.301.111.494-.043.77-.437.785-.882 1.564-1.335 2.34-.159.272-.352.375-.68.37-.777-.016-1.552-.01-2.327.016a.099.099 0 00-.081.05 575.097 575.097 0 01-2.705 4.74c-.169.293-.38.363-.725.364-.997.003-2.002.004-3.017.002a.537.537 0 01-.465-.271l-1.335-2.323a.09.09 0 00-.083-.049H4.982c-.285.03-.553-.001-.805-.092l-1.603-2.77a.543.543 0 01-.002-.54l1.207-2.12a.198.198 0 000-.197 550.951 550.951 0 01-1.875-3.272l-.79-1.395c-.16-.31-.173-.496.095-.965.465-.813.927-1.625 1.387-2.436.132-.234.304-.334.584-.335a338.3 338.3 0 012.589-.001.124.124 0 00.107-.063l2.806-4.895a.488.488 0 01.422-.246c.524-.001 1.053 0 1.583-.006L11.704 1c.341-.003.724.032.9.34zm-3.432.403a.06.06 0 00-.052.03L6.254 6.788a.157.157 0 01-.135.078H3.253c-.056 0-.07.025-.041.074l5.81 10.156c.025.042.013.062-.034.063l-2.795.015a.218.218 0 00-.2.116l-1.32 2.31c-.044.078-.021.118.068.118l5.716.008c.046 0 .08.02.104.061l1.403 2.454c.046.081.092.082.139 0l5.006-8.76.783-1.382a.055.055 0 01.096 0l1.424 2.53a.122.122 0 00.107.062l2.763-.02a.04.04 0 00.035-.02.041.041 0 000-.04l-2.9-5.086a.108.108 0 010-.113l.293-.507 1.12-1.977c.024-.041.012-.062-.035-.062H9.2c-.059 0-.073-.026-.043-.077l1.434-2.505a.107.107 0 000-.114L9.225 1.774a.06.06 0 00-.053-.031zm6.29 8.02c.046 0 .058.02.034.06l-.832 1.465-2.613 4.585a.056.056 0 01-.05.029.058.058 0 01-.05-.029L8.498 9.841c-.02-.034-.01-.052.028-.054l.216-.012 6.722-.012z",fill:l,fillRule:"nonzero"}),c.jsx("defs",{children:c.jsxs("linearGradient",{id:a,x1:"0%",x2:"100%",y1:"0%",y2:"0%",children:[c.jsx("stop",{offset:"0%",stopColor:"#6336E7",stopOpacity:".84"}),c.jsx("stop",{offset:"100%",stopColor:"#6F69F7",stopOpacity:".84"})]})})]}))});function dw(e){"@babel/helpers - typeof";return dw=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},dw(e)}var _Ze=["size","style"];function AH(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);r&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,i)}return n}function yE(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?AH(Object(n),!0).forEach(function(i){wZe(e,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):AH(Object(n)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(n,i))})}return e}function wZe(e,r,n){return r=SZe(r),r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function SZe(e){var r=kZe(e,"string");return dw(r)=="symbol"?r:String(r)}function kZe(e,r){if(dw(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var i=n.call(e,r);if(dw(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function CZe(e,r){if(e==null)return{};var n=jZe(e,r),i,s;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(s=0;s<o.length;s++)i=o[s],!(r.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(e,i)&&(n[i]=e[i])}return n}function jZe(e,r){if(e==null)return{};var n={},i=Object.keys(e),s,o;for(o=0;o<i.length;o++)s=i[o],!(r.indexOf(s)>=0)&&(n[s]=e[s]);return n}var tae=y.memo(function(e){var r=e.size,n=r===void 0?"1em":r,i=e.style,s=CZe(e,_Ze);return c.jsxs("svg",yE(yE({fill:"currentColor",fillRule:"evenodd",height:n,style:yE({flex:"none",lineHeight:1},i),viewBox:"0 0 75 24",xmlns:"http://www.w3.org/2000/svg"},s),{},{children:[c.jsx("title",{children:G0}),c.jsx("path",{d:"M11.425 14.13h3.642l1.529 1.795a7.89 7.89 0 002.166-2.832 8.36 8.36 0 00.771-3.562c0-2.03-.624-3.664-1.874-4.905-1.24-1.25-2.884-1.874-4.931-1.874-1.028 0-1.99.186-2.885.558A6.99 6.99 0 007.45 4.932 8.576 8.576 0 005.656 7.67a8.354 8.354 0 00-.625 3.19c0 2.003.611 3.643 1.834 4.919 1.223 1.276 2.779 1.914 4.666 1.914.39 0 .793-.031 1.21-.093.425-.062.868-.16 1.329-.293l-2.645-3.177zM18.07 22l-2.127-2.46c-.753.293-1.48.51-2.18.652a9.84 9.84 0 01-2.073.226c-2.97 0-5.326-.85-7.072-2.552C2.873 16.164 2 13.865 2 10.966c0-1.577.28-3.052.837-4.426a10.148 10.148 0 012.406-3.576A10.427 10.427 0 018.713.758C10.025.253 11.429 0 12.927 0c2.915 0 5.25.86 7.005 2.579 1.755 1.72 2.632 4.01 2.632 6.872 0 1.764-.354 3.399-1.063 4.905a10.156 10.156 0 01-3.031 3.776L21.714 22H18.07zm5.743-14.675h2.884l2.047 6.433.054.16c.248.789.38 1.373.399 1.755.097-.302.221-.62.372-.958.16-.345.354-.713.585-1.103l4.227-7.218 2.06 7.43c.08.275.146.559.2.851.053.293.097.63.133 1.01.132-.372.265-.708.398-1.01.142-.3.28-.562.412-.784l3.816-6.567h3.243L36.097 20.71l-2.127-7.045a8.683 8.683 0 01-.213-.798 17.846 17.846 0 01-.146-.97 69.17 69.17 0 01-.519 1.063c-.15.302-.265.514-.345.638l-4.28 7.112-4.653-13.385zm24.392 4.785h6.5c-.026-.85-.292-1.52-.797-2.007-.496-.497-1.166-.745-2.008-.745-.957 0-1.768.248-2.432.745-.665.496-1.086 1.165-1.263 2.007zm6.34 3.948l2.061 1.608c-.735.966-1.533 1.67-2.392 2.114-.86.443-1.848.665-2.965.665-1.87 0-3.38-.563-4.533-1.689-1.152-1.134-1.728-2.623-1.728-4.466 0-2.162.66-3.935 1.98-5.317 1.33-1.391 3.018-2.087 5.066-2.087 1.71 0 3.07.532 4.08 1.595 1.02 1.055 1.53 2.473 1.53 4.254 0 .15-.01.345-.027.585-.01.23-.027.51-.054.837h-9.61c0 1.143.288 2.056.864 2.738.576.674 1.342 1.01 2.3 1.01.664 0 1.293-.159 1.887-.478a4.633 4.633 0 001.542-1.369zm14.317 3.868l.957-7.244c.018-.133.031-.27.04-.412.009-.151.013-.368.013-.652 0-.824-.2-1.453-.598-1.887-.399-.444-.98-.665-1.741-.665-1.188 0-2.118.385-2.792 1.156-.673.763-1.112 1.937-1.316 3.523l-.797 6.181H59.77l1.661-12.601h2.752l-.213 1.515c.727-.664 1.476-1.156 2.247-1.475a6.5 6.5 0 012.486-.479c1.293 0 2.3.341 3.017 1.024.727.673 1.09 1.622 1.09 2.845 0 .31-.018.673-.053 1.09-.036.407-.089.886-.16 1.435l-.877 6.647h-2.858z"})]}))});function hw(e){"@babel/helpers - typeof";return hw=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},hw(e)}var NZe=["type","extraStyle"];function OH(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);r&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,i)}return n}function RH(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?OH(Object(n),!0).forEach(function(i){TZe(e,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):OH(Object(n)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(n,i))})}return e}function TZe(e,r,n){return r=EZe(r),r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function EZe(e){var r=AZe(e,"string");return hw(r)=="symbol"?r:String(r)}function AZe(e,r){if(hw(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var i=n.call(e,r);if(hw(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function OZe(e,r){if(e==null)return{};var n=RZe(e,r),i,s;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(s=0;s<o.length;s++)i=o[s],!(r.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(e,i)&&(n[i]=e[i])}return n}function RZe(e,r){if(e==null)return{};var n={},i=Object.keys(e),s,o;for(o=0;o<i.length;o++)s=i[o],!(r.indexOf(s)>=0)&&(n[s]=e[s]);return n}var MZe=y.memo(function(e){var r=e.type,n=r===void 0?"mono":r,i=e.extraStyle,s=OZe(e,NZe),o=n==="color"?eae:oP;return c.jsx(_l,RH({Icon:o,Text:tae,"aria-label":G0,extraStyle:RH({fontWeight:500},i),spaceMultiple:JXe,textMultiple:ZXe},s))}),kd=oP;kd.Color=eae;kd.Text=tae;kd.Combine=MZe;kd.Avatar=pZe;kd.colorPrimary=Qoe;kd.colorGradient=QXe;kd.title=G0;var Vh="Meta",PZe=.75,LZe=.2,$Ze="#1d65c1",rae="linear-gradient(45deg, #007FF8, #0668E1, #007FF8)",DZe=rae,IZe="#fff",BZe=.75;function fw(e){"@babel/helpers - typeof";return fw=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},fw(e)}var zZe=["size","style"];function MH(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);r&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,i)}return n}function vE(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?MH(Object(n),!0).forEach(function(i){FZe(e,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):MH(Object(n)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(n,i))})}return e}function FZe(e,r,n){return r=HZe(r),r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function HZe(e){var r=WZe(e,"string");return fw(r)=="symbol"?r:String(r)}function WZe(e,r){if(fw(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var i=n.call(e,r);if(fw(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function UZe(e,r){if(e==null)return{};var n=VZe(e,r),i,s;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(s=0;s<o.length;s++)i=o[s],!(r.indexOf(i)>=0)&&Object.prototype.propertyIsEnumerable.call(e,i)&&(n[i]=e[i])}return n}function VZe(e,r){if(e==null)return{};var n={},i=Object.keys(e),s,o;for(o=0;o<i.length;o++)s=i[o],!(r.indexOf(s)>=0)&&(n[s]=e[s]);return n}var aP=y.memo(function(e){var r=e.size,n=r===void 0?"1em":r,i=e.style,s=UZe(e,zZe);return c.jsxs("svg",vE(vE({fill:"currentColor",fillRule:"evenodd",height:n,style:vE({flex:"none",lineHeight:1},i),viewBox:"0 0 24 24",width:n,xmlns:"http://www.w3.org/2000/svg"},s),{},{children:[c.jsx("title",{children:Vh}),c.jsx("path",{d:"M6.897 4c1.915 0 3.516.932 5.43 3.376l.282-.373c.19-.246.383-.484.58-.71l.313-.35C14.588 4.788 15.792 4 17.225 4c1.273 0 2.469.557 3.491 1.516l.218.213c1.73 1.765 2.917 4.71 3.053 8.026l.011.392.002.25c0 1.501-.28 2.759-.818 3.7l-.14.23-.108.153c-.301.42-.664.758-1.086 1.009l-.265.142-.087.04a3.493 3.493 0 01-.302.118 4.117 4.117 0 01-1.33.208c-.524 0-.996-.067-1.438-.215-.614-.204-1.163-.56-1.726-1.116l-.227-.235c-.753-.812-1.534-1.976-2.493-3.586l-1.43-2.41-.544-.895-1.766 3.13-.343.592C7.597 19.156 6.227 20 4.356 20c-1.21 0-2.205-.42-2.936-1.182l-.168-.184c-.484-.573-.837-1.311-1.043-2.189l-.067-.32a8.69 8.69 0 01-.136-1.288L0 14.468c.002-.745.06-1.49.174-2.23l.1-.573c.298-1.53.828-2.958 1.536-4.157l.209-.34c1.177-1.83 2.789-3.053 4.615-3.16L6.897 4zm-.033 2.615l-.201.01c-.83.083-1.606.673-2.252 1.577l-.138.199-.01.018c-.67 1.017-1.185 2.378-1.456 3.845l-.004.022a12.591 12.591 0 00-.207 2.254l.002.188c.004.18.017.36.04.54l.043.291c.092.503.257.908.486 1.208l.117.137c.303.323.698.492 1.17.492 1.1 0 1.796-.676 3.696-3.641l2.175-3.4.454-.701-.139-.198C9.11 7.3 8.084 6.616 6.864 6.616zm10.196-.552l-.176.007c-.635.048-1.223.359-1.82.933l-.196.198c-.439.462-.887 1.064-1.367 1.807l.266.398c.18.274.362.56.55.858l.293.475 1.396 2.335.695 1.114c.583.926 1.03 1.6 1.408 2.082l.213.262c.282.326.529.54.777.673l.102.05c.227.1.457.138.718.138.176.002.35-.023.518-.073.338-.104.61-.32.813-.637l.095-.163.077-.162c.194-.459.29-1.06.29-1.785l-.006-.449c-.08-2.871-.938-5.372-2.2-6.798l-.176-.189c-.67-.683-1.444-1.074-2.27-1.074z"})]}))});function pw(e){"@babel/helpers - typeof";return pw=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},pw(e)}function PH(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);r&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,i)}return n}function qZe(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?PH(Object(n),!0).forEach(function(i){GZe(e,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):PH(Object(n)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(n,i))})}return e}function GZe(e,r,n){return r=KZe(r),r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function KZe(e){var r=YZe(e,"string");return pw(r)=="symbol"?r:String(r)}function YZe(e,r){if(pw(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var i=n.call(e,r);if(pw(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function XZe(e){if(e==null)throw new TypeError("Cannot destructure "+e)}var ZZe=y.memo(function(e){var r=Object.assign({},(XZe(e),e));return c.jsx(bl,qZe({Icon:aP,"aria-label":Vh,background:DZe,color:IZe,iconMultiple:BZe},r))});function mw(e){"@babel/helpers - typeof";return mw=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(r){return typeof r}:function(r){return r&&typeof Symbol=="function"&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},mw(e)}var JZe=["size","style"];function LH(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);r&&(i=i.filter(function(s){return Object.getOwnPropertyDescriptor(e,s).enumerable})),n.push.apply(n,i)}return n}function xE(e){for(var r=1;r<arguments.length;r++){var n=arguments[r]!=null?arguments[r]:{};r%2?LH(Object(n),!0).forEach(function(i){QZe(e,i,n[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):LH(Object(n)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(n,i))})}return e}function QZe(e,r,n){return r=eJe(r),r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function eJe(e){var r=tJe(e,"string");return mw(r)=="symbol"?r:String(r)}function tJe(e,r){if(mw(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var i=n.call(e,r);if(mw(i)!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(r==="string"?String:Number)(e)}function rJe(e,r){return oJe(e)||sJe(e,r)||iJe(e,r)||nJe()}function nJe(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.