@jait/gateway 0.1.386 → 0.1.388

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 (59) hide show
  1. package/dist/routes/update.d.ts.map +1 -1
  2. package/dist/routes/update.js +2 -1
  3. package/dist/routes/update.js.map +1 -1
  4. package/dist/tools/redeploy-tools.js +4 -2
  5. package/dist/tools/redeploy-tools.js.map +1 -1
  6. package/package.json +1 -1
  7. package/web-dist/assets/{_basePickBy-BXZRiCmU.js → _basePickBy-Rm1nk2-J.js} +1 -1
  8. package/web-dist/assets/{_baseUniq-MZGnGk4b.js → _baseUniq-eegdhD3S.js} +1 -1
  9. package/web-dist/assets/{arc-CmWEdifE.js → arc-ChJj5aUQ.js} +1 -1
  10. package/web-dist/assets/{architectureDiagram-2XIMDMQ5-CQ4UH63R.js → architectureDiagram-2XIMDMQ5-DHQAkY8U.js} +1 -1
  11. package/web-dist/assets/{blockDiagram-WCTKOSBZ-BNRUqN8U.js → blockDiagram-WCTKOSBZ-F6w5rbVO.js} +1 -1
  12. package/web-dist/assets/{c4Diagram-IC4MRINW-CV0axTns.js → c4Diagram-IC4MRINW-BRwblko3.js} +1 -1
  13. package/web-dist/assets/channel-aPpfht4A.js +1 -0
  14. package/web-dist/assets/{chunk-4BX2VUAB-DEl_IitM.js → chunk-4BX2VUAB-D-UsGKte.js} +1 -1
  15. package/web-dist/assets/{chunk-55IACEB6-DxhqlMJO.js → chunk-55IACEB6-CEp64Fyo.js} +1 -1
  16. package/web-dist/assets/{chunk-FMBD7UC4-CCSvYleD.js → chunk-FMBD7UC4-M_Qlfnyh.js} +1 -1
  17. package/web-dist/assets/{chunk-JSJVCQXG-B6akuuhS.js → chunk-JSJVCQXG-Dik0HyOL.js} +1 -1
  18. package/web-dist/assets/{chunk-KX2RTZJC-DGgYS32K.js → chunk-KX2RTZJC-B3eQN7z-.js} +1 -1
  19. package/web-dist/assets/{chunk-NQ4KR5QH-BRk8FziX.js → chunk-NQ4KR5QH-ChERH--p.js} +1 -1
  20. package/web-dist/assets/{chunk-QZHKN3VN-xmCOWG3O.js → chunk-QZHKN3VN-CEhYncr_.js} +1 -1
  21. package/web-dist/assets/{chunk-WL4C6EOR-cnUhlQ_q.js → chunk-WL4C6EOR-DrT1CV_y.js} +1 -1
  22. package/web-dist/assets/classDiagram-VBA2DB6C-Dw1gEIva.js +1 -0
  23. package/web-dist/assets/classDiagram-v2-RAHNMMFH-Dw1gEIva.js +1 -0
  24. package/web-dist/assets/clone-pGFj9GCE.js +1 -0
  25. package/web-dist/assets/{cose-bilkent-S5V4N54A-CuRkM-32.js → cose-bilkent-S5V4N54A-DWm-S0vX.js} +1 -1
  26. package/web-dist/assets/{dagre-KLK3FWXG-BDo5L6X5.js → dagre-KLK3FWXG-BrnKnDyj.js} +1 -1
  27. package/web-dist/assets/{diagram-E7M64L7V-CQvnKhaJ.js → diagram-E7M64L7V-DEA2XDBr.js} +1 -1
  28. package/web-dist/assets/{diagram-IFDJBPK2-DeuKIenB.js → diagram-IFDJBPK2-DHiv3xvn.js} +1 -1
  29. package/web-dist/assets/{diagram-P4PSJMXO-BHsoJA7q.js → diagram-P4PSJMXO-DMoyTfQb.js} +1 -1
  30. package/web-dist/assets/{erDiagram-INFDFZHY-DWh3DB8M.js → erDiagram-INFDFZHY-BVAOL8cd.js} +1 -1
  31. package/web-dist/assets/{flowDiagram-PKNHOUZH-DoFiw4u0.js → flowDiagram-PKNHOUZH-DpkviZuG.js} +1 -1
  32. package/web-dist/assets/{ganttDiagram-A5KZAMGK-D-oZWlkD.js → ganttDiagram-A5KZAMGK-CaW7pA4w.js} +1 -1
  33. package/web-dist/assets/{gitGraphDiagram-K3NZZRJ6-BFECdsJr.js → gitGraphDiagram-K3NZZRJ6-RJvOQY_w.js} +1 -1
  34. package/web-dist/assets/{graph-J3UMwoQx.js → graph-C3bw02gT.js} +1 -1
  35. package/web-dist/assets/{index-DlGzWGrc.js → index-BDVleDcT.js} +4 -4
  36. package/web-dist/assets/{infoDiagram-LFFYTUFH-BF4ZqIjt.js → infoDiagram-LFFYTUFH-CGJpKZSz.js} +1 -1
  37. package/web-dist/assets/{ishikawaDiagram-PHBUUO56-Br4BTPPU.js → ishikawaDiagram-PHBUUO56-Dk1Thix7.js} +1 -1
  38. package/web-dist/assets/{journeyDiagram-4ABVD52K-RUXQRHKu.js → journeyDiagram-4ABVD52K-BSf3HgNR.js} +1 -1
  39. package/web-dist/assets/{kanban-definition-K7BYSVSG-CQQua1ol.js → kanban-definition-K7BYSVSG-DXs_wEuy.js} +1 -1
  40. package/web-dist/assets/{layout-BU-jiiB3.js → layout-BTE1q0rQ.js} +1 -1
  41. package/web-dist/assets/{linear-CLyfqQdp.js → linear-DSvJyXrX.js} +1 -1
  42. package/web-dist/assets/{mindmap-definition-YRQLILUH-5a1kyPQG.js → mindmap-definition-YRQLILUH-CefPS_aA.js} +1 -1
  43. package/web-dist/assets/{pieDiagram-SKSYHLDU-kRzIT5pJ.js → pieDiagram-SKSYHLDU-BS3wAXZT.js} +1 -1
  44. package/web-dist/assets/{quadrantDiagram-337W2JSQ-CG073SHF.js → quadrantDiagram-337W2JSQ-Cm0jHWPc.js} +1 -1
  45. package/web-dist/assets/{requirementDiagram-Z7DCOOCP-Cu9BWm-x.js → requirementDiagram-Z7DCOOCP-CLRswCzL.js} +1 -1
  46. package/web-dist/assets/{sankeyDiagram-WA2Y5GQK-DGsL3W8F.js → sankeyDiagram-WA2Y5GQK-CeD4zAS6.js} +1 -1
  47. package/web-dist/assets/{sequenceDiagram-2WXFIKYE-DnLHlRh8.js → sequenceDiagram-2WXFIKYE-Dmcxwid4.js} +1 -1
  48. package/web-dist/assets/{stateDiagram-RAJIS63D-FSKGWY5-.js → stateDiagram-RAJIS63D-Qws-YJqW.js} +1 -1
  49. package/web-dist/assets/stateDiagram-v2-FVOUBMTO-2Ms8hEFm.js +1 -0
  50. package/web-dist/assets/{timeline-definition-YZTLITO2-BtD9Z6nP.js → timeline-definition-YZTLITO2-Daycq3BS.js} +1 -1
  51. package/web-dist/assets/{treemap-KZPCXAKY-8AgiWapA.js → treemap-KZPCXAKY-Cx3W2b9f.js} +1 -1
  52. package/web-dist/assets/{vennDiagram-LZ73GAT5-gvaIxUvQ.js → vennDiagram-LZ73GAT5-C8x6lkPc.js} +1 -1
  53. package/web-dist/assets/{xychartDiagram-JWTSCODW-CA51b6Kn.js → xychartDiagram-JWTSCODW-CwMt6Z8n.js} +1 -1
  54. package/web-dist/index.html +1 -1
  55. package/web-dist/assets/channel-Gy1j6Eod.js +0 -1
  56. package/web-dist/assets/classDiagram-VBA2DB6C-DehUbCjf.js +0 -1
  57. package/web-dist/assets/classDiagram-v2-RAHNMMFH-DehUbCjf.js +0 -1
  58. package/web-dist/assets/clone-DaIkNSm1.js +0 -1
  59. package/web-dist/assets/stateDiagram-v2-FVOUBMTO-8Jy2Z5dI.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-BDo5L6X5.js","./graph-J3UMwoQx.js","./_baseUniq-MZGnGk4b.js","./layout-BU-jiiB3.js","./_basePickBy-BXZRiCmU.js","./clone-DaIkNSm1.js","./cose-bilkent-S5V4N54A-CuRkM-32.js","./cytoscape.esm-BQaXIfA_.js","./c4Diagram-IC4MRINW-CV0axTns.js","./chunk-JSJVCQXG-B6akuuhS.js","./flowDiagram-PKNHOUZH-DoFiw4u0.js","./chunk-FMBD7UC4-CCSvYleD.js","./chunk-55IACEB6-DxhqlMJO.js","./chunk-KX2RTZJC-DGgYS32K.js","./channel-Gy1j6Eod.js","./erDiagram-INFDFZHY-DWh3DB8M.js","./gitGraphDiagram-K3NZZRJ6-BFECdsJr.js","./chunk-4BX2VUAB-DEl_IitM.js","./chunk-QZHKN3VN-xmCOWG3O.js","./treemap-KZPCXAKY-8AgiWapA.js","./ganttDiagram-A5KZAMGK-D-oZWlkD.js","./linear-CLyfqQdp.js","./defaultLocale-DX6XiGOO.js","./infoDiagram-LFFYTUFH-BF4ZqIjt.js","./pieDiagram-SKSYHLDU-kRzIT5pJ.js","./arc-CmWEdifE.js","./quadrantDiagram-337W2JSQ-CG073SHF.js","./xychartDiagram-JWTSCODW-CA51b6Kn.js","./requirementDiagram-Z7DCOOCP-Cu9BWm-x.js","./sequenceDiagram-2WXFIKYE-DnLHlRh8.js","./classDiagram-VBA2DB6C-DehUbCjf.js","./chunk-WL4C6EOR-cnUhlQ_q.js","./classDiagram-v2-RAHNMMFH-DehUbCjf.js","./stateDiagram-RAJIS63D-FSKGWY5-.js","./chunk-NQ4KR5QH-BRk8FziX.js","./stateDiagram-v2-FVOUBMTO-8Jy2Z5dI.js","./journeyDiagram-4ABVD52K-RUXQRHKu.js","./timeline-definition-YZTLITO2-BtD9Z6nP.js","./mindmap-definition-YRQLILUH-5a1kyPQG.js","./kanban-definition-K7BYSVSG-CQQua1ol.js","./diagram-P4PSJMXO-BHsoJA7q.js","./diagram-IFDJBPK2-DeuKIenB.js","./blockDiagram-WCTKOSBZ-BNRUqN8U.js","./architectureDiagram-2XIMDMQ5-CQ4UH63R.js","./diagram-E7M64L7V-CQvnKhaJ.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-BrnKnDyj.js","./graph-C3bw02gT.js","./_baseUniq-eegdhD3S.js","./layout-BTE1q0rQ.js","./_basePickBy-Rm1nk2-J.js","./clone-pGFj9GCE.js","./cose-bilkent-S5V4N54A-DWm-S0vX.js","./cytoscape.esm-BQaXIfA_.js","./c4Diagram-IC4MRINW-BRwblko3.js","./chunk-JSJVCQXG-Dik0HyOL.js","./flowDiagram-PKNHOUZH-DpkviZuG.js","./chunk-FMBD7UC4-M_Qlfnyh.js","./chunk-55IACEB6-CEp64Fyo.js","./chunk-KX2RTZJC-B3eQN7z-.js","./channel-aPpfht4A.js","./erDiagram-INFDFZHY-BVAOL8cd.js","./gitGraphDiagram-K3NZZRJ6-RJvOQY_w.js","./chunk-4BX2VUAB-D-UsGKte.js","./chunk-QZHKN3VN-CEhYncr_.js","./treemap-KZPCXAKY-Cx3W2b9f.js","./ganttDiagram-A5KZAMGK-CaW7pA4w.js","./linear-DSvJyXrX.js","./defaultLocale-DX6XiGOO.js","./infoDiagram-LFFYTUFH-CGJpKZSz.js","./pieDiagram-SKSYHLDU-BS3wAXZT.js","./arc-ChJj5aUQ.js","./quadrantDiagram-337W2JSQ-Cm0jHWPc.js","./xychartDiagram-JWTSCODW-CwMt6Z8n.js","./requirementDiagram-Z7DCOOCP-CLRswCzL.js","./sequenceDiagram-2WXFIKYE-Dmcxwid4.js","./classDiagram-VBA2DB6C-Dw1gEIva.js","./chunk-WL4C6EOR-DrT1CV_y.js","./classDiagram-v2-RAHNMMFH-Dw1gEIva.js","./stateDiagram-RAJIS63D-Qws-YJqW.js","./chunk-NQ4KR5QH-ChERH--p.js","./stateDiagram-v2-FVOUBMTO-2Ms8hEFm.js","./journeyDiagram-4ABVD52K-BSf3HgNR.js","./timeline-definition-YZTLITO2-Daycq3BS.js","./mindmap-definition-YRQLILUH-CefPS_aA.js","./kanban-definition-K7BYSVSG-DXs_wEuy.js","./diagram-P4PSJMXO-DMoyTfQb.js","./diagram-IFDJBPK2-DHiv3xvn.js","./blockDiagram-WCTKOSBZ-F6w5rbVO.js","./architectureDiagram-2XIMDMQ5-DHQAkY8U.js","./diagram-E7M64L7V-DEA2XDBr.js"])))=>i.map(i=>d[i]);
2
2
  var The=Object.defineProperty;var Ehe=(e,r,n)=>r in e?The(e,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[r]=n;var Be=(e,r,n)=>Ehe(e,typeof r!="symbol"?r+"":r,n);function Ahe(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 z0(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function F1t(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:{}},Zx={};/**
3
3
  * @license React
4
4
  * react-jsx-runtime.production.js
@@ -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),St.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 St.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"),TF=Y((e,r)=>{St.warn("abc88 cutPathAtIntersect",e,r);let n=[],i=e[0],s=!1;return e.forEach(o=>{if(St.info("abc88 checking point",o,r),!gVe(r,o)&&!s){const a=yVe(r,i,o);St.debug("abc88 inside",o,i,a),St.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)?St.warn("abc88 no intersect",a,n):n.push(a),s=!0}else St.warn("abc88 outside",o,i),i=o,s||n.push(o)}),St.debug("returning points",n),n},"cutPathAtIntersect");function _se(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(_se,"extractCornerPoints");var EF=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"),vVe=Y(function(e){const{cornerPointPositions:r}=_se(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=EF(s,a,5),d=EF(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){St.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 St.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"),xVe=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"),bVe=Y(function(e,r,n,i,s,o,a,l=!1){var L;const{handDrawnSeed:d}=ei();let u=r.points,f=!1;const p=s;var g=o;const v=[];for(const z in r.cssCompiledStyles)_ne(z)||v.push(r.cssCompiledStyles[z]);St.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])),St.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&&(St.info("to cluster abc88",n.get(r.toCluster)),u=TF(r.points,n.get(r.toCluster).node),f=!0),r.fromCluster&&(St.debug("from cluster abc88",n.get(r.fromCluster),JSON.stringify(u,null,2)),u=TF(u.reverse(),n.get(r.fromCluster).node).reverse(),f=!0);let _=u.filter(z=>!Number.isNaN(z.y));const S=fVe(r.curve);S!=="rounded"&&(_=vVe(_));let w=R_;switch(S){case"linear":w=R_;break;case"basis":w=FA;break;case"cardinal":w=tte;break;case"bumpX":w=Xee;break;case"bumpY":w=Zee;break;case"catmullRom":w=nte;break;case"monotoneX":w=cte;break;case"monotoneY":w=ute;break;case"natural":w=hte;break;case"step":w=fte;break;case"stepAfter":w=mte;break;case"stepBefore":w=pte;break;case"rounded":w=R_;break;default:w=FA}const{x:C,y:j}=gze(r),T=qIe().x(C).y(j).curve(w);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,R=S==="rounded"?wse(Sse(_,r),5):T(_);const $=Array.isArray(r.style)?r.style:[r.style];let B=$.find(z=>z==null?void 0:z.startsWith("stroke:")),P="";r.animate&&(P="edge-animation-fast"),r.animation&&(P="edge-animation-"+r.animation);let H=!1;if(r.look==="handDrawn"){const z=Sr.svg(e);Object.assign([],_);const G=z.path(R,{roughness:.3,seed:d});N+=" transition",A=zr(G).select("path").attr("id",r.id).attr("class"," "+N+(r.classes?" "+r.classes:"")+(P?" "+P:"")).attr("style",$?$.reduce((F,W)=>F+";"+W,""):"");let X=A.attr("d");A.attr("d",X),e.node().appendChild(A.node())}else{const z=v.join(";"),G=$?$.reduce((ee,re)=>ee+re+";",""):"",X=(z?z+";"+G+";":G)+";"+($?$.reduce((ee,re)=>ee+";"+re,""):"");A=e.append("path").attr("d",R).attr("id",r.id).attr("class"," "+N+(r.classes?" "+r.classes:"")+(P?" "+P:"")).attr("style",X),B=(L=X.match(/stroke:([^;]+)/))==null?void 0:L[1],H=r.animate===!0||!!r.animation||z.includes("animation");const F=A.node(),W=typeof F.getTotalLength=="function"?F.getTotalLength():0,Q=Uz[r.arrowTypeStart]||0,V=Uz[r.arrowTypeEnd]||0;if(r.look==="neo"&&!H){const re=`stroke-dasharray: ${r.pattern==="dotted"||r.pattern==="dashed"?xVe(W,Q,V):`0 ${Q} ${W-Q-V} ${V}`}; stroke-dashoffset: 0;`;A.attr("style",re+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="";(ei().flowchart.arrowMarkerAbsolute||ei().state.arrowMarkerAbsolute)&&(U=window.location.protocol+"//"+window.location.host+window.location.pathname+window.location.search,U=U.replace(/\(/g,"\\(").replace(/\)/g,"\\)")),St.info("arrowTypeStart",r.arrowTypeStart),St.info("arrowTypeEnd",r.arrowTypeEnd),dVe(A,r,U,a,i,B);const q=Math.floor(u.length/2),M=u[q];od.isLabelCoordinateInPath(M,A.attr("d"))||(f=!0);let I={};return f&&(I.updatedPath=u),I.originalPath=r.points,I},"insertEdge");function wse(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,w=p/b,C=g/b,j=_*w+S*C,T=Math.max(-1,Math.min(1,j)),N=Math.acos(T);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),R=a.x-_*A,$=a.y-S*A,B=a.x+w*A,P=a.y+C*A;n+=`L${R},${$}`,n+=`Q${a.x},${a.y} ${B},${P}`}}return n}Y(wse,"generateRoundedPath");function mO(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(mO,"calculateDeltaAndAngle");function Sse(e,r){const n=e.map(s=>({...s}));if(e.length>=2&&ka[r.arrowTypeStart]){const s=ka[r.arrowTypeStart],o=e[0],a=e[1],{angle:l}=mO(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&&ka[r.arrowTypeEnd]){const s=ka[r.arrowTypeEnd],o=e[i-1],a=e[i-2],{angle:l}=mO(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(Sse,"applyMarkerOffsetsToPoints");var _Ve=Y((e,r,n,i)=>{r.forEach(s=>{DVe[s](e,n,i)})},"insertMarkers"),wVe=Y((e,r,n)=>{St.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"),SVe=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"),kVe=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"),CVe=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"),jVe=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"),NVe=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"),TVe=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"),EVe=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"),AVe=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"),OVe=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"),RVe=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"),MVe=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"),PVe=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"),LVe=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"),$Ve=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"),DVe={extension:wVe,composition:SVe,aggregation:kVe,dependency:CVe,lollipop:jVe,point:NVe,circle:TVe,cross:EVe,barb:AVe,only_one:OVe,zero_or_one:RVe,one_or_more:MVe,zero_or_more:PVe,requirement_arrow:LVe,requirement_contains:$Ve},IVe=_Ve,BVe={common:kS,getConfig:Aa,insertCluster:VUe,insertEdge:bVe,insertEdgeLabel:pVe,insertMarkers:IVe,insertNode:bse,interpolateToCurve:AM,labelHelper:Gr,log:St,positionEdgeLabel:mVe},V2={},kse=Y(e=>{for(const r of e)V2[r.name]=r},"registerLayoutLoaders"),zVe=Y(()=>{kse([{name:"dagre",loader:Y(async()=>await Ge(()=>import("./dagre-KLK3FWXG-BDo5L6X5.js"),__vite__mapDeps([47,48,49,50,51,52]),import.meta.url),"loader")},{name:"cose-bilkent",loader:Y(async()=>await Ge(()=>import("./cose-bilkent-S5V4N54A-CuRkM-32.js"),__vite__mapDeps([53,54]),import.meta.url),"loader")}])},"registerDefaultLayoutLoaders");zVe();var Tvt=Y(async(e,r)=>{if(!(e.layoutAlgorithm in V2))throw new Error(`Unknown layout algorithm: ${e.layoutAlgorithm}`);const n=V2[e.layoutAlgorithm];return(await n.loader()).render(e,r,BVe,{algorithm:n.algorithm})},"render"),Evt=Y((e="",{fallback:r="dagre"}={})=>{if(e in V2)return e;if(r in V2)return St.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"),FVe=ene(Object.keys,Object),HVe=Object.prototype,WVe=HVe.hasOwnProperty;function UVe(e){if(!Qj(e))return FVe(e);var r=[];for(var n in Object(e))WVe.call(e,n)&&n!="constructor"&&r.push(n);return r}var gO=J0(Td,"DataView"),yO=J0(Td,"Promise"),vO=J0(Td,"Set"),xO=J0(Td,"WeakMap"),AF="[object Map]",VVe="[object Object]",OF="[object Promise]",RF="[object Set]",MF="[object WeakMap]",PF="[object DataView]",qVe=Z0(gO),GVe=Z0(W2),KVe=Z0(yO),YVe=Z0(vO),XVe=Z0(xO),Xg=X0;(gO&&Xg(new gO(new ArrayBuffer(1)))!=PF||W2&&Xg(new W2)!=AF||yO&&Xg(yO.resolve())!=OF||vO&&Xg(new vO)!=RF||xO&&Xg(new xO)!=MF)&&(Xg=function(e){var r=X0(e),n=r==VVe?e.constructor:void 0,i=n?Z0(n):"";if(i)switch(i){case qVe:return PF;case GVe:return AF;case KVe:return OF;case YVe:return RF;case XVe:return MF}return r});var ZVe="[object Map]",JVe="[object Set]",QVe=Object.prototype,eqe=QVe.hasOwnProperty;function LF(e){if(e==null)return!0;if(e6(e)&&(Y5(e)||typeof e=="string"||typeof e.splice=="function"||TM(e)||EM(e)||K5(e)))return!e.length;var r=Xg(e);if(r==ZVe||r==JVe)return!e.size;if(Qj(e))return!UVe(e).length;for(var n in e)if(eqe.call(e,n))return!1;return!0}var Cse="c4",tqe=Y(e=>/^\s*C4Context|C4Container|C4Component|C4Dynamic|C4Deployment/.test(e),"detector"),rqe=Y(async()=>{const{diagram:e}=await Ge(async()=>{const{diagram:r}=await import("./c4Diagram-IC4MRINW-CV0axTns.js");return{diagram:r}},__vite__mapDeps([55,56]),import.meta.url);return{id:Cse,diagram:e}},"loader"),nqe={id:Cse,detector:tqe,loader:rqe},iqe=nqe,jse="flowchart",sqe=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"),oqe=Y(async()=>{const{diagram:e}=await Ge(async()=>{const{diagram:r}=await import("./flowDiagram-PKNHOUZH-DoFiw4u0.js");return{diagram:r}},__vite__mapDeps([57,58,56,59,60,61]),import.meta.url);return{id:jse,diagram:e}},"loader"),aqe={id:jse,detector:sqe,loader:oqe},lqe=aqe,Nse="flowchart-v2",cqe=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"),uqe=Y(async()=>{const{diagram:e}=await Ge(async()=>{const{diagram:r}=await import("./flowDiagram-PKNHOUZH-DoFiw4u0.js");return{diagram:r}},__vite__mapDeps([57,58,56,59,60,61]),import.meta.url);return{id:Nse,diagram:e}},"loader"),dqe={id:Nse,detector:cqe,loader:uqe},hqe=dqe,Tse="er",fqe=Y(e=>/^\s*erDiagram/.test(e),"detector"),pqe=Y(async()=>{const{diagram:e}=await Ge(async()=>{const{diagram:r}=await import("./erDiagram-INFDFZHY-DWh3DB8M.js");return{diagram:r}},__vite__mapDeps([62,59,60,61]),import.meta.url);return{id:Tse,diagram:e}},"loader"),mqe={id:Tse,detector:fqe,loader:pqe},gqe=mqe,Ese="gitGraph",yqe=Y(e=>/^\s*gitGraph/.test(e),"detector"),vqe=Y(async()=>{const{diagram:e}=await Ge(async()=>{const{diagram:r}=await import("./gitGraphDiagram-K3NZZRJ6-BFECdsJr.js");return{diagram:r}},__vite__mapDeps([63,64,65,66,49,51,52]),import.meta.url);return{id:Ese,diagram:e}},"loader"),xqe={id:Ese,detector:yqe,loader:vqe},bqe=xqe,Ase="gantt",_qe=Y(e=>/^\s*gantt/.test(e),"detector"),wqe=Y(async()=>{const{diagram:e}=await Ge(async()=>{const{diagram:r}=await import("./ganttDiagram-A5KZAMGK-D-oZWlkD.js");return{diagram:r}},__vite__mapDeps([67,68,69]),import.meta.url);return{id:Ase,diagram:e}},"loader"),Sqe={id:Ase,detector:_qe,loader:wqe},kqe=Sqe,Ose="info",Cqe=Y(e=>/^\s*info/.test(e),"detector"),jqe=Y(async()=>{const{diagram:e}=await Ge(async()=>{const{diagram:r}=await import("./infoDiagram-LFFYTUFH-BF4ZqIjt.js");return{diagram:r}},__vite__mapDeps([70,66,49,51,52]),import.meta.url);return{id:Ose,diagram:e}},"loader"),Nqe={id:Ose,detector:Cqe,loader:jqe},Rse="pie",Tqe=Y(e=>/^\s*pie/.test(e),"detector"),Eqe=Y(async()=>{const{diagram:e}=await Ge(async()=>{const{diagram:r}=await import("./pieDiagram-SKSYHLDU-kRzIT5pJ.js");return{diagram:r}},__vite__mapDeps([71,64,66,49,51,52,72]),import.meta.url);return{id:Rse,diagram:e}},"loader"),Aqe={id:Rse,detector:Tqe,loader:Eqe},Mse="quadrantChart",Oqe=Y(e=>/^\s*quadrantChart/.test(e),"detector"),Rqe=Y(async()=>{const{diagram:e}=await Ge(async()=>{const{diagram:r}=await import("./quadrantDiagram-337W2JSQ-CG073SHF.js");return{diagram:r}},__vite__mapDeps([73,68,69]),import.meta.url);return{id:Mse,diagram:e}},"loader"),Mqe={id:Mse,detector:Oqe,loader:Rqe},Pqe=Mqe,Pse="xychart",Lqe=Y(e=>/^\s*xychart(-beta)?/.test(e),"detector"),$qe=Y(async()=>{const{diagram:e}=await Ge(async()=>{const{diagram:r}=await import("./xychartDiagram-JWTSCODW-CA51b6Kn.js");return{diagram:r}},__vite__mapDeps([74,68,69]),import.meta.url);return{id:Pse,diagram:e}},"loader"),Dqe={id:Pse,detector:Lqe,loader:$qe},Iqe=Dqe,Lse="requirement",Bqe=Y(e=>/^\s*requirement(Diagram)?/.test(e),"detector"),zqe=Y(async()=>{const{diagram:e}=await Ge(async()=>{const{diagram:r}=await import("./requirementDiagram-Z7DCOOCP-Cu9BWm-x.js");return{diagram:r}},__vite__mapDeps([75,59,60]),import.meta.url);return{id:Lse,diagram:e}},"loader"),Fqe={id:Lse,detector:Bqe,loader:zqe},Hqe=Fqe,$se="sequence",Wqe=Y(e=>/^\s*sequenceDiagram/.test(e),"detector"),Uqe=Y(async()=>{const{diagram:e}=await Ge(async()=>{const{diagram:r}=await import("./sequenceDiagram-2WXFIKYE-DnLHlRh8.js");return{diagram:r}},__vite__mapDeps([76,56,65]),import.meta.url);return{id:$se,diagram:e}},"loader"),Vqe={id:$se,detector:Wqe,loader:Uqe},qqe=Vqe,Dse="class",Gqe=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"),Kqe=Y(async()=>{const{diagram:e}=await Ge(async()=>{const{diagram:r}=await import("./classDiagram-VBA2DB6C-DehUbCjf.js");return{diagram:r}},__vite__mapDeps([77,78,58,56,59,60]),import.meta.url);return{id:Dse,diagram:e}},"loader"),Yqe={id:Dse,detector:Gqe,loader:Kqe},Xqe=Yqe,Ise="classDiagram",Zqe=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"),Jqe=Y(async()=>{const{diagram:e}=await Ge(async()=>{const{diagram:r}=await import("./classDiagram-v2-RAHNMMFH-DehUbCjf.js");return{diagram:r}},__vite__mapDeps([79,78,58,56,59,60]),import.meta.url);return{id:Ise,diagram:e}},"loader"),Qqe={id:Ise,detector:Zqe,loader:Jqe},eGe=Qqe,Bse="state",tGe=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"),rGe=Y(async()=>{const{diagram:e}=await Ge(async()=>{const{diagram:r}=await import("./stateDiagram-RAJIS63D-FSKGWY5-.js");return{diagram:r}},__vite__mapDeps([80,81,59,60,48,49,50,51]),import.meta.url);return{id:Bse,diagram:e}},"loader"),nGe={id:Bse,detector:tGe,loader:rGe},iGe=nGe,zse="stateDiagram",sGe=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"),oGe=Y(async()=>{const{diagram:e}=await Ge(async()=>{const{diagram:r}=await import("./stateDiagram-v2-FVOUBMTO-8Jy2Z5dI.js");return{diagram:r}},__vite__mapDeps([82,81,59,60]),import.meta.url);return{id:zse,diagram:e}},"loader"),aGe={id:zse,detector:sGe,loader:oGe},lGe=aGe,Fse="journey",cGe=Y(e=>/^\s*journey/.test(e),"detector"),uGe=Y(async()=>{const{diagram:e}=await Ge(async()=>{const{diagram:r}=await import("./journeyDiagram-4ABVD52K-RUXQRHKu.js");return{diagram:r}},__vite__mapDeps([83,58,56,72]),import.meta.url);return{id:Fse,diagram:e}},"loader"),dGe={id:Fse,detector:cGe,loader:uGe},hGe=dGe,fGe=Y((e,r,n)=>{St.debug(`rendering svg for syntax error
1125
- `);const i=lBe(r),s=i.append("g");i.attr("viewBox","0 0 2412 512"),gee(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"),Hse={draw:fGe},pGe=Hse,mGe={db:{},renderer:Hse,parser:{parse:Y(()=>{},"parse")}},gGe=mGe,Wse="flowchart-elk",yGe=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"),vGe=Y(async()=>{const{diagram:e}=await Ge(async()=>{const{diagram:r}=await import("./flowDiagram-PKNHOUZH-DoFiw4u0.js");return{diagram:r}},__vite__mapDeps([57,58,56,59,60,61]),import.meta.url);return{id:Wse,diagram:e}},"loader"),xGe={id:Wse,detector:yGe,loader:vGe},bGe=xGe,Use="timeline",_Ge=Y(e=>/^\s*timeline/.test(e),"detector"),wGe=Y(async()=>{const{diagram:e}=await Ge(async()=>{const{diagram:r}=await import("./timeline-definition-YZTLITO2-BtD9Z6nP.js");return{diagram:r}},__vite__mapDeps([84,72]),import.meta.url);return{id:Use,diagram:e}},"loader"),SGe={id:Use,detector:_Ge,loader:wGe},kGe=SGe,Vse="mindmap",CGe=Y(e=>/^\s*mindmap/.test(e),"detector"),jGe=Y(async()=>{const{diagram:e}=await Ge(async()=>{const{diagram:r}=await import("./mindmap-definition-YRQLILUH-5a1kyPQG.js");return{diagram:r}},__vite__mapDeps([85,59,60]),import.meta.url);return{id:Vse,diagram:e}},"loader"),NGe={id:Vse,detector:CGe,loader:jGe},TGe=NGe,qse="kanban",EGe=Y(e=>/^\s*kanban/.test(e),"detector"),AGe=Y(async()=>{const{diagram:e}=await Ge(async()=>{const{diagram:r}=await import("./kanban-definition-K7BYSVSG-CQQua1ol.js");return{diagram:r}},__vite__mapDeps([86,58]),import.meta.url);return{id:qse,diagram:e}},"loader"),OGe={id:qse,detector:EGe,loader:AGe},RGe=OGe,Gse="sankey",MGe=Y(e=>/^\s*sankey(-beta)?/.test(e),"detector"),PGe=Y(async()=>{const{diagram:e}=await Ge(async()=>{const{diagram:r}=await import("./sankeyDiagram-WA2Y5GQK-DGsL3W8F.js");return{diagram:r}},[],import.meta.url);return{id:Gse,diagram:e}},"loader"),LGe={id:Gse,detector:MGe,loader:PGe},$Ge=LGe,Kse="packet",DGe=Y(e=>/^\s*packet(-beta)?/.test(e),"detector"),IGe=Y(async()=>{const{diagram:e}=await Ge(async()=>{const{diagram:r}=await import("./diagram-P4PSJMXO-BHsoJA7q.js");return{diagram:r}},__vite__mapDeps([87,64,66,49,51,52]),import.meta.url);return{id:Kse,diagram:e}},"loader"),BGe={id:Kse,detector:DGe,loader:IGe},Yse="radar",zGe=Y(e=>/^\s*radar-beta/.test(e),"detector"),FGe=Y(async()=>{const{diagram:e}=await Ge(async()=>{const{diagram:r}=await import("./diagram-IFDJBPK2-DeuKIenB.js");return{diagram:r}},__vite__mapDeps([88,64,66,49,51,52]),import.meta.url);return{id:Yse,diagram:e}},"loader"),HGe={id:Yse,detector:zGe,loader:FGe},Xse="block",WGe=Y(e=>/^\s*block(-beta)?/.test(e),"detector"),UGe=Y(async()=>{const{diagram:e}=await Ge(async()=>{const{diagram:r}=await import("./blockDiagram-WCTKOSBZ-BNRUqN8U.js");return{diagram:r}},__vite__mapDeps([89,58,52,49,48,61]),import.meta.url);return{id:Xse,diagram:e}},"loader"),VGe={id:Xse,detector:WGe,loader:UGe},qGe=VGe,Zse="architecture",GGe=Y(e=>/^\s*architecture/.test(e),"detector"),KGe=Y(async()=>{const{diagram:e}=await Ge(async()=>{const{diagram:r}=await import("./architectureDiagram-2XIMDMQ5-CQ4UH63R.js");return{diagram:r}},__vite__mapDeps([90,64,66,49,51,52,54]),import.meta.url);return{id:Zse,diagram:e}},"loader"),YGe={id:Zse,detector:GGe,loader:KGe},XGe=YGe,Jse="ishikawa",ZGe=Y(e=>/^\s*ishikawa(-beta)?\b/i.test(e),"detector"),JGe=Y(async()=>{const{diagram:e}=await Ge(async()=>{const{diagram:r}=await import("./ishikawaDiagram-PHBUUO56-Br4BTPPU.js");return{diagram:r}},[],import.meta.url);return{id:Jse,diagram:e}},"loader"),QGe={id:Jse,detector:ZGe,loader:JGe},Qse="venn",eKe=Y(e=>/^\s*venn-beta/.test(e),"detector"),tKe=Y(async()=>{const{diagram:e}=await Ge(async()=>{const{diagram:r}=await import("./vennDiagram-LZ73GAT5-gvaIxUvQ.js");return{diagram:r}},[],import.meta.url);return{id:Qse,diagram:e}},"loader"),rKe={id:Qse,detector:eKe,loader:tKe},nKe=rKe,eoe="treemap",iKe=Y(e=>/^\s*treemap/.test(e),"detector"),sKe=Y(async()=>{const{diagram:e}=await Ge(async()=>{const{diagram:r}=await import("./diagram-E7M64L7V-CQvnKhaJ.js");return{diagram:r}},__vite__mapDeps([91,60,64,66,49,51,52,69]),import.meta.url);return{id:eoe,diagram:e}},"loader"),oKe={id:eoe,detector:iKe,loader:sKe},$F=!1,l6=Y(()=>{$F||($F=!0,A5("error",gGe,e=>e.toLowerCase().trim()==="error"),A5("---",{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("---")),jA(bGe,TGe,XGe),jA(iqe,RGe,eGe,Xqe,gqe,kqe,Nqe,Aqe,Hqe,qqe,hqe,lqe,kGe,bqe,lGe,iGe,hGe,Pqe,$Ge,BGe,Iqe,qGe,HGe,QGe,oKe,nKe))},"addDiagrams"),aKe=Y(async()=>{St.debug("Loading registered diagrams");const r=(await Promise.allSettled(Object.entries(j0).map(async([n,{detector:i,loader:s}])=>{if(s)try{AA(n)}catch{try{const{diagram:o,id:a}=await s();A5(a,o,i)}catch(o){throw St.error(`Failed to load external diagram with key ${n}. Removing from detectors.`),delete j0[n],o}}}))).filter(n=>n.status==="rejected");if(r.length>0){St.error(`Failed to load ${r.length} external diagrams`);for(const n of r)St.error(n);throw new Error(`Failed to load ${r.length} external diagrams`)}},"loadRegisteredDiagrams"),lKe="graphics-document document";function toe(e,r){e.attr("role",lKe),r!==""&&e.attr("aria-roledescription",r)}Y(toe,"setA11yDiagramInfo");function roe(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(roe,"addSVGa11yTitleDescription");var y0,bO=(y0=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=Aa(),s=Z9(r,i);r=dWe(r)+`
1124
+ L0,20`)},"requirement_arrow"),$Ve=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"),DVe={extension:wVe,composition:SVe,aggregation:kVe,dependency:CVe,lollipop:jVe,point:NVe,circle:TVe,cross:EVe,barb:AVe,only_one:OVe,zero_or_one:RVe,one_or_more:MVe,zero_or_more:PVe,requirement_arrow:LVe,requirement_contains:$Ve},IVe=_Ve,BVe={common:kS,getConfig:Aa,insertCluster:VUe,insertEdge:bVe,insertEdgeLabel:pVe,insertMarkers:IVe,insertNode:bse,interpolateToCurve:AM,labelHelper:Gr,log:St,positionEdgeLabel:mVe},V2={},kse=Y(e=>{for(const r of e)V2[r.name]=r},"registerLayoutLoaders"),zVe=Y(()=>{kse([{name:"dagre",loader:Y(async()=>await Ge(()=>import("./dagre-KLK3FWXG-BrnKnDyj.js"),__vite__mapDeps([47,48,49,50,51,52]),import.meta.url),"loader")},{name:"cose-bilkent",loader:Y(async()=>await Ge(()=>import("./cose-bilkent-S5V4N54A-DWm-S0vX.js"),__vite__mapDeps([53,54]),import.meta.url),"loader")}])},"registerDefaultLayoutLoaders");zVe();var Tvt=Y(async(e,r)=>{if(!(e.layoutAlgorithm in V2))throw new Error(`Unknown layout algorithm: ${e.layoutAlgorithm}`);const n=V2[e.layoutAlgorithm];return(await n.loader()).render(e,r,BVe,{algorithm:n.algorithm})},"render"),Evt=Y((e="",{fallback:r="dagre"}={})=>{if(e in V2)return e;if(r in V2)return St.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"),FVe=ene(Object.keys,Object),HVe=Object.prototype,WVe=HVe.hasOwnProperty;function UVe(e){if(!Qj(e))return FVe(e);var r=[];for(var n in Object(e))WVe.call(e,n)&&n!="constructor"&&r.push(n);return r}var gO=J0(Td,"DataView"),yO=J0(Td,"Promise"),vO=J0(Td,"Set"),xO=J0(Td,"WeakMap"),AF="[object Map]",VVe="[object Object]",OF="[object Promise]",RF="[object Set]",MF="[object WeakMap]",PF="[object DataView]",qVe=Z0(gO),GVe=Z0(W2),KVe=Z0(yO),YVe=Z0(vO),XVe=Z0(xO),Xg=X0;(gO&&Xg(new gO(new ArrayBuffer(1)))!=PF||W2&&Xg(new W2)!=AF||yO&&Xg(yO.resolve())!=OF||vO&&Xg(new vO)!=RF||xO&&Xg(new xO)!=MF)&&(Xg=function(e){var r=X0(e),n=r==VVe?e.constructor:void 0,i=n?Z0(n):"";if(i)switch(i){case qVe:return PF;case GVe:return AF;case KVe:return OF;case YVe:return RF;case XVe:return MF}return r});var ZVe="[object Map]",JVe="[object Set]",QVe=Object.prototype,eqe=QVe.hasOwnProperty;function LF(e){if(e==null)return!0;if(e6(e)&&(Y5(e)||typeof e=="string"||typeof e.splice=="function"||TM(e)||EM(e)||K5(e)))return!e.length;var r=Xg(e);if(r==ZVe||r==JVe)return!e.size;if(Qj(e))return!UVe(e).length;for(var n in e)if(eqe.call(e,n))return!1;return!0}var Cse="c4",tqe=Y(e=>/^\s*C4Context|C4Container|C4Component|C4Dynamic|C4Deployment/.test(e),"detector"),rqe=Y(async()=>{const{diagram:e}=await Ge(async()=>{const{diagram:r}=await import("./c4Diagram-IC4MRINW-BRwblko3.js");return{diagram:r}},__vite__mapDeps([55,56]),import.meta.url);return{id:Cse,diagram:e}},"loader"),nqe={id:Cse,detector:tqe,loader:rqe},iqe=nqe,jse="flowchart",sqe=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"),oqe=Y(async()=>{const{diagram:e}=await Ge(async()=>{const{diagram:r}=await import("./flowDiagram-PKNHOUZH-DpkviZuG.js");return{diagram:r}},__vite__mapDeps([57,58,56,59,60,61]),import.meta.url);return{id:jse,diagram:e}},"loader"),aqe={id:jse,detector:sqe,loader:oqe},lqe=aqe,Nse="flowchart-v2",cqe=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"),uqe=Y(async()=>{const{diagram:e}=await Ge(async()=>{const{diagram:r}=await import("./flowDiagram-PKNHOUZH-DpkviZuG.js");return{diagram:r}},__vite__mapDeps([57,58,56,59,60,61]),import.meta.url);return{id:Nse,diagram:e}},"loader"),dqe={id:Nse,detector:cqe,loader:uqe},hqe=dqe,Tse="er",fqe=Y(e=>/^\s*erDiagram/.test(e),"detector"),pqe=Y(async()=>{const{diagram:e}=await Ge(async()=>{const{diagram:r}=await import("./erDiagram-INFDFZHY-BVAOL8cd.js");return{diagram:r}},__vite__mapDeps([62,59,60,61]),import.meta.url);return{id:Tse,diagram:e}},"loader"),mqe={id:Tse,detector:fqe,loader:pqe},gqe=mqe,Ese="gitGraph",yqe=Y(e=>/^\s*gitGraph/.test(e),"detector"),vqe=Y(async()=>{const{diagram:e}=await Ge(async()=>{const{diagram:r}=await import("./gitGraphDiagram-K3NZZRJ6-RJvOQY_w.js");return{diagram:r}},__vite__mapDeps([63,64,65,66,49,51,52]),import.meta.url);return{id:Ese,diagram:e}},"loader"),xqe={id:Ese,detector:yqe,loader:vqe},bqe=xqe,Ase="gantt",_qe=Y(e=>/^\s*gantt/.test(e),"detector"),wqe=Y(async()=>{const{diagram:e}=await Ge(async()=>{const{diagram:r}=await import("./ganttDiagram-A5KZAMGK-CaW7pA4w.js");return{diagram:r}},__vite__mapDeps([67,68,69]),import.meta.url);return{id:Ase,diagram:e}},"loader"),Sqe={id:Ase,detector:_qe,loader:wqe},kqe=Sqe,Ose="info",Cqe=Y(e=>/^\s*info/.test(e),"detector"),jqe=Y(async()=>{const{diagram:e}=await Ge(async()=>{const{diagram:r}=await import("./infoDiagram-LFFYTUFH-CGJpKZSz.js");return{diagram:r}},__vite__mapDeps([70,66,49,51,52]),import.meta.url);return{id:Ose,diagram:e}},"loader"),Nqe={id:Ose,detector:Cqe,loader:jqe},Rse="pie",Tqe=Y(e=>/^\s*pie/.test(e),"detector"),Eqe=Y(async()=>{const{diagram:e}=await Ge(async()=>{const{diagram:r}=await import("./pieDiagram-SKSYHLDU-BS3wAXZT.js");return{diagram:r}},__vite__mapDeps([71,64,66,49,51,52,72]),import.meta.url);return{id:Rse,diagram:e}},"loader"),Aqe={id:Rse,detector:Tqe,loader:Eqe},Mse="quadrantChart",Oqe=Y(e=>/^\s*quadrantChart/.test(e),"detector"),Rqe=Y(async()=>{const{diagram:e}=await Ge(async()=>{const{diagram:r}=await import("./quadrantDiagram-337W2JSQ-Cm0jHWPc.js");return{diagram:r}},__vite__mapDeps([73,68,69]),import.meta.url);return{id:Mse,diagram:e}},"loader"),Mqe={id:Mse,detector:Oqe,loader:Rqe},Pqe=Mqe,Pse="xychart",Lqe=Y(e=>/^\s*xychart(-beta)?/.test(e),"detector"),$qe=Y(async()=>{const{diagram:e}=await Ge(async()=>{const{diagram:r}=await import("./xychartDiagram-JWTSCODW-CwMt6Z8n.js");return{diagram:r}},__vite__mapDeps([74,68,69]),import.meta.url);return{id:Pse,diagram:e}},"loader"),Dqe={id:Pse,detector:Lqe,loader:$qe},Iqe=Dqe,Lse="requirement",Bqe=Y(e=>/^\s*requirement(Diagram)?/.test(e),"detector"),zqe=Y(async()=>{const{diagram:e}=await Ge(async()=>{const{diagram:r}=await import("./requirementDiagram-Z7DCOOCP-CLRswCzL.js");return{diagram:r}},__vite__mapDeps([75,59,60]),import.meta.url);return{id:Lse,diagram:e}},"loader"),Fqe={id:Lse,detector:Bqe,loader:zqe},Hqe=Fqe,$se="sequence",Wqe=Y(e=>/^\s*sequenceDiagram/.test(e),"detector"),Uqe=Y(async()=>{const{diagram:e}=await Ge(async()=>{const{diagram:r}=await import("./sequenceDiagram-2WXFIKYE-Dmcxwid4.js");return{diagram:r}},__vite__mapDeps([76,56,65]),import.meta.url);return{id:$se,diagram:e}},"loader"),Vqe={id:$se,detector:Wqe,loader:Uqe},qqe=Vqe,Dse="class",Gqe=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"),Kqe=Y(async()=>{const{diagram:e}=await Ge(async()=>{const{diagram:r}=await import("./classDiagram-VBA2DB6C-Dw1gEIva.js");return{diagram:r}},__vite__mapDeps([77,78,58,56,59,60]),import.meta.url);return{id:Dse,diagram:e}},"loader"),Yqe={id:Dse,detector:Gqe,loader:Kqe},Xqe=Yqe,Ise="classDiagram",Zqe=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"),Jqe=Y(async()=>{const{diagram:e}=await Ge(async()=>{const{diagram:r}=await import("./classDiagram-v2-RAHNMMFH-Dw1gEIva.js");return{diagram:r}},__vite__mapDeps([79,78,58,56,59,60]),import.meta.url);return{id:Ise,diagram:e}},"loader"),Qqe={id:Ise,detector:Zqe,loader:Jqe},eGe=Qqe,Bse="state",tGe=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"),rGe=Y(async()=>{const{diagram:e}=await Ge(async()=>{const{diagram:r}=await import("./stateDiagram-RAJIS63D-Qws-YJqW.js");return{diagram:r}},__vite__mapDeps([80,81,59,60,48,49,50,51]),import.meta.url);return{id:Bse,diagram:e}},"loader"),nGe={id:Bse,detector:tGe,loader:rGe},iGe=nGe,zse="stateDiagram",sGe=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"),oGe=Y(async()=>{const{diagram:e}=await Ge(async()=>{const{diagram:r}=await import("./stateDiagram-v2-FVOUBMTO-2Ms8hEFm.js");return{diagram:r}},__vite__mapDeps([82,81,59,60]),import.meta.url);return{id:zse,diagram:e}},"loader"),aGe={id:zse,detector:sGe,loader:oGe},lGe=aGe,Fse="journey",cGe=Y(e=>/^\s*journey/.test(e),"detector"),uGe=Y(async()=>{const{diagram:e}=await Ge(async()=>{const{diagram:r}=await import("./journeyDiagram-4ABVD52K-BSf3HgNR.js");return{diagram:r}},__vite__mapDeps([83,58,56,72]),import.meta.url);return{id:Fse,diagram:e}},"loader"),dGe={id:Fse,detector:cGe,loader:uGe},hGe=dGe,fGe=Y((e,r,n)=>{St.debug(`rendering svg for syntax error
1125
+ `);const i=lBe(r),s=i.append("g");i.attr("viewBox","0 0 2412 512"),gee(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"),Hse={draw:fGe},pGe=Hse,mGe={db:{},renderer:Hse,parser:{parse:Y(()=>{},"parse")}},gGe=mGe,Wse="flowchart-elk",yGe=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"),vGe=Y(async()=>{const{diagram:e}=await Ge(async()=>{const{diagram:r}=await import("./flowDiagram-PKNHOUZH-DpkviZuG.js");return{diagram:r}},__vite__mapDeps([57,58,56,59,60,61]),import.meta.url);return{id:Wse,diagram:e}},"loader"),xGe={id:Wse,detector:yGe,loader:vGe},bGe=xGe,Use="timeline",_Ge=Y(e=>/^\s*timeline/.test(e),"detector"),wGe=Y(async()=>{const{diagram:e}=await Ge(async()=>{const{diagram:r}=await import("./timeline-definition-YZTLITO2-Daycq3BS.js");return{diagram:r}},__vite__mapDeps([84,72]),import.meta.url);return{id:Use,diagram:e}},"loader"),SGe={id:Use,detector:_Ge,loader:wGe},kGe=SGe,Vse="mindmap",CGe=Y(e=>/^\s*mindmap/.test(e),"detector"),jGe=Y(async()=>{const{diagram:e}=await Ge(async()=>{const{diagram:r}=await import("./mindmap-definition-YRQLILUH-CefPS_aA.js");return{diagram:r}},__vite__mapDeps([85,59,60]),import.meta.url);return{id:Vse,diagram:e}},"loader"),NGe={id:Vse,detector:CGe,loader:jGe},TGe=NGe,qse="kanban",EGe=Y(e=>/^\s*kanban/.test(e),"detector"),AGe=Y(async()=>{const{diagram:e}=await Ge(async()=>{const{diagram:r}=await import("./kanban-definition-K7BYSVSG-DXs_wEuy.js");return{diagram:r}},__vite__mapDeps([86,58]),import.meta.url);return{id:qse,diagram:e}},"loader"),OGe={id:qse,detector:EGe,loader:AGe},RGe=OGe,Gse="sankey",MGe=Y(e=>/^\s*sankey(-beta)?/.test(e),"detector"),PGe=Y(async()=>{const{diagram:e}=await Ge(async()=>{const{diagram:r}=await import("./sankeyDiagram-WA2Y5GQK-CeD4zAS6.js");return{diagram:r}},[],import.meta.url);return{id:Gse,diagram:e}},"loader"),LGe={id:Gse,detector:MGe,loader:PGe},$Ge=LGe,Kse="packet",DGe=Y(e=>/^\s*packet(-beta)?/.test(e),"detector"),IGe=Y(async()=>{const{diagram:e}=await Ge(async()=>{const{diagram:r}=await import("./diagram-P4PSJMXO-DMoyTfQb.js");return{diagram:r}},__vite__mapDeps([87,64,66,49,51,52]),import.meta.url);return{id:Kse,diagram:e}},"loader"),BGe={id:Kse,detector:DGe,loader:IGe},Yse="radar",zGe=Y(e=>/^\s*radar-beta/.test(e),"detector"),FGe=Y(async()=>{const{diagram:e}=await Ge(async()=>{const{diagram:r}=await import("./diagram-IFDJBPK2-DHiv3xvn.js");return{diagram:r}},__vite__mapDeps([88,64,66,49,51,52]),import.meta.url);return{id:Yse,diagram:e}},"loader"),HGe={id:Yse,detector:zGe,loader:FGe},Xse="block",WGe=Y(e=>/^\s*block(-beta)?/.test(e),"detector"),UGe=Y(async()=>{const{diagram:e}=await Ge(async()=>{const{diagram:r}=await import("./blockDiagram-WCTKOSBZ-F6w5rbVO.js");return{diagram:r}},__vite__mapDeps([89,58,52,49,48,61]),import.meta.url);return{id:Xse,diagram:e}},"loader"),VGe={id:Xse,detector:WGe,loader:UGe},qGe=VGe,Zse="architecture",GGe=Y(e=>/^\s*architecture/.test(e),"detector"),KGe=Y(async()=>{const{diagram:e}=await Ge(async()=>{const{diagram:r}=await import("./architectureDiagram-2XIMDMQ5-DHQAkY8U.js");return{diagram:r}},__vite__mapDeps([90,64,66,49,51,52,54]),import.meta.url);return{id:Zse,diagram:e}},"loader"),YGe={id:Zse,detector:GGe,loader:KGe},XGe=YGe,Jse="ishikawa",ZGe=Y(e=>/^\s*ishikawa(-beta)?\b/i.test(e),"detector"),JGe=Y(async()=>{const{diagram:e}=await Ge(async()=>{const{diagram:r}=await import("./ishikawaDiagram-PHBUUO56-Dk1Thix7.js");return{diagram:r}},[],import.meta.url);return{id:Jse,diagram:e}},"loader"),QGe={id:Jse,detector:ZGe,loader:JGe},Qse="venn",eKe=Y(e=>/^\s*venn-beta/.test(e),"detector"),tKe=Y(async()=>{const{diagram:e}=await Ge(async()=>{const{diagram:r}=await import("./vennDiagram-LZ73GAT5-C8x6lkPc.js");return{diagram:r}},[],import.meta.url);return{id:Qse,diagram:e}},"loader"),rKe={id:Qse,detector:eKe,loader:tKe},nKe=rKe,eoe="treemap",iKe=Y(e=>/^\s*treemap/.test(e),"detector"),sKe=Y(async()=>{const{diagram:e}=await Ge(async()=>{const{diagram:r}=await import("./diagram-E7M64L7V-DEA2XDBr.js");return{diagram:r}},__vite__mapDeps([91,60,64,66,49,51,52,69]),import.meta.url);return{id:eoe,diagram:e}},"loader"),oKe={id:eoe,detector:iKe,loader:sKe},$F=!1,l6=Y(()=>{$F||($F=!0,A5("error",gGe,e=>e.toLowerCase().trim()==="error"),A5("---",{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("---")),jA(bGe,TGe,XGe),jA(iqe,RGe,eGe,Xqe,gqe,kqe,Nqe,Aqe,Hqe,qqe,hqe,lqe,kGe,bqe,lGe,iGe,hGe,Pqe,$Ge,BGe,Iqe,qGe,HGe,QGe,oKe,nKe))},"addDiagrams"),aKe=Y(async()=>{St.debug("Loading registered diagrams");const r=(await Promise.allSettled(Object.entries(j0).map(async([n,{detector:i,loader:s}])=>{if(s)try{AA(n)}catch{try{const{diagram:o,id:a}=await s();A5(a,o,i)}catch(o){throw St.error(`Failed to load external diagram with key ${n}. Removing from detectors.`),delete j0[n],o}}}))).filter(n=>n.status==="rejected");if(r.length>0){St.error(`Failed to load ${r.length} external diagrams`);for(const n of r)St.error(n);throw new Error(`Failed to load ${r.length} external diagrams`)}},"loadRegisteredDiagrams"),lKe="graphics-document document";function toe(e,r){e.attr("role",lKe),r!==""&&e.attr("aria-roledescription",r)}Y(toe,"setA11yDiagramInfo");function roe(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(roe,"addSVGa11yTitleDescription");var y0,bO=(y0=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=Aa(),s=Z9(r,i);r=dWe(r)+`
1126
1126
  `;try{AA(s)}catch{const p=QMe(s);if(!p)throw new ree(`Diagram ${s} not found.`);const{id:g,diagram:v}=await p();A5(g,v)}const{db:o,parser:a,renderer:l,init:d}=AA(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 y0(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(y0,"Diagram"),y0),DF=[],cKe=Y(()=>{DF.forEach(e=>{e()}),DF=[]},"attachFunctions"),uKe=Y(e=>e.replace(/^\s*%%(?!{)[^\n]+\n?/gm,"").trimStart(),"cleanupComments");function noe(e){const r=e.match(tee);if(!r)return{text:e,metadata:{}};let n=mze(r[1],{schema:pze})??{};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(noe,"extractFrontMatter");var dKe=Y(e=>e.replace(/\r\n?/g,`
1127
1127
  `).replace(/<(\w+)([^>]*)>/g,(r,n,i)=>"<"+n+i.replace(/="([^"]*)"/g,"='$1'")+">"),"cleanupText"),hKe=Y(e=>{const{text:r,metadata:n}=noe(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"),fKe=Y(e=>{const r=od.detectInit(e)??{},n=od.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:JHe(e),directive:r}},"processDirectives");function ZM(e){const r=dKe(e),n=hKe(r),i=fKe(n.text),s=LM(n.config,i.directive);return e=uKe(i.text),{code:e,title:n.title,config:s}}Y(ZM,"preprocessDiagram");function ioe(e){const r=new TextEncoder().encode(e),n=Array.from(r,i=>String.fromCodePoint(i)).join("");return btoa(n)}Y(ioe,"toBase64");var pKe=5e4,mKe="graph TB;a[Maximum text size in diagram exceeded];style a fill:#faa",gKe="sandbox",yKe="loose",vKe="http://www.w3.org/2000/svg",xKe="http://www.w3.org/1999/xlink",bKe="http://www.w3.org/1999/xhtml",_Ke="100%",wKe="100%",SKe="border:0;margin:0;",kKe="margin:0",CKe="allow-top-navigation-by-user-activation allow-popups",jKe='The "iframe" tag is not supported by your browser.',NKe=["foreignobject"],TKe=["dominant-baseline"];function JM(e){const r=ZM(e);return T5(),mPe(r.config??{}),r}Y(JM,"processAndSetConfigs");async function soe(e,r){l6();try{const{code:n,config:i}=JM(e);return{diagramType:(await aoe(n)).type,config:i}}catch(n){if(r!=null&&r.suppressErrors)return!1;throw n}}Y(soe,"parse");var IF=Y((e,r,n=[])=>`
1128
1128
  .${e} ${r} { ${n.join(" !important; ")} !important; }`,"cssImportantStyles"),EKe=Y((e,r=new Map)=>{let n="";if(e.themeCSS!==void 0&&(n+=`
@@ -1258,7 +1258,7 @@ WARNING: This link could potentially be dangerous`)){let n=window.open();if(n){t
1258
1258
  * Fabrice Bellard's javascript vt100 for jslinux:
1259
1259
  * http://bellard.org/jslinux/
1260
1260
  * Copyright (c) 2011 Fabrice Bellard
1261
- */var jft=class{constructor(e,r,n,i={}){this._terminal=e,this._regex=r,this._handler=n,this._options=i}provideLinks(e,r){let n=Tft.computeLink(e,this._regex,this._terminal,this._handler);r(this._addCallbacks(n))}_addCallbacks(e){return e.map(r=>(r.leave=this._options.leave,r.hover=(n,i)=>{if(this._options.hover){let{range:s}=r;this._options.hover(n,i,s)}},r))}};function Nft(e){try{let r=new URL(e),n=r.password&&r.username?`${r.protocol}//${r.username}:${r.password}@${r.host}`:r.username?`${r.protocol}//${r.username}@${r.host}`:`${r.protocol}//${r.host}`;return e.toLocaleLowerCase().startsWith(n.toLocaleLowerCase())}catch{return!1}}var Tft=class HC{static computeLink(r,n,i,s){let o=new RegExp(n.source,(n.flags||"")+"g"),[a,l]=HC._getWindowedLineStrings(r-1,i),d=a.join(""),u,f=[];for(;u=o.exec(d);){let p=u[0];if(!Nft(p))continue;let[g,v]=HC._mapStrIdx(i,l,0,u.index),[b,_]=HC._mapStrIdx(i,g,v,p.length);if(g===-1||v===-1||b===-1||_===-1)continue;let S={start:{x:v+1,y:g+1},end:{x:_,y:b+1}};f.push({range:S,text:p,activate:s})}return f}static _getWindowedLineStrings(r,n){let i,s=r,o=r,a=0,l="",d=[];if(i=n.buffer.active.getLine(r)){let u=i.translateToString(!0);if(i.isWrapped&&u[0]!==" "){for(a=0;(i=n.buffer.active.getLine(--s))&&a<2048&&(l=i.translateToString(!0),a+=l.length,d.push(l),!(!i.isWrapped||l.indexOf(" ")!==-1)););d.reverse()}for(d.push(u),a=0;(i=n.buffer.active.getLine(++o))&&i.isWrapped&&a<2048&&(l=i.translateToString(!0),a+=l.length,d.push(l),l.indexOf(" ")===-1););}return[d,s]}static _mapStrIdx(r,n,i,s){let o=r.buffer.active,a=o.getNullCell(),l=i;for(;s;){let d=o.getLine(n);if(!d)return[-1,-1];for(let u=l;u<d.length;++u){d.getCell(u,a);let f=a.getChars();if(a.getWidth()&&(s-=f.length||1,u===d.length-1&&f==="")){let p=o.getLine(n+1);p&&p.isWrapped&&(p.getCell(0,a),a.getWidth()===2&&(s+=1))}if(s<0)return[n,u]}n++,l=0}return[n,l]}},Eft=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function Aft(e,r){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=r}else console.warn("Opening link blocked as opener could not be cleared")}var Oft=class{constructor(e=Aft,r={}){this._handler=e,this._options=r}activate(e){this._terminal=e;let r=this._options,n=r.urlRegex||Eft;this._linkProvider=this._terminal.registerLinkProvider(new jft(this._terminal,n,this._handler,r))}dispose(){var e;(e=this._linkProvider)==null||e.dispose()}};function Rft(e,r,n){if(!n||n.type!=="terminal.output"||n.terminalId!==r)return!1;if(!n.streamId||typeof n.seq!="number")return!0;const i=e.get(n.streamId)??-1;return n.seq<=i?!1:(e.set(n.streamId,n.seq),!0)}const W_=Ln(),Mft=Y0(),Pft=140,Lft=72,qg=8,$ft=250;function U_(e){return e?{Authorization:`Bearer ${e}`}:{}}function vV(e){var r;return{...e,workspaceRoot:((r=e.metadata)==null?void 0:r.cwd)??e.workspaceRoot??null}}function Bb(e,r,n){const i=e.getPropertyValue(r).trim();return i?`hsl(${i})`:n}function xV(){const e=getComputedStyle(document.documentElement);return{background:Bb(e,"--background","#0a0a0a"),foreground:Bb(e,"--foreground","#e4e4e7"),cursor:Bb(e,"--foreground","#e4e4e7"),cursorAccent:Bb(e,"--background","#0a0a0a"),selectionBackground:Bb(e,"--primary","#2563eb")}}async function bV(e,r){var i;const n=typeof window<"u"?(i=window.jaitDesktop)==null?void 0:i.readClipboardText:void 0;if(!n&&!(e!=null&&e.readText))return!1;try{const s=n?await n():await e.readText();return s?(r(s),!0):!1}catch{if(!(e!=null&&e.readText))return!1;try{const s=await e.readText();return s?(r(s),!0):!1}catch{return!1}}}function Dft(e,r,n,i,s=Pft,o=Lft){const a=Math.max(qg,n-s-qg),l=Math.min(Math.max(e,qg),a),u=r+o+qg<=i?r:r-o,f=Math.max(qg,i-o-qg),p=Math.min(Math.max(u,qg),f);return{left:l,top:p}}function Ift(e,r){var i,s;const n=((i=e.clipboardData)==null?void 0:i.getData("text/plain"))||((s=e.clipboardData)==null?void 0:s.getData("text"));return n?(e.preventDefault(),r(n),!0):!1}function Bft(e){return e.type!=="keydown"||e.altKey||e.shiftKey?!1:(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()==="v"}function zft(e,r,n){return e===""&&n-r>=0&&n-r<=$ft}function Fft(e){const[r,n]=y.useState([]),[i,s]=y.useState(null),o=y.useCallback(async()=>{try{const p=(await(await fetch(`${W_}/api/terminals`,{headers:U_(e)})).json()).terminals.map(vV);return n(p),p}catch{return[]}},[e]),a=y.useRef(!1),l=y.useCallback(async(u,f,p)=>{if(a.current)return r[0]??{id:"",type:"terminal",state:"idle",sessionId:u,workspaceRoot:f??null,metadata:{}};a.current=!0;try{const g=await fetch(`${W_}/api/terminals`,{method:"POST",headers:{"Content-Type":"application/json",...U_(e)},body:JSON.stringify({sessionId:u,workspaceRoot:f,...p?{shell:p}:{}})}),v=vV(await g.json());return n(b=>[...b,v]),s(v.id),v}finally{a.current=!1}},[e,r]),d=y.useCallback(async u=>{await fetch(`${W_}/api/terminals/${u}`,{method:"DELETE",headers:U_(e)}),n(f=>f.filter(p=>p.id!==u)),s(f=>f===u?null:f)},[e]);return y.useEffect(()=>{o()},[o]),{terminals:r,activeTerminalId:i,setActiveTerminalId:s,createTerminal:l,killTerminal:d,refresh:o}}function Hft(e){const[r,n]=y.useState([]),i=y.useRef(!1);return y.useEffect(()=>{i.current||(i.current=!0,(async()=>{try{const o=await(await fetch(`${W_}/api/terminals/shells`,{headers:U_(e)})).json();n(o.shells??[])}catch{}})())},[e]),r}const N4=y.forwardRef(function({terminalId:r,className:n,token:i,workspaceRoot:s,onReferenceSelection:o},a){const l=y.useRef(null),d=y.useRef(null),u=y.useRef(null),f=y.useRef(null),p=y.useRef(null),g=Toe(),[v,b]=y.useState(null);y.useImperativeHandle(a,()=>({focus(){var w;(w=d.current)==null||w.focus()}}),[]),y.useEffect(()=>{if(!l.current)return;const w=new wft({cursorBlink:!0,fontSize:13,fontFamily:"'Cascadia Code', 'Fira Code', 'JetBrains Mono', monospace",theme:xV(),allowProposedApi:!0}),C=new Cft,j=new Oft;w.loadAddon(C),w.loadAddon(j),w.open(l.current);const T=te=>{H&&H.readyState===WebSocket.OPEN&&H.send(JSON.stringify({type:"terminal.input",terminalId:r,data:te}))};let N=0,A=0,R=null;const $=()=>{R&&clearTimeout(R),R=setTimeout(()=>{R=null,!(A>=N)&&bV(navigator.clipboard,T)},30)};w.attachCustomKeyEventHandler(te=>(Bft(te)&&(N=Date.now(),$()),!0));const B=()=>{const te=w.getSelection().trim();if(!te){p.current=null;return}const ne=`${r}:${te}`;if(p.current===ne)return;p.current=ne;const me=w.getSelectionPosition();o==null||o(r,te,s,me==null?void 0:me.start.y,me==null?void 0:me.end.y)};requestAnimationFrame(()=>{C.fit(),w.focus()});const P=setTimeout(()=>{C.fit(),w.focus()},150);d.current=w,u.current=C;let H=null,U=null,q=!1,M=1e3,I=!1;const L=3e4,z=new Map;function G(){U&&(clearTimeout(U),U=null)}function X(){H&&(H.onclose=null,H.close(),H=null,f.current=null)}function F(){if(q||typeof document<"u"&&document.hidden)return;const te=i?`?token=${encodeURIComponent(i)}`:"";H=new WebSocket(`${Mft}${te}`),f.current=H,H.onopen=()=>{M=1e3,H.send(JSON.stringify({type:"terminal.subscribe",terminalId:r}))},H.onmessage=ne=>{try{const me=JSON.parse(ne.data);Rft(z,r,me.payload)&&w.write(me.payload.data??"")}catch{}},H.onclose=()=>{!q&&!I&&(U=setTimeout(F,M),M=Math.min(M*1.5,L))},H.onerror=()=>{}}const W=()=>{const te=typeof document<"u"&&document.hidden;if(I=te,te){G(),X();return}M=1e3,H||F()};F(),typeof document<"u"&&document.addEventListener("visibilitychange",W),w.onData(te=>{zft(te,N,Date.now())||T(te)}),w.onResize(({cols:te,rows:ne})=>{H&&H.readyState===WebSocket.OPEN&&H.send(JSON.stringify({type:"terminal.resize",terminalId:r,cols:te,rows:ne})),fetch(`${W_}/api/terminals/${r}/resize`,{method:"POST",headers:{"Content-Type":"application/json",...U_(i)},body:JSON.stringify({cols:te,rows:ne})})});const Q=new ResizeObserver(()=>{requestAnimationFrame(()=>C.fit())});Q.observe(l.current);const V=l.current,ee=()=>{window.setTimeout(B,0)},re=()=>{window.setTimeout(B,0)},ce=te=>{const ne=w.getSelection();if(!!!window.jaitDesktop){w.focus(),b(null);return}te.preventDefault();const me=Dft(te.clientX,te.clientY,window.innerWidth,window.innerHeight);b({left:me.left,top:me.top,hasSelection:!!ne.trim()})},de=te=>{Ift(te,T)&&(A=Date.now())};return V.addEventListener("mouseup",ee),V.addEventListener("keyup",re),V.addEventListener("contextmenu",ce,{capture:!0}),V.addEventListener("paste",de,{capture:!0}),()=>{q=!0,clearTimeout(P),R&&clearTimeout(R),G(),typeof document<"u"&&document.removeEventListener("visibilitychange",W),Q.disconnect(),V.removeEventListener("mouseup",ee),V.removeEventListener("keyup",re),V.removeEventListener("contextmenu",ce,{capture:!0}),V.removeEventListener("paste",de,{capture:!0}),X(),w.dispose(),d.current=null,u.current=null,f.current=null}},[r,i,s,o]),y.useEffect(()=>{const w=d.current;w&&(w.options.theme=xV())},[g]);const _=y.useCallback(()=>{var j;const w=d.current;if(!w)return;const C=w.getSelection().trim();C&&((j=navigator.clipboard)!=null&&j.writeText)&&navigator.clipboard.writeText(C),b(null),w.focus()},[]),S=y.useCallback(()=>{const w=d.current,C=f.current;w&&(bV(navigator.clipboard,j=>{w.focus(),C&&C.readyState===WebSocket.OPEN&&C.send(JSON.stringify({type:"terminal.input",terminalId:r,data:j}))}),b(null),w.focus())},[r]);return c.jsxs("div",{className:`relative w-full overflow-hidden ${n??""}`,tabIndex:-1,onMouseDown:w=>{var C;v&&b(null),(w.target===w.currentTarget||(C=l.current)!=null&&C.contains(w.target))&&requestAnimationFrame(()=>{var j;return(j=d.current)==null?void 0:j.focus()})},children:[c.jsx("div",{ref:l,className:"h-full w-full",style:{minHeight:0}}),v&&c.jsxs("div",{className:"fixed z-50 min-w-[140px] rounded-md border border-border bg-popover py-1 shadow-md",style:{left:v.left,top:v.top},onMouseDown:w=>w.stopPropagation(),children:[c.jsxs("button",{type:"button",className:"flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm text-popover-foreground hover:bg-accent hover:text-accent-foreground disabled:opacity-40 disabled:pointer-events-none",disabled:!v.hasSelection,onClick:_,children:[c.jsx(xc,{className:"h-3.5 w-3.5"}),"Copy"]}),c.jsxs("button",{type:"button",className:"flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm text-popover-foreground hover:bg-accent hover:text-accent-foreground",onClick:S,children:[c.jsx(Zge,{className:"h-3.5 w-3.5"}),"Paste"]})]})]})}),Gk=16;function _V({terminals:e,activeTerminalId:r,onSelect:n,onCreate:i,onKill:s,onDetach:o,availableShells:a}){const[l,d]=y.useState(!1),u=y.useRef(null),f=y.useRef(null),[p,g]=y.useState(null);y.useEffect(()=>{if(!l)return;const b=_=>{u.current&&!u.current.contains(_.target)&&f.current&&!f.current.contains(_.target)&&d(!1)};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[l]);const v=a&&a.length>1;return c.jsxs("div",{className:"flex items-center gap-1 px-2 h-9 border-b bg-background shrink-0 overflow-x-auto",children:[e.map(b=>c.jsxs("div",{role:"tab",tabIndex:0,draggable:!0,onDragStart:_=>{_.dataTransfer.effectAllowed="copy",_.dataTransfer.setData($Q,JSON.stringify(ORe(b.id,b.id.replace(/^term-/,"").slice(0,8),b.workspaceRoot)))},onDragEnd:_=>{if(!o)return;const S=_.clientX<=Gk||_.clientY<=Gk||_.clientX>=window.innerWidth-Gk||_.clientY>=window.innerHeight-Gk,w=_.dataTransfer.dropEffect==="none"&&(_.clientX===0||_.clientY===0);(S||w)&&o(b.id)},onClick:()=>n(b.id),onKeyDown:_=>{(_.key==="Enter"||_.key===" ")&&n(b.id)},className:`group flex items-center gap-1.5 h-6 px-2.5 text-xs rounded-sm border cursor-pointer ${r===b.id?"bg-background text-foreground border-border shadow-sm":"text-muted-foreground border-transparent hover:text-foreground hover:bg-background/50 hover:border-border"}`,children:[c.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${b.state==="running"?"bg-green-500":"bg-zinc-500"}`}),c.jsx("span",{className:"truncate max-w-[100px]",children:b.id.replace(/^term-/,"").slice(0,8)}),c.jsx("button",{onClick:_=>{_.stopPropagation(),s(b.id)},className:"text-muted-foreground hover:text-destructive ml-0.5 text-sm leading-none","aria-label":"Close terminal",children:"×"})]},b.id)),c.jsxs("div",{className:"flex items-center",children:[c.jsx("button",{onClick:()=>i(),className:"px-2 py-1 text-sm text-muted-foreground hover:text-foreground","aria-label":"New terminal",children:"+"}),v&&c.jsx("button",{ref:f,onClick:()=>{var _;if(l){d(!1);return}const b=(_=f.current)==null?void 0:_.getBoundingClientRect();b&&g({top:b.bottom+4,left:b.left}),d(!0)},className:"px-0.5 py-1 text-muted-foreground hover:text-foreground","aria-label":"Select shell type",children:c.jsx(ul,{className:"h-3 w-3"})})]}),l&&v&&p&&c.jsx("div",{ref:u,className:"fixed z-50 min-w-[120px] rounded-md border bg-popover p-1 shadow-md",style:{top:p.top,left:p.left},children:a.map(b=>c.jsx("button",{onClick:()=>{i(b.shell),d(!1)},className:"flex w-full items-center rounded-sm px-2 py-1.5 text-xs hover:bg-accent hover:text-accent-foreground transition-colors",children:b.label},b.shell))})]})}const T4=Ln(),y1={gateway:"#22c55e",device:"#3b82f6",mesh:"#a855f7",host:"#6b7280"},wV={gateway:28,device:20,mesh:20,host:16};function Wft(e){if(e.length===0)return e;const r=[{type:"device",radius:150},{type:"mesh",radius:235},{type:"host",radius:325}],n=e.map(i=>i.data.type==="gateway"?{...i,x:0,y:0,fx:0,fy:0}:{...i});for(const{type:i,radius:s}of r){const o=n.filter(l=>l.data.type===i),a=o.length;a!==0&&o.forEach((l,d)=>{const u=-Math.PI/2+Math.PI*2/a*d;l.x=Math.cos(u)*s,l.y=Math.sin(u)*s})}return n}const Uft="M0 3.449L9.75 2.1V11.551H0zm10.949-1.564L24 0v11.551H10.949zM0 12.449h9.75v9.451L0 20.551zm10.949-.898H24V24l-13.051-1.869z";function zb(e,r,n="0 0 24 24"){const i=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="${n}" fill="${r}"><path d="${e}"/></svg>`;return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(i)}`}function Fb(e){const r=new Image;return r.src=e,r}const Kk={windows:Fb(zb(Uft,"#ffffff")),macos:Fb(zb(SU.path,"#ffffff")),linux:Fb(zb(fut.path,"#ffffff")),android:Fb(zb(hut.path,"#ffffff")),ios:Fb(zb(SU.path,"#ffffff"))};function Vft(e){if(!e)return null;const r=e.toLowerCase();return r.includes("windows")?"windows":r.includes("macos")||r.includes("mac os")||r.includes("darwin")?"macos":r.includes("android")?"android":r.includes("ios")||r.includes("iphone")||r.includes("ipad")?"ios":r.includes("linux")||r.includes("ubuntu")||r.includes("debian")||r.includes("fedora")||r.includes("arch")||r.includes("centos")||r.includes("rhel")||r.includes("mint")||r.includes("manjaro")||r.includes("suse")||r.includes("alpine")?"linux":null}function qft(e){if("platform"in e&&typeof e.platform=="string"&&Kk[e.platform])return Kk[e.platform];if("osVersion"in e){const r=Vft(e.osVersion);if(r&&Kk[r])return Kk[r]}return null}function Gft({node:e,onClose:r,onDeploy:n}){const i=e?e.type==="gateway"?co:e.type==="device"?"platform"in e&&(e.platform==="android"||e.platform==="ios")?X4:Ea:e.type==="mesh"?bi:"isRouter"in e&&e.isRouter?j1:Ea:Ea,s=e?y1[e.type]??"#6b7280":"#6b7280",o=e&&"sshReachable"in e&&e.sshReachable&&"agentStatus"in e&&e.agentStatus!=="running"&&"ip"in e;return c.jsx("div",{className:ze("absolute right-0 top-0 bottom-0 w-72 bg-background border-l z-10 flex flex-col transition-transform duration-200 ease-in-out",e?"translate-x-0":"translate-x-full"),children:e&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b shrink-0",children:[c.jsx("div",{className:"h-8 w-8 rounded-lg flex items-center justify-center shrink-0",style:{backgroundColor:`${s}22`,color:s},children:c.jsx(i,{className:"h-4 w-4"})}),c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsx("div",{className:"truncate text-sm font-medium",children:e.name}),c.jsx("div",{className:"text-xs text-muted-foreground capitalize",children:"isRouter"in e&&e.isRouter?"router":e.type})]}),c.jsx(be,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:r,children:c.jsx(Yn,{className:"h-3.5 w-3.5"})})]}),c.jsxs("div",{className:"flex-1 overflow-y-auto px-4 py-3 space-y-3 text-sm",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:`h-2.5 w-2.5 rounded-full ${e.online?"bg-green-500":"bg-red-500"}`}),c.jsx("span",{children:e.online?"Online":"Offline"})]}),"platform"in e&&e.platform&&c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-muted-foreground",children:"Platform"}),c.jsx("span",{className:"flex items-center gap-1.5 capitalize",children:e.platform})]}),"ip"in e&&e.ip&&c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-muted-foreground",children:"IP Address"}),c.jsx("code",{className:"text-xs bg-muted px-2 py-0.5 rounded",children:e.ip})]}),"isRouter"in e&&e.isRouter&&c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-muted-foreground",children:"Role"}),c.jsx(on,{variant:"secondary",className:"text-2xs",children:"Router"})]}),"version"in e&&e.version&&c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-muted-foreground",children:"Version"}),c.jsxs(on,{variant:"secondary",className:"font-mono text-2xs",children:["v",e.version]})]}),"osVersion"in e&&e.osVersion&&c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-muted-foreground",children:"OS"}),c.jsx("span",{className:"text-xs",children:e.osVersion})]}),"mac"in e&&e.mac&&c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-muted-foreground",children:"MAC Address"}),c.jsx("code",{className:"text-xs bg-muted px-2 py-0.5 rounded",children:e.mac})]}),"providers"in e&&e.providers.length>0&&c.jsxs("div",{children:[c.jsx("span",{className:"text-muted-foreground block mb-1.5",children:"Providers"}),c.jsx("div",{className:"flex flex-wrap gap-1",children:e.providers.map(a=>c.jsxs(on,{variant:"outline",className:"text-2xs",children:[c.jsx(Io,{className:"h-2.5 w-2.5 mr-1"}),a]},a))})]}),"openPorts"in e&&e.openPorts.length>0&&c.jsxs("div",{children:[c.jsx("span",{className:"text-muted-foreground block mb-1.5",children:"Open Ports"}),c.jsx("div",{className:"flex flex-wrap gap-1",children:e.openPorts.map(a=>c.jsx(on,{variant:"outline",className:"text-2xs font-mono",children:a},a))})]}),"sshReachable"in e&&c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-muted-foreground",children:"SSH"}),c.jsxs("span",{className:"flex items-center gap-1.5",children:[c.jsx(Y4,{className:"h-3 w-3"}),e.sshReachable?"Reachable":"Not reachable"]})]}),"agentStatus"in e&&c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-muted-foreground",children:"Agent"}),c.jsx(on,{variant:e.agentStatus==="running"?"default":"secondary",className:"text-2xs",children:e.agentStatus})]}),"registeredAt"in e&&e.registeredAt&&c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-muted-foreground",children:"Connected"}),c.jsx("span",{className:"text-xs",children:new Date(e.registeredAt).toLocaleString()})]}),"agentStatus"in e&&e.agentStatus==="running"&&"ip"in e&&c.jsx(be,{size:"sm",variant:"outline",className:"w-full mt-2",asChild:!0,children:c.jsxs("a",{href:`http://${e.ip}:8000`,target:"_blank",rel:"noopener noreferrer",children:[c.jsx(bi,{className:"h-3.5 w-3.5 mr-1.5"}),"Open Dashboard"]})}),o&&n&&c.jsxs(be,{size:"sm",variant:"default",className:"w-full mt-2",onClick:()=>{n(e.ip),r()},children:[c.jsx(L8,{className:"h-3.5 w-3.5 mr-1.5"}),"Deploy Node"]})]})]})})}function Kft({ip:e,token:r,sessionId:n,onClose:i}){const[s,o]=y.useState([]),[a,l]=y.useState("ready"),[d,u]=y.useState(""),[f,p]=y.useState(null),[g,v]=y.useState(!1),b=y.useRef(null);return y.useEffect(()=>{b.current&&(b.current.scrollTop=b.current.scrollHeight)},[s]),y.useEffect(()=>{if(!e||!g)return;o([]),l("starting");const _=new AbortController;return(async()=>{try{const w={"Content-Type":"application/json"};r&&(w.Authorization=`Bearer ${r}`);const C=await fetch(`${T4}/api/terminals`,{method:"POST",headers:w,body:JSON.stringify({sessionId:n}),signal:_.signal});if(!C.ok){o(N=>[...N,`Error: ${C.statusText}`]),l("error");return}const j=await C.json();p(j.id);const T=await fetch(`${T4}/api/network/deploy`,{method:"POST",headers:w,body:JSON.stringify({ip:e,username:d||"root",terminalId:j.id,sessionId:n}),signal:_.signal});if(!T.ok){const N=await T.json().catch(()=>null);o(A=>[...A,`Error: ${(N==null?void 0:N.error)??T.statusText}`]),l("error");return}await T.json().catch(()=>null),o([`Deploy started for ${d||"root"}@${e}.`,"Continue here in the embedded terminal below.","SSH and sudo prompts will appear in this side panel."]),l("running")}catch(w){_.signal.aborted||(o(C=>[...C,`Error: ${w instanceof Error?w.message:"Connection failed"}`]),l("error"))}})(),()=>_.abort()},[e,n,g,r,d]),e?c.jsxs("div",{className:"absolute inset-0 z-20 bg-background flex flex-col",children:[c.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b shrink-0",children:[c.jsx(L8,{className:"h-4 w-4 text-primary"}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"text-sm font-medium truncate",children:["Deploy to ",e]}),c.jsxs("div",{className:"text-2xs text-muted-foreground",children:[a==="ready"&&"Ready",a==="starting"&&"Preparing terminal...",a==="running"&&"Interactive session ready",a==="error"&&"Failed"]})]}),c.jsx(be,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:i,children:c.jsx(Yn,{className:"h-3.5 w-3.5"})})]}),g?c.jsxs(c.Fragment,{children:[c.jsxs("div",{ref:b,className:"shrink-0 overflow-y-auto border-b p-3 font-mono text-xs leading-5 space-y-0.5 max-h-32",children:[s.map((_,S)=>c.jsx("div",{className:ze(_.startsWith("✓")?"text-green-500":_.startsWith("✗")?"text-red-500":_.startsWith("[")?"text-blue-400":"text-muted-foreground"),children:_},S)),a==="starting"&&c.jsx("div",{className:"text-muted-foreground animate-pulse",children:"Preparing terminal..."})]}),f&&a==="running"&&c.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[c.jsxs("div",{className:"flex items-center justify-between border-b px-3 py-2 text-2xs text-muted-foreground",children:[c.jsx("span",{children:"Interactive deploy session"}),c.jsxs("span",{className:"truncate",children:["Terminal: ",f]})]}),c.jsx(N4,{terminalId:f,className:"flex-1 min-h-0",token:r})]}),a==="error"&&c.jsx("div",{className:"p-3 border-t shrink-0",children:c.jsx(be,{size:"sm",variant:"outline",className:"w-full",onClick:()=>{v(!1),o([]),l("ready"),p(null)},children:"Try Again"})})]}):c.jsxs("div",{className:"flex-1 flex flex-col gap-3 p-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"text-xs text-muted-foreground",children:"SSH Username"}),c.jsx("input",{type:"text",value:d,onChange:_=>u(_.target.value),placeholder:"root",className:"w-full px-3 py-2 text-sm rounded-md border bg-background",onKeyDown:_=>_.key==="Enter"&&v(!0)})]}),c.jsx("div",{className:"text-2xs text-muted-foreground",children:"Starts a real terminal inside this side panel. If SSH or sudo needs a password, it will prompt here directly."}),c.jsxs(be,{className:"w-full",onClick:()=>v(!0),children:[c.jsx(L8,{className:"h-3.5 w-3.5 mr-1.5"}),"Deploy"]})]})]}):null}function Yft({token:e,sessionId:r}){const n=y.useRef(null),i=y.useRef(void 0),[s,o]=y.useState({width:0,height:0}),[a,l]=y.useState(null),[d,u]=y.useState(!1),[f,p]=y.useState(null),[g,v]=y.useState(null),[b,_]=y.useState(null),[S,w]=y.useState(null),C=y.useCallback(()=>{const H={};return e&&(H.Authorization=`Bearer ${e}`),H},[e]),j=y.useRef(""),T=y.useCallback(async()=>{try{const H=await fetch(`${T4}/api/network/topology`,{headers:C()});if(H.ok){const U=await H.text();U!==j.current&&(j.current=U,l(JSON.parse(U))),v(null)}}catch(H){v(H instanceof Error?H.message:"Failed to fetch topology")}},[C]),N=y.useCallback(async()=>{u(!0),v(null);try{const H=await fetch(`${T4}/api/network/scan`,{method:"POST",headers:{...C(),"Content-Type":"application/json"},body:JSON.stringify({deep:!0})});if(!H.ok)throw new Error(`Scan failed: ${H.status}`);await T()}catch(H){v(H instanceof Error?H.message:"Scan failed")}finally{u(!1)}},[C,T]);y.useEffect(()=>{T();let H=null;const U=()=>{H||(H=setInterval(()=>void T(),6e4))},q=()=>{H&&(clearInterval(H),H=null)},M=()=>{document.hidden?q():U()};return document.addEventListener("visibilitychange",M),document.hidden||U(),()=>{q(),document.removeEventListener("visibilitychange",M)}},[T]),y.useEffect(()=>{const H=n.current;if(!H)return;const U=new ResizeObserver(([q])=>{q&&o({width:q.contentRect.width,height:q.contentRect.height})});return U.observe(H),()=>U.disconnect()},[]);const A=y.useMemo(()=>{if(!a)return{nodes:[],links:[]};const H=[],U=[];H.push({id:a.gateway.id,data:a.gateway});for(const q of a.devices)H.push({id:q.id,data:q}),U.push({source:q.id,target:"gateway",type:"connected"});for(const q of a.meshNodes)H.push({id:q.id,data:q}),U.push({source:q.id,target:"gateway",type:"connected"});for(const q of a.hosts)q.ip!==a.gateway.ip&&(H.push({id:q.id,data:q}),U.push({source:q.id,target:"gateway",type:"scanned"}));return{nodes:Wft(H),links:U}},[a]),R=y.useRef(!1);y.useEffect(()=>{R.current||A.nodes.length===0||(R.current=!0,requestAnimationFrame(()=>{const H=i.current;if(!H)return;const U=H.d3Force("charge");U&&typeof U.strength=="function"&&U.strength(-200);const q=H.d3Force("link");q&&typeof q.distance=="function"&&q.distance(80),H.zoom(3.5,0)}))},[A]);const $=y.useCallback((H,U,q)=>{const{data:M}=H,I=H.x??0,L=H.y??0,z=wV[M.type]??8,G=y1[M.type]??"#6b7280",X=b===H.id,F=(f==null?void 0:f.id)===M.id;M.type==="gateway"&&(U.beginPath(),U.arc(I,L,z+4,0,2*Math.PI),U.fillStyle=`${G}33`,U.fill()),M.type==="host"&&"sshReachable"in M&&M.sshReachable&&(U.beginPath(),U.arc(I,L,z+3,0,2*Math.PI),U.strokeStyle="#f59e0b55",U.lineWidth=1.5/q,U.stroke()),(X||F)&&(U.beginPath(),U.arc(I,L,z+2.5,0,2*Math.PI),U.strokeStyle=G,U.lineWidth=1.5/q,U.stroke()),U.beginPath(),U.arc(I,L,z,0,2*Math.PI),U.fillStyle=G,U.fill(),M.online&&(U.beginPath(),U.arc(I+z*.65,L-z*.65,2.5,0,2*Math.PI),U.fillStyle="#22c55e",U.fill(),U.strokeStyle="#0a0a0a",U.lineWidth=.5,U.stroke());const W=qft(M);if(W!=null&&W.complete&&W.naturalWidth>0){const re=z*1.1;U.drawImage(W,I-re/2,L-re/2,re,re)}const Q=Math.max(3.5,10/q);U.font=`${Q}px -apple-system, BlinkMacSystemFont, sans-serif`,U.textAlign="center",U.textBaseline="top",U.fillStyle=X?"#ffffff":"#a1a1aa";const V=M.name.length>20?M.name.slice(0,18)+"…":M.name;U.fillText(V,I,L+z+3),M.type==="gateway"?(U.font=`bold ${Math.max(3,8/q)}px -apple-system, BlinkMacSystemFont, sans-serif`,U.fillStyle="#22c55e",U.fillText("GATEWAY",I,L+z+3+Q+2)):M.type==="host"&&"isRouter"in M&&M.isRouter&&(U.font=`bold ${Math.max(3,8/q)}px -apple-system, BlinkMacSystemFont, sans-serif`,U.fillStyle="#f59e0b",U.fillText("ROUTER",I,L+z+3+Q+2));const ee="providers"in M&&Array.isArray(M.providers)?M.providers:[];if(ee.length>0){const re=Math.max(2.5,7/q);U.font=`${re}px -apple-system, BlinkMacSystemFont, sans-serif`,U.fillStyle="#a855f7";const ce=M.type==="gateway"?Q*2+6:Q+5;U.fillText(ee.join(" · "),I,L+z+3+ce)}if(M.type==="host"&&"openPorts"in M&&M.openPorts.length>0){const re=M.openPorts.length,ce=Math.max(2.5,7/q);U.font=`bold ${ce}px -apple-system, BlinkMacSystemFont, sans-serif`,U.fillStyle="#3b82f6",U.textAlign="center",U.textBaseline="middle";const de=I-z*.65,te=L-z*.65;U.beginPath(),U.arc(de,te,3.5,0,2*Math.PI),U.fillStyle="#3b82f6",U.fill(),U.fillStyle="#ffffff",U.fillText(String(re),de,te)}},[b,f]),B=y.useCallback((H,U)=>{const q=H.source,M=H.target;(q==null?void 0:q.x)==null||(M==null?void 0:M.x)==null||(U.beginPath(),U.moveTo(q.x,q.y),U.lineTo(M.x,M.y),H.type==="connected"?(U.strokeStyle="#3b82f644",U.lineWidth=1.5,U.setLineDash([])):(U.strokeStyle="#6b728033",U.lineWidth=.5,U.setLineDash([4,4])),U.stroke(),U.setLineDash([]))},[]),P=a?1+a.devices.length+a.meshNodes.length+a.hosts.length:0;return c.jsxs("div",{className:"h-full flex flex-col",children:[c.jsxs("div",{className:"flex items-center justify-between gap-2 border-b px-4 py-3 shrink-0",children:[c.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[c.jsx(j1,{className:"h-4 w-4 text-primary"}),c.jsx("h2",{className:"text-sm font-semibold",children:"Network"}),P>0&&c.jsxs(on,{variant:"secondary",className:"w-[4.75rem] justify-center px-1 text-2xs tabular-nums",children:[P," ",P===1?"node":"nodes"]}),(a==null?void 0:a.scannedAt)&&c.jsxs("span",{className:"text-2xs text-muted-foreground hidden sm:inline",children:["Last scan: ",new Date(a.scannedAt).toLocaleTimeString()]})]}),c.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[c.jsxs(be,{size:"sm",variant:"outline",className:"h-7 px-2 text-xs sm:px-2.5",onClick:()=>void T(),children:[c.jsx(ea,{className:"h-3 w-3 sm:mr-1"}),c.jsx("span",{className:"hidden sm:inline",children:"Refresh"})]}),c.jsx(be,{size:"sm",variant:"default",className:"h-7 px-2 text-xs sm:px-2.5",onClick:()=>void N(),disabled:d,children:d?c.jsxs(c.Fragment,{children:[c.jsx(ir,{className:"h-3 w-3 animate-spin sm:mr-1"}),c.jsx("span",{className:"hidden sm:inline",children:"Scanning..."})]}):c.jsxs(c.Fragment,{children:[c.jsx(Il,{className:"h-3 w-3 sm:mr-1"}),c.jsx("span",{className:"hidden sm:inline",children:a!=null&&a.scannedAt?"Rescan Network":"Discover Devices"})]})})]})]}),g&&c.jsxs("div",{className:"flex items-center gap-2 text-sm text-red-500 bg-red-500/10 px-4 py-2",children:[c.jsx(Yn,{className:"h-3.5 w-3.5 shrink-0"}),g]}),c.jsxs("div",{className:"flex items-center gap-4 px-4 py-2 border-b text-2xs text-muted-foreground shrink-0 flex-wrap",children:[c.jsxs("span",{className:"flex items-center gap-1.5",children:[c.jsx("span",{className:"h-2.5 w-2.5 rounded-full",style:{backgroundColor:y1.gateway}}),"Gateway"]}),c.jsxs("span",{className:"flex items-center gap-1.5",children:[c.jsx("span",{className:"h-2.5 w-2.5 rounded-full",style:{backgroundColor:y1.device}}),"Connected Device"]}),c.jsxs("span",{className:"flex items-center gap-1.5",children:[c.jsx("span",{className:"h-2.5 w-2.5 rounded-full",style:{backgroundColor:y1.mesh}}),"Mesh Node"]}),c.jsxs("span",{className:"flex items-center gap-1.5",children:[c.jsx("span",{className:"h-2.5 w-2.5 rounded-full",style:{backgroundColor:y1.host}}),"Network Host"]}),c.jsxs("span",{className:"flex items-center gap-1.5",children:[c.jsx("span",{className:"h-2.5 w-2.5 rounded-full border border-amber-500/50",style:{backgroundColor:"transparent"}}),"SSH Available"]})]}),c.jsxs("div",{ref:n,className:"flex-1 min-h-0 relative bg-background overflow-hidden",children:[A.nodes.length>0&&s.width>0&&s.height>0?c.jsx(NP,{ref:i,width:s.width,height:s.height,graphData:A,nodeId:"id",nodeCanvasObject:$,nodePointerAreaPaint:(H,U,q)=>{const M=wV[H.data.type]??6;q.beginPath(),q.arc(H.x??0,H.y??0,M+4,0,2*Math.PI),q.fillStyle=U,q.fill()},linkCanvasObject:B,onNodeClick:H=>p(H.data),onNodeHover:H=>_((H==null?void 0:H.id)??null),cooldownTicks:80,d3VelocityDecay:.3,d3AlphaDecay:.02,minZoom:.65,maxZoom:8,enableNodeDrag:!0,enableZoomInteraction:!0,enablePanInteraction:!0,backgroundColor:"transparent"}):a?c.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-3",children:[c.jsx("div",{className:"h-12 w-12 rounded-full bg-muted flex items-center justify-center",children:c.jsx(Ea,{className:"h-6 w-6 text-muted-foreground"})}),c.jsx("div",{className:"text-sm font-medium",children:"No devices found"}),c.jsx("div",{className:"text-xs text-muted-foreground max-w-xs text-center",children:"Run a network scan to discover devices on your local network."}),c.jsxs(be,{size:"sm",onClick:()=>void N(),className:"mt-2",children:[c.jsx(Il,{className:"h-3.5 w-3.5 mr-1.5"}),"Discover Devices"]})]}):c.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-3",children:[c.jsx(ir,{className:"h-8 w-8 animate-spin text-muted-foreground"}),c.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading network topology..."})]}),c.jsx(Gft,{node:f,onClose:()=>p(null),onDeploy:H=>w(H)}),c.jsx("div",{className:ze("absolute top-0 right-0 h-full w-80 border-l bg-background transition-transform duration-200 ease-in-out z-30",S?"translate-x-0":"translate-x-full"),children:c.jsx(Kft,{ip:S,token:e,sessionId:r,onClose:()=>w(null)})})]})]})}function Xft({platform:e,className:r}){switch(e){case"electron":return c.jsx(Ea,{className:r??"h-4 w-4"});case"react-native":return c.jsx(X4,{className:r??"h-4 w-4"});default:return c.jsx(bi,{className:r??"h-4 w-4"})}}function SV({device:e,isLocal:r,isConnected:n,isLoading:i,onConnect:s}){const o=!r&&e.capabilities.includes("screen-share");return c.jsxs("div",{className:`flex items-center gap-3 px-3 py-2.5 rounded-lg text-sm transition-colors
1261
+ */var jft=class{constructor(e,r,n,i={}){this._terminal=e,this._regex=r,this._handler=n,this._options=i}provideLinks(e,r){let n=Tft.computeLink(e,this._regex,this._terminal,this._handler);r(this._addCallbacks(n))}_addCallbacks(e){return e.map(r=>(r.leave=this._options.leave,r.hover=(n,i)=>{if(this._options.hover){let{range:s}=r;this._options.hover(n,i,s)}},r))}};function Nft(e){try{let r=new URL(e),n=r.password&&r.username?`${r.protocol}//${r.username}:${r.password}@${r.host}`:r.username?`${r.protocol}//${r.username}@${r.host}`:`${r.protocol}//${r.host}`;return e.toLocaleLowerCase().startsWith(n.toLocaleLowerCase())}catch{return!1}}var Tft=class HC{static computeLink(r,n,i,s){let o=new RegExp(n.source,(n.flags||"")+"g"),[a,l]=HC._getWindowedLineStrings(r-1,i),d=a.join(""),u,f=[];for(;u=o.exec(d);){let p=u[0];if(!Nft(p))continue;let[g,v]=HC._mapStrIdx(i,l,0,u.index),[b,_]=HC._mapStrIdx(i,g,v,p.length);if(g===-1||v===-1||b===-1||_===-1)continue;let S={start:{x:v+1,y:g+1},end:{x:_,y:b+1}};f.push({range:S,text:p,activate:s})}return f}static _getWindowedLineStrings(r,n){let i,s=r,o=r,a=0,l="",d=[];if(i=n.buffer.active.getLine(r)){let u=i.translateToString(!0);if(i.isWrapped&&u[0]!==" "){for(a=0;(i=n.buffer.active.getLine(--s))&&a<2048&&(l=i.translateToString(!0),a+=l.length,d.push(l),!(!i.isWrapped||l.indexOf(" ")!==-1)););d.reverse()}for(d.push(u),a=0;(i=n.buffer.active.getLine(++o))&&i.isWrapped&&a<2048&&(l=i.translateToString(!0),a+=l.length,d.push(l),l.indexOf(" ")===-1););}return[d,s]}static _mapStrIdx(r,n,i,s){let o=r.buffer.active,a=o.getNullCell(),l=i;for(;s;){let d=o.getLine(n);if(!d)return[-1,-1];for(let u=l;u<d.length;++u){d.getCell(u,a);let f=a.getChars();if(a.getWidth()&&(s-=f.length||1,u===d.length-1&&f==="")){let p=o.getLine(n+1);p&&p.isWrapped&&(p.getCell(0,a),a.getWidth()===2&&(s+=1))}if(s<0)return[n,u]}n++,l=0}return[n,l]}},Eft=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function Aft(e,r){let n=window.open();if(n){try{n.opener=null}catch{}n.location.href=r}else console.warn("Opening link blocked as opener could not be cleared")}var Oft=class{constructor(e=Aft,r={}){this._handler=e,this._options=r}activate(e){this._terminal=e;let r=this._options,n=r.urlRegex||Eft;this._linkProvider=this._terminal.registerLinkProvider(new jft(this._terminal,n,this._handler,r))}dispose(){var e;(e=this._linkProvider)==null||e.dispose()}};function Rft(e,r,n){if(!n||n.type!=="terminal.output"||n.terminalId!==r)return!1;if(!n.streamId||typeof n.seq!="number")return!0;const i=e.get(n.streamId)??-1;return n.seq<=i?!1:(e.set(n.streamId,n.seq),!0)}const W_=Ln(),Mft=Y0(),Pft=140,Lft=72,qg=8,$ft=250;function U_(e){return e?{Authorization:`Bearer ${e}`}:{}}function vV(e){var r;return{...e,workspaceRoot:((r=e.metadata)==null?void 0:r.cwd)??e.workspaceRoot??null}}function Bb(e,r,n){const i=e.getPropertyValue(r).trim();return i?`hsl(${i})`:n}function xV(){const e=getComputedStyle(document.documentElement);return{background:Bb(e,"--background","#0a0a0a"),foreground:Bb(e,"--foreground","#e4e4e7"),cursor:Bb(e,"--foreground","#e4e4e7"),cursorAccent:Bb(e,"--background","#0a0a0a"),selectionBackground:Bb(e,"--primary","#2563eb")}}async function bV(e,r){var i;const n=typeof window<"u"?(i=window.jaitDesktop)==null?void 0:i.readClipboardText:void 0;if(!n&&!(e!=null&&e.readText))return!1;try{const s=n?await n():await e.readText();return s?(r(s),!0):!1}catch{if(!(e!=null&&e.readText))return!1;try{const s=await e.readText();return s?(r(s),!0):!1}catch{return!1}}}function Dft(e,r,n,i,s=Pft,o=Lft){const a=Math.max(qg,n-s-qg),l=Math.min(Math.max(e,qg),a),u=r+o+qg<=i?r:r-o,f=Math.max(qg,i-o-qg),p=Math.min(Math.max(u,qg),f);return{left:l,top:p}}function Ift(e,r){var i,s;const n=((i=e.clipboardData)==null?void 0:i.getData("text/plain"))||((s=e.clipboardData)==null?void 0:s.getData("text"));return n?(e.preventDefault(),r(n),!0):!1}function Bft(e){return e.type!=="keydown"||e.altKey||e.shiftKey?!1:(e.ctrlKey||e.metaKey)&&e.key.toLowerCase()==="v"}function zft(e,r,n){return e===""&&n-r>=0&&n-r<=$ft}function Fft(e){const[r,n]=y.useState([]),[i,s]=y.useState(null),o=y.useCallback(async()=>{try{const p=(await(await fetch(`${W_}/api/terminals`,{headers:U_(e)})).json()).terminals.map(vV);return n(p),p}catch{return[]}},[e]),a=y.useRef(!1),l=y.useCallback(async(u,f,p)=>{if(a.current)return r[0]??{id:"",type:"terminal",state:"idle",sessionId:u,workspaceRoot:f??null,metadata:{}};a.current=!0;try{const g=await fetch(`${W_}/api/terminals`,{method:"POST",headers:{"Content-Type":"application/json",...U_(e)},body:JSON.stringify({sessionId:u,workspaceRoot:f,...p?{shell:p}:{}})}),v=vV(await g.json());return n(b=>[...b,v]),s(v.id),v}finally{a.current=!1}},[e,r]),d=y.useCallback(async u=>{await fetch(`${W_}/api/terminals/${u}`,{method:"DELETE",headers:U_(e)}),n(f=>f.filter(p=>p.id!==u)),s(f=>f===u?null:f)},[e]);return y.useEffect(()=>{o()},[o]),{terminals:r,activeTerminalId:i,setActiveTerminalId:s,createTerminal:l,killTerminal:d,refresh:o}}function Hft(e){const[r,n]=y.useState([]),i=y.useRef(!1);return y.useEffect(()=>{i.current||(i.current=!0,(async()=>{try{const o=await(await fetch(`${W_}/api/terminals/shells`,{headers:U_(e)})).json();n(o.shells??[])}catch{}})())},[e]),r}const N4=y.forwardRef(function({terminalId:r,className:n,token:i,workspaceRoot:s,onReferenceSelection:o},a){const l=y.useRef(null),d=y.useRef(null),u=y.useRef(null),f=y.useRef(null),p=y.useRef(null),g=Toe(),[v,b]=y.useState(null);y.useImperativeHandle(a,()=>({focus(){var w;(w=d.current)==null||w.focus()}}),[]),y.useEffect(()=>{if(!l.current)return;const w=new wft({cursorBlink:!0,fontSize:13,fontFamily:"'Cascadia Code', 'Fira Code', 'JetBrains Mono', monospace",theme:xV(),allowProposedApi:!0}),C=new Cft,j=new Oft;w.loadAddon(C),w.loadAddon(j),w.open(l.current);const T=te=>{H&&H.readyState===WebSocket.OPEN&&H.send(JSON.stringify({type:"terminal.input",terminalId:r,data:te}))};let N=0,A=0,R=null;const $=()=>{R&&clearTimeout(R),R=setTimeout(()=>{R=null,!(A>=N)&&bV(navigator.clipboard,T)},30)};w.attachCustomKeyEventHandler(te=>(Bft(te)&&(N=Date.now(),$()),!0));const B=()=>{const te=w.getSelection().trim();if(!te){p.current=null;return}const ne=`${r}:${te}`;if(p.current===ne)return;p.current=ne;const me=w.getSelectionPosition();o==null||o(r,te,s,me==null?void 0:me.start.y,me==null?void 0:me.end.y)};requestAnimationFrame(()=>{C.fit(),w.focus()});const P=setTimeout(()=>{C.fit(),w.focus()},150);d.current=w,u.current=C;let H=null,U=null,q=!1,M=1e3,I=!1;const L=3e4,z=new Map;function G(){U&&(clearTimeout(U),U=null)}function X(){H&&(H.onclose=null,H.close(),H=null,f.current=null)}function F(){if(q||typeof document<"u"&&document.hidden)return;const te=i?`?token=${encodeURIComponent(i)}`:"";H=new WebSocket(`${Mft}${te}`),f.current=H,H.onopen=()=>{M=1e3,H.send(JSON.stringify({type:"terminal.subscribe",terminalId:r}))},H.onmessage=ne=>{try{const me=JSON.parse(ne.data);Rft(z,r,me.payload)&&w.write(me.payload.data??"")}catch{}},H.onclose=()=>{!q&&!I&&(U=setTimeout(F,M),M=Math.min(M*1.5,L))},H.onerror=()=>{}}const W=()=>{const te=typeof document<"u"&&document.hidden;if(I=te,te){G(),X();return}M=1e3,H||F()};F(),typeof document<"u"&&document.addEventListener("visibilitychange",W),w.onData(te=>{zft(te,N,Date.now())||T(te)}),w.onResize(({cols:te,rows:ne})=>{H&&H.readyState===WebSocket.OPEN&&H.send(JSON.stringify({type:"terminal.resize",terminalId:r,cols:te,rows:ne})),fetch(`${W_}/api/terminals/${r}/resize`,{method:"POST",headers:{"Content-Type":"application/json",...U_(i)},body:JSON.stringify({cols:te,rows:ne})})});const Q=new ResizeObserver(()=>{requestAnimationFrame(()=>C.fit())});Q.observe(l.current);const V=l.current,ee=()=>{window.setTimeout(B,0)},re=()=>{window.setTimeout(B,0)},ce=te=>{const ne=w.getSelection();te.preventDefault();const me=Dft(te.clientX,te.clientY,window.innerWidth,window.innerHeight);b({left:me.left,top:me.top,hasSelection:!!ne.trim()})},de=te=>{Ift(te,T)&&(A=Date.now())};return V.addEventListener("mouseup",ee),V.addEventListener("keyup",re),V.addEventListener("contextmenu",ce,{capture:!0}),V.addEventListener("paste",de,{capture:!0}),()=>{q=!0,clearTimeout(P),R&&clearTimeout(R),G(),typeof document<"u"&&document.removeEventListener("visibilitychange",W),Q.disconnect(),V.removeEventListener("mouseup",ee),V.removeEventListener("keyup",re),V.removeEventListener("contextmenu",ce,{capture:!0}),V.removeEventListener("paste",de,{capture:!0}),X(),w.dispose(),d.current=null,u.current=null,f.current=null}},[r,i,s,o]),y.useEffect(()=>{const w=d.current;w&&(w.options.theme=xV())},[g]);const _=y.useCallback(()=>{var j;const w=d.current;if(!w)return;const C=w.getSelection().trim();C&&((j=navigator.clipboard)!=null&&j.writeText)&&navigator.clipboard.writeText(C),b(null),w.focus()},[]),S=y.useCallback(()=>{const w=d.current,C=f.current;w&&(bV(navigator.clipboard,j=>{w.focus(),C&&C.readyState===WebSocket.OPEN&&C.send(JSON.stringify({type:"terminal.input",terminalId:r,data:j}))}),b(null),w.focus())},[r]);return c.jsxs("div",{className:`relative w-full overflow-hidden ${n??""}`,tabIndex:-1,onMouseDown:w=>{var C;v&&b(null),(w.target===w.currentTarget||(C=l.current)!=null&&C.contains(w.target))&&requestAnimationFrame(()=>{var j;return(j=d.current)==null?void 0:j.focus()})},children:[c.jsx("div",{ref:l,className:"h-full w-full",style:{minHeight:0}}),v&&c.jsxs("div",{className:"fixed z-50 min-w-[140px] rounded-md border border-border bg-popover py-1 shadow-md",style:{left:v.left,top:v.top},onMouseDown:w=>w.stopPropagation(),children:[c.jsxs("button",{type:"button",className:"flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm text-popover-foreground hover:bg-accent hover:text-accent-foreground disabled:opacity-40 disabled:pointer-events-none",disabled:!v.hasSelection,onClick:_,children:[c.jsx(xc,{className:"h-3.5 w-3.5"}),"Copy"]}),c.jsxs("button",{type:"button",className:"flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm text-popover-foreground hover:bg-accent hover:text-accent-foreground",onClick:S,children:[c.jsx(Zge,{className:"h-3.5 w-3.5"}),"Paste"]})]})]})}),Gk=16;function _V({terminals:e,activeTerminalId:r,onSelect:n,onCreate:i,onKill:s,onDetach:o,availableShells:a}){const[l,d]=y.useState(!1),u=y.useRef(null),f=y.useRef(null),[p,g]=y.useState(null);y.useEffect(()=>{if(!l)return;const b=_=>{u.current&&!u.current.contains(_.target)&&f.current&&!f.current.contains(_.target)&&d(!1)};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[l]);const v=a&&a.length>1;return c.jsxs("div",{className:"flex items-center gap-1 px-2 h-9 border-b bg-background shrink-0 overflow-x-auto",children:[e.map(b=>c.jsxs("div",{role:"tab",tabIndex:0,draggable:!0,onDragStart:_=>{_.dataTransfer.effectAllowed="copy",_.dataTransfer.setData($Q,JSON.stringify(ORe(b.id,b.id.replace(/^term-/,"").slice(0,8),b.workspaceRoot)))},onDragEnd:_=>{if(!o)return;const S=_.clientX<=Gk||_.clientY<=Gk||_.clientX>=window.innerWidth-Gk||_.clientY>=window.innerHeight-Gk,w=_.dataTransfer.dropEffect==="none"&&(_.clientX===0||_.clientY===0);(S||w)&&o(b.id)},onClick:()=>n(b.id),onKeyDown:_=>{(_.key==="Enter"||_.key===" ")&&n(b.id)},className:`group flex items-center gap-1.5 h-6 px-2.5 text-xs rounded-sm border cursor-pointer ${r===b.id?"bg-background text-foreground border-border shadow-sm":"text-muted-foreground border-transparent hover:text-foreground hover:bg-background/50 hover:border-border"}`,children:[c.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${b.state==="running"?"bg-green-500":"bg-zinc-500"}`}),c.jsx("span",{className:"truncate max-w-[100px]",children:b.id.replace(/^term-/,"").slice(0,8)}),c.jsx("button",{onClick:_=>{_.stopPropagation(),s(b.id)},className:"text-muted-foreground hover:text-destructive ml-0.5 text-sm leading-none","aria-label":"Close terminal",children:"×"})]},b.id)),c.jsxs("div",{className:"flex items-center",children:[c.jsx("button",{onClick:()=>i(),className:"px-2 py-1 text-sm text-muted-foreground hover:text-foreground","aria-label":"New terminal",children:"+"}),v&&c.jsx("button",{ref:f,onClick:()=>{var _;if(l){d(!1);return}const b=(_=f.current)==null?void 0:_.getBoundingClientRect();b&&g({top:b.bottom+4,left:b.left}),d(!0)},className:"px-0.5 py-1 text-muted-foreground hover:text-foreground","aria-label":"Select shell type",children:c.jsx(ul,{className:"h-3 w-3"})})]}),l&&v&&p&&c.jsx("div",{ref:u,className:"fixed z-50 min-w-[120px] rounded-md border bg-popover p-1 shadow-md",style:{top:p.top,left:p.left},children:a.map(b=>c.jsx("button",{onClick:()=>{i(b.shell),d(!1)},className:"flex w-full items-center rounded-sm px-2 py-1.5 text-xs hover:bg-accent hover:text-accent-foreground transition-colors",children:b.label},b.shell))})]})}const T4=Ln(),y1={gateway:"#22c55e",device:"#3b82f6",mesh:"#a855f7",host:"#6b7280"},wV={gateway:28,device:20,mesh:20,host:16};function Wft(e){if(e.length===0)return e;const r=[{type:"device",radius:150},{type:"mesh",radius:235},{type:"host",radius:325}],n=e.map(i=>i.data.type==="gateway"?{...i,x:0,y:0,fx:0,fy:0}:{...i});for(const{type:i,radius:s}of r){const o=n.filter(l=>l.data.type===i),a=o.length;a!==0&&o.forEach((l,d)=>{const u=-Math.PI/2+Math.PI*2/a*d;l.x=Math.cos(u)*s,l.y=Math.sin(u)*s})}return n}const Uft="M0 3.449L9.75 2.1V11.551H0zm10.949-1.564L24 0v11.551H10.949zM0 12.449h9.75v9.451L0 20.551zm10.949-.898H24V24l-13.051-1.869z";function zb(e,r,n="0 0 24 24"){const i=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="${n}" fill="${r}"><path d="${e}"/></svg>`;return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(i)}`}function Fb(e){const r=new Image;return r.src=e,r}const Kk={windows:Fb(zb(Uft,"#ffffff")),macos:Fb(zb(SU.path,"#ffffff")),linux:Fb(zb(fut.path,"#ffffff")),android:Fb(zb(hut.path,"#ffffff")),ios:Fb(zb(SU.path,"#ffffff"))};function Vft(e){if(!e)return null;const r=e.toLowerCase();return r.includes("windows")?"windows":r.includes("macos")||r.includes("mac os")||r.includes("darwin")?"macos":r.includes("android")?"android":r.includes("ios")||r.includes("iphone")||r.includes("ipad")?"ios":r.includes("linux")||r.includes("ubuntu")||r.includes("debian")||r.includes("fedora")||r.includes("arch")||r.includes("centos")||r.includes("rhel")||r.includes("mint")||r.includes("manjaro")||r.includes("suse")||r.includes("alpine")?"linux":null}function qft(e){if("platform"in e&&typeof e.platform=="string"&&Kk[e.platform])return Kk[e.platform];if("osVersion"in e){const r=Vft(e.osVersion);if(r&&Kk[r])return Kk[r]}return null}function Gft({node:e,onClose:r,onDeploy:n}){const i=e?e.type==="gateway"?co:e.type==="device"?"platform"in e&&(e.platform==="android"||e.platform==="ios")?X4:Ea:e.type==="mesh"?bi:"isRouter"in e&&e.isRouter?j1:Ea:Ea,s=e?y1[e.type]??"#6b7280":"#6b7280",o=e&&"sshReachable"in e&&e.sshReachable&&"agentStatus"in e&&e.agentStatus!=="running"&&"ip"in e;return c.jsx("div",{className:ze("absolute right-0 top-0 bottom-0 w-72 bg-background border-l z-10 flex flex-col transition-transform duration-200 ease-in-out",e?"translate-x-0":"translate-x-full"),children:e&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b shrink-0",children:[c.jsx("div",{className:"h-8 w-8 rounded-lg flex items-center justify-center shrink-0",style:{backgroundColor:`${s}22`,color:s},children:c.jsx(i,{className:"h-4 w-4"})}),c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsx("div",{className:"truncate text-sm font-medium",children:e.name}),c.jsx("div",{className:"text-xs text-muted-foreground capitalize",children:"isRouter"in e&&e.isRouter?"router":e.type})]}),c.jsx(be,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:r,children:c.jsx(Yn,{className:"h-3.5 w-3.5"})})]}),c.jsxs("div",{className:"flex-1 overflow-y-auto px-4 py-3 space-y-3 text-sm",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:`h-2.5 w-2.5 rounded-full ${e.online?"bg-green-500":"bg-red-500"}`}),c.jsx("span",{children:e.online?"Online":"Offline"})]}),"platform"in e&&e.platform&&c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-muted-foreground",children:"Platform"}),c.jsx("span",{className:"flex items-center gap-1.5 capitalize",children:e.platform})]}),"ip"in e&&e.ip&&c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-muted-foreground",children:"IP Address"}),c.jsx("code",{className:"text-xs bg-muted px-2 py-0.5 rounded",children:e.ip})]}),"isRouter"in e&&e.isRouter&&c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-muted-foreground",children:"Role"}),c.jsx(on,{variant:"secondary",className:"text-2xs",children:"Router"})]}),"version"in e&&e.version&&c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-muted-foreground",children:"Version"}),c.jsxs(on,{variant:"secondary",className:"font-mono text-2xs",children:["v",e.version]})]}),"osVersion"in e&&e.osVersion&&c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-muted-foreground",children:"OS"}),c.jsx("span",{className:"text-xs",children:e.osVersion})]}),"mac"in e&&e.mac&&c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-muted-foreground",children:"MAC Address"}),c.jsx("code",{className:"text-xs bg-muted px-2 py-0.5 rounded",children:e.mac})]}),"providers"in e&&e.providers.length>0&&c.jsxs("div",{children:[c.jsx("span",{className:"text-muted-foreground block mb-1.5",children:"Providers"}),c.jsx("div",{className:"flex flex-wrap gap-1",children:e.providers.map(a=>c.jsxs(on,{variant:"outline",className:"text-2xs",children:[c.jsx(Io,{className:"h-2.5 w-2.5 mr-1"}),a]},a))})]}),"openPorts"in e&&e.openPorts.length>0&&c.jsxs("div",{children:[c.jsx("span",{className:"text-muted-foreground block mb-1.5",children:"Open Ports"}),c.jsx("div",{className:"flex flex-wrap gap-1",children:e.openPorts.map(a=>c.jsx(on,{variant:"outline",className:"text-2xs font-mono",children:a},a))})]}),"sshReachable"in e&&c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-muted-foreground",children:"SSH"}),c.jsxs("span",{className:"flex items-center gap-1.5",children:[c.jsx(Y4,{className:"h-3 w-3"}),e.sshReachable?"Reachable":"Not reachable"]})]}),"agentStatus"in e&&c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-muted-foreground",children:"Agent"}),c.jsx(on,{variant:e.agentStatus==="running"?"default":"secondary",className:"text-2xs",children:e.agentStatus})]}),"registeredAt"in e&&e.registeredAt&&c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("span",{className:"text-muted-foreground",children:"Connected"}),c.jsx("span",{className:"text-xs",children:new Date(e.registeredAt).toLocaleString()})]}),"agentStatus"in e&&e.agentStatus==="running"&&"ip"in e&&c.jsx(be,{size:"sm",variant:"outline",className:"w-full mt-2",asChild:!0,children:c.jsxs("a",{href:`http://${e.ip}:8000`,target:"_blank",rel:"noopener noreferrer",children:[c.jsx(bi,{className:"h-3.5 w-3.5 mr-1.5"}),"Open Dashboard"]})}),o&&n&&c.jsxs(be,{size:"sm",variant:"default",className:"w-full mt-2",onClick:()=>{n(e.ip),r()},children:[c.jsx(L8,{className:"h-3.5 w-3.5 mr-1.5"}),"Deploy Node"]})]})]})})}function Kft({ip:e,token:r,sessionId:n,onClose:i}){const[s,o]=y.useState([]),[a,l]=y.useState("ready"),[d,u]=y.useState(""),[f,p]=y.useState(null),[g,v]=y.useState(!1),b=y.useRef(null);return y.useEffect(()=>{b.current&&(b.current.scrollTop=b.current.scrollHeight)},[s]),y.useEffect(()=>{if(!e||!g)return;o([]),l("starting");const _=new AbortController;return(async()=>{try{const w={"Content-Type":"application/json"};r&&(w.Authorization=`Bearer ${r}`);const C=await fetch(`${T4}/api/terminals`,{method:"POST",headers:w,body:JSON.stringify({sessionId:n}),signal:_.signal});if(!C.ok){o(N=>[...N,`Error: ${C.statusText}`]),l("error");return}const j=await C.json();p(j.id);const T=await fetch(`${T4}/api/network/deploy`,{method:"POST",headers:w,body:JSON.stringify({ip:e,username:d||"root",terminalId:j.id,sessionId:n}),signal:_.signal});if(!T.ok){const N=await T.json().catch(()=>null);o(A=>[...A,`Error: ${(N==null?void 0:N.error)??T.statusText}`]),l("error");return}await T.json().catch(()=>null),o([`Deploy started for ${d||"root"}@${e}.`,"Continue here in the embedded terminal below.","SSH and sudo prompts will appear in this side panel."]),l("running")}catch(w){_.signal.aborted||(o(C=>[...C,`Error: ${w instanceof Error?w.message:"Connection failed"}`]),l("error"))}})(),()=>_.abort()},[e,n,g,r,d]),e?c.jsxs("div",{className:"absolute inset-0 z-20 bg-background flex flex-col",children:[c.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b shrink-0",children:[c.jsx(L8,{className:"h-4 w-4 text-primary"}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"text-sm font-medium truncate",children:["Deploy to ",e]}),c.jsxs("div",{className:"text-2xs text-muted-foreground",children:[a==="ready"&&"Ready",a==="starting"&&"Preparing terminal...",a==="running"&&"Interactive session ready",a==="error"&&"Failed"]})]}),c.jsx(be,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0",onClick:i,children:c.jsx(Yn,{className:"h-3.5 w-3.5"})})]}),g?c.jsxs(c.Fragment,{children:[c.jsxs("div",{ref:b,className:"shrink-0 overflow-y-auto border-b p-3 font-mono text-xs leading-5 space-y-0.5 max-h-32",children:[s.map((_,S)=>c.jsx("div",{className:ze(_.startsWith("✓")?"text-green-500":_.startsWith("✗")?"text-red-500":_.startsWith("[")?"text-blue-400":"text-muted-foreground"),children:_},S)),a==="starting"&&c.jsx("div",{className:"text-muted-foreground animate-pulse",children:"Preparing terminal..."})]}),f&&a==="running"&&c.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[c.jsxs("div",{className:"flex items-center justify-between border-b px-3 py-2 text-2xs text-muted-foreground",children:[c.jsx("span",{children:"Interactive deploy session"}),c.jsxs("span",{className:"truncate",children:["Terminal: ",f]})]}),c.jsx(N4,{terminalId:f,className:"flex-1 min-h-0",token:r})]}),a==="error"&&c.jsx("div",{className:"p-3 border-t shrink-0",children:c.jsx(be,{size:"sm",variant:"outline",className:"w-full",onClick:()=>{v(!1),o([]),l("ready"),p(null)},children:"Try Again"})})]}):c.jsxs("div",{className:"flex-1 flex flex-col gap-3 p-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"text-xs text-muted-foreground",children:"SSH Username"}),c.jsx("input",{type:"text",value:d,onChange:_=>u(_.target.value),placeholder:"root",className:"w-full px-3 py-2 text-sm rounded-md border bg-background",onKeyDown:_=>_.key==="Enter"&&v(!0)})]}),c.jsx("div",{className:"text-2xs text-muted-foreground",children:"Starts a real terminal inside this side panel. If SSH or sudo needs a password, it will prompt here directly."}),c.jsxs(be,{className:"w-full",onClick:()=>v(!0),children:[c.jsx(L8,{className:"h-3.5 w-3.5 mr-1.5"}),"Deploy"]})]})]}):null}function Yft({token:e,sessionId:r}){const n=y.useRef(null),i=y.useRef(void 0),[s,o]=y.useState({width:0,height:0}),[a,l]=y.useState(null),[d,u]=y.useState(!1),[f,p]=y.useState(null),[g,v]=y.useState(null),[b,_]=y.useState(null),[S,w]=y.useState(null),C=y.useCallback(()=>{const H={};return e&&(H.Authorization=`Bearer ${e}`),H},[e]),j=y.useRef(""),T=y.useCallback(async()=>{try{const H=await fetch(`${T4}/api/network/topology`,{headers:C()});if(H.ok){const U=await H.text();U!==j.current&&(j.current=U,l(JSON.parse(U))),v(null)}}catch(H){v(H instanceof Error?H.message:"Failed to fetch topology")}},[C]),N=y.useCallback(async()=>{u(!0),v(null);try{const H=await fetch(`${T4}/api/network/scan`,{method:"POST",headers:{...C(),"Content-Type":"application/json"},body:JSON.stringify({deep:!0})});if(!H.ok)throw new Error(`Scan failed: ${H.status}`);await T()}catch(H){v(H instanceof Error?H.message:"Scan failed")}finally{u(!1)}},[C,T]);y.useEffect(()=>{T();let H=null;const U=()=>{H||(H=setInterval(()=>void T(),6e4))},q=()=>{H&&(clearInterval(H),H=null)},M=()=>{document.hidden?q():U()};return document.addEventListener("visibilitychange",M),document.hidden||U(),()=>{q(),document.removeEventListener("visibilitychange",M)}},[T]),y.useEffect(()=>{const H=n.current;if(!H)return;const U=new ResizeObserver(([q])=>{q&&o({width:q.contentRect.width,height:q.contentRect.height})});return U.observe(H),()=>U.disconnect()},[]);const A=y.useMemo(()=>{if(!a)return{nodes:[],links:[]};const H=[],U=[];H.push({id:a.gateway.id,data:a.gateway});for(const q of a.devices)H.push({id:q.id,data:q}),U.push({source:q.id,target:"gateway",type:"connected"});for(const q of a.meshNodes)H.push({id:q.id,data:q}),U.push({source:q.id,target:"gateway",type:"connected"});for(const q of a.hosts)q.ip!==a.gateway.ip&&(H.push({id:q.id,data:q}),U.push({source:q.id,target:"gateway",type:"scanned"}));return{nodes:Wft(H),links:U}},[a]),R=y.useRef(!1);y.useEffect(()=>{R.current||A.nodes.length===0||(R.current=!0,requestAnimationFrame(()=>{const H=i.current;if(!H)return;const U=H.d3Force("charge");U&&typeof U.strength=="function"&&U.strength(-200);const q=H.d3Force("link");q&&typeof q.distance=="function"&&q.distance(80),H.zoom(3.5,0)}))},[A]);const $=y.useCallback((H,U,q)=>{const{data:M}=H,I=H.x??0,L=H.y??0,z=wV[M.type]??8,G=y1[M.type]??"#6b7280",X=b===H.id,F=(f==null?void 0:f.id)===M.id;M.type==="gateway"&&(U.beginPath(),U.arc(I,L,z+4,0,2*Math.PI),U.fillStyle=`${G}33`,U.fill()),M.type==="host"&&"sshReachable"in M&&M.sshReachable&&(U.beginPath(),U.arc(I,L,z+3,0,2*Math.PI),U.strokeStyle="#f59e0b55",U.lineWidth=1.5/q,U.stroke()),(X||F)&&(U.beginPath(),U.arc(I,L,z+2.5,0,2*Math.PI),U.strokeStyle=G,U.lineWidth=1.5/q,U.stroke()),U.beginPath(),U.arc(I,L,z,0,2*Math.PI),U.fillStyle=G,U.fill(),M.online&&(U.beginPath(),U.arc(I+z*.65,L-z*.65,2.5,0,2*Math.PI),U.fillStyle="#22c55e",U.fill(),U.strokeStyle="#0a0a0a",U.lineWidth=.5,U.stroke());const W=qft(M);if(W!=null&&W.complete&&W.naturalWidth>0){const re=z*1.1;U.drawImage(W,I-re/2,L-re/2,re,re)}const Q=Math.max(3.5,10/q);U.font=`${Q}px -apple-system, BlinkMacSystemFont, sans-serif`,U.textAlign="center",U.textBaseline="top",U.fillStyle=X?"#ffffff":"#a1a1aa";const V=M.name.length>20?M.name.slice(0,18)+"…":M.name;U.fillText(V,I,L+z+3),M.type==="gateway"?(U.font=`bold ${Math.max(3,8/q)}px -apple-system, BlinkMacSystemFont, sans-serif`,U.fillStyle="#22c55e",U.fillText("GATEWAY",I,L+z+3+Q+2)):M.type==="host"&&"isRouter"in M&&M.isRouter&&(U.font=`bold ${Math.max(3,8/q)}px -apple-system, BlinkMacSystemFont, sans-serif`,U.fillStyle="#f59e0b",U.fillText("ROUTER",I,L+z+3+Q+2));const ee="providers"in M&&Array.isArray(M.providers)?M.providers:[];if(ee.length>0){const re=Math.max(2.5,7/q);U.font=`${re}px -apple-system, BlinkMacSystemFont, sans-serif`,U.fillStyle="#a855f7";const ce=M.type==="gateway"?Q*2+6:Q+5;U.fillText(ee.join(" · "),I,L+z+3+ce)}if(M.type==="host"&&"openPorts"in M&&M.openPorts.length>0){const re=M.openPorts.length,ce=Math.max(2.5,7/q);U.font=`bold ${ce}px -apple-system, BlinkMacSystemFont, sans-serif`,U.fillStyle="#3b82f6",U.textAlign="center",U.textBaseline="middle";const de=I-z*.65,te=L-z*.65;U.beginPath(),U.arc(de,te,3.5,0,2*Math.PI),U.fillStyle="#3b82f6",U.fill(),U.fillStyle="#ffffff",U.fillText(String(re),de,te)}},[b,f]),B=y.useCallback((H,U)=>{const q=H.source,M=H.target;(q==null?void 0:q.x)==null||(M==null?void 0:M.x)==null||(U.beginPath(),U.moveTo(q.x,q.y),U.lineTo(M.x,M.y),H.type==="connected"?(U.strokeStyle="#3b82f644",U.lineWidth=1.5,U.setLineDash([])):(U.strokeStyle="#6b728033",U.lineWidth=.5,U.setLineDash([4,4])),U.stroke(),U.setLineDash([]))},[]),P=a?1+a.devices.length+a.meshNodes.length+a.hosts.length:0;return c.jsxs("div",{className:"h-full flex flex-col",children:[c.jsxs("div",{className:"flex items-center justify-between gap-2 border-b px-4 py-3 shrink-0",children:[c.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[c.jsx(j1,{className:"h-4 w-4 text-primary"}),c.jsx("h2",{className:"text-sm font-semibold",children:"Network"}),P>0&&c.jsxs(on,{variant:"secondary",className:"w-[4.75rem] justify-center px-1 text-2xs tabular-nums",children:[P," ",P===1?"node":"nodes"]}),(a==null?void 0:a.scannedAt)&&c.jsxs("span",{className:"text-2xs text-muted-foreground hidden sm:inline",children:["Last scan: ",new Date(a.scannedAt).toLocaleTimeString()]})]}),c.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[c.jsxs(be,{size:"sm",variant:"outline",className:"h-7 px-2 text-xs sm:px-2.5",onClick:()=>void T(),children:[c.jsx(ea,{className:"h-3 w-3 sm:mr-1"}),c.jsx("span",{className:"hidden sm:inline",children:"Refresh"})]}),c.jsx(be,{size:"sm",variant:"default",className:"h-7 px-2 text-xs sm:px-2.5",onClick:()=>void N(),disabled:d,children:d?c.jsxs(c.Fragment,{children:[c.jsx(ir,{className:"h-3 w-3 animate-spin sm:mr-1"}),c.jsx("span",{className:"hidden sm:inline",children:"Scanning..."})]}):c.jsxs(c.Fragment,{children:[c.jsx(Il,{className:"h-3 w-3 sm:mr-1"}),c.jsx("span",{className:"hidden sm:inline",children:a!=null&&a.scannedAt?"Rescan Network":"Discover Devices"})]})})]})]}),g&&c.jsxs("div",{className:"flex items-center gap-2 text-sm text-red-500 bg-red-500/10 px-4 py-2",children:[c.jsx(Yn,{className:"h-3.5 w-3.5 shrink-0"}),g]}),c.jsxs("div",{className:"flex items-center gap-4 px-4 py-2 border-b text-2xs text-muted-foreground shrink-0 flex-wrap",children:[c.jsxs("span",{className:"flex items-center gap-1.5",children:[c.jsx("span",{className:"h-2.5 w-2.5 rounded-full",style:{backgroundColor:y1.gateway}}),"Gateway"]}),c.jsxs("span",{className:"flex items-center gap-1.5",children:[c.jsx("span",{className:"h-2.5 w-2.5 rounded-full",style:{backgroundColor:y1.device}}),"Connected Device"]}),c.jsxs("span",{className:"flex items-center gap-1.5",children:[c.jsx("span",{className:"h-2.5 w-2.5 rounded-full",style:{backgroundColor:y1.mesh}}),"Mesh Node"]}),c.jsxs("span",{className:"flex items-center gap-1.5",children:[c.jsx("span",{className:"h-2.5 w-2.5 rounded-full",style:{backgroundColor:y1.host}}),"Network Host"]}),c.jsxs("span",{className:"flex items-center gap-1.5",children:[c.jsx("span",{className:"h-2.5 w-2.5 rounded-full border border-amber-500/50",style:{backgroundColor:"transparent"}}),"SSH Available"]})]}),c.jsxs("div",{ref:n,className:"flex-1 min-h-0 relative bg-background overflow-hidden",children:[A.nodes.length>0&&s.width>0&&s.height>0?c.jsx(NP,{ref:i,width:s.width,height:s.height,graphData:A,nodeId:"id",nodeCanvasObject:$,nodePointerAreaPaint:(H,U,q)=>{const M=wV[H.data.type]??6;q.beginPath(),q.arc(H.x??0,H.y??0,M+4,0,2*Math.PI),q.fillStyle=U,q.fill()},linkCanvasObject:B,onNodeClick:H=>p(H.data),onNodeHover:H=>_((H==null?void 0:H.id)??null),cooldownTicks:80,d3VelocityDecay:.3,d3AlphaDecay:.02,minZoom:.65,maxZoom:8,enableNodeDrag:!0,enableZoomInteraction:!0,enablePanInteraction:!0,backgroundColor:"transparent"}):a?c.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-3",children:[c.jsx("div",{className:"h-12 w-12 rounded-full bg-muted flex items-center justify-center",children:c.jsx(Ea,{className:"h-6 w-6 text-muted-foreground"})}),c.jsx("div",{className:"text-sm font-medium",children:"No devices found"}),c.jsx("div",{className:"text-xs text-muted-foreground max-w-xs text-center",children:"Run a network scan to discover devices on your local network."}),c.jsxs(be,{size:"sm",onClick:()=>void N(),className:"mt-2",children:[c.jsx(Il,{className:"h-3.5 w-3.5 mr-1.5"}),"Discover Devices"]})]}):c.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-3",children:[c.jsx(ir,{className:"h-8 w-8 animate-spin text-muted-foreground"}),c.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading network topology..."})]}),c.jsx(Gft,{node:f,onClose:()=>p(null),onDeploy:H=>w(H)}),c.jsx("div",{className:ze("absolute top-0 right-0 h-full w-80 border-l bg-background transition-transform duration-200 ease-in-out z-30",S?"translate-x-0":"translate-x-full"),children:c.jsx(Kft,{ip:S,token:e,sessionId:r,onClose:()=>w(null)})})]})]})}function Xft({platform:e,className:r}){switch(e){case"electron":return c.jsx(Ea,{className:r??"h-4 w-4"});case"react-native":return c.jsx(X4,{className:r??"h-4 w-4"});default:return c.jsx(bi,{className:r??"h-4 w-4"})}}function SV({device:e,isLocal:r,isConnected:n,isLoading:i,onConnect:s}){const o=!r&&e.capabilities.includes("screen-share");return c.jsxs("div",{className:`flex items-center gap-3 px-3 py-2.5 rounded-lg text-sm transition-colors
1262
1262
  ${n?"bg-green-500/10 border border-green-500/30":"bg-muted/50 hover:bg-muted/80"}`,children:[c.jsx("div",{className:`h-9 w-9 rounded-lg flex items-center justify-center shrink-0
1263
1263
  ${n?"bg-green-500/15 text-green-500":r?"bg-primary/10 text-primary":"bg-muted text-muted-foreground"}`,children:c.jsx(Xft,{platform:e.platform,className:"h-4.5 w-4.5"})}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsxs("div",{className:"font-medium truncate text-sm",children:[e.name,r&&c.jsx("span",{className:"text-xs text-muted-foreground ml-1",children:"(you)"})]}),c.jsxs("div",{className:"text-xs text-muted-foreground mt-0.5",children:[e.platform,n&&c.jsx("span",{className:"text-green-500 ml-1",children:"· connected"})]})]}),o&&!n&&c.jsx(be,{size:"sm",variant:"outline",className:"h-7 text-xs px-2.5 shrink-0",onClick:s,disabled:i,children:i?c.jsx(ir,{className:"h-3 w-3 animate-spin"}):c.jsxs(c.Fragment,{children:[c.jsx(Aye,{className:"h-3 w-3 mr-1"}),"Connect"]})}),n&&c.jsxs(on,{className:"bg-green-500/15 text-green-500 border-green-500/30 shrink-0 text-2xs",children:[c.jsx(Tye,{className:"h-2.5 w-2.5 mr-0.5"})," live"]})]})}function Zft({stream:e}){const r=y.useRef(null),n=y.useRef(null),[i,s]=y.useState(!1);y.useEffect(()=>{console.log(`[screen-share] RemoteScreen: stream=${!!e} tracks=${e==null?void 0:e.getTracks().map(a=>`${a.kind}:${a.readyState}`).join(",")} videoRef=${!!r.current}`),r.current&&e&&(r.current.srcObject=e)},[e]);const o=y.useCallback(()=>{const a=n.current;a&&(document.fullscreenElement?(document.exitFullscreen(),s(!1)):(a.requestFullscreen(),s(!0)))},[]);return y.useEffect(()=>{const a=()=>s(!!document.fullscreenElement);return document.addEventListener("fullscreenchange",a),()=>document.removeEventListener("fullscreenchange",a)},[]),e?c.jsxs("div",{ref:n,className:"relative flex-1 group bg-black rounded-lg overflow-hidden",children:[c.jsx("video",{ref:r,autoPlay:!0,playsInline:!0,muted:!0,className:"w-full h-full object-contain bg-black"}),c.jsx("button",{onClick:o,className:"absolute top-2 right-2 p-1.5 rounded bg-black/60 text-white opacity-0 group-hover:opacity-100 transition-opacity",children:i?c.jsx(OR,{className:"h-3.5 w-3.5"}):c.jsx(AR,{className:"h-3.5 w-3.5"})})]}):c.jsx("div",{className:"flex-1 bg-black/20 rounded-lg flex items-center justify-center text-muted-foreground",children:c.jsxs("div",{className:"text-center",children:[c.jsx(hye,{className:"h-10 w-10 mx-auto mb-3 opacity-40"}),c.jsx("p",{className:"text-sm font-medium",children:"Waiting for remote screen…"}),c.jsx("p",{className:"text-xs mt-1 opacity-60",children:"The remote device is preparing to share"})]})})}function Jft({screenShare:e}){var o;const r=e.session,n=e.isViewer||e.isHost;console.log(`[screen-share] Panel render: isHost=${e.isHost} isViewer=${e.isViewer} isConnected=${n} remoteStream=${!!e.remoteStream} localStream=${!!e.localStream}`);const i=e.devices.filter(a=>a.id!==e.localDeviceId),s=e.devices.find(a=>a.id===e.localDeviceId);return c.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[e.pendingShareRequest&&!n&&c.jsx("div",{className:"p-3 border-b bg-amber-500/5",children:c.jsxs("div",{className:"flex items-start gap-3",children:[c.jsx("div",{className:"h-9 w-9 rounded-lg bg-amber-500/15 text-amber-500 flex items-center justify-center shrink-0 mt-0.5",children:c.jsx(cD,{className:"h-4.5 w-4.5"})}),c.jsxs("div",{className:"flex-1 min-w-0",children:[c.jsx("p",{className:"text-sm font-medium",children:"Screen share requested"}),c.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:"A remote device wants to view your screen."}),c.jsxs("div",{className:"flex gap-2 mt-2",children:[c.jsxs(be,{size:"sm",className:"h-7 text-xs px-3",onClick:()=>e.acceptPendingShare(),children:[c.jsx(cD,{className:"h-3 w-3 mr-1"}),"Share Screen"]}),c.jsx(be,{size:"sm",variant:"ghost",className:"h-7 text-xs px-2 text-muted-foreground",onClick:()=>e.rejectPendingShare(),children:"Decline"})]})]})]})}),n?c.jsxs("div",{className:"flex flex-col flex-1 min-h-0",children:[c.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b bg-muted/20 shrink-0",children:[c.jsxs(on,{className:"bg-green-500/15 text-green-500 border-green-500/30 text-2xs",children:[c.jsx(j1,{className:"h-2.5 w-2.5 mr-1"})," Live"]}),c.jsx("span",{className:"text-xs text-muted-foreground truncate flex-1",children:e.connectedDeviceId?((o=e.devices.find(a=>a.id===e.connectedDeviceId))==null?void 0:o.name)??e.connectedDeviceId:"Connected"}),r&&c.jsxs("span",{className:"text-2xs text-muted-foreground",children:[r.transport.routeMode.toUpperCase()," · ",r.transport.avgLatencyMs,"ms"]}),c.jsxs(be,{variant:"ghost",size:"sm",className:"h-6 text-xs px-2 text-destructive hover:text-destructive",onClick:()=>e.disconnect(),children:[c.jsx(Yn,{className:"h-3 w-3 mr-1"}),"Disconnect"]})]}),e.error&&c.jsx("div",{className:"mx-2 p-2 rounded-md bg-red-500/10 text-red-500 text-xs border border-red-500/20",children:e.error}),e.isHost?c.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:c.jsxs("div",{className:"text-center",children:[c.jsx(Qg,{className:"h-10 w-10 mx-auto mb-3 opacity-40"}),c.jsx("p",{className:"text-sm font-medium",children:"Sharing your screen"}),c.jsx("p",{className:"text-xs mt-1 opacity-60",children:"A remote device is viewing this screen"}),r&&c.jsxs("p",{className:"text-xs mt-2 opacity-50",children:[c.jsx(D8,{className:"h-3 w-3 inline mr-0.5"}),r.viewers.length," viewer",r.viewers.length!==1?"s":""]})]})}):c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"flex-1 min-h-0 p-2",children:c.jsx(Zft,{stream:e.remoteStream})}),r&&c.jsxs("div",{className:"flex items-center gap-3 px-3 py-1.5 border-t text-2xs text-muted-foreground shrink-0",children:[c.jsxs("span",{children:["Session ",r.id.slice(0,8)]}),c.jsx("span",{children:"·"}),c.jsxs("span",{children:["ICE: ",r.transport.iceConnectionState]}),c.jsx("span",{children:"·"}),c.jsxs("span",{children:[c.jsx(D8,{className:"h-2.5 w-2.5 inline mr-0.5"}),r.viewers.length," viewer",r.viewers.length!==1?"s":""]})]})]})]}):c.jsxs("div",{className:"flex flex-col gap-3 p-3 overflow-y-auto",children:[e.error&&c.jsx("div",{className:"p-2.5 rounded-md bg-red-500/10 text-red-500 text-xs border border-red-500/20",children:e.error}),c.jsxs("div",{className:"space-y-1.5",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("h3",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Remote Devices"}),c.jsx(be,{variant:"ghost",size:"sm",className:"h-5 w-5 p-0",onClick:()=>e.refreshState(),children:c.jsx(ea,{className:"h-3 w-3"})})]}),i.length===0?c.jsxs("div",{className:"py-6 text-center",children:[c.jsx(Qg,{className:"h-8 w-8 mx-auto mb-2 text-muted-foreground/40"}),c.jsx("p",{className:"text-xs text-muted-foreground font-medium",children:"No remote devices found"}),c.jsx("p",{className:"text-xs text-muted-foreground/60 mt-1 max-w-[200px] mx-auto",children:"Open Jait on another device (desktop app or mobile) to connect to it"})]}):c.jsx("div",{className:"space-y-1.5",children:i.map(a=>c.jsx(SV,{device:a,isLocal:!1,isConnected:!1,isLoading:e.loading&&e.connectedDeviceId===a.id,onConnect:()=>e.requestRemoteShare(a.id)},a.id))})]}),s&&c.jsxs("div",{className:"space-y-1.5",children:[c.jsx("h3",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"This Device"}),c.jsx(SV,{device:s,isLocal:!0,isConnected:!1,isLoading:!1,onConnect:()=>{}})]}),c.jsxs("div",{className:"px-2 py-2 rounded-md bg-muted/30 text-xs text-muted-foreground",children:[c.jsx("strong",{children:"Tip:"})," Ask your agent to connect to a device — e.g. “Show me my desktop screen”"]})]})]})}function Mo(){return typeof window<"u"&&window.jaitDesktop?"electron":typeof window<"u"&&"Capacitor"in window?"capacitor":"web"}let td=null;function H7(e){return`${e}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}async function Qft(){var o;if(td)return td;const e=Mo(),r=`jait-device-id-${e}`,n="deviceId";if(e==="electron"&&((o=window.jaitDesktop)!=null&&o.getSetting)){const a=window.jaitDesktop,l=await a.getSetting(n,null);if(l)return td=l,localStorage.setItem(r,l),l;const d=localStorage.getItem(r);if(d)return td=d,await a.setSetting(n,d),d;const u=H7(e);return td=u,localStorage.setItem(r,u),await a.setSetting(n,u),u}const i=localStorage.getItem(r);if(i)return td=i,i;const s=H7(e);return td=s,localStorage.setItem(r,s),s}function IP(){if(td)return td;const e=Mo(),r=`jait-device-id-${e}`,n=localStorage.getItem(r);if(n)return td=n,n;const i=H7(e);return td=i,localStorage.setItem(r,i),i}const Hb=Ln(),ept=Y0(),sue="jait-screen-share-auto-approve";function oue(){try{const e=localStorage.getItem(sue);return e?new Set(JSON.parse(e)):new Set}catch{return new Set}}function tpt(e){const r=oue();r.add(e),localStorage.setItem(sue,JSON.stringify([...r]))}function rpt(){const e=Mo(),r=navigator.userAgent;return e==="electron"?`Jait Desktop (${navigator.platform})`:e==="capacitor"?"Jait Mobile":r.includes("Chrome")?`Chrome (${navigator.platform})`:r.includes("Firefox")?`Firefox (${navigator.platform})`:r.includes("Safari")?`Safari (${navigator.platform})`:`Browser (${navigator.platform})`}const npt=[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:stun1.l.google.com:19302"}];function ipt(e={}){const{token:r}=e,[n,i]=y.useState({session:null,devices:[],localDeviceId:null,isHost:!1,isViewer:!1,isActive:!1,loading:!1,error:null,connectedDeviceId:null,pendingShareRequest:null}),s=y.useRef(null),o=y.useRef(null),a=y.useRef(null),l=y.useRef(null),d=y.useRef(IP()),u=y.useRef(null),f=y.useCallback(()=>{const T={"Content-Type":"application/json"};return r&&(T.Authorization=`Bearer ${r}`),T},[r]),p=y.useCallback(async()=>{const T=d.current,N=Mo(),A=rpt(),R=["screen-view"];N==="electron"&&R.push("screen-share","remote-input"),N==="web"&&R.push("screen-share");try{(await fetch(`${Hb}/api/screen-share/devices/register`,{method:"POST",headers:f(),body:JSON.stringify({id:T,name:A,platform:N,capabilities:R})})).ok&&i(B=>({...B,localDeviceId:T}))}catch($){console.error("Failed to register screen-share device:",$)}},[f]),g=y.useCallback(async()=>{try{const T=await fetch(`${Hb}/api/screen-share/state`,{headers:f()});if(!T.ok)return;const N=await T.json();i(A=>{var R;return{...A,session:N.activeSession??A.session,devices:N.devices,isActive:((R=N.activeSession)==null?void 0:R.status)==="sharing"}})}catch(T){console.error("Failed to refresh screen-share state:",T)}},[f]),v=y.useCallback((T,N,A)=>{var $;console.log(`[screen-share] setupPeerConnection: isHost=${N} session=${A.slice(0,8)} prevPC=${!!s.current} stream=${!!T} device=${d.current}`),($=s.current)==null||$.close();const R=new RTCPeerConnection({iceServers:npt});if(s.current=R,N&&T){const B=T.getTracks();console.log(`[screen-share] Adding ${B.length} track(s):`,B.map(P=>`${P.kind}:${P.label}:${P.readyState}`)),B.forEach(P=>R.addTrack(P,T))}if(R.ontrack=B=>{const[P]=B.streams;console.log(`[screen-share] ontrack: streams=${B.streams.length} tracks=${P==null?void 0:P.getTracks().map(H=>`${H.kind}:${H.readyState}`).join(",")}`),P&&(a.current=P,console.log("[screen-share] remoteStreamRef set, triggering re-render"),i(H=>({...H})))},R.onicecandidate=B=>{var P;B.candidate&&((P=l.current)==null?void 0:P.readyState)===WebSocket.OPEN&&l.current.send(JSON.stringify({type:"screen-share:ice-candidate",payload:{sessionId:A,fromDeviceId:d.current,candidate:B.candidate.candidate,sdpMid:B.candidate.sdpMid,sdpMLineIndex:B.candidate.sdpMLineIndex}}))},R.oniceconnectionstatechange=()=>{console.log("[screen-share] ICE state:",R.iceConnectionState),(R.iceConnectionState==="disconnected"||R.iceConnectionState==="failed")&&i(B=>({...B,error:`Connection ${R.iceConnectionState}`}))},N&&R.createOffer().then(B=>{var P;R.setLocalDescription(B),console.log("[screen-share] Sending offer via WS"),(P=l.current)==null||P.send(JSON.stringify({type:"screen-share:offer",payload:{sessionId:A,hostDeviceId:d.current,sdp:B.sdp}}))}),!N&&u.current){const B=u.current;u.current=null,console.log("[screen-share] Processing queued offer"),R.setRemoteDescription(new RTCSessionDescription({type:"offer",sdp:B.sdp})).then(()=>R.createAnswer()).then(P=>{var H;R.setLocalDescription(P),(H=l.current)==null||H.send(JSON.stringify({type:"screen-share:answer",payload:{sessionId:B.sessionId,viewerDeviceId:d.current,sdp:P.sdp}}))}).catch(P=>console.error("[screen-share] Failed to process queued offer:",P))}},[]),b=y.useCallback(async T=>{var N,A;i(R=>({...R,loading:!0,error:null}));try{let R;if(!((N=navigator.mediaDevices)!=null&&N.getDisplayMedia))throw new Error("Screen sharing is not supported on this device. Use a desktop browser or the Electron app.");if(console.log("[screen-share] Requesting screen capture via getDisplayMedia..."),R=await navigator.mediaDevices.getDisplayMedia({video:{width:{ideal:1920},height:{ideal:1080},frameRate:{ideal:15,max:30}},audio:!1}),console.log("[screen-share] Screen capture obtained:",(A=R.getVideoTracks()[0])==null?void 0:A.label),o.current=R,!T){await p();const $=await fetch(`${Hb}/api/screen-share/start`,{method:"POST",headers:f(),body:JSON.stringify({hostDeviceId:d.current})});if(!$.ok){const P=await $.json();throw new Error(P.error)}const B=await $.json();T=B.session.id,i(P=>({...P,session:B.session}))}i($=>({...$,isHost:!0,isViewer:!1,isActive:!0,loading:!1})),console.log("[screen-share] Host capturing — setting up peer connection for session:",T),v(R,!0,T??"")}catch(R){console.error("[screen-share] Capture failed:",R),i($=>({...$,loading:!1,isHost:!1,error:R instanceof Error?R.message:"Failed to start screen capture"}))}},[p,f,v]),_=y.useCallback(async T=>{i(N=>({...N,loading:!0,error:null,connectedDeviceId:T}));try{await p();const N=await fetch(`${Hb}/api/screen-share/start`,{method:"POST",headers:f(),body:JSON.stringify({hostDeviceId:T,viewerDeviceIds:[d.current]})});if(!N.ok){const R=await N.json();throw new Error(R.error)}const{session:A}=await N.json();i(R=>({...R,session:A,isViewer:!0,isActive:!0,loading:!1})),console.log(`[screen-share] requestRemoteShare: HTTP done, session=${A.id.slice(0,8)} pcRef=${!!s.current}`),s.current?console.log("[screen-share] requestRemoteShare: PC already exists, skipping creation"):(console.log("[screen-share] requestRemoteShare: creating viewer PC (no WS-created PC yet)"),v(null,!1,A.id))}catch(N){i(A=>({...A,loading:!1,connectedDeviceId:null,error:N instanceof Error?N.message:"Failed to connect to remote device"}))}},[p,f,v]),S=y.useCallback(async()=>{var T,N;(T=o.current)==null||T.getTracks().forEach(A=>A.stop()),o.current=null,a.current=null,(N=s.current)==null||N.close(),s.current=null;try{await fetch(`${Hb}/api/screen-share/stop`,{method:"POST",headers:f(),body:JSON.stringify({})})}catch{}i(A=>({...A,session:null,isHost:!1,isViewer:!1,isActive:!1,connectedDeviceId:null,pendingShareRequest:null}))},[f]),w=y.useCallback(()=>{const T=n.pendingShareRequest;T&&(i(N=>({...N,pendingShareRequest:null})),b(T.sessionId))},[n.pendingShareRequest,b]),C=y.useCallback(()=>{i(T=>({...T,pendingShareRequest:null}))},[]),j=y.useCallback(async()=>{if(!window.jaitDesktop)return[];try{return await window.jaitDesktop.getDesktopSources()}catch{return[]}},[]);return y.useEffect(()=>{if(!r||!window.jaitDesktop)return;let T=!0,N=null;const A=()=>{if(!T)return;const R=`${ept}${r?`?token=${r}`:""}`,$=new WebSocket(R);l.current=$,$.onopen=()=>{console.log("[screen-share] WS connected"),$.send(JSON.stringify({type:"subscribe",deviceId:d.current}))},$.onmessage=B=>{var P,H,U,q,M,I,L;try{const z=JSON.parse(B.data);switch(z.type.startsWith("screen-share:")&&console.log(`[screen-share] WS recv: ${z.type}`,JSON.stringify(z.payload).slice(0,300)),z.type){case"screen-share:state-update":{const G=z.payload;G.status==="idle"?((P=o.current)==null||P.getTracks().forEach(X=>X.stop()),o.current=null,a.current=null,(H=s.current)==null||H.close(),s.current=null,i(X=>({...X,session:null,isHost:!1,isViewer:!1,isActive:!1,connectedDeviceId:null,pendingShareRequest:null}))):i(X=>({...X,session:G,isActive:G.status==="sharing"}));break}case"screen-share:start-request":{const G=z.payload;if(console.log(`[screen-share] start-request: host=${G.hostDeviceId} local=${d.current} viewers=[${(U=G.viewerDeviceIds)==null?void 0:U.join(",")}] isHostMatch=${G.hostDeviceId===d.current} pcRef=${!!s.current}`),G.hostDeviceId===d.current){const X=((q=G.viewerDeviceIds)==null?void 0:q[0])??"unknown",F=oue();if(F.has(X)||F.has("*")){console.log("[screen-share] Auto-approved share request from",X),b(G.sessionId);break}Mo()==="electron"&&((M=window.jaitDesktop)==null||M.notify({title:"Screen Share Request",body:"A remote device wants to view your screen."}).catch(()=>{}));const Q=Qn("Screen share requested",{description:"A remote device wants to view your screen.",duration:1/0,action:{label:"Always Allow",onClick:()=>{console.log("[screen-share] User accepted + enabled always-approve"),tpt("*"),b(G.sessionId),Qn.dismiss(Q)}},cancel:{label:"Share Once",onClick:()=>{console.log("[screen-share] User accepted share request (once)"),b(G.sessionId),Qn.dismiss(Q)}}})}else if(!G.viewerDeviceIds||G.viewerDeviceIds.length===0||G.viewerDeviceIds.includes(d.current)){if(s.current){console.log("[screen-share] Viewer PC already set up, skipping duplicate start-request");break}o.current&&(o.current.getTracks().forEach(X=>X.stop()),o.current=null),console.log("[screen-share] Setting up as viewer for session:",G.sessionId,"host:",G.hostDeviceId),i(X=>({...X,isViewer:!0,isHost:!1,isActive:!0,connectedDeviceId:G.hostDeviceId})),v(null,!1,G.sessionId)}break}case"screen-share:offer":{const G=z.payload;if(G.hostDeviceId===d.current){console.log("[screen-share] Ignoring own offer (we are the host)");break}console.log(`[screen-share] Received offer from host=${G.hostDeviceId} pcRef=${!!s.current}`);const X=s.current;X?X.setRemoteDescription(new RTCSessionDescription({type:"offer",sdp:G.sdp})).then(()=>X.createAnswer()).then(F=>{var W;X.setLocalDescription(F),console.log("[screen-share] Sending answer"),(W=l.current)==null||W.send(JSON.stringify({type:"screen-share:answer",payload:{sessionId:G.sessionId,viewerDeviceId:d.current,sdp:F.sdp}}))}).catch(F=>console.error("[screen-share] Offer handling failed:",F)):(console.log("[screen-share] PC not ready, queuing offer"),u.current=G);break}case"screen-share:answer":{const G=z.payload;if(G.viewerDeviceId===d.current){console.log("[screen-share] Ignoring own answer (we are the viewer)");break}console.log(`[screen-share] Received answer from viewer=${G.viewerDeviceId}`),(I=s.current)==null||I.setRemoteDescription(new RTCSessionDescription({type:"answer",sdp:G.sdp}));break}case"screen-share:ice-candidate":{const G=z.payload;if(G.fromDeviceId===d.current)break;console.log(`[screen-share] ICE candidate from=${G.fromDeviceId} pcRef=${!!s.current}`),(L=s.current)==null||L.addIceCandidate(new RTCIceCandidate({candidate:G.candidate,sdpMid:G.sdpMid,sdpMLineIndex:G.sdpMLineIndex}));break}}}catch{}},$.onclose=()=>{l.current=null,T&&(N=setTimeout(A,3e4))},$.onerror=()=>{}};return A(),()=>{var R;T=!1,N&&clearTimeout(N),(R=l.current)==null||R.close(),l.current=null}},[r]),y.useEffect(()=>{!r||!window.jaitDesktop||(p(),g())},[r,p,g]),y.useEffect(()=>{window.jaitDesktop&&(window.jaitDesktop.onScreenShareStart(()=>b()),window.jaitDesktop.onScreenShareStop(()=>S()))},[b,S]),{...n,requestRemoteShare:_,startHosting:b,disconnect:S,acceptPendingShare:w,rejectPendingShare:C,getDesktopSources:j,refreshState:g,localStream:o.current,remoteStream:a.current}}function spt(){return typeof window>"u"?!1:window.matchMedia("(prefers-color-scheme: dark)").matches}function BP(e){const{activeTheme:r}=WQ(),[n,i]=y.useState(spt);y.useEffect(()=>{if(typeof window>"u")return;const a=window.matchMedia("(prefers-color-scheme: dark)"),l=()=>i(a.matches);return l(),a.addEventListener("change",l),()=>a.removeEventListener("change",l)},[]);const s=(r==null?void 0:r.colorMode)??(e==="dark"||e==="system"&&n?"dark":"light"),o=(r==null?void 0:r.monacoThemeName)??(s==="dark"?"vs-dark":"vs");return y.useEffect(()=>{I9e({colorMode:s,monacoThemeName:o,theme:r})},[r,o,s]),{activeTheme:r,monacoThemeName:o,resolvedTheme:s}}function opt(e){const r=e==null?void 0:e.trim();return r?/^https?:\/\//i.test(r)?r:r.startsWith("/")?`${Ln()}${r}`:r:null}async function apt(e,r,n){const i=await fetch(`${Ln()}/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 save file: ${i.statusText}`)}}function lpt({detachedTabId:e}){const[r,n]=y.useState(()=>YF(e)),[i,s]=y.useState((r==null?void 0:r.tab.content)??""),[o,a]=y.useState(!1),[l,d]=y.useState(null),{monacoThemeName:u}=BP((r==null?void 0:r.theme)??"dark");y.useEffect(()=>{const v=()=>n(YF(e));return v(),window.addEventListener("storage",v),()=>window.removeEventListener("storage",v)},[e]),y.useEffect(()=>{r&&(document.title=r.title||r.tab.label||"Jait")},[r]),y.useEffect(()=>{s((r==null?void 0:r.tab.content)??"")},[r==null?void 0:r.tab.content]);const f=y.useMemo(()=>opt(r==null?void 0:r.tab.previewSrc),[r==null?void 0:r.tab.previewSrc]),p=y.useCallback(()=>{kYe(e),window.close()},[e]),g=y.useCallback(async()=>{if(!(!r||r.tab.type!=="file")){a(!0),d(null);try{await apt(r.tab.path,i,r.surfaceId??null)}catch(v){d(v instanceof Error?v.message:"Failed to save file")}finally{a(!1)}}},[i,r]);return r?c.jsxs("div",{className:"flex h-screen flex-col bg-muted/10 text-foreground",children:[c.jsxs("div",{className:"flex h-[35px] items-center gap-2 border-b bg-muted/30 px-3 shrink-0",children:[r.tab.type==="architecture"?c.jsx(G_,{className:"h-4 w-4 shrink-0"}):r.tab.type==="preview"?c.jsx(bi,{className:"h-4 w-4 shrink-0"}):null,c.jsx("span",{className:"truncate text-sm font-medium",children:r.title}),c.jsxs("div",{className:"ml-auto flex items-center gap-1.5",children:[r.tab.type==="file"&&c.jsxs(be,{type:"button",variant:"ghost",size:"sm",className:"h-8 px-2 text-xs",onClick:()=>{g()},disabled:o,children:[o?c.jsx(ir,{className:"mr-1 h-3 w-3 animate-spin"}):c.jsx(MR,{className:"mr-1 h-3 w-3"}),"Save"]}),r.tab.type==="preview"&&f&&c.jsx("a",{href:f,target:"_blank",rel:"noreferrer",className:"inline-flex",children:c.jsxs(be,{type:"button",variant:"ghost",size:"sm",className:"h-8 px-2 text-xs",children:[c.jsx(ep,{className:"mr-1 h-3 w-3"}),"Open"]})}),c.jsx(be,{type:"button",variant:"ghost",size:"icon",className:"h-8 w-8",onClick:p,children:c.jsx(Yn,{className:"h-4 w-4"})})]})]}),l?c.jsx("div",{className:"border-b px-3 py-2 text-xs text-destructive",children:l}):null,c.jsx("div",{className:"min-h-0 flex-1 bg-background",children:r.tab.type==="diff"?c.jsx(O2,{className:"h-full",editorClassName:"h-full",original:r.tab.originalContent??"",modified:r.tab.modifiedContent??"",language:r.tab.language??"plaintext",renderSideBySide:!0,options:{minimap:{enabled:!1}}}):r.tab.type==="preview"?f?c.jsx("iframe",{src:f,title:r.title,className:"h-full w-full bg-white",sandbox:"allow-forms allow-modals allow-pointer-lock allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-downloads"}):c.jsx("div",{className:"flex h-full items-center justify-center text-sm text-muted-foreground",children:"Preview unavailable."}):r.tab.type==="architecture"?c.jsx(kO,{diagram:r.architectureDiagram??null,isGenerating:r.architectureGenerating,theme:r.theme}):r.tab.originalContent!=null?c.jsx(Ooe,{path:r.tab.path,language:r.tab.language??"plaintext",value:i,originalContent:r.tab.originalContent,theme:u,onChange:v=>s(v??"")}):c.jsx(Ij,{height:"100%",beforeMount:C0,theme:u,path:r.tab.path,language:r.tab.language??"plaintext",value:i,onChange:v=>s(v??""),options:{minimap:{enabled:!1},fontSize:13,automaticLayout:!0}})})]}):c.jsx("div",{className:"flex h-screen items-center justify-center bg-background text-sm text-muted-foreground",children:"Detached tab not found."})}const cpt="jait:detached-terminal:";function zP(e){return`${cpt}${e}`}function upt(e){localStorage.setItem(zP(e.id),JSON.stringify(e))}function kV(e){const r=localStorage.getItem(zP(e));if(!r)return null;try{return JSON.parse(r)}catch{return null}}function dpt(e){localStorage.removeItem(zP(e))}function hpt({detachedId:e}){const[r,n]=y.useState(()=>kV(e));BP((r==null?void 0:r.theme)??"dark"),y.useEffect(()=>{const s=()=>n(kV(e));return s(),window.addEventListener("storage",s),()=>window.removeEventListener("storage",s)},[e]),y.useEffect(()=>{r&&(document.title=r.label||"Terminal")},[r]);const i=y.useCallback(()=>{dpt(e),window.close()},[e]);return r?c.jsxs("div",{className:"flex h-screen flex-col bg-background text-foreground",children:[c.jsxs("div",{className:"flex h-9 shrink-0 items-center justify-between border-b px-3",children:[c.jsx("span",{className:"truncate text-xs text-muted-foreground",children:r.label}),c.jsx("button",{onClick:i,className:"p-1 rounded hover:bg-muted text-muted-foreground hover:text-foreground transition-colors","aria-label":"Close",children:c.jsx(Yn,{className:"h-4 w-4"})})]}),c.jsx(N4,{terminalId:r.terminalId,className:"flex-1",token:r.token,workspaceRoot:r.workspaceRoot})]}):c.jsx("div",{className:"flex h-screen items-center justify-center bg-background text-muted-foreground",children:"Terminal session not found."})}const f8=Ln();function fpt({platform:e}){switch(e){case"windows":case"macos":case"linux":return c.jsx(Ea,{className:"h-3.5 w-3.5"});case"android":case"ios":return c.jsx(X4,{className:"h-3.5 w-3.5"});default:return c.jsx(bi,{className:"h-3.5 w-3.5"})}}function CV({open:e,onOpenChange:r,onSelect:n,gatewayOnly:i,initialPath:s,initialNodeId:o}){const[a,l]=y.useState(null),[d,u]=y.useState(null),[f,p]=y.useState([]),[g,v]=y.useState([]),[b,_]=y.useState(!1),[S,w]=y.useState(null),[C,j]=y.useState(""),[T,N]=y.useState(!1),[A,R]=y.useState([]),[$,B]=y.useState("gateway"),P=y.useCallback(X=>{l(X.path),u(X.parent),p(X.entries),j(X.path)},[]),H=y.useCallback(async(X,F)=>{const W=`${f8}/api/filesystem/browse?path=${encodeURIComponent(X)}&nodeId=${encodeURIComponent(F)}`,Q=await fetch(W);if(!Q.ok){const V=await Q.json().catch(()=>({message:"Failed to browse"}));throw new Error(V.message??"Failed to browse")}return await Q.json()},[]),U=y.useCallback(async(X,F)=>{try{_(!0),w(null),l(null),u(null),p([]);const W=`${f8}/api/filesystem/roots?nodeId=${encodeURIComponent(X)}`,Q=await fetch(W);if(!Q.ok)throw new Error("Failed to load roots");const V=await Q.json();if(v(V.roots),F)try{const re=await H(F,X);P(re);return}catch{}const ee=V.roots.find(re=>re.name==="Home")??V.roots[0];if(ee){const re=await H(ee.path,X);P(re)}}catch(W){w(W instanceof Error?W.message:"Failed to load")}finally{_(!1)}},[P,H]),q=y.useCallback(async(X,F)=>{try{const W=await fetch(`${f8}/api/filesystem/nodes`);if(!W.ok)throw new Error("Failed to load nodes");const Q=await W.json();R(Q.nodes);const V=Mo();let ee="gateway";if(X&&Q.nodes.some(re=>re.id===X)&&(ee=X),ee==="gateway"&&(V==="electron"||V==="capacitor")){const re=IP(),ce=Q.nodes.find(de=>de.id===re);ce&&(ee=ce.id)}B(ee),await U(ee,X===ee?F:null)}catch(W){w(W instanceof Error?W.message:"Failed to load nodes")}},[U]);y.useEffect(()=>{if(e){if(i){B("gateway"),U("gateway",s);return}q(o,s)}},[e,i,o,s,q,U]);const M=y.useCallback(async(X,F)=>{const W=F??$;try{_(!0),w(null);const Q=await H(X,W);P(Q)}catch(Q){w(Q instanceof Error?Q.message:"Failed to browse")}finally{_(!1)}},[P,H,$]),I=y.useCallback(X=>{B(X),U(X)},[U]),L=y.useCallback(()=>{a&&(n(a,$),r(!1))},[a,$,n,r]),z=y.useCallback(()=>{C.trim()&&(M(C.trim()),N(!1))},[C,M]),G=f.filter(X=>X.type==="dir");return c.jsx(jd,{open:e,onOpenChange:r,children:c.jsxs(_u,{className:"max-w-md sm:max-w-lg p-0 gap-0 overflow-hidden",children:[c.jsx(bd,{className:"px-4 pt-4 pb-2",children:c.jsxs(vu,{className:"flex items-center gap-2 text-base",children:[c.jsx(Ch,{className:"h-4 w-4"}),"Open Workspace"]})}),!i&&A.length>1&&c.jsx("div",{className:"flex items-center gap-1 px-3 py-1.5 border-b bg-muted/20 overflow-x-auto",children:A.map(X=>c.jsxs("button",{onClick:()=>I(X.id),className:ze("flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs whitespace-nowrap transition-colors",$===X.id?"bg-primary text-primary-foreground":"hover:bg-accent hover:text-accent-foreground text-muted-foreground"),children:[c.jsx(fpt,{platform:X.platform}),c.jsx("span",{children:X.name})]},X.id))}),c.jsxs("div",{className:"flex items-center gap-1 px-3 py-1.5 border-b text-xs text-muted-foreground bg-muted/30",children:[g.filter(X=>X.name!=="Home").map(X=>c.jsxs("button",{onClick:()=>void M(X.path),className:"px-1.5 py-0.5 rounded hover:bg-accent hover:text-accent-foreground flex items-center gap-1",title:X.path,children:[c.jsx(L0e,{className:"h-3 w-3"}),c.jsx("span",{children:X.name})]},X.path)),c.jsx("button",{onClick:()=>{const X=g.find(F=>F.name==="Home");X&&M(X.path)},className:"px-1.5 py-0.5 rounded hover:bg-accent hover:text-accent-foreground flex items-center gap-1",title:"Home directory",children:c.jsx(aK,{className:"h-3 w-3"})}),c.jsx("div",{className:"h-3 w-px bg-border mx-1"}),d&&c.jsx("button",{onClick:()=>void M(d),className:"px-1.5 py-0.5 rounded hover:bg-accent hover:text-accent-foreground flex items-center gap-1",title:"Go up",children:c.jsx(tK,{className:"h-3 w-3"})}),c.jsx("button",{onClick:()=>N(X=>!X),className:"ml-auto px-1.5 py-0.5 rounded hover:bg-accent hover:text-accent-foreground text-2xs",children:T?"Browse":"Enter path"})]}),T&&c.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b bg-muted/20",children:[c.jsx("input",{type:"text",value:C,onChange:X=>j(X.target.value),onKeyDown:X=>{X.key==="Enter"&&z()},className:"flex-1 h-7 px-2 text-xs border rounded bg-background focus:outline-none focus:ring-1 focus:ring-ring",placeholder:"Enter absolute path...",autoFocus:!0}),c.jsx(be,{size:"sm",variant:"secondary",className:"h-7 text-xs",onClick:z,children:"Go"})]}),c.jsx("div",{className:"px-3 py-1.5 text-xs font-mono text-muted-foreground truncate border-b",children:a??"..."}),c.jsx("div",{className:"overflow-y-auto min-h-[120px] max-h-[50vh]",children:c.jsxs("div",{className:"p-2",children:[b&&c.jsxs("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:[c.jsx(ir,{className:"h-4 w-4 animate-spin mr-2"}),"Loading..."]}),S&&c.jsx("div",{className:"text-destructive text-xs py-4 text-center",children:S}),!b&&!S&&G.length===0&&c.jsx("div",{className:"text-muted-foreground text-xs py-4 text-center",children:"No subdirectories"}),!b&&!S&&G.map(X=>c.jsxs("button",{onClick:()=>void M(X.path),className:ze("w-full flex items-center gap-2 px-2 py-1.5 rounded text-xs text-left","hover:bg-accent hover:text-accent-foreground transition-colors"),children:[c.jsx(TR,{className:"h-3.5 w-3.5 text-yellow-500 shrink-0"}),c.jsx("span",{className:"truncate",children:X.name}),c.jsx(mo,{className:"h-3 w-3 ml-auto text-muted-foreground shrink-0"})]},X.path))]})}),c.jsxs(W0,{className:"px-4 py-3 border-t",children:[c.jsx(be,{variant:"ghost",size:"sm",onClick:()=>r(!1),children:"Cancel"}),c.jsxs(be,{size:"sm",onClick:L,disabled:!a,children:[c.jsx(Ch,{className:"h-3.5 w-3.5 mr-1.5"}),"Open this folder"]})]})]})})}function ppt({onRetry:e}){const[r,n]=y.useState(!1),i=()=>{n(!0),e(),setTimeout(()=>n(!1),3e3)};return c.jsx("div",{className:"flex h-screen w-full items-center justify-center bg-background text-foreground",children:c.jsxs("div",{className:"flex max-w-md flex-col items-center gap-6 px-6 text-center",children:[c.jsx("div",{className:"flex h-20 w-20 items-center justify-center rounded-full bg-destructive/10",children:c.jsx(Hye,{className:"h-10 w-10 text-destructive"})}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Backend Unavailable"}),c.jsxs("p",{className:"text-sm text-muted-foreground",children:["Unable to connect to the Jait gateway at"," ",c.jsx("code",{className:"rounded bg-muted px-1.5 py-0.5 text-xs font-mono",children:Ln()})]}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Make sure the gateway is running and accessible, then try again."})]}),c.jsxs("button",{onClick:i,disabled:r,className:"inline-flex items-center gap-2 rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow hover:bg-primary/90 transition-colors disabled:opacity-50",children:[c.jsx(ea,{className:`h-4 w-4 ${r?"animate-spin":""}`}),r?"Connecting…":"Retry Connection"]})]})})}function jV(e){return{id:e.id??`evt-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,source:e.source,title:e.title,detail:e.detail,createdAt:e.createdAt??new Date().toISOString()}}function NV(e){if(e.role!=="user")return null;const r=Array.isArray(e.displaySegments)&&e.displaySegments.length>0,n=e.content.trim(),i=typeof e.displayContent=="string"?e.displayContent.trim():"";return JSON.stringify({role:"user",content:n,displayContent:i,displaySegments:r?e.displaySegments:null})}function mpt(e,r){const n=new Map;for(const s of e){const o=NV(s);o&&n.set(o,(n.get(o)??0)+1)}const i=[];for(const s of r){if(!s.optimistic||s.role!=="user")continue;const o=NV(s);if(!o){i.push(s);continue}const a=n.get(o)??0;if(a>0){n.set(o,a-1);continue}i.push(s)}return i.length===0?e:[...e,...i]}const Ku=Ln(),gpt=120,W7="Connection interrupted. Attempting to reconnect...";function p8(e){return e?{Authorization:`Bearer ${e}`}:{}}function TV(e){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?`${e}-${crypto.randomUUID()}`:`${e}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function EV(e){if(!(e instanceof Error)||e.name==="AbortError")return!1;const r=e.message.toLowerCase();return r.includes("network error")||r.includes("failed to fetch")||r.includes("fetch failed")||r.includes("load failed")||r.includes("network connection was lost")||r.includes("the internet connection appears to be offline")}function AV(e){return!e.sessionId||e.isLoadingHistory?!1:e.isLoading||e.messageCount===0||e.error===W7}function OV(e){if(!(e!=null&&e.length))return;const r=e.flatMap(n=>n.type==="image"?[{name:n.name,mimeType:n.mimeType,data:n.data,preview:`data:${n.mimeType};base64,${n.data}`}]:[]);return r.length>0?r:void 0}function ypt(e,r,n,i){const[s,o]=y.useState({messages:[],isLoading:!1,isLoadingHistory:!1,promptCount:0,remainingPrompts:null,error:null,hitMaxRounds:!1}),[a,l]=y.useState(null),[d,u]=y.useState([]),[f,p]=y.useState([]),[g,v]=y.useState([]),[b,_]=y.useState(0),[S,w]=y.useState(null),[C,j]=y.useState(null),T=y.useRef(null),N=y.useRef(null),A=y.useRef(null),R=y.useRef(null),$=y.useRef(0),B=y.useRef(!1),P=y.useRef(!1),[H,U]=y.useState(0),q=y.useCallback(()=>{e&&(R.current===e&&T.current||(P.current=!0,N.current=null,U($e=>$e+1)))},[e]);y.useEffect(()=>{if(e===N.current)return;const $e=P.current;if(P.current=!1,$.current+=1,N.current=e,A.current&&(A.current.abort(),A.current=null),!e){o({messages:[],isLoading:!1,isLoadingHistory:!1,promptCount:0,remainingPrompts:null,hitMaxRounds:!1,error:null}),u([]),p([]),v([]),w(null);return}let Ce=!1;o(_t=>({..._t,messages:$e?_t.messages:[],isLoading:!1,isLoadingHistory:!0,error:null})),w(null);const tt=new AbortController;return A.current=tt,(async()=>{var _t,yt;try{const Oe=await fetch(`${Ku}/api/sessions/${e}/stream?limit=${gpt}`,{signal:tt.signal,headers:p8(r)});if(Oe.status===401){n==null||n(),o(Xe=>({...Xe,isLoadingHistory:!1}));return}if(!Oe.ok||Ce)return;const He=(_t=Oe.body)==null?void 0:_t.getReader();if(!He)return;const Qe=new TextDecoder;let Mt="",_e=null;const Re=(Xe,Ct)=>{const mt=Xe?[...Xe]:[],Wt=mt[mt.length-1];return(Wt==null?void 0:Wt.type)==="text"?mt[mt.length-1]={type:"text",content:Wt.content+Ct}:mt.push({type:"text",content:Ct}),mt},ft=(Xe,Ct)=>{const mt=Xe?[...Xe]:[],Wt=mt[mt.length-1];return(Wt==null?void 0:Wt.type)==="toolGroup"?Wt.callIds.includes(Ct)||(mt[mt.length-1]={type:"toolGroup",callIds:[...Wt.callIds,Ct]}):mt.push({type:"toolGroup",callIds:[Ct]}),mt};let dt=null,De=null;const Ye=()=>{if(De!==null&&(window.cancelAnimationFrame(De),De=null),Ce||!dt||!_e)return;const Xe=dt,Ct=_e;dt=null,o(mt=>({...mt,messages:mt.messages.map(Wt=>Wt.id===Ct?{...Wt,...Xe}:Wt)}))},Fe=Xe=>{dt={...dt??{},...Xe},De===null&&(De=window.requestAnimationFrame(()=>{De=null,Ye()}))};let nt="",Bt,qe="";for(;;){const{done:Xe,value:Ct}=await He.read();if(Xe)break;if(Ce){He.cancel();break}Mt+=Qe.decode(Ct,{stream:!0});const mt=Mt.split(`
1264
1264
  `);Mt=mt.pop()||"";for(const Wt of mt)if(Wt.startsWith("data: "))try{const ct=JSON.parse(Wt.slice(6));if(dE(String(ct.type??"unknown"),Wt.slice(6)),ct.type==="snapshot"){const Ze=ct.messages,Nt=ct.streaming,Tt=Ze.map(Lt=>{const Et={id:Lt.id,role:Lt.role,content:Lt.content,contextFlow:Lt.contextFlow,thinking:Lt.thinking};if(Lt.role==="user"&&Lt.segments&&Lt.segments.length>0)Et.displaySegments=M9(Lt.segments),Et.displayContent=J1(Et.displaySegments),Et.referencedFiles=Q1(Et.displaySegments),Et.attachments=OV(Et.displaySegments);else if(Lt.role==="user"){const pt=zJ(Lt.content);pt.files.length>0&&(Et.displayContent=pt.text,Et.referencedFiles=pt.files,Et.displaySegments=pt.displaySegments,Et.attachments=OV(Et.displaySegments))}else Lt.segments&&Lt.segments.length>0&&(Et.segments=Lt.segments);return Lt.toolCalls&&Lt.toolCalls.length>0&&(Et.toolCalls=Lt.toolCalls.map(pt=>{let mr=pt.status??(pt.ok?"success":"error");return(mr==="running"||mr==="pending")&&!Nt&&(mr="error"),{callId:pt.callId,tool:pt.tool,args:pt.args??{},status:mr,result:mr==="running"?void 0:{ok:!!pt.ok,message:pt.message??"Cancelled",data:pt.data??(pt.output!=null?{output:pt.output}:void 0)},streamingOutput:pt.streamingOutput,startedAt:pt.startedAt??0,completedAt:pt.completedAt??0}})),Et}),we=Tt[Tt.length-1];(we==null?void 0:we.role)==="assistant"&&(_e=we.id,nt=we.content,Bt=we.segments,qe=we.thinking??""),o(Lt=>({...Lt,messages:mpt(Tt,Lt.messages),isLoadingHistory:!1,isLoading:Nt,error:null}))}else if(ct.type==="token"&&_e){const Ze=ct.content;nt+=Ze,Bt=Re(Bt,Ze),Fe({content:nt,segments:Bt?[...Bt]:void 0})}else if(ct.type==="thinking"&&_e)qe+=ct.content,Fe({thinking:qe});else if(ct.type==="tool_call_delta"&&_e){Ye();const Ze=ct.call_id,Nt=ct.name_delta||"",Tt=ct.args_delta||"";o(we=>{var mr;const Lt=we.messages.find(Nr=>Nr.id===_e);if((mr=Lt==null?void 0:Lt.toolCalls)==null?void 0:mr.find(Nr=>Nr.callId===Ze))return{...we,messages:we.messages.map(Nr=>{var tn;return Nr.id===_e?{...Nr,toolCalls:(tn=Nr.toolCalls)==null?void 0:tn.map($r=>$r.callId===Ze?{...$r,tool:$r.tool+Nt,streamingArgs:($r.streamingArgs??"")+Tt}:$r)}:Nr})};const pt={callId:Ze,parentCallId:ct.parent_call_id,tool:Nt,args:{},status:"pending",streamingArgs:Tt,startedAt:Date.now()};return{...we,messages:we.messages.map(Nr=>Nr.id===_e?{...Nr,toolCalls:[...Nr.toolCalls??[],pt],segments:ft(Nr.segments,Ze)}:Nr)}})}else if(ct.type==="tool_start"&&_e){Ye();const Ze=ct.call_id;o(Nt=>{var Et;const Tt=Nt.messages.find(pt=>pt.id===_e);if((Et=Tt==null?void 0:Tt.toolCalls)==null?void 0:Et.find(pt=>pt.callId===Ze))return{...Nt,messages:Nt.messages.map(pt=>{var mr;return pt.id===_e?{...pt,toolCalls:(mr=pt.toolCalls)==null?void 0:mr.map(Nr=>Nr.callId===Ze?{...Nr,tool:ct.tool,args:ct.args??{},parentCallId:ct.parent_call_id,status:"running",streamingArgs:void 0}:Nr)}:pt})};const Lt={callId:Ze,parentCallId:ct.parent_call_id,tool:ct.tool,args:ct.args??{},status:"running",startedAt:Date.now()};return{...Nt,messages:Nt.messages.map(pt=>pt.id===_e?{...pt,toolCalls:[...pt.toolCalls??[],Lt],segments:ft(pt.segments,Ze)}:pt)}})}else if(ct.type==="tool_output"&&_e)o(Ze=>({...Ze,messages:Ze.messages.map(Nt=>{var Tt;return Nt.id!==_e?Nt:{...Nt,toolCalls:(Tt=Nt.toolCalls)==null?void 0:Tt.map(we=>we.callId===ct.call_id?{...we,streamingOutput:(we.streamingOutput??"")+ct.content}:we)}})}));else if(ct.type==="tool_result"&&_e){if(o(Ze=>({...Ze,messages:Ze.messages.map(Nt=>{var Tt;return Nt.id!==_e?Nt:{...Nt,toolCalls:(Tt=Nt.toolCalls)==null?void 0:Tt.map(we=>we.callId===ct.call_id?{...we,parentCallId:we.parentCallId??ct.parent_call_id,status:ct.ok?"success":"error",result:{ok:ct.ok,message:ct.message,data:ct.data},completedAt:Date.now()}:we)}})})),ct.ok){const Ze=s.messages.find(Tt=>Tt.id===_e),Nt=(yt=Ze==null?void 0:Ze.toolCalls)==null?void 0:yt.find(Tt=>Tt.callId===ct.call_id);if(Nt){const Tt=Nt.tool.replace("_",".");if(Tt==="file.write"||Tt==="file.patch"||Tt==="edit"){const we=ct.data&&typeof ct.data=="object"?ct.data:void 0,Lt=AO(Tt,Nt.args??{},we,ct.message)??"";if(Lt){const Et=Lt.split("/").pop()??Lt;p(pt=>pt.some(mr=>mr.path===Lt)?pt:[...pt,{path:Lt,name:Et,state:"undecided"}])}}}}}else if(ct.type==="todo_list"){const Ze=ct.items;u(Ze)}else if(ct.type==="context_usage")w(ct);else if(ct.type==="context_flow"&&_e)o(Ze=>({...Ze,messages:Ze.messages.map(Nt=>Nt.id===_e?{...Nt,contextFlow:{provider:String(ct.provider??"jait"),model:typeof ct.model=="string"?ct.model:void 0,rounds:Array.isArray(ct.rounds)?ct.rounds:[]}}:Nt)}));else if(ct.type==="provider_fallback")j({provider:"jait",workspacePath:"",isRemote:!1});else if(ct.type==="session_info")j({provider:ct.provider,workspacePath:ct.workspacePath,isRemote:ct.isRemote,remoteNode:ct.remoteNode});else if(ct.type==="file_changed"){const Ze=ct.path,Nt=ct.name;p(Tt=>Tt.find(Lt=>Lt.path===Ze)?Tt:[...Tt,{path:Ze,name:Nt,state:"undecided"}])}else ct.type==="done"?(Ye(),o(Ze=>(Ze.isLoading&&_(Nt=>Nt+1),{...Ze,isLoading:!1,promptCount:ct.prompt_count??Ze.promptCount,remainingPrompts:ct.remaining_prompts??Ze.remainingPrompts,messages:Ze.messages.map(Nt=>{var Tt;return(Tt=Nt.toolCalls)!=null&&Tt.some(we=>we.status==="running")?{...Nt,toolCalls:Nt.toolCalls.map(we=>we.status==="running"?{...we,status:"error",result:{ok:!1,message:"Cancelled"},completedAt:Date.now()}:we)}:Nt})}))):ct.type==="error"&&o(Ze=>({...Ze,isLoading:!1,error:ct.message}))}catch(ct){if(!(ct instanceof SyntaxError))throw ct}}Ye()}catch(Oe){if(Oe instanceof Error&&Oe.name==="AbortError")return;Ce||o(He=>({...He,isLoadingHistory:!1,error:$e&&EV(Oe)?W7:He.error}))}})(),()=>{Ce=!0,tt.abort(),N.current=null}},[r,n,e,H]);const M=y.useCallback(()=>{!e||s.isLoading||q()},[q,e,s.isLoading]),I=y.useCallback(async($e,Ce={})=>{var Fe,nt,Bt,qe,Xe,Ct;const{token:tt,sessionId:_t,onLoginRequired:yt}=Ce,Oe=tt??r,He=yt??n,Qe=_t??e,Mt=TV("assistant"),_e={id:TV("user"),role:"user",content:$e,optimistic:!0,...Ce.displayContent?{displayContent:Ce.displayContent}:{},...(Fe=Ce.referencedFiles)!=null&&Fe.length?{referencedFiles:Ce.referencedFiles}:{},...(nt=Ce.displaySegments)!=null&&nt.length?{displaySegments:Ce.displaySegments}:{},...(Bt=Ce.attachments)!=null&&Bt.length?{attachments:Ce.attachments}:{}};o(mt=>({...mt,messages:[...mt.messages,_e,{id:Mt,role:"assistant",content:""}],isLoading:!0,error:null,hitMaxRounds:!1})),u([]);const Re=new AbortController;T.current=Re,R.current=Qe,A.current&&(A.current.abort(),A.current=null);const ft=++$.current,dt=()=>N.current!==Qe||$.current!==ft;let De=null,Ye=null;try{const mt={"Content-Type":"application/json"};Oe&&(mt.Authorization=`Bearer ${Oe}`);const Wt={content:$e,sessionId:Qe,...Ce.mode&&Ce.mode!=="agent"?{mode:Ce.mode}:{},...Ce.provider&&Ce.provider!=="jait"?{provider:Ce.provider}:{},...Ce.provider&&Ce.provider!=="jait"&&Ce.runtimeMode?{runtimeMode:Ce.runtimeMode}:{},...Ce.responseStyle&&Ce.responseStyle!=="normal"?{responseStyle:Ce.responseStyle}:{},...Ce.model?{model:Ce.model}:{},...(qe=Ce.displaySegments)!=null&&qe.length?{displaySegments:Ce.displaySegments}:{},...(Xe=Ce.attachments)!=null&&Xe.length?{attachments:Ce.attachments.map(ht=>({name:ht.name,mimeType:ht.mimeType,data:ht.data}))}:{}};dE("request",JSON.stringify(Wt));const ct=await fetch(`${Ku}/api/chat`,{method:"POST",headers:mt,body:JSON.stringify(Wt),signal:Re.signal});if(ct.status===401){const ht=await ct.json();if(ht.detail==="login_required"||ht.detail==="limit_reached")return o(fr=>({...fr,isLoading:!1,error:ht.detail,messages:fr.messages.filter(Dt=>Ce.queued?Dt.id!==Mt&&Dt.id!==_e.id:!(Dt.id===Mt&&!Dt.content&&!Dt.thinking&&(!Dt.toolCalls||Dt.toolCalls.length===0)))})),ht.detail==="login_required"&&(He==null||He()),"retry"}if(!ct.ok)throw new Error(`HTTP ${ct.status}`);const Ze=(Ct=ct.body)==null?void 0:Ct.getReader();if(!Ze)throw new Error("No response body");const Nt=new TextDecoder;let Tt="",we="",Lt=null,Et;const pt=[],mr=[];let Nr="",tn=!1;const $r=ht=>{const fr=mr[mr.length-1];(fr==null?void 0:fr.type)==="text"?fr.content+=ht:mr.push({type:"text",content:ht})},st=ht=>{const fr=mr[mr.length-1];(fr==null?void 0:fr.type)==="toolGroup"?fr.callIds.includes(ht)||fr.callIds.push(ht):mr.push({type:"toolGroup",callIds:[ht]})},Pt=()=>{if(Ye!==null&&(window.cancelAnimationFrame(Ye),Ye=null),dt()||!De)return;const ht=De;De=null,o(fr=>({...fr,messages:fr.messages.map(Dt=>Dt.id===Mt?{...Dt,...ht}:Dt)}))},Lr=(ht,fr)=>{if(!dt()){if(De={...De??{},...ht},fr!=null&&fr.immediate){Pt();return}Ye===null&&(Ye=window.requestAnimationFrame(()=>{Ye=null,Pt()}))}};for(;;){const{done:ht,value:fr}=await Ze.read();if(ht)break;Nr+=Nt.decode(fr,{stream:!0});const Dt=Nr.split(`
@@ -1,2 +1,2 @@
1
- import{_ as a,l as s,L as n,e as i}from"./index-DlGzWGrc.js";import{p}from"./treemap-KZPCXAKY-8AgiWapA.js";import"./_baseUniq-MZGnGk4b.js";import"./_basePickBy-BXZRiCmU.js";import"./clone-DaIkNSm1.js";var g={parse:a(async r=>{const e=await p("info",r);s.debug(e)},"parse")},v={version:"11.13.0"},d=a(()=>v.version,"getVersion"),m={getVersion:d},c=a((r,e,o)=>{s.debug(`rendering info diagram
1
+ import{_ as a,l as s,L as n,e as i}from"./index-BDVleDcT.js";import{p}from"./treemap-KZPCXAKY-Cx3W2b9f.js";import"./_baseUniq-eegdhD3S.js";import"./_basePickBy-Rm1nk2-J.js";import"./clone-pGFj9GCE.js";var g={parse:a(async r=>{const e=await p("info",r);s.debug(e)},"parse")},v={version:"11.13.0"},d=a(()=>v.version,"getVersion"),m={getVersion:d},c=a((r,e,o)=>{s.debug(`rendering info diagram
2
2
  `+r);const t=n(e);i(t,100,400,!0),t.append("g").append("text").attr("x",100).attr("y",40).attr("class","version").attr("font-size",32).style("text-anchor","middle").text(`v${o}`)},"draw"),l={draw:c},y={parser:g,db:m,renderer:l};export{y as diagram};
@@ -1,4 +1,4 @@
1
- import{_ as o,c as ot,a4 as ut,L as dt,as as yt,A as ft,k as pt,q as it,a as gt,b as kt,g as wt,s as mt,t as _t,e as bt}from"./index-DlGzWGrc.js";var tt=(function(){var e=o(function(M,t,s,i){for(s=s||{},i=M.length;i--;s[M[i]]=t);return s},"o"),h=[1,4],r=[1,14],a=[1,12],l=[1,13],y=[6,7,8],f=[1,20],d=[1,18],w=[1,19],c=[6,7,11],k=[1,6,13,14],g=[1,23],_=[1,24],x=[1,6,7,11,13,14],N={trace:o(function(){},"trace"),yy:{},symbols_:{error:2,start:3,ishikawa:4,spaceLines:5,SPACELINE:6,NL:7,ISHIKAWA:8,document:9,stop:10,EOF:11,statement:12,SPACELIST:13,TEXT:14,$accept:0,$end:1},terminals_:{2:"error",6:"SPACELINE",7:"NL",8:"ISHIKAWA",11:"EOF",13:"SPACELIST",14:"TEXT"},productions_:[0,[3,1],[3,2],[5,1],[5,2],[5,2],[4,2],[4,3],[10,1],[10,1],[10,1],[10,2],[10,2],[9,3],[9,2],[12,2],[12,1],[12,1],[12,1]],performAction:o(function(t,s,i,u,p,n,v){var m=n.length-1;switch(p){case 6:case 7:return u;case 15:u.addNode(n[m-1].length,n[m].trim());break;case 16:u.addNode(0,n[m].trim());break}},"anonymous"),table:[{3:1,4:2,5:3,6:[1,5],8:h},{1:[3]},{1:[2,1]},{4:6,6:[1,7],7:[1,8],8:h},{6:r,7:[1,10],9:9,12:11,13:a,14:l},e(y,[2,3]),{1:[2,2]},e(y,[2,4]),e(y,[2,5]),{1:[2,6],6:r,12:15,13:a,14:l},{6:r,9:16,12:11,13:a,14:l},{6:f,7:d,10:17,11:w},e(c,[2,18],{14:[1,21]}),e(c,[2,16]),e(c,[2,17]),{6:f,7:d,10:22,11:w},{1:[2,7],6:r,12:15,13:a,14:l},e(k,[2,14],{7:g,11:_}),e(x,[2,8]),e(x,[2,9]),e(x,[2,10]),e(c,[2,15]),e(k,[2,13],{7:g,11:_}),e(x,[2,11]),e(x,[2,12])],defaultActions:{2:[2,1],6:[2,2]},parseError:o(function(t,s){if(s.recoverable)this.trace(t);else{var i=new Error(t);throw i.hash=s,i}},"parseError"),parse:o(function(t){var s=this,i=[0],u=[],p=[null],n=[],v=this.table,m="",I=0,S=0,L=2,E=1,R=n.slice.call(arguments,1),b=Object.create(this.lexer),C={yy:{}};for(var F in this.yy)Object.prototype.hasOwnProperty.call(this.yy,F)&&(C.yy[F]=this.yy[F]);b.setInput(t,C.yy),C.yy.lexer=b,C.yy.parser=this,typeof b.yylloc>"u"&&(b.yylloc={});var T=b.yylloc;n.push(T);var D=b.options&&b.options.ranges;typeof C.yy.parseError=="function"?this.parseError=C.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function j(P){i.length=i.length-2*P,p.length=p.length-P,n.length=n.length-P}o(j,"popStack");function z(){var P;return P=u.pop()||b.lex()||E,typeof P!="number"&&(P instanceof Array&&(u=P,P=u.pop()),P=s.symbols_[P]||P),P}o(z,"lex");for(var A,W,B,K,H={},X,V,et,Y;;){if(W=i[i.length-1],this.defaultActions[W]?B=this.defaultActions[W]:((A===null||typeof A>"u")&&(A=z()),B=v[W]&&v[W][A]),typeof B>"u"||!B.length||!B[0]){var Q="";Y=[];for(X in v[W])this.terminals_[X]&&X>L&&Y.push("'"+this.terminals_[X]+"'");b.showPosition?Q="Parse error on line "+(I+1)+`:
1
+ import{_ as o,c as ot,a4 as ut,L as dt,as as yt,A as ft,k as pt,q as it,a as gt,b as kt,g as wt,s as mt,t as _t,e as bt}from"./index-BDVleDcT.js";var tt=(function(){var e=o(function(M,t,s,i){for(s=s||{},i=M.length;i--;s[M[i]]=t);return s},"o"),h=[1,4],r=[1,14],a=[1,12],l=[1,13],y=[6,7,8],f=[1,20],d=[1,18],w=[1,19],c=[6,7,11],k=[1,6,13,14],g=[1,23],_=[1,24],x=[1,6,7,11,13,14],N={trace:o(function(){},"trace"),yy:{},symbols_:{error:2,start:3,ishikawa:4,spaceLines:5,SPACELINE:6,NL:7,ISHIKAWA:8,document:9,stop:10,EOF:11,statement:12,SPACELIST:13,TEXT:14,$accept:0,$end:1},terminals_:{2:"error",6:"SPACELINE",7:"NL",8:"ISHIKAWA",11:"EOF",13:"SPACELIST",14:"TEXT"},productions_:[0,[3,1],[3,2],[5,1],[5,2],[5,2],[4,2],[4,3],[10,1],[10,1],[10,1],[10,2],[10,2],[9,3],[9,2],[12,2],[12,1],[12,1],[12,1]],performAction:o(function(t,s,i,u,p,n,v){var m=n.length-1;switch(p){case 6:case 7:return u;case 15:u.addNode(n[m-1].length,n[m].trim());break;case 16:u.addNode(0,n[m].trim());break}},"anonymous"),table:[{3:1,4:2,5:3,6:[1,5],8:h},{1:[3]},{1:[2,1]},{4:6,6:[1,7],7:[1,8],8:h},{6:r,7:[1,10],9:9,12:11,13:a,14:l},e(y,[2,3]),{1:[2,2]},e(y,[2,4]),e(y,[2,5]),{1:[2,6],6:r,12:15,13:a,14:l},{6:r,9:16,12:11,13:a,14:l},{6:f,7:d,10:17,11:w},e(c,[2,18],{14:[1,21]}),e(c,[2,16]),e(c,[2,17]),{6:f,7:d,10:22,11:w},{1:[2,7],6:r,12:15,13:a,14:l},e(k,[2,14],{7:g,11:_}),e(x,[2,8]),e(x,[2,9]),e(x,[2,10]),e(c,[2,15]),e(k,[2,13],{7:g,11:_}),e(x,[2,11]),e(x,[2,12])],defaultActions:{2:[2,1],6:[2,2]},parseError:o(function(t,s){if(s.recoverable)this.trace(t);else{var i=new Error(t);throw i.hash=s,i}},"parseError"),parse:o(function(t){var s=this,i=[0],u=[],p=[null],n=[],v=this.table,m="",I=0,S=0,L=2,E=1,R=n.slice.call(arguments,1),b=Object.create(this.lexer),C={yy:{}};for(var F in this.yy)Object.prototype.hasOwnProperty.call(this.yy,F)&&(C.yy[F]=this.yy[F]);b.setInput(t,C.yy),C.yy.lexer=b,C.yy.parser=this,typeof b.yylloc>"u"&&(b.yylloc={});var T=b.yylloc;n.push(T);var D=b.options&&b.options.ranges;typeof C.yy.parseError=="function"?this.parseError=C.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function j(P){i.length=i.length-2*P,p.length=p.length-P,n.length=n.length-P}o(j,"popStack");function z(){var P;return P=u.pop()||b.lex()||E,typeof P!="number"&&(P instanceof Array&&(u=P,P=u.pop()),P=s.symbols_[P]||P),P}o(z,"lex");for(var A,W,B,K,H={},X,V,et,Y;;){if(W=i[i.length-1],this.defaultActions[W]?B=this.defaultActions[W]:((A===null||typeof A>"u")&&(A=z()),B=v[W]&&v[W][A]),typeof B>"u"||!B.length||!B[0]){var Q="";Y=[];for(X in v[W])this.terminals_[X]&&X>L&&Y.push("'"+this.terminals_[X]+"'");b.showPosition?Q="Parse error on line "+(I+1)+`:
2
2
  `+b.showPosition()+`
3
3
  Expecting `+Y.join(", ")+", got '"+(this.terminals_[A]||A)+"'":Q="Parse error on line "+(I+1)+": Unexpected "+(A==E?"end of input":"'"+(this.terminals_[A]||A)+"'"),this.parseError(Q,{text:b.match,token:this.terminals_[A]||A,line:b.yylineno,loc:T,expected:Y})}if(B[0]instanceof Array&&B.length>1)throw new Error("Parse Error: multiple actions possible at state: "+W+", token: "+A);switch(B[0]){case 1:i.push(A),p.push(b.yytext),n.push(b.yylloc),i.push(B[1]),A=null,S=b.yyleng,m=b.yytext,I=b.yylineno,T=b.yylloc;break;case 2:if(V=this.productions_[B[1]][1],H.$=p[p.length-V],H._$={first_line:n[n.length-(V||1)].first_line,last_line:n[n.length-1].last_line,first_column:n[n.length-(V||1)].first_column,last_column:n[n.length-1].last_column},D&&(H._$.range=[n[n.length-(V||1)].range[0],n[n.length-1].range[1]]),K=this.performAction.apply(H,[m,S,I,C.yy,B[1],p,n].concat(R)),typeof K<"u")return K;V&&(i=i.slice(0,-1*V*2),p=p.slice(0,-1*V),n=n.slice(0,-1*V)),i.push(this.productions_[B[1]][0]),p.push(H.$),n.push(H._$),et=v[i[i.length-2]][i[i.length-1]],i.push(et);break;case 3:return!0}}return!0},"parse")},O=(function(){var M={EOF:1,parseError:o(function(s,i){if(this.yy.parser)this.yy.parser.parseError(s,i);else throw new Error(s)},"parseError"),setInput:o(function(t,s){return this.yy=s||this.yy||{},this._input=t,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},"setInput"),input:o(function(){var t=this._input[0];this.yytext+=t,this.yyleng++,this.offset++,this.match+=t,this.matched+=t;var s=t.match(/(?:\r\n?|\n).*/g);return s?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),t},"input"),unput:o(function(t){var s=t.length,i=t.split(/(?:\r\n?|\n)/g);this._input=t+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-s),this.offset-=s;var u=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),i.length-1&&(this.yylineno-=i.length-1);var p=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:i?(i.length===u.length?this.yylloc.first_column:0)+u[u.length-i.length].length-i[0].length:this.yylloc.first_column-s},this.options.ranges&&(this.yylloc.range=[p[0],p[0]+this.yyleng-s]),this.yyleng=this.yytext.length,this},"unput"),more:o(function(){return this._more=!0,this},"more"),reject:o(function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return this.parseError("Lexical error on line "+(this.yylineno+1)+`. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
4
4
  `+this.showPosition(),{text:"",token:null,line:this.yylineno});return this},"reject"),less:o(function(t){this.unput(this.match.slice(t))},"less"),pastInput:o(function(){var t=this.matched.substr(0,this.matched.length-this.match.length);return(t.length>20?"...":"")+t.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:o(function(){var t=this.match;return t.length<20&&(t+=this._input.substr(0,20-t.length)),(t.substr(0,20)+(t.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:o(function(){var t=this.pastInput(),s=new Array(t.length+1).join("-");return t+this.upcomingInput()+`
@@ -1,4 +1,4 @@
1
- import{g as gt}from"./chunk-FMBD7UC4-CCSvYleD.js";import{a as mt,g as lt,h as xt,d as kt}from"./chunk-JSJVCQXG-B6akuuhS.js";import{g as _t,s as vt,a as bt,b as wt,t as Tt,q as St,_ as n,c as R,d as X,e as $t,A as Mt}from"./index-DlGzWGrc.js";import{d as et}from"./arc-CmWEdifE.js";var U=(function(){var t=n(function(h,i,a,l){for(a=a||{},l=h.length;l--;a[h[l]]=i);return a},"o"),e=[6,8,10,11,12,14,16,17,18],s=[1,9],c=[1,10],r=[1,11],f=[1,12],u=[1,13],y=[1,14],g={trace:n(function(){},"trace"),yy:{},symbols_:{error:2,start:3,journey:4,document:5,EOF:6,line:7,SPACE:8,statement:9,NEWLINE:10,title:11,acc_title:12,acc_title_value:13,acc_descr:14,acc_descr_value:15,acc_descr_multiline_value:16,section:17,taskName:18,taskData:19,$accept:0,$end:1},terminals_:{2:"error",4:"journey",6:"EOF",8:"SPACE",10:"NEWLINE",11:"title",12:"acc_title",13:"acc_title_value",14:"acc_descr",15:"acc_descr_value",16:"acc_descr_multiline_value",17:"section",18:"taskName",19:"taskData"},productions_:[0,[3,3],[5,0],[5,2],[7,2],[7,1],[7,1],[7,1],[9,1],[9,2],[9,2],[9,1],[9,1],[9,2]],performAction:n(function(i,a,l,d,p,o,b){var k=o.length-1;switch(p){case 1:return o[k-1];case 2:this.$=[];break;case 3:o[k-1].push(o[k]),this.$=o[k-1];break;case 4:case 5:this.$=o[k];break;case 6:case 7:this.$=[];break;case 8:d.setDiagramTitle(o[k].substr(6)),this.$=o[k].substr(6);break;case 9:this.$=o[k].trim(),d.setAccTitle(this.$);break;case 10:case 11:this.$=o[k].trim(),d.setAccDescription(this.$);break;case 12:d.addSection(o[k].substr(8)),this.$=o[k].substr(8);break;case 13:d.addTask(o[k-1],o[k]),this.$="task";break}},"anonymous"),table:[{3:1,4:[1,2]},{1:[3]},t(e,[2,2],{5:3}),{6:[1,4],7:5,8:[1,6],9:7,10:[1,8],11:s,12:c,14:r,16:f,17:u,18:y},t(e,[2,7],{1:[2,1]}),t(e,[2,3]),{9:15,11:s,12:c,14:r,16:f,17:u,18:y},t(e,[2,5]),t(e,[2,6]),t(e,[2,8]),{13:[1,16]},{15:[1,17]},t(e,[2,11]),t(e,[2,12]),{19:[1,18]},t(e,[2,4]),t(e,[2,9]),t(e,[2,10]),t(e,[2,13])],defaultActions:{},parseError:n(function(i,a){if(a.recoverable)this.trace(i);else{var l=new Error(i);throw l.hash=a,l}},"parseError"),parse:n(function(i){var a=this,l=[0],d=[],p=[null],o=[],b=this.table,k="",C=0,K=0,dt=2,Q=1,yt=o.slice.call(arguments,1),_=Object.create(this.lexer),I={yy:{}};for(var O in this.yy)Object.prototype.hasOwnProperty.call(this.yy,O)&&(I.yy[O]=this.yy[O]);_.setInput(i,I.yy),I.yy.lexer=_,I.yy.parser=this,typeof _.yylloc>"u"&&(_.yylloc={});var Y=_.yylloc;o.push(Y);var ft=_.options&&_.options.ranges;typeof I.yy.parseError=="function"?this.parseError=I.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function pt(w){l.length=l.length-2*w,p.length=p.length-w,o.length=o.length-w}n(pt,"popStack");function D(){var w;return w=d.pop()||_.lex()||Q,typeof w!="number"&&(w instanceof Array&&(d=w,w=d.pop()),w=a.symbols_[w]||w),w}n(D,"lex");for(var v,A,T,q,F={},N,M,tt,z;;){if(A=l[l.length-1],this.defaultActions[A]?T=this.defaultActions[A]:((v===null||typeof v>"u")&&(v=D()),T=b[A]&&b[A][v]),typeof T>"u"||!T.length||!T[0]){var H="";z=[];for(N in b[A])this.terminals_[N]&&N>dt&&z.push("'"+this.terminals_[N]+"'");_.showPosition?H="Parse error on line "+(C+1)+`:
1
+ import{g as gt}from"./chunk-FMBD7UC4-M_Qlfnyh.js";import{a as mt,g as lt,h as xt,d as kt}from"./chunk-JSJVCQXG-Dik0HyOL.js";import{g as _t,s as vt,a as bt,b as wt,t as Tt,q as St,_ as n,c as R,d as X,e as $t,A as Mt}from"./index-BDVleDcT.js";import{d as et}from"./arc-ChJj5aUQ.js";var U=(function(){var t=n(function(h,i,a,l){for(a=a||{},l=h.length;l--;a[h[l]]=i);return a},"o"),e=[6,8,10,11,12,14,16,17,18],s=[1,9],c=[1,10],r=[1,11],f=[1,12],u=[1,13],y=[1,14],g={trace:n(function(){},"trace"),yy:{},symbols_:{error:2,start:3,journey:4,document:5,EOF:6,line:7,SPACE:8,statement:9,NEWLINE:10,title:11,acc_title:12,acc_title_value:13,acc_descr:14,acc_descr_value:15,acc_descr_multiline_value:16,section:17,taskName:18,taskData:19,$accept:0,$end:1},terminals_:{2:"error",4:"journey",6:"EOF",8:"SPACE",10:"NEWLINE",11:"title",12:"acc_title",13:"acc_title_value",14:"acc_descr",15:"acc_descr_value",16:"acc_descr_multiline_value",17:"section",18:"taskName",19:"taskData"},productions_:[0,[3,3],[5,0],[5,2],[7,2],[7,1],[7,1],[7,1],[9,1],[9,2],[9,2],[9,1],[9,1],[9,2]],performAction:n(function(i,a,l,d,p,o,b){var k=o.length-1;switch(p){case 1:return o[k-1];case 2:this.$=[];break;case 3:o[k-1].push(o[k]),this.$=o[k-1];break;case 4:case 5:this.$=o[k];break;case 6:case 7:this.$=[];break;case 8:d.setDiagramTitle(o[k].substr(6)),this.$=o[k].substr(6);break;case 9:this.$=o[k].trim(),d.setAccTitle(this.$);break;case 10:case 11:this.$=o[k].trim(),d.setAccDescription(this.$);break;case 12:d.addSection(o[k].substr(8)),this.$=o[k].substr(8);break;case 13:d.addTask(o[k-1],o[k]),this.$="task";break}},"anonymous"),table:[{3:1,4:[1,2]},{1:[3]},t(e,[2,2],{5:3}),{6:[1,4],7:5,8:[1,6],9:7,10:[1,8],11:s,12:c,14:r,16:f,17:u,18:y},t(e,[2,7],{1:[2,1]}),t(e,[2,3]),{9:15,11:s,12:c,14:r,16:f,17:u,18:y},t(e,[2,5]),t(e,[2,6]),t(e,[2,8]),{13:[1,16]},{15:[1,17]},t(e,[2,11]),t(e,[2,12]),{19:[1,18]},t(e,[2,4]),t(e,[2,9]),t(e,[2,10]),t(e,[2,13])],defaultActions:{},parseError:n(function(i,a){if(a.recoverable)this.trace(i);else{var l=new Error(i);throw l.hash=a,l}},"parseError"),parse:n(function(i){var a=this,l=[0],d=[],p=[null],o=[],b=this.table,k="",C=0,K=0,dt=2,Q=1,yt=o.slice.call(arguments,1),_=Object.create(this.lexer),I={yy:{}};for(var O in this.yy)Object.prototype.hasOwnProperty.call(this.yy,O)&&(I.yy[O]=this.yy[O]);_.setInput(i,I.yy),I.yy.lexer=_,I.yy.parser=this,typeof _.yylloc>"u"&&(_.yylloc={});var Y=_.yylloc;o.push(Y);var ft=_.options&&_.options.ranges;typeof I.yy.parseError=="function"?this.parseError=I.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function pt(w){l.length=l.length-2*w,p.length=p.length-w,o.length=o.length-w}n(pt,"popStack");function D(){var w;return w=d.pop()||_.lex()||Q,typeof w!="number"&&(w instanceof Array&&(d=w,w=d.pop()),w=a.symbols_[w]||w),w}n(D,"lex");for(var v,A,T,q,F={},N,M,tt,z;;){if(A=l[l.length-1],this.defaultActions[A]?T=this.defaultActions[A]:((v===null||typeof v>"u")&&(v=D()),T=b[A]&&b[A][v]),typeof T>"u"||!T.length||!T[0]){var H="";z=[];for(N in b[A])this.terminals_[N]&&N>dt&&z.push("'"+this.terminals_[N]+"'");_.showPosition?H="Parse error on line "+(C+1)+`:
2
2
  `+_.showPosition()+`
3
3
  Expecting `+z.join(", ")+", got '"+(this.terminals_[v]||v)+"'":H="Parse error on line "+(C+1)+": Unexpected "+(v==Q?"end of input":"'"+(this.terminals_[v]||v)+"'"),this.parseError(H,{text:_.match,token:this.terminals_[v]||v,line:_.yylineno,loc:Y,expected:z})}if(T[0]instanceof Array&&T.length>1)throw new Error("Parse Error: multiple actions possible at state: "+A+", token: "+v);switch(T[0]){case 1:l.push(v),p.push(_.yytext),o.push(_.yylloc),l.push(T[1]),v=null,K=_.yyleng,k=_.yytext,C=_.yylineno,Y=_.yylloc;break;case 2:if(M=this.productions_[T[1]][1],F.$=p[p.length-M],F._$={first_line:o[o.length-(M||1)].first_line,last_line:o[o.length-1].last_line,first_column:o[o.length-(M||1)].first_column,last_column:o[o.length-1].last_column},ft&&(F._$.range=[o[o.length-(M||1)].range[0],o[o.length-1].range[1]]),q=this.performAction.apply(F,[k,K,C,I.yy,T[1],p,o].concat(yt)),typeof q<"u")return q;M&&(l=l.slice(0,-1*M*2),p=p.slice(0,-1*M),o=o.slice(0,-1*M)),l.push(this.productions_[T[1]][0]),p.push(F.$),o.push(F._$),tt=b[l[l.length-2]][l[l.length-1]],l.push(tt);break;case 3:return!0}}return!0},"parse")},m=(function(){var h={EOF:1,parseError:n(function(a,l){if(this.yy.parser)this.yy.parser.parseError(a,l);else throw new Error(a)},"parseError"),setInput:n(function(i,a){return this.yy=a||this.yy||{},this._input=i,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},"setInput"),input:n(function(){var i=this._input[0];this.yytext+=i,this.yyleng++,this.offset++,this.match+=i,this.matched+=i;var a=i.match(/(?:\r\n?|\n).*/g);return a?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),i},"input"),unput:n(function(i){var a=i.length,l=i.split(/(?:\r\n?|\n)/g);this._input=i+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-a),this.offset-=a;var d=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),l.length-1&&(this.yylineno-=l.length-1);var p=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:l?(l.length===d.length?this.yylloc.first_column:0)+d[d.length-l.length].length-l[0].length:this.yylloc.first_column-a},this.options.ranges&&(this.yylloc.range=[p[0],p[0]+this.yyleng-a]),this.yyleng=this.yytext.length,this},"unput"),more:n(function(){return this._more=!0,this},"more"),reject:n(function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return this.parseError("Lexical error on line "+(this.yylineno+1)+`. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
4
4
  `+this.showPosition(),{text:"",token:null,line:this.yylineno});return this},"reject"),less:n(function(i){this.unput(this.match.slice(i))},"less"),pastInput:n(function(){var i=this.matched.substr(0,this.matched.length-this.match.length);return(i.length>20?"...":"")+i.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:n(function(){var i=this.match;return i.length<20&&(i+=this._input.substr(0,20-i.length)),(i.substr(0,20)+(i.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:n(function(){var i=this.pastInput(),a=new Array(i.length+1).join("-");return i+this.upcomingInput()+`