loki-mode 9.53.0 → 9.54.2

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 (119) hide show
  1. package/SKILL.md +2 -2
  2. package/VERSION +1 -1
  3. package/autonomy/completion-council.sh +28 -5
  4. package/autonomy/council-v2.sh +13 -7
  5. package/autonomy/lib/done-recognition.sh +24 -16
  6. package/autonomy/lib/proof-check.sh +11 -3
  7. package/autonomy/lib/proof-generator.py +36 -5
  8. package/autonomy/lib/voter-agents.sh +8 -3
  9. package/autonomy/lib/workspace_diff.py +106 -12
  10. package/autonomy/prd-checklist.sh +19 -11
  11. package/autonomy/run.sh +503 -52
  12. package/dashboard/__init__.py +1 -1
  13. package/dashboard/api_v2.py +4 -0
  14. package/dashboard/audit.py +9 -1
  15. package/dashboard/auth.py +16 -4
  16. package/dashboard/registry.py +34 -12
  17. package/dashboard/rigour_integration.py +25 -17
  18. package/dashboard/server.py +252 -104
  19. package/dashboard/static/cost.html +55 -26
  20. package/dashboard/static/index.html +475 -1544
  21. package/dashboard/static/proofs.html +1 -1
  22. package/docs/INSTALLATION.md +1 -1
  23. package/docs/air-gapped.md +7 -2
  24. package/docs/image-provenance.md +4 -2
  25. package/docs/v10/BACKLOG.md +82 -2
  26. package/docs/v10/BOARD.md +105 -0
  27. package/docs/v10/DECISIONS.md +71 -0
  28. package/docs/v10/METRICS.md +2 -1
  29. package/docs/v10/PROGRESS.md +60 -0
  30. package/docs/v10/SWARM-PROMPT.md +98 -0
  31. package/docs/v10/SWARM.md +237 -0
  32. package/loki-ts/dist/loki.js +323 -322
  33. package/mcp/__init__.py +1 -1
  34. package/package.json +1 -1
  35. package/plugins/loki-mode/.claude-plugin/plugin.json +1 -1
  36. package/providers/aider.sh +8 -0
  37. package/providers/cline.sh +8 -0
  38. package/providers/codex.sh +9 -0
  39. package/providers/opencode.sh +9 -0
  40. package/web-app/dist/assets/AdminPage-CZrBkzRF.js +32 -0
  41. package/web-app/dist/assets/Avatar-gQIp6FBI.js +11 -0
  42. package/web-app/dist/assets/{Badge-BF3mhT57.js → Badge-D2_fBTFY.js} +1 -1
  43. package/web-app/dist/assets/{Button-BDp9aJ9q.js → Button-D5qDd2ef.js} +1 -1
  44. package/web-app/dist/assets/CockpitPage-DVMk2RUK.js +47 -0
  45. package/web-app/dist/assets/ComparePage-NMLyE1xL.js +1 -0
  46. package/web-app/dist/assets/{ErrorBoundary-ut3wrUmu.js → ErrorBoundary-BRABI-BT.js} +1 -1
  47. package/web-app/dist/assets/EvidenceReceiptPanel-D2LNKqUx.js +1 -0
  48. package/web-app/dist/assets/GitHubIssuesPanel-BC5GzKUN.js +7 -0
  49. package/web-app/dist/assets/{GitHubPRsPanel-DurZgSaj.js → GitHubPRsPanel-BSlmoVTS.js} +3 -3
  50. package/web-app/dist/assets/HomePage-D_CDMoen.js +12 -0
  51. package/web-app/dist/assets/{LoginPage-HeRGJeZy.js → LoginPage-BBNA_N9t.js} +1 -1
  52. package/web-app/dist/assets/{MagicPage-CUKrqsZs.js → MagicPage-CnFRZCMx.js} +1 -1
  53. package/web-app/dist/assets/MetricsPage-CPfLMRlh.js +6 -0
  54. package/web-app/dist/assets/{NotFoundPage-BZDZ-B77.js → NotFoundPage-lA0XSGTz.js} +1 -1
  55. package/web-app/dist/assets/ProjectPage-CNAPbr9z.js +256 -0
  56. package/web-app/dist/assets/ProjectsPage-CMtm8goN.js +6 -0
  57. package/web-app/dist/assets/SettingsPage-BhIjVMYE.js +10 -0
  58. package/web-app/dist/assets/{ShowcasePage-BGS2jTGH.js → ShowcasePage-BndtGeYo.js} +1 -1
  59. package/web-app/dist/assets/SystemSettingsPage-euXI-KXE.js +1 -0
  60. package/web-app/dist/assets/TeamsPage-ClUKecun.js +11 -0
  61. package/web-app/dist/assets/TemplatesPage-BWHWVk0L.js +29 -0
  62. package/web-app/dist/assets/{TerminalOutput-togzv9Zl.js → TerminalOutput-Cv3N3Szf.js} +1 -1
  63. package/web-app/dist/assets/{activity-Dreyb_Kr.js → activity-dEhz-bXR.js} +1 -1
  64. package/web-app/dist/assets/{bell-DWH0drES.js → bell-B3XUMq1t.js} +1 -1
  65. package/web-app/dist/assets/{bot-78MoCuDl.js → bot-X-ssNlwR.js} +1 -1
  66. package/web-app/dist/assets/{check-ikfylPst.js → check-C_9Nx7kb.js} +1 -1
  67. package/web-app/dist/assets/{chevron-left-DXUqkd8J.js → chevron-left-tvNswo3A.js} +1 -1
  68. package/web-app/dist/assets/{circle-alert-Da74VO8P.js → circle-alert-CSB88nEs.js} +1 -1
  69. package/web-app/dist/assets/{clock-mlGCFq8l.js → clock-C8p2e4NI.js} +1 -1
  70. package/web-app/dist/assets/{cloud-B_Y5ZrIO.js → cloud-CKp2ZvhG.js} +1 -1
  71. package/web-app/dist/assets/{code-xml-Bbom7YWV.js → code-xml-dY70LCHD.js} +1 -1
  72. package/web-app/dist/assets/{database-CLcofiVp.js → database-DObn5fmn.js} +1 -1
  73. package/web-app/dist/assets/{dollar-sign-C5mkjXIM.js → dollar-sign-DSu6n3K3.js} +1 -1
  74. package/web-app/dist/assets/{file-code-corner-CVrkaOQP.js → file-code-corner-DpCnS73z.js} +1 -1
  75. package/web-app/dist/assets/{file-plus-BV9240gX.js → file-plus-D3IPKCf1.js} +1 -1
  76. package/web-app/dist/assets/{globe-aZ0Zso4I.js → globe-C9QXkgH_.js} +1 -1
  77. package/web-app/dist/assets/{hammer-EgOQNukG.js → hammer-D_FtWe1y.js} +1 -1
  78. package/web-app/dist/assets/index-CI54rara.css +1 -0
  79. package/web-app/dist/assets/{index-DvZ0Kk2x.js → index-Cz7q1bvC.js} +2 -2
  80. package/web-app/dist/assets/{layers-BOVKmepE.js → layers-DsW7jnJX.js} +1 -1
  81. package/web-app/dist/assets/{loader-circle-0K8yLgHl.js → loader-circle-B3HspjKR.js} +1 -1
  82. package/web-app/dist/assets/{lock-XzlDMy8M.js → lock-DSI29pct.js} +1 -1
  83. package/web-app/dist/assets/{package-BtXTKusI.js → package-CLNxtA2x.js} +1 -1
  84. package/web-app/dist/assets/{plus-PxeiD8ju.js → plus-DyI4WC4_.js} +1 -1
  85. package/web-app/dist/assets/{refresh-cw-CjqzYczt.js → refresh-cw-D2dv0xA0.js} +1 -1
  86. package/web-app/dist/assets/{rotate-ccw-CY0os4DH.js → rotate-ccw-CBvihA-a.js} +1 -1
  87. package/web-app/dist/assets/scroll-text-DvoOvAl_.js +6 -0
  88. package/web-app/dist/assets/{server-pIIs9vNp.js → server-DenWvSUt.js} +1 -1
  89. package/web-app/dist/assets/{shield-alert-CsDqKXwA.js → shield-alert-40cX_FvG.js} +1 -1
  90. package/web-app/dist/assets/{thumbs-up-CAh3HVzH.js → thumbs-up-BrjZ6QuV.js} +12 -7
  91. package/web-app/dist/assets/trash-2-C6evwkEH.js +16 -0
  92. package/web-app/dist/assets/{trending-down-DrtBd_C9.js → trending-down-CfbZis3O.js} +1 -1
  93. package/web-app/dist/assets/{trending-up-D-DbCHXm.js → trending-up-DWuEK3WC.js} +1 -1
  94. package/web-app/dist/assets/{upload-D4l6DCOt.js → upload-B9DFBcPG.js} +1 -1
  95. package/web-app/dist/assets/{usePolling-D0aoTX80.js → usePolling-BryVC-T1.js} +1 -1
  96. package/web-app/dist/assets/{user-BQf_XJO_.js → user-DMRXwZiw.js} +1 -1
  97. package/web-app/dist/index.html +2 -2
  98. package/web-app/server.py +122 -47
  99. package/web-app/dist/assets/AdminPage-y6_b2Xo4.js +0 -32
  100. package/web-app/dist/assets/Avatar-BFPkXhIJ.js +0 -6
  101. package/web-app/dist/assets/CockpitPage-5TKICCoA.js +0 -47
  102. package/web-app/dist/assets/ComparePage-BSuNsUHy.js +0 -1
  103. package/web-app/dist/assets/EvidenceReceiptPanel-CcaBwEI-.js +0 -1
  104. package/web-app/dist/assets/GitHubIssuesPanel-DJeYgzAa.js +0 -12
  105. package/web-app/dist/assets/HomePage-Bs451LAy.js +0 -28
  106. package/web-app/dist/assets/MetricsPage-DvY1csgz.js +0 -6
  107. package/web-app/dist/assets/ProjectPage-CqHkEZkl.js +0 -257
  108. package/web-app/dist/assets/ProjectsPage-CLvCK1Y8.js +0 -6
  109. package/web-app/dist/assets/SettingsPage-DP7OmdwP.js +0 -10
  110. package/web-app/dist/assets/SystemSettingsPage-P_rlLh0x.js +0 -1
  111. package/web-app/dist/assets/TeamsPage-DxtBDcBC.js +0 -11
  112. package/web-app/dist/assets/TemplatesPage-5e-faH3W.js +0 -29
  113. package/web-app/dist/assets/folder-open-D_6yV78G.js +0 -11
  114. package/web-app/dist/assets/index-BSgmPwC0.css +0 -1
  115. package/web-app/dist/assets/lightbulb-DdASgqOG.js +0 -6
  116. package/web-app/dist/assets/mail-COu670_W.js +0 -6
  117. package/web-app/dist/assets/minus-bQpUt9ff.js +0 -6
  118. package/web-app/dist/assets/save-v8qep5cY.js +0 -6
  119. package/web-app/dist/assets/trash-2-Dt6urTyY.js +0 -6
@@ -0,0 +1,256 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/GitHubIssuesPanel-BC5GzKUN.js","assets/index-Cz7q1bvC.js","assets/index-CI54rara.css","assets/Button-D5qDd2ef.js","assets/thumbs-up-BrjZ6QuV.js","assets/refresh-cw-D2dv0xA0.js","assets/circle-alert-CSB88nEs.js","assets/user-DMRXwZiw.js","assets/loader-circle-B3HspjKR.js","assets/rotate-ccw-CBvihA-a.js","assets/GitHubPRsPanel-BSlmoVTS.js","assets/chevron-left-tvNswo3A.js","assets/shield-alert-40cX_FvG.js","assets/file-code-corner-DpCnS73z.js","assets/clock-C8p2e4NI.js","assets/check-C_9Nx7kb.js","assets/ErrorBoundary-BRABI-BT.js","assets/TerminalOutput-Cv3N3Szf.js","assets/lock-DSI29pct.js","assets/package-CLNxtA2x.js","assets/file-plus-D3IPKCf1.js","assets/activity-dEhz-bXR.js","assets/scroll-text-DvoOvAl_.js","assets/bot-X-ssNlwR.js","assets/hammer-D_FtWe1y.js","assets/dollar-sign-DSu6n3K3.js","assets/globe-C9QXkgH_.js","assets/trash-2-C6evwkEH.js","assets/upload-B9DFBcPG.js","assets/plus-DyI4WC4_.js","assets/code-xml-dY70LCHD.js","assets/trending-up-DWuEK3WC.js","assets/layers-DsW7jnJX.js","assets/trending-down-CfbZis3O.js","assets/server-DenWvSUt.js"])))=>i.map(i=>d[i]);
2
+ var ra=e=>{throw TypeError(e)};var na=(e,t,s)=>t.has(e)||ra("Cannot "+s);var Us=(e,t,s)=>(na(e,t,"read from private field"),s?s.call(e):t.get(e)),oa=(e,t,s)=>t.has(e)?ra("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),aa=(e,t,s,i)=>(na(e,t,"write to private field"),i?i.call(e,s):t.set(e,s),s);import{c as ae,r as d,W as Ms,j as r,e as sn,f as Vl,g as mr,h as ms,I as xd,T as Ut,R as Kt,i as os,M as Gl,k as sr,l as ps,S as Yl,U as vd,X as gt,m as as,Z as Ls,a as W,E as ls,G as Te,K as bd,n as yd,o as Sd,F as _i,P as rs,_ as eo,p as pr,q as Xl,s as wd,t as Cd,v as kd,A as to,L as Nd,B as Js,w as rn,x as jd,d as Ed,y as Es,z as la,D as ca,H as Dd,J as Jl,N as oi,O as Rd,u as Pd}from"./index-Cz7q1bvC.js";import{R as Md,S as ir,P as Zl,E as Wi}from"./ErrorBoundary-BRABI-BT.js";import{B as le}from"./Button-D5qDd2ef.js";import{T as Ld,F as Bd}from"./TerminalOutput-Cv3N3Szf.js";import{P as Ql}from"./package-CLNxtA2x.js";import{F as Q}from"./file-code-corner-DpCnS73z.js";import{F as _r}from"./file-plus-D3IPKCf1.js";import{C as ut}from"./clock-C8p2e4NI.js";import{A as Td}from"./activity-dEhz-bXR.js";import{S as zd}from"./scroll-text-DvoOvAl_.js";import{B as Ad}from"./bot-X-ssNlwR.js";import{C as Yt}from"./check-C_9Nx7kb.js";import{L as gi}from"./loader-circle-B3HspjKR.js";import{H as Od}from"./hammer-D_FtWe1y.js";import{D as ec}from"./dollar-sign-DSu6n3K3.js";import{R as bt}from"./refresh-cw-D2dv0xA0.js";import{C as _s}from"./circle-alert-CSB88nEs.js";import{G as nn}from"./globe-C9QXkgH_.js";import{C as so,T as io,F as on}from"./trash-2-C6evwkEH.js";import{C as $d,G as an,a as tc,F as sc,H as rr,M as ic,T as Id}from"./thumbs-up-BrjZ6QuV.js";import{U as rc}from"./upload-B9DFBcPG.js";import{P as gr}from"./plus-DyI4WC4_.js";import{R as nc,E as Fd}from"./rotate-ccw-CBvihA-a.js";import{C as ln}from"./code-xml-dY70LCHD.js";import{T as Hd}from"./trending-up-DWuEK3WC.js";import{L as Wd}from"./layers-DsW7jnJX.js";import{T as Ud}from"./trending-down-CfbZis3O.js";import{S as Kd}from"./server-DenWvSUt.js";/**
3
+ * @license lucide-react v0.577.0 - ISC
4
+ *
5
+ * This source code is licensed under the ISC license.
6
+ * See the LICENSE file in the root directory of this source tree.
7
+ */const qd=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M16 8v5a3 3 0 0 0 6 0v-1a10 10 0 1 0-4 8",key:"7n84p3"}]],Vd=ae("at-sign",qd);/**
8
+ * @license lucide-react v0.577.0 - ISC
9
+ *
10
+ * This source code is licensed under the ISC license.
11
+ * See the LICENSE file in the root directory of this source tree.
12
+ */const Gd=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}]],oc=ae("ban",Gd);/**
13
+ * @license lucide-react v0.577.0 - ISC
14
+ *
15
+ * This source code is licensed under the ISC license.
16
+ * See the LICENSE file in the root directory of this source tree.
17
+ */const Yd=[["path",{d:"M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z",key:"18u6gg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]],Xd=ae("camera",Yd);/**
18
+ * @license lucide-react v0.577.0 - ISC
19
+ *
20
+ * This source code is licensed under the ISC license.
21
+ * See the LICENSE file in the root directory of this source tree.
22
+ */const Jd=[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]],Zd=ae("check-check",Jd);/**
23
+ * @license lucide-react v0.577.0 - ISC
24
+ *
25
+ * This source code is licensed under the ISC license.
26
+ * See the LICENSE file in the root directory of this source tree.
27
+ */const Qd=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}]],eu=ae("compass",Qd);/**
28
+ * @license lucide-react v0.577.0 - ISC
29
+ *
30
+ * This source code is licensed under the ISC license.
31
+ * See the LICENSE file in the root directory of this source tree.
32
+ */const tu=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1",key:"1oajmo"}],["path",{d:"M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1",key:"mpwhp6"}]],ro=ae("file-braces",tu);/**
33
+ * @license lucide-react v0.577.0 - ISC
34
+ *
35
+ * This source code is licensed under the ISC license.
36
+ * See the LICENSE file in the root directory of this source tree.
37
+ */const su=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]],ac=ae("file-code",su);/**
38
+ * @license lucide-react v0.577.0 - ISC
39
+ *
40
+ * This source code is licensed under the ISC license.
41
+ * See the LICENSE file in the root directory of this source tree.
42
+ */const iu=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M11 18h2",key:"12mj7e"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"M9 13v-.5a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 .5.5v.5",key:"qbrxap"}]],no=ae("file-type",iu);/**
43
+ * @license lucide-react v0.577.0 - ISC
44
+ *
45
+ * This source code is licensed under the ISC license.
46
+ * See the LICENSE file in the root directory of this source tree.
47
+ */const ru=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m14.5 12.5-5 5",key:"b62r18"}],["path",{d:"m9.5 12.5 5 5",key:"1rk7el"}]],nu=ae("file-x",ru);/**
48
+ * @license lucide-react v0.577.0 - ISC
49
+ *
50
+ * This source code is licensed under the ISC license.
51
+ * See the LICENSE file in the root directory of this source tree.
52
+ */const ou=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}]],oo=ae("file",ou);/**
53
+ * @license lucide-react v0.577.0 - ISC
54
+ *
55
+ * This source code is licensed under the ISC license.
56
+ * See the LICENSE file in the root directory of this source tree.
57
+ */const au=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],ao=ae("folder",au);/**
58
+ * @license lucide-react v0.577.0 - ISC
59
+ *
60
+ * This source code is licensed under the ISC license.
61
+ * See the LICENSE file in the root directory of this source tree.
62
+ */const lu=[["path",{d:"M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4",key:"tonef"}],["path",{d:"M9 18c-4.51 2-5-2-7-2",key:"9comsn"}]],cu=ae("github",lu);/**
63
+ * @license lucide-react v0.577.0 - ISC
64
+ *
65
+ * This source code is licensed under the ISC license.
66
+ * See the LICENSE file in the root directory of this source tree.
67
+ */const hu=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],du=ae("hash",hu);/**
68
+ * @license lucide-react v0.577.0 - ISC
69
+ *
70
+ * This source code is licensed under the ISC license.
71
+ * See the LICENSE file in the root directory of this source tree.
72
+ */const uu=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],ha=ae("image",uu);/**
73
+ * @license lucide-react v0.577.0 - ISC
74
+ *
75
+ * This source code is licensed under the ISC license.
76
+ * See the LICENSE file in the root directory of this source tree.
77
+ */const fu=[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]],mu=ae("key-round",fu);/**
78
+ * @license lucide-react v0.577.0 - ISC
79
+ *
80
+ * This source code is licensed under the ISC license.
81
+ * See the LICENSE file in the root directory of this source tree.
82
+ */const pu=[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]],Mr=ae("layout-dashboard",pu);/**
83
+ * @license lucide-react v0.577.0 - ISC
84
+ *
85
+ * This source code is licensed under the ISC license.
86
+ * See the LICENSE file in the root directory of this source tree.
87
+ */const _u=[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]],lc=ae("link",_u);/**
88
+ * @license lucide-react v0.577.0 - ISC
89
+ *
90
+ * This source code is licensed under the ISC license.
91
+ * See the LICENSE file in the root directory of this source tree.
92
+ */const gu=[["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m16.2 7.8 2.9-2.9",key:"r700ao"}],["path",{d:"M18 12h4",key:"wj9ykh"}],["path",{d:"m16.2 16.2 2.9 2.9",key:"1bxg5t"}],["path",{d:"M12 18v4",key:"jadmvz"}],["path",{d:"m4.9 19.1 2.9-2.9",key:"bwix9q"}],["path",{d:"M2 12h4",key:"j09sii"}],["path",{d:"m4.9 4.9 2.9 2.9",key:"giyufr"}]],xr=ae("loader",gu);/**
93
+ * @license lucide-react v0.577.0 - ISC
94
+ *
95
+ * This source code is licensed under the ISC license.
96
+ * See the LICENSE file in the root directory of this source tree.
97
+ */const xu=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],cn=ae("maximize-2",xu);/**
98
+ * @license lucide-react v0.577.0 - ISC
99
+ *
100
+ * This source code is licensed under the ISC license.
101
+ * See the LICENSE file in the root directory of this source tree.
102
+ */const vu=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],cc=ae("minimize-2",vu);/**
103
+ * @license lucide-react v0.577.0 - ISC
104
+ *
105
+ * This source code is licensed under the ISC license.
106
+ * See the LICENSE file in the root directory of this source tree.
107
+ */const bu=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"m15 8-3 3-3-3",key:"1oxy1z"}]],yu=ae("panel-bottom-close",bu);/**
108
+ * @license lucide-react v0.577.0 - ISC
109
+ *
110
+ * This source code is licensed under the ISC license.
111
+ * See the LICENSE file in the root directory of this source tree.
112
+ */const Su=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"m9 10 3-3 3 3",key:"11gsxs"}]],wu=ae("panel-bottom-open",Su);/**
113
+ * @license lucide-react v0.577.0 - ISC
114
+ *
115
+ * This source code is licensed under the ISC license.
116
+ * See the LICENSE file in the root directory of this source tree.
117
+ */const Cu=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]],ku=ae("panel-left-open",Cu);/**
118
+ * @license lucide-react v0.577.0 - ISC
119
+ *
120
+ * This source code is licensed under the ISC license.
121
+ * See the LICENSE file in the root directory of this source tree.
122
+ */const Nu=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],ju=ae("save",Nu);/**
123
+ * @license lucide-react v0.577.0 - ISC
124
+ *
125
+ * This source code is licensed under the ISC license.
126
+ * See the LICENSE file in the root directory of this source tree.
127
+ */const Eu=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],Du=ae("send",Eu);/**
128
+ * @license lucide-react v0.577.0 - ISC
129
+ *
130
+ * This source code is licensed under the ISC license.
131
+ * See the LICENSE file in the root directory of this source tree.
132
+ */const Ru=[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]],hc=ae("share-2",Ru);/**
133
+ * @license lucide-react v0.577.0 - ISC
134
+ *
135
+ * This source code is licensed under the ISC license.
136
+ * See the LICENSE file in the root directory of this source tree.
137
+ */const Pu=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],Mu=ae("smartphone",Pu);/**
138
+ * @license lucide-react v0.577.0 - ISC
139
+ *
140
+ * This source code is licensed under the ISC license.
141
+ * See the LICENSE file in the root directory of this source tree.
142
+ */const Lu=[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2",key:"76otgf"}],["line",{x1:"12",x2:"12.01",y1:"18",y2:"18",key:"1dp563"}]],Bu=ae("tablet",Lu);/**
143
+ * @license lucide-react v0.577.0 - ISC
144
+ *
145
+ * This source code is licensed under the ISC license.
146
+ * See the LICENSE file in the root directory of this source tree.
147
+ */const Tu=[["path",{d:"M21 7 6.82 21.18a2.83 2.83 0 0 1-3.99-.01a2.83 2.83 0 0 1 0-4L17 3",key:"1ub6xw"}],["path",{d:"m16 2 6 6",key:"1gw87d"}],["path",{d:"M12 16H4",key:"1cjfip"}]],ai=ae("test-tube-diagonal",Tu);/**
148
+ * @license lucide-react v0.577.0 - ISC
149
+ *
150
+ * This source code is licensed under the ISC license.
151
+ * See the LICENSE file in the root directory of this source tree.
152
+ */const zu=[["path",{d:"M9 18.12 10 14H4.17a2 2 0 0 1-1.92-2.56l2.33-8A2 2 0 0 1 6.5 2H20a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-2.76a2 2 0 0 0-1.79 1.11L12 22a3.13 3.13 0 0 1-3-3.88Z",key:"m61m77"}],["path",{d:"M17 14V2",key:"8ymqnk"}]],Au=ae("thumbs-down",zu);/**
153
+ * @license lucide-react v0.577.0 - ISC
154
+ *
155
+ * This source code is licensed under the ISC license.
156
+ * See the LICENSE file in the root directory of this source tree.
157
+ */const Ou=[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]],dc=ae("timer",Ou);/**
158
+ * @license lucide-react v0.577.0 - ISC
159
+ *
160
+ * This source code is licensed under the ISC license.
161
+ * See the LICENSE file in the root directory of this source tree.
162
+ */const $u=[["path",{d:"m19 5 3-3",key:"yk6iyv"}],["path",{d:"m2 22 3-3",key:"19mgm9"}],["path",{d:"M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z",key:"goz73y"}],["path",{d:"M7.5 13.5 10 11",key:"7xgeeb"}],["path",{d:"M10.5 16.5 13 14",key:"10btkg"}],["path",{d:"m12 6 6 6 2.3-2.3a2.4 2.4 0 0 0 0-3.4l-2.6-2.6a2.4 2.4 0 0 0-3.4 0Z",key:"1snsnr"}]],Iu=ae("unplug",$u);function da(e,t){(t==null||t>e.length)&&(t=e.length);for(var s=0,i=Array(t);s<t;s++)i[s]=e[s];return i}function Fu(e){if(Array.isArray(e))return e}function Hu(e,t,s){return(t=Yu(t))in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function Wu(e,t){var s=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(s!=null){var i,n,o,a,l=[],h=!0,c=!1;try{if(o=(s=s.call(e)).next,t!==0)for(;!(h=(i=o.call(s)).done)&&(l.push(i.value),l.length!==t);h=!0);}catch(f){c=!0,n=f}finally{try{if(!h&&s.return!=null&&(a=s.return(),Object(a)!==a))return}finally{if(c)throw n}}return l}}function Uu(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
163
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ua(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),s.push.apply(s,i)}return s}function fa(e){for(var t=1;t<arguments.length;t++){var s=arguments[t]!=null?arguments[t]:{};t%2?ua(Object(s),!0).forEach(function(i){Hu(e,i,s[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):ua(Object(s)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(s,i))})}return e}function Ku(e,t){if(e==null)return{};var s,i,n=qu(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(i=0;i<o.length;i++)s=o[i],t.indexOf(s)===-1&&{}.propertyIsEnumerable.call(e,s)&&(n[s]=e[s])}return n}function qu(e,t){if(e==null)return{};var s={};for(var i in e)if({}.hasOwnProperty.call(e,i)){if(t.indexOf(i)!==-1)continue;s[i]=e[i]}return s}function Vu(e,t){return Fu(e)||Wu(e,t)||Xu(e,t)||Uu()}function Gu(e,t){if(typeof e!="object"||!e)return e;var s=e[Symbol.toPrimitive];if(s!==void 0){var i=s.call(e,t);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Yu(e){var t=Gu(e,"string");return typeof t=="symbol"?t:t+""}function Xu(e,t){if(e){if(typeof e=="string")return da(e,t);var s={}.toString.call(e).slice(8,-1);return s==="Object"&&e.constructor&&(s=e.constructor.name),s==="Map"||s==="Set"?Array.from(e):s==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s)?da(e,t):void 0}}function Ju(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function ma(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),s.push.apply(s,i)}return s}function pa(e){for(var t=1;t<arguments.length;t++){var s=arguments[t]!=null?arguments[t]:{};t%2?ma(Object(s),!0).forEach(function(i){Ju(e,i,s[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):ma(Object(s)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(s,i))})}return e}function Zu(){for(var e=arguments.length,t=new Array(e),s=0;s<e;s++)t[s]=arguments[s];return function(i){return t.reduceRight(function(n,o){return o(n)},i)}}function Zs(e){return function t(){for(var s=this,i=arguments.length,n=new Array(i),o=0;o<i;o++)n[o]=arguments[o];return n.length>=e.length?e.apply(this,n):function(){for(var a=arguments.length,l=new Array(a),h=0;h<a;h++)l[h]=arguments[h];return t.apply(s,[].concat(n,l))}}}function nr(e){return{}.toString.call(e).includes("Object")}function Qu(e){return!Object.keys(e).length}function di(e){return typeof e=="function"}function ef(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function tf(e,t){return nr(t)||qt("changeType"),Object.keys(t).some(function(s){return!ef(e,s)})&&qt("changeField"),t}function sf(e){di(e)||qt("selectorType")}function rf(e){di(e)||nr(e)||qt("handlerType"),nr(e)&&Object.values(e).some(function(t){return!di(t)})&&qt("handlersType")}function nf(e){e||qt("initialIsRequired"),nr(e)||qt("initialType"),Qu(e)&&qt("initialContent")}function of(e,t){throw new Error(e[t]||e.default)}var af={initialIsRequired:"initial state is required",initialType:"initial state should be an object",initialContent:"initial state shouldn't be an empty object",handlerType:"handler should be an object or a function",handlersType:"all handlers should be a functions",selectorType:"selector should be a function",changeType:"provided value of changes should be an object",changeField:'it seams you want to change a field in the state which is not specified in the "initial" state',default:"an unknown error accured in `state-local` package"},qt=Zs(of)(af),Li={changes:tf,selector:sf,handler:rf,initial:nf};function lf(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Li.initial(e),Li.handler(t);var s={current:e},i=Zs(df)(s,t),n=Zs(hf)(s),o=Zs(Li.changes)(e),a=Zs(cf)(s);function l(){var c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(f){return f};return Li.selector(c),c(s.current)}function h(c){Zu(i,n,o,a)(c)}return[l,h]}function cf(e,t){return di(t)?t(e.current):t}function hf(e,t){return e.current=pa(pa({},e.current),t),t}function df(e,t,s){return di(t)?t(e.current):Object.keys(s).forEach(function(i){var n;return(n=t[i])===null||n===void 0?void 0:n.call(t,e.current[i])}),s}var uf={create:lf},ff={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function mf(e){return function t(){for(var s=this,i=arguments.length,n=new Array(i),o=0;o<i;o++)n[o]=arguments[o];return n.length>=e.length?e.apply(this,n):function(){for(var a=arguments.length,l=new Array(a),h=0;h<a;h++)l[h]=arguments[h];return t.apply(s,[].concat(n,l))}}}function pf(e){return{}.toString.call(e).includes("Object")}function _f(e){return e||_a("configIsRequired"),pf(e)||_a("configType"),e.urls?(gf(),{paths:{vs:e.urls.monacoBase}}):e}function gf(){console.warn(uc.deprecation)}function xf(e,t){throw new Error(e[t]||e.default)}var uc={configIsRequired:"the configuration object is required",configType:"the configuration object should be an object",default:"an unknown error accured in `@monaco-editor/loader` package",deprecation:`Deprecation warning!
164
+ You are using deprecated way of configuration.
165
+
166
+ Instead of using
167
+ monaco.config({ urls: { monacoBase: '...' } })
168
+ use
169
+ monaco.config({ paths: { vs: '...' } })
170
+
171
+ For more please check the link https://github.com/suren-atoyan/monaco-loader#config
172
+ `},_a=mf(xf)(uc),vf={config:_f},bf=function(){for(var t=arguments.length,s=new Array(t),i=0;i<t;i++)s[i]=arguments[i];return function(n){return s.reduceRight(function(o,a){return a(o)},n)}};function fc(e,t){return Object.keys(t).forEach(function(s){t[s]instanceof Object&&e[s]&&Object.assign(t[s],fc(e[s],t[s]))}),fa(fa({},e),t)}var yf={type:"cancelation",msg:"operation is manually canceled"};function Lr(e){var t=!1,s=new Promise(function(i,n){e.then(function(o){return t?n(yf):i(o)}),e.catch(n)});return s.cancel=function(){return t=!0},s}var Sf=["monaco"],wf=uf.create({config:ff,isInitialized:!1,resolve:null,reject:null,monaco:null}),mc=Vu(wf,2),xi=mc[0],vr=mc[1];function Cf(e){var t=vf.config(e),s=t.monaco,i=Ku(t,Sf);vr(function(n){return{config:fc(n.config,i),monaco:s}})}function kf(){var e=xi(function(t){var s=t.monaco,i=t.isInitialized,n=t.resolve;return{monaco:s,isInitialized:i,resolve:n}});if(!e.isInitialized){if(vr({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),Lr(Br);if(window.monaco&&window.monaco.editor)return pc(window.monaco),e.resolve(window.monaco),Lr(Br);bf(Nf,Ef)(Df)}return Lr(Br)}function Nf(e){return document.body.appendChild(e)}function jf(e){var t=document.createElement("script");return e&&(t.src=e),t}function Ef(e){var t=xi(function(i){var n=i.config,o=i.reject;return{config:n,reject:o}}),s=jf("".concat(t.config.paths.vs,"/loader.js"));return s.onload=function(){return e()},s.onerror=t.reject,s}function Df(){var e=xi(function(s){var i=s.config,n=s.resolve,o=s.reject;return{config:i,resolve:n,reject:o}}),t=window.require;t.config(e.config),t(["vs/editor/editor.main"],function(s){var i=s.m||s;pc(i),e.resolve(i)},function(s){e.reject(s)})}function pc(e){xi().monaco||vr({monaco:e})}function Rf(){return xi(function(e){var t=e.monaco;return t})}var Br=new Promise(function(e,t){return vr({resolve:e,reject:t})}),_c={config:Cf,init:kf,__getMonacoInstance:Rf},Pf={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},Tr=Pf,Mf={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},Lf=Mf;function Bf({children:e}){return Ms.createElement("div",{style:Lf.container},e)}var Tf=Bf,zf=Tf;function Af({width:e,height:t,isEditorReady:s,loading:i,_ref:n,className:o,wrapperProps:a}){return Ms.createElement("section",{style:{...Tr.wrapper,width:e,height:t},...a},!s&&Ms.createElement(zf,null,i),Ms.createElement("div",{ref:n,style:{...Tr.fullWidth,...!s&&Tr.hide},className:o}))}var Of=Af,gc=d.memo(Of);function $f(e){d.useEffect(e,[])}var xc=$f;function If(e,t,s=!0){let i=d.useRef(!0);d.useEffect(i.current||!s?()=>{i.current=!1}:e,t)}var nt=If;function li(){}function Ds(e,t,s,i){return Ff(e,i)||Hf(e,t,s,i)}function Ff(e,t){return e.editor.getModel(vc(e,t))}function Hf(e,t,s,i){return e.editor.createModel(t,s,i?vc(e,i):void 0)}function vc(e,t){return e.Uri.parse(t)}function Wf({original:e,modified:t,language:s,originalLanguage:i,modifiedLanguage:n,originalModelPath:o,modifiedModelPath:a,keepCurrentOriginalModel:l=!1,keepCurrentModifiedModel:h=!1,theme:c="light",loading:f="Loading...",options:p={},height:u="100%",width:g="100%",className:m,wrapperProps:_={},beforeMount:x=li,onMount:y=li}){let[v,j]=d.useState(!1),[k,w]=d.useState(!0),N=d.useRef(null),M=d.useRef(null),U=d.useRef(null),Y=d.useRef(y),V=d.useRef(x),$=d.useRef(!1);xc(()=>{let S=_c.init();return S.then(C=>(M.current=C)&&w(!1)).catch(C=>(C==null?void 0:C.type)!=="cancelation"&&console.error("Monaco initialization: error:",C)),()=>N.current?B():S.cancel()}),nt(()=>{if(N.current&&M.current){let S=N.current.getOriginalEditor(),C=Ds(M.current,e||"",i||s||"text",o||"");C!==S.getModel()&&S.setModel(C)}},[o],v),nt(()=>{if(N.current&&M.current){let S=N.current.getModifiedEditor(),C=Ds(M.current,t||"",n||s||"text",a||"");C!==S.getModel()&&S.setModel(C)}},[a],v),nt(()=>{let S=N.current.getModifiedEditor();S.getOption(M.current.editor.EditorOption.readOnly)?S.setValue(t||""):t!==S.getValue()&&(S.executeEdits("",[{range:S.getModel().getFullModelRange(),text:t||"",forceMoveMarkers:!0}]),S.pushUndoStop())},[t],v),nt(()=>{var S,C;(C=(S=N.current)==null?void 0:S.getModel())==null||C.original.setValue(e||"")},[e],v),nt(()=>{let{original:S,modified:C}=N.current.getModel();M.current.editor.setModelLanguage(S,i||s||"text"),M.current.editor.setModelLanguage(C,n||s||"text")},[s,i,n],v),nt(()=>{var S;(S=M.current)==null||S.editor.setTheme(c)},[c],v),nt(()=>{var S;(S=N.current)==null||S.updateOptions(p)},[p],v);let P=d.useCallback(()=>{var D;if(!M.current)return;V.current(M.current);let S=Ds(M.current,e||"",i||s||"text",o||""),C=Ds(M.current,t||"",n||s||"text",a||"");(D=N.current)==null||D.setModel({original:S,modified:C})},[s,t,n,e,i,o,a]),E=d.useCallback(()=>{var S;!$.current&&U.current&&(N.current=M.current.editor.createDiffEditor(U.current,{automaticLayout:!0,...p}),P(),(S=M.current)==null||S.editor.setTheme(c),j(!0),$.current=!0)},[p,c,P]);d.useEffect(()=>{v&&Y.current(N.current,M.current)},[v]),d.useEffect(()=>{!k&&!v&&E()},[k,v,E]);function B(){var C,D,L,Z;let S=(C=N.current)==null?void 0:C.getModel();l||((D=S==null?void 0:S.original)==null||D.dispose()),h||((L=S==null?void 0:S.modified)==null||L.dispose()),(Z=N.current)==null||Z.dispose()}return Ms.createElement(gc,{width:g,height:u,isEditorReady:v,loading:f,_ref:U,className:m,wrapperProps:_})}var Uf=Wf;d.memo(Uf);function Kf(e){let t=d.useRef();return d.useEffect(()=>{t.current=e},[e]),t.current}var qf=Kf,Bi=new Map;function Vf({defaultValue:e,defaultLanguage:t,defaultPath:s,value:i,language:n,path:o,theme:a="light",line:l,loading:h="Loading...",options:c={},overrideServices:f={},saveViewState:p=!0,keepCurrentModel:u=!1,width:g="100%",height:m="100%",className:_,wrapperProps:x={},beforeMount:y=li,onMount:v=li,onChange:j,onValidate:k=li}){let[w,N]=d.useState(!1),[M,U]=d.useState(!0),Y=d.useRef(null),V=d.useRef(null),$=d.useRef(null),P=d.useRef(v),E=d.useRef(y),B=d.useRef(),S=d.useRef(i),C=qf(o),D=d.useRef(!1),L=d.useRef(!1);xc(()=>{let q=_c.init();return q.then(J=>(Y.current=J)&&U(!1)).catch(J=>(J==null?void 0:J.type)!=="cancelation"&&console.error("Monaco initialization: error:",J)),()=>V.current?oe():q.cancel()}),nt(()=>{var J,se,de,ue;let q=Ds(Y.current,e||i||"",t||n||"",o||s||"");q!==((J=V.current)==null?void 0:J.getModel())&&(p&&Bi.set(C,(se=V.current)==null?void 0:se.saveViewState()),(de=V.current)==null||de.setModel(q),p&&((ue=V.current)==null||ue.restoreViewState(Bi.get(o))))},[o],w),nt(()=>{var q;(q=V.current)==null||q.updateOptions(c)},[c],w),nt(()=>{!V.current||i===void 0||(V.current.getOption(Y.current.editor.EditorOption.readOnly)?V.current.setValue(i):i!==V.current.getValue()&&(L.current=!0,V.current.executeEdits("",[{range:V.current.getModel().getFullModelRange(),text:i,forceMoveMarkers:!0}]),V.current.pushUndoStop(),L.current=!1))},[i],w),nt(()=>{var J,se;let q=(J=V.current)==null?void 0:J.getModel();q&&n&&((se=Y.current)==null||se.editor.setModelLanguage(q,n))},[n],w),nt(()=>{var q;l!==void 0&&((q=V.current)==null||q.revealLine(l))},[l],w),nt(()=>{var q;(q=Y.current)==null||q.editor.setTheme(a)},[a],w);let Z=d.useCallback(()=>{var q;if(!(!$.current||!Y.current)&&!D.current){E.current(Y.current);let J=o||s,se=Ds(Y.current,i||e||"",t||n||"",J||"");V.current=(q=Y.current)==null?void 0:q.editor.create($.current,{model:se,automaticLayout:!0,...c},f),p&&V.current.restoreViewState(Bi.get(J)),Y.current.editor.setTheme(a),l!==void 0&&V.current.revealLine(l),N(!0),D.current=!0}},[e,t,s,i,n,o,c,f,p,a,l]);d.useEffect(()=>{w&&P.current(V.current,Y.current)},[w]),d.useEffect(()=>{!M&&!w&&Z()},[M,w,Z]),S.current=i,d.useEffect(()=>{var q,J;w&&j&&((q=B.current)==null||q.dispose(),B.current=(J=V.current)==null?void 0:J.onDidChangeModelContent(se=>{L.current||j(V.current.getValue(),se)}))},[w,j]),d.useEffect(()=>{if(w){let q=Y.current.editor.onDidChangeMarkers(J=>{var de;let se=(de=V.current.getModel())==null?void 0:de.uri;if(se&&J.find(ue=>ue.path===se.path)){let ue=Y.current.editor.getModelMarkers({resource:se});k==null||k(ue)}});return()=>{q==null||q.dispose()}}return()=>{}},[w,k]);function oe(){var q,J;(q=B.current)==null||q.dispose(),u?p&&Bi.set(o,V.current.saveViewState()):(J=V.current.getModel())==null||J.dispose(),V.current.dispose()}return Ms.createElement(gc,{width:g,height:m,isEditorReady:w,loading:h,_ref:$,className:_,wrapperProps:x})}var Gf=Vf,Yf=d.memo(Gf),Xf=Yf;function Jf(e,t){const s=getComputedStyle(e),i=parseFloat(s.fontSize);return t*i}function Zf(e,t){const s=getComputedStyle(e.ownerDocument.body),i=parseFloat(s.fontSize);return t*i}function Qf(e){return e/100*window.innerHeight}function em(e){return e/100*window.innerWidth}function tm(e){switch(typeof e){case"number":return[e,"px"];case"string":{const t=parseFloat(e);return e.endsWith("%")?[t,"%"]:e.endsWith("px")?[t,"px"]:e.endsWith("rem")?[t,"rem"]:e.endsWith("em")?[t,"em"]:e.endsWith("vh")?[t,"vh"]:e.endsWith("vw")?[t,"vw"]:[t,"%"]}}}function Qs({groupSize:e,panelElement:t,styleProp:s}){let i;const[n,o]=tm(s);switch(o){case"%":{i=n/100*e;break}case"px":{i=n;break}case"rem":{i=Zf(t,n);break}case"em":{i=Jf(t,n);break}case"vh":{i=Qf(n);break}case"vw":{i=em(n);break}}return i}function et(e){return parseFloat(e.toFixed(3))}function zs({group:e}){const{orientation:t,panels:s}=e;return s.reduce((i,n)=>(i+=t==="horizontal"?n.element.offsetWidth:n.element.offsetHeight,i),0)}function hn(e){const{panels:t}=e,s=zs({group:e});return s===0?t.map(i=>({groupResizeBehavior:i.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:i.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:i.panelConstraints.disabled,minSize:0,maxSize:100,panelId:i.id})):t.map(i=>{const{element:n,panelConstraints:o}=i;let a=0;if(o.collapsedSize!==void 0){const f=Qs({groupSize:s,panelElement:n,styleProp:o.collapsedSize});a=et(f/s*100)}let l;if(o.defaultSize!==void 0){const f=Qs({groupSize:s,panelElement:n,styleProp:o.defaultSize});l=et(f/s*100)}let h=0;if(o.minSize!==void 0){const f=Qs({groupSize:s,panelElement:n,styleProp:o.minSize});h=et(f/s*100)}let c=100;if(o.maxSize!==void 0){const f=Qs({groupSize:s,panelElement:n,styleProp:o.maxSize});c=et(f/s*100)}return{groupResizeBehavior:o.groupResizeBehavior,collapsedSize:a,collapsible:o.collapsible===!0,defaultSize:l,disabled:o.disabled,minSize:h,maxSize:c,panelId:i.id}})}function me(e,t="Assertion error"){if(!e)throw Error(t)}function dn(e,t){return Array.from(t).sort(e==="horizontal"?sm:im)}function sm(e,t){const s=e.element.offsetLeft-t.element.offsetLeft;return s!==0?s:e.element.offsetWidth-t.element.offsetWidth}function im(e,t){const s=e.element.offsetTop-t.element.offsetTop;return s!==0?s:e.element.offsetHeight-t.element.offsetHeight}function bc(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function yc(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function rm({orientation:e,rects:t,targetRect:s}){const i={x:s.x+s.width/2,y:s.y+s.height/2};let n,o=Number.MAX_VALUE;for(const a of t){const{x:l,y:h}=yc(i,a),c=e==="horizontal"?l:h;c<o&&(o=c,n=a)}return me(n,"No rect found"),n}let Ti;function nm(){return Ti===void 0&&(typeof matchMedia=="function"?Ti=!!matchMedia("(pointer:coarse)").matches:Ti=!1),Ti}function Sc(e){const{element:t,orientation:s,panels:i,separators:n}=e,o=dn(s,Array.from(t.children).filter(bc).map(m=>({element:m}))).map(({element:m})=>m),a=[];let l=!1,h=!1,c=-1,f=-1,p=0,u,g=[];{let m=-1;for(const _ of o)_.hasAttribute("data-panel")&&(m++,_.ariaDisabled===null&&(p++,c===-1&&(c=m),f=m))}if(p>1){let m=-1;for(const _ of o)if(_.hasAttribute("data-panel")){m++;const x=i.find(y=>y.element===_);if(x){if(u){const y=u.element.getBoundingClientRect(),v=_.getBoundingClientRect();let j;if(h){const k=s==="horizontal"?new DOMRect(y.right,y.top,0,y.height):new DOMRect(y.left,y.bottom,y.width,0),w=s==="horizontal"?new DOMRect(v.left,v.top,0,v.height):new DOMRect(v.left,v.top,v.width,0);switch(g.length){case 0:{j=[k,w];break}case 1:{const N=g[0],M=rm({orientation:s,rects:[y,v],targetRect:N.element.getBoundingClientRect()});j=[N,M===y?w:k];break}default:{j=g;break}}}else g.length?j=g:j=[s==="horizontal"?new DOMRect(y.right,v.top,v.left-y.right,v.height):new DOMRect(v.left,y.bottom,v.width,v.top-y.bottom)];for(const k of j){let w="width"in k?k:k.element.getBoundingClientRect();const N=nm()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(w.width<N){const U=N-w.width;w=new DOMRect(w.x-U/2,w.y,w.width+U,w.height)}if(w.height<N){const U=N-w.height;w=new DOMRect(w.x,w.y-U/2,w.width,w.height+U)}const M=m<=c||m>f;!l&&!M&&a.push({group:e,groupSize:zs({group:e}),panels:[u,x],separator:"width"in k?void 0:k,rect:w}),l=!1}}h=!1,u=x,g=[]}}else if(_.hasAttribute("data-separator")){_.ariaDisabled!==null&&(l=!0);const x=n.find(y=>y.element===_);x?g.push(x):(u=void 0,g=[])}else h=!0}return a}var Ht,Wl;let wc=(Wl=class{constructor(){oa(this,Ht,{})}addListener(t,s){const i=Us(this,Ht)[t];return i===void 0?Us(this,Ht)[t]=[s]:i.includes(s)||i.push(s),()=>{this.removeListener(t,s)}}emit(t,s){const i=Us(this,Ht)[t];if(i!==void 0)if(i.length===1)i[0].call(null,s);else{let n=!1,o=null;const a=Array.from(i);for(let l=0;l<a.length;l++){const h=a[l];try{h.call(null,s)}catch(c){o===null&&(n=!0,o=c)}}if(n)throw o}}removeAllListeners(){aa(this,Ht,{})}removeListener(t,s){const i=Us(this,Ht)[t];if(i!==void 0){const n=i.indexOf(s);n>=0&&i.splice(n,1)}}},Ht=new WeakMap,Wl),xt=new Map;const Cc=new wc;function om(e){xt=new Map(xt),xt.delete(e)}function ga(e,t){for(const[s]of xt)if(s.id===e)return s}function Vt(e,t){for(const[s,i]of xt)if(s.id===e)return i;if(t)throw Error(`Could not find data for Group with id ${e}`)}function gs(){return xt}function lo(e,t){return Cc.addListener("groupChange",s=>{s.group.id===e&&t(s)})}function Rt(e,t){const s=xt.get(e);xt=new Map(xt),xt.set(e,t),Cc.emit("groupChange",{group:e,prev:s,next:t})}function am(e,t,s){let i,n={x:1/0,y:1/0};for(const o of t){const a=yc(s,o.rect);switch(e){case"horizontal":{a.x<=n.x&&(i=o,n=a);break}case"vertical":{a.y<=n.y&&(i=o,n=a);break}}}return i?{distance:n,hitRegion:i}:void 0}function lm(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function cm(e,t){if(e===t)throw new Error("Cannot compare node with itself");const s={a:ba(e),b:ba(t)};let i;for(;s.a.at(-1)===s.b.at(-1);)i=s.a.pop(),s.b.pop();me(i,"Stacking order can only be calculated for elements with a common ancestor");const n={a:va(xa(s.a)),b:va(xa(s.b))};if(n.a===n.b){const o=i.childNodes,a={a:s.a.at(-1),b:s.b.at(-1)};let l=o.length;for(;l--;){const h=o[l];if(h===a.a)return 1;if(h===a.b)return-1}}return Math.sign(n.a-n.b)}const hm=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function dm(e){const t=getComputedStyle(kc(e)??e).display;return t==="flex"||t==="inline-flex"}function um(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||dm(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||hm.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function xa(e){let t=e.length;for(;t--;){const s=e[t];if(me(s,"Missing node"),um(s))return s}return null}function va(e){return e&&Number(getComputedStyle(e).zIndex)||0}function ba(e){const t=[];for(;e;)t.push(e),e=kc(e);return t}function kc(e){const{parentNode:t}=e;return lm(t)?t.host:t}function fm(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function mm({groupElement:e,hitRegion:t,pointerEventTarget:s}){if(!bc(s)||s.contains(e)||e.contains(s))return!0;if(cm(s,e)>0){let i=s;for(;i;){if(i.contains(e))return!0;if(fm(i.getBoundingClientRect(),t))return!1;i=i.parentElement}}return!0}function co(e,t){const s=[];return t.forEach((i,n)=>{if(n.disabled)return;const o=Sc(n),a=am(n.orientation,o,{x:e.clientX,y:e.clientY});a&&a.distance.x<=0&&a.distance.y<=0&&mm({groupElement:n.element,hitRegion:a.hitRegion.rect,pointerEventTarget:e.target})&&s.push(a.hitRegion)}),s}function pm(e,t){if(e.length!==t.length)return!1;for(let s=0;s<e.length;s++)if(e[s]!=t[s])return!1;return!0}function Ve(e,t,s=0){return Math.abs(et(e)-et(t))<=s}function _t(e,t){return Ve(e,t)?0:e>t?1:-1}function Rs({overrideDisabledPanels:e,panelConstraints:t,prevSize:s,size:i}){const{collapsedSize:n=0,collapsible:o,disabled:a,maxSize:l=100,minSize:h=0}=t;if(a&&!e)return s;if(_t(i,h)<0)if(o){const c=(n+h)/2;_t(i,c)<0?i=n:i=h}else i=h;return i=Math.min(l,i),i=et(i),i}function ui({delta:e,initialLayout:t,panelConstraints:s,pivotIndices:i,prevLayout:n,trigger:o}){if(Ve(e,0))return t;const a=o==="imperative-api",l=Object.values(t),h=Object.values(n),c=[...l],[f,p]=i;me(f!=null,"Invalid first pivot index"),me(p!=null,"Invalid second pivot index");let u=0;switch(o){case"keyboard":{{const _=e<0?p:f,x=s[_];me(x,`Panel constraints not found for index ${_}`);const{collapsedSize:y=0,collapsible:v,minSize:j=0}=x;if(v){const k=l[_];if(me(k!=null,`Previous layout not found for panel index ${_}`),Ve(k,y)){const w=j-k;_t(w,Math.abs(e))>0&&(e=e<0?0-w:w)}}}{const _=e<0?f:p,x=s[_];me(x,`No panel constraints found for index ${_}`);const{collapsedSize:y=0,collapsible:v,minSize:j=0}=x;if(v){const k=l[_];if(me(k!=null,`Previous layout not found for panel index ${_}`),Ve(k,j)){const w=k-y;_t(w,Math.abs(e))>0&&(e=e<0?0-w:w)}}}break}default:{const _=e<0?p:f,x=s[_];me(x,`Panel constraints not found for index ${_}`);const y=l[_],{collapsible:v,collapsedSize:j,minSize:k}=x;if(v&&_t(y,k)<0)if(e>0){const w=k-j,N=w/2,M=y+e;_t(M,k)<0&&(e=_t(e,N)<=0?0:w)}else{const w=k-j,N=100-w/2,M=y-e;_t(M,k)<0&&(e=_t(100+e,N)>0?0:-w)}break}}{const _=e<0?1:-1;let x=e<0?p:f,y=0;for(;;){const j=l[x];me(j!=null,`Previous layout not found for panel index ${x}`);const k=Rs({overrideDisabledPanels:a,panelConstraints:s[x],prevSize:j,size:100})-j;if(y+=k,x+=_,x<0||x>=s.length)break}const v=Math.min(Math.abs(e),Math.abs(y));e=e<0?0-v:v}{let _=e<0?f:p;for(;_>=0&&_<s.length;){const x=Math.abs(e)-Math.abs(u),y=l[_];me(y!=null,`Previous layout not found for panel index ${_}`);const v=y-x,j=Rs({overrideDisabledPanels:a,panelConstraints:s[_],prevSize:y,size:v});if(!Ve(y,j)&&(u+=y-j,c[_]=j,u.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?_--:_++}}if(pm(h,c))return n;{const _=e<0?p:f,x=l[_];me(x!=null,`Previous layout not found for panel index ${_}`);const y=x+u,v=Rs({overrideDisabledPanels:a,panelConstraints:s[_],prevSize:x,size:y});if(c[_]=v,!Ve(v,y)){let j=y-v,k=e<0?p:f;for(;k>=0&&k<s.length;){const w=c[k];me(w!=null,`Previous layout not found for panel index ${k}`);const N=w+j,M=Rs({overrideDisabledPanels:a,panelConstraints:s[k],prevSize:w,size:N});if(Ve(w,M)||(j-=M-w,c[k]=M),Ve(j,0))break;e>0?k--:k++}}}const g=Object.values(c).reduce((_,x)=>x+_,0);if(!Ve(g,100,.1))return n;const m=Object.keys(n);return c.reduce((_,x,y)=>(_[m[y]]=x,_),{})}function cs(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const s in e)if(t[s]===void 0||_t(e[s],t[s])!==0)return!1;return!0}function hs({layout:e,panelConstraints:t}){const s=Object.values(e),i=[...s],n=i.reduce((l,h)=>l+h,0);if(i.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${i.map(l=>`${l}%`).join(", ")}`);if(!Ve(n,100)&&i.length>0)for(let l=0;l<t.length;l++){const h=i[l];me(h!=null,`No layout data found for index ${l}`);const c=100/n*h;i[l]=c}let o=0;for(let l=0;l<t.length;l++){const h=s[l];me(h!=null,`No layout data found for index ${l}`);const c=i[l];me(c!=null,`No layout data found for index ${l}`);const f=Rs({overrideDisabledPanels:!0,panelConstraints:t[l],prevSize:h,size:c});c!=f&&(o+=c-f,i[l]=f)}if(!Ve(o,0))for(let l=0;l<t.length;l++){const h=i[l];me(h!=null,`No layout data found for index ${l}`);const c=h+o,f=Rs({overrideDisabledPanels:!0,panelConstraints:t[l],prevSize:h,size:c});if(h!==f&&(o-=f-h,i[l]=f,Ve(o,0)))break}const a=Object.keys(e);return i.reduce((l,h,c)=>(l[a[c]]=h,l),{})}function Nc({groupId:e,panelId:t}){const s=()=>{const l=gs();for(const[h,{defaultLayoutDeferred:c,derivedPanelConstraints:f,layout:p,groupSize:u,separatorToPanels:g}]of l)if(h.id===e)return{defaultLayoutDeferred:c,derivedPanelConstraints:f,group:h,groupSize:u,layout:p,separatorToPanels:g};throw Error(`Group ${e} not found`)},i=()=>{const l=s().derivedPanelConstraints.find(h=>h.panelId===t);if(l!==void 0)return l;throw Error(`Panel constraints not found for Panel ${t}`)},n=()=>{const l=s().group.panels.find(h=>h.id===t);if(l!==void 0)return l;throw Error(`Layout not found for Panel ${t}`)},o=()=>{const l=s().layout[t];if(l!==void 0)return l;throw Error(`Layout not found for Panel ${t}`)},a=l=>{const h=o();if(l===h)return;const{defaultLayoutDeferred:c,derivedPanelConstraints:f,group:p,groupSize:u,layout:g,separatorToPanels:m}=s(),_=p.panels.findIndex(j=>j.id===t),x=_===p.panels.length-1,y=ui({delta:x?h-l:l-h,initialLayout:g,panelConstraints:f,pivotIndices:x?[_-1,_]:[_,_+1],prevLayout:g,trigger:"imperative-api"}),v=hs({layout:y,panelConstraints:f});cs(g,v)||Rt(p,{defaultLayoutDeferred:c,derivedPanelConstraints:f,groupSize:u,layout:v,separatorToPanels:m})};return{collapse:()=>{const{collapsible:l,collapsedSize:h}=i(),{mutableValues:c}=n(),f=o();l&&f!==h&&(c.expandToSize=f,a(h))},expand:()=>{const{collapsible:l,collapsedSize:h,minSize:c}=i(),{mutableValues:f}=n(),p=o();if(l&&p===h){let u=f.expandToSize??c;u===0&&(u=1),a(u)}},getSize:()=>{const{group:l}=s(),h=o(),{element:c}=n(),f=l.orientation==="horizontal"?c.offsetWidth:c.offsetHeight;return{asPercentage:h,inPixels:f}},isCollapsed:()=>{const{collapsible:l,collapsedSize:h}=i(),c=o();return l&&Ve(h,c)},resize:l=>{const{group:h}=s(),{element:c}=n(),f=zs({group:h}),p=Qs({groupSize:f,panelElement:c,styleProp:l}),u=et(p/f*100);a(u)}}}function ya(e){if(e.defaultPrevented)return;const t=gs();co(e,t).forEach(s=>{if(s.separator){const i=s.panels.find(n=>n.panelConstraints.defaultSize!==void 0);if(i){const n=i.panelConstraints.defaultSize,o=Nc({groupId:s.group.id,panelId:i.id});o&&n!==void 0&&(o.resize(n),e.preventDefault())}}})}function Ui(e){const t=gs();for(const[s]of t)if(s.separators.some(i=>i.element===e))return s;throw Error("Could not find parent Group for separator element")}function jc({groupId:e}){const t=()=>{const s=gs();for(const[i,n]of s)if(i.id===e)return{group:i,...n};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){const{defaultLayoutDeferred:s,layout:i}=t();return s?{}:i},setLayout(s){const{defaultLayoutDeferred:i,derivedPanelConstraints:n,group:o,groupSize:a,layout:l,separatorToPanels:h}=t(),c=hs({layout:s,panelConstraints:n});return i?l:(cs(l,c)||Rt(o,{defaultLayoutDeferred:i,derivedPanelConstraints:n,groupSize:a,layout:c,separatorToPanels:h}),c)}}}function Zt(e,t){const s=Ui(e),i=Vt(s.id,!0),n=s.separators.find(f=>f.element===e);me(n,"Matching separator not found");const o=i.separatorToPanels.get(n);me(o,"Matching panels not found");const a=o.map(f=>s.panels.indexOf(f)),l=jc({groupId:s.id}).getLayout(),h=ui({delta:t,initialLayout:l,panelConstraints:i.derivedPanelConstraints,pivotIndices:a,prevLayout:l,trigger:"keyboard"}),c=hs({layout:h,panelConstraints:i.derivedPanelConstraints});cs(l,c)||Rt(s,{defaultLayoutDeferred:i.defaultLayoutDeferred,derivedPanelConstraints:i.derivedPanelConstraints,groupSize:i.groupSize,layout:c,separatorToPanels:i.separatorToPanels})}function Sa(e){if(e.defaultPrevented)return;const t=e.currentTarget,s=Ui(t);if(!s.disabled)switch(e.key){case"ArrowDown":{e.preventDefault(),s.orientation==="vertical"&&Zt(t,5);break}case"ArrowLeft":{e.preventDefault(),s.orientation==="horizontal"&&Zt(t,-5);break}case"ArrowRight":{e.preventDefault(),s.orientation==="horizontal"&&Zt(t,5);break}case"ArrowUp":{e.preventDefault(),s.orientation==="vertical"&&Zt(t,-5);break}case"End":{e.preventDefault(),Zt(t,100);break}case"Enter":{e.preventDefault();const i=Ui(t),n=Vt(i.id,!0),{derivedPanelConstraints:o,layout:a,separatorToPanels:l}=n,h=i.separators.find(u=>u.element===t);me(h,"Matching separator not found");const c=l.get(h);me(c,"Matching panels not found");const f=c[0],p=o.find(u=>u.panelId===f.id);if(me(p,"Panel metadata not found"),p.collapsible){const u=a[f.id],g=p.collapsedSize===u?i.mutableState.expandedPanelSizes[f.id]??p.minSize:p.collapsedSize;Zt(t,g-u)}break}case"F6":{e.preventDefault();const i=Ui(t).separators.map(a=>a.element),n=Array.from(i).findIndex(a=>a===e.currentTarget);me(n!==null,"Index not found");const o=e.shiftKey?n>0?n-1:i.length-1:n+1<i.length?n+1:0;i[o].focus({preventScroll:!0});break}case"Home":{e.preventDefault(),Zt(t,-100);break}}}let Bs={cursorFlags:0,state:"inactive"};const ho=new wc;function ds(){return Bs}function _m(e){return ho.addListener("change",e)}function gm(e){const t=Bs,s={...Bs};s.cursorFlags=e,Bs=s,ho.emit("change",{prev:t,next:s})}function Ts(e){const t=Bs;Bs=e,ho.emit("change",{prev:t,next:e})}function wa(e){if(e.defaultPrevented||e.pointerType==="mouse"&&e.button>0)return;const t=gs(),s=co(e,t),i=new Map;let n=!1;s.forEach(o=>{o.separator&&(n||(n=!0,o.separator.element.focus({preventScroll:!0})));const a=t.get(o.group);a&&i.set(o.group,a.layout)}),Ts({cursorFlags:0,hitRegions:s,initialLayoutMap:i,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:"active"}),s.length&&e.preventDefault()}const xm=e=>e,zr=()=>{},Ec=1,Dc=2,Rc=4,Pc=8,Ca=3,ka=12;let zi;function Na(){return zi===void 0&&(zi=!1,typeof window<"u"&&(window.navigator.userAgent.includes("Chrome")||window.navigator.userAgent.includes("Firefox"))&&(zi=!0)),zi}function vm({cursorFlags:e,groups:t,state:s}){let i=0,n=0;switch(s){case"active":case"hover":t.forEach(o=>{if(!o.mutableState.disableCursor)switch(o.orientation){case"horizontal":{i++;break}case"vertical":{n++;break}}})}if(!(i===0&&n===0)){switch(s){case"active":{if(e&&Na()){const o=(e&Ec)!==0,a=(e&Dc)!==0,l=(e&Rc)!==0,h=(e&Pc)!==0;if(o)return l?"se-resize":h?"ne-resize":"e-resize";if(a)return l?"sw-resize":h?"nw-resize":"w-resize";if(l)return"s-resize";if(h)return"n-resize"}break}}return Na()?i>0&&n>0?"move":i>0?"ew-resize":"ns-resize":i>0&&n>0?"grab":i>0?"col-resize":"row-resize"}}const ja=new WeakMap;function uo(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:s}=ja.get(e)??{};s===void 0&&(s=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&e.adoptedStyleSheets.push(s));const i=ds();switch(i.state){case"active":case"hover":{const n=vm({cursorFlags:i.cursorFlags,groups:i.hitRegions.map(a=>a.group),state:i.state}),o=`*, *:hover {cursor: ${n} !important; }`;if(t===o)return;t=o,n?s.cssRules.length===0?s.insertRule(o):s.replaceSync(o):s.cssRules.length===1&&s.deleteRule(0);break}case"inactive":{t=void 0,s.cssRules.length===1&&s.deleteRule(0);break}}ja.set(e,{prevStyle:t,styleSheet:s})}function Mc({document:e,event:t,hitRegions:s,initialLayoutMap:i,mountedGroups:n,pointerDownAtPoint:o,prevCursorFlags:a}){let l=0;s.forEach(c=>{const{group:f,groupSize:p}=c,{orientation:u,panels:g}=f,{disableCursor:m}=f.mutableState;let _=0;o?u==="horizontal"?_=(t.clientX-o.x)/p*100:_=(t.clientY-o.y)/p*100:u==="horizontal"?_=t.clientX<0?-100:100:_=t.clientY<0?-100:100;const x=i.get(f),y=n.get(f);if(!x||!y)return;const{defaultLayoutDeferred:v,derivedPanelConstraints:j,groupSize:k,layout:w,separatorToPanels:N}=y;if(j&&w&&N){const M=ui({delta:_,initialLayout:x,panelConstraints:j,pivotIndices:c.panels.map(U=>g.indexOf(U)),prevLayout:w,trigger:"mouse-or-touch"});if(cs(M,w)){if(_!==0&&!m)switch(u){case"horizontal":{l|=_<0?Ec:Dc;break}case"vertical":{l|=_<0?Rc:Pc;break}}}else Rt(c.group,{defaultLayoutDeferred:v,derivedPanelConstraints:j,groupSize:k,layout:M,separatorToPanels:N})}});let h=0;t.movementX===0?h|=a&Ca:h|=l&Ca,t.movementY===0?h|=a&ka:h|=l&ka,gm(h),uo(e)}function Ea(e){const t=gs(),s=ds();switch(s.state){case"active":Mc({document:e.currentTarget,event:e,hitRegions:s.hitRegions,initialLayoutMap:s.initialLayoutMap,mountedGroups:t,prevCursorFlags:s.cursorFlags})}}function Da(e){if(e.defaultPrevented)return;const t=ds(),s=gs();switch(t.state){case"active":{if(e.buttons===0){Ts({cursorFlags:0,state:"inactive"}),t.hitRegions.forEach(i=>{const n=Vt(i.group.id,!0);Rt(i.group,n)});return}Mc({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:s,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break}default:{const i=co(e,s);i.length===0?t.state!=="inactive"&&Ts({cursorFlags:0,state:"inactive"}):Ts({cursorFlags:0,hitRegions:i,state:"hover"}),uo(e.currentTarget);break}}}function Ra(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(ds().state){case"hover":Ts({cursorFlags:0,state:"inactive"})}}function Pa(e){if(e.defaultPrevented||e.pointerType==="mouse"&&e.button>0)return;const t=ds();switch(t.state){case"active":Ts({cursorFlags:0,state:"inactive"}),t.hitRegions.length>0&&(uo(e.currentTarget),t.hitRegions.forEach(s=>{const i=Vt(s.group.id,!0);Rt(s.group,i)}),e.preventDefault())}}function Ma(e){let t=0,s=0;const i={};for(const o of e)if(o.defaultSize!==void 0){t++;const a=et(o.defaultSize);s+=a,i[o.panelId]=a}else i[o.panelId]=void 0;const n=e.length-t;if(n!==0){const o=et((100-s)/n);for(const a of e)a.defaultSize===void 0&&(i[a.panelId]=o)}return i}function bm(e,t,s){if(!s[0])return;const i=e.panels.find(h=>h.element===t);if(!i||!i.onResize)return;const n=zs({group:e}),o=e.orientation==="horizontal"?i.element.offsetWidth:i.element.offsetHeight,a=i.mutableValues.prevSize,l={asPercentage:et(o/n*100),inPixels:o};i.mutableValues.prevSize=l,i.onResize(l,i.id,a)}function ym(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const s in e)if(e[s]!==t[s])return!1;return!0}function Sm({group:e,nextGroupSize:t,prevGroupSize:s,prevLayout:i}){if(s<=0||t<=0||s===t)return i;let n=0,o=0,a=!1;const l=new Map,h=[];for(const p of e.panels){const u=i[p.id]??0;switch(p.panelConstraints.groupResizeBehavior){case"preserve-pixel-size":{a=!0;const g=u/100*s,m=et(g/t*100);l.set(p.id,m),n+=m;break}case"preserve-relative-size":default:{h.push(p.id),o+=u;break}}}if(!a||h.length===0)return i;const c=100-n,f={...i};if(l.forEach((p,u)=>{f[u]=p}),o>0)for(const p of h){const u=i[p]??0;f[p]=et(u/o*c)}else{const p=et(c/h.length);for(const u of h)f[u]=p}return f}function wm(e,t){const s=e.map(n=>n.id),i=Object.keys(t);if(s.length!==i.length)return!1;for(const n of s)if(!i.includes(n))return!1;return!0}const Cs=new Map;function Cm(e){let t=!0;me(e.element.ownerDocument.defaultView,"Cannot register an unmounted Group");const s=e.element.ownerDocument.defaultView.ResizeObserver,i=new Set,n=new Set,o=new s(m=>{for(const _ of m){const{borderBoxSize:x,target:y}=_;if(y===e.element){if(t){const v=zs({group:e});if(v===0)return;const j=Vt(e.id);if(!j)return;const k=hn(e),w=j.defaultLayoutDeferred?Ma(k):j.layout,N=Sm({group:e,nextGroupSize:v,prevGroupSize:j.groupSize,prevLayout:w}),M=hs({layout:N,panelConstraints:k});if(!j.defaultLayoutDeferred&&cs(j.layout,M)&&ym(j.derivedPanelConstraints,k)&&j.groupSize===v)return;Rt(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:k,groupSize:v,layout:M,separatorToPanels:j.separatorToPanels})}}else bm(e,y,x)}});o.observe(e.element),e.panels.forEach(m=>{me(!i.has(m.id),`Panel ids must be unique; id "${m.id}" was used more than once`),i.add(m.id),m.onResize&&o.observe(m.element)});const a=zs({group:e}),l=hn(e),h=e.panels.map(({id:m})=>m).join(",");let c=e.mutableState.defaultLayout;c&&(wm(e.panels,c)||(c=void 0));const f=e.mutableState.layouts[h]??c??Ma(l),p=hs({layout:f,panelConstraints:l}),u=e.element.ownerDocument;Cs.set(u,(Cs.get(u)??0)+1);const g=new Map;return Sc(e).forEach(m=>{m.separator&&g.set(m.separator,m.panels)}),Rt(e,{defaultLayoutDeferred:a===0,derivedPanelConstraints:l,groupSize:a,layout:p,separatorToPanels:g}),e.separators.forEach(m=>{me(!n.has(m.id),`Separator ids must be unique; id "${m.id}" was used more than once`),n.add(m.id),m.element.addEventListener("keydown",Sa)}),Cs.get(u)===1&&(u.addEventListener("dblclick",ya,!0),u.addEventListener("pointerdown",wa,!0),u.addEventListener("pointerleave",Ea),u.addEventListener("pointermove",Da),u.addEventListener("pointerout",Ra),u.addEventListener("pointerup",Pa,!0)),function(){t=!1,Cs.set(u,Math.max(0,(Cs.get(u)??0)-1)),om(e),e.separators.forEach(m=>{m.element.removeEventListener("keydown",Sa)}),Cs.get(u)||(u.removeEventListener("dblclick",ya,!0),u.removeEventListener("pointerdown",wa,!0),u.removeEventListener("pointerleave",Ea),u.removeEventListener("pointermove",Da),u.removeEventListener("pointerout",Ra),u.removeEventListener("pointerup",Pa,!0)),o.disconnect()}}function km(){const[e,t]=d.useState({}),s=d.useCallback(()=>t({}),[]);return[e,s]}function fo(e){const t=d.useId();return`${e??t}`}const xs=typeof window<"u"?d.useLayoutEffect:d.useEffect;function ci(e){const t=d.useRef(e);return xs(()=>{t.current=e},[e]),d.useCallback((...s)=>{var i;return(i=t.current)==null?void 0:i.call(t,...s)},[t])}function mo(...e){return ci(t=>{e.forEach(s=>{if(s)switch(typeof s){case"function":{s(t);break}case"object":{s.current=t;break}}})})}function po(e){const t=d.useRef({...e});return xs(()=>{for(const s in e)t.current[s]=e[s]},[e]),t.current}const Lc=d.createContext(null);function Nm(e,t){const s=d.useRef({getLayout:()=>({}),setLayout:xm});d.useImperativeHandle(t,()=>s.current,[]),xs(()=>{Object.assign(s.current,jc({groupId:e}))})}function un({children:e,className:t,defaultLayout:s,disableCursor:i,disabled:n,elementRef:o,groupRef:a,id:l,onLayoutChange:h,onLayoutChanged:c,orientation:f="horizontal",resizeTargetMinimumSize:p={coarse:20,fine:10},style:u,...g}){const m=d.useRef({onLayoutChange:{},onLayoutChanged:{}}),_=ci($=>{cs(m.current.onLayoutChange,$)||(m.current.onLayoutChange=$,h==null||h($))}),x=ci($=>{cs(m.current.onLayoutChanged,$)||(m.current.onLayoutChanged=$,c==null||c($))}),y=fo(l),v=d.useRef(null),[j,k]=km(),w=d.useRef({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:p,separators:[]}),N=mo(v,o);Nm(y,a);const M=ci(($,P)=>{const E=ds(),B=ga($),S=Vt($);if(S){let C=!1;switch(E.state){case"active":{C=E.hitRegions.some(D=>D.group===B);break}}return{flexGrow:S.layout[P]??1,pointerEvents:C?"none":void 0}}return{flexGrow:(s==null?void 0:s[P])??1}}),U=po({defaultLayout:s,disableCursor:i}),Y=d.useMemo(()=>({get disableCursor(){return!!U.disableCursor},getPanelStyles:M,id:y,orientation:f,registerPanel:$=>{const P=w.current;return P.panels=dn(f,[...P.panels,$]),k(),()=>{P.panels=P.panels.filter(E=>E!==$),k()}},registerSeparator:$=>{const P=w.current;return P.separators=dn(f,[...P.separators,$]),k(),()=>{P.separators=P.separators.filter(E=>E!==$),k()}},togglePanelDisabled:($,P)=>{const E=w.current.panels.find(C=>C.id===$);E&&(E.panelConstraints.disabled=P);const B=ga(y),S=Vt(y);B&&S&&Rt(B,{...S,derivedPanelConstraints:hn(B)})},toggleSeparatorDisabled:($,P)=>{const E=w.current.separators.find(B=>B.id===$);E&&(E.disabled=P)}}),[M,y,k,f,U]),V=d.useRef(null);return xs(()=>{const $=v.current;if($===null)return;const P=w.current;let E;if(U.defaultLayout!==void 0&&Object.keys(U.defaultLayout).length===P.panels.length){E={};for(const oe of P.panels){const q=U.defaultLayout[oe.id];q!==void 0&&(E[oe.id]=q)}}const B={disabled:!!n,element:$,id:y,mutableState:{defaultLayout:E,disableCursor:!!U.disableCursor,expandedPanelSizes:w.current.lastExpandedPanelSizes,layouts:w.current.layouts},orientation:f,panels:P.panels,resizeTargetMinimumSize:P.resizeTargetMinimumSize,separators:P.separators};V.current=B;const S=Cm(B),{defaultLayoutDeferred:C,derivedPanelConstraints:D,layout:L}=Vt(B.id,!0);!C&&D.length>0&&(_(L),x(L));const Z=lo(y,oe=>{const{defaultLayoutDeferred:q,derivedPanelConstraints:J,layout:se}=oe.next;if(q||J.length===0)return;const de=B.panels.map(({id:ce})=>ce).join(",");B.mutableState.layouts[de]=se,J.forEach(ce=>{if(ce.collapsible){const{layout:ge}=oe.prev??{};if(ge){const Fe=Ve(ce.collapsedSize,se[ce.panelId]),z=Ve(ce.collapsedSize,ge[ce.panelId]);Fe&&!z&&(B.mutableState.expandedPanelSizes[ce.panelId]=ge[ce.panelId])}}});const ue=ds().state!=="active";_(se),ue&&x(se)});return()=>{V.current=null,S(),Z()}},[n,y,x,_,f,j,U]),d.useEffect(()=>{const $=V.current;$&&($.mutableState.defaultLayout=s,$.mutableState.disableCursor=!!i)}),r.jsx(Lc.Provider,{value:Y,children:r.jsx("div",{...g,className:t,"data-group":!0,"data-testid":y,id:y,ref:N,style:{height:"100%",width:"100%",overflow:"hidden",...u,display:"flex",flexDirection:f==="horizontal"?"row":"column",flexWrap:"nowrap",touchAction:f==="horizontal"?"pan-y":"pan-x"},children:e})})}un.displayName="Group";function _o(){const e=d.useContext(Lc);return me(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function jm(e,t){const{id:s}=_o(),i=d.useRef({collapse:zr,expand:zr,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:zr});d.useImperativeHandle(t,()=>i.current,[]),xs(()=>{Object.assign(i.current,Nc({groupId:s,panelId:e}))})}function ei({children:e,className:t,collapsedSize:s="0%",collapsible:i=!1,defaultSize:n,disabled:o,elementRef:a,groupResizeBehavior:l="preserve-relative-size",id:h,maxSize:c="100%",minSize:f="0%",onResize:p,panelRef:u,style:g,...m}){const _=!!h,x=fo(h),y=po({disabled:o}),v=d.useRef(null),j=mo(v,a),{getPanelStyles:k,id:w,orientation:N,registerPanel:M,togglePanelDisabled:U}=_o(),Y=p!==null,V=ci((P,E,B)=>{p==null||p(P,h,B)});xs(()=>{const P=v.current;if(P!==null){const E={element:P,id:x,idIsStable:_,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:Y?V:void 0,panelConstraints:{groupResizeBehavior:l,collapsedSize:s,collapsible:i,defaultSize:n,disabled:y.disabled,maxSize:c,minSize:f}};return M(E)}},[l,s,i,n,Y,x,_,c,f,V,M,y]),d.useEffect(()=>{U(x,!!o)},[o,x,U]),jm(x,u);const $=d.useSyncExternalStore(P=>lo(w,P),()=>JSON.stringify(k(w,x)),()=>JSON.stringify(k(w,x)));return r.jsx("div",{...m,"aria-disabled":o||void 0,"data-panel":!0,"data-testid":x,id:x,ref:j,style:{...Em,display:"flex",flexBasis:0,flexShrink:1,overflow:"visible",...JSON.parse($)},children:r.jsx("div",{className:t,style:{maxHeight:"100%",maxWidth:"100%",flexGrow:1,overflow:"auto",...g,touchAction:N==="horizontal"?"pan-y":"pan-x"},children:e})})}ei.displayName="Panel";const Em={minHeight:0,maxHeight:"100%",height:"auto",minWidth:0,maxWidth:"100%",width:"auto",border:"none",borderWidth:0,padding:0,margin:0};function Dm({layout:e,panelConstraints:t,panelId:s,panelIndex:i}){let n,o;const a=e[s],l=t.find(h=>h.panelId===s);if(l){const h=l.maxSize,c=l.collapsible?l.collapsedSize:l.minSize,f=[i,i+1];o=hs({layout:ui({delta:c-a,initialLayout:e,panelConstraints:t,pivotIndices:f,prevLayout:e}),panelConstraints:t})[s],n=hs({layout:ui({delta:h-a,initialLayout:e,panelConstraints:t,pivotIndices:f,prevLayout:e}),panelConstraints:t})[s]}return{valueControls:s,valueMax:n,valueMin:o,valueNow:a}}function fn({children:e,className:t,disabled:s,elementRef:i,id:n,style:o,...a}){const l=fo(n),h=po({disabled:s}),[c,f]=d.useState({}),[p,u]=d.useState("inactive"),g=d.useRef(null),m=mo(g,i),{disableCursor:_,id:x,orientation:y,registerSeparator:v,toggleSeparatorDisabled:j}=_o(),k=y==="horizontal"?"vertical":"horizontal";xs(()=>{const N=g.current;if(N!==null){const M={disabled:h.disabled,element:N,id:l},U=v(M),Y=_m($=>{u($.next.state!=="inactive"&&$.next.hitRegions.some(P=>P.separator===M)?$.next.state:"inactive")}),V=lo(x,$=>{const{derivedPanelConstraints:P,layout:E,separatorToPanels:B}=$.next,S=B.get(M);if(S){const C=S[0],D=S.indexOf(C);f(Dm({layout:E,panelConstraints:P,panelId:C.id,panelIndex:D}))}});return()=>{Y(),V(),U()}}},[x,l,v,h]),d.useEffect(()=>{j(l,!!s)},[s,l,j]);let w;return s&&!_&&(w="not-allowed"),r.jsx("div",{...a,"aria-controls":c.valueControls,"aria-disabled":s||void 0,"aria-orientation":k,"aria-valuemax":c.valueMax,"aria-valuemin":c.valueMin,"aria-valuenow":c.valueNow,children:e,className:t,"data-separator":s?"disabled":p,"data-testid":l,id:l,ref:m,role:"separator",style:{flexBasis:"auto",cursor:w,...o,flexGrow:0,flexShrink:0,touchAction:"none"},tabIndex:s?void 0:0})}fn.displayName="Separator";const Rm={ghost:"hover:bg-[#F8F4F0] text-[#36342E]",subtle:"hover:bg-[#ECEAE3] text-[#6B6960]"},Pm={sm:"w-7 h-7",md:"w-8 h-8"},Mm={sm:14,md:16};function At({icon:e,label:t,size:s="md",variant:i="ghost",onClick:n,className:o="",disabled:a=!1,title:l}){return r.jsx("button",{type:"button","aria-label":t,title:l??t,disabled:a,onClick:n,className:["inline-flex items-center justify-center rounded-btn transition-colors",Rm[i],Pm[s],a?"opacity-40 cursor-not-allowed":"",o].filter(Boolean).join(" "),children:r.jsx(e,{size:Mm[s]})})}function Lm({x:e,y:t,items:s,onClose:i}){const[n,o]=d.useState(0),a=d.useRef(null),l=d.useRef([]);d.useEffect(()=>{var c;(c=l.current[0])==null||c.focus()},[]),d.useEffect(()=>{const c=f=>{a.current&&!a.current.contains(f.target)&&i()};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[i]);const h=d.useCallback(c=>{var f,p;switch(c.key){case"Escape":c.preventDefault(),i();break;case"ArrowDown":c.preventDefault(),o(u=>{var m;const g=(u+1)%s.length;return(m=l.current[g])==null||m.focus(),g});break;case"ArrowUp":c.preventDefault(),o(u=>{var m;const g=(u-1+s.length)%s.length;return(m=l.current[g])==null||m.focus(),g});break;case"Home":c.preventDefault(),o(0),(f=l.current[0])==null||f.focus();break;case"End":c.preventDefault(),o(s.length-1),(p=l.current[s.length-1])==null||p.focus();break}},[s.length,i]);return r.jsx("div",{ref:a,role:"menu",className:"bg-card border border-border rounded-card shadow-card-hover py-1 min-w-[160px]",style:{position:"fixed",left:e,top:t,zIndex:100},onKeyDown:h,children:s.map((c,f)=>{const p=c.icon,u=c.variant==="danger";return r.jsxs("button",{ref:g=>{l.current[f]=g},role:"menuitem",tabIndex:n===f?0:-1,onClick:()=>{c.onClick(),i()},className:["flex items-center gap-2 w-full text-left px-3 py-2 text-sm transition-colors",u?"text-danger hover:bg-danger/10":"text-ink hover:bg-hover"].join(" "),children:[r.jsx(p,{size:14}),c.label]},c.label)})})}/**
173
+ * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
174
+ * @license MIT
175
+ *
176
+ * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
177
+ * @license MIT
178
+ *
179
+ * Originally forked from (with the author's permission):
180
+ * Fabrice Bellard's javascript vt100 for jslinux:
181
+ * http://bellard.org/jslinux/
182
+ * Copyright (c) 2011 Fabrice Bellard
183
+ */var Bc=Object.defineProperty,Bm=Object.getOwnPropertyDescriptor,Tm=(e,t)=>{for(var s in t)Bc(e,s,{get:t[s],enumerable:!0})},Ce=(e,t,s,i)=>{for(var n=i>1?void 0:i?Bm(t,s):t,o=e.length-1,a;o>=0;o--)(a=e[o])&&(n=(i?a(t,s,n):a(n))||n);return i&&n&&Bc(t,s,n),n},H=(e,t)=>(s,i)=>t(s,i,e),La="Terminal input",mn={get:()=>La,set:e=>La=e},Ba="Too much output to announce, navigate to rows manually to read",pn={get:()=>Ba,set:e=>Ba=e};function zm(e){return e.replace(/\r?\n/g,"\r")}function Am(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function Om(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function $m(e,t,s,i){if(e.stopPropagation(),e.clipboardData){let n=e.clipboardData.getData("text/plain");Tc(n,t,s,i)}}function Tc(e,t,s,i){e=zm(e),e=Am(e,s.decPrivateModes.bracketedPasteMode&&i.rawOptions.ignoreBracketedPasteMode!==!0),s.triggerDataEvent(e,!0),t.value=""}function zc(e,t,s){let i=s.getBoundingClientRect(),n=e.clientX-i.left-10,o=e.clientY-i.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${n}px`,t.style.top=`${o}px`,t.style.zIndex="1000",t.focus()}function Ta(e,t,s,i,n){zc(e,t,s),n&&i.rightClickSelect(e),t.value=i.selectionText,t.select()}function Ft(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function br(e,t=0,s=e.length){let i="";for(let n=t;n<s;++n){let o=e[n];o>65535?(o-=65536,i+=String.fromCharCode((o>>10)+55296)+String.fromCharCode(o%1024+56320)):i+=String.fromCharCode(o)}return i}var Im=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let s=e.length;if(!s)return 0;let i=0,n=0;if(this._interim){let o=e.charCodeAt(n++);56320<=o&&o<=57343?t[i++]=(this._interim-55296)*1024+o-56320+65536:(t[i++]=this._interim,t[i++]=o),this._interim=0}for(let o=n;o<s;++o){let a=e.charCodeAt(o);if(55296<=a&&a<=56319){if(++o>=s)return this._interim=a,i;let l=e.charCodeAt(o);56320<=l&&l<=57343?t[i++]=(a-55296)*1024+l-56320+65536:(t[i++]=a,t[i++]=l);continue}a!==65279&&(t[i++]=a)}return i}},Fm=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let s=e.length;if(!s)return 0;let i=0,n,o,a,l,h=0,c=0;if(this.interim[0]){let u=!1,g=this.interim[0];g&=(g&224)===192?31:(g&240)===224?15:7;let m=0,_;for(;(_=this.interim[++m]&63)&&m<4;)g<<=6,g|=_;let x=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,y=x-m;for(;c<y;){if(c>=s)return 0;if(_=e[c++],(_&192)!==128){c--,u=!0;break}else this.interim[m++]=_,g<<=6,g|=_&63}u||(x===2?g<128?c--:t[i++]=g:x===3?g<2048||g>=55296&&g<=57343||g===65279||(t[i++]=g):g<65536||g>1114111||(t[i++]=g)),this.interim.fill(0)}let f=s-4,p=c;for(;p<s;){for(;p<f&&!((n=e[p])&128)&&!((o=e[p+1])&128)&&!((a=e[p+2])&128)&&!((l=e[p+3])&128);)t[i++]=n,t[i++]=o,t[i++]=a,t[i++]=l,p+=4;if(n=e[p++],n<128)t[i++]=n;else if((n&224)===192){if(p>=s)return this.interim[0]=n,i;if(o=e[p++],(o&192)!==128){p--;continue}if(h=(n&31)<<6|o&63,h<128){p--;continue}t[i++]=h}else if((n&240)===224){if(p>=s)return this.interim[0]=n,i;if(o=e[p++],(o&192)!==128){p--;continue}if(p>=s)return this.interim[0]=n,this.interim[1]=o,i;if(a=e[p++],(a&192)!==128){p--;continue}if(h=(n&15)<<12|(o&63)<<6|a&63,h<2048||h>=55296&&h<=57343||h===65279)continue;t[i++]=h}else if((n&248)===240){if(p>=s)return this.interim[0]=n,i;if(o=e[p++],(o&192)!==128){p--;continue}if(p>=s)return this.interim[0]=n,this.interim[1]=o,i;if(a=e[p++],(a&192)!==128){p--;continue}if(p>=s)return this.interim[0]=n,this.interim[1]=o,this.interim[2]=a,i;if(l=e[p++],(l&192)!==128){p--;continue}if(h=(n&7)<<18|(o&63)<<12|(a&63)<<6|l&63,h<65536||h>1114111)continue;t[i++]=h}}return i}},Ac="",Wt=" ",vi=class Oc{constructor(){this.fg=0,this.bg=0,this.extended=new or}static toColorRGB(t){return[t>>>16&255,t>>>8&255,t&255]}static fromColorRGB(t){return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255}clone(){let t=new Oc;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},or=class $c{constructor(t=0,s=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=s}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new $c(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},ht=class Ic extends vi{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new or,this.combinedData=""}static fromCharData(t){let s=new Ic;return s.setFromCharData(t),s}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Ft(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let s=!1;if(t[1].length>2)s=!0;else if(t[1].length===2){let i=t[1].charCodeAt(0);if(55296<=i&&i<=56319){let n=t[1].charCodeAt(1);56320<=n&&n<=57343?this.content=(i-55296)*1024+n-56320+65536|t[2]<<22:s=!0}else s=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;s&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},za="di$target",_n="di$dependencies",Ar=new Map;function Hm(e){return e[_n]||[]}function ze(e){if(Ar.has(e))return Ar.get(e);let t=function(s,i,n){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");Wm(t,s,n)};return t._id=e,Ar.set(e,t),t}function Wm(e,t,s){t[za]===t?t[_n].push({id:e,index:s}):(t[_n]=[{id:e,index:s}],t[za]=t)}var Ge=ze("BufferService"),Fc=ze("CoreMouseService"),vs=ze("CoreService"),Um=ze("CharsetService"),go=ze("InstantiationService"),Hc=ze("LogService"),Ye=ze("OptionsService"),Wc=ze("OscLinkService"),Km=ze("UnicodeService"),bi=ze("DecorationService"),gn=class{constructor(e,t,s){this._bufferService=e,this._optionsService=t,this._oscLinkService=s}provideLinks(e,t){var f;let s=this._bufferService.buffer.lines.get(e-1);if(!s){t(void 0);return}let i=[],n=this._optionsService.rawOptions.linkHandler,o=new ht,a=s.getTrimmedLength(),l=-1,h=-1,c=!1;for(let p=0;p<a;p++)if(!(h===-1&&!s.hasContent(p))){if(s.loadCell(p,o),o.hasExtendedAttrs()&&o.extended.urlId)if(h===-1){h=p,l=o.extended.urlId;continue}else c=o.extended.urlId!==l;else h!==-1&&(c=!0);if(c||h!==-1&&p===a-1){let u=(f=this._oscLinkService.getLinkData(l))==null?void 0:f.uri;if(u){let g={start:{x:h+1,y:e},end:{x:p+(!c&&p===a-1?1:0),y:e}},m=!1;if(!(n!=null&&n.allowNonHttpProtocols))try{let _=new URL(u);["http:","https:"].includes(_.protocol)||(m=!0)}catch{m=!0}m||i.push({text:u,range:g,activate:(_,x)=>n?n.activate(_,x,g):qm(_,x),hover:(_,x)=>{var y;return(y=n==null?void 0:n.hover)==null?void 0:y.call(n,_,x,g)},leave:(_,x)=>{var y;return(y=n==null?void 0:n.leave)==null?void 0:y.call(n,_,x,g)}})}c=!1,o.hasExtendedAttrs()&&o.extended.urlId?(h=p,l=o.extended.urlId):(h=-1,l=-1)}}t(i)}};gn=Ce([H(0,Ge),H(1,Ye),H(2,Wc)],gn);function qm(e,t){if(confirm(`Do you want to navigate to ${t}?
184
+
185
+ WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){try{s.opener=null}catch{}s.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var yr=ze("CharSizeService"),Pt=ze("CoreBrowserService"),xo=ze("MouseService"),Mt=ze("RenderService"),Vm=ze("SelectionService"),Uc=ze("CharacterJoinerService"),Os=ze("ThemeService"),Kc=ze("LinkProviderService"),Gm=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?Aa.isErrorNoTelemetry(e)?new Aa(e.message+`
186
+
187
+ `+e.stack):new Error(e.message+`
188
+
189
+ `+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}},Ym=new Gm;function Ki(e){Xm(e)||Ym.onUnexpectedError(e)}var xn="Canceled";function Xm(e){return e instanceof Jm?!0:e instanceof Error&&e.name===xn&&e.message===xn}var Jm=class extends Error{constructor(){super(xn),this.name=this.message}};function Zm(e){return new Error(`Illegal argument: ${e}`)}var Aa=class vn extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof vn)return t;let s=new vn;return s.message=t.message,s.stack=t.stack,s}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},bn=class qc extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,qc.prototype)}};function st(e,t=0){return e[e.length-(1+t)]}var Qm;(e=>{function t(o){return o<0}e.isLessThan=t;function s(o){return o<=0}e.isLessThanOrEqual=s;function i(o){return o>0}e.isGreaterThan=i;function n(o){return o===0}e.isNeitherLessOrGreaterThan=n,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(Qm||(Qm={}));function ep(e,t){let s=this,i=!1,n;return function(){return i||(i=!0,t||(n=e.apply(s,arguments))),n}}var Vc;(e=>{function t(k){return k&&typeof k=="object"&&typeof k[Symbol.iterator]=="function"}e.is=t;let s=Object.freeze([]);function i(){return s}e.empty=i;function*n(k){yield k}e.single=n;function o(k){return t(k)?k:n(k)}e.wrap=o;function a(k){return k||s}e.from=a;function*l(k){for(let w=k.length-1;w>=0;w--)yield k[w]}e.reverse=l;function h(k){return!k||k[Symbol.iterator]().next().done===!0}e.isEmpty=h;function c(k){return k[Symbol.iterator]().next().value}e.first=c;function f(k,w){let N=0;for(let M of k)if(w(M,N++))return!0;return!1}e.some=f;function p(k,w){for(let N of k)if(w(N))return N}e.find=p;function*u(k,w){for(let N of k)w(N)&&(yield N)}e.filter=u;function*g(k,w){let N=0;for(let M of k)yield w(M,N++)}e.map=g;function*m(k,w){let N=0;for(let M of k)yield*w(M,N++)}e.flatMap=m;function*_(...k){for(let w of k)yield*w}e.concat=_;function x(k,w,N){let M=N;for(let U of k)M=w(M,U);return M}e.reduce=x;function*y(k,w,N=k.length){for(w<0&&(w+=k.length),N<0?N+=k.length:N>k.length&&(N=k.length);w<N;w++)yield k[w]}e.slice=y;function v(k,w=Number.POSITIVE_INFINITY){let N=[];if(w===0)return[N,k];let M=k[Symbol.iterator]();for(let U=0;U<w;U++){let Y=M.next();if(Y.done)return[N,e.empty()];N.push(Y.value)}return[N,{[Symbol.iterator](){return M}}]}e.consume=v;async function j(k){let w=[];for await(let N of k)w.push(N);return Promise.resolve(w)}e.asyncToArray=j})(Vc||(Vc={}));function us(e){if(Vc.is(e)){let t=[];for(let s of e)if(s)try{s.dispose()}catch(i){t.push(i)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function tp(...e){return ve(()=>us(e))}function ve(e){return{dispose:ep(()=>{e()})}}var Gc=class Yc{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{us(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?Yc.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(t),t}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&(this._toDispose.delete(t),void 0)}};Gc.DISABLE_DISPOSED_WARNING=!1;var Gt=Gc,re=class{constructor(){this._store=new Gt,this._store}dispose(){this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};re.None=Object.freeze({dispose(){}});var As=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){var t;this._isDisposed||e===this._value||((t=this._value)==null||t.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){var e;this._isDisposed=!0,(e=this._value)==null||e.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},Dt=typeof window=="object"?window:globalThis,yn=class Sn{constructor(t){this.element=t,this.next=Sn.Undefined,this.prev=Sn.Undefined}};yn.Undefined=new yn(void 0);var ye=yn,Oa=class{constructor(){this._first=ye.Undefined,this._last=ye.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===ye.Undefined}clear(){let e=this._first;for(;e!==ye.Undefined;){let t=e.next;e.prev=ye.Undefined,e.next=ye.Undefined,e=t}this._first=ye.Undefined,this._last=ye.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let s=new ye(e);if(this._first===ye.Undefined)this._first=s,this._last=s;else if(t){let n=this._last;this._last=s,s.prev=n,n.next=s}else{let n=this._first;this._first=s,s.next=n,n.prev=s}this._size+=1;let i=!1;return()=>{i||(i=!0,this._remove(s))}}shift(){if(this._first!==ye.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==ye.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==ye.Undefined&&e.next!==ye.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===ye.Undefined&&e.next===ye.Undefined?(this._first=ye.Undefined,this._last=ye.Undefined):e.next===ye.Undefined?(this._last=this._last.prev,this._last.next=ye.Undefined):e.prev===ye.Undefined&&(this._first=this._first.next,this._first.prev=ye.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==ye.Undefined;)yield e.element,e=e.next}},sp=globalThis.performance&&typeof globalThis.performance.now=="function",ip=class Xc{static create(t){return new Xc(t)}constructor(t){this._now=sp&&t===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},$e;(e=>{e.None=()=>re.None;function t(P,E){return p(P,()=>{},0,void 0,!0,void 0,E)}e.defer=t;function s(P){return(E,B=null,S)=>{let C=!1,D;return D=P(L=>{if(!C)return D?D.dispose():C=!0,E.call(B,L)},null,S),C&&D.dispose(),D}}e.once=s;function i(P,E,B){return c((S,C=null,D)=>P(L=>S.call(C,E(L)),null,D),B)}e.map=i;function n(P,E,B){return c((S,C=null,D)=>P(L=>{E(L),S.call(C,L)},null,D),B)}e.forEach=n;function o(P,E,B){return c((S,C=null,D)=>P(L=>E(L)&&S.call(C,L),null,D),B)}e.filter=o;function a(P){return P}e.signal=a;function l(...P){return(E,B=null,S)=>{let C=tp(...P.map(D=>D(L=>E.call(B,L))));return f(C,S)}}e.any=l;function h(P,E,B,S){let C=B;return i(P,D=>(C=E(C,D),C),S)}e.reduce=h;function c(P,E){let B,S={onWillAddFirstListener(){B=P(C.fire,C)},onDidRemoveLastListener(){B==null||B.dispose()}},C=new O(S);return E==null||E.add(C),C.event}function f(P,E){return E instanceof Array?E.push(P):E&&E.add(P),P}function p(P,E,B=100,S=!1,C=!1,D,L){let Z,oe,q,J=0,se,de={leakWarningThreshold:D,onWillAddFirstListener(){Z=P(ce=>{J++,oe=E(oe,ce),S&&!q&&(ue.fire(oe),oe=void 0),se=()=>{let ge=oe;oe=void 0,q=void 0,(!S||J>1)&&ue.fire(ge),J=0},typeof B=="number"?(clearTimeout(q),q=setTimeout(se,B)):q===void 0&&(q=0,queueMicrotask(se))})},onWillRemoveListener(){C&&J>0&&(se==null||se())},onDidRemoveLastListener(){se=void 0,Z.dispose()}},ue=new O(de);return L==null||L.add(ue),ue.event}e.debounce=p;function u(P,E=0,B){return e.debounce(P,(S,C)=>S?(S.push(C),S):[C],E,void 0,!0,void 0,B)}e.accumulate=u;function g(P,E=(S,C)=>S===C,B){let S=!0,C;return o(P,D=>{let L=S||!E(D,C);return S=!1,C=D,L},B)}e.latch=g;function m(P,E,B){return[e.filter(P,E,B),e.filter(P,S=>!E(S),B)]}e.split=m;function _(P,E=!1,B=[],S){let C=B.slice(),D=P(oe=>{C?C.push(oe):Z.fire(oe)});S&&S.add(D);let L=()=>{C==null||C.forEach(oe=>Z.fire(oe)),C=null},Z=new O({onWillAddFirstListener(){D||(D=P(oe=>Z.fire(oe)),S&&S.add(D))},onDidAddFirstListener(){C&&(E?setTimeout(L):L())},onDidRemoveLastListener(){D&&D.dispose(),D=null}});return S&&S.add(Z),Z.event}e.buffer=_;function x(P,E){return(B,S,C)=>{let D=E(new v);return P(function(L){let Z=D.evaluate(L);Z!==y&&B.call(S,Z)},void 0,C)}}e.chain=x;let y=Symbol("HaltChainable");class v{constructor(){this.steps=[]}map(E){return this.steps.push(E),this}forEach(E){return this.steps.push(B=>(E(B),B)),this}filter(E){return this.steps.push(B=>E(B)?B:y),this}reduce(E,B){let S=B;return this.steps.push(C=>(S=E(S,C),S)),this}latch(E=(B,S)=>B===S){let B=!0,S;return this.steps.push(C=>{let D=B||!E(C,S);return B=!1,S=C,D?C:y}),this}evaluate(E){for(let B of this.steps)if(E=B(E),E===y)break;return E}}function j(P,E,B=S=>S){let S=(...Z)=>L.fire(B(...Z)),C=()=>P.on(E,S),D=()=>P.removeListener(E,S),L=new O({onWillAddFirstListener:C,onDidRemoveLastListener:D});return L.event}e.fromNodeEventEmitter=j;function k(P,E,B=S=>S){let S=(...Z)=>L.fire(B(...Z)),C=()=>P.addEventListener(E,S),D=()=>P.removeEventListener(E,S),L=new O({onWillAddFirstListener:C,onDidRemoveLastListener:D});return L.event}e.fromDOMEventEmitter=k;function w(P){return new Promise(E=>s(P)(E))}e.toPromise=w;function N(P){let E=new O;return P.then(B=>{E.fire(B)},()=>{E.fire(void 0)}).finally(()=>{E.dispose()}),E.event}e.fromPromise=N;function M(P,E){return P(B=>E.fire(B))}e.forward=M;function U(P,E,B){return E(B),P(S=>E(S))}e.runAndSubscribe=U;class Y{constructor(E,B){this._observable=E,this._counter=0,this._hasChanged=!1;let S={onWillAddFirstListener:()=>{E.addObserver(this)},onDidRemoveLastListener:()=>{E.removeObserver(this)}};this.emitter=new O(S),B&&B.add(this.emitter)}beginUpdate(E){this._counter++}handlePossibleChange(E){}handleChange(E,B){this._hasChanged=!0}endUpdate(E){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function V(P,E){return new Y(P,E).emitter.event}e.fromObservable=V;function $(P){return(E,B,S)=>{let C=0,D=!1,L={beginUpdate(){C++},endUpdate(){C--,C===0&&(P.reportChanges(),D&&(D=!1,E.call(B)))},handlePossibleChange(){},handleChange(){D=!0}};P.addObserver(L),P.reportChanges();let Z={dispose(){P.removeObserver(L)}};return S instanceof Gt?S.add(Z):Array.isArray(S)&&S.push(Z),Z}}e.fromObservableLight=$})($e||($e={}));var wn=class Cn{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${Cn._idPool++}`,Cn.all.add(this)}start(t){this._stopWatch=new ip,this.listenerCount=t}stop(){if(this._stopWatch){let t=this._stopWatch.elapsed();this.durations.push(t),this.elapsedOverall+=t,this.invocationCount+=1,this._stopWatch=void 0}}};wn.all=new Set,wn._idPool=0;var rp=wn,np=-1,Jc=class Zc{constructor(t,s,i=(Zc._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=s,this.name=i,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,s){let i=this.threshold;if(i<=0||s<i)return;this._stacks||(this._stacks=new Map);let n=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,n+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=i*.5;let[o,a]=this.getMostFrequentStack(),l=`[${this.name}] potential listener LEAK detected, having ${s} listeners already. MOST frequent listener (${a}):`;console.warn(l),console.warn(o);let h=new lp(l,o);this._errorHandler(h)}return()=>{let o=this._stacks.get(t.value)||0;this._stacks.set(t.value,o-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,s=0;for(let[i,n]of this._stacks)(!t||s<n)&&(t=[i,n],s=n);return t}};Jc._idPool=1;var op=Jc,ap=class Qc{constructor(t){this.value=t}static create(){let t=new Error;return new Qc(t.stack??"")}print(){console.warn(this.value.split(`
190
+ `).slice(2).join(`
191
+ `))}},lp=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},cp=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},hp=0,Or=class{constructor(e){this.value=e,this.id=hp++}},dp=2,up,O=class{constructor(t){var s,i,n,o;this._size=0,this._options=t,this._leakageMon=(s=this._options)!=null&&s.leakWarningThreshold?new op((t==null?void 0:t.onListenerError)??Ki,((i=this._options)==null?void 0:i.leakWarningThreshold)??np):void 0,this._perfMon=(n=this._options)!=null&&n._profName?new rp(this._options._profName):void 0,this._deliveryQueue=(o=this._options)==null?void 0:o.deliveryQueue}dispose(){var t,s,i,n;this._disposed||(this._disposed=!0,((t=this._deliveryQueue)==null?void 0:t.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(i=(s=this._options)==null?void 0:s.onDidRemoveLastListener)==null||i.call(s),(n=this._leakageMon)==null||n.dispose())}get event(){return this._event??(this._event=(t,s,i)=>{var l,h,c,f,p;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let u=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(u);let g=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],m=new cp(`${u}. HINT: Stack shows most frequent listener (${g[1]}-times)`,g[0]);return(((l=this._options)==null?void 0:l.onListenerError)||Ki)(m),re.None}if(this._disposed)return re.None;s&&(t=t.bind(s));let n=new Or(t),o;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(n.stack=ap.create(),o=this._leakageMon.check(n.stack,this._size+1)),this._listeners?this._listeners instanceof Or?(this._deliveryQueue??(this._deliveryQueue=new fp),this._listeners=[this._listeners,n]):this._listeners.push(n):((c=(h=this._options)==null?void 0:h.onWillAddFirstListener)==null||c.call(h,this),this._listeners=n,(p=(f=this._options)==null?void 0:f.onDidAddFirstListener)==null||p.call(f,this)),this._size++;let a=ve(()=>{o==null||o(),this._removeListener(n)});return i instanceof Gt?i.add(a):Array.isArray(i)&&i.push(a),a}),this._event}_removeListener(t){var o,a,l,h;if((a=(o=this._options)==null?void 0:o.onWillRemoveListener)==null||a.call(o,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(h=(l=this._options)==null?void 0:l.onDidRemoveLastListener)==null||h.call(l,this),this._size=0;return}let s=this._listeners,i=s.indexOf(t);if(i===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,s[i]=void 0;let n=this._deliveryQueue.current===this;if(this._size*dp<=s.length){let c=0;for(let f=0;f<s.length;f++)s[f]?s[c++]=s[f]:n&&(this._deliveryQueue.end--,c<this._deliveryQueue.i&&this._deliveryQueue.i--);s.length=c}}_deliver(t,s){var n;if(!t)return;let i=((n=this._options)==null?void 0:n.onListenerError)||Ki;if(!i){t.value(s);return}try{t.value(s)}catch(o){i(o)}}_deliverQueue(t){let s=t.current._listeners;for(;t.i<t.end;)this._deliver(s[t.i++],t.value);t.reset()}fire(t){var s,i,n,o;if((s=this._deliveryQueue)!=null&&s.current&&(this._deliverQueue(this._deliveryQueue),(i=this._perfMon)==null||i.stop()),(n=this._perfMon)==null||n.start(this._size),this._listeners)if(this._listeners instanceof Or)this._deliver(this._listeners,t);else{let a=this._deliveryQueue;a.enqueue(this,t,this._listeners.length),this._deliverQueue(a)}(o=this._perfMon)==null||o.stop()}hasListeners(){return this._size>0}},fp=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,s){this.i=0,this.end=s,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},kn=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new O,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new O,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,s){if(this.getZoomLevel(s)===t)return;let i=this.getWindowId(s);this.mapWindowIdToZoomLevel.set(i,t),this._onDidChangeZoomLevel.fire(i)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,s){this.mapWindowIdToZoomFactor.set(this.getWindowId(s),t)}setFullscreen(t,s){if(this.isFullscreen(s)===t)return;let i=this.getWindowId(s);this.mapWindowIdToFullScreen.set(i,t),this._onDidChangeFullscreen.fire(i)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};kn.INSTANCE=new kn;var vo=kn;function mp(e,t,s){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",s)}vo.INSTANCE.onDidChangeZoomLevel;function pp(e){return vo.INSTANCE.getZoomFactor(e)}vo.INSTANCE.onDidChangeFullscreen;var $s=typeof navigator=="object"?navigator.userAgent:"",Nn=$s.indexOf("Firefox")>=0,_p=$s.indexOf("AppleWebKit")>=0,bo=$s.indexOf("Chrome")>=0,gp=!bo&&$s.indexOf("Safari")>=0;$s.indexOf("Electron/")>=0;$s.indexOf("Android")>=0;var $r=!1;if(typeof Dt.matchMedia=="function"){let e=Dt.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=Dt.matchMedia("(display-mode: fullscreen)");$r=e.matches,mp(Dt,e,({matches:s})=>{$r&&t.matches||($r=s)})}var Ps="en",jn=!1,En=!1,qi=!1,eh=!1,Ai,Vi=Ps,$a=Ps,xp,dt,ns=globalThis,Oe,Ul;typeof ns.vscode<"u"&&typeof ns.vscode.process<"u"?Oe=ns.vscode.process:typeof process<"u"&&typeof((Ul=process==null?void 0:process.versions)==null?void 0:Ul.node)=="string"&&(Oe=process);var Kl,vp=typeof((Kl=Oe==null?void 0:Oe.versions)==null?void 0:Kl.electron)=="string",bp=vp&&(Oe==null?void 0:Oe.type)==="renderer",ql;if(typeof Oe=="object"){jn=Oe.platform==="win32",En=Oe.platform==="darwin",qi=Oe.platform==="linux",qi&&Oe.env.SNAP&&Oe.env.SNAP_REVISION,Oe.env.CI||Oe.env.BUILD_ARTIFACTSTAGINGDIRECTORY,Ai=Ps,Vi=Ps;let e=Oe.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);Ai=t.userLocale,$a=t.osLocale,Vi=t.resolvedLanguage||Ps,xp=(ql=t.languagePack)==null?void 0:ql.translationsConfigFile}catch{}eh=!0}else typeof navigator=="object"&&!bp?(dt=navigator.userAgent,jn=dt.indexOf("Windows")>=0,En=dt.indexOf("Macintosh")>=0,(dt.indexOf("Macintosh")>=0||dt.indexOf("iPad")>=0||dt.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,qi=dt.indexOf("Linux")>=0,(dt==null?void 0:dt.indexOf("Mobi"))>=0,Vi=globalThis._VSCODE_NLS_LANGUAGE||Ps,Ai=navigator.language.toLowerCase(),$a=Ai):console.error("Unable to resolve platform.");var th=jn,yt=En,yp=qi,Ia=eh,St=dt,Ot=Vi,Sp;(e=>{function t(){return Ot}e.value=t;function s(){return Ot.length===2?Ot==="en":Ot.length>=3?Ot[0]==="e"&&Ot[1]==="n"&&Ot[2]==="-":!1}e.isDefaultVariant=s;function i(){return Ot==="en"}e.isDefault=i})(Sp||(Sp={}));var wp=typeof ns.postMessage=="function"&&!ns.importScripts;(()=>{if(wp){let e=[];ns.addEventListener("message",s=>{if(s.data&&s.data.vscodeScheduleAsyncWork)for(let i=0,n=e.length;i<n;i++){let o=e[i];if(o.id===s.data.vscodeScheduleAsyncWork){e.splice(i,1),o.callback();return}}});let t=0;return s=>{let i=++t;e.push({id:i,callback:s}),ns.postMessage({vscodeScheduleAsyncWork:i},"*")}}return e=>setTimeout(e)})();var Cp=!!(St&&St.indexOf("Chrome")>=0);St&&St.indexOf("Firefox")>=0;!Cp&&St&&St.indexOf("Safari")>=0;St&&St.indexOf("Edg/")>=0;St&&St.indexOf("Android")>=0;var ks=typeof navigator=="object"?navigator:{};Ia||document.queryCommandSupported&&document.queryCommandSupported("copy")||ks&&ks.clipboard&&ks.clipboard.writeText,Ia||ks&&ks.clipboard&&ks.clipboard.readText;var yo=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},Ir=new yo,Fa=new yo,Ha=new yo,kp=new Array(230),sh;(e=>{function t(l){return Ir.keyCodeToStr(l)}e.toString=t;function s(l){return Ir.strToKeyCode(l)}e.fromString=s;function i(l){return Fa.keyCodeToStr(l)}e.toUserSettingsUS=i;function n(l){return Ha.keyCodeToStr(l)}e.toUserSettingsGeneral=n;function o(l){return Fa.strToKeyCode(l)||Ha.strToKeyCode(l)}e.fromUserSettings=o;function a(l){if(l>=98&&l<=113)return null;switch(l){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return Ir.keyCodeToStr(l)}e.toElectronAccelerator=a})(sh||(sh={}));var Np=class ih{constructor(t,s,i,n,o){this.ctrlKey=t,this.shiftKey=s,this.altKey=i,this.metaKey=n,this.keyCode=o}equals(t){return t instanceof ih&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){let t=this.ctrlKey?"1":"0",s=this.shiftKey?"1":"0",i=this.altKey?"1":"0",n=this.metaKey?"1":"0";return`K${t}${s}${i}${n}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new jp([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},jp=class{constructor(e){if(e.length===0)throw Zm("chords");this.chords=e}getHashCode(){let e="";for(let t=0,s=this.chords.length;t<s;t++)t!==0&&(e+=";"),e+=this.chords[t].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let t=0;t<this.chords.length;t++)if(!this.chords[t].equals(e.chords[t]))return!1;return!0}};function Ep(e){if(e.charCode){let s=String.fromCharCode(e.charCode).toUpperCase();return sh.fromString(s)}let t=e.keyCode;if(t===3)return 7;if(Nn)switch(t){case 59:return 85;case 60:if(yp)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(yt)return 57;break}else if(_p&&(yt&&t===93||!yt&&t===92))return 57;return kp[t]||0}var Dp=yt?256:2048,Rp=512,Pp=1024,Mp=yt?2048:256,Wa=class{constructor(e){var s;this._standardKeyboardEventBrand=!0;let t=e;this.browserEvent=t,this.target=t.target,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.altGraphKey=(s=t.getModifierState)==null?void 0:s.call(t,"AltGraph"),this.keyCode=Ep(t),this.code=t.code,this.ctrlKey=this.ctrlKey||this.keyCode===5,this.altKey=this.altKey||this.keyCode===6,this.shiftKey=this.shiftKey||this.keyCode===4,this.metaKey=this.metaKey||this.keyCode===57,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(e){return this._asKeybinding===e}_computeKeybinding(){let e=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode);let t=0;return this.ctrlKey&&(t|=Dp),this.altKey&&(t|=Rp),this.shiftKey&&(t|=Pp),this.metaKey&&(t|=Mp),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new Np(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},Ua=new WeakMap;function Lp(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,s=e.parent.location;if(t.origin!=="null"&&s.origin!=="null"&&t.origin!==s.origin)return null}catch{return null}return e.parent}var Bp=class{static getSameOriginWindowChain(e){let t=Ua.get(e);if(!t){t=[],Ua.set(e,t);let s=e,i;do i=Lp(s),i?t.push({window:new WeakRef(s),iframeElement:s.frameElement||null}):t.push({window:new WeakRef(s),iframeElement:null}),s=i;while(s)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let s=0,i=0,n=this.getSameOriginWindowChain(e);for(let o of n){let a=o.window.deref();if(s+=(a==null?void 0:a.scrollY)??0,i+=(a==null?void 0:a.scrollX)??0,a===t||!o.iframeElement)break;let l=o.iframeElement.getBoundingClientRect();s+=l.top,i+=l.left}return{top:s,left:i}}},Oi=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=t.button===0,this.middleButton=t.button===1,this.rightButton=t.button===2,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,t.type==="dblclick"&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,typeof t.pageX=="number"?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let s=Bp.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=s.left,this.posy-=s.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},Ka=class{constructor(e,t=0,s=0){var n;this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=s,this.deltaX=t;let i=!1;if(bo){let o=navigator.userAgent.match(/Chrome\/(\d+)/);i=(o?parseInt(o[1]):123)<=122}if(e){let o=e,a=e,l=((n=e.view)==null?void 0:n.devicePixelRatio)||1;if(typeof o.wheelDeltaY<"u")i?this.deltaY=o.wheelDeltaY/(120*l):this.deltaY=o.wheelDeltaY/120;else if(typeof a.VERTICAL_AXIS<"u"&&a.axis===a.VERTICAL_AXIS)this.deltaY=-a.detail/3;else if(e.type==="wheel"){let h=e;h.deltaMode===h.DOM_DELTA_LINE?Nn&&!yt?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof o.wheelDeltaX<"u")gp&&th?this.deltaX=-(o.wheelDeltaX/120):i?this.deltaX=o.wheelDeltaX/(120*l):this.deltaX=o.wheelDeltaX/120;else if(typeof a.HORIZONTAL_AXIS<"u"&&a.axis===a.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let h=e;h.deltaMode===h.DOM_DELTA_LINE?Nn&&!yt?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(i?this.deltaY=e.wheelDelta/(120*l):this.deltaY=e.wheelDelta/120)}}preventDefault(){var e;(e=this.browserEvent)==null||e.preventDefault()}stopPropagation(){var e;(e=this.browserEvent)==null||e.stopPropagation()}},rh=Object.freeze(function(e,t){let s=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(s)}}}),Tp;(e=>{function t(s){return s===e.None||s===e.Cancelled||s instanceof zp?!0:!s||typeof s!="object"?!1:typeof s.isCancellationRequested=="boolean"&&typeof s.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:$e.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:rh})})(Tp||(Tp={}));var zp=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?rh:(this._emitter||(this._emitter=new O),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},So=class{constructor(e,t){this._isDisposed=!1,this._token=-1,typeof e=="function"&&typeof t=="number"&&this.setIfNotSet(e,t)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,t){if(this._isDisposed)throw new bn("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new bn("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},Ap=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){var e;(e=this.disposable)==null||e.dispose(),this.disposable=void 0}cancelAndSet(e,t,s=globalThis){if(this.isDisposed)throw new bn("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let i=s.setInterval(()=>{e()},t);this.disposable=ve(()=>{s.clearInterval(i),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},Op;(e=>{async function t(i){let n,o=await Promise.all(i.map(a=>a.then(l=>l,l=>{n||(n=l)})));if(typeof n<"u")throw n;return o}e.settled=t;function s(i){return new Promise(async(n,o)=>{try{await i(n,o)}catch(a){o(a)}})}e.withAsyncBody=s})(Op||(Op={}));var qa=class lt{static fromArray(t){return new lt(s=>{s.emitMany(t)})}static fromPromise(t){return new lt(async s=>{s.emitMany(await t)})}static fromPromises(t){return new lt(async s=>{await Promise.all(t.map(async i=>s.emitOne(await i)))})}static merge(t){return new lt(async s=>{await Promise.all(t.map(async i=>{for await(let n of i)s.emitOne(n)}))})}constructor(t,s){this._state=0,this._results=[],this._error=null,this._onReturn=s,this._onStateChanged=new O,queueMicrotask(async()=>{let i={emitOne:n=>this.emitOne(n),emitMany:n=>this.emitMany(n),reject:n=>this.reject(n)};try{await Promise.resolve(t(i)),this.resolve()}catch(n){this.reject(n)}finally{i.emitOne=void 0,i.emitMany=void 0,i.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await $e.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>{var s;return(s=this._onReturn)==null||s.call(this),{done:!0,value:void 0}}}}static map(t,s){return new lt(async i=>{for await(let n of t)i.emitOne(s(n))})}map(t){return lt.map(this,t)}static filter(t,s){return new lt(async i=>{for await(let n of t)s(n)&&i.emitOne(n)})}filter(t){return lt.filter(this,t)}static coalesce(t){return lt.filter(t,s=>!!s)}coalesce(){return lt.coalesce(this)}static async toPromise(t){let s=[];for await(let i of t)s.push(i);return s}toPromise(){return lt.toPromise(this)}emitOne(t){this._state===0&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){this._state===0&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(t){this._state===0&&(this._state=2,this._error=t,this._onStateChanged.fire())}};qa.EMPTY=qa.fromArray([]);var{getWindow:vt,getWindowId:$p,onDidRegisterWindow:Ip}=(function(){let e=new Map,t={window:Dt,disposables:new Gt};e.set(Dt.vscodeWindowId,t);let s=new O,i=new O,n=new O;function o(a,l){return(typeof a=="number"?e.get(a):void 0)??(l?t:void 0)}return{onDidRegisterWindow:s.event,onWillUnregisterWindow:n.event,onDidUnregisterWindow:i.event,registerWindow(a){if(e.has(a.vscodeWindowId))return re.None;let l=new Gt,h={window:a,disposables:l.add(new Gt)};return e.set(a.vscodeWindowId,h),l.add(ve(()=>{e.delete(a.vscodeWindowId),i.fire(a)})),l.add(X(a,Pe.BEFORE_UNLOAD,()=>{n.fire(a)})),s.fire(h),l},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(a){return a.vscodeWindowId},hasWindow(a){return e.has(a)},getWindowById:o,getWindow(a){var c;let l=a;if((c=l==null?void 0:l.ownerDocument)!=null&&c.defaultView)return l.ownerDocument.defaultView.window;let h=a;return h!=null&&h.view?h.view.window:Dt},getDocument(a){return vt(a).document}}})(),Fp=class{constructor(e,t,s,i){this._node=e,this._type=t,this._handler=s,this._options=i||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function X(e,t,s,i){return new Fp(e,t,s,i)}var Va=function(e,t,s,i){return X(e,t,s,i)},wo,Hp=class extends Ap{constructor(e){super(),this.defaultTarget=e&&vt(e)}cancelAndSet(e,t,s){return super.cancelAndSet(e,t,s??this.defaultTarget)}},Ga=class{constructor(e,t=0){this._runner=e,this.priority=t,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){Ki(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,s=new Map,i=new Map,n=o=>{s.set(o,!1);let a=e.get(o)??[];for(t.set(o,a),e.set(o,[]),i.set(o,!0);a.length>0;)a.sort(Ga.sort),a.shift().execute();i.set(o,!1)};wo=(o,a,l=0)=>{let h=$p(o),c=new Ga(a,l),f=e.get(h);return f||(f=[],e.set(h,f)),f.push(c),s.get(h)||(s.set(h,!0),o.requestAnimationFrame(()=>n(h))),c}})();function Wp(e){let t=e.getBoundingClientRect(),s=vt(e);return{left:t.left+s.scrollX,top:t.top+s.scrollY,width:t.width,height:t.height}}var Pe={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},Up=class{constructor(e){this.domNode=e,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(e){let t=Qe(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=Qe(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=Qe(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=Qe(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=Qe(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=Qe(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=Qe(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=Qe(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=Qe(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=Qe(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=Qe(e);this._paddingRight!==t&&(this._paddingRight=t,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let t=Qe(e);this._fontSize!==t&&(this._fontSize=t,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let t=Qe(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=Qe(e);this._letterSpacing!==t&&(this._letterSpacing=t,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,t){this.domNode.classList.toggle(e,t),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,t){this.domNode.setAttribute(e,t)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function Qe(e){return typeof e=="number"?`${e}px`:e}function hi(e){return new Up(e)}var nh=class{constructor(){this._hooks=new Gt,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let s=this._onStopCallback;this._onStopCallback=null,e&&s&&s(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,s,i,n){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=i,this._onStopCallback=n;let o=e;try{e.setPointerCapture(t),this._hooks.add(ve(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{o=vt(e)}this._hooks.add(X(o,Pe.POINTER_MOVE,a=>{if(a.buttons!==s){this.stopMonitoring(!0);return}a.preventDefault(),this._pointerMoveCallback(a)})),this._hooks.add(X(o,Pe.POINTER_UP,a=>this.stopMonitoring(!0)))}};function Kp(e,t,s){let i=null,n=null;if(typeof s.value=="function"?(i="value",n=s.value,n.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof s.get=="function"&&(i="get",n=s.get),!n)throw new Error("not supported");let o=`$memoize$${t}`;s[i]=function(...a){return this.hasOwnProperty(o)||Object.defineProperty(this,o,{configurable:!1,enumerable:!1,writable:!1,value:n.apply(this,a)}),this[o]}}var pt;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(pt||(pt={}));var ti=class Ie extends re{constructor(){super(),this.dispatched=!1,this.targets=new Oa,this.ignoreTargets=new Oa,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register($e.runAndSubscribe(Ip,({window:t,disposables:s})=>{s.add(X(t.document,"touchstart",i=>this.onTouchStart(i),{passive:!1})),s.add(X(t.document,"touchend",i=>this.onTouchEnd(t,i))),s.add(X(t.document,"touchmove",i=>this.onTouchMove(i),{passive:!1}))},{window:Dt,disposables:this._store}))}static addTarget(t){if(!Ie.isTouchDevice())return re.None;Ie.INSTANCE||(Ie.INSTANCE=new Ie);let s=Ie.INSTANCE.targets.push(t);return ve(s)}static ignoreTarget(t){if(!Ie.isTouchDevice())return re.None;Ie.INSTANCE||(Ie.INSTANCE=new Ie);let s=Ie.INSTANCE.ignoreTargets.push(t);return ve(s)}static isTouchDevice(){return"ontouchstart"in Dt||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let s=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let i=0,n=t.targetTouches.length;i<n;i++){let o=t.targetTouches.item(i);this.activeTouches[o.identifier]={id:o.identifier,initialTarget:o.target,initialTimeStamp:s,initialPageX:o.pageX,initialPageY:o.pageY,rollingTimestamps:[s],rollingPageX:[o.pageX],rollingPageY:[o.pageY]};let a=this.newGestureEvent(pt.Start,o.target);a.pageX=o.pageX,a.pageY=o.pageY,this.dispatchEvent(a)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,s){let i=Date.now(),n=Object.keys(this.activeTouches).length;for(let o=0,a=s.changedTouches.length;o<a;o++){let l=s.changedTouches.item(o);if(!this.activeTouches.hasOwnProperty(String(l.identifier))){console.warn("move of an UNKNOWN touch",l);continue}let h=this.activeTouches[l.identifier],c=Date.now()-h.initialTimeStamp;if(c<Ie.HOLD_DELAY&&Math.abs(h.initialPageX-st(h.rollingPageX))<30&&Math.abs(h.initialPageY-st(h.rollingPageY))<30){let f=this.newGestureEvent(pt.Tap,h.initialTarget);f.pageX=st(h.rollingPageX),f.pageY=st(h.rollingPageY),this.dispatchEvent(f)}else if(c>=Ie.HOLD_DELAY&&Math.abs(h.initialPageX-st(h.rollingPageX))<30&&Math.abs(h.initialPageY-st(h.rollingPageY))<30){let f=this.newGestureEvent(pt.Contextmenu,h.initialTarget);f.pageX=st(h.rollingPageX),f.pageY=st(h.rollingPageY),this.dispatchEvent(f)}else if(n===1){let f=st(h.rollingPageX),p=st(h.rollingPageY),u=st(h.rollingTimestamps)-h.rollingTimestamps[0],g=f-h.rollingPageX[0],m=p-h.rollingPageY[0],_=[...this.targets].filter(x=>h.initialTarget instanceof Node&&x.contains(h.initialTarget));this.inertia(t,_,i,Math.abs(g)/u,g>0?1:-1,f,Math.abs(m)/u,m>0?1:-1,p)}this.dispatchEvent(this.newGestureEvent(pt.End,h.initialTarget)),delete this.activeTouches[l.identifier]}this.dispatched&&(s.preventDefault(),s.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,s){let i=document.createEvent("CustomEvent");return i.initEvent(t,!1,!0),i.initialTarget=s,i.tapCount=0,i}dispatchEvent(t){if(t.type===pt.Tap){let s=new Date().getTime(),i=0;s-this._lastSetTapCountTime>Ie.CLEAR_TAP_COUNT_TIME?i=1:i=2,this._lastSetTapCountTime=s,t.tapCount=i}else(t.type===pt.Change||t.type===pt.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let i of this.ignoreTargets)if(i.contains(t.initialTarget))return;let s=[];for(let i of this.targets)if(i.contains(t.initialTarget)){let n=0,o=t.initialTarget;for(;o&&o!==i;)n++,o=o.parentElement;s.push([n,i])}s.sort((i,n)=>i[0]-n[0]);for(let[i,n]of s)n.dispatchEvent(t),this.dispatched=!0}}inertia(t,s,i,n,o,a,l,h,c){this.handle=wo(t,()=>{let f=Date.now(),p=f-i,u=0,g=0,m=!0;n+=Ie.SCROLL_FRICTION*p,l+=Ie.SCROLL_FRICTION*p,n>0&&(m=!1,u=o*n*p),l>0&&(m=!1,g=h*l*p);let _=this.newGestureEvent(pt.Change);_.translationX=u,_.translationY=g,s.forEach(x=>x.dispatchEvent(_)),m||this.inertia(t,s,f,n,o,a+u,l,h,c+g)})}onTouchMove(t){let s=Date.now();for(let i=0,n=t.changedTouches.length;i<n;i++){let o=t.changedTouches.item(i);if(!this.activeTouches.hasOwnProperty(String(o.identifier))){console.warn("end of an UNKNOWN touch",o);continue}let a=this.activeTouches[o.identifier],l=this.newGestureEvent(pt.Change,a.initialTarget);l.translationX=o.pageX-st(a.rollingPageX),l.translationY=o.pageY-st(a.rollingPageY),l.pageX=o.pageX,l.pageY=o.pageY,this.dispatchEvent(l),a.rollingPageX.length>3&&(a.rollingPageX.shift(),a.rollingPageY.shift(),a.rollingTimestamps.shift()),a.rollingPageX.push(o.pageX),a.rollingPageY.push(o.pageY),a.rollingTimestamps.push(s)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};ti.SCROLL_FRICTION=-.005,ti.HOLD_DELAY=700,ti.CLEAR_TAP_COUNT_TIME=400,Ce([Kp],ti,"isTouchDevice",1);var qp=ti,Co=class extends re{onclick(e,t){this._register(X(e,Pe.CLICK,s=>t(new Oi(vt(e),s))))}onmousedown(e,t){this._register(X(e,Pe.MOUSE_DOWN,s=>t(new Oi(vt(e),s))))}onmouseover(e,t){this._register(X(e,Pe.MOUSE_OVER,s=>t(new Oi(vt(e),s))))}onmouseleave(e,t){this._register(X(e,Pe.MOUSE_LEAVE,s=>t(new Oi(vt(e),s))))}onkeydown(e,t){this._register(X(e,Pe.KEY_DOWN,s=>t(new Wa(s))))}onkeyup(e,t){this._register(X(e,Pe.KEY_UP,s=>t(new Wa(s))))}oninput(e,t){this._register(X(e,Pe.INPUT,t))}onblur(e,t){this._register(X(e,Pe.BLUR,t))}onfocus(e,t){this._register(X(e,Pe.FOCUS,t))}onchange(e,t){this._register(X(e,Pe.CHANGE,t))}ignoreGesture(e){return qp.ignoreTarget(e)}},Ya=11,Vp=class extends Co{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=e.bgWidth+"px",this.bgDomNode.style.height=e.bgHeight+"px",typeof e.top<"u"&&(this.bgDomNode.style.top="0px"),typeof e.left<"u"&&(this.bgDomNode.style.left="0px"),typeof e.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof e.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=e.className,this.domNode.style.position="absolute",this.domNode.style.width=Ya+"px",this.domNode.style.height=Ya+"px",typeof e.top<"u"&&(this.domNode.style.top=e.top+"px"),typeof e.left<"u"&&(this.domNode.style.left=e.left+"px"),typeof e.bottom<"u"&&(this.domNode.style.bottom=e.bottom+"px"),typeof e.right<"u"&&(this.domNode.style.right=e.right+"px"),this._pointerMoveMonitor=this._register(new nh),this._register(Va(this.bgDomNode,Pe.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(Va(this.domNode,Pe.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new Hp),this._pointerdownScheduleRepeatTimer=this._register(new So)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,vt(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,s=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},Gp=class Dn{constructor(t,s,i,n,o,a,l){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(s=s|0,i=i|0,n=n|0,o=o|0,a=a|0,l=l|0),this.rawScrollLeft=n,this.rawScrollTop=l,s<0&&(s=0),n+s>i&&(n=i-s),n<0&&(n=0),o<0&&(o=0),l+o>a&&(l=a-o),l<0&&(l=0),this.width=s,this.scrollWidth=i,this.scrollLeft=n,this.height=o,this.scrollHeight=a,this.scrollTop=l}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(t,s){return new Dn(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,s?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,s?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new Dn(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,s){let i=this.width!==t.width,n=this.scrollWidth!==t.scrollWidth,o=this.scrollLeft!==t.scrollLeft,a=this.height!==t.height,l=this.scrollHeight!==t.scrollHeight,h=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:s,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:i,scrollWidthChanged:n,scrollLeftChanged:o,heightChanged:a,scrollHeightChanged:l,scrollTopChanged:h}}},Yp=class extends re{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new O),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new Gp(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){var i;let s=this._state.withScrollDimensions(e,t);this._setState(s,!!this._smoothScrolling),(i=this._smoothScrolling)==null||i.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let s=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===s.scrollLeft&&this._smoothScrolling.to.scrollTop===s.scrollTop)return;let i;t?i=new Ja(this._smoothScrolling.from,s,this._smoothScrolling.startTime,this._smoothScrolling.duration):i=this._smoothScrolling.combine(this._state,s,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=i}else{let s=this._state.withScrollPosition(e);this._smoothScrolling=Ja.start(this._state,s,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),!!this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let s=this._state;s.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(s,t)))}},Xa=class{constructor(e,t,s){this.scrollLeft=e,this.scrollTop=t,this.isDone=s}};function Fr(e,t){let s=t-e;return function(i){return e+s*Zp(i)}}function Xp(e,t,s){return function(i){return i<s?e(i/s):t((i-s)/(1-s))}}var Ja=class Rn{constructor(t,s,i,n){this.from=t,this.to=s,this.duration=n,this.startTime=i,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(t,s,i){if(Math.abs(t-s)>2.5*i){let n,o;return t<s?(n=t+.75*i,o=s-.75*i):(n=t-.75*i,o=s+.75*i),Xp(Fr(t,n),Fr(o,s),.33)}return Fr(t,s)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(t){this.to=t.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(t){let s=(t-this.startTime)/this.duration;if(s<1){let i=this.scrollLeft(s),n=this.scrollTop(s);return new Xa(i,n,!1)}return new Xa(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,s,i){return Rn.start(t,s,i)}static start(t,s,i){i=i+10;let n=Date.now()-10;return new Rn(t,s,n,i)}};function Jp(e){return Math.pow(e,3)}function Zp(e){return 1-Jp(1-e)}var Qp=class extends re{constructor(e,t,s){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=s,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new So)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return this._visibility===2?!1:this._visibility===3?!0:this._rawShouldBeVisible}_updateShouldBeVisible(){let e=this._applyVisibilitySetting();this._shouldBeVisible!==e&&(this._shouldBeVisible=e,this.ensureVisibility())}setIsNeeded(e){this._isNeeded!==e&&(this._isNeeded=e,this.ensureVisibility())}setDomNode(e){this._domNode=e,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){if(!this._isNeeded){this._hide(!1);return}this._shouldBeVisible?this._reveal():this._hide(!0)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{var e;(e=this._domNode)==null||e.setClassName(this._visibleClassName)},0))}_hide(e){var t;this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,(t=this._domNode)==null||t.setClassName(this._invisibleClassName+(e?" fade":"")))}},e_=140,oh=class extends Co{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new Qp(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new nh),this._shouldRender=!0,this.domNode=hi(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(X(this.domNode.domNode,Pe.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new Vp(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,s,i){this.slider=hi(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof s=="number"&&this.slider.setWidth(s),typeof i=="number"&&this.slider.setHeight(i),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(X(this.slider.domNode,Pe.POINTER_DOWN,n=>{n.button===0&&(n.preventDefault(),this._sliderPointerDown(n))})),this.onclick(this.slider.domNode,n=>{n.leftButton&&n.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,s=t+this._scrollbarState.getSliderPosition(),i=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),n=this._sliderPointerPosition(e);s<=n&&n<=i?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,s;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,s=e.offsetY;else{let n=Wp(this.domNode.domNode);t=e.pageX-n.left,s=e.pageY-n.top}let i=this._pointerDownRelativePosition(t,s);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(i):this._scrollbarState.getDesiredScrollPositionFromOffset(i)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),s=this._sliderOrthogonalPointerPosition(e),i=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,n=>{let o=this._sliderOrthogonalPointerPosition(n),a=Math.abs(o-s);if(th&&a>e_){this._setDesiredScrollPositionNow(i.getScrollPosition());return}let l=this._sliderPointerPosition(n)-t;this._setDesiredScrollPositionNow(i.getDesiredScrollPositionFromDelta(l))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},ah=class Pn{constructor(t,s,i,n,o,a){this._scrollbarSize=Math.round(s),this._oppositeScrollbarSize=Math.round(i),this._arrowSize=Math.round(t),this._visibleSize=n,this._scrollSize=o,this._scrollPosition=a,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new Pn(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let s=Math.round(t);return this._visibleSize!==s?(this._visibleSize=s,this._refreshComputedValues(),!0):!1}setScrollSize(t){let s=Math.round(t);return this._scrollSize!==s?(this._scrollSize=s,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let s=Math.round(t);return this._scrollPosition!==s?(this._scrollPosition=s,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,s,i,n,o){let a=Math.max(0,i-t),l=Math.max(0,a-2*s),h=n>0&&n>i;if(!h)return{computedAvailableSize:Math.round(a),computedIsNeeded:h,computedSliderSize:Math.round(l),computedSliderRatio:0,computedSliderPosition:0};let c=Math.round(Math.max(20,Math.floor(i*l/n))),f=(l-c)/(n-i),p=o*f;return{computedAvailableSize:Math.round(a),computedIsNeeded:h,computedSliderSize:Math.round(c),computedSliderRatio:f,computedSliderPosition:Math.round(p)}}_refreshComputedValues(){let t=Pn._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(t){if(!this._computedIsNeeded)return 0;let s=t-this._arrowSize-this._computedSliderSize/2;return Math.round(s/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let s=t-this._arrowSize,i=this._scrollPosition;return s<this._computedSliderPosition?i-=this._visibleSize:i+=this._visibleSize,i}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let s=this._computedSliderPosition+t;return Math.round(s/this._computedSliderRatio)}},t_=class extends oh{constructor(e,t,s){let i=e.getScrollDimensions(),n=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:s,scrollbarState:new ah(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,i.width,i.scrollWidth,n.scrollLeft),visibility:t.horizontal,extraScrollbarClassName:"horizontal",scrollable:e,scrollByPage:t.scrollByPage}),t.horizontalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((t.horizontalScrollbarSize-t.horizontalSliderSize)/2),0,void 0,t.horizontalSliderSize)}_updateSlider(e,t){this.slider.setWidth(e),this.slider.setLeft(t)}_renderDomNode(e,t){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,t){e.scrollLeft=t}updateOptions(e){this.updateScrollbarSize(e.horizontal===2?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},s_=class extends oh{constructor(e,t,s){let i=e.getScrollDimensions(),n=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:s,scrollbarState:new ah(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,i.height,i.scrollHeight,n.scrollTop),visibility:t.vertical,extraScrollbarClassName:"vertical",scrollable:e,scrollByPage:t.scrollByPage}),t.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((t.verticalScrollbarSize-t.verticalSliderSize)/2),t.verticalSliderSize,void 0)}_updateSlider(e,t){this.slider.setHeight(e),this.slider.setTop(t)}_renderDomNode(e,t){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return t}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,t){e.scrollTop=t}updateOptions(e){this.updateScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},i_=500,Za=50,r_=class{constructor(e,t,s){this.timestamp=e,this.deltaX=t,this.deltaY=s,this.score=0}},Mn=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let t=1,s=0,i=1,n=this._rear;do{let o=n===this._front?t:Math.pow(2,-i);if(t-=o,s+=this._memory[n].score*o,n===this._front)break;n=(this._capacity+n-1)%this._capacity,i++}while(!0);return s<=.5}acceptStandardWheelEvent(t){if(bo){let s=vt(t.browserEvent),i=pp(s);this.accept(Date.now(),t.deltaX*i,t.deltaY*i)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,s,i){let n=null,o=new r_(t,s,i);this._front===-1&&this._rear===-1?(this._memory[0]=o,this._front=0,this._rear=0):(n=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=o),o.score=this._computeScore(o,n)}_computeScore(t,s){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let i=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(i+=.25),s){let n=Math.abs(t.deltaX),o=Math.abs(t.deltaY),a=Math.abs(s.deltaX),l=Math.abs(s.deltaY),h=Math.max(Math.min(n,a),1),c=Math.max(Math.min(o,l),1),f=Math.max(n,a),p=Math.max(o,l);f%h===0&&p%c===0&&(i-=.5)}return Math.min(Math.max(i,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};Mn.INSTANCE=new Mn;var n_=Mn,o_=class extends Co{constructor(e,t,s){super(),this._onScroll=this._register(new O),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new O),this.onWillScroll=this._onWillScroll.event,this._options=l_(t),this._scrollable=s,this._register(this._scrollable.onScroll(n=>{this._onWillScroll.fire(n),this._onDidScroll(n),this._onScroll.fire(n)}));let i={onMouseWheel:n=>this._onMouseWheel(n),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new s_(this._scrollable,this._options,i)),this._horizontalScrollbar=this._register(new t_(this._scrollable,this._options,i)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=hi(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=hi(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=hi(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,n=>this._onMouseOver(n)),this.onmouseleave(this._listenOnDomNode,n=>this._onMouseLeave(n)),this._hideTimeout=this._register(new So),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=us(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,yt&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(e){typeof e.handleMouseWheel<"u"&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<"u"&&(this._options.horizontal=e.horizontal),typeof e.vertical<"u"&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<"u"&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new Ka(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=us(this._mouseWheelToDispose),e)){let t=s=>{this._onMouseWheel(new Ka(s))};this._mouseWheelToDispose.push(X(this._listenOnDomNode,Pe.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var n;if((n=e.browserEvent)!=null&&n.defaultPrevented)return;let t=n_.INSTANCE;t.acceptStandardWheelEvent(e);let s=!1;if(e.deltaY||e.deltaX){let o=e.deltaY*this._options.mouseWheelScrollSensitivity,a=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&a+o===0?a=o=0:Math.abs(o)>=Math.abs(a)?a=0:o=0),this._options.flipAxes&&([o,a]=[a,o]);let l=!yt&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||l)&&!a&&(a=o,o=0),e.browserEvent&&e.browserEvent.altKey&&(a=a*this._options.fastScrollSensitivity,o=o*this._options.fastScrollSensitivity);let h=this._scrollable.getFutureScrollPosition(),c={};if(o){let f=Za*o,p=h.scrollTop-(f<0?Math.floor(f):Math.ceil(f));this._verticalScrollbar.writeScrollPosition(c,p)}if(a){let f=Za*a,p=h.scrollLeft-(f<0?Math.floor(f):Math.ceil(f));this._horizontalScrollbar.writeScrollPosition(c,p)}c=this._scrollable.validateScrollPosition(c),(h.scrollLeft!==c.scrollLeft||h.scrollTop!==c.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(c):this._scrollable.setScrollPositionNow(c),s=!0)}let i=s;!i&&this._options.alwaysConsumeMouseWheel&&(i=!0),!i&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(i=!0),i&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,s=e.scrollLeft>0,i=s?" left":"",n=t?" top":"",o=s||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${i}`),this._topShadowDomNode.setClassName(`shadow${n}`),this._topLeftShadowDomNode.setClassName(`shadow${o}${n}${i}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),i_)}},a_=class extends o_{constructor(e,t,s){super(e,t,s)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function l_(e){let t={lazyRender:typeof e.lazyRender<"u"?e.lazyRender:!1,className:typeof e.className<"u"?e.className:"",useShadows:typeof e.useShadows<"u"?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<"u"?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<"u"?e.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<"u"?e.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<"u"?e.alwaysConsumeMouseWheel:!1,scrollYToX:typeof e.scrollYToX<"u"?e.scrollYToX:!1,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<"u"?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<"u"?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<"u"?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<"u"?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<"u"?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<"u"?e.listenOnDomNode:null,horizontal:typeof e.horizontal<"u"?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<"u"?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<"u"?e.horizontalHasArrows:!1,vertical:typeof e.vertical<"u"?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<"u"?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<"u"?e.verticalHasArrows:!1,verticalSliderSize:typeof e.verticalSliderSize<"u"?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<"u"?e.scrollByPage:!1};return t.horizontalSliderSize=typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<"u"?e.verticalSliderSize:t.verticalScrollbarSize,yt&&(t.className+=" mac"),t}var Ln=class extends re{constructor(e,t,s,i,n,o,a,l){super(),this._bufferService=s,this._optionsService=a,this._renderService=l,this._onRequestScrollLines=this._register(new O),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let h=this._register(new Yp({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:c=>wo(i.window,c)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{h.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new a_(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},h)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(n.onProtocolChange(c=>{this._scrollableElement.updateOptions({handleMouseWheel:!(c&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register($e.runAndSubscribe(o.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=o.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(ve(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=i.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(ve(()=>this._styleElement.remove())),this._register($e.runAndSubscribe(o.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${o.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${o.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${o.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
192
+ `)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(c=>this._handleScroll(c)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){var e;return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:((e=this._optionsService.rawOptions.overviewRuler)==null?void 0:e.width)||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),s=t-this._bufferService.buffer.ydisp;s!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(s)),this._isHandlingScroll=!1}};Ln=Ce([H(2,Ge),H(3,Pt),H(4,Fc),H(5,Os),H(6,Ye),H(7,Mt)],Ln);var Bn=class extends re{constructor(e,t,s,i,n){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=s,this._decorationService=i,this._renderService=n,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this._register(this._renderService.onRenderedViewportChange(()=>this._doRefreshDecorations())),this._register(this._renderService.onDimensionsChange(()=>{this._dimensionsChanged=!0,this._queueRefresh()})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt})),this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh())),this._register(this._decorationService.onDecorationRemoved(o=>this._removeDecoration(o))),this._register(ve(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){var i;let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",((i=e==null?void 0:e.options)==null?void 0:i.layer)==="top"),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let s=e.options.x??0;return s&&s>this._bufferService.cols&&(t.style.display="none"),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let s=this._decorationElements.get(e);s||(s=this._createElement(e),e.element=s,this._decorationElements.set(e,s),this._container.appendChild(s),e.onDispose(()=>{this._decorationElements.delete(e),s.remove()})),s.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(s.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,s.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,s.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,s.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(s)}}_refreshXPosition(e,t=e.element){if(!t)return;let s=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=s?`${s*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=s?`${s*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){var t;(t=this._decorationElements.get(e))==null||t.remove(),this._decorationElements.delete(e),e.dispose()}};Bn=Ce([H(1,Ge),H(2,Pt),H(3,bi),H(4,Mt)],Bn);var c_=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,s){return t>=e.startBufferLine-this._linePadding[s||"full"]&&t<=e.endBufferLine+this._linePadding[s||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},ft={full:0,left:0,center:0,right:0},$t={full:0,left:0,center:0,right:0},Ks={full:0,left:0,center:0,right:0},ar=class extends re{constructor(e,t,s,i,n,o,a,l){var c;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=s,this._decorationService=i,this._renderService=n,this._optionsService=o,this._themeService=a,this._coreBrowserService=l,this._colorZoneStore=new c_,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(c=this._viewportElement.parentElement)==null||c.insertBefore(this._canvas,this._viewportElement),this._register(ve(()=>{var f;return(f=this._canvas)==null?void 0:f.remove()}));let h=this._canvas.getContext("2d");if(h)this._ctx=h;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),this._register(this._renderService.onRenderedViewportChange(()=>this._queueRefresh())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"})),this._register(this._bufferService.onScroll(()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){var e;return((e=this._optionsService.options.overviewRuler)==null?void 0:e.width)||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);$t.full=this._canvas.width,$t.left=e,$t.center=t,$t.right=e,this._refreshDrawHeightConstants(),Ks.full=1,Ks.left=1,Ks.center=1+$t.left,Ks.right=1+$t.left+$t.center}_refreshDrawHeightConstants(){ft.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);ft.left=t,ft.center=t,ft.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ft.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ft.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ft.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*ft.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(let t of this._decorationService.decorations)this._colorZoneStore.addDecoration(t);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!=="full"&&this._renderColorZone(t);for(let t of e)t.position==="full"&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(Ks[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-ft[e.position||"full"]/2),$t[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+ft[e.position||"full"]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};ar=Ce([H(2,Ge),H(3,bi),H(4,Mt),H(5,Ye),H(6,Os),H(7,Pt)],ar);var R;(e=>(e.NUL="\0",e.SOH="",e.STX="",e.ETX="",e.EOT="",e.ENQ="",e.ACK="",e.BEL="\x07",e.BS="\b",e.HT=" ",e.LF=`
193
+ `,e.VT="\v",e.FF="\f",e.CR="\r",e.SO="",e.SI="",e.DLE="",e.DC1="",e.DC2="",e.DC3="",e.DC4="",e.NAK="",e.SYN="",e.ETB="",e.CAN="",e.EM="",e.SUB="",e.ESC="\x1B",e.FS="",e.GS="",e.RS="",e.US="",e.SP=" ",e.DEL=""))(R||(R={}));var Gi;(e=>(e.PAD="€",e.HOP="",e.BPH="‚",e.NBH="ƒ",e.IND="„",e.NEL="…",e.SSA="†",e.ESA="‡",e.HTS="ˆ",e.HTJ="‰",e.VTS="Š",e.PLD="‹",e.PLU="Œ",e.RI="",e.SS2="Ž",e.SS3="",e.DCS="",e.PU1="‘",e.PU2="’",e.STS="“",e.CCH="”",e.MW="•",e.SPA="–",e.EPA="—",e.SOS="˜",e.SGCI="™",e.SCI="š",e.CSI="›",e.ST="œ",e.OSC="",e.PM="ž",e.APC="Ÿ"))(Gi||(Gi={}));var lh;(e=>e.ST=`${R.ESC}\\`)(lh||(lh={}));var Tn=class{constructor(e,t,s,i,n,o){this._textarea=e,this._compositionView=t,this._bufferService=s,this._optionsService=i,this._coreService=n,this._renderService=o,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let s;t.start+=this._dataAlreadySent.length,this._isComposing?s=this._textarea.value.substring(t.start,this._compositionPosition.start):s=this._textarea.value.substring(t.start),s.length>0&&this._coreService.triggerDataEvent(s,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,s=t.replace(e,"");this._dataAlreadySent=s,t.length>e.length?this._coreService.triggerDataEvent(s,!0):t.length<e.length?this._coreService.triggerDataEvent(`${R.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let t=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),s=this._renderService.dimensions.css.cell.height,i=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,n=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=n+"px",this._compositionView.style.top=i+"px",this._compositionView.style.height=s+"px",this._compositionView.style.lineHeight=s+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let o=this._compositionView.getBoundingClientRect();this._textarea.style.left=n+"px",this._textarea.style.top=i+"px",this._textarea.style.width=Math.max(o.width,1)+"px",this._textarea.style.height=Math.max(o.height,1)+"px",this._textarea.style.lineHeight=o.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};Tn=Ce([H(2,Ge),H(3,Ye),H(4,vs),H(5,Mt)],Tn);var Me=0,Le=0,Be=0,we=0,Qa={css:"#00000000",rgba:0},je;(e=>{function t(n,o,a,l){return l!==void 0?`#${Qt(n)}${Qt(o)}${Qt(a)}${Qt(l)}`:`#${Qt(n)}${Qt(o)}${Qt(a)}`}e.toCss=t;function s(n,o,a,l=255){return(n<<24|o<<16|a<<8|l)>>>0}e.toRgba=s;function i(n,o,a,l){return{css:e.toCss(n,o,a,l),rgba:e.toRgba(n,o,a,l)}}e.toColor=i})(je||(je={}));var _e;(e=>{function t(h,c){if(we=(c.rgba&255)/255,we===1)return{css:c.css,rgba:c.rgba};let f=c.rgba>>24&255,p=c.rgba>>16&255,u=c.rgba>>8&255,g=h.rgba>>24&255,m=h.rgba>>16&255,_=h.rgba>>8&255;Me=g+Math.round((f-g)*we),Le=m+Math.round((p-m)*we),Be=_+Math.round((u-_)*we);let x=je.toCss(Me,Le,Be),y=je.toRgba(Me,Le,Be);return{css:x,rgba:y}}e.blend=t;function s(h){return(h.rgba&255)===255}e.isOpaque=s;function i(h,c,f){let p=Yi.ensureContrastRatio(h.rgba,c.rgba,f);if(p)return je.toColor(p>>24&255,p>>16&255,p>>8&255)}e.ensureContrastRatio=i;function n(h){let c=(h.rgba|255)>>>0;return[Me,Le,Be]=Yi.toChannels(c),{css:je.toCss(Me,Le,Be),rgba:c}}e.opaque=n;function o(h,c){return we=Math.round(c*255),[Me,Le,Be]=Yi.toChannels(h.rgba),{css:je.toCss(Me,Le,Be,we),rgba:je.toRgba(Me,Le,Be,we)}}e.opacity=o;function a(h,c){return we=h.rgba&255,o(h,we*c/255)}e.multiplyOpacity=a;function l(h){return[h.rgba>>24&255,h.rgba>>16&255,h.rgba>>8&255]}e.toColorRGB=l})(_e||(_e={}));var Se;(e=>{let t,s;try{let n=document.createElement("canvas");n.width=1,n.height=1;let o=n.getContext("2d",{willReadFrequently:!0});o&&(t=o,t.globalCompositeOperation="copy",s=t.createLinearGradient(0,0,1,1))}catch{}function i(n){if(n.match(/#[\da-f]{3,8}/i))switch(n.length){case 4:return Me=parseInt(n.slice(1,2).repeat(2),16),Le=parseInt(n.slice(2,3).repeat(2),16),Be=parseInt(n.slice(3,4).repeat(2),16),je.toColor(Me,Le,Be);case 5:return Me=parseInt(n.slice(1,2).repeat(2),16),Le=parseInt(n.slice(2,3).repeat(2),16),Be=parseInt(n.slice(3,4).repeat(2),16),we=parseInt(n.slice(4,5).repeat(2),16),je.toColor(Me,Le,Be,we);case 7:return{css:n,rgba:(parseInt(n.slice(1),16)<<8|255)>>>0};case 9:return{css:n,rgba:parseInt(n.slice(1),16)>>>0}}let o=n.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(o)return Me=parseInt(o[1]),Le=parseInt(o[2]),Be=parseInt(o[3]),we=Math.round((o[5]===void 0?1:parseFloat(o[5]))*255),je.toColor(Me,Le,Be,we);if(!t||!s)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=s,t.fillStyle=n,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Me,Le,Be,we]=t.getImageData(0,0,1,1).data,we!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:je.toRgba(Me,Le,Be,we),css:n}}e.toColor=i})(Se||(Se={}));var qe;(e=>{function t(i){return s(i>>16&255,i>>8&255,i&255)}e.relativeLuminance=t;function s(i,n,o){let a=i/255,l=n/255,h=o/255,c=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),f=l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4),p=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4);return c*.2126+f*.7152+p*.0722}e.relativeLuminance2=s})(qe||(qe={}));var Yi;(e=>{function t(a,l){if(we=(l&255)/255,we===1)return l;let h=l>>24&255,c=l>>16&255,f=l>>8&255,p=a>>24&255,u=a>>16&255,g=a>>8&255;return Me=p+Math.round((h-p)*we),Le=u+Math.round((c-u)*we),Be=g+Math.round((f-g)*we),je.toRgba(Me,Le,Be)}e.blend=t;function s(a,l,h){let c=qe.relativeLuminance(a>>8),f=qe.relativeLuminance(l>>8);if(jt(c,f)<h){if(f<c){let g=i(a,l,h),m=jt(c,qe.relativeLuminance(g>>8));if(m<h){let _=n(a,l,h),x=jt(c,qe.relativeLuminance(_>>8));return m>x?g:_}return g}let p=n(a,l,h),u=jt(c,qe.relativeLuminance(p>>8));if(u<h){let g=i(a,l,h),m=jt(c,qe.relativeLuminance(g>>8));return u>m?p:g}return p}}e.ensureContrastRatio=s;function i(a,l,h){let c=a>>24&255,f=a>>16&255,p=a>>8&255,u=l>>24&255,g=l>>16&255,m=l>>8&255,_=jt(qe.relativeLuminance2(u,g,m),qe.relativeLuminance2(c,f,p));for(;_<h&&(u>0||g>0||m>0);)u-=Math.max(0,Math.ceil(u*.1)),g-=Math.max(0,Math.ceil(g*.1)),m-=Math.max(0,Math.ceil(m*.1)),_=jt(qe.relativeLuminance2(u,g,m),qe.relativeLuminance2(c,f,p));return(u<<24|g<<16|m<<8|255)>>>0}e.reduceLuminance=i;function n(a,l,h){let c=a>>24&255,f=a>>16&255,p=a>>8&255,u=l>>24&255,g=l>>16&255,m=l>>8&255,_=jt(qe.relativeLuminance2(u,g,m),qe.relativeLuminance2(c,f,p));for(;_<h&&(u<255||g<255||m<255);)u=Math.min(255,u+Math.ceil((255-u)*.1)),g=Math.min(255,g+Math.ceil((255-g)*.1)),m=Math.min(255,m+Math.ceil((255-m)*.1)),_=jt(qe.relativeLuminance2(u,g,m),qe.relativeLuminance2(c,f,p));return(u<<24|g<<16|m<<8|255)>>>0}e.increaseLuminance=n;function o(a){return[a>>24&255,a>>16&255,a>>8&255,a&255]}e.toChannels=o})(Yi||(Yi={}));function Qt(e){let t=e.toString(16);return t.length<2?"0"+t:t}function jt(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var h_=class extends vi{constructor(e,t,s){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=s}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},lr=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new ht}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let s=[],i=t.translateToString(!0),n=0,o=0,a=0,l=t.getFg(0),h=t.getBg(0);for(let c=0;c<t.getTrimmedLength();c++)if(t.loadCell(c,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==l||this._workCell.bg!==h){if(c-n>1){let f=this._getJoinedRanges(i,a,o,t,n);for(let p=0;p<f.length;p++)s.push(f[p])}n=c,a=o,l=this._workCell.fg,h=this._workCell.bg}o+=this._workCell.getChars().length||Wt.length}if(this._bufferService.cols-n>1){let c=this._getJoinedRanges(i,a,o,t,n);for(let f=0;f<c.length;f++)s.push(c[f])}return s}_getJoinedRanges(e,t,s,i,n){let o=e.substring(t,s),a=[];try{a=this._characterJoiners[0].handler(o)}catch(l){console.error(l)}for(let l=1;l<this._characterJoiners.length;l++)try{let h=this._characterJoiners[l].handler(o);for(let c=0;c<h.length;c++)lr._mergeRanges(a,h[c])}catch(h){console.error(h)}return this._stringRangesToCellRanges(a,i,n),a}_stringRangesToCellRanges(e,t,s){let i=0,n=!1,o=0,a=e[i];if(a){for(let l=s;l<this._bufferService.cols;l++){let h=t.getWidth(l),c=t.getString(l).length||Wt.length;if(h!==0){if(!n&&a[0]<=o&&(a[0]=l,n=!0),a[1]<=o){if(a[1]=l,a=e[++i],!a)break;a[0]<=o?(a[0]=l,n=!0):n=!1}o+=c}}a&&(a[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let s=!1;for(let i=0;i<e.length;i++){let n=e[i];if(s){if(t[1]<=n[0])return e[i-1][1]=t[1],e;if(t[1]<=n[1])return e[i-1][1]=Math.max(t[1],n[1]),e.splice(i,1),e;e.splice(i,1),i--}else{if(t[1]<=n[0])return e.splice(i,0,t),e;if(t[1]<=n[1])return n[0]=Math.min(t[0],n[0]),e;t[0]<n[1]&&(n[0]=Math.min(t[0],n[0]),s=!0);continue}}return s?e[e.length-1][1]=t[1]:e.push(t),e}};lr=Ce([H(0,Ge)],lr);function d_(e){return 57508<=e&&e<=57558}function u_(e){return 9472<=e&&e<=9631}function f_(e){return d_(e)||u_(e)}function m_(){return{css:{canvas:$i(),cell:$i()},device:{canvas:$i(),cell:$i(),char:{width:0,height:0,left:0,top:0}}}}function $i(){return{width:0,height:0}}var zn=class{constructor(e,t,s,i,n,o,a){this._document=e,this._characterJoinerService=t,this._optionsService=s,this._coreBrowserService=i,this._coreService=n,this._decorationService=o,this._themeService=a,this._workCell=new ht,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,s){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=s}createRow(e,t,s,i,n,o,a,l,h,c,f){let p=[],u=this._characterJoinerService.getJoinedCharacters(t),g=this._themeService.colors,m=e.getNoBgTrimmedLength();s&&m<o+1&&(m=o+1);let _,x=0,y="",v=0,j=0,k=0,w=0,N=!1,M=0,U=!1,Y=0,V=0,$=[],P=c!==-1&&f!==-1;for(let E=0;E<m;E++){e.loadCell(E,this._workCell);let B=this._workCell.getWidth();if(B===0)continue;let S=!1,C=E>=V,D=E,L=this._workCell;if(u.length>0&&E===u[0][0]&&C){let K=u.shift(),ne=this._isCellInSelection(K[0],t);for(v=K[0]+1;v<K[1];v++)C&&(C=ne===this._isCellInSelection(v,t));C&&(C=!s||o<K[0]||o>=K[1]),C?(S=!0,L=new h_(this._workCell,e.translateToString(!0,K[0],K[1]),K[1]-K[0]),D=K[1]-1,B=L.getWidth()):V=K[1]}let Z=this._isCellInSelection(E,t),oe=s&&E===o,q=P&&E>=c&&E<=f,J=!1;this._decorationService.forEachDecorationAtCell(E,t,void 0,K=>{J=!0});let se=L.getChars()||Wt;if(se===" "&&(L.isUnderline()||L.isOverline())&&(se=" "),Y=B*l-h.get(se,L.isBold(),L.isItalic()),!_)_=this._document.createElement("span");else if(x&&(Z&&U||!Z&&!U&&L.bg===j)&&(Z&&U&&g.selectionForeground||L.fg===k)&&L.extended.ext===w&&q===N&&Y===M&&!oe&&!S&&!J&&C){L.isInvisible()?y+=Wt:y+=se,x++;continue}else x&&(_.textContent=y),_=this._document.createElement("span"),x=0,y="";if(j=L.bg,k=L.fg,w=L.extended.ext,N=q,M=Y,U=Z,S&&o>=E&&o<=D&&(o=E),!this._coreService.isCursorHidden&&oe&&this._coreService.isCursorInitialized){if($.push("xterm-cursor"),this._coreBrowserService.isFocused)a&&$.push("xterm-cursor-blink"),$.push(i==="bar"?"xterm-cursor-bar":i==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(n)switch(n){case"outline":$.push("xterm-cursor-outline");break;case"block":$.push("xterm-cursor-block");break;case"bar":$.push("xterm-cursor-bar");break;case"underline":$.push("xterm-cursor-underline");break}}if(L.isBold()&&$.push("xterm-bold"),L.isItalic()&&$.push("xterm-italic"),L.isDim()&&$.push("xterm-dim"),L.isInvisible()?y=Wt:y=L.getChars()||Wt,L.isUnderline()&&($.push(`xterm-underline-${L.extended.underlineStyle}`),y===" "&&(y=" "),!L.isUnderlineColorDefault()))if(L.isUnderlineColorRGB())_.style.textDecorationColor=`rgb(${vi.toColorRGB(L.getUnderlineColor()).join(",")})`;else{let K=L.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&L.isBold()&&K<8&&(K+=8),_.style.textDecorationColor=g.ansi[K].css}L.isOverline()&&($.push("xterm-overline"),y===" "&&(y=" ")),L.isStrikethrough()&&$.push("xterm-strikethrough"),q&&(_.style.textDecoration="underline");let de=L.getFgColor(),ue=L.getFgColorMode(),ce=L.getBgColor(),ge=L.getBgColorMode(),Fe=!!L.isInverse();if(Fe){let K=de;de=ce,ce=K;let ne=ue;ue=ge,ge=ne}let z,xe,T=!1;this._decorationService.forEachDecorationAtCell(E,t,void 0,K=>{K.options.layer!=="top"&&T||(K.backgroundColorRGB&&(ge=50331648,ce=K.backgroundColorRGB.rgba>>8&16777215,z=K.backgroundColorRGB),K.foregroundColorRGB&&(ue=50331648,de=K.foregroundColorRGB.rgba>>8&16777215,xe=K.foregroundColorRGB),T=K.options.layer==="top")}),!T&&Z&&(z=this._coreBrowserService.isFocused?g.selectionBackgroundOpaque:g.selectionInactiveBackgroundOpaque,ce=z.rgba>>8&16777215,ge=50331648,T=!0,g.selectionForeground&&(ue=50331648,de=g.selectionForeground.rgba>>8&16777215,xe=g.selectionForeground)),T&&$.push("xterm-decoration-top");let G;switch(ge){case 16777216:case 33554432:G=g.ansi[ce],$.push(`xterm-bg-${ce}`);break;case 50331648:G=je.toColor(ce>>16,ce>>8&255,ce&255),this._addStyle(_,`background-color:#${el((ce>>>0).toString(16),"0",6)}`);break;case 0:default:Fe?(G=g.foreground,$.push("xterm-bg-257")):G=g.background}switch(z||L.isDim()&&(z=_e.multiplyOpacity(G,.5)),ue){case 16777216:case 33554432:L.isBold()&&de<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(de+=8),this._applyMinimumContrast(_,G,g.ansi[de],L,z,void 0)||$.push(`xterm-fg-${de}`);break;case 50331648:let K=je.toColor(de>>16&255,de>>8&255,de&255);this._applyMinimumContrast(_,G,K,L,z,xe)||this._addStyle(_,`color:#${el(de.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(_,G,g.foreground,L,z,xe)||Fe&&$.push("xterm-fg-257")}$.length&&(_.className=$.join(" "),$.length=0),!oe&&!S&&!J&&C?x++:_.textContent=y,Y!==this.defaultSpacing&&(_.style.letterSpacing=`${Y}px`),p.push(_),E=D}return _&&x&&(_.textContent=y),p}_applyMinimumContrast(e,t,s,i,n,o){if(this._optionsService.rawOptions.minimumContrastRatio===1||f_(i.getCode()))return!1;let a=this._getContrastCache(i),l;if(!n&&!o&&(l=a.getColor(t.rgba,s.rgba)),l===void 0){let h=this._optionsService.rawOptions.minimumContrastRatio/(i.isDim()?2:1);l=_e.ensureContrastRatio(n||t,o||s,h),a.setColor((n||t).rgba,(o||s).rgba,l??null)}return l?(this._addStyle(e,`color:${l.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let s=this._selectionStart,i=this._selectionEnd;return!s||!i?!1:this._columnSelectMode?s[0]<=i[0]?e>=s[0]&&t>=s[1]&&e<i[0]&&t<=i[1]:e<s[0]&&t>=s[1]&&e>=i[0]&&t<=i[1]:t>s[1]&&t<i[1]||s[1]===i[1]&&t===s[1]&&e>=s[0]&&e<i[0]||s[1]<i[1]&&t===i[1]&&e<i[0]||s[1]<i[1]&&t===s[1]&&e>=s[0]}};zn=Ce([H(1,Uc),H(2,Ye),H(3,Pt),H(4,vs),H(5,bi),H(6,Os)],zn);function el(e,t,s){for(;e.length<s;)e=t+e;return e}var p_=class{constructor(e,t){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let s=e.createElement("span");s.classList.add("xterm-char-measure-element");let i=e.createElement("span");i.classList.add("xterm-char-measure-element"),i.style.fontWeight="bold";let n=e.createElement("span");n.classList.add("xterm-char-measure-element"),n.style.fontStyle="italic";let o=e.createElement("span");o.classList.add("xterm-char-measure-element"),o.style.fontWeight="bold",o.style.fontStyle="italic",this._measureElements=[s,i,n,o],this._container.appendChild(s),this._container.appendChild(i),this._container.appendChild(n),this._container.appendChild(o),t.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(e,t,s,i){e===this._font&&t===this._fontSize&&s===this._weight&&i===this._weightBold||(this._font=e,this._fontSize=t,this._weight=s,this._weightBold=i,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${s}`,this._measureElements[1].style.fontWeight=`${i}`,this._measureElements[2].style.fontWeight=`${s}`,this._measureElements[3].style.fontWeight=`${i}`,this.clear())}get(e,t,s){let i=0;if(!t&&!s&&e.length===1&&(i=e.charCodeAt(0))<256){if(this._flat[i]!==-9999)return this._flat[i];let a=this._measure(e,0);return a>0&&(this._flat[i]=a),a}let n=e;t&&(n+="B"),s&&(n+="I");let o=this._holey.get(n);if(o===void 0){let a=0;t&&(a|=1),s&&(a|=2),o=this._measure(e,a),o>0&&this._holey.set(n,o)}return o}_measure(e,t){let s=this._measureElements[t];return s.textContent=e.repeat(32),s.offsetWidth/32}},__=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,s,i=!1){if(this.selectionStart=t,this.selectionEnd=s,!t||!s||t[0]===s[0]&&t[1]===s[1]){this.clear();return}let n=e.buffers.active.ydisp,o=t[1]-n,a=s[1]-n,l=Math.max(o,0),h=Math.min(a,e.rows-1);if(l>=e.rows||h<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=i,this.viewportStartRow=o,this.viewportEndRow=a,this.viewportCappedStartRow=l,this.viewportCappedEndRow=h,this.startCol=t[0],this.endCol=s[0]}isCellSelected(e,t,s){return this.hasSelection?(s-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&s>=this.viewportCappedStartRow&&t<this.endCol&&s<=this.viewportCappedEndRow:t<this.startCol&&s>=this.viewportCappedStartRow&&t>=this.endCol&&s<=this.viewportCappedEndRow:s>this.viewportStartRow&&s<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&s===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportStartRow&&t>=this.startCol):!1}};function g_(){return new __}var Hr="xterm-dom-renderer-owner-",at="xterm-rows",Ii="xterm-fg-",tl="xterm-bg-",qs="xterm-focus",Fi="xterm-selection",x_=1,An=class extends re{constructor(e,t,s,i,n,o,a,l,h,c,f,p,u,g){super(),this._terminal=e,this._document=t,this._element=s,this._screenElement=i,this._viewportElement=n,this._helperContainer=o,this._linkifier2=a,this._charSizeService=h,this._optionsService=c,this._bufferService=f,this._coreService=p,this._coreBrowserService=u,this._themeService=g,this._terminalClass=x_++,this._rowElements=[],this._selectionRenderModel=g_(),this.onRequestRedraw=this._register(new O).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(at),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(Fi),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=m_(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(m=>this._injectCss(m))),this._injectCss(this._themeService.colors),this._rowFactory=l.createInstance(zn,document),this._element.classList.add(Hr+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(m=>this._handleLinkHover(m))),this._register(this._linkifier2.onHideLinkUnderline(m=>this._handleLinkLeave(m))),this._register(ve(()=>{this._element.classList.remove(Hr+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new p_(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(let s of this._rowElements)s.style.width=`${this.dimensions.css.canvas.width}px`,s.style.height=`${this.dimensions.css.cell.height}px`,s.style.lineHeight=`${this.dimensions.css.cell.height}px`,s.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${at} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${at} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${at} .xterm-dim { color: ${_e.multiplyOpacity(e.foreground,.5).css};}`,t+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`;let s=`blink_underline_${this._terminalClass}`,i=`blink_bar_${this._terminalClass}`,n=`blink_block_${this._terminalClass}`;t+=`@keyframes ${s} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${i} { 50% { box-shadow: none; }}`,t+=`@keyframes ${n} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${at}.${qs} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${at}.${qs} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${at}.${qs} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${n} 1s step-end infinite;}${this._terminalSelector} .${at} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${at} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${at} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${at} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${at} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${Fi} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${Fi} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${Fi} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[o,a]of e.ansi.entries())t+=`${this._terminalSelector} .${Ii}${o} { color: ${a.css}; }${this._terminalSelector} .${Ii}${o}.xterm-dim { color: ${_e.multiplyOpacity(a,.5).css}; }${this._terminalSelector} .${tl}${o} { background-color: ${a.css}; }`;t+=`${this._terminalSelector} .${Ii}257 { color: ${_e.opaque(e.background).css}; }${this._terminalSelector} .${Ii}257.xterm-dim { color: ${_e.multiplyOpacity(_e.opaque(e.background),.5).css}; }${this._terminalSelector} .${tl}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let s=this._rowElements.length;s<=t;s++){let i=this._document.createElement("div");this._rowContainer.appendChild(i),this._rowElements.push(i)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(qs),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(qs),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,s){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,s),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,s),!this._selectionRenderModel.hasSelection))return;let i=this._selectionRenderModel.viewportStartRow,n=this._selectionRenderModel.viewportEndRow,o=this._selectionRenderModel.viewportCappedStartRow,a=this._selectionRenderModel.viewportCappedEndRow,l=this._document.createDocumentFragment();if(s){let h=e[0]>t[0];l.appendChild(this._createSelectionElement(o,h?t[0]:e[0],h?e[0]:t[0],a-o+1))}else{let h=i===o?e[0]:0,c=o===n?t[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(o,h,c));let f=a-o-1;if(l.appendChild(this._createSelectionElement(o+1,0,this._bufferService.cols,f)),o!==a){let p=n===a?t[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(a,0,p))}}this._selectionContainer.appendChild(l)}_createSelectionElement(e,t,s,i=1){let n=this._document.createElement("div"),o=t*this.dimensions.css.cell.width,a=this.dimensions.css.cell.width*(s-t);return o+a>this.dimensions.css.canvas.width&&(a=this.dimensions.css.canvas.width-o),n.style.height=`${i*this.dimensions.css.cell.height}px`,n.style.top=`${e*this.dimensions.css.cell.height}px`,n.style.left=`${o}px`,n.style.width=`${a}px`,n}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let s=this._bufferService.buffer,i=s.ybase+s.y,n=Math.min(s.x,this._bufferService.cols-1),o=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,a=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,l=this._optionsService.rawOptions.cursorInactiveStyle;for(let h=e;h<=t;h++){let c=h+s.ydisp,f=this._rowElements[h],p=s.lines.get(c);if(!f||!p)break;f.replaceChildren(...this._rowFactory.createRow(p,c,c===i,a,l,n,o,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${Hr}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,s,i,n,o){s<0&&(e=0),i<0&&(t=0);let a=this._bufferService.rows-1;s=Math.max(Math.min(s,a),0),i=Math.max(Math.min(i,a),0),n=Math.min(n,this._bufferService.cols);let l=this._bufferService.buffer,h=l.ybase+l.y,c=Math.min(l.x,n-1),f=this._optionsService.rawOptions.cursorBlink,p=this._optionsService.rawOptions.cursorStyle,u=this._optionsService.rawOptions.cursorInactiveStyle;for(let g=s;g<=i;++g){let m=g+l.ydisp,_=this._rowElements[g],x=l.lines.get(m);if(!_||!x)break;_.replaceChildren(...this._rowFactory.createRow(x,m,m===h,p,u,c,f,this.dimensions.css.cell.width,this._widthCache,o?g===s?e:0:-1,o?(g===i?t:n)-1:-1))}}};An=Ce([H(7,go),H(8,yr),H(9,Ye),H(10,Ge),H(11,vs),H(12,Pt),H(13,Os)],An);var On=class extends re{constructor(e,t,s){super(),this._optionsService=s,this.width=0,this.height=0,this._onCharSizeChange=this._register(new O),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new b_(this._optionsService))}catch{this._measureStrategy=this._register(new v_(e,t,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};On=Ce([H(2,Ye)],On);var ch=class extends re{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},v_=class extends ch{constructor(e,t,s){super(),this._document=e,this._parentElement=t,this._optionsService=s,this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},b_=class extends ch{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let t=this._ctx.measureText("W");if(!("width"in t&&"fontBoundingBoxAscent"in t&&"fontBoundingBoxDescent"in t))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText("W");return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},y_=class extends re{constructor(e,t,s){super(),this._textarea=e,this._window=t,this.mainDocument=s,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new S_(this._window)),this._onDprChange=this._register(new O),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new O),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(i=>this._screenDprMonitor.setWindow(i))),this._register($e.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(X(this._textarea,"focus",()=>this._isFocused=!0)),this._register(X(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask(()=>this._cachedIsFocused=void 0)),this._cachedIsFocused}},S_=class extends re{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new As),this._onDprChange=this._register(new O),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(ve(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=X(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var e;this._outerListener&&((e=this._resolutionMediaMatchList)==null||e.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){!this._resolutionMediaMatchList||!this._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},w_=class extends re{constructor(){super(),this.linkProviders=[],this._register(ve(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};function ko(e,t,s){let i=s.getBoundingClientRect(),n=e.getComputedStyle(s),o=parseInt(n.getPropertyValue("padding-left")),a=parseInt(n.getPropertyValue("padding-top"));return[t.clientX-i.left-o,t.clientY-i.top-a]}function C_(e,t,s,i,n,o,a,l,h){if(!o)return;let c=ko(e,t,s);if(c)return c[0]=Math.ceil((c[0]+(h?a/2:0))/a),c[1]=Math.ceil(c[1]/l),c[0]=Math.min(Math.max(c[0],1),i+(h?1:0)),c[1]=Math.min(Math.max(c[1],1),n),c}var $n=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,s,i,n){return C_(window,e,t,s,i,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,n)}getMouseReportCoords(e,t){let s=ko(window,e,t);if(this._charSizeService.hasValidSize)return s[0]=Math.min(Math.max(s[0],0),this._renderService.dimensions.css.canvas.width-1),s[1]=Math.min(Math.max(s[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(s[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(s[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(s[0]),y:Math.floor(s[1])}}};$n=Ce([H(0,Mt),H(1,yr)],$n);var k_=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,t,s){this._rowCount=s,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},hh={};Tm(hh,{getSafariVersion:()=>j_,isChromeOS:()=>mh,isFirefox:()=>dh,isIpad:()=>E_,isIphone:()=>D_,isLegacyEdge:()=>N_,isLinux:()=>No,isMac:()=>cr,isNode:()=>Sr,isSafari:()=>uh,isWindows:()=>fh});var Sr=typeof process<"u"&&"title"in process,yi=Sr?"node":navigator.userAgent,Si=Sr?"node":navigator.platform,dh=yi.includes("Firefox"),N_=yi.includes("Edge"),uh=/^((?!chrome|android).)*safari/i.test(yi);function j_(){if(!uh)return 0;let e=yi.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var cr=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Si),E_=Si==="iPad",D_=Si==="iPhone",fh=["Windows","Win16","Win32","WinCE"].includes(Si),No=Si.indexOf("Linux")>=0,mh=/\bCrOS\b/.test(yi),ph=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(e){this._idleCallback=void 0;let t=0,s=0,i=e.timeRemaining(),n=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),s=Math.max(t,s),n=e.timeRemaining(),s*1.5>n){i-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(i-t))}ms`),this._start();return}i=n}this.clear()}},R_=class extends ph{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},P_=class extends ph{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},hr=!Sr&&"requestIdleCallback"in window?P_:R_,M_=class{constructor(){this._queue=new hr}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},In=class extends re{constructor(e,t,s,i,n,o,a,l,h){super(),this._rowCount=e,this._optionsService=s,this._charSizeService=i,this._coreService=n,this._coreBrowserService=l,this._renderer=this._register(new As),this._pausedResizeTask=new M_,this._observerDisposable=this._register(new As),this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this._register(new O),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new O),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new O),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new O),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new k_((c,f)=>this._renderRows(c,f),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new L_(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(ve(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(a.onResize(()=>this._fullRefresh())),this._register(a.buffers.onBufferActivate(()=>{var c;return(c=this._renderer.value)==null?void 0:c.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(o.onDecorationRegistered(()=>this._fullRefresh())),this._register(o.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(a.cols,a.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(a.buffer.y,a.buffer.y,!0))),this._register(h.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(c=>this._registerIntersectionObserver(c,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let s=new e.IntersectionObserver(i=>this._handleIntersectionChange(i[i.length-1]),{threshold:0});s.observe(t),this._observerDisposable.value=ve(()=>s.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.isIntersecting,!this._isPaused&&!this._charSizeService.hasValidSize&&this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(e,t,s=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let i=this._syncOutputHandler.flush();i&&(e=Math.min(e,i.start),t=Math.max(t,i.end)),s||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var e,t;this._renderer.value&&((t=(e=this._renderer.value).clearTextureAtlas)==null||t.call(e),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>{var s;return(s=this._renderer.value)==null?void 0:s.handleResize(e,t)}):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){var e;(e=this._renderer.value)==null||e.handleCharSizeChanged()}handleBlur(){var e;(e=this._renderer.value)==null||e.handleBlur()}handleFocus(){var e;(e=this._renderer.value)==null||e.handleFocus()}handleSelectionChanged(e,t,s){var i;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=s,(i=this._renderer.value)==null||i.handleSelectionChanged(e,t,s)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};In=Ce([H(2,Ye),H(3,yr),H(4,vs),H(5,bi),H(6,Ge),H(7,Pt),H(8,Os)],In);var L_=class{constructor(e,t,s){this._coreBrowserService=e,this._coreService=t,this._onTimeout=s,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function B_(e,t,s,i){let n=s.buffer.x,o=s.buffer.y;if(!s.buffer.hasScrollback)return A_(n,o,e,t,s,i)+wr(o,t,s,i)+O_(n,o,e,t,s,i);let a;if(o===t)return a=n>e?"D":"C",mi(Math.abs(n-e),fi(a,i));a=o>t?"D":"C";let l=Math.abs(o-t),h=z_(o>t?e:n,s)+(l-1)*s.cols+1+T_(o>t?n:e);return mi(h,fi(a,i))}function T_(e,t){return e-1}function z_(e,t){return t.cols-e}function A_(e,t,s,i,n,o){return wr(t,i,n,o).length===0?"":mi(gh(e,t,e,t-fs(t,n),!1,n).length,fi("D",o))}function wr(e,t,s,i){let n=e-fs(e,s),o=t-fs(t,s),a=Math.abs(n-o)-$_(e,t,s);return mi(a,fi(_h(e,t),i))}function O_(e,t,s,i,n,o){let a;wr(t,i,n,o).length>0?a=i-fs(i,n):a=t;let l=i,h=I_(e,t,s,i,n,o);return mi(gh(e,a,s,l,h==="C",n).length,fi(h,o))}function $_(e,t,s){var a;let i=0,n=e-fs(e,s),o=t-fs(t,s);for(let l=0;l<Math.abs(n-o);l++){let h=_h(e,t)==="A"?-1:1;(a=s.buffer.lines.get(n+h*l))!=null&&a.isWrapped&&i++}return i}function fs(e,t){let s=0,i=t.buffer.lines.get(e),n=i==null?void 0:i.isWrapped;for(;n&&e>=0&&e<t.rows;)s++,i=t.buffer.lines.get(--e),n=i==null?void 0:i.isWrapped;return s}function I_(e,t,s,i,n,o){let a;return wr(s,i,n,o).length>0?a=i-fs(i,n):a=t,e<s&&a<=i||e>=s&&a<i?"C":"D"}function _h(e,t){return e>t?"A":"B"}function gh(e,t,s,i,n,o){let a=e,l=t,h="";for(;(a!==s||l!==i)&&l>=0&&l<o.buffer.lines.length;)a+=n?1:-1,n&&a>o.cols-1?(h+=o.buffer.translateBufferLineToString(l,!1,e,a),a=0,e=0,l++):!n&&a<0&&(h+=o.buffer.translateBufferLineToString(l,!1,0,e+1),a=o.cols-1,e=a,l--);return h+o.buffer.translateBufferLineToString(l,!1,e,a)}function fi(e,t){let s=t?"O":"[";return R.ESC+s+e}function mi(e,t){e=Math.floor(e);let s="";for(let i=0;i<e;i++)s+=t;return s}var F_=class{constructor(e){this._bufferService=e,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:!this.selectionEnd||!this.selectionStart?this.selectionStart:this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function sl(e,t){if(e.start.y>e.end.y)throw new Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var Wr=50,H_=15,W_=50,U_=500,K_=" ",q_=new RegExp(K_,"g"),Fn=class extends re{constructor(e,t,s,i,n,o,a,l,h){super(),this._element=e,this._screenElement=t,this._linkifier=s,this._bufferService=i,this._coreService=n,this._mouseService=o,this._optionsService=a,this._renderService=l,this._coreBrowserService=h,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new ht,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new O),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new O),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new O),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new O),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=c=>this._handleMouseMove(c),this._mouseUpListener=c=>this._handleMouseUp(c),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(c=>this._handleTrim(c)),this._register(this._bufferService.buffers.onBufferActivate(c=>this._handleBufferActivate(c))),this.enable(),this._model=new F_(this._bufferService),this._activeSelectionMode=0,this._register(ve(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(c=>{c.rowsChanged&&this.clearSelection()}))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let s=this._bufferService.buffer,i=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let n=e[0]<t[0]?e[0]:t[0],o=e[0]<t[0]?t[0]:e[0];for(let a=e[1];a<=t[1];a++){let l=s.translateBufferLineToString(a,!0,n,o);i.push(l)}}else{let n=e[1]===t[1]?t[0]:void 0;i.push(s.translateBufferLineToString(e[1],!0,e[0],n));for(let o=e[1]+1;o<=t[1]-1;o++){let a=s.lines.get(o),l=s.translateBufferLineToString(o,!0);a!=null&&a.isWrapped?i[i.length-1]+=l:i.push(l)}if(e[1]!==t[1]){let o=s.lines.get(t[1]),a=s.translateBufferLineToString(t[1],!0,0,t[0]);o&&o.isWrapped?i[i.length-1]+=a:i.push(a)}}return i.map(n=>n.replace(q_," ")).join(fh?`\r
194
+ `:`
195
+ `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),No&&e&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(e){let t=this._getMouseBufferCoords(e),s=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!s||!i||!t?!1:this._areCoordsInSelection(t,s,i)}isCellInSelection(e,t){let s=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!s||!i?!1:this._areCoordsInSelection([e,t],s,i)}_areCoordsInSelection(e,t,s){return e[1]>t[1]&&e[1]<s[1]||t[1]===s[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<s[0]||t[1]<s[1]&&e[1]===s[1]&&e[0]<s[0]||t[1]<s[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){var n,o;let s=(o=(n=this._linkifier.currentLink)==null?void 0:n.link)==null?void 0:o.range;if(s)return this._model.selectionStart=[s.start.x-1,s.start.y-1],this._model.selectionStartLength=sl(s,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let i=this._getMouseBufferCoords(e);return i?(this._selectWordAt(i,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=ko(this._coreBrowserService.window,e,this._screenElement)[1],s=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=s?0:(t>s&&(t-=s),t=Math.min(Math.max(t,-Wr),Wr),t/=Wr,t/Math.abs(t)+Math.round(t*(H_-1)))}shouldForceSelection(e){return cr?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval(()=>this._dragScroll(),W_)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(cr&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let s=this._bufferService.buffer;if(this._model.selectionEnd[1]<s.lines.length){let i=s.lines.get(this._model.selectionEnd[1]);i&&i.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[1]!==this._model.selectionEnd[1])&&this.refresh(!0)}_dragScroll(){if(!(!this._model.selectionEnd||!this._model.selectionStart)&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<U_&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let s=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(s&&s[0]!==void 0&&s[1]!==void 0){let i=B_(s[0]-1,s[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(i,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,s=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!s){this._oldHasSelection&&this._fireOnSelectionChange(e,t,s);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,s)}_fireOnSelectionChange(e,t,s){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=s,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let s=t;for(let i=0;t>=i;i++){let n=e.loadCell(i,this._workCell).getChars().length;this._workCell.getWidth()===0?s--:n>1&&t!==i&&(s+=n-1)}return s}setSelection(e,t,s){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=s,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,s=!0,i=!0){if(e[0]>=this._bufferService.cols)return;let n=this._bufferService.buffer,o=n.lines.get(e[1]);if(!o)return;let a=n.translateBufferLineToString(e[1],!1),l=this._convertViewportColToCharacterIndex(o,e[0]),h=l,c=e[0]-l,f=0,p=0,u=0,g=0;if(a.charAt(l)===" "){for(;l>0&&a.charAt(l-1)===" ";)l--;for(;h<a.length&&a.charAt(h+1)===" ";)h++}else{let x=e[0],y=e[0];o.getWidth(x)===0&&(f++,x--),o.getWidth(y)===2&&(p++,y++);let v=o.getString(y).length;for(v>1&&(g+=v-1,h+=v-1);x>0&&l>0&&!this._isCharWordSeparator(o.loadCell(x-1,this._workCell));){o.loadCell(x-1,this._workCell);let j=this._workCell.getChars().length;this._workCell.getWidth()===0?(f++,x--):j>1&&(u+=j-1,l-=j-1),l--,x--}for(;y<o.length&&h+1<a.length&&!this._isCharWordSeparator(o.loadCell(y+1,this._workCell));){o.loadCell(y+1,this._workCell);let j=this._workCell.getChars().length;this._workCell.getWidth()===2?(p++,y++):j>1&&(g+=j-1,h+=j-1),h++,y++}}h++;let m=l+c-f+u,_=Math.min(this._bufferService.cols,h-l+f+p-u-g);if(!(!t&&a.slice(l,h).trim()==="")){if(s&&m===0&&o.getCodePoint(0)!==32){let x=n.lines.get(e[1]-1);if(x&&o.isWrapped&&x.getCodePoint(this._bufferService.cols-1)!==32){let y=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(y){let v=this._bufferService.cols-y.start;m-=v,_+=v}}}if(i&&m+_===this._bufferService.cols&&o.getCodePoint(this._bufferService.cols-1)!==32){let x=n.lines.get(e[1]+1);if(x!=null&&x.isWrapped&&x.getCodePoint(0)!==32){let y=this._getWordAt([0,e[1]+1],!1,!1,!0);y&&(_+=y.length)}}return{start:m,length:_}}}_selectWordAt(e,t){let s=this._getWordAt(e,t);if(s){for(;s.start<0;)s.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[s.start,e[1]],this._model.selectionStartLength=s.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let s=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,s--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,s++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,s]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),s={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=sl(s,this._bufferService.cols)}};Fn=Ce([H(3,Ge),H(4,vs),H(5,xo),H(6,Ye),H(7,Mt),H(8,Pt)],Fn);var il=class{constructor(){this._data={}}set(e,t,s){this._data[e]||(this._data[e]={}),this._data[e][t]=s}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},rl=class{constructor(){this._color=new il,this._css=new il}setCss(e,t,s){this._css.set(e,t,s)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,s){this._color.set(e,t,s)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},Ee=Object.freeze((()=>{let e=[Se.toColor("#2e3436"),Se.toColor("#cc0000"),Se.toColor("#4e9a06"),Se.toColor("#c4a000"),Se.toColor("#3465a4"),Se.toColor("#75507b"),Se.toColor("#06989a"),Se.toColor("#d3d7cf"),Se.toColor("#555753"),Se.toColor("#ef2929"),Se.toColor("#8ae234"),Se.toColor("#fce94f"),Se.toColor("#729fcf"),Se.toColor("#ad7fa8"),Se.toColor("#34e2e2"),Se.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let s=0;s<216;s++){let i=t[s/36%6|0],n=t[s/6%6|0],o=t[s%6];e.push({css:je.toCss(i,n,o),rgba:je.toRgba(i,n,o)})}for(let s=0;s<24;s++){let i=8+s*10;e.push({css:je.toCss(i,i,i),rgba:je.toRgba(i,i,i)})}return e})()),ts=Se.toColor("#ffffff"),si=Se.toColor("#000000"),nl=Se.toColor("#ffffff"),ol=si,Vs={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},V_=ts,Hn=class extends re{constructor(e){super(),this._optionsService=e,this._contrastCache=new rl,this._halfContrastCache=new rl,this._onChangeColors=this._register(new O),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:ts,background:si,cursor:nl,cursorAccent:ol,selectionForeground:void 0,selectionBackgroundTransparent:Vs,selectionBackgroundOpaque:_e.blend(si,Vs),selectionInactiveBackgroundTransparent:Vs,selectionInactiveBackgroundOpaque:_e.blend(si,Vs),scrollbarSliderBackground:_e.opacity(ts,.2),scrollbarSliderHoverBackground:_e.opacity(ts,.4),scrollbarSliderActiveBackground:_e.opacity(ts,.5),overviewRulerBorder:ts,ansi:Ee.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this._register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",()=>this._contrastCache.clear())),this._register(this._optionsService.onSpecificOptionChange("theme",()=>this._setTheme(this._optionsService.rawOptions.theme)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=fe(e.foreground,ts),t.background=fe(e.background,si),t.cursor=_e.blend(t.background,fe(e.cursor,nl)),t.cursorAccent=_e.blend(t.background,fe(e.cursorAccent,ol)),t.selectionBackgroundTransparent=fe(e.selectionBackground,Vs),t.selectionBackgroundOpaque=_e.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=fe(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=_e.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?fe(e.selectionForeground,Qa):void 0,t.selectionForeground===Qa&&(t.selectionForeground=void 0),_e.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=_e.opacity(t.selectionBackgroundTransparent,.3)),_e.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=_e.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=fe(e.scrollbarSliderBackground,_e.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=fe(e.scrollbarSliderHoverBackground,_e.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=fe(e.scrollbarSliderActiveBackground,_e.opacity(t.foreground,.5)),t.overviewRulerBorder=fe(e.overviewRulerBorder,V_),t.ansi=Ee.slice(),t.ansi[0]=fe(e.black,Ee[0]),t.ansi[1]=fe(e.red,Ee[1]),t.ansi[2]=fe(e.green,Ee[2]),t.ansi[3]=fe(e.yellow,Ee[3]),t.ansi[4]=fe(e.blue,Ee[4]),t.ansi[5]=fe(e.magenta,Ee[5]),t.ansi[6]=fe(e.cyan,Ee[6]),t.ansi[7]=fe(e.white,Ee[7]),t.ansi[8]=fe(e.brightBlack,Ee[8]),t.ansi[9]=fe(e.brightRed,Ee[9]),t.ansi[10]=fe(e.brightGreen,Ee[10]),t.ansi[11]=fe(e.brightYellow,Ee[11]),t.ansi[12]=fe(e.brightBlue,Ee[12]),t.ansi[13]=fe(e.brightMagenta,Ee[13]),t.ansi[14]=fe(e.brightCyan,Ee[14]),t.ansi[15]=fe(e.brightWhite,Ee[15]),e.extendedAnsi){let s=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let i=0;i<s;i++)t.ansi[i+16]=fe(e.extendedAnsi[i],Ee[i+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(e){this._restoreColor(e),this._onChangeColors.fire(this.colors)}_restoreColor(e){if(e===void 0){for(let t=0;t<this._restoreColors.ansi.length;++t)this._colors.ansi[t]=this._restoreColors.ansi[t];return}switch(e){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[e]=this._restoreColors.ansi[e]}}modifyColors(e){e(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};Hn=Ce([H(0,Ye)],Hn);function fe(e,t){if(e!==void 0)try{return Se.toColor(e)}catch{}return t}var G_=class{constructor(...e){this._entries=new Map;for(let[t,s]of e)this.set(t,s)}set(e,t){let s=this._entries.get(e);return this._entries.set(e,t),s}forEach(e){for(let[t,s]of this._entries.entries())e(t,s)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},Y_=class{constructor(){this._services=new G_,this._services.set(go,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let s=Hm(e).sort((o,a)=>o.index-a.index),i=[];for(let o of s){let a=this._services.get(o.id);if(!a)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${o.id._id}.`);i.push(a)}let n=s.length>0?s[0].index:t.length;if(t.length!==n)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${n+1} conflicts with ${t.length} static arguments`);return new e(...t,...i)}},X_={trace:0,debug:1,info:2,warn:3,error:4,off:5},J_="xterm.js: ",Wn=class extends re{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=X_[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]=="function"&&(e[t]=e[t]())}_log(e,t,s){this._evalLazyOptionalParams(s),e.call(console,(this._optionsService.options.logger?"":J_)+t,...s)}trace(e,...t){var s;this._logLevel<=0&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.trace.bind(this._optionsService.options.logger))??console.log,e,t)}debug(e,...t){var s;this._logLevel<=1&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.debug.bind(this._optionsService.options.logger))??console.log,e,t)}info(e,...t){var s;this._logLevel<=2&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.info.bind(this._optionsService.options.logger))??console.info,e,t)}warn(e,...t){var s;this._logLevel<=3&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.warn.bind(this._optionsService.options.logger))??console.warn,e,t)}error(e,...t){var s;this._logLevel<=4&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.error.bind(this._optionsService.options.logger))??console.error,e,t)}};Wn=Ce([H(0,Ye)],Wn);var al=class extends re{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new O),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new O),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new O),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=new Array(e);for(let s=0;s<Math.min(e,this.length);s++)t[s]=this._array[this._getCyclicIndex(s)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(e,t,...s){if(t){for(let i=e;i<this._length-t;i++)this._array[this._getCyclicIndex(i)]=this._array[this._getCyclicIndex(i+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let i=this._length-1;i>=e;i--)this._array[this._getCyclicIndex(i+s.length)]=this._array[this._getCyclicIndex(i)];for(let i=0;i<s.length;i++)this._array[this._getCyclicIndex(e+i)]=s[i];if(s.length&&this.onInsertEmitter.fire({index:e,amount:s.length}),this._length+s.length>this._maxLength){let i=this._length+s.length-this._maxLength;this._startIndex+=i,this._length=this._maxLength,this.onTrimEmitter.fire(i)}else this._length+=s.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,s){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+s<0)throw new Error("Cannot shift elements in list beyond index 0");if(s>0){for(let n=t-1;n>=0;n--)this.set(e+n+s,this.get(e+n));let i=e+t+s-this._length;if(i>0)for(this._length+=i;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let i=0;i<t;i++)this.set(e+i+s,this.get(e+i))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},ie=3,Ne=Object.freeze(new vi),Hi=0,Ur=2,ii=class xh{constructor(t,s,i=!1){this.isWrapped=i,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*ie);let n=s||ht.fromCharData([0,Ac,1,0]);for(let o=0;o<t;++o)this.setCell(o,n);this.length=t}get(t){let s=this._data[t*ie+0],i=s&2097151;return[this._data[t*ie+1],s&2097152?this._combined[t]:i?Ft(i):"",s>>22,s&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):i]}set(t,s){this._data[t*ie+1]=s[0],s[1].length>1?(this._combined[t]=s[1],this._data[t*ie+0]=t|2097152|s[2]<<22):this._data[t*ie+0]=s[1].charCodeAt(0)|s[2]<<22}getWidth(t){return this._data[t*ie+0]>>22}hasWidth(t){return this._data[t*ie+0]&12582912}getFg(t){return this._data[t*ie+1]}getBg(t){return this._data[t*ie+2]}hasContent(t){return this._data[t*ie+0]&4194303}getCodePoint(t){let s=this._data[t*ie+0];return s&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s&2097151}isCombined(t){return this._data[t*ie+0]&2097152}getString(t){let s=this._data[t*ie+0];return s&2097152?this._combined[t]:s&2097151?Ft(s&2097151):""}isProtected(t){return this._data[t*ie+2]&536870912}loadCell(t,s){return Hi=t*ie,s.content=this._data[Hi+0],s.fg=this._data[Hi+1],s.bg=this._data[Hi+2],s.content&2097152&&(s.combinedData=this._combined[t]),s.bg&268435456&&(s.extended=this._extendedAttrs[t]),s}setCell(t,s){s.content&2097152&&(this._combined[t]=s.combinedData),s.bg&268435456&&(this._extendedAttrs[t]=s.extended),this._data[t*ie+0]=s.content,this._data[t*ie+1]=s.fg,this._data[t*ie+2]=s.bg}setCellFromCodepoint(t,s,i,n){n.bg&268435456&&(this._extendedAttrs[t]=n.extended),this._data[t*ie+0]=s|i<<22,this._data[t*ie+1]=n.fg,this._data[t*ie+2]=n.bg}addCodepointToCell(t,s,i){let n=this._data[t*ie+0];n&2097152?this._combined[t]+=Ft(s):n&2097151?(this._combined[t]=Ft(n&2097151)+Ft(s),n&=-2097152,n|=2097152):n=s|1<<22,i&&(n&=-12582913,n|=i<<22),this._data[t*ie+0]=n}insertCells(t,s,i){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,i),s<this.length-t){let n=new ht;for(let o=this.length-t-s-1;o>=0;--o)this.setCell(t+s+o,this.loadCell(t+o,n));for(let o=0;o<s;++o)this.setCell(t+o,i)}else for(let n=t;n<this.length;++n)this.setCell(n,i);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,i)}deleteCells(t,s,i){if(t%=this.length,s<this.length-t){let n=new ht;for(let o=0;o<this.length-t-s;++o)this.setCell(t+o,this.loadCell(t+s+o,n));for(let o=this.length-s;o<this.length;++o)this.setCell(o,i)}else for(let n=t;n<this.length;++n)this.setCell(n,i);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,i),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,i)}replaceCells(t,s,i,n=!1){if(n){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,i),s<this.length&&this.getWidth(s-1)===2&&!this.isProtected(s)&&this.setCellFromCodepoint(s,0,1,i);t<s&&t<this.length;)this.isProtected(t)||this.setCell(t,i),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,i),s<this.length&&this.getWidth(s-1)===2&&this.setCellFromCodepoint(s,0,1,i);t<s&&t<this.length;)this.setCell(t++,i)}resize(t,s){if(t===this.length)return this._data.length*4*Ur<this._data.buffer.byteLength;let i=t*ie;if(t>this.length){if(this._data.buffer.byteLength>=i*4)this._data=new Uint32Array(this._data.buffer,0,i);else{let n=new Uint32Array(i);n.set(this._data),this._data=n}for(let n=this.length;n<t;++n)this.setCell(n,s)}else{this._data=this._data.subarray(0,i);let n=Object.keys(this._combined);for(let a=0;a<n.length;a++){let l=parseInt(n[a],10);l>=t&&delete this._combined[l]}let o=Object.keys(this._extendedAttrs);for(let a=0;a<o.length;a++){let l=parseInt(o[a],10);l>=t&&delete this._extendedAttrs[l]}}return this.length=t,i*4*Ur<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*Ur<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,s=!1){if(s){for(let i=0;i<this.length;++i)this.isProtected(i)||this.setCell(i,t);return}this._combined={},this._extendedAttrs={};for(let i=0;i<this.length;++i)this.setCell(i,t)}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let s in t._combined)this._combined[s]=t._combined[s];this._extendedAttrs={};for(let s in t._extendedAttrs)this._extendedAttrs[s]=t._extendedAttrs[s];this.isWrapped=t.isWrapped}clone(){let t=new xh(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let s in this._combined)t._combined[s]=this._combined[s];for(let s in this._extendedAttrs)t._extendedAttrs[s]=this._extendedAttrs[s];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*ie+0]&4194303)return t+(this._data[t*ie+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*ie+0]&4194303||this._data[t*ie+2]&50331648)return t+(this._data[t*ie+0]>>22);return 0}copyCellsFrom(t,s,i,n,o){let a=t._data;if(o)for(let h=n-1;h>=0;h--){for(let c=0;c<ie;c++)this._data[(i+h)*ie+c]=a[(s+h)*ie+c];a[(s+h)*ie+2]&268435456&&(this._extendedAttrs[i+h]=t._extendedAttrs[s+h])}else for(let h=0;h<n;h++){for(let c=0;c<ie;c++)this._data[(i+h)*ie+c]=a[(s+h)*ie+c];a[(s+h)*ie+2]&268435456&&(this._extendedAttrs[i+h]=t._extendedAttrs[s+h])}let l=Object.keys(t._combined);for(let h=0;h<l.length;h++){let c=parseInt(l[h],10);c>=s&&(this._combined[c-s+i]=t._combined[c])}}translateToString(t,s,i,n){s=s??0,i=i??this.length,t&&(i=Math.min(i,this.getTrimmedLength())),n&&(n.length=0);let o="";for(;s<i;){let a=this._data[s*ie+0],l=a&2097151,h=a&2097152?this._combined[s]:l?Ft(l):Wt;if(o+=h,n)for(let c=0;c<h.length;++c)n.push(s);s+=a>>22||1}return n&&n.push(s),o}};function Z_(e,t,s,i,n,o){let a=[];for(let l=0;l<e.length-1;l++){let h=l,c=e.get(++h);if(!c.isWrapped)continue;let f=[e.get(l)];for(;h<e.length&&c.isWrapped;)f.push(c),c=e.get(++h);if(!o&&i>=l&&i<h){l+=f.length-1;continue}let p=0,u=pi(f,p,t),g=1,m=0;for(;g<f.length;){let x=pi(f,g,t),y=x-m,v=s-u,j=Math.min(y,v);f[p].copyCellsFrom(f[g],m,u,j,!1),u+=j,u===s&&(p++,u=0),m+=j,m===x&&(g++,m=0),u===0&&p!==0&&f[p-1].getWidth(s-1)===2&&(f[p].copyCellsFrom(f[p-1],s-1,u++,1,!1),f[p-1].setCell(s-1,n))}f[p].replaceCells(u,s,n);let _=0;for(let x=f.length-1;x>0&&(x>p||f[x].getTrimmedLength()===0);x--)_++;_>0&&(a.push(l+f.length-_),a.push(_)),l+=f.length-1}return a}function Q_(e,t){let s=[],i=0,n=t[i],o=0;for(let a=0;a<e.length;a++)if(n===a){let l=t[++i];e.onDeleteEmitter.fire({index:a-o,amount:l}),a+=l-1,o+=l,n=t[++i]}else s.push(a);return{layout:s,countRemoved:o}}function eg(e,t){let s=[];for(let i=0;i<t.length;i++)s.push(e.get(t[i]));for(let i=0;i<s.length;i++)e.set(i,s[i]);e.length=t.length}function tg(e,t,s){let i=[],n=e.map((h,c)=>pi(e,c,t)).reduce((h,c)=>h+c),o=0,a=0,l=0;for(;l<n;){if(n-l<s){i.push(n-l);break}o+=s;let h=pi(e,a,t);o>h&&(o-=h,a++);let c=e[a].getWidth(o-1)===2;c&&o--;let f=c?s-1:s;i.push(f),l+=f}return i}function pi(e,t,s){if(t===e.length-1)return e[t].getTrimmedLength();let i=!e[t].hasContent(s-1)&&e[t].getWidth(s-1)===1,n=e[t+1].getWidth(0)===2;return i&&n?s-1:s}var vh=class bh{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=bh._nextId++,this._onDispose=this.register(new O),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),us(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};vh._nextId=1;var sg=vh,Re={},ss=Re.B;Re[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"␤",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"};Re.A={"#":"£"};Re.B=void 0;Re[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Re.C=Re[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Re.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Re.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Re.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Re.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Re.E=Re[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Re.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Re.H=Re[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Re["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var ll=4294967295,cl=class{constructor(e,t,s){this._hasScrollback=e,this._optionsService=t,this._bufferService=s,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=Ne.clone(),this.savedCharset=ss,this.markers=[],this._nullCell=ht.fromCharData([0,Ac,1,0]),this._whitespaceCell=ht.fromCharData([0,Wt,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new hr,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new al(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new or),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new or),this._whitespaceCell}getBlankLine(e,t){return new ii(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let t=e+this._optionsService.rawOptions.scrollback;return t>ll?ll:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=Ne);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new al(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let s=this.getNullCell(Ne),i=0,n=this._getCorrectBufferLength(t);if(n>this.lines.maxLength&&(this.lines.maxLength=n),this.lines.length>0){if(this._cols<e)for(let a=0;a<this.lines.length;a++)i+=+this.lines.get(a).resize(e,s);let o=0;if(this._rows<t)for(let a=this._rows;a<t;a++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new ii(e,s)):this.ybase>0&&this.lines.length<=this.ybase+this.y+o+1?(this.ybase--,o++,this.ydisp>0&&this.ydisp--):this.lines.push(new ii(e,s)));else for(let a=this._rows;a>t;a--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(n<this.lines.maxLength){let a=this.lines.length-n;a>0&&(this.lines.trimStart(a),this.ybase=Math.max(this.ybase-a,0),this.ydisp=Math.max(this.ydisp-a,0),this.savedY=Math.max(this.savedY-a,0)),this.lines.maxLength=n}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),o&&(this.y+=o),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let o=0;o<this.lines.length;o++)i+=+this.lines.get(o).resize(e,s);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),i>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let s=this._optionsService.rawOptions.reflowCursorLine,i=Z_(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(Ne),s);if(i.length>0){let n=Q_(this.lines,i);eg(this.lines,n.layout),this._reflowLargerAdjustViewport(e,t,n.countRemoved)}}_reflowLargerAdjustViewport(e,t,s){let i=this.getNullCell(Ne),n=s;for(;n-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new ii(e,i))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-s,0)}_reflowSmaller(e,t){let s=this._optionsService.rawOptions.reflowCursorLine,i=this.getNullCell(Ne),n=[],o=0;for(let a=this.lines.length-1;a>=0;a--){let l=this.lines.get(a);if(!l||!l.isWrapped&&l.getTrimmedLength()<=e)continue;let h=[l];for(;l.isWrapped&&a>0;)l=this.lines.get(--a),h.unshift(l);if(!s){let j=this.ybase+this.y;if(j>=a&&j<a+h.length)continue}let c=h[h.length-1].getTrimmedLength(),f=tg(h,this._cols,e),p=f.length-h.length,u;this.ybase===0&&this.y!==this.lines.length-1?u=Math.max(0,this.y-this.lines.maxLength+p):u=Math.max(0,this.lines.length-this.lines.maxLength+p);let g=[];for(let j=0;j<p;j++){let k=this.getBlankLine(Ne,!0);g.push(k)}g.length>0&&(n.push({start:a+h.length+o,newLines:g}),o+=g.length),h.push(...g);let m=f.length-1,_=f[m];_===0&&(m--,_=f[m]);let x=h.length-p-1,y=c;for(;x>=0;){let j=Math.min(y,_);if(h[m]===void 0)break;if(h[m].copyCellsFrom(h[x],y-j,_-j,j,!0),_-=j,_===0&&(m--,_=f[m]),y-=j,y===0){x--;let k=Math.max(x,0);y=pi(h,k,this._cols)}}for(let j=0;j<h.length;j++)f[j]<e&&h[j].setCell(f[j],i);let v=p-u;for(;v-- >0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+o)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+p,this.ybase+t-1)}if(n.length>0){let a=[],l=[];for(let _=0;_<this.lines.length;_++)l.push(this.lines.get(_));let h=this.lines.length,c=h-1,f=0,p=n[f];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+o);let u=0;for(let _=Math.min(this.lines.maxLength-1,h+o-1);_>=0;_--)if(p&&p.start>c+u){for(let x=p.newLines.length-1;x>=0;x--)this.lines.set(_--,p.newLines[x]);_++,a.push({index:c+1,amount:p.newLines.length}),u+=p.newLines.length,p=n[++f]}else this.lines.set(_,l[c--]);let g=0;for(let _=a.length-1;_>=0;_--)a[_].index+=g,this.lines.onInsertEmitter.fire(a[_]),g+=a[_].amount;let m=Math.max(0,h+o-this.lines.maxLength);m>0&&this.lines.onTrimEmitter.fire(m)}}translateBufferLineToString(e,t,s=0,i){let n=this.lines.get(e);return n?n.translateToString(t,s,i):""}getWrappedRangeForLine(e){let t=e,s=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;s+1<this.lines.length&&this.lines.get(s+1).isWrapped;)s++;return{first:t,last:s}}setupTabStops(e){for(e!=null?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e==null&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new sg(e);return this.markers.push(t),t.register(this.lines.onTrim(s=>{t.line-=s,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(s=>{t.line>=s.index&&(t.line+=s.amount)})),t.register(this.lines.onDelete(s=>{t.line>=s.index&&t.line<s.index+s.amount&&t.dispose(),t.line>s.index&&(t.line-=s.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},ig=class extends re{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new O),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this._register(this._optionsService.onSpecificOptionChange("scrollback",()=>this.resize(this._bufferService.cols,this._bufferService.rows))),this._register(this._optionsService.onSpecificOptionChange("tabStopWidth",()=>this.setupTabStops()))}reset(){this._normal=new cl(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new cl(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},yh=2,Sh=1,Un=class extends re{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new O),this.onResize=this._onResize.event,this._onScroll=this._register(new O),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,yh),this.rows=Math.max(e.rawOptions.rows||0,Sh),this.buffers=this._register(new ig(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let s=this.cols!==e,i=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:s,rowsChanged:i})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let s=this.buffer,i;i=this._cachedBlankLine,(!i||i.length!==this.cols||i.getFg(0)!==e.fg||i.getBg(0)!==e.bg)&&(i=s.getBlankLine(e,t),this._cachedBlankLine=i),i.isWrapped=t;let n=s.ybase+s.scrollTop,o=s.ybase+s.scrollBottom;if(s.scrollTop===0){let a=s.lines.isFull;o===s.lines.length-1?a?s.lines.recycle().copyFrom(i):s.lines.push(i.clone()):s.lines.splice(o+1,0,i.clone()),a?this.isUserScrolling&&(s.ydisp=Math.max(s.ydisp-1,0)):(s.ybase++,this.isUserScrolling||s.ydisp++)}else{let a=o-n+1;s.lines.shiftElements(n+1,a-1,-1),s.lines.set(o,i.clone())}this.isUserScrolling||(s.ydisp=s.ybase),this._onScroll.fire(s.ydisp)}scrollLines(e,t){let s=this.buffer;if(e<0){if(s.ydisp===0)return;this.isUserScrolling=!0}else e+s.ydisp>=s.ybase&&(this.isUserScrolling=!1);let i=s.ydisp;s.ydisp=Math.max(Math.min(s.ydisp+e,s.ybase),0),i!==s.ydisp&&(t||this._onScroll.fire(s.ydisp))}};Un=Ce([H(0,Ye)],Un);var Ns={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:cr,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},rg=["normal","bold","100","200","300","400","500","600","700","800","900"],ng=class extends re{constructor(e){super(),this._onOptionChange=this._register(new O),this.onOptionChange=this._onOptionChange.event;let t={...Ns};for(let s in e)if(s in t)try{let i=e[s];t[s]=this._sanitizeAndValidateOption(s,i)}catch(i){console.error(i)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(ve(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(s=>{s===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(s=>{e.indexOf(s)!==-1&&t()})}_setupOptions(){let e=s=>{if(!(s in Ns))throw new Error(`No option with key "${s}"`);return this.rawOptions[s]},t=(s,i)=>{if(!(s in Ns))throw new Error(`No option with key "${s}"`);i=this._sanitizeAndValidateOption(s,i),this.rawOptions[s]!==i&&(this.rawOptions[s]=i,this._onOptionChange.fire(s))};for(let s in this.rawOptions){let i={get:e.bind(this,s),set:t.bind(this,s)};Object.defineProperty(this.options,s,i)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=Ns[e]),!og(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=Ns[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=rg.includes(t)?t:Ns[e];break;case"cursorWidth":t=Math.floor(t);case"lineHeight":case"tabStopWidth":if(t<1)throw new Error(`${e} cannot be less than 1, value: ${t}`);break;case"minimumContrastRatio":t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case"scrollback":if(t=Math.min(t,4294967295),t<0)throw new Error(`${e} cannot be less than 0, value: ${t}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(t<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case"rows":case"cols":if(!t&&t!==0)throw new Error(`${e} must be numeric, value: ${t}`);break;case"windowsPty":t=t??{};break}return t}};function og(e){return e==="block"||e==="underline"||e==="bar"}function ri(e,t=5){if(typeof e!="object")return e;let s=Array.isArray(e)?[]:{};for(let i in e)s[i]=t<=1?e[i]:e[i]&&ri(e[i],t-1);return s}var hl=Object.freeze({insertMode:!1}),dl=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),Kn=class extends re{constructor(e,t,s){super(),this._bufferService=e,this._logService=t,this._optionsService=s,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new O),this.onData=this._onData.event,this._onUserInput=this._register(new O),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new O),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new O),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=ri(hl),this.decPrivateModes=ri(dl)}reset(){this.modes=ri(hl),this.decPrivateModes=ri(dl)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let s=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&s.ybase!==s.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(i=>i.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};Kn=Ce([H(0,Ge),H(1,Hc),H(2,Ye)],Kn);var ul={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>!(e.action===32&&e.button===3)},ANY:{events:31,restrict:e=>!0}};function Kr(e,t){let s=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(s|=64,s|=e.action):(s|=e.button&3,e.button&4&&(s|=64),e.button&8&&(s|=128),e.action===32?s|=32:e.action===0&&!t&&(s|=3)),s}var qr=String.fromCharCode,fl={DEFAULT:e=>{let t=[Kr(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${qr(t[0])}${qr(t[1])}${qr(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Kr(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${Kr(e,!0)};${e.x};${e.y}${t}`}},qn=class extends re{constructor(e,t,s){super(),this._bufferService=e,this._coreService=t,this._optionsService=s,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new O),this.onProtocolChange=this._onProtocolChange.event;for(let i of Object.keys(ul))this.addProtocol(i,ul[i]);for(let i of Object.keys(fl))this.addEncoding(i,fl[i]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,s){if(e.deltaY===0||e.shiftKey||t===void 0||s===void 0)return 0;let i=t/s,n=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(n/=i+0,Math.abs(e.deltaY)<50&&(n*=.3),this._wheelPartialScroll+=n,n=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(n*=this._bufferService.rows),n}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,s){if(s){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};qn=Ce([H(0,Ge),H(1,vs),H(2,Ye)],qn);var Vr=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],ag=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]],De;function lg(e,t){let s=0,i=t.length-1,n;if(e<t[0][0]||e>t[i][1])return!1;for(;i>=s;)if(n=s+i>>1,e>t[n][1])s=n+1;else if(e<t[n][0])i=n-1;else return!0;return!1}var cg=class{constructor(){if(this.version="6",!De){De=new Uint8Array(65536),De.fill(1),De[0]=0,De.fill(0,1,32),De.fill(0,127,160),De.fill(2,4352,4448),De[9001]=2,De[9002]=2,De.fill(2,11904,42192),De[12351]=1,De.fill(2,44032,55204),De.fill(2,63744,64256),De.fill(2,65040,65050),De.fill(2,65072,65136),De.fill(2,65280,65377),De.fill(2,65504,65511);for(let e=0;e<Vr.length;++e)De.fill(0,Vr[e][0],Vr[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?De[e]:lg(e,ag)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let s=this.wcwidth(e),i=s===0&&t!==0;if(i){let n=is.extractWidth(t);n===0?i=!1:n>s&&(s=n)}return is.createPropertyValue(0,s,i)}},is=class Xi{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new O,this.onChange=this._onChange.event;let t=new cg;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,s,i=!1){return(t&16777215)<<3|(s&3)<<1|(i?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let s=0,i=0,n=t.length;for(let o=0;o<n;++o){let a=t.charCodeAt(o);if(55296<=a&&a<=56319){if(++o>=n)return s+this.wcwidth(a);let c=t.charCodeAt(o);56320<=c&&c<=57343?a=(a-55296)*1024+c-56320+65536:s+=this.wcwidth(c)}let l=this.charProperties(a,i),h=Xi.extractWidth(l);Xi.extractShouldJoin(l)&&(h-=Xi.extractWidth(i)),s+=h,i=l}return s}charProperties(t,s){return this._activeProvider.charProperties(t,s)}},hg=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function ml(e){var i;let t=(i=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:i.get(e.cols-1),s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);s&&t&&(s.isWrapped=t[3]!==0&&t[3]!==32)}var Gs=2147483647,dg=256,wh=class Vn{constructor(t=32,s=32){if(this.maxLength=t,this.maxSubParamsLength=s,s>dg)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(s),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let s=new Vn;if(!t.length)return s;for(let i=Array.isArray(t[0])?1:0;i<t.length;++i){let n=t[i];if(Array.isArray(n))for(let o=0;o<n.length;++o)s.addSubParam(n[o]);else s.addParam(n)}return s}clone(){let t=new Vn(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let t=[];for(let s=0;s<this.length;++s){t.push(this.params[s]);let i=this._subParamsIdx[s]>>8,n=this._subParamsIdx[s]&255;n-i>0&&t.push(Array.prototype.slice.call(this._subParams,i,n))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>Gs?Gs:t}addSubParam(t){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=t>Gs?Gs:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let s=this._subParamsIdx[t]>>8,i=this._subParamsIdx[t]&255;return i-s>0?this._subParams.subarray(s,i):null}getSubParamsAll(){let t={};for(let s=0;s<this.length;++s){let i=this._subParamsIdx[s]>>8,n=this._subParamsIdx[s]&255;n-i>0&&(t[s]=this._subParams.slice(i,n))}return t}addDigit(t){let s;if(this._rejectDigits||!(s=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let i=this._digitIsSub?this._subParams:this.params,n=i[s-1];i[s-1]=~n?Math.min(n*10+t,Gs):t}},Ys=[],ug=class{constructor(){this._state=0,this._active=Ys,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(t),{dispose:()=>{let i=s.indexOf(t);i!==-1&&s.splice(i,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Ys}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=Ys,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Ys,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,s){if(!this._active.length)this._handlerFb(this._id,"PUT",br(e,t,s));else for(let i=this._active.length-1;i>=0;i--)this._active[i].put(e,t,s)}start(){this.reset(),this._state=1}put(e,t,s){if(this._state!==3){if(this._state===1)for(;t<s;){let i=e[t++];if(i===59){this._state=2,this._start();break}if(i<48||57<i){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+i-48}this._state===2&&s-t>0&&this._put(e,t,s)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let s=!1,i=this._active.length-1,n=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,s=t,n=this._stack.fallThrough,this._stack.paused=!1),!n&&s===!1){for(;i>=0&&(s=this._active[i].end(e),s!==!0);i--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,s;i--}for(;i>=0;i--)if(s=this._active[i].end(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,s}this._active=Ys,this._id=-1,this._state=0}}},it=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,s){this._hitLimit||(this._data+=br(e,t,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(s=>(this._data="",this._hitLimit=!1,s));return this._data="",this._hitLimit=!1,t}},Xs=[],fg=class{constructor(){this._handlers=Object.create(null),this._active=Xs,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Xs}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(t),{dispose:()=>{let i=s.indexOf(t);i!==-1&&s.splice(i,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=Xs,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||Xs,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let s=this._active.length-1;s>=0;s--)this._active[s].hook(t)}put(e,t,s){if(!this._active.length)this._handlerFb(this._ident,"PUT",br(e,t,s));else for(let i=this._active.length-1;i>=0;i--)this._active[i].put(e,t,s)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let s=!1,i=this._active.length-1,n=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,s=t,n=this._stack.fallThrough,this._stack.paused=!1),!n&&s===!1){for(;i>=0&&(s=this._active[i].unhook(e),s!==!0);i--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,s;i--}for(;i>=0;i--)if(s=this._active[i].unhook(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,s}this._active=Xs,this._ident=0}},ni=new wh;ni.addParam(0);var pl=class{constructor(e){this._handler=e,this._data="",this._params=ni,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():ni,this._data="",this._hitLimit=!1}put(e,t,s){this._hitLimit||(this._data+=br(e,t,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(s=>(this._params=ni,this._data="",this._hitLimit=!1,s));return this._params=ni,this._data="",this._hitLimit=!1,t}},mg=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,s,i){this.table[t<<8|e]=s<<4|i}addMany(e,t,s,i){for(let n=0;n<e.length;n++)this.table[t<<8|e[n]]=s<<4|i}},ct=160,pg=(function(){let e=new mg(4095),t=Array.apply(null,Array(256)).map((l,h)=>h),s=(l,h)=>t.slice(l,h),i=s(32,127),n=s(0,24);n.push(25),n.push.apply(n,s(28,32));let o=s(0,14),a;e.setDefault(1,0),e.addMany(i,0,2,0);for(a in o)e.addMany([24,26,153,154],a,3,0),e.addMany(s(128,144),a,3,0),e.addMany(s(144,152),a,3,0),e.add(156,a,0,0),e.add(27,a,11,1),e.add(157,a,4,8),e.addMany([152,158,159],a,0,7),e.add(155,a,11,3),e.add(144,a,11,9);return e.addMany(n,0,3,0),e.addMany(n,1,3,1),e.add(127,1,0,1),e.addMany(n,8,0,8),e.addMany(n,3,3,3),e.add(127,3,0,3),e.addMany(n,4,3,4),e.add(127,4,0,4),e.addMany(n,6,3,6),e.addMany(n,5,3,5),e.add(127,5,0,5),e.addMany(n,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(i,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(s(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(i,7,0,7),e.addMany(n,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(s(64,127),3,7,0),e.addMany(s(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(s(48,60),4,8,4),e.addMany(s(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(s(32,64),6,0,6),e.add(127,6,0,6),e.addMany(s(64,127),6,0,0),e.addMany(s(32,48),3,9,5),e.addMany(s(32,48),5,9,5),e.addMany(s(48,64),5,0,6),e.addMany(s(64,127),5,7,0),e.addMany(s(32,48),4,9,5),e.addMany(s(32,48),1,9,2),e.addMany(s(32,48),2,9,2),e.addMany(s(48,127),2,10,0),e.addMany(s(48,80),1,10,0),e.addMany(s(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(s(96,127),1,10,0),e.add(80,1,11,9),e.addMany(n,9,0,9),e.add(127,9,0,9),e.addMany(s(28,32),9,0,9),e.addMany(s(32,48),9,9,12),e.addMany(s(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(n,11,0,11),e.addMany(s(32,128),11,0,11),e.addMany(s(28,32),11,0,11),e.addMany(n,10,0,10),e.add(127,10,0,10),e.addMany(s(28,32),10,0,10),e.addMany(s(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(s(32,48),10,9,12),e.addMany(n,12,0,12),e.add(127,12,0,12),e.addMany(s(28,32),12,0,12),e.addMany(s(32,48),12,9,12),e.addMany(s(48,64),12,0,11),e.addMany(s(64,127),12,12,13),e.addMany(s(64,127),10,12,13),e.addMany(s(64,127),9,12,13),e.addMany(n,13,13,13),e.addMany(i,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(ct,0,2,0),e.add(ct,8,5,8),e.add(ct,6,0,6),e.add(ct,11,0,11),e.add(ct,13,13,13),e})(),_g=class extends re{constructor(e=pg){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new wh,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,s,i)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,s)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(ve(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new ug),this._dcsParser=this._register(new fg),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let s=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(s=e.prefix.charCodeAt(0),s&&60>s||s>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let n=0;n<e.intermediates.length;++n){let o=e.intermediates.charCodeAt(n);if(32>o||o>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");s<<=8,s|=o}}if(e.final.length!==1)throw new Error("final must be a single byte");let i=e.final.charCodeAt(0);if(t[0]>i||i>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return s<<=8,s|=i,s}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let s=this._identifier(e,[48,126]);this._escHandlers[s]===void 0&&(this._escHandlers[s]=[]);let i=this._escHandlers[s];return i.push(t),{dispose:()=>{let n=i.indexOf(t);n!==-1&&i.splice(n,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let s=this._identifier(e);this._csiHandlers[s]===void 0&&(this._csiHandlers[s]=[]);let i=this._csiHandlers[s];return i.push(t),{dispose:()=>{let n=i.indexOf(t);n!==-1&&i.splice(n,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,s,i,n){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=s,this._parseStack.transition=i,this._parseStack.chunkPos=n}parse(e,t,s){let i=0,n=0,o=0,a;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,o=this._parseStack.chunkPos+1;else{if(s===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let l=this._parseStack.handlers,h=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(s===!1&&h>-1){for(;h>=0&&(a=l[h](this._params),a!==!0);h--)if(a instanceof Promise)return this._parseStack.handlerPos=h,a}this._parseStack.handlers=[];break;case 4:if(s===!1&&h>-1){for(;h>=0&&(a=l[h](),a!==!0);h--)if(a instanceof Promise)return this._parseStack.handlerPos=h,a}this._parseStack.handlers=[];break;case 6:if(i=e[this._parseStack.chunkPos],a=this._dcsParser.unhook(i!==24&&i!==26,s),a)return a;i===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(i=e[this._parseStack.chunkPos],a=this._oscParser.end(i!==24&&i!==26,s),a)return a;i===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,o=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let l=o;l<t;++l){switch(i=e[l],n=this._transitions.table[this.currentState<<8|(i<160?i:ct)],n>>4){case 2:for(let u=l+1;;++u){if(u>=t||(i=e[u])<32||i>126&&i<ct){this._printHandler(e,l,u),l=u-1;break}if(++u>=t||(i=e[u])<32||i>126&&i<ct){this._printHandler(e,l,u),l=u-1;break}if(++u>=t||(i=e[u])<32||i>126&&i<ct){this._printHandler(e,l,u),l=u-1;break}if(++u>=t||(i=e[u])<32||i>126&&i<ct){this._printHandler(e,l,u),l=u-1;break}}break;case 3:this._executeHandlers[i]?this._executeHandlers[i]():this._executeHandlerFb(i),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:l,code:i,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let h=this._csiHandlers[this._collect<<8|i],c=h?h.length-1:-1;for(;c>=0&&(a=h[c](this._params),a!==!0);c--)if(a instanceof Promise)return this._preserveStack(3,h,c,n,l),a;c<0&&this._csiHandlerFb(this._collect<<8|i,this._params),this.precedingJoinState=0;break;case 8:do switch(i){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(i-48)}while(++l<t&&(i=e[l])>47&&i<60);l--;break;case 9:this._collect<<=8,this._collect|=i;break;case 10:let f=this._escHandlers[this._collect<<8|i],p=f?f.length-1:-1;for(;p>=0&&(a=f[p](),a!==!0);p--)if(a instanceof Promise)return this._preserveStack(4,f,p,n,l),a;p<0&&this._escHandlerFb(this._collect<<8|i),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|i,this._params);break;case 13:for(let u=l+1;;++u)if(u>=t||(i=e[u])===24||i===26||i===27||i>127&&i<ct){this._dcsParser.put(e,l,u),l=u-1;break}break;case 14:if(a=this._dcsParser.unhook(i!==24&&i!==26),a)return this._preserveStack(6,[],0,n,l),a;i===27&&(n|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let u=l+1;;u++)if(u>=t||(i=e[u])<32||i>127&&i<ct){this._oscParser.put(e,l,u),l=u-1;break}break;case 6:if(a=this._oscParser.end(i!==24&&i!==26),a)return this._preserveStack(5,[],0,n,l),a;i===27&&(n|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=n&15}}},gg=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,xg=/^[\da-f]+$/;function _l(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let s=gg.exec(t);if(s){let i=s[1]?15:s[4]?255:s[7]?4095:65535;return[Math.round(parseInt(s[1]||s[4]||s[7]||s[10],16)/i*255),Math.round(parseInt(s[2]||s[5]||s[8]||s[11],16)/i*255),Math.round(parseInt(s[3]||s[6]||s[9]||s[12],16)/i*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),xg.exec(t)&&[3,6,9,12].includes(t.length))){let s=t.length/3,i=[0,0,0];for(let n=0;n<3;++n){let o=parseInt(t.slice(s*n,s*n+s),16);i[n]=s===1?o<<4:s===2?o:s===3?o>>4:o>>8}return i}}function Gr(e,t){let s=e.toString(16),i=s.length<2?"0"+s:s;switch(t){case 4:return s[0];case 8:return i;case 12:return(i+i).slice(0,3);default:return i+i}}function vg(e,t=16){let[s,i,n]=e;return`rgb:${Gr(s,t)}/${Gr(i,t)}/${Gr(n,t)}`}var bg={"(":0,")":1,"*":2,"+":3,"-":1,".":2},It=131072,gl=10;function xl(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var vl=5e3,bl=0,yg=class extends re{constructor(e,t,s,i,n,o,a,l,h=new _g){super(),this._bufferService=e,this._charsetService=t,this._coreService=s,this._logService=i,this._optionsService=n,this._oscLinkService=o,this._coreMouseService=a,this._unicodeService=l,this._parser=h,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new Im,this._utf8Decoder=new Fm,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Ne.clone(),this._eraseAttrDataInternal=Ne.clone(),this._onRequestBell=this._register(new O),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new O),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new O),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new O),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new O),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new O),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new O),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new O),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new O),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new O),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new O),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new O),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new O),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this._register(this._parser),this._dirtyRowTracker=new Gn(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(c=>this._activeBuffer=c.activeBuffer)),this._parser.setCsiHandlerFallback((c,f)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(c),params:f.toArray()})}),this._parser.setEscHandlerFallback(c=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(c)})}),this._parser.setExecuteHandlerFallback(c=>{this._logService.debug("Unknown EXECUTE code: ",{code:c})}),this._parser.setOscHandlerFallback((c,f,p)=>{this._logService.debug("Unknown OSC code: ",{identifier:c,action:f,data:p})}),this._parser.setDcsHandlerFallback((c,f,p)=>{f==="HOOK"&&(p=p.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(c),action:f,payload:p})}),this._parser.setPrintHandler((c,f,p)=>this.print(c,f,p)),this._parser.registerCsiHandler({final:"@"},c=>this.insertChars(c)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},c=>this.scrollLeft(c)),this._parser.registerCsiHandler({final:"A"},c=>this.cursorUp(c)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},c=>this.scrollRight(c)),this._parser.registerCsiHandler({final:"B"},c=>this.cursorDown(c)),this._parser.registerCsiHandler({final:"C"},c=>this.cursorForward(c)),this._parser.registerCsiHandler({final:"D"},c=>this.cursorBackward(c)),this._parser.registerCsiHandler({final:"E"},c=>this.cursorNextLine(c)),this._parser.registerCsiHandler({final:"F"},c=>this.cursorPrecedingLine(c)),this._parser.registerCsiHandler({final:"G"},c=>this.cursorCharAbsolute(c)),this._parser.registerCsiHandler({final:"H"},c=>this.cursorPosition(c)),this._parser.registerCsiHandler({final:"I"},c=>this.cursorForwardTab(c)),this._parser.registerCsiHandler({final:"J"},c=>this.eraseInDisplay(c,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},c=>this.eraseInDisplay(c,!0)),this._parser.registerCsiHandler({final:"K"},c=>this.eraseInLine(c,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},c=>this.eraseInLine(c,!0)),this._parser.registerCsiHandler({final:"L"},c=>this.insertLines(c)),this._parser.registerCsiHandler({final:"M"},c=>this.deleteLines(c)),this._parser.registerCsiHandler({final:"P"},c=>this.deleteChars(c)),this._parser.registerCsiHandler({final:"S"},c=>this.scrollUp(c)),this._parser.registerCsiHandler({final:"T"},c=>this.scrollDown(c)),this._parser.registerCsiHandler({final:"X"},c=>this.eraseChars(c)),this._parser.registerCsiHandler({final:"Z"},c=>this.cursorBackwardTab(c)),this._parser.registerCsiHandler({final:"`"},c=>this.charPosAbsolute(c)),this._parser.registerCsiHandler({final:"a"},c=>this.hPositionRelative(c)),this._parser.registerCsiHandler({final:"b"},c=>this.repeatPrecedingCharacter(c)),this._parser.registerCsiHandler({final:"c"},c=>this.sendDeviceAttributesPrimary(c)),this._parser.registerCsiHandler({prefix:">",final:"c"},c=>this.sendDeviceAttributesSecondary(c)),this._parser.registerCsiHandler({final:"d"},c=>this.linePosAbsolute(c)),this._parser.registerCsiHandler({final:"e"},c=>this.vPositionRelative(c)),this._parser.registerCsiHandler({final:"f"},c=>this.hVPosition(c)),this._parser.registerCsiHandler({final:"g"},c=>this.tabClear(c)),this._parser.registerCsiHandler({final:"h"},c=>this.setMode(c)),this._parser.registerCsiHandler({prefix:"?",final:"h"},c=>this.setModePrivate(c)),this._parser.registerCsiHandler({final:"l"},c=>this.resetMode(c)),this._parser.registerCsiHandler({prefix:"?",final:"l"},c=>this.resetModePrivate(c)),this._parser.registerCsiHandler({final:"m"},c=>this.charAttributes(c)),this._parser.registerCsiHandler({final:"n"},c=>this.deviceStatus(c)),this._parser.registerCsiHandler({prefix:"?",final:"n"},c=>this.deviceStatusPrivate(c)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},c=>this.softReset(c)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},c=>this.setCursorStyle(c)),this._parser.registerCsiHandler({final:"r"},c=>this.setScrollRegion(c)),this._parser.registerCsiHandler({final:"s"},c=>this.saveCursor(c)),this._parser.registerCsiHandler({final:"t"},c=>this.windowOptions(c)),this._parser.registerCsiHandler({final:"u"},c=>this.restoreCursor(c)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},c=>this.insertColumns(c)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},c=>this.deleteColumns(c)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},c=>this.selectProtected(c)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},c=>this.requestMode(c,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},c=>this.requestMode(c,!1)),this._parser.setExecuteHandler(R.BEL,()=>this.bell()),this._parser.setExecuteHandler(R.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(R.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(R.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(R.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(R.BS,()=>this.backspace()),this._parser.setExecuteHandler(R.HT,()=>this.tab()),this._parser.setExecuteHandler(R.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(R.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Gi.IND,()=>this.index()),this._parser.setExecuteHandler(Gi.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Gi.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new it(c=>(this.setTitle(c),this.setIconName(c),!0))),this._parser.registerOscHandler(1,new it(c=>this.setIconName(c))),this._parser.registerOscHandler(2,new it(c=>this.setTitle(c))),this._parser.registerOscHandler(4,new it(c=>this.setOrReportIndexedColor(c))),this._parser.registerOscHandler(8,new it(c=>this.setHyperlink(c))),this._parser.registerOscHandler(10,new it(c=>this.setOrReportFgColor(c))),this._parser.registerOscHandler(11,new it(c=>this.setOrReportBgColor(c))),this._parser.registerOscHandler(12,new it(c=>this.setOrReportCursorColor(c))),this._parser.registerOscHandler(104,new it(c=>this.restoreIndexedColor(c))),this._parser.registerOscHandler(110,new it(c=>this.restoreFgColor(c))),this._parser.registerOscHandler(111,new it(c=>this.restoreBgColor(c))),this._parser.registerOscHandler(112,new it(c=>this.restoreCursorColor(c))),this._parser.registerEscHandler({final:"7"},()=>this.saveCursor()),this._parser.registerEscHandler({final:"8"},()=>this.restoreCursor()),this._parser.registerEscHandler({final:"D"},()=>this.index()),this._parser.registerEscHandler({final:"E"},()=>this.nextLine()),this._parser.registerEscHandler({final:"H"},()=>this.tabSet()),this._parser.registerEscHandler({final:"M"},()=>this.reverseIndex()),this._parser.registerEscHandler({final:"="},()=>this.keypadApplicationMode()),this._parser.registerEscHandler({final:">"},()=>this.keypadNumericMode()),this._parser.registerEscHandler({final:"c"},()=>this.fullReset()),this._parser.registerEscHandler({final:"n"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"o"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"|"},()=>this.setgLevel(3)),this._parser.registerEscHandler({final:"}"},()=>this.setgLevel(2)),this._parser.registerEscHandler({final:"~"},()=>this.setgLevel(1)),this._parser.registerEscHandler({intermediates:"%",final:"@"},()=>this.selectDefaultCharset()),this._parser.registerEscHandler({intermediates:"%",final:"G"},()=>this.selectDefaultCharset());for(let c in Re)this._parser.registerEscHandler({intermediates:"(",final:c},()=>this.selectCharset("("+c)),this._parser.registerEscHandler({intermediates:")",final:c},()=>this.selectCharset(")"+c)),this._parser.registerEscHandler({intermediates:"*",final:c},()=>this.selectCharset("*"+c)),this._parser.registerEscHandler({intermediates:"+",final:c},()=>this.selectCharset("+"+c)),this._parser.registerEscHandler({intermediates:"-",final:c},()=>this.selectCharset("-"+c)),this._parser.registerEscHandler({intermediates:".",final:c},()=>this.selectCharset("."+c)),this._parser.registerEscHandler({intermediates:"/",final:c},()=>this.selectCharset("/"+c));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(c=>(this._logService.error("Parsing error: ",c),c)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new pl((c,f)=>this.requestStatusString(c,f)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,s,i){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=s,this._parseStack.position=i}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,s)=>setTimeout(()=>s("#SLOW_TIMEOUT"),vl))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${vl} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let s,i=this._activeBuffer.x,n=this._activeBuffer.y,o=0,a=this._parseStack.paused;if(a){if(s=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(s),s;i=this._parseStack.cursorStartX,n=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>It&&(o=this._parseStack.position+It)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,c=>String.fromCharCode(c)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(c=>c.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<It&&(this._parseBuffer=new Uint32Array(Math.min(e.length,It))),a||this._dirtyRowTracker.clearRange(),e.length>It)for(let c=o;c<e.length;c+=It){let f=c+It<e.length?c+It:e.length,p=typeof e=="string"?this._stringDecoder.decode(e.substring(c,f),this._parseBuffer):this._utf8Decoder.decode(e.subarray(c,f),this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,p))return this._preserveStack(i,n,p,c),this._logSlowResolvingAsync(s),s}else if(!a){let c=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,c))return this._preserveStack(i,n,c,0),this._logSlowResolvingAsync(s),s}(this._activeBuffer.x!==i||this._activeBuffer.y!==n)&&this._onCursorMove.fire();let l=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),h=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);h<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(h,this._bufferService.rows-1),end:Math.min(l,this._bufferService.rows-1)})}print(e,t,s){let i,n,o=this._charsetService.charset,a=this._optionsService.rawOptions.screenReaderMode,l=this._bufferService.cols,h=this._coreService.decPrivateModes.wraparound,c=this._coreService.modes.insertMode,f=this._curAttrData,p=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&s-t>0&&p.getWidth(this._activeBuffer.x-1)===2&&p.setCellFromCodepoint(this._activeBuffer.x-1,0,1,f);let u=this._parser.precedingJoinState;for(let g=t;g<s;++g){if(i=e[g],i<127&&o){let y=o[String.fromCharCode(i)];y&&(i=y.charCodeAt(0))}let m=this._unicodeService.charProperties(i,u);n=is.extractWidth(m);let _=is.extractShouldJoin(m),x=_?is.extractWidth(u):0;if(u=m,a&&this._onA11yChar.fire(Ft(i)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+n-x>l){if(h){let y=p,v=this._activeBuffer.x-x;for(this._activeBuffer.x=x,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),p=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),x>0&&p instanceof ii&&p.copyCellsFrom(y,v,0,x,!1);v<l;)y.setCellFromCodepoint(v++,0,1,f)}else if(this._activeBuffer.x=l-1,n===2)continue}if(_&&this._activeBuffer.x){let y=p.getWidth(this._activeBuffer.x-1)?1:2;p.addCodepointToCell(this._activeBuffer.x-y,i,n);for(let v=n-x;--v>=0;)p.setCellFromCodepoint(this._activeBuffer.x++,0,0,f);continue}if(c&&(p.insertCells(this._activeBuffer.x,n-x,this._activeBuffer.getNullCell(f)),p.getWidth(l-1)===2&&p.setCellFromCodepoint(l-1,0,1,f)),p.setCellFromCodepoint(this._activeBuffer.x++,i,n,f),n>0)for(;--n;)p.setCellFromCodepoint(this._activeBuffer.x++,0,0,f)}this._parser.precedingJoinState=u,this._activeBuffer.x<l&&s-t>0&&p.getWidth(this._activeBuffer.x)===0&&!p.hasContent(this._activeBuffer.x)&&p.setCellFromCodepoint(this._activeBuffer.x,0,1,f),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,s=>xl(s.params[0],this._optionsService.rawOptions.windowOptions)?t(s):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new pl(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new it(t))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var e;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&((e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&e.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,s,i=!1,n=!1){let o=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);o.replaceCells(t,s,this._activeBuffer.getNullCell(this._eraseAttrData()),n),i&&(o.isWrapped=!1)}_resetBufferLine(e,t=!1){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);s&&(s.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),s.isWrapped=!1)}eraseInDisplay(e,t=!1){var i;this._restrictCursor(this._bufferService.cols);let s;switch(e.params[0]){case 0:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);s<this._bufferService.rows;s++)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(s);break;case 1:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(s+1).isWrapped=!1);s--;)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(s=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,s-1);s--&&!((i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s))!=null&&i.getTrimmedLength()););for(;s>=0;s--)this._bufferService.scroll(this._eraseAttrData())}else{for(s=this._bufferService.rows,this._dirtyRowTracker.markDirty(s-1);s--;)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let n=this._activeBuffer.lines.length-this._bufferService.rows;n>0&&(this._activeBuffer.lines.trimStart(n),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-n,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-n,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=this._activeBuffer.ybase+this._activeBuffer.y,i=this._bufferService.rows-1-this._activeBuffer.scrollBottom,n=this._bufferService.rows-1+this._activeBuffer.ybase-i+1;for(;t--;)this._activeBuffer.lines.splice(n-1,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=this._activeBuffer.ybase+this._activeBuffer.y,i;for(i=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-i;t--;)this._activeBuffer.lines.splice(s,1),this._activeBuffer.lines.splice(i,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(e){let t=e.params[0]||1;for(;t--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(Ne));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let s=e.params[0]||1,i=is.extractWidth(t),n=this._activeBuffer.x-i,o=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(n),a=new Uint32Array(o.length*s),l=0;for(let c=0;c<o.length;){let f=o.codePointAt(c)||0;a[l++]=f,c+=f>65535?2:1}let h=l;for(let c=1;c<s;++c)a.copyWithin(h,0,l),h+=l;return this.print(a,0,h),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(R.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(R.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(R.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(R.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(R.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,ss),this._charsetService.setgCharset(1,ss),this._charsetService.setgCharset(2,ss),this._charsetService.setgCharset(3,ss);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,t){(_=>(_[_.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",_[_.SET=1]="SET",_[_.RESET=2]="RESET",_[_.PERMANENTLY_SET=3]="PERMANENTLY_SET",_[_.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(s={}));let i=this._coreService.decPrivateModes,{activeProtocol:n,activeEncoding:o}=this._coreMouseService,a=this._coreService,{buffers:l,cols:h}=this._bufferService,{active:c,alt:f}=l,p=this._optionsService.rawOptions,u=(_,x)=>(a.triggerDataEvent(`${R.ESC}[${t?"":"?"}${_};${x}$y`),!0),g=_=>_?1:2,m=e.params[0];return t?m===2?u(m,4):m===4?u(m,g(a.modes.insertMode)):m===12?u(m,3):m===20?u(m,g(p.convertEol)):u(m,0):m===1?u(m,g(i.applicationCursorKeys)):m===3?u(m,p.windowOptions.setWinLines?h===80?2:h===132?1:0:0):m===6?u(m,g(i.origin)):m===7?u(m,g(i.wraparound)):m===8?u(m,3):m===9?u(m,g(n==="X10")):m===12?u(m,g(p.cursorBlink)):m===25?u(m,g(!a.isCursorHidden)):m===45?u(m,g(i.reverseWraparound)):m===66?u(m,g(i.applicationKeypad)):m===67?u(m,4):m===1e3?u(m,g(n==="VT200")):m===1002?u(m,g(n==="DRAG")):m===1003?u(m,g(n==="ANY")):m===1004?u(m,g(i.sendFocus)):m===1005?u(m,4):m===1006?u(m,g(o==="SGR")):m===1015?u(m,4):m===1016?u(m,g(o==="SGR_PIXELS")):m===1048?u(m,1):m===47||m===1047||m===1049?u(m,g(c===f)):m===2004?u(m,g(i.bracketedPasteMode)):m===2026?u(m,g(i.synchronizedOutput)):u(m,0)}_updateAttrColor(e,t,s,i,n){return t===2?(e|=50331648,e&=-16777216,e|=vi.fromColorRGB([s,i,n])):t===5&&(e&=-50331904,e|=33554432|s&255),e}_extractColor(e,t,s){let i=[0,0,-1,0,0,0],n=0,o=0;do{if(i[o+n]=e.params[t+o],e.hasSubParams(t+o)){let a=e.getSubParams(t+o),l=0;do i[1]===5&&(n=1),i[o+l+1+n]=a[l];while(++l<a.length&&l+o+1+n<i.length);break}if(i[1]===5&&o+n>=2||i[1]===2&&o+n>=5)break;i[1]&&(n=1)}while(++o+t<e.length&&o+n<i.length);for(let a=2;a<i.length;++a)i[a]===-1&&(i[a]=0);switch(i[0]){case 38:s.fg=this._updateAttrColor(s.fg,i[1],i[3],i[4],i[5]);break;case 48:s.bg=this._updateAttrColor(s.bg,i[1],i[3],i[4],i[5]);break;case 58:s.extended=s.extended.clone(),s.extended.underlineColor=this._updateAttrColor(s.extended.underlineColor,i[1],i[3],i[4],i[5])}return o}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=Ne.fg,e.bg=Ne.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,s,i=this._curAttrData;for(let n=0;n<t;n++)s=e.params[n],s>=30&&s<=37?(i.fg&=-50331904,i.fg|=16777216|s-30):s>=40&&s<=47?(i.bg&=-50331904,i.bg|=16777216|s-40):s>=90&&s<=97?(i.fg&=-50331904,i.fg|=16777216|s-90|8):s>=100&&s<=107?(i.bg&=-50331904,i.bg|=16777216|s-100|8):s===0?this._processSGR0(i):s===1?i.fg|=134217728:s===3?i.bg|=67108864:s===4?(i.fg|=268435456,this._processUnderline(e.hasSubParams(n)?e.getSubParams(n)[0]:1,i)):s===5?i.fg|=536870912:s===7?i.fg|=67108864:s===8?i.fg|=1073741824:s===9?i.fg|=2147483648:s===2?i.bg|=134217728:s===21?this._processUnderline(2,i):s===22?(i.fg&=-134217729,i.bg&=-134217729):s===23?i.bg&=-67108865:s===24?(i.fg&=-268435457,this._processUnderline(0,i)):s===25?i.fg&=-536870913:s===27?i.fg&=-67108865:s===28?i.fg&=-1073741825:s===29?i.fg&=2147483647:s===39?(i.fg&=-67108864,i.fg|=Ne.fg&16777215):s===49?(i.bg&=-67108864,i.bg|=Ne.bg&16777215):s===38||s===48||s===58?n+=this._extractColor(e,n,i):s===53?i.bg|=1073741824:s===55?i.bg&=-1073741825:s===59?(i.extended=i.extended.clone(),i.extended.underlineColor=-1,i.updateExtended()):s===100?(i.fg&=-67108864,i.fg|=Ne.fg&16777215,i.bg&=-67108864,i.bg|=Ne.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",s);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${R.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${R.ESC}[${t};${s}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${R.ESC}[?${t};${s}R`);break}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=Ne.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let s=t%2===1;this._coreService.decPrivateModes.cursorBlink=s}return!0}setScrollRegion(e){let t=e.params[0]||1,s;return(e.length<2||(s=e.params[1])>this._bufferService.rows||s===0)&&(s=this._bufferService.rows),s>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=s-1,this._setCursor(0,0)),!0}windowOptions(e){if(!xl(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${R.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>gl&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>gl&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(e){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],s=e.split(";");for(;s.length>1;){let i=s.shift(),n=s.shift();if(/^\d+$/.exec(i)){let o=parseInt(i);if(yl(o))if(n==="?")t.push({type:0,index:o});else{let a=_l(n);a&&t.push({type:1,index:o,color:a})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let s=e.slice(0,t).trim(),i=e.slice(t+1);return i?this._createHyperlink(s,i):s.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let s=e.split(":"),i,n=s.findIndex(o=>o.startsWith("id="));return n!==-1&&(i=s[n].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:i,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let s=e.split(";");for(let i=0;i<s.length&&!(t>=this._specialColors.length);++i,++t)if(s[i]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let n=_l(s[i]);n&&this._onColor.fire([{type:1,index:this._specialColors[t],color:n}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],s=e.split(";");for(let i=0;i<s.length;++i)if(/^\d+$/.exec(s[i])){let n=parseInt(s[i]);yl(n)&&t.push({type:2,index:n})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,ss),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(bg[e[0]],Re[e[1]]||ss),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=Ne.clone(),this._eraseAttrDataInternal=Ne.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new ht;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let s=this._activeBuffer.ybase+this._activeBuffer.y+t,i=this._activeBuffer.lines.get(s);i&&(i.fill(e),i.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let s=a=>(this._coreService.triggerDataEvent(`${R.ESC}${a}${R.ESC}\\`),!0),i=this._bufferService.buffer,n=this._optionsService.rawOptions;return s(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${i.scrollTop+1};${i.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[n.cursorStyle]-(n.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},Gn=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(bl=e,e=t,t=bl),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};Gn=Ce([H(0,Ge)],Gn);function yl(e){return 0<=e&&e<256}var Sg=5e7,Sl=12,wg=50,Cg=class extends re{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new O),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let s;for(;s=this._writeBuffer.shift();){this._action(s);let i=this._callbacks.shift();i&&i()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>Sg)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let s=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let i=this._writeBuffer[this._bufferOffset],n=this._action(i,t);if(n){let a=l=>performance.now()-s>=Sl?setTimeout(()=>this._innerWrite(0,l)):this._innerWrite(s,l);n.catch(l=>(queueMicrotask(()=>{throw l}),Promise.resolve(!1))).then(a);return}let o=this._callbacks[this._bufferOffset];if(o&&o(),this._bufferOffset++,this._pendingData-=i.length,performance.now()-s>=Sl)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>wg&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout(()=>this._innerWrite())):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}},Yn=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let l=t.addMarker(t.ybase+t.y),h={data:e,id:this._nextId++,lines:[l]};return l.onDispose(()=>this._removeMarkerFromLink(h,l)),this._dataByLinkId.set(h.id,h),h.id}let s=e,i=this._getEntryIdKey(s),n=this._entriesWithId.get(i);if(n)return this.addLineToLink(n.id,t.ybase+t.y),n.id;let o=t.addMarker(t.ybase+t.y),a={id:this._nextId++,key:this._getEntryIdKey(s),data:s,lines:[o]};return o.onDispose(()=>this._removeMarkerFromLink(a,o)),this._entriesWithId.set(a.key,a),this._dataByLinkId.set(a.id,a),a.id}addLineToLink(e,t){let s=this._dataByLinkId.get(e);if(s&&s.lines.every(i=>i.line!==t)){let i=this._bufferService.buffer.addMarker(t);s.lines.push(i),i.onDispose(()=>this._removeMarkerFromLink(s,i))}}getLinkData(e){var t;return(t=this._dataByLinkId.get(e))==null?void 0:t.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let s=e.lines.indexOf(t);s!==-1&&(e.lines.splice(s,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};Yn=Ce([H(0,Ge)],Yn);var wl=!1,kg=class extends re{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new As),this._onBinary=this._register(new O),this.onBinary=this._onBinary.event,this._onData=this._register(new O),this.onData=this._onData.event,this._onLineFeed=this._register(new O),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new O),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new O),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new O),this._instantiationService=new Y_,this.optionsService=this._register(new ng(e)),this._instantiationService.setService(Ye,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(Un)),this._instantiationService.setService(Ge,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Wn)),this._instantiationService.setService(Hc,this._logService),this.coreService=this._register(this._instantiationService.createInstance(Kn)),this._instantiationService.setService(vs,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(qn)),this._instantiationService.setService(Fc,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(is)),this._instantiationService.setService(Km,this.unicodeService),this._charsetService=this._instantiationService.createInstance(hg),this._instantiationService.setService(Um,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(Yn),this._instantiationService.setService(Wc,this._oscLinkService),this._inputHandler=this._register(new yg(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register($e.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register($e.forward(this._bufferService.onResize,this._onResize)),this._register($e.forward(this.coreService.onData,this._onData)),this._register($e.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new Cg((t,s)=>this._inputHandler.parse(t,s))),this._register($e.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new O),this._onScroll.event(e=>{var t;(t=this._onScrollApi)==null||t.fire(e.position)})),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!wl&&(this._logService.warn("writeSync is unreliable and will be removed soon."),wl=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,yh),t=Math.max(t,Sh),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend==="conpty"&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(ml.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(ml(this._bufferService),!1))),this._windowsWrappingHeuristics.value=ve(()=>{for(let t of e)t.dispose()})}}},Ng={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};function jg(e,t,s,i){var a;let n={type:0,cancel:!1,key:void 0},o=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?n.key=R.ESC+"OA":n.key=R.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?n.key=R.ESC+"OD":n.key=R.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?n.key=R.ESC+"OC":n.key=R.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?n.key=R.ESC+"OB":n.key=R.ESC+"[B");break;case 8:n.key=e.ctrlKey?"\b":R.DEL,e.altKey&&(n.key=R.ESC+n.key);break;case 9:if(e.shiftKey){n.key=R.ESC+"[Z";break}n.key=R.HT,n.cancel=!0;break;case 13:n.key=e.altKey?R.ESC+R.CR:R.CR,n.cancel=!0;break;case 27:n.key=R.ESC,e.altKey&&(n.key=R.ESC+R.ESC),n.cancel=!0;break;case 37:if(e.metaKey)break;o?n.key=R.ESC+"[1;"+(o+1)+"D":t?n.key=R.ESC+"OD":n.key=R.ESC+"[D";break;case 39:if(e.metaKey)break;o?n.key=R.ESC+"[1;"+(o+1)+"C":t?n.key=R.ESC+"OC":n.key=R.ESC+"[C";break;case 38:if(e.metaKey)break;o?n.key=R.ESC+"[1;"+(o+1)+"A":t?n.key=R.ESC+"OA":n.key=R.ESC+"[A";break;case 40:if(e.metaKey)break;o?n.key=R.ESC+"[1;"+(o+1)+"B":t?n.key=R.ESC+"OB":n.key=R.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(n.key=R.ESC+"[2~");break;case 46:o?n.key=R.ESC+"[3;"+(o+1)+"~":n.key=R.ESC+"[3~";break;case 36:o?n.key=R.ESC+"[1;"+(o+1)+"H":t?n.key=R.ESC+"OH":n.key=R.ESC+"[H";break;case 35:o?n.key=R.ESC+"[1;"+(o+1)+"F":t?n.key=R.ESC+"OF":n.key=R.ESC+"[F";break;case 33:e.shiftKey?n.type=2:e.ctrlKey?n.key=R.ESC+"[5;"+(o+1)+"~":n.key=R.ESC+"[5~";break;case 34:e.shiftKey?n.type=3:e.ctrlKey?n.key=R.ESC+"[6;"+(o+1)+"~":n.key=R.ESC+"[6~";break;case 112:o?n.key=R.ESC+"[1;"+(o+1)+"P":n.key=R.ESC+"OP";break;case 113:o?n.key=R.ESC+"[1;"+(o+1)+"Q":n.key=R.ESC+"OQ";break;case 114:o?n.key=R.ESC+"[1;"+(o+1)+"R":n.key=R.ESC+"OR";break;case 115:o?n.key=R.ESC+"[1;"+(o+1)+"S":n.key=R.ESC+"OS";break;case 116:o?n.key=R.ESC+"[15;"+(o+1)+"~":n.key=R.ESC+"[15~";break;case 117:o?n.key=R.ESC+"[17;"+(o+1)+"~":n.key=R.ESC+"[17~";break;case 118:o?n.key=R.ESC+"[18;"+(o+1)+"~":n.key=R.ESC+"[18~";break;case 119:o?n.key=R.ESC+"[19;"+(o+1)+"~":n.key=R.ESC+"[19~";break;case 120:o?n.key=R.ESC+"[20;"+(o+1)+"~":n.key=R.ESC+"[20~";break;case 121:o?n.key=R.ESC+"[21;"+(o+1)+"~":n.key=R.ESC+"[21~";break;case 122:o?n.key=R.ESC+"[23;"+(o+1)+"~":n.key=R.ESC+"[23~";break;case 123:o?n.key=R.ESC+"[24;"+(o+1)+"~":n.key=R.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?n.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?n.key=R.NUL:e.keyCode>=51&&e.keyCode<=55?n.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?n.key=R.DEL:e.keyCode===219?n.key=R.ESC:e.keyCode===220?n.key=R.FS:e.keyCode===221&&(n.key=R.GS);else if((!s||i)&&e.altKey&&!e.metaKey){let l=(a=Ng[e.keyCode])==null?void 0:a[e.shiftKey?1:0];if(l)n.key=R.ESC+l;else if(e.keyCode>=65&&e.keyCode<=90){let h=e.ctrlKey?e.keyCode-64:e.keyCode+32,c=String.fromCharCode(h);e.shiftKey&&(c=c.toUpperCase()),n.key=R.ESC+c}else if(e.keyCode===32)n.key=R.ESC+(e.ctrlKey?R.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let h=e.code.slice(3,4);e.shiftKey||(h=h.toLowerCase()),n.key=R.ESC+h,n.cancel=!0}}else s&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(n.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?n.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(n.key=R.US),e.key==="@"&&(n.key=R.NUL));break}return n}var ke=0,Eg=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new hr,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new hr,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((n,o)=>this._getKey(n)-this._getKey(o)),t=0,s=0,i=new Array(this._array.length+this._insertedValues.length);for(let n=0;n<i.length;n++)s>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[s])?(i[n]=e[t],t++):i[n]=this._array[s++];this._array=i,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(ke=this._search(t),ke===-1)||this._getKey(this._array[ke])!==t)return!1;do if(this._array[ke]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(ke),!0;while(++ke<this._array.length&&this._getKey(this._array[ke])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((n,o)=>n-o),t=0,s=new Array(this._array.length-e.length),i=0;for(let n=0;n<this._array.length;n++)e[t]===n?t++:s[i++]=this._array[n];this._array=s,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(ke=this._search(e),!(ke<0||ke>=this._array.length)&&this._getKey(this._array[ke])===e))do yield this._array[ke];while(++ke<this._array.length&&this._getKey(this._array[ke])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(ke=this._search(e),!(ke<0||ke>=this._array.length)&&this._getKey(this._array[ke])===e))do t(this._array[ke]);while(++ke<this._array.length&&this._getKey(this._array[ke])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,s=this._array.length-1;for(;s>=t;){let i=t+s>>1,n=this._getKey(this._array[i]);if(n>e)s=i-1;else if(n<e)t=i+1;else{for(;i>0&&this._getKey(this._array[i-1])===e;)i--;return i}}return t}},Yr=0,Cl=0,Dg=class extends re{constructor(){super(),this._decorations=new Eg(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new O),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new O),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(ve(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new Rg(e);if(t){let s=t.marker.onDispose(()=>t.dispose()),i=t.onDispose(()=>{i.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),s.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,s){let i=0,n=0;for(let o of this._decorations.getKeyIterator(t))i=o.options.x??0,n=i+(o.options.width??1),e>=i&&e<n&&(!s||(o.options.layer??"bottom")===s)&&(yield o)}forEachDecorationAtCell(e,t,s,i){this._decorations.forEachByKey(t,n=>{Yr=n.options.x??0,Cl=Yr+(n.options.width??1),e>=Yr&&e<Cl&&(!s||(n.options.layer??"bottom")===s)&&i(n)})}},Rg=class extends Gt{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new O),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new O),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=Se.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=Se.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},Pg=1e3,Mg=class{constructor(e,t=Pg){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,s){this._rowCount=s,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t;let i=performance.now();if(i-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=i,this._innerRefresh();else if(!this._additionalRefreshRequested){let n=i-this._lastRefreshMs,o=this._debounceThresholdMS-n;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},o)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},kl=20,dr=class extends re{constructor(e,t,s,i){super(),this._terminal=e,this._coreBrowserService=s,this._renderService=i,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let n=this._coreBrowserService.mainDocument;this._accessibilityContainer=n.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=n.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let o=0;o<this._terminal.rows;o++)this._rowElements[o]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[o]);if(this._topBoundaryFocusListener=o=>this._handleBoundaryFocus(o,0),this._bottomBoundaryFocusListener=o=>this._handleBoundaryFocus(o,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=n.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new Mg(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this._register(this._terminal.onResize(o=>this._handleResize(o.rows))),this._register(this._terminal.onRender(o=>this._refreshRows(o.start,o.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(o=>this._handleChar(o))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
196
+ `))),this._register(this._terminal.onA11yTab(o=>this._handleTab(o))),this._register(this._terminal.onKey(o=>this._handleKey(o.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(X(n,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(ve(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<kl+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
197
+ `&&(this._liveRegionLineCount++,this._liveRegionLineCount===kl+1&&(this._liveRegion.textContent+=pn.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let s=this._terminal.buffer,i=s.lines.length.toString();for(let n=e;n<=t;n++){let o=s.lines.get(s.ydisp+n),a=[],l=(o==null?void 0:o.translateToString(!0,void 0,void 0,a))||"",h=(s.ydisp+n+1).toString(),c=this._rowElements[n];c&&(l.length===0?(c.textContent=" ",this._rowColumns.set(c,[0,1])):(c.textContent=l,this._rowColumns.set(c,a)),c.setAttribute("aria-posinset",h),c.setAttribute("aria-setsize",i),this._alignRowWidth(c))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let s=e.target,i=this._rowElements[t===0?1:this._rowElements.length-2],n=s.getAttribute("aria-posinset"),o=t===0?"1":`${this._terminal.buffer.lines.length}`;if(n===o||e.relatedTarget!==i)return;let a,l;if(t===0?(a=s,l=this._rowElements.pop(),this._rowContainer.removeChild(l)):(a=this._rowElements.shift(),l=s,this._rowContainer.removeChild(a)),a.removeEventListener("focus",this._topBoundaryFocusListener),l.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let h=this._createAccessibilityTreeNode();this._rowElements.unshift(h),this._rowContainer.insertAdjacentElement("afterbegin",h)}else{let h=this._createAccessibilityTreeNode();this._rowElements.push(h),this._rowContainer.appendChild(h)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){var l;if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},s={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(s.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===s.node&&t.offset>s.offset)&&([t,s]=[s,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let i=this._rowElements.slice(-1)[0];if(s.node.compareDocumentPosition(i)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(s={node:i,offset:((l=i.textContent)==null?void 0:l.length)??0}),!this._rowContainer.contains(s.node))return;let n=({node:h,offset:c})=>{let f=h instanceof Text?h.parentNode:h,p=parseInt(f==null?void 0:f.getAttribute("aria-posinset"),10)-1;if(isNaN(p))return console.warn("row is invalid. Race condition?"),null;let u=this._rowColumns.get(f);if(!u)return console.warn("columns is null. Race condition?"),null;let g=c<u.length?u[c]:u.slice(-1)[0]+1;return g>=this._terminal.cols&&(++p,g=0),{row:p,column:g}},o=n(t),a=n(s);if(!(!o||!a)){if(o.row>a.row||o.row===a.row&&o.column>=a.column)throw new Error("invalid range");this._terminal.select(o.column,o.row,(a.row-o.row)*this._terminal.cols-o.column+a.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){var n,o;e.style.transform="";let t=e.getBoundingClientRect().width,s=(o=(n=this._rowColumns.get(e))==null?void 0:n.slice(-1))==null?void 0:o[0];if(!s)return;let i=s*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${i/t})`}};dr=Ce([H(1,go),H(2,Pt),H(3,Mt)],dr);var Xn=class extends re{constructor(e,t,s,i,n){super(),this._element=e,this._mouseService=t,this._renderService=s,this._bufferService=i,this._linkProviderService=n,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new O),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new O),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(ve(()=>{var o;us(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,(o=this._activeProviderReplies)==null||o.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(X(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(X(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(X(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(X(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let s=e.composedPath();for(let i=0;i<s.length;i++){let n=s[i];if(n.classList.contains("xterm"))break;if(n.classList.contains("xterm-hover"))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){var i,n;(!this._activeProviderReplies||!t)&&((i=this._activeProviderReplies)==null||i.forEach(o=>{o==null||o.forEach(a=>{a.link.dispose&&a.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let s=!1;for(let[o,a]of this._linkProviderService.linkProviders.entries())t?(n=this._activeProviderReplies)!=null&&n.get(o)&&(s=this._checkLinkProviderResult(o,e,s)):a.provideLinks(e.y,l=>{var c,f;if(this._isMouseOut)return;let h=l==null?void 0:l.map(p=>({link:p}));(c=this._activeProviderReplies)==null||c.set(o,h),s=this._checkLinkProviderResult(o,e,s),((f=this._activeProviderReplies)==null?void 0:f.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let s=new Set;for(let i=0;i<t.size;i++){let n=t.get(i);if(n)for(let o=0;o<n.length;o++){let a=n[o],l=a.link.range.start.y<e?0:a.link.range.start.x,h=a.link.range.end.y>e?this._bufferService.cols:a.link.range.end.x;for(let c=l;c<=h;c++){if(s.has(c)){n.splice(o--,1);break}s.add(c)}}}}_checkLinkProviderResult(e,t,s){var o;if(!this._activeProviderReplies)return s;let i=this._activeProviderReplies.get(e),n=!1;for(let a=0;a<e;a++)(!this._activeProviderReplies.has(a)||this._activeProviderReplies.get(a))&&(n=!0);if(!n&&i){let a=i.find(l=>this._linkAtPosition(l.link,t));a&&(s=!0,this._handleNewLink(a))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!s)for(let a=0;a<this._activeProviderReplies.size;a++){let l=(o=this._activeProviderReplies.get(a))==null?void 0:o.find(h=>this._linkAtPosition(h.link,t));if(l){s=!0,this._handleNewLink(l);break}}return s}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&Lg(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,us(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>{var s,i;return(i=(s=this._currentLink)==null?void 0:s.state)==null?void 0:i.decorations.pointerCursor},set:s=>{var i;(i=this._currentLink)!=null&&i.state&&this._currentLink.state.decorations.pointerCursor!==s&&(this._currentLink.state.decorations.pointerCursor=s,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",s))}},underline:{get:()=>{var s,i;return(i=(s=this._currentLink)==null?void 0:s.state)==null?void 0:i.decorations.underline},set:s=>{var i,n,o;(i=this._currentLink)!=null&&i.state&&((o=(n=this._currentLink)==null?void 0:n.state)==null?void 0:o.decorations.underline)!==s&&(this._currentLink.state.decorations.underline=s,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,s))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(s=>{if(!this._currentLink)return;let i=s.start===0?0:s.start+1+this._bufferService.buffer.ydisp,n=this._bufferService.buffer.ydisp+1+s.end;if(this._currentLink.link.range.start.y>=i&&this._currentLink.link.range.end.y<=n&&(this._clearCurrentLink(i,n),this._lastMouseEvent)){let o=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);o&&this._askForLink(o,!1)}})))}_linkHover(e,t,s){var i;(i=this._currentLink)!=null&&i.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(s,t.text)}_fireUnderlineEvent(e,t){let s=e.range,i=this._bufferService.buffer.ydisp,n=this._createLinkUnderlineEvent(s.start.x-1,s.start.y-i-1,s.end.x,s.end.y-i-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(n)}_linkLeave(e,t,s){var i;(i=this._currentLink)!=null&&i.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(s,t.text)}_linkAtPosition(e,t){let s=e.range.start.y*this._bufferService.cols+e.range.start.x,i=e.range.end.y*this._bufferService.cols+e.range.end.x,n=t.y*this._bufferService.cols+t.x;return s<=n&&n<=i}_positionFromMouseEvent(e,t,s){let i=s.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(i)return{x:i[0],y:i[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,s,i,n){return{x1:e,y1:t,x2:s,y2:i,cols:this._bufferService.cols,fg:n}}};Xn=Ce([H(1,xo),H(2,Mt),H(3,Ge),H(4,Kc)],Xn);function Lg(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var Bg=class extends kg{constructor(e={}){super(e),this._linkifier=this._register(new As),this.browser=hh,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new As),this._onCursorMove=this._register(new O),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new O),this.onKey=this._onKey.event,this._onRender=this._register(new O),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new O),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new O),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new O),this.onBell=this._onBell.event,this._onFocus=this._register(new O),this._onBlur=this._register(new O),this._onA11yCharEmitter=this._register(new O),this._onA11yTabEmitter=this._register(new O),this._onWillOpen=this._register(new O),this._setup(),this._decorationService=this._instantiationService.createInstance(Dg),this._instantiationService.setService(bi,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(w_),this._instantiationService.setService(Kc,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(gn)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh((t==null?void 0:t.start)??0,(t==null?void 0:t.end)??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(t=>this._reportWindowsOptions(t))),this._register(this._inputHandler.onColor(t=>this._handleColorEvent(t))),this._register($e.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register($e.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register($e.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register($e.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(ve(()=>{var t,s;this._customKeyEventHandler=void 0,(s=(t=this.element)==null?void 0:t.parentNode)==null||s.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}_handleColorEvent(e){if(this._themeService)for(let t of e){let s,i="";switch(t.index){case 256:s="foreground",i="10";break;case 257:s="background",i="11";break;case 258:s="cursor",i="12";break;default:s="ansi",i="4;"+t.index}switch(t.type){case 0:let n=_e.toColorRGB(s==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[s]);this.coreService.triggerDataEvent(`${R.ESC}]${i};${vg(n)}${lh.ST}`);break;case 1:if(s==="ansi")this._themeService.modifyColors(o=>o.ansi[t.index]=je.toColor(...t.color));else{let o=s;this._themeService.modifyColors(a=>a[o]=je.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(dr,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(R.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var e;return(e=this.textarea)==null?void 0:e.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(R.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let s=Math.min(this.buffer.x,this.cols-1),i=this._renderService.dimensions.css.cell.height,n=t.getWidth(s),o=this._renderService.dimensions.css.cell.width*n,a=this.buffer.y*this._renderService.dimensions.css.cell.height,l=s*this._renderService.dimensions.css.cell.width;this.textarea.style.left=l+"px",this.textarea.style.top=a+"px",this.textarea.style.width=o+"px",this.textarea.style.height=i+"px",this.textarea.style.lineHeight=i+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(X(this.element,"copy",t=>{this.hasSelection()&&Om(t,this._selectionService)}));let e=t=>$m(t,this.textarea,this.coreService,this.optionsService);this._register(X(this.textarea,"paste",e)),this._register(X(this.element,"paste",e)),dh?this._register(X(this.element,"mousedown",t=>{t.button===2&&Ta(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(X(this.element,"contextmenu",t=>{Ta(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),No&&this._register(X(this.element,"auxclick",t=>{t.button===1&&zc(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(X(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(X(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(X(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(X(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(X(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(X(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(X(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var n;if(!e)throw new Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),((n=this.element)==null?void 0:n.ownerDocument.defaultView)&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(X(this.screenElement,"mousemove",o=>this.updateCursorStyle(o))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let s=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",mn.get()),mh||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>s.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(y_,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(Pt,this._coreBrowserService),this._register(X(this.textarea,"focus",o=>this._handleTextAreaFocus(o))),this._register(X(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(On,this._document,this._helperContainer),this._instantiationService.setService(yr,this._charSizeService),this._themeService=this._instantiationService.createInstance(Hn),this._instantiationService.setService(Os,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(lr),this._instantiationService.setService(Uc,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(In,this.rows,this.screenElement)),this._instantiationService.setService(Mt,this._renderService),this._register(this._renderService.onRenderedViewportChange(o=>this._onRender.fire(o))),this.onResize(o=>this._renderService.resize(o.cols,o.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(Tn,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance($n),this._instantiationService.setService(xo,this._mouseService);let i=this._linkifier.value=this._register(this._instantiationService.createInstance(Xn,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._register(this.onCursorMove(()=>{this._renderService.handleCursorMove(),this._syncTextArea()})),this._register(this.onResize(()=>this._renderService.handleResize(this.cols,this.rows))),this._register(this.onBlur(()=>this._renderService.handleBlur())),this._register(this.onFocus(()=>this._renderService.handleFocus())),this._viewport=this._register(this._instantiationService.createInstance(Ln,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(o=>{super.scrollLines(o,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(Fn,this.element,this.screenElement,i)),this._instantiationService.setService(Vm,this._selectionService),this._register(this._selectionService.onRequestScrollLines(o=>this.scrollLines(o.amount,o.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(o=>this._renderService.handleSelectionChanged(o.start,o.end,o.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(o=>{this.textarea.value=o,this.textarea.focus(),this.textarea.select()})),this._register($e.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var o;this._selectionService.refresh(),(o=this._viewport)==null||o.queueSync()})),this._register(this._instantiationService.createInstance(Bn,this.screenElement)),this._register(X(this.element,"mousedown",o=>this._selectionService.handleMouseDown(o))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(dr,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",o=>this._handleScreenReaderModeOptionChange(o))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(ar,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",o=>{!this._overviewRulerRenderer&&o&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(ar,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(An,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function s(o){var c,f,p,u,g;let a=e._mouseService.getMouseReportCoords(o,e.screenElement);if(!a)return!1;let l,h;switch(o.overrideType||o.type){case"mousemove":h=32,o.buttons===void 0?(l=3,o.button!==void 0&&(l=o.button<3?o.button:3)):l=o.buttons&1?0:o.buttons&4?1:o.buttons&2?2:3;break;case"mouseup":h=0,l=o.button<3?o.button:3;break;case"mousedown":h=1,l=o.button<3?o.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(o)===!1)return!1;let m=o.deltaY;if(m===0||e.coreMouseService.consumeWheelEvent(o,(u=(p=(f=(c=e._renderService)==null?void 0:c.dimensions)==null?void 0:f.device)==null?void 0:p.cell)==null?void 0:u.height,(g=e._coreBrowserService)==null?void 0:g.dpr)===0)return!1;h=m<0?0:1,l=4;break;default:return!1}return h===void 0||l===void 0||l>4?!1:e.coreMouseService.triggerMouseEvent({col:a.col,row:a.row,x:a.x,y:a.y,button:l,action:h,ctrl:o.ctrlKey,alt:o.altKey,shift:o.shiftKey})}let i={mouseup:null,wheel:null,mousedrag:null,mousemove:null},n={mouseup:o=>(s(o),o.buttons||(this._document.removeEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.removeEventListener("mousemove",i.mousedrag)),this.cancel(o)),wheel:o=>(s(o),this.cancel(o,!0)),mousedrag:o=>{o.buttons&&s(o)},mousemove:o=>{o.buttons||s(o)}};this._register(this.coreMouseService.onProtocolChange(o=>{o?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(o)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),o&8?i.mousemove||(t.addEventListener("mousemove",n.mousemove),i.mousemove=n.mousemove):(t.removeEventListener("mousemove",i.mousemove),i.mousemove=null),o&16?i.wheel||(t.addEventListener("wheel",n.wheel,{passive:!1}),i.wheel=n.wheel):(t.removeEventListener("wheel",i.wheel),i.wheel=null),o&2?i.mouseup||(i.mouseup=n.mouseup):(this._document.removeEventListener("mouseup",i.mouseup),i.mouseup=null),o&4?i.mousedrag||(i.mousedrag=n.mousedrag):(this._document.removeEventListener("mousemove",i.mousedrag),i.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(X(t,"mousedown",o=>{if(o.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(o)))return s(o),i.mouseup&&this._document.addEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.addEventListener("mousemove",i.mousedrag),this.cancel(o)})),this._register(X(t,"wheel",o=>{var a,l,h,c,f;if(!i.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(o)===!1)return!1;if(!this.buffer.hasScrollback){if(o.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(o,(c=(h=(l=(a=e._renderService)==null?void 0:a.dimensions)==null?void 0:l.device)==null?void 0:h.cell)==null?void 0:c.height,(f=e._coreBrowserService)==null?void 0:f.dpr)===0)return this.cancel(o,!0);let p=R.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(o.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(p,!0),this.cancel(o,!0)}}},{passive:!1}))}refresh(e,t){var s;(s=this._renderService)==null||s.refreshRows(e,t)}updateCursorStyle(e){var t;(t=this._selectionService)!=null&&t.shouldColumnSelect(e)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){Tc(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,s){this._selectionService.setSelection(e,t,s)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(!(!this._selectionService||!this._selectionService.hasSelection))return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var e;(e=this._selectionService)==null||e.clearSelection()}selectAll(){var e;(e=this._selectionService)==null||e.selectAll()}selectLines(e,t){var s;(s=this._selectionService)==null||s.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let s=jg(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),s.type===3||s.type===2){let i=this.rows-1;return this.scrollLines(s.type===2?-i:i),this.cancel(e,!0)}if(s.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(s.cancel&&this.cancel(e,!0),!s.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((s.key===R.ETX||s.key===R.CR)&&(this.textarea.value=""),this._onKey.fire({key:s.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(s.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let s=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return t.type==="keypress"?s:s&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(Tg(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){var s;(s=this._charSizeService)==null||s.measure()}clear(){if(!(this.buffer.ybase===0&&this.buffer.y===0)){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(Ne));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){var t;this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),(t=this._selectionService)==null||t.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){var e;(e=this._renderService)==null||e.clearTextureAtlas()}_reportFocus(){var e;(e=this.element)!=null&&e.classList.contains("focus")?this.coreService.triggerDataEvent(R.ESC+"[I"):this.coreService.triggerDataEvent(R.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),s=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${R.ESC}[4;${s};${t}t`);break;case 1:let i=this._renderService.dimensions.css.cell.width.toFixed(0),n=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${R.ESC}[6;${n};${i}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function Tg(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var zg=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let s={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(s),t.dispose=()=>this._wrappedAddonDispose(s),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let s=0;s<this._addons.length;s++)if(this._addons[s]===e){t=s;break}if(t===-1)throw new Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},Ag=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new ht)}translateToString(e,t,s){return this._line.translateToString(e,t,s)}},Nl=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(e){let t=this._buffer.lines.get(e);if(t)return new Ag(t)}getNullCell(){return new ht}},Og=class extends re{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new O),this.onBufferChange=this._onBufferChange.event,this._normal=new Nl(this._core.buffers.normal,"normal"),this._alternate=new Nl(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate(()=>this._onBufferChange.fire(this.active))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}},$g=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,s=>t(s.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(s,i)=>t(s,i.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},Ig=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},Fg=["cols","rows"],mt=0,Hg=class extends re{constructor(e){super(),this._core=this._register(new Bg(e)),this._addonManager=this._register(new zg),this._publicOptions={...this._core.options};let t=i=>this._core.options[i],s=(i,n)=>{this._checkReadonlyOptions(i),this._core.options[i]=n};for(let i in this._core.options){let n={get:t.bind(this,i),set:s.bind(this,i)};Object.defineProperty(this._publicOptions,i,n)}}_checkReadonlyOptions(e){if(Fg.includes(e))throw new Error(`Option "${e}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new $g(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new Ig(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this._register(new Og(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,s){this._verifyIntegers(e,t,s),this._core.select(e,t,s)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
198
+ `,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return mn.get()},set promptLabel(e){mn.set(e)},get tooMuchOutput(){return pn.get()},set tooMuchOutput(e){pn.set(e)}}}_verifyIntegers(...e){for(mt of e)if(mt===1/0||isNaN(mt)||mt%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(mt of e)if(mt&&(mt===1/0||isNaN(mt)||mt%1!==0||mt<0))throw new Error("This API only accepts positive integers")}};/**
199
+ * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
200
+ * @license MIT
201
+ *
202
+ * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
203
+ * @license MIT
204
+ *
205
+ * Originally forked from (with the author's permission):
206
+ * Fabrice Bellard's javascript vt100 for jslinux:
207
+ * http://bellard.org/jslinux/
208
+ * Copyright (c) 2011 Fabrice Bellard
209
+ */var Wg=2,Ug=1,Kg=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){var p;if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let t=this._terminal.options.scrollback===0?0:((p=this._terminal.options.overviewRuler)==null?void 0:p.width)||14,s=window.getComputedStyle(this._terminal.element.parentElement),i=parseInt(s.getPropertyValue("height")),n=Math.max(0,parseInt(s.getPropertyValue("width"))),o=window.getComputedStyle(this._terminal.element),a={top:parseInt(o.getPropertyValue("padding-top")),bottom:parseInt(o.getPropertyValue("padding-bottom")),right:parseInt(o.getPropertyValue("padding-right")),left:parseInt(o.getPropertyValue("padding-left"))},l=a.top+a.bottom,h=a.right+a.left,c=i-l,f=n-h-t;return{cols:Math.max(Wg,Math.floor(f/e.css.cell.width)),rows:Math.max(Ug,Math.floor(c/e.css.cell.height))}}};/**
210
+ * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
211
+ * @license MIT
212
+ *
213
+ * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
214
+ * @license MIT
215
+ *
216
+ * Originally forked from (with the author's permission):
217
+ * Fabrice Bellard's javascript vt100 for jslinux:
218
+ * http://bellard.org/jslinux/
219
+ * Copyright (c) 2011 Fabrice Bellard
220
+ */var qg=class{constructor(e,t,s,i={}){this._terminal=e,this._regex=t,this._handler=s,this._options=i}provideLinks(e,t){let s=Gg.computeLink(e,this._regex,this._terminal,this._handler);t(this._addCallbacks(s))}_addCallbacks(e){return e.map(t=>(t.leave=this._options.leave,t.hover=(s,i)=>{if(this._options.hover){let{range:n}=t;this._options.hover(s,i,n)}},t))}};function Vg(e){try{let t=new URL(e),s=t.password&&t.username?`${t.protocol}//${t.username}:${t.password}@${t.host}`:t.username?`${t.protocol}//${t.username}@${t.host}`:`${t.protocol}//${t.host}`;return e.toLocaleLowerCase().startsWith(s.toLocaleLowerCase())}catch{return!1}}var Gg=class Ji{static computeLink(t,s,i,n){let o=new RegExp(s.source,(s.flags||"")+"g"),[a,l]=Ji._getWindowedLineStrings(t-1,i),h=a.join(""),c,f=[];for(;c=o.exec(h);){let p=c[0];if(!Vg(p))continue;let[u,g]=Ji._mapStrIdx(i,l,0,c.index),[m,_]=Ji._mapStrIdx(i,u,g,p.length);if(u===-1||g===-1||m===-1||_===-1)continue;let x={start:{x:g+1,y:u+1},end:{x:_,y:m+1}};f.push({range:x,text:p,activate:n})}return f}static _getWindowedLineStrings(t,s){let i,n=t,o=t,a=0,l="",h=[];if(i=s.buffer.active.getLine(t)){let c=i.translateToString(!0);if(i.isWrapped&&c[0]!==" "){for(a=0;(i=s.buffer.active.getLine(--n))&&a<2048&&(l=i.translateToString(!0),a+=l.length,h.push(l),!(!i.isWrapped||l.indexOf(" ")!==-1)););h.reverse()}for(h.push(c),a=0;(i=s.buffer.active.getLine(++o))&&i.isWrapped&&a<2048&&(l=i.translateToString(!0),a+=l.length,h.push(l),l.indexOf(" ")===-1););}return[h,n]}static _mapStrIdx(t,s,i,n){let o=t.buffer.active,a=o.getNullCell(),l=i;for(;n;){let h=o.getLine(s);if(!h)return[-1,-1];for(let c=l;c<h.length;++c){h.getCell(c,a);let f=a.getChars();if(a.getWidth()&&(n-=f.length||1,c===h.length-1&&f==="")){let p=o.getLine(s+1);p&&p.isWrapped&&(p.getCell(0,a),a.getWidth()===2&&(n+=1))}if(n<0)return[s,c]}s++,l=0}return[s,l]}},Yg=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function Xg(e,t){let s=window.open();if(s){try{s.opener=null}catch{}s.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}var Jg=class{constructor(e=Xg,t={}){this._handler=e,this._options=t}activate(e){this._terminal=e;let t=this._options,s=t.urlRegex||Yg;this._linkProvider=this._terminal.registerLinkProvider(new qg(this._terminal,s,this._handler,t))}dispose(){var e;(e=this._linkProvider)==null||e.dispose()}};const jl=10,Zg=1e3,Qg=3e4;function ex({sessionId:e,isActive:t}){const s=d.useRef(null),i=d.useRef(null),n=d.useRef(null),o=d.useRef(null),a=d.useRef(null),l=d.useRef(!0),h=d.useRef(0),c=d.useCallback(()=>{const p=o.current,u=i.current;p&&p.readyState===WebSocket.OPEN&&u&&p.send(JSON.stringify({type:"resize",cols:u.cols,rows:u.rows}))},[]),f=d.useCallback(()=>{if(!l.current)return;o.current&&(o.current.onclose=null,o.current.onerror=null,o.current.close(),o.current=null);const u=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}${sn}/ws/terminal/${e}`,g=new WebSocket(u);o.current=g,g.onopen=()=>{h.current=0;const m=i.current;m&&m.writeln("\x1B[32m-- Terminal connected --\x1B[0m");const _=n.current;if(_&&m){try{_.fit()}catch{}c()}},g.onmessage=m=>{try{const _=JSON.parse(m.data);_.type==="output"&&i.current?i.current.write(_.data):_.type==="error"&&i.current&&i.current.writeln(`\x1B[31m${_.data}\x1B[0m`)}catch{i.current&&i.current.write(m.data)}},g.onclose=m=>{if(!l.current)return;const _=i.current;if(m.code===4e3){_&&_.writeln(`\r
221
+ \x1B[31m-- Terminal unavailable: `+(m.reason||"server rejected connection")+". --\x1B[0m");return}const x=h.current;if(x>=jl){_&&_.writeln(`\r
222
+ \x1B[31m-- Terminal disconnected. Max reconnect attempts reached. Refresh the page to try again. --\x1B[0m`);return}const y=Math.min(Zg*Math.pow(2,x),Qg);h.current=x+1,_&&_.writeln(`\r
223
+ \x1B[33m-- Terminal disconnected. Reconnecting in ${(y/1e3).toFixed(0)}s (attempt ${x+1}/${jl})... --\x1B[0m`),a.current=setTimeout(()=>{l.current&&f()},y)},g.onerror=()=>{}},[e,c]);return d.useEffect(()=>{l.current=!0,h.current=0;const p=s.current;if(!p)return;const u=new Hg({cursorBlink:!0,fontSize:13,fontFamily:"'JetBrains Mono', 'Fira Code', 'Cascadia Code', Menlo, Monaco, monospace",theme:{background:"#1a1a2e",foreground:"#e0e0e0",cursor:"#a78bfa",selectionBackground:"#3d3d5c",black:"#1a1a2e",red:"#ff6b6b",green:"#51cf66",yellow:"#ffd43b",blue:"#74c0fc",magenta:"#da77f2",cyan:"#66d9ef",white:"#e0e0e0",brightBlack:"#4a4a6a",brightRed:"#ff8787",brightGreen:"#69db7c",brightYellow:"#ffe066",brightBlue:"#91d5ff",brightMagenta:"#e599f7",brightCyan:"#99f7f5",brightWhite:"#ffffff"},scrollback:1e4,convertEol:!0,allowProposedApi:!0}),g=new Kg,m=new Jg;u.loadAddon(g),u.loadAddon(m),u.open(p),i.current=u,n.current=g;try{g.fit()}catch{}u.onData(y=>{const v=o.current;v&&v.readyState===WebSocket.OPEN&&v.send(JSON.stringify({type:"input",data:y}))}),f();let _=null;const x=new ResizeObserver(()=>{_&&clearTimeout(_),_=setTimeout(()=>{if(!(!n.current||!i.current))try{n.current.fit(),c()}catch{}},50)});return x.observe(p),()=>{l.current=!1,x.disconnect(),_&&clearTimeout(_),a.current&&clearTimeout(a.current),o.current&&(o.current.onclose=null,o.current.close(),o.current=null),u.dispose(),i.current=null,n.current=null}},[f,c]),d.useEffect(()=>{if(t&&n.current&&i.current){const p=setTimeout(()=>{var u;try{(u=n.current)==null||u.fit(),c()}catch{}},50);return()=>clearTimeout(p)}},[t,c]),r.jsx("div",{ref:s,className:"h-full w-full",style:{backgroundColor:"#1a1a2e"}})}const El={file_created:{icon:_r,color:"bg-blue-500",bgColor:"bg-blue-500/10",labelColor:"text-blue-600"},file_modified:{icon:Q,color:"bg-blue-400",bgColor:"bg-blue-400/10",labelColor:"text-blue-500"},dependency_install:{icon:Ql,color:"bg-teal-500",bgColor:"bg-teal-500/10",labelColor:"text-teal-600"},test_pass:{icon:ps,color:"bg-green-500",bgColor:"bg-green-500/10",labelColor:"text-green-600"},test_fail:{icon:sr,color:"bg-red-500",bgColor:"bg-red-500/10",labelColor:"text-red-500"},error:{icon:sr,color:"bg-red-500",bgColor:"bg-red-500/10",labelColor:"text-red-500"},narration:{icon:Gl,color:"bg-purple-500",bgColor:"bg-purple-500/10",labelColor:"text-purple-600"},command:{icon:os,color:"bg-gray-500",bgColor:"bg-gray-500/10",labelColor:"text-gray-600"},phase_change:{icon:Kt,color:"bg-primary",bgColor:"bg-primary/10",labelColor:"text-primary"},deploy:{icon:Kt,color:"bg-primary",bgColor:"bg-primary/10",labelColor:"text-primary"},warning:{icon:Ut,color:"bg-yellow-500",bgColor:"bg-yellow-500/10",labelColor:"text-yellow-600"},info:{icon:xd,color:"bg-gray-400",bgColor:"bg-gray-400/10",labelColor:"text-gray-500"}};function Dl(e){try{return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return""}}function tx({event:e,isLast:t,onFileClick:s}){const i=El[e.type]||El.info,n=i.icon,o=e.type==="narration";return r.jsxs("div",{className:"flex gap-3 group",children:[r.jsxs("div",{className:"flex flex-col items-center flex-shrink-0",children:[r.jsx("div",{className:`w-7 h-7 rounded-full flex items-center justify-center ${i.bgColor}`,children:r.jsx(n,{size:14,className:i.labelColor})}),!t&&r.jsx("div",{className:"w-px flex-1 bg-border min-h-[16px]"})]}),r.jsx("div",{className:"flex-1 min-w-0 pb-4 ",children:o?r.jsxs("div",{className:"relative bg-purple-500/5 border border-purple-500/20 rounded-lg px-3 py-2 mt-0.5",children:[r.jsx("div",{className:"absolute -left-1.5 top-2.5 w-2.5 h-2.5 bg-purple-500/5 border-l border-b border-purple-500/20 rotate-45"}),r.jsx("p",{className:"text-xs text-ink leading-relaxed",children:e.message}),e.detail&&r.jsx("p",{className:"text-[11px] text-muted mt-1 leading-relaxed",children:e.detail}),r.jsxs("span",{className:"text-[10px] text-muted/60 mt-1.5 flex items-center gap-1",children:[r.jsx(ut,{size:10}),Dl(e.timestamp)]})]}):r.jsxs("div",{className:"mt-1",children:[r.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[r.jsx("span",{className:`text-xs font-medium ${i.labelColor}`,children:e.message}),e.filePath&&s&&r.jsx("button",{onClick:()=>s(e.filePath),className:"text-[11px] font-mono text-primary hover:text-primary/80 hover:underline truncate max-w-[200px]",title:e.filePath,children:e.filePath})]}),r.jsxs("span",{className:"text-[10px] text-muted/60 flex items-center gap-1 mt-0.5",children:[r.jsx(ut,{size:10}),Dl(e.timestamp)]})]})})]})}const Xr=20,Rl=10;function sx({events:e,onFileClick:t,maxHeight:s}){const i=d.useRef(null),[n,o]=d.useState(!0);if(d.useEffect(()=>{i.current&&(i.current.scrollTop=i.current.scrollHeight)},[e.length]),d.useEffect(()=>{e.length>Xr},[e.length,n]),e.length===0)return r.jsxs("div",{className:"flex flex-col items-center justify-center py-10 text-center",children:[r.jsx(Vl,{size:28,className:"text-muted/30 mb-3"}),r.jsx("p",{className:"text-xs text-muted font-medium",children:"No build events yet"}),r.jsx("p",{className:"text-[11px] text-muted/70 mt-1",children:"Events will appear here as the build progresses."})]});const a=e.length>Xr&&n,l=a?e.slice(-Rl):e,h=a?e.length-Rl:0;return r.jsxs("div",{ref:i,className:"overflow-y-auto terminal-scroll px-3 py-3",style:{maxHeight:s||"100%"},children:[a&&h>0&&r.jsxs("button",{onClick:()=>o(!1),className:"flex items-center gap-1.5 text-[11px] text-primary hover:text-primary/80 font-medium mb-3 ml-9",children:[r.jsx(mr,{size:12}),"Show ",h," earlier event",h!==1?"s":""]}),!n&&e.length>Xr&&r.jsxs("button",{onClick:()=>o(!0),className:"flex items-center gap-1.5 text-[11px] text-primary hover:text-primary/80 font-medium mb-3 ml-9",children:[r.jsx(ms,{size:12}),"Collapse older events"]}),l.map((c,f)=>r.jsx(tx,{event:c,isLast:f===l.length-1,onFileClick:t},c.id))]})}const Pl=[{id:"terminal",label:"Terminal",icon:os,alwaysShow:!0},{id:"activity",label:"Activity",icon:Td,alwaysShow:!0},{id:"build",label:"Build Log",icon:zd},{id:"agents",label:"Agents",icon:Ad},{id:"quality",label:"Quality",icon:Yl}];function ix({status:e}){switch(e){case"pass":return r.jsx(Yt,{size:14,className:"text-success"});case"fail":return r.jsx(gt,{size:14,className:"text-danger"});default:return r.jsx(ut,{size:14,className:"text-muted"})}}function rx({agents:e}){return!e||e.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center p-6 text-center h-full",children:[r.jsx(vd,{size:24,className:"text-muted/30 mb-2"}),r.jsx("p",{className:"text-xs text-muted font-medium",children:"No agents active"}),r.jsx("p",{className:"text-[11px] text-muted/70 mt-0.5",children:"Agents appear here during active builds"})]}):r.jsx("div",{className:"p-2 space-y-1 overflow-y-auto terminal-scroll",children:e.map(t=>r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-btn bg-hover text-xs",children:[r.jsx("span",{className:"font-semibold text-ink truncate",children:t.name}),r.jsx("span",{className:"text-xs font-mono text-muted-accessible px-1.5 py-0.5 rounded-btn bg-card",children:t.type}),r.jsx("span",{className:`text-xs font-semibold ${t.status==="running"?"text-success":"text-muted"}`,children:t.status}),r.jsx("span",{className:"ml-auto text-xs text-muted-accessible font-mono truncate max-w-[200px]",children:t.task})]},t.id))})}function nx({checklist:e}){return!e||!e.items||e.items.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center p-6 text-center h-full",children:[r.jsx(Yl,{size:24,className:"text-muted/30 mb-2"}),r.jsx("p",{className:"text-xs text-muted font-medium",children:"No quality gate data"}),r.jsx("p",{className:"text-[11px] text-muted/70 mt-0.5",children:"Quality gates appear during active builds"})]}):r.jsxs("div",{className:"p-2 space-y-1 overflow-y-auto terminal-scroll",children:[r.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 text-xs text-muted-accessible font-semibold uppercase",children:[r.jsx("span",{children:"Gate"}),r.jsxs("span",{className:"ml-auto",children:[e.passed,"/",e.total," passed"]})]}),e.items.map(t=>r.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-btn hover:bg-hover text-xs",children:[r.jsx(ix,{status:t.status}),r.jsx("span",{className:"text-ink",children:t.label}),t.details&&r.jsx("span",{className:"ml-auto text-xs text-muted-accessible truncate max-w-[200px]",children:t.details})]},t.id))]})}function ox({logs:e,logsLoading:t,agents:s,checklist:i,sessionId:n,isRunning:o,subscribe:a,buildEvents:l,onFileClick:h}){var _;const[c,f]=d.useState("terminal"),p=s&&s.length>0,u=i&&i.items&&i.items.length>0,g=e&&e.length>0,m=Pl.filter(x=>!!(x.alwaysShow||x.id==="build"&&(g||o)||x.id==="agents"&&(p||o)||x.id==="quality"&&(u||o)));return m.find(x=>x.id===c)||f("terminal"),r.jsxs("div",{className:"h-full flex flex-col bg-card",children:[r.jsx("div",{role:"tablist",className:"flex items-center border-b border-border px-2 flex-shrink-0",children:m.map(x=>{const y=x.icon,v=c===x.id;return r.jsxs("button",{role:"tab","aria-selected":v,onClick:()=>f(x.id),className:`flex items-center gap-1.5 px-3 py-2 text-xs font-medium transition-colors border-b-2 ${v?"border-primary text-primary":"border-transparent text-muted hover:text-ink"}`,children:[r.jsx(y,{size:14}),x.label,x.id==="agents"&&p&&r.jsx("span",{className:"ml-0.5 px-1.5 py-0.5 text-[10px] font-bold rounded-full bg-primary/10 text-primary",children:s.length}),x.id==="quality"&&u&&r.jsxs("span",{className:"ml-0.5 px-1.5 py-0.5 text-[10px] font-bold rounded-full bg-success/10 text-success",children:[i.passed,"/",i.total]})]},x.id)})}),r.jsxs("div",{role:"tabpanel","aria-label":(_=Pl.find(x=>x.id===c))==null?void 0:_.label,className:"flex-1 min-h-0 overflow-hidden relative",children:[r.jsx("div",{className:"absolute inset-0",style:{visibility:c==="terminal"?"visible":"hidden",zIndex:c==="terminal"?1:0},children:r.jsx(ex,{sessionId:n,isActive:c==="terminal"})}),c==="build"&&r.jsx(Ld,{logs:e,loading:t,subscribe:a}),c==="agents"&&r.jsx(rx,{agents:s}),c==="activity"&&r.jsx(sx,{events:l||[],onFileClick:h}),c==="quality"&&r.jsx(nx,{checklist:i})]})]})}const Ml={ai:["Warming up the AI...","Reading your code...","Thinking about the best approach...","Running quality checks...","Almost there..."],build:["Working..."],deploy:["Preparing containers...","Pushing to the cloud...","Configuring services...","Running health checks...","Almost live..."],general:["Loading...","Getting things ready...","Just a moment...","Fetching data...","Almost there..."]};function ax({context:e="general",className:t=""}){const s=Ml[e]||Ml.general,[i,n]=d.useState(0),[o,a]=d.useState(!1);return d.useEffect(()=>{if(s.length<2)return;const l=setInterval(()=>{a(!0),setTimeout(()=>{n(h=>(h+1)%s.length),a(!1)},300)},3e3);return()=>clearInterval(l)},[s.length]),r.jsxs("div",{className:`flex items-center gap-2 ${t}`,children:[r.jsx(gi,{size:14,className:"animate-spin text-primary/60"}),r.jsx("span",{className:`text-xs text-muted transition-opacity duration-300 ${o?"opacity-0":"opacity-100"}`,children:s[i]})]})}const Jr=[{id:"planning",label:"Plan",color:"bg-blue-500",textColor:"text-blue-500",icon:eu},{id:"building",label:"Build",color:"bg-primary",textColor:"text-primary",icon:Od},{id:"testing",label:"Test",color:"bg-teal",textColor:"text-teal",icon:ai},{id:"reviewing",label:"Review",color:"bg-warning",textColor:"text-warning",icon:as},{id:"complete",label:"Done",color:"bg-success",textColor:"text-success",icon:ps}];function lx({phase:e,iteration:t,maxIterations:s,cost:i,startTime:n,isRunning:o}){const[a,l]=d.useState(null),[h,c]=d.useState(e),[f,p]=d.useState(!1);if(d.useEffect(()=>{if(!o||!n)return;const x=setInterval(()=>{l(Math.floor((Date.now()-n)/1e3))},1e3);return()=>clearInterval(x)},[o,n]),d.useEffect(()=>{if(e!==h){p(!0);const x=setTimeout(()=>{c(e),p(!1)},400);return()=>clearTimeout(x)}},[e,h]),!o&&e==="idle")return null;const u=Jr.findIndex(x=>x.id===e),g=t!==null&&s?Math.min(t/s*100,100):0,m=a!==null&&t&&s?Math.ceil(a/t*Math.max(0,s-t)):null,_=x=>x<60?`${x}s`:`${Math.floor(x/60)}m ${x%60}s`;return r.jsxs("div",{className:"flex-shrink-0 build-progress-container",children:[r.jsxs("div",{className:"h-1 bg-border relative overflow-hidden",children:[r.jsx("div",{className:"h-full bg-gradient-to-r from-primary to-teal build-progress-bar",style:{width:`${g}%`}}),o&&r.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-transparent via-white/20 to-transparent animate-shimmer"})]}),r.jsxs("div",{className:`px-4 py-1.5 flex items-center gap-4 bg-card border-b border-border text-xs ${f?"phase-transitioning":""}`,children:[r.jsx("div",{className:"flex items-center gap-1",children:Jr.map((x,y)=>{const v=y<u,j=y===u,k=x.icon;return r.jsxs("div",{className:`flex items-center gap-1 phase-indicator ${j?"phase-indicator-active":""} ${v?"phase-indicator-complete":""}`,children:[r.jsx("div",{className:`phase-icon-wrapper ${j?"phase-icon-active":""} ${v?"phase-icon-complete":""}`,children:v?r.jsx(ps,{size:14,className:"text-success phase-check-enter"}):j?r.jsx(k,{size:14,className:`${x.textColor} phase-icon-spin`}):r.jsx(k,{size:14,className:"text-muted/40"})}),r.jsx("span",{className:`text-[11px] font-medium transition-all duration-300 ${j?"text-ink":v?"text-success":"text-muted/50"}`,children:x.label}),y<Jr.length-1&&r.jsx("div",{className:`mx-1 h-px w-4 transition-all duration-500 ${v?"bg-success":"bg-border"}`})]},x.id)})}),o&&e!=="complete"&&e!=="idle"&&r.jsx(ax,{context:"build"}),r.jsx("div",{className:"flex-1"}),r.jsxs("div",{className:"flex items-center gap-3 text-muted",children:[r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(Ls,{size:12}),"Iter ",t??"--",s?`/${s}`:""]}),r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(ut,{size:12}),a===null?"--":_(a),o&&m!==null&&m>0&&r.jsxs("span",{className:"text-muted/60",children:["(est. ",_(m)," to iteration cap)"]})]}),r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(ec,{size:12}),i!==null?`$${i.toFixed(2)}`:"not recorded"]})]})]})]})}const Zr=[{id:"vercel",name:"Vercel",description:"Optimized for Next.js, React, and static sites with global CDN.",initial:"V",color:"text-ink",bgColor:"bg-ink/10",borderColor:"border-ink/20",tokenUrl:"https://vercel.com/account/tokens",tokenUrlLabel:"Get your token from vercel.com/account/tokens",hasTokenAuth:!0},{id:"netlify",name:"Netlify",description:"Deploy with CI/CD, serverless functions, and form handling.",initial:"N",color:"text-teal-600",bgColor:"bg-teal-500/10",borderColor:"border-teal-500/20",tokenUrl:"https://app.netlify.com/user/applications#personal-access-tokens",tokenUrlLabel:"Get your token from app.netlify.com/user/applications",hasTokenAuth:!0},{id:"github",name:"GitHub",description:"Free hosting for static sites directly from a GitHub repository.",initial:"G",color:"text-purple-600",bgColor:"bg-purple-500/10",borderColor:"border-purple-500/20",tokenUrl:"https://cli.github.com/",tokenUrlLabel:"Install GitHub CLI",hasTokenAuth:!1}];function cx({platform:e,onConnect:t}){const[s,i]=d.useState(""),[n,o]=d.useState(!1),[a,l]=d.useState(null),h=d.useCallback(async c=>{if(c.preventDefault(),!!s.trim()){o(!0),l(null);try{await t(s.trim()),i("")}catch(f){l(f instanceof Error?f.message:"Connection failed")}finally{o(!1)}}},[s,t]);return r.jsxs("form",{onSubmit:h,className:"mt-3 space-y-2.5",children:[r.jsxs("div",{children:[r.jsxs("label",{htmlFor:`token-${e.id}`,className:"sr-only",children:[e.name," Token"]}),r.jsx("input",{id:`token-${e.id}`,type:"password",value:s,onChange:c=>i(c.target.value),placeholder:`${e.name} access token`,disabled:n,className:`w-full px-3 py-2 text-sm border border-border rounded-lg bg-card text-ink
224
+ focus:border-primary focus:outline-none focus:ring-1 focus:ring-primary
225
+ placeholder:text-muted disabled:opacity-50`})]}),r.jsxs("div",{className:"flex items-center justify-between gap-2",children:[r.jsxs("a",{href:e.tokenUrl,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-[11px] text-primary hover:underline",children:[e.tokenUrlLabel,r.jsx(ls,{size:10})]}),r.jsx(le,{type:"submit",variant:"primary",size:"sm",loading:n,disabled:!s.trim()||n,children:"Connect"})]}),a&&r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-red-500 mt-1",children:[r.jsx(_s,{size:12}),a]})]})}function hx(){return r.jsxs("div",{className:"mt-3 space-y-2",children:[r.jsxs("div",{className:"flex items-start gap-2 bg-amber-500/5 border border-amber-500/15 rounded-lg px-3 py-2.5",children:[r.jsx(os,{size:14,className:"text-amber-600 flex-shrink-0 mt-0.5"}),r.jsxs("div",{className:"text-xs text-muted leading-relaxed",children:[r.jsx("p",{className:"font-medium text-ink mb-1",children:"Run in your terminal:"}),r.jsx("code",{className:"block bg-ink/5 rounded px-2 py-1 font-mono text-[11px] text-ink",children:"gh auth login"})]})]}),r.jsxs("a",{href:"https://cli.github.com/",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-[11px] text-primary hover:underline",children:["Install GitHub CLI",r.jsx(ls,{size:10})]})]})}function dx({platform:e,status:t,onConnect:s,onDisconnect:i}){const[n,o]=d.useState(!1),[a,l]=d.useState(!1),h=d.useCallback(async()=>{l(!0);try{i()}finally{l(!1)}},[i]),c=d.useCallback(async f=>{await s(f),o(!1)},[s]);return r.jsxs("div",{className:`border rounded-lg p-4 transition-colors ${t.connected?"border-green-500/30 bg-green-500/5":"border-border hover:border-primary/30 hover:bg-hover"}`,children:[r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:`w-10 h-10 rounded-lg flex items-center justify-center ${e.bgColor}`,children:r.jsx("span",{className:`text-sm font-bold ${e.color}`,children:e.initial})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("h4",{className:"text-sm font-semibold text-ink",children:e.name}),r.jsx("p",{className:"text-[11px] text-muted leading-snug mt-0.5",children:e.description})]}),r.jsx("div",{className:"flex-shrink-0",children:r.jsx("span",{className:`inline-block w-2.5 h-2.5 rounded-full ${t.connected?"bg-green-500":"bg-gray-300"}`,title:t.connected?"Connected":"Not connected"})})]}),t.connected?r.jsxs("div",{className:"mt-3 space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-green-600 font-medium",children:[r.jsx(ps,{size:14}),"Connected as ",t.user||"unknown"]}),t.last_deployed&&r.jsxs("p",{className:"text-[11px] text-muted",children:["Last deployed: ",new Date(t.last_deployed).toLocaleString()]}),r.jsx(le,{variant:"danger",size:"sm",icon:Iu,onClick:h,loading:a,className:"w-full",children:"Disconnect"})]}):r.jsxs(r.Fragment,{children:[t.error&&r.jsxs("div",{className:"mt-3 flex items-start gap-2 bg-red-500/5 border border-red-500/15 rounded-lg px-3 py-2",children:[r.jsx(_s,{size:14,className:"text-red-500 flex-shrink-0 mt-0.5"}),r.jsx("span",{className:"text-xs text-red-600",children:t.error})]}),e.hasTokenAuth?r.jsxs(r.Fragment,{children:[!n&&r.jsx("div",{className:"mt-3",children:r.jsx(le,{variant:"secondary",size:"sm",onClick:()=>o(!0),className:"w-full",children:t.error?`Reconnect ${e.name}`:`Connect ${e.name}`})}),n&&r.jsx(cx,{platform:e,onConnect:c})]}):r.jsx(hx,{})]})]})}function ux({compact:e=!1,onStatusChange:t}){const[s,i]=d.useState({vercel:{connected:!1},netlify:{connected:!1},github:{connected:!1}}),[n,o]=d.useState(!0),[a,l]=d.useState(null),h=d.useCallback(async()=>{try{const m=await W.getDeployStatus();i(m),t==null||t(m),l(null)}catch(m){l(m instanceof Error?m.message:"Failed to fetch connection status")}finally{o(!1)}},[t]);d.useEffect(()=>{h();const m=setInterval(h,3e4);return()=>clearInterval(m)},[h]);const c=d.useCallback(async m=>{const _=await W.connectVercel(m);_.success&&(i(x=>({...x,vercel:{connected:!0,user:_.user}})),t==null||t({...s,vercel:{connected:!0,user:_.user}}))},[s,t]),f=d.useCallback(async m=>{const _=await W.connectNetlify(m);_.success&&(i(x=>({...x,netlify:{connected:!0,user:_.user}})),t==null||t({...s,netlify:{connected:!0,user:_.user}}))},[s,t]),p=d.useCallback(async m=>{await W.disconnectPlatform(m),i(x=>({...x,[m]:{connected:!1}}));const _={...s,[m]:{connected:!1}};t==null||t(_)},[s,t]),u={vercel:c,netlify:f,github:async()=>{}};if(n)return r.jsxs("div",{className:"flex items-center justify-center py-8",children:[r.jsx(gi,{size:20,className:"text-primary animate-spin"}),r.jsx("span",{className:"text-sm text-muted ml-2",children:"Loading connections..."})]});const g=[s.vercel,s.netlify,s.github].filter(m=>m.connected).length;return r.jsxs("div",{className:e?"space-y-3":"space-y-4",children:[!e&&r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{children:[r.jsx("h3",{className:"text-sm font-semibold text-ink",children:"Platform Connections"}),r.jsxs("p",{className:"text-[11px] text-muted mt-0.5",children:[g," of ",Zr.length," platforms connected"]})]}),r.jsx("button",{onClick:h,className:"p-1.5 text-muted hover:text-ink rounded transition-colors",title:"Refresh connection status",children:r.jsx(bt,{size:14})})]}),e&&r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsx("div",{className:"flex items-center gap-3",children:Zr.map(m=>{const _=s[m.id];return r.jsxs("div",{className:"flex items-center gap-1.5",title:`${m.name}: ${_.connected?`Connected as ${_.user}`:"Not connected"}`,children:[r.jsx("span",{className:`w-2 h-2 rounded-full ${_.connected?"bg-green-500":"bg-gray-300"}`}),r.jsx("span",{className:"text-[11px] text-muted",children:m.name})]},m.id)})}),r.jsx("button",{onClick:h,className:"p-1 text-muted hover:text-ink rounded transition-colors",title:"Refresh",children:r.jsx(bt,{size:12})})]}),a&&r.jsxs("div",{className:"flex items-center gap-2 bg-red-500/5 border border-red-500/15 rounded-lg px-3 py-2",children:[r.jsx(_s,{size:14,className:"text-red-500 flex-shrink-0"}),r.jsx("span",{className:"text-xs text-red-600",children:a})]}),r.jsx("div",{className:e?"space-y-2":"space-y-3",children:Zr.map(m=>r.jsx(dx,{platform:m,status:s[m.id],onConnect:u[m.id],onDisconnect:()=>p(m.id)},m.id))})]})}const Ll={connected:"Connected",disconnected:"Not connected",checking:"Checking...",unknown:"Status unknown"},fx=[{id:"vercel",name:"Vercel",description:"Optimized for Next.js, React, and static sites. Global CDN with instant rollbacks.",icon:nn,color:"text-ink",bgColor:"bg-ink/5",connectionKey:"vercel"},{id:"netlify",name:"Netlify",description:"Deploy with CI/CD, serverless functions, and form handling built in.",icon:nn,color:"text-teal-600",bgColor:"bg-teal-500/5",connectionKey:"netlify"},{id:"github-pages",name:"GitHub Pages",description:"Free hosting for static sites directly from a GitHub repository.",icon:Te,color:"text-purple-600",bgColor:"bg-purple-500/5",connectionKey:"github"}];function mx({platform:e,deployState:t,onDeploy:s,disabled:i,connection:n}){const[o,a]=d.useState(!1),l=e.icon,h=d.useCallback(async()=>{if(t.url)try{await navigator.clipboard.writeText(t.url),a(!0),setTimeout(()=>a(!1),2e3)}catch{}},[t.url]),c=n==="connected",f=i||!c;return r.jsxs("div",{className:`border border-border rounded-lg p-4 transition-colors ${t.status==="success"?"border-green-500/30 bg-green-500/5":t.status==="error"?"border-red-500/30 bg-red-500/5":n==="disconnected"?"opacity-60":"hover:border-primary/30 hover:bg-hover"}`,children:[r.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[r.jsx("div",{className:`w-10 h-10 rounded-lg flex items-center justify-center ${e.bgColor}`,children:r.jsx(l,{size:20,className:e.color})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("h4",{className:"text-sm font-semibold text-ink",children:e.name}),r.jsx("p",{className:"text-[11px] text-muted leading-snug mt-0.5",children:e.description})]}),n==="checking"||n==="unknown"?r.jsx("span",{className:"text-[10px] text-muted flex-shrink-0",children:Ll[n]}):r.jsx("span",{className:`w-2.5 h-2.5 rounded-full flex-shrink-0 ${c?"bg-green-500":"bg-gray-300"}`,title:Ll[n]})]}),t.status==="idle"&&r.jsxs("div",{className:"relative group",children:[r.jsxs(le,{variant:"secondary",size:"sm",icon:Kt,onClick:s,disabled:f,className:"w-full",children:["Deploy to ",e.name]}),n==="disconnected"&&r.jsx("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",children:r.jsxs("span",{className:"bg-ink text-white text-[10px] px-2 py-1 rounded shadow opacity-0 group-hover:opacity-100 transition-opacity",children:["Connect ",e.name," first"]})})]}),t.status==="deploying"&&r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-btn bg-primary/5 border border-primary/20",children:[r.jsx(gi,{size:14,className:"text-primary animate-spin"}),r.jsxs("span",{className:"text-xs font-medium text-primary",children:["Deploying to ",e.name,"..."]})]}),t.status==="success"&&t.url&&r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-green-600 font-medium",children:[r.jsx(ps,{size:14}),"Deployed successfully"]}),r.jsxs("div",{className:"flex items-center gap-1.5 bg-card border border-border rounded-btn px-3 py-2",children:[r.jsx(nn,{size:12,className:"text-muted flex-shrink-0"}),r.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:"text-xs font-mono text-primary hover:underline truncate flex-1",children:t.url}),r.jsxs("button",{onClick:h,className:"flex items-center gap-1 text-[11px] text-muted hover:text-ink transition-colors flex-shrink-0",title:"Copy URL",children:[o?r.jsx(Yt,{size:12,className:"text-green-500"}):r.jsx(so,{size:12}),o?"Copied":"Copy"]}),r.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:"text-muted hover:text-ink transition-colors flex-shrink-0",title:"Open in new tab",children:r.jsx(ls,{size:12})})]})]}),t.status==="error"&&r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-red-500 font-medium",children:[r.jsx(_s,{size:14}),"Deploy failed"]}),r.jsx("p",{className:"text-[11px] text-muted bg-red-500/5 border border-red-500/10 rounded px-2 py-1.5 font-mono",children:t.error||"Unknown error"}),r.jsx(le,{variant:"secondary",size:"sm",icon:Kt,onClick:s,disabled:f,className:"w-full",children:"Retry"})]})]})}function px({sessionId:e,disabled:t}){const[s,i]=d.useState({status:"idle"}),[n,o]=d.useState(!1),a=d.useCallback(async()=>{i({status:"pushing"});try{const h=await W.githubPush(e);h.repo_url?i({status:"success",repoUrl:h.repo_url}):i({status:"error",error:h.error||"Push failed"})}catch(h){i({status:"error",error:h instanceof Error?h.message:"Push failed"})}},[e]),l=d.useCallback(async()=>{if(s.repoUrl)try{await navigator.clipboard.writeText(s.repoUrl),o(!0),setTimeout(()=>o(!1),2e3)}catch{}},[s.repoUrl]);return r.jsxs("div",{className:"border border-border rounded-lg p-4",children:[r.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[r.jsx("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center bg-ink/5",children:r.jsx(Te,{size:20,className:"text-ink"})}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("h4",{className:"text-sm font-semibold text-ink",children:"Push to GitHub"}),r.jsx("p",{className:"text-[11px] text-muted leading-snug mt-0.5",children:"Create a repository and push your code to GitHub."})]})]}),s.status==="idle"&&r.jsx(le,{variant:"secondary",size:"sm",icon:Te,onClick:a,disabled:t,className:"w-full",children:"Create Repo + Push"}),s.status==="pushing"&&r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-btn bg-primary/5 border border-primary/20",children:[r.jsx(gi,{size:14,className:"text-primary animate-spin"}),r.jsx("span",{className:"text-xs font-medium text-primary",children:"Creating repository and pushing..."})]}),s.status==="success"&&s.repoUrl&&r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-green-600 font-medium",children:[r.jsx(ps,{size:14}),"Pushed to GitHub"]}),r.jsxs("div",{className:"flex items-center gap-1.5 bg-card border border-border rounded-btn px-3 py-2",children:[r.jsx(Te,{size:12,className:"text-muted flex-shrink-0"}),r.jsx("a",{href:s.repoUrl,target:"_blank",rel:"noopener noreferrer",className:"text-xs font-mono text-primary hover:underline truncate flex-1",children:s.repoUrl}),r.jsxs("button",{onClick:l,className:"flex items-center gap-1 text-[11px] text-muted hover:text-ink transition-colors flex-shrink-0",title:"Copy URL",children:[n?r.jsx(Yt,{size:12,className:"text-green-500"}):r.jsx(so,{size:12}),n?"Copied":"Copy"]})]})]}),s.status==="error"&&r.jsxs("div",{className:"space-y-2",children:[r.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-red-500 font-medium",children:[r.jsx(_s,{size:14}),"Push failed"]}),r.jsx("p",{className:"text-[11px] text-muted bg-red-500/5 border border-red-500/10 rounded px-2 py-1.5 font-mono",children:s.error}),r.jsx(le,{variant:"secondary",size:"sm",icon:Te,onClick:a,disabled:t,className:"w-full",children:"Retry"})]})]})}function _x({sessionId:e}){const[t,s]=d.useState({vercel:{status:"idle"},netlify:{status:"idle"},"github-pages":{status:"idle"}}),[i,n]=d.useState(null),[o,a]=d.useState(!1);d.useEffect(()=>{W.getDeployStatus().then(n).catch(()=>a(!0))},[]);const[l,h]=d.useState(!1),c=Object.values(t).some(u=>u.status==="deploying"),f=d.useCallback(async u=>{s(g=>({...g,[u]:{status:"deploying"}}));try{const g=await W.deployProject(e,u);g.url?s(m=>({...m,[u]:{status:"success",url:g.url}})):s(m=>({...m,[u]:{status:"error",error:g.error||"Deploy failed"}}))}catch(g){s(m=>({...m,[u]:{status:"error",error:g instanceof Error?g.message:"Deploy failed"}}))}},[e]),p=u=>{var g;return i?(g=i[u.connectionKey])!=null&&g.connected?"connected":"disconnected":o?"unknown":"checking"};return r.jsx("div",{className:"h-full overflow-y-auto terminal-scroll",children:r.jsxs("div",{className:"p-6 max-w-2xl mx-auto space-y-6",children:[r.jsxs("div",{children:[r.jsxs("h3",{className:"text-lg font-heading font-bold text-ink flex items-center gap-2",children:[r.jsx(Kt,{size:20,className:"text-primary"}),"Deploy Your Project"]}),r.jsx("p",{className:"text-xs text-muted mt-1",children:"Choose a platform to deploy your project. One click to go live."})]}),r.jsxs("div",{className:"border border-border rounded-lg overflow-hidden",children:[r.jsxs("button",{type:"button",onClick:()=>h(!l),className:"flex items-center justify-between w-full px-4 py-3 text-left hover:bg-hover transition-colors",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(lc,{size:16,className:"text-primary"}),r.jsx("span",{className:"text-sm font-medium text-ink",children:"Platform Connections"}),r.jsx("div",{className:"flex items-center gap-1 ml-2",children:i?["vercel","netlify","github"].map(u=>{var g,m;return r.jsx("span",{className:`w-2 h-2 rounded-full ${(g=i[u])!=null&&g.connected?"bg-green-500":"bg-gray-300"}`,title:`${u}: ${(m=i[u])!=null&&m.connected?"Connected":"Not connected"}`},u)}):r.jsx("span",{className:"text-[11px] text-muted",children:o?"Status unknown":"Checking..."})})]}),r.jsx("span",{className:"text-xs text-muted",children:l?"Hide":"Manage"})]}),l&&r.jsx("div",{className:"border-t border-border p-4",children:r.jsx(ux,{compact:!0,onStatusChange:n})})]}),r.jsx("div",{className:"space-y-3",children:fx.map(u=>r.jsx(mx,{platform:u,deployState:t[u.id],onDeploy:()=>f(u.id),disabled:c,connection:p(u)},u.id))}),r.jsx("div",{className:"border-t border-border"}),r.jsx(px,{sessionId:e,disabled:c})]})})}const Ch=typeof navigator<"u"&&/Mac/.test(navigator.userAgent),Et=Ch?"Cmd":"Ctrl",Bl=[{keys:[`${Et}+K`],label:"Open Command Palette",category:"navigation"},{keys:[`${Et}+P`],label:"Quick open file",category:"navigation"},{keys:[`${Et}+,`],label:"Open settings",category:"navigation"},{keys:[`${Et}+S`],label:"Save file",category:"editor"},{keys:[`${Et}+Z`],label:"Undo",category:"editor"},{keys:[`${Et}+Shift+Z`],label:"Redo",category:"editor"},{keys:[`${Et}+B`],label:"Start / stop build",category:"build"},{keys:[`${Et}+\``],label:"Toggle terminal",category:"build"},{keys:["?"],label:"Show keyboard shortcuts",category:"general"},{keys:[`${Et}+?`],label:"Show keyboard shortcuts (alt)",category:"general"},{keys:["Escape"],label:"Close modals",category:"general"}],gx={navigation:"Navigation",editor:"Editor",build:"Build",general:"General"},xx=["navigation","editor","build","general"];function vx({onToggleTerminal:e,onToggleBuild:t}){const[s,i]=d.useState(!1),n=d.useCallback(o=>{var c,f;const a=Ch?o.metaKey:o.ctrlKey,l=(c=o.target)==null?void 0:c.tagName,h=l==="INPUT"||l==="TEXTAREA"||((f=o.target)==null?void 0:f.isContentEditable);if(a&&(o.key==="?"||o.shiftKey&&o.key==="/")){o.preventDefault(),i(p=>!p);return}if(o.key==="?"&&!a&&!h){o.preventDefault(),i(p=>!p);return}if(a&&o.key==="`"){o.preventDefault(),e==null||e();return}if(a&&o.key==="b"){o.preventDefault(),t==null||t();return}o.key==="Escape"&&s&&i(!1)},[e,t,s]);return d.useEffect(()=>(window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)),[n]),{showHelp:s,setShowHelp:i}}function bx({open:e,onClose:t}){const[s,i]=d.useState("");d.useEffect(()=>{e&&i("")},[e]);const n=d.useMemo(()=>{if(!s.trim())return Bl;const a=s.toLowerCase();return Bl.filter(l=>l.label.toLowerCase().includes(a)||l.keys.some(h=>h.toLowerCase().includes(a))||l.category.toLowerCase().includes(a))},[s]),o=d.useMemo(()=>{const a={};for(const l of n)a[l.category]||(a[l.category]=[]),a[l.category].push(l);return a},[n]);return e?r.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-ink/20",onClick:t,children:r.jsxs("div",{className:"bg-card rounded-xl shadow-2xl border border-border w-full max-w-md mx-4 overflow-hidden",onClick:a=>a.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-border",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(bd,{size:16,className:"text-primary"}),r.jsx("h2",{className:"text-sm font-heading font-bold text-ink",children:"Keyboard Shortcuts"})]}),r.jsx("button",{onClick:t,className:"text-muted hover:text-ink transition-colors p-1 rounded-btn hover:bg-hover",children:r.jsx(gt,{size:16})})]}),r.jsx("div",{className:"px-4 py-2 border-b border-border",children:r.jsxs("div",{className:"relative",children:[r.jsx(as,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted"}),r.jsx("input",{type:"text",value:s,onChange:a=>i(a.target.value),placeholder:"Filter shortcuts...",className:"w-full pl-9 pr-3 py-1.5 text-xs bg-card border border-border rounded-btn outline-none focus:border-primary transition-colors",autoFocus:!0})]})}),r.jsxs("div",{className:"max-h-[400px] overflow-y-auto terminal-scroll",children:[xx.map(a=>{const l=o[a];return!l||l.length===0?null:r.jsxs("div",{children:[r.jsx("div",{className:"px-5 pt-3 pb-1",children:r.jsx("span",{className:"text-[10px] font-semibold text-muted uppercase tracking-wider",children:gx[a]})}),r.jsx("div",{className:"px-4 space-y-0.5 pb-2",children:l.map(h=>r.jsxs("div",{className:"flex items-center justify-between px-2 py-2 rounded-btn hover:bg-hover",children:[r.jsx("span",{className:"text-xs text-ink",children:h.label}),r.jsx("div",{className:"flex items-center gap-1",children:h.keys.map(c=>r.jsx("kbd",{className:"px-2 py-0.5 text-[11px] font-mono bg-hover border border-border rounded text-muted-accessible",children:c},c))})]},h.label))})]},a)}),n.length===0&&r.jsx("div",{className:"px-5 py-8 text-center",children:r.jsxs("p",{className:"text-xs text-muted",children:['No shortcuts matching "',s,'"']})})]}),r.jsx("div",{className:"px-5 py-3 border-t border-border text-center",children:r.jsxs("span",{className:"text-[11px] text-muted",children:["Press ",r.jsx("kbd",{className:"px-1.5 py-0.5 text-[10px] font-mono bg-hover border border-border rounded",children:"Escape"})," to close"]})})]})}):null}function yx({onClick:e}){return r.jsx("button",{onClick:e,title:"Keyboard shortcuts",className:"inline-flex items-center justify-center w-7 h-7 rounded-btn text-muted hover:text-ink hover:bg-hover transition-colors text-xs font-bold",children:"?"})}const kh="pl_recent_commands",Sx=5;function Nh(){try{const e=localStorage.getItem(kh);return e?JSON.parse(e):[]}catch{return[]}}function Qr(e){try{const t=Nh().filter(s=>s!==e);t.unshift(e),localStorage.setItem(kh,JSON.stringify(t.slice(0,Sx)))}catch{}}function wx(e){var i;const t=((i=e.split(".").pop())==null?void 0:i.toLowerCase())||"";return{js:Q,ts:Q,tsx:Q,jsx:Q,py:Q,go:Q,rs:Q,rb:Q,sh:Q,html:ac,css:no,json:ro,md:_i}[t]||oo}function Cx(e,t){const s=e.toLowerCase(),i=t.toLowerCase(),n=[];let o=0;for(let a=0;a<i.length&&o<s.length;a++)i[a]===s[o]&&(n.push(a),o++);return o===s.length?n:null}function Tl({text:e,indices:t}){if(t.length===0)return r.jsx(r.Fragment,{children:e});const s=new Set(t);return r.jsx(r.Fragment,{children:e.split("").map((i,n)=>s.has(n)?r.jsx("span",{className:"text-primary font-semibold",children:i},n):r.jsx("span",{children:i},n))})}function kx({isOpen:e,onClose:t,commands:s,sessionId:i,onFileSelect:n}){const[o,a]=d.useState(""),[l,h]=d.useState(0),[c,f]=d.useState([]),[p,u]=d.useState(!1),g=d.useRef(null),m=d.useRef(null),_=yd(e);Sd(e,t),d.useEffect(()=>{e&&(a(""),h(0),f([]),u(!1),setTimeout(()=>{var S;return(S=g.current)==null?void 0:S.focus()},50))},[e]);const x=d.useMemo(()=>Nh().map(C=>s.find(D=>D.id===C)).filter(Boolean),[s]),y=d.useMemo(()=>{if(!o.trim())return s.map(C=>({cmd:C,indices:[]}));const S=[];for(const C of s){const D=Cx(o,C.label);if(D){const L=D[0]*10+(D[D.length-1]-D[0]);S.push({cmd:C,indices:D,score:L})}}return S.sort((C,D)=>C.score-D.score),S.map(C=>({cmd:C.cmd,indices:C.indices}))},[s,o]),v=d.useMemo(()=>o.trim()?y.filter(S=>S.cmd.category==="setting"):[],[y,o]),j=d.useMemo(()=>y.filter(S=>S.cmd.category!=="setting"),[y]);d.useEffect(()=>{if(!i||!o.trim()){f([]),u(!1);return}return u(!0),m.current&&clearTimeout(m.current),m.current=setTimeout(async()=>{try{const S=await W.searchFiles(i,o);f(S.filter(C=>C.type==="file"))}catch{f([])}u(!1)},200),()=>{m.current&&clearTimeout(m.current)}},[o,i]);const k=!o.trim()&&x.length>0,w=d.useMemo(()=>{const S=[];return k&&x.forEach((C,D)=>S.push({type:"recent",index:D})),j.forEach((C,D)=>S.push({type:"command",index:D})),v.length>0&&v.forEach((C,D)=>S.push({type:"setting",index:D})),c.forEach((C,D)=>S.push({type:"file",index:D})),S},[k,x,j,v,c]),N=w.length;d.useEffect(()=>{h(0)},[o]);const M=d.useCallback(S=>{const C=w[S];if(C){if(C.type==="recent"){const D=x[C.index];D&&(Qr(D.id),D.action(),t())}else if(C.type==="command"){const D=j[C.index];D&&(Qr(D.cmd.id),D.cmd.action(),t())}else if(C.type==="setting"){const D=v[C.index];D&&(Qr(D.cmd.id),D.cmd.action(),t())}else if(C.type==="file"){const D=c[C.index];D&&n&&(n(D.path,D.name),t())}}},[w,x,j,v,c,n,t]),U=d.useCallback(S=>{S.key==="ArrowDown"?(S.preventDefault(),h(C=>Math.min(C+1,N-1))):S.key==="ArrowUp"?(S.preventDefault(),h(C=>Math.max(C-1,0))):S.key==="Enter"&&N>0?M(l):S.key==="Escape"&&t()},[N,l,M,t]);if(!e)return null;let Y=0;const V=()=>Y++,$=j.length>0,P=v.length>0,E=c.length>0,B=p&&o.trim().length>0;return r.jsxs("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[20vh]",onClick:t,children:[r.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm"}),r.jsxs("div",{ref:_,className:"relative w-full max-w-lg bg-card rounded-xl shadow-2xl border border-border overflow-hidden",onClick:S=>S.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border",children:[r.jsx(as,{size:18,className:"text-muted"}),r.jsx("input",{ref:g,value:o,onChange:S=>a(S.target.value),onKeyDown:U,placeholder:"Search commands, files, settings...",className:"flex-1 bg-transparent text-sm outline-none text-ink placeholder:text-muted"}),r.jsx("kbd",{className:"text-[10px] text-muted bg-hover px-1.5 py-0.5 rounded border border-border font-mono",children:"ESC"})]}),r.jsxs("div",{className:"max-h-[360px] overflow-y-auto py-1 terminal-scroll",children:[k&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"px-4 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider flex items-center gap-1.5",children:[r.jsx(ut,{size:10})," Recent"]}),x.map((S,C)=>{const D=V(),L=S.icon;return r.jsxs("button",{onClick:()=>M(D),className:`w-full flex items-center gap-3 px-4 py-2.5 text-sm transition-colors ${D===l?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[r.jsx(L,{size:16}),r.jsx("span",{className:"flex-1 text-left",children:S.label}),S.shortcut&&r.jsx("kbd",{className:"text-[10px] text-muted bg-hover px-1.5 py-0.5 rounded border border-border font-mono",children:S.shortcut})]},`recent-${S.id}`)})]}),$&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"px-4 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider",children:"Commands"}),j.map((S,C)=>{const D=V(),L=S.cmd.icon;return r.jsxs("button",{onClick:()=>M(D),className:`w-full flex items-center gap-3 px-4 py-2.5 text-sm transition-colors ${D===l?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[r.jsx(L,{size:16}),r.jsx("span",{className:"flex-1 text-left",children:o.trim()?r.jsx(Tl,{text:S.cmd.label,indices:S.indices}):S.cmd.label}),S.cmd.shortcut&&r.jsx("kbd",{className:"text-[10px] text-muted bg-hover px-1.5 py-0.5 rounded border border-border font-mono",children:S.cmd.shortcut})]},S.cmd.id)})]}),P&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"px-4 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider mt-1",children:"Settings"}),v.map((S,C)=>{const D=V(),L=S.cmd.icon;return r.jsxs("button",{onClick:()=>M(D),className:`w-full flex items-center gap-3 px-4 py-2.5 text-sm transition-colors ${D===l?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[r.jsx(L,{size:16}),r.jsx("span",{className:"flex-1 text-left",children:r.jsx(Tl,{text:S.cmd.label,indices:S.indices})}),S.cmd.shortcut&&r.jsx("kbd",{className:"text-[10px] text-muted bg-hover px-1.5 py-0.5 rounded border border-border font-mono",children:S.cmd.shortcut})]},`setting-${S.cmd.id}`)})]}),E&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"px-4 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider mt-1",children:"Files"}),c.map((S,C)=>{const D=V(),L=S.type==="directory"?ao:wx(S.name);return r.jsxs("button",{onClick:()=>M(D),className:`w-full flex items-center gap-3 px-4 py-2 text-sm transition-colors ${D===l?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[r.jsx(L,{size:14}),r.jsx("span",{className:"flex-1 text-left font-mono text-xs truncate",children:S.name}),r.jsx("span",{className:"text-[10px] text-muted truncate max-w-[200px]",children:S.path})]},`file-${S.path}`)})]}),B&&!E&&r.jsx("div",{className:"px-4 py-2 text-xs text-muted animate-pulse",children:"Searching files..."}),N===0&&!B&&r.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted",children:"No results found"})]})]})]})}const Nx=d.lazy(()=>eo(()=>import("./GitHubIssuesPanel-BC5GzKUN.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9])).then(e=>({default:e.GitHubIssuesPanel}))),jx=d.lazy(()=>eo(()=>import("./GitHubPRsPanel-BSlmoVTS.js"),__vite__mapDeps([10,1,2,3,11,4,5,6,12,13,14,15,16,17,18,19,20,21,22,23,8,24,25,26,27,28,29,9,30,31,32,33,34])).then(e=>({default:e.GitHubPRsPanel}))),Ex=d.lazy(()=>eo(()=>Promise.resolve().then(()=>qx),void 0).then(e=>({default:e.CICDPanel}))),Dx=3e4,Rx={modified:r.jsx(Q,{size:13,className:"text-yellow-500"}),added:r.jsx(_r,{size:13,className:"text-green-500"}),deleted:r.jsx(io,{size:13,className:"text-red-400"}),renamed:r.jsx(Q,{size:13,className:"text-blue-400"}),untracked:r.jsx(sc,{size:13,className:"text-muted"})},Px={modified:"M",added:"A",deleted:"D",renamed:"R",untracked:"?"};function Mx({commit:e}){return r.jsx("div",{className:"px-3 py-2 border-b border-border hover:bg-hover transition-colors",children:r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx(tc,{size:14,className:"text-primary mt-0.5 flex-shrink-0"}),r.jsxs("div",{className:"min-w-0 flex-1",children:[r.jsx("p",{className:"text-xs font-medium text-ink truncate",children:e.message}),r.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[r.jsx("span",{className:"text-[11px] font-mono text-primary/70",children:e.short_hash}),r.jsx("span",{className:"text-[11px] text-muted",children:e.author}),r.jsx("span",{className:"text-[11px] text-muted ml-auto flex-shrink-0",children:e.date})]}),e.refs.length>0&&r.jsx("div",{className:"flex gap-1 mt-1",children:e.refs.map((t,s)=>r.jsxs("span",{className:"inline-flex items-center gap-0.5 px-1.5 py-0.5 text-[10px] font-mono bg-primary/10 text-primary rounded",children:[r.jsx(Te,{size:9}),t]},s))})]})]})})}function zl({file:e}){return r.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 hover:bg-hover transition-colors text-xs",children:[Rx[e.status]||r.jsx(sc,{size:13}),r.jsx("span",{className:"font-mono text-ink truncate flex-1",children:e.path}),r.jsx("span",{className:`font-mono text-[10px] px-1 rounded ${e.staged?"bg-green-500/10 text-green-500":"bg-muted/10 text-muted"}`,children:Px[e.status]||"?"})]})}function Lx({sessionId:e}){const[t,s]=d.useState("changes"),[i,n]=d.useState(null),[o,a]=d.useState([]),[l,h]=d.useState([]),[c,f]=d.useState(!0),[p,u]=d.useState(null),[g,m]=d.useState(""),[_,x]=d.useState(!1),[y,v]=d.useState(null),[j,k]=d.useState(!1),[w,N]=d.useState(""),[M,U]=d.useState(!1),[Y,V]=d.useState(!1),[$,P]=d.useState(""),[E,B]=d.useState(""),[S,C]=d.useState(!1),[D,L]=d.useState(null),[Z,oe]=d.useState(!1),q=d.useCallback(async()=>{f(!0),u(null);try{const[z,xe,T]=await Promise.all([W.git.status(e),W.git.log(e),W.git.branches(e)]);n(z),a(xe),h(T)}catch(z){u(z instanceof Error?z.message:"Failed to load git data")}f(!1)},[e]);d.useEffect(()=>{q()},[q]);const J=async()=>{if(!(!g.trim()||_)){x(!0),v(null);try{const z=await W.git.commit(e,g.trim());v(`Committed: ${z.hash}`),m(""),await q()}catch(z){v(`Error: ${z instanceof Error?z.message:"Commit failed"}`)}x(!1)}},se=async()=>{if(!(!w.trim()||M)){U(!0);try{await W.git.createBranch(e,w.trim()),N(""),k(!1),await q()}catch(z){u(z instanceof Error?z.message:"Branch creation failed")}U(!1)}},de=async z=>{try{await W.git.checkoutBranch(e,z),await q()}catch(xe){u(xe instanceof Error?xe.message:"Checkout failed")}},ue=async()=>{oe(!0);try{await W.git.push(e),await q()}catch(z){u(z instanceof Error?z.message:"Push failed")}oe(!1)},ce=async()=>{if(!(!$.trim()||S)){C(!0),L(null);try{const z=await W.git.pr(e,$.trim(),E.trim());L(z.url),P(""),B(""),V(!1)}catch(z){L(`Error: ${z instanceof Error?z.message:"PR creation failed"}`)}C(!1)}},ge=(i==null?void 0:i.files.filter(z=>z.staged))||[],Fe=(i==null?void 0:i.files.filter(z=>!z.staged))||[];return c&&!i?r.jsx("div",{className:"h-full flex items-center justify-center",children:r.jsxs("div",{className:"flex flex-col items-center gap-2",children:[r.jsx(bt,{size:20,className:"text-muted animate-spin"}),r.jsx("span",{className:"text-xs text-muted",children:"Loading git status..."})]})}):p&&!i?r.jsx("div",{className:"h-full flex items-center justify-center p-6",children:r.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[r.jsx(_s,{size:32,className:"text-muted/40"}),r.jsx("p",{className:"text-sm text-muted",children:p}),r.jsx("p",{className:"text-xs text-muted/60",children:"This project may not be a git repository."}),r.jsx(le,{size:"sm",variant:"secondary",icon:bt,onClick:q,children:"Retry"})]})}):r.jsxs("div",{className:"h-full flex flex-col",children:[r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border bg-hover flex-shrink-0",children:[r.jsx(Te,{size:14,className:"text-primary"}),r.jsx("span",{className:"text-xs font-semibold text-ink",children:(i==null?void 0:i.branch)||"unknown"}),i&&(i.ahead>0||i.behind>0)&&r.jsxs("span",{className:"text-[10px] text-muted font-mono",children:[i.ahead>0&&`+${i.ahead}`,i.ahead>0&&i.behind>0&&" / ",i.behind>0&&`-${i.behind}`]}),(i==null?void 0:i.clean)&&r.jsxs("span",{className:"flex items-center gap-0.5 text-[10px] text-green-500",children:[r.jsx(Yt,{size:10})," Clean"]}),r.jsx("div",{className:"flex-1"}),r.jsx("button",{onClick:q,className:"p-1 text-muted hover:text-ink rounded transition-colors",title:"Refresh",children:r.jsx(bt,{size:13,className:c?"animate-spin":""})})]}),r.jsx("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b border-border flex-shrink-0",children:[{id:"changes",label:"Changes",icon:Q,count:(i==null?void 0:i.files.length)||0},{id:"history",label:"History",icon:ut},{id:"branches",label:"Branches",icon:Te,count:l.length}].map(z=>r.jsxs("button",{onClick:()=>s(z.id),className:`flex items-center gap-1 px-2.5 py-1 text-[11px] font-medium rounded-btn transition-colors ${t===z.id?"bg-primary/10 text-primary":"text-muted hover:text-ink"}`,children:[r.jsx(z.icon,{size:12}),z.label,z.count!==void 0&&z.count>0&&r.jsx("span",{className:"ml-0.5 px-1 py-0 text-[9px] rounded-full bg-primary/20 text-primary font-mono",children:z.count})]},z.id))}),p&&r.jsx("div",{className:"px-3 py-2 bg-red-500/5 border-b border-red-500/20 text-xs text-red-400",children:p}),r.jsxs("div",{className:"flex-1 overflow-y-auto terminal-scroll",children:[t==="changes"&&r.jsx("div",{className:"flex flex-col h-full",children:(i==null?void 0:i.files.length)===0?r.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[r.jsx(Yt,{size:28,className:"text-green-500/30 mb-2"}),r.jsx("p",{className:"text-xs text-muted",children:"Working tree clean"}),r.jsx("p",{className:"text-[11px] text-muted/60 mt-0.5",children:"No changes to commit."})]}):r.jsxs(r.Fragment,{children:[ge.length>0&&r.jsxs("div",{children:[r.jsxs("div",{className:"px-3 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider bg-green-500/5 border-b border-border",children:["Staged (",ge.length,")"]}),ge.map((z,xe)=>r.jsx(zl,{file:z},`s-${xe}`))]}),Fe.length>0&&r.jsxs("div",{children:[r.jsxs("div",{className:"px-3 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider bg-yellow-500/5 border-b border-border",children:["Unstaged (",Fe.length,")"]}),Fe.map((z,xe)=>r.jsx(zl,{file:z},`u-${xe}`))]}),r.jsxs("div",{className:"mt-auto border-t border-border p-3 space-y-2 flex-shrink-0",children:[r.jsx("textarea",{value:g,onChange:z=>m(z.target.value),placeholder:"Commit message...",rows:2,className:"w-full px-3 py-1.5 text-xs bg-card border border-border rounded-btn outline-none focus:border-primary transition-colors resize-none font-mono"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(le,{size:"sm",icon:tc,onClick:J,disabled:!g.trim()||_,loading:_,children:"Commit"}),r.jsx(le,{size:"sm",variant:"secondary",icon:rc,onClick:ue,loading:Z,disabled:Z,children:"Push"}),r.jsx(le,{size:"sm",variant:"ghost",icon:an,onClick:()=>V(!Y),children:"PR"})]}),y&&r.jsx("p",{className:`text-[11px] font-mono ${y.startsWith("Error")?"text-red-400":"text-green-500"}`,children:y}),D&&r.jsx("p",{className:"text-[11px] font-mono text-primary",children:D.startsWith("Error")?r.jsx("span",{className:"text-red-400",children:D}):r.jsx("a",{href:D,target:"_blank",rel:"noopener noreferrer",className:"underline hover:text-primary/80",children:D})})]}),Y&&r.jsxs("div",{className:"border-t border-border p-3 space-y-2 flex-shrink-0 bg-hover",children:[r.jsx("p",{className:"text-[11px] font-semibold text-ink",children:"Create Pull Request"}),r.jsx("input",{value:$,onChange:z=>P(z.target.value),placeholder:"PR title...",className:"w-full px-3 py-1.5 text-xs bg-card border border-border rounded-btn outline-none focus:border-primary"}),r.jsx("textarea",{value:E,onChange:z=>B(z.target.value),placeholder:"PR description (optional)...",rows:3,className:"w-full px-3 py-1.5 text-xs bg-card border border-border rounded-btn outline-none focus:border-primary resize-none"}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx(le,{size:"sm",icon:an,onClick:ce,disabled:!$.trim()||S,loading:S,children:"Create PR"}),r.jsx(le,{size:"sm",variant:"ghost",onClick:()=>V(!1),children:"Cancel"})]})]})]})}),t==="history"&&r.jsx("div",{children:o.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[r.jsx(ut,{size:28,className:"text-muted/30 mb-2"}),r.jsx("p",{className:"text-xs text-muted",children:"No commits yet"})]}):o.map((z,xe)=>r.jsx(Mx,{commit:z},xe))}),t==="branches"&&r.jsxs("div",{children:[r.jsx("div",{className:"px-3 py-2 border-b border-border flex items-center gap-2",children:r.jsxs("button",{onClick:()=>k(!j),className:"flex items-center gap-1 text-xs text-primary hover:text-primary/80 font-medium",children:[r.jsx(gr,{size:12}),"New Branch"]})}),j&&r.jsxs("div",{className:"px-3 py-2 border-b border-border bg-hover flex items-center gap-2",children:[r.jsx("input",{value:w,onChange:z=>N(z.target.value),placeholder:"branch-name",className:"flex-1 px-2 py-1 text-xs font-mono bg-card border border-border rounded-btn outline-none focus:border-primary",onKeyDown:z=>{z.key==="Enter"&&se()}}),r.jsx(le,{size:"sm",onClick:se,disabled:!w.trim()||M,loading:M,children:"Create"})]}),l.length===0?r.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[r.jsx(Te,{size:28,className:"text-muted/30 mb-2"}),r.jsx("p",{className:"text-xs text-muted",children:"No branches found"})]}):r.jsxs("div",{children:[l.filter(z=>!z.remote).map((z,xe)=>r.jsxs("button",{onClick:()=>!z.current&&de(z.name),disabled:z.current,className:`w-full text-left flex items-center gap-2 px-3 py-2 text-xs border-b border-border transition-colors ${z.current?"bg-primary/5":"hover:bg-hover cursor-pointer"}`,children:[r.jsx(Te,{size:13,className:z.current?"text-primary":"text-muted"}),r.jsx("span",{className:`font-mono ${z.current?"text-primary font-semibold":"text-ink"}`,children:z.name}),z.current&&r.jsx("span",{className:"ml-auto text-[10px] bg-primary/10 text-primary px-1.5 py-0.5 rounded font-medium",children:"current"})]},`l-${xe}`)),l.filter(z=>z.remote).length>0&&r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"px-3 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider bg-hover border-b border-border",children:"Remote"}),l.filter(z=>z.remote).map((z,xe)=>r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs border-b border-border",children:[r.jsx(Te,{size:13,className:"text-muted/60"}),r.jsx("span",{className:"font-mono text-muted",children:z.name})]},`r-${xe}`))]})]})]})]})]})}function en(){return r.jsx("div",{className:"h-full flex items-center justify-center",children:r.jsxs("div",{className:"flex flex-col items-center gap-2",children:[r.jsx(bt,{size:20,className:"text-muted animate-spin"}),r.jsx("span",{className:"text-xs text-muted",children:"Loading..."})]})})}function tn({sessionId:e,onPushed:t}){const[s,i]=d.useState(!1),[n,o]=d.useState(null),a=async()=>{i(!0),o(null);try{await W.githubPush(e),t()}catch(l){o(l instanceof Error?l.message:"Push to GitHub failed")}i(!1)};return r.jsx("div",{className:"h-full flex items-center justify-center p-8",children:r.jsxs("div",{className:"flex flex-col items-center gap-4 text-center max-w-xs",children:[r.jsx(cu,{size:40,className:"text-muted/30"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-medium text-ink",children:"This project isn't connected to GitHub yet"}),r.jsx("p",{className:"text-xs text-muted mt-1",children:"Push your project to GitHub to access issues, pull requests, and CI/CD workflows."})]}),r.jsx("div",{className:"flex items-center gap-2",children:r.jsx(le,{size:"sm",icon:rc,onClick:a,loading:s,children:"Push to GitHub"})}),n&&r.jsx("p",{className:"text-[11px] text-red-400 font-mono",children:n})]})})}function Bx({sessionId:e}){const[t,s]=d.useState("changes"),[i,n]=d.useState(!0),[o,a]=d.useState(null),[l,h]=d.useState({actions:0,fetchedAt:0}),c=d.useRef(!1),f=d.useCallback(async()=>{n(!0);try{const _=await W.git.branches(e);a({has_remote:_.some(x=>x.remote)})}catch{a(null)}n(!1)},[e]);d.useEffect(()=>{f()},[f]);const p=d.useCallback(async()=>{if(!(o!=null&&o.has_remote)||Date.now()-l.fetchedAt<Dx||c.current)return;c.current=!0;const x=await W.getWorkflowRuns(e,5).catch(()=>null);h({actions:x?x.filter(y=>y.status==="in_progress").length:0,fetchedAt:Date.now()}),c.current=!1},[e,o==null?void 0:o.has_remote,l.fetchedAt]);if(d.useEffect(()=>{o!=null&&o.has_remote&&p()},[o==null?void 0:o.has_remote,p]),d.useEffect(()=>{["issues","prs","actions"].includes(t)&&(o!=null&&o.has_remote)&&p()},[t,o==null?void 0:o.has_remote,p]),i)return r.jsx("div",{className:"h-full flex items-center justify-center",children:r.jsxs("div",{className:"flex flex-col items-center gap-2",children:[r.jsx(bt,{size:20,className:"text-muted animate-spin"}),r.jsx("span",{className:"text-xs text-muted",children:"Checking GitHub connection..."})]})});const u=(o==null?void 0:o.has_remote)??!0,g=[{id:"changes",label:"Changes",icon:Q,requiresRemote:!1},{id:"issues",label:"Issues",icon:$d,requiresRemote:!0},{id:"prs",label:"PRs",icon:an,requiresRemote:!0},{id:"actions",label:"Actions",icon:rs,count:l.actions,requiresRemote:!0}],m=g;return r.jsxs("div",{className:"h-full flex flex-col",children:[r.jsxs("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b border-border bg-hover flex-shrink-0",children:[m.map(_=>{const x=_.requiresRemote&&!u;return r.jsxs("button",{onClick:()=>s(_.id),disabled:x,className:`flex items-center gap-1 px-2.5 py-1 text-[11px] font-medium rounded-btn transition-colors ${t===_.id?"bg-primary/10 text-primary":x?"text-muted/40 cursor-not-allowed":"text-muted hover:text-ink"}`,title:x?"Connect to GitHub to access this tab":void 0,children:[r.jsx(_.icon,{size:12}),_.label,_.count!==void 0&&_.count>0&&r.jsx("span",{className:"ml-0.5 px-1 py-0 text-[9px] rounded-full bg-primary/20 text-primary font-mono",children:_.count})]},_.id)}),u&&(o==null?void 0:o.owner)&&r.jsxs("div",{className:"ml-auto flex items-center gap-1 text-[10px] text-muted font-mono",children:[r.jsx(lc,{size:10}),o.owner,"/",o.repo]})]}),r.jsxs("div",{className:"flex-1 overflow-hidden",children:[t==="changes"&&r.jsx(Lx,{sessionId:e}),t==="issues"&&(u?r.jsx(d.Suspense,{fallback:r.jsx(en,{}),children:r.jsx(Nx,{sessionId:e})}):r.jsx(tn,{sessionId:e,onPushed:f})),t==="prs"&&(u?r.jsx(d.Suspense,{fallback:r.jsx(en,{}),children:r.jsx(jx,{sessionId:e})}):r.jsx(tn,{sessionId:e,onPushed:f})),t==="actions"&&(u?r.jsx(d.Suspense,{fallback:r.jsx(en,{}),children:r.jsx("div",{className:"h-full overflow-y-auto p-4",children:r.jsx(Ex,{sessionId:e})})}):r.jsx(tn,{sessionId:e,onPushed:f}))]})]})}function Tx({sessionId:e,onRestore:t}){const[s,i]=d.useState([]),[n,o]=d.useState(!0),[a,l]=d.useState(null),[h,c]=d.useState(null),[f,p]=d.useState(null),u=d.useCallback(async()=>{try{const _=await W.getCheckpoints(e);i(_),p(null)}catch{p("Failed to load checkpoints")}o(!1)},[e]);d.useEffect(()=>{u();const _=setInterval(u,15e3);return()=>clearInterval(_)},[u]);const g=d.useCallback(async _=>{if(a)return;const x=s.find(v=>v.id===_);if(!(!x||!window.confirm(`Restore to checkpoint "${x.description}"?
226
+
227
+ This will revert files to this checkpoint state.`))){l(_);try{await W.restoreCheckpoint(e,_),await u(),t==null||t()}catch{p("Failed to restore checkpoint")}l(null)}},[e,s,a,u,t]);if(n)return r.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-card border-b border-border",children:[r.jsx(rr,{size:14,className:"text-muted animate-pulse"}),r.jsx("span",{className:"text-xs text-muted",children:"Loading checkpoints..."})]});if(f&&s.length===0||s.length===0)return null;const m=_=>{if(!_)return"";try{return new Date(_).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}};return r.jsxs("div",{className:"flex items-center gap-2 px-4 py-1.5 bg-card border-b border-border overflow-x-auto",children:[r.jsx(rr,{size:14,className:"text-muted flex-shrink-0"}),r.jsx("span",{className:"text-[11px] font-medium text-muted flex-shrink-0",children:"Checkpoints"}),r.jsx("div",{className:"flex items-center gap-1 flex-1 min-w-0",children:s.map((_,x)=>r.jsxs("div",{className:"flex items-center gap-1",children:[x>0&&r.jsx("div",{className:"w-4 h-px bg-border flex-shrink-0"}),r.jsxs("div",{className:"relative flex-shrink-0",children:[r.jsx("button",{onClick:()=>g(_.id),onMouseEnter:()=>c(_.id),onMouseLeave:()=>c(null),disabled:a!==null,className:`w-3.5 h-3.5 rounded-full border-2 transition-all cursor-pointer ${_.is_current?"bg-primary border-primary shadow-sm shadow-primary/30":a===_.id?"bg-warning border-warning animate-pulse":"bg-card border-border hover:border-primary hover:bg-primary/10"} ${a!==null&&a!==_.id?"opacity-50":""}`,title:`${_.description} -- Click to restore`}),h===_.id&&r.jsxs("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 z-50 pointer-events-none",children:[r.jsxs("div",{className:"bg-card border border-border rounded-lg shadow-lg px-3 py-2 whitespace-nowrap",children:[r.jsx("p",{className:"text-xs font-medium text-ink",children:_.description}),r.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[_.timestamp&&r.jsxs("span",{className:"flex items-center gap-1 text-[11px] text-muted",children:[r.jsx(ut,{size:10}),m(_.timestamp)]}),(_.files_changed??0)>0&&r.jsxs("span",{className:"flex items-center gap-1 text-[11px] text-muted",children:[r.jsx(Q,{size:10}),_.files_changed," file",_.files_changed!==1?"s":""]}),(_.iteration??0)>0&&r.jsxs("span",{className:"text-[11px] text-muted",children:["Iter ",_.iteration]})]}),!_.is_current&&r.jsxs("div",{className:"flex items-center gap-1 mt-1.5 text-[11px] text-primary font-medium",children:[r.jsx(nc,{size:10}),"Click to restore"]}),_.is_current&&r.jsx("div",{className:"text-[11px] text-success mt-1",children:"Current"})]}),r.jsx("div",{className:"w-2 h-2 bg-card border-r border-b border-border rotate-45 mx-auto -mt-1"})]})]})]},_.id))}),f&&r.jsx("span",{className:"text-[11px] text-danger flex-shrink-0",children:f})]})}function zx({line:e}){const t=e.type==="add"?"bg-success/10":e.type==="delete"?"bg-danger/10":"",s=e.type==="add"?"text-success":e.type==="delete"?"text-danger":"text-muted",i=e.type==="add"?"+":e.type==="delete"?"-":" ",n=e.type==="delete"?e.old_line:e.new_line;return r.jsxs("div",{className:`flex font-mono text-xs leading-5 ${t}`,children:[r.jsx("span",{className:"w-12 text-right pr-2 text-muted/60 select-none flex-shrink-0 border-r border-border",children:n||""}),r.jsx("span",{className:`w-5 text-center select-none flex-shrink-0 ${s} font-bold`,children:i}),r.jsx("span",{className:`flex-1 whitespace-pre-wrap break-all pl-1 ${e.type==="context"?"text-ink/70":s}`,children:e.content})]})}function Ax({file:e,isSelected:t,onToggle:s}){const[i,n]=d.useState(!0),o=e.action==="add"?r.jsx(_r,{size:14,className:"text-success"}):e.action==="delete"?r.jsx(nu,{size:14,className:"text-danger"}):r.jsx(Q,{size:14,className:"text-blue-500"}),a=e.action==="add"?"New":e.action==="delete"?"Deleted":"Modified";return r.jsxs("div",{className:"border border-border rounded-lg overflow-hidden",children:[r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-hover/50",children:[r.jsx("input",{type:"checkbox",checked:t,onChange:s,className:"w-3.5 h-3.5 rounded border-border accent-primary cursor-pointer"}),r.jsxs("button",{onClick:()=>n(l=>!l),className:"flex items-center gap-1 flex-1 min-w-0 text-left",children:[r.jsx(pr,{size:14,className:`text-muted transition-transform flex-shrink-0 ${i?"rotate-90":""}`}),o,r.jsx("span",{className:"text-xs font-mono text-ink truncate",children:e.path})]}),r.jsx("span",{className:`text-[11px] font-medium px-1.5 py-0.5 rounded ${e.action==="add"?"bg-success/10 text-success":e.action==="delete"?"bg-danger/10 text-danger":"bg-blue-500/10 text-blue-500"}`,children:a}),e.additions>0&&r.jsxs("span",{className:"flex items-center gap-0.5 text-[11px] text-success",children:[r.jsx(gr,{size:10}),e.additions]}),e.deletions>0&&r.jsxs("span",{className:"flex items-center gap-0.5 text-[11px] text-danger",children:[r.jsx(ic,{size:10}),e.deletions]})]}),i&&e.hunks.length>0&&r.jsx("div",{className:"border-t border-border max-h-[300px] overflow-y-auto terminal-scroll",children:e.hunks.map((l,h)=>r.jsxs("div",{children:[h>0&&r.jsxs("div",{className:"px-3 py-1 bg-hover/30 text-[11px] text-muted font-mono border-y border-border",children:["@@ -",l.old_start,",",l.old_count," +",l.new_start,",",l.new_count," @@"]}),l.lines.map((c,f)=>r.jsx(zx,{line:c},`${h}-${f}`))]},h))})]})}function Ox({data:e,onAcceptAll:t,onAcceptSelected:s,onReject:i,onClose:n}){const[o,a]=d.useState(()=>new Set(e.files.map(u=>u.path))),[l,h]=d.useState(0),c=d.useCallback(u=>{a(g=>{const m=new Set(g);return m.has(u)?m.delete(u):m.add(u),m})},[]),f=d.useCallback(()=>{o.size===e.files.length?a(new Set):a(new Set(e.files.map(u=>u.path)))},[o.size,e.files]),p=d.useCallback(()=>{s(Array.from(o))},[o,s]);return e.files.length===0?r.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",onClick:n,children:[r.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm"}),r.jsxs("div",{className:"relative bg-card rounded-xl shadow-2xl border border-border p-8 max-w-md",onClick:u=>u.stopPropagation(),children:[r.jsx("p",{className:"text-sm text-ink text-center",children:"No pending changes to preview."}),r.jsx("button",{onClick:n,className:"mt-4 w-full py-2 text-sm font-medium rounded-btn border border-border text-muted hover:text-ink hover:bg-hover transition-colors",children:"Close"})]})]}):r.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",onClick:n,children:[r.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm"}),r.jsxs("div",{className:"relative bg-card rounded-xl shadow-2xl border border-border w-full max-w-5xl max-h-[85vh] flex flex-col overflow-hidden",onClick:u=>u.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border flex-shrink-0",children:[r.jsx(Q,{size:18,className:"text-primary"}),r.jsx("h3",{className:"text-sm font-bold text-ink flex-1",children:"Change Preview"}),r.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted",children:[r.jsxs("span",{className:"flex items-center gap-1 text-success",children:[r.jsx(gr,{size:12}),e.total_additions]}),r.jsxs("span",{className:"flex items-center gap-1 text-danger",children:[r.jsx(ic,{size:12}),e.total_deletions]}),r.jsxs("span",{children:[e.files.length," file",e.files.length!==1?"s":""]})]}),r.jsx("button",{onClick:n,className:"p-1 rounded hover:bg-hover text-muted hover:text-ink transition-colors",children:r.jsx(gt,{size:16})})]}),r.jsxs("div",{className:"flex flex-1 min-h-0",children:[r.jsxs("div",{className:"w-56 flex-shrink-0 border-r border-border overflow-y-auto terminal-scroll bg-hover/30",children:[r.jsx("div",{className:"px-3 py-2 border-b border-border",children:r.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[r.jsx("input",{type:"checkbox",checked:o.size===e.files.length,onChange:f,className:"w-3.5 h-3.5 rounded border-border accent-primary"}),r.jsx("span",{className:"text-[11px] font-medium text-muted",children:"Select All"})]})}),e.files.map((u,g)=>{const m=u.action==="add"?"text-success":u.action==="delete"?"text-danger":"text-blue-500";return r.jsxs("button",{onClick:()=>h(g),className:`w-full flex items-center gap-2 px-3 py-1.5 text-left transition-colors ${g===l?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[r.jsx("input",{type:"checkbox",checked:o.has(u.path),onChange:()=>c(u.path),onClick:_=>_.stopPropagation(),className:"w-3 h-3 rounded border-border accent-primary flex-shrink-0"}),r.jsx("span",{className:"text-xs font-mono truncate flex-1",children:u.path.split("/").pop()}),r.jsx("span",{className:`text-[10px] flex-shrink-0 ${m}`,children:u.action==="add"?"+":u.action==="delete"?"-":"M"})]},u.path)})]}),r.jsx("div",{className:"flex-1 overflow-y-auto p-4 space-y-3 terminal-scroll",children:e.files[l]&&r.jsx(Ax,{file:e.files[l],isSelected:o.has(e.files[l].path),onToggle:()=>c(e.files[l].path)})})]}),r.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-t border-border bg-hover/30 flex-shrink-0",children:[r.jsxs("button",{onClick:i,className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium rounded-btn border border-danger/30 text-danger hover:bg-danger/10 transition-colors",children:[r.jsx(oc,{size:14}),"Reject"]}),r.jsx("div",{className:"flex-1"}),r.jsxs("button",{onClick:p,disabled:o.size===0,className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium rounded-btn border border-primary/30 text-primary hover:bg-primary/10 transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:[r.jsx(Yt,{size:14}),"Accept Selected (",o.size,")"]}),r.jsxs("button",{onClick:t,className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium rounded-btn bg-primary text-white hover:bg-primary-hover transition-colors",children:[r.jsx(Zd,{size:14}),"Accept All"]})]})]})]})}function Zi(e){if(e.status==="completed")switch(e.conclusion){case"success":return"success";case"failure":return"failed";case"cancelled":return"cancelled";case"skipped":return"skipped";case"timed_out":return"failed";default:return"failed"}return e.status==="in_progress"?"running":e.status==="queued"||e.status==="waiting"||e.status==="requested"||e.status==="pending"?"pending":"running"}function $x(e){if(e.status==="completed")switch(e.conclusion){case"success":return"success";case"failure":return"failed";case"cancelled":return"cancelled";case"skipped":return"skipped";default:return"failed"}return e.status==="in_progress"?"running":e.status==="queued"||e.status==="waiting"?"pending":"running"}function Ix(e){if(e.status==="completed")switch(e.conclusion){case"success":return"success";case"failure":return"failed";case"cancelled":return"cancelled";case"skipped":return"skipped";default:return"failed"}return e.status==="in_progress"?"running":"pending"}const jo={pending:{color:"text-[#939084]",bg:"bg-[#939084]/10",Icon:ut,label:"Queued"},running:{color:"text-[#553DE9]",bg:"bg-[#553DE9]/10",Icon:xr,label:"Running"},success:{color:"text-[#1FC5A8]",bg:"bg-[#1FC5A8]/10",Icon:Xl,label:"Success"},failed:{color:"text-[#C45B5B]",bg:"bg-[#C45B5B]/10",Icon:sr,label:"Failed"},cancelled:{color:"text-[#939084]",bg:"bg-[#939084]/10",Icon:oc,label:"Cancelled"},skipped:{color:"text-[#939084]",bg:"bg-[#939084]/10",Icon:wd,label:"Skipped"}};function jh(e){const t=new Date(e),i=Math.floor((new Date().getTime()-t.getTime())/1e3);if(i<60)return`${i}s ago`;const n=Math.floor(i/60);if(n<60)return`${n}m ago`;const o=Math.floor(n/60);return o<24?`${o}h ago`:`${Math.floor(o/24)}d ago`}function Eh(e,t){if(!t)return"--";const s=new Date(t).getTime()-new Date(e).getTime();if(s<0)return"--";const i=Math.floor(s/1e3);if(i<60)return`${i}s`;const n=Math.floor(i/60),o=i%60;if(n<60)return`${n}m ${o}s`;const a=Math.floor(n/60),l=n%60;return`${a}h ${l}m`}function Eo({status:e}){const t=jo[e];return r.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium ${t.bg} ${t.color}`,children:[r.jsx(t.Icon,{size:12,className:e==="running"?"animate-spin":""}),t.label]})}function Fx({step:e}){const t=Ix(e),s=jo[t];return r.jsxs("div",{className:"flex items-center gap-2 py-1 px-3 text-xs",children:[r.jsx(s.Icon,{size:12,className:`${s.color} flex-shrink-0 ${t==="running"?"animate-spin":""}`}),r.jsx("span",{className:"text-[#201515] dark:text-[#E8E6E3] flex-1 truncate",children:e.name}),e.startedAt&&e.completedAt&&r.jsx("span",{className:"text-[#939084] font-mono flex-shrink-0",children:Eh(e.startedAt,e.completedAt)}),r.jsx(Eo,{status:t})]})}function Hx({job:e}){const[t,s]=d.useState(!1),i=$x(e),n=jo[i];return r.jsxs("div",{className:"border border-[#ECEAE3] dark:border-[#2A2A30] rounded-lg overflow-hidden",children:[r.jsxs("button",{onClick:()=>s(!t),className:"w-full flex items-center gap-3 px-4 py-2.5 text-left hover:bg-[#F8F4F0] dark:hover:bg-[#222228] transition-colors",children:[t?r.jsx(ms,{size:14,className:"text-[#939084]"}):r.jsx(pr,{size:14,className:"text-[#939084]"}),r.jsx(n.Icon,{size:14,className:`${n.color} ${i==="running"?"animate-spin":""}`}),r.jsx("span",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3] flex-1 truncate",children:e.name}),e.startedAt&&r.jsx("span",{className:"text-xs text-[#939084] font-mono flex-shrink-0",children:Eh(e.startedAt,e.completedAt)}),r.jsx(Eo,{status:i})]}),t&&e.steps&&e.steps.length>0&&r.jsx("div",{className:"border-t border-[#ECEAE3] dark:border-[#2A2A30] bg-[#FAFAF8] dark:bg-[#1A1A1F] divide-y divide-[#ECEAE3] dark:divide-[#2A2A30]",children:e.steps.map(o=>r.jsx(Fx,{step:o},o.number))})]})}function Wx({sessionId:e,runId:t}){const[s,i]=d.useState(null),[n,o]=d.useState(!1),[a,l]=d.useState(null),h=d.useCallback(async()=>{o(!0),l(null);try{const c=await W.getWorkflowRunLogs(e,t);i(c)}catch(c){l(c instanceof Error?c.message:"Failed to fetch logs")}finally{o(!1)}},[e,t]);return d.useEffect(()=>{h()},[h]),n?r.jsxs("div",{className:"bg-[#0F0F11] rounded-lg p-4 text-center",children:[r.jsx(xr,{size:16,className:"animate-spin text-[#939084] inline-block"}),r.jsx("span",{className:"text-xs text-[#939084] ml-2",children:"Loading logs..."})]}):a?r.jsx("div",{className:"bg-[#0F0F11] rounded-lg p-4",children:r.jsx("p",{className:"text-xs text-[#C45B5B] font-mono",children:a})}):r.jsx("div",{className:"bg-[#0F0F11] rounded-lg p-3 max-h-80 overflow-y-auto terminal-scroll",children:r.jsx("pre",{className:"text-xs font-mono leading-relaxed whitespace-pre-wrap text-[#E8E6E3]",children:s||"(No log output)"})})}function Ux({run:e,sessionId:t}){const[s,i]=d.useState(!1),[n,o]=d.useState(null),[a,l]=d.useState(!1),[h,c]=d.useState(null),[f,p]=d.useState(!1),u=Zi(e),g=d.useCallback(async()=>{if(!(n||a)){l(!0),c(null);try{const _=await W.getWorkflowRunDetail(t,e.databaseId);o(_)}catch(_){c(_ instanceof Error?_.message:"Failed to load run details")}finally{l(!1)}}},[t,e.databaseId,n,a]),m=()=>{const _=!s;i(_),_&&g()};return r.jsxs("div",{className:"border border-[#ECEAE3] dark:border-[#2A2A30] rounded-lg overflow-hidden",children:[r.jsxs("button",{onClick:m,className:"w-full flex items-center gap-3 px-4 py-3 text-left hover:bg-[#F8F4F0] dark:hover:bg-[#222228] transition-colors",children:[s?r.jsx(ms,{size:14,className:"text-[#939084] flex-shrink-0"}):r.jsx(pr,{size:14,className:"text-[#939084] flex-shrink-0"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[r.jsx("span",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3] truncate",children:e.name}),r.jsx(Eo,{status:u})]}),r.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[r.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-[#939084]",children:[r.jsx(Te,{size:12}),e.headBranch]}),r.jsx("span",{className:"text-xs text-[#939084]",children:e.event}),r.jsx("span",{className:"text-xs text-[#939084]",children:jh(e.createdAt)})]})]}),r.jsx("a",{href:e.url,target:"_blank",rel:"noopener noreferrer",onClick:_=>_.stopPropagation(),className:"text-[#939084] hover:text-[#553DE9] transition-colors flex-shrink-0",title:"Open on GitHub",children:r.jsx(ls,{size:14})})]}),s&&r.jsxs("div",{className:"border-t border-[#ECEAE3] dark:border-[#2A2A30] px-4 pb-4 pt-3 space-y-3",children:[a&&r.jsxs("div",{className:"text-center py-4",children:[r.jsx(xr,{size:16,className:"animate-spin text-[#553DE9] inline-block"}),r.jsx("span",{className:"text-xs text-[#939084] ml-2",children:"Loading jobs..."})]}),h&&r.jsxs("div",{className:"flex items-center gap-2 p-3 rounded-lg bg-[#C45B5B]/10 text-[#C45B5B]",children:[r.jsx(Ut,{size:14}),r.jsx("span",{className:"text-xs",children:h})]}),n&&n.jobs&&n.jobs.length>0&&r.jsxs("div",{className:"space-y-2",children:[r.jsx("h4",{className:"text-xs font-semibold text-[#939084] uppercase tracking-wider",children:"Jobs"}),n.jobs.map(_=>r.jsx(Hx,{job:_},_.databaseId))]}),n&&(!n.jobs||n.jobs.length===0)&&!a&&r.jsx("p",{className:"text-xs text-[#939084]",children:"No jobs found for this run."}),n&&r.jsxs("div",{className:"pt-1",children:[r.jsxs("button",{onClick:()=>p(!f),className:"inline-flex items-center gap-1.5 text-xs text-[#553DE9] hover:text-[#4432c4] transition-colors",children:[r.jsx(os,{size:12}),f?"Hide full logs":"View full logs"]}),f&&r.jsx("div",{className:"mt-2",children:r.jsx(Wx,{sessionId:t,runId:e.databaseId})})]})]})]})}function Kx({sessionId:e,workflows:t,onClose:s,onDispatched:i}){var g;const[n,o]=d.useState(((g=t[0])==null?void 0:g.name)||""),[a,l]=d.useState(""),[h,c]=d.useState(!1),[f,p]=d.useState(null),u=async()=>{if(n){c(!0),p(null);try{await W.dispatchWorkflow(e,n,a),i(),s()}catch(m){p(m instanceof Error?m.message:"Dispatch failed")}finally{c(!1)}}};return r.jsxs("div",{className:"border border-[#ECEAE3] dark:border-[#2A2A30] rounded-lg p-4 bg-[#FAFAF8] dark:bg-[#1A1A1F] space-y-3",children:[r.jsx("h4",{className:"text-sm font-semibold text-[#201515] dark:text-[#E8E6E3]",children:"Run Workflow"}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-xs text-[#939084] mb-1",children:"Workflow"}),r.jsx("select",{value:n,onChange:m=>o(m.target.value),className:"w-full px-3 py-1.5 text-sm rounded-lg border border-[#ECEAE3] dark:border-[#2A2A30] bg-white dark:bg-[#0F0F11] text-[#201515] dark:text-[#E8E6E3] focus:outline-none focus:ring-2 focus:ring-[#553DE9]/40",children:t.map(m=>r.jsxs("option",{value:m.name,children:[m.name," (",m.name,")"]},m.id))})]}),r.jsxs("div",{children:[r.jsx("label",{className:"block text-xs text-[#939084] mb-1",children:"Branch / ref (leave empty for default)"}),r.jsx("input",{type:"text",value:a,onChange:m=>l(m.target.value),placeholder:"main",className:"w-full px-3 py-1.5 text-sm rounded-lg border border-[#ECEAE3] dark:border-[#2A2A30] bg-white dark:bg-[#0F0F11] text-[#201515] dark:text-[#E8E6E3] focus:outline-none focus:ring-2 focus:ring-[#553DE9]/40"})]}),f&&r.jsxs("div",{className:"flex items-center gap-2 p-2 rounded bg-[#C45B5B]/10 text-[#C45B5B]",children:[r.jsx(Ut,{size:12}),r.jsx("span",{className:"text-xs",children:f})]}),r.jsxs("div",{className:"flex items-center gap-2 justify-end",children:[r.jsx(le,{size:"sm",variant:"ghost",onClick:s,children:"Cancel"}),r.jsx(le,{size:"sm",icon:rs,onClick:u,loading:h,children:"Dispatch"})]})]})}function Dh({sessionId:e}){const[t,s]=d.useState([]),[i,n]=d.useState([]),[o,a]=d.useState(""),[l,h]=d.useState(!0),[c,f]=d.useState(null),[p,u]=d.useState(!1),[g,m]=d.useState(null),_=d.useRef(null),x=t.some(N=>N.status==="in_progress"||N.status==="queued"||N.status==="waiting"||N.status==="requested"||N.status==="pending"),y=d.useCallback(async(N=!1)=>{if(e){N&&h(!0),f(null);try{const M=await W.getWorkflowRuns(e);s(M),a(""),m(new Date)}catch(M){const U=M instanceof Error?M.message:String(M);U.includes("gh CLI not found")?f({type:"gh_not_found",message:"The gh CLI is not installed. Install it from https://cli.github.com/ to enable CI/CD integration."}):U.includes("not authenticated")||U.includes("401")?f({type:"not_authenticated",message:'The gh CLI is not authenticated. Run "gh auth login" in your terminal.'}):U.includes("Could not detect")?f({type:"no_repo",message:"No GitHub remote detected. Push this project to GitHub first."}):f({type:"generic",message:U})}finally{h(!1)}}},[e]),v=d.useCallback(async()=>{if(e)try{const N=await W.getWorkflows(e);n(N.filter(M=>M.state==="active"))}catch{n([])}},[e]);d.useEffect(()=>{y(!0),v()},[y,v]),d.useEffect(()=>(x&&e?_.current=setInterval(()=>y(!1),1e4):_.current&&(clearInterval(_.current),_.current=null),()=>{_.current&&clearInterval(_.current)}),[x,e,y]);const j=t.filter(N=>Zi(N)==="success").length,k=t.filter(N=>Zi(N)==="failed").length,w=t.filter(N=>{const M=Zi(N);return M==="running"||M==="pending"}).length;return r.jsxs("div",{className:"card p-6",children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Te,{size:18,className:"text-[#553DE9]"}),r.jsx("h3",{className:"text-sm font-semibold text-[#201515] dark:text-[#E8E6E3] uppercase tracking-wider",children:"CI/CD Pipelines"}),o&&r.jsx("span",{className:"text-xs text-[#939084] font-mono",children:o})]}),r.jsxs("div",{className:"flex items-center gap-2",children:[g&&r.jsxs("span",{className:"text-[10px] text-[#939084] flex items-center gap-1",children:[r.jsx(dc,{size:10}),jh(g.toISOString())]}),r.jsx(le,{size:"sm",variant:"ghost",icon:bt,onClick:()=>y(!0),children:"Refresh"}),i.length>0&&r.jsx(le,{size:"sm",icon:rs,onClick:()=>u(!p),children:"Run Workflow"})]})]}),p&&e&&i.length>0&&r.jsx("div",{className:"mb-4",children:r.jsx(Kx,{sessionId:e,workflows:i,onClose:()=>u(!1),onDispatched:()=>{setTimeout(()=>y(!1),3e3)}})}),c&&r.jsxs("div",{className:"mb-4",children:[c.type==="gh_not_found"&&r.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-lg bg-[#939084]/5 border border-[#ECEAE3] dark:border-[#2A2A30]",children:[r.jsx(Ut,{size:18,className:"text-[#939084] flex-shrink-0 mt-0.5"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3]",children:"GitHub CLI not installed"}),r.jsx("p",{className:"text-xs text-[#939084] mt-1",children:c.message}),r.jsxs("a",{href:"https://cli.github.com/",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-[#553DE9] hover:text-[#4432c4] mt-2",children:["Install GitHub CLI ",r.jsx(ls,{size:10})]})]})]}),c.type==="not_authenticated"&&r.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-lg bg-[#C45B5B]/5 border border-[#C45B5B]/20",children:[r.jsx(Ut,{size:18,className:"text-[#C45B5B] flex-shrink-0 mt-0.5"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3]",children:"Not authenticated"}),r.jsx("p",{className:"text-xs text-[#939084] mt-1",children:c.message}),r.jsx("code",{className:"inline-block text-xs bg-[#0F0F11] text-[#E8E6E3] px-2 py-1 rounded mt-2 font-mono",children:"gh auth login"})]})]}),c.type==="no_repo"&&r.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-lg bg-[#939084]/5 border border-[#ECEAE3] dark:border-[#2A2A30]",children:[r.jsx(Te,{size:18,className:"text-[#939084] flex-shrink-0 mt-0.5"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3]",children:"No GitHub repository"}),r.jsx("p",{className:"text-xs text-[#939084] mt-1",children:c.message})]})]}),c.type==="generic"&&r.jsxs("div",{className:"flex items-start gap-3 p-4 rounded-lg bg-[#C45B5B]/5 border border-[#C45B5B]/20",children:[r.jsx(Ut,{size:18,className:"text-[#C45B5B] flex-shrink-0 mt-0.5"}),r.jsxs("div",{children:[r.jsx("p",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3]",children:"Failed to load workflow runs"}),r.jsx("p",{className:"text-xs text-[#939084] mt-1",children:c.message})]})]})]}),!l&&!c&&t.length>0&&r.jsxs("div",{className:"flex items-center gap-4 mb-4 text-xs",children:[r.jsxs("span",{className:"flex items-center gap-1 text-[#1FC5A8]",children:[r.jsx(Xl,{size:12}),j," passed"]}),r.jsxs("span",{className:"flex items-center gap-1 text-[#C45B5B]",children:[r.jsx(sr,{size:12}),k," failed"]}),r.jsxs("span",{className:"flex items-center gap-1 text-[#553DE9]",children:[r.jsx(xr,{size:12,className:w>0?"animate-spin":""}),w," active"]}),x&&r.jsx("span",{className:"text-[#939084] italic",children:"Auto-refreshing every 10s"})]}),l&&r.jsx("div",{className:"space-y-3",children:[1,2,3].map(N=>r.jsx("div",{className:"border border-[#ECEAE3] dark:border-[#2A2A30] rounded-lg p-4 animate-pulse",children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-4 h-4 bg-[#ECEAE3] dark:bg-[#2A2A30] rounded"}),r.jsxs("div",{className:"flex-1",children:[r.jsx("div",{className:"h-4 bg-[#ECEAE3] dark:bg-[#2A2A30] rounded w-48"}),r.jsx("div",{className:"h-3 bg-[#ECEAE3] dark:bg-[#2A2A30] rounded w-32 mt-2"})]}),r.jsx("div",{className:"h-5 bg-[#ECEAE3] dark:bg-[#2A2A30] rounded-full w-16"})]})},N))}),!l&&!c&&t.length===0&&r.jsxs("div",{className:"text-center py-8",children:[r.jsx("p",{className:"text-[#939084] text-sm",children:"No workflow runs found"}),r.jsx("p",{className:"text-[#939084]/60 text-xs mt-1",children:"Push commits or trigger a workflow to see runs here"})]}),!l&&!c&&t.length>0&&e&&r.jsx("div",{className:"space-y-3 max-h-[600px] overflow-y-auto terminal-scroll",children:t.map(N=>r.jsx(Ux,{run:N,sessionId:e},N.databaseId))})]})}const qx=Object.freeze(Object.defineProperty({__proto__:null,CICDPanel:Dh},Symbol.toStringTag,{value:"Module"}));function Vx({phase:e,buildTime:t,onDismiss:s}){const[i,n]=d.useState(!1),[o,a]=d.useState(!1),l=d.useRef(e);if(d.useEffect(()=>{if(e==="complete"&&l.current!=="complete"){n(!0),a(!1);const c=setTimeout(()=>{n(!1),a(!0),s==null||s()},3e3);return()=>clearTimeout(c)}e!=="complete"&&a(!1),l.current=e},[e,s]),!i||o)return null;const h=c=>{if(c<60)return`${c}s`;const f=Math.floor(c/60),p=c%60;return`${f}m ${p}s`};return r.jsx("div",{className:"build-celebration-overlay",onClick:()=>{n(!1),a(!0),s==null||s()},children:r.jsxs("div",{className:"build-celebration-content",onClick:c=>c.stopPropagation(),children:[r.jsx("div",{className:"build-celebration-icon",children:r.jsx(ps,{size:48,className:"text-success"})}),r.jsx("div",{className:"build-celebration-burst"}),r.jsx("h3",{className:"text-lg font-heading font-bold text-ink mt-4",children:"Your app is ready!"}),r.jsx("p",{className:"text-sm text-muted mt-1",children:t?`Built in ${h(t)}. Time to see it in action.`:"Everything looks great. Go take a look."})]})})}function Gx({tokenHistory:e,className:t=""}){const s=e.slice(-10);if(s.length<2)return null;const i=64,n=20,o=2,a=Math.max(...s,1),l=Math.min(...s,0),h=a-l||1,c=s.map((u,g)=>({x:o+g/(s.length-1)*(i-o*2),y:o+(1-(u-l)/h)*(n-o*2)})),f=c.map((u,g)=>`${g===0?"M":"L"} ${u.x.toFixed(1)} ${u.y.toFixed(1)}`).join(" "),p=`${f} L ${c[c.length-1].x.toFixed(1)} ${n-o} L ${c[0].x.toFixed(1)} ${n-o} Z`;return r.jsxs("svg",{width:i,height:n,viewBox:`0 0 ${i} ${n}`,className:`inline-block align-middle text-muted ${t}`,"aria-label":"Token usage trend",children:[r.jsx("path",{d:p,fill:"currentColor",fillOpacity:.15}),r.jsx("path",{d:f,fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),r.jsx("circle",{cx:c[c.length-1].x,cy:c[c.length-1].y,r:"2",fill:"currentColor"})]})}function Yx(){const[e,t]=d.useState([]),s=d.useRef(0);return{history:e,recordTokens:n=>{n!==s.current&&(s.current=n,t(o=>{const a=[...o,n];return a.length>20?a.slice(-20):a}))}}}function Xx(e){var i;const t=((i=e.split(".").pop())==null?void 0:i.toLowerCase())||"";return{js:{icon:Q,color:"text-yellow-600",label:"JavaScript"},jsx:{icon:Q,color:"text-yellow-500",label:"JSX"},ts:{icon:Q,color:"text-blue-500",label:"TypeScript"},tsx:{icon:Q,color:"text-blue-400",label:"TSX"},py:{icon:Q,color:"text-green-600",label:"Python"},html:{icon:Q,color:"text-orange-500",label:"HTML"},css:{icon:no,color:"text-purple-500",label:"CSS"},json:{icon:ro,color:"text-green-500",label:"JSON"},md:{icon:_i,color:"text-muted",label:"Markdown"},go:{icon:Q,color:"text-cyan-600",label:"Go"},rs:{icon:Q,color:"text-orange-600",label:"Rust"}}[t]||{icon:oo,color:"text-muted",label:t.toUpperCase()||"Plain Text"}}function Jx(e){const t=Math.floor((Date.now()-e)/1e3);return t<2?"just now":t<60?`${t}s ago`:`${Math.floor(t/60)}m ago`}function Al(e){if(e<60)return`${e}s`;const t=Math.floor(e/60),s=e%60;return`${t}m ${s}s`}function Zx({selectedFile:e,fileName:t,isModified:s,isSaving:i,lastSavedAt:n,lineCount:o,cursorLine:a,cursorColumn:l,buildTime:h,sessionId:c,prd:f}){const[p,u]=d.useState(""),[g,m]=d.useState(!1);d.useEffect(()=>{if(!n)return;const v=()=>u(Jx(n));v();const j=setInterval(v,5e3);return()=>clearInterval(j)},[n]);const _=d.useCallback(async()=>{const v=["Built with Loki Mode",c?`Session: ${c}`:"",h?`Build time: ${Al(h)}`:"",f?`
228
+ Project: ${f.substring(0,100)}${f.length>100?"...":""}`:"",`
229
+ https://autonomi.dev`].filter(Boolean).join(`
230
+ `);try{await navigator.clipboard.writeText(v),m(!0),setTimeout(()=>m(!1),2e3)}catch{}},[c,h,f]);if(!e)return null;const x=Xx(t),y=x.icon;return r.jsxs("div",{className:"flex items-center gap-3 px-3 py-1 bg-card border-t border-border text-[11px] font-mono text-muted select-none flex-shrink-0",children:[r.jsxs("span",{className:"flex items-center gap-1.5",children:[r.jsx(y,{size:12,className:x.color}),r.jsx("span",{children:x.label})]}),r.jsx("span",{className:"text-border",children:"|"}),r.jsxs("span",{children:[o," lines"]}),r.jsx("span",{className:"text-border",children:"|"}),r.jsxs("span",{children:["Ln ",a,", Col ",l]}),r.jsx("span",{className:"text-border",children:"|"}),r.jsxs("span",{className:"flex items-center gap-1",children:[r.jsx(ju,{size:11}),i?r.jsx("span",{className:"text-primary animate-pulse",children:"Saving..."}):s?r.jsx("span",{className:"text-warning",children:"Unsaved"}):n?r.jsxs("span",{className:"text-success",children:["Saved ",p]}):r.jsx("span",{children:"Saved"})]}),r.jsx("div",{className:"flex-1"}),h!=null&&h>0&&r.jsxs("span",{className:"flex items-center gap-1 text-success",children:[r.jsx(dc,{size:11}),r.jsxs("span",{children:["Built in ",Al(h)]})]}),c&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"text-border",children:"|"}),r.jsx("button",{onClick:_,className:"flex items-center gap-1 hover:text-primary transition-colors",title:"Copy build summary to clipboard",children:g?r.jsxs(r.Fragment,{children:[r.jsx(Yt,{size:11,className:"text-success"}),r.jsx("span",{className:"text-success",children:"Copied!"})]}):r.jsxs(r.Fragment,{children:[r.jsx(hc,{size:11}),r.jsx("span",{children:"Share"})]})})]})]})}const Jn=[{id:"desktop",label:"Desktop",icon:Cd,width:"100%",frameWidth:1920,frameClass:"device-frame-desktop"},{id:"tablet",label:"Tablet",icon:Bu,width:"768px",frameWidth:768,frameClass:"device-frame-tablet"},{id:"mobile",label:"Mobile",icon:Mu,width:"375px",frameWidth:375,frameClass:"device-frame-mobile"}];function Qx({selectedDevice:e,onDeviceChange:t,containerWidth:s}){return r.jsxs("div",{className:"flex items-center gap-1",children:[Jn.map(i=>{const n=i.icon,o=e===i.id;return r.jsx("button",{onClick:()=>t(i.id),title:`${i.label} (${i.frameWidth}px)`,className:`p-1.5 rounded transition-colors ${o?"bg-primary/10 text-primary":"text-muted hover:text-ink hover:bg-hover"}`,children:r.jsx(n,{size:14})},i.id)}),s!=null&&s>0&&r.jsxs("span",{className:"text-[10px] font-mono text-muted ml-1 tabular-nums",children:[s,"px"]})]})}function ev(){const[e,t]=d.useState("desktop"),s=Jn.find(i=>i.id===e)||Jn[0];return{device:e,setDevice:t,iframeWidth:s.width,frameClass:s.frameClass,frameWidth:s.frameWidth}}const tv=[75,100,125];function sv({zoom:e,onZoomChange:t}){return r.jsx("div",{className:"flex items-center gap-0.5 border border-border rounded-btn",children:tv.map(s=>r.jsxs("button",{onClick:()=>t(s),className:`px-2 py-1 text-[10px] font-medium transition-colors ${e===s?"bg-primary/10 text-primary":"text-muted hover:text-ink hover:bg-hover"}`,title:`Zoom ${s}%`,children:[s,"%"]},s))})}function iv(){const[e,t]=d.useState(!1);return r.jsxs("div",{className:"relative",children:[r.jsx("button",{onClick:()=>t(s=>!s),className:"p-1.5 rounded text-muted hover:text-ink hover:bg-hover transition-colors",title:"Screenshot",children:r.jsx(Xd,{size:14})}),e&&r.jsx("div",{className:"absolute top-full right-0 mt-1 z-20 bg-card border border-border rounded-btn shadow-lg p-2 text-xs text-muted whitespace-nowrap",children:"Right-click the preview to save as image"})]})}function rv({url:e}){const[t,s]=d.useState(!1),i=d.useCallback(async()=>{try{await navigator.clipboard.writeText(e),s(!0),setTimeout(()=>s(!1),2e3)}catch{}},[e]);return r.jsxs("button",{onClick:i,className:"p-1.5 rounded text-muted hover:text-ink hover:bg-hover transition-colors relative",title:"Copy preview URL",children:[t?r.jsx(Yt,{size:14,className:"text-success"}):r.jsx(so,{size:14}),t&&r.jsx("div",{className:"copy-toast",children:"Copied!"})]})}function nv({isFullscreen:e,onToggle:t}){return r.jsx("button",{onClick:t,className:"p-1.5 rounded text-muted hover:text-ink hover:bg-hover transition-colors",title:e?"Exit fullscreen":"Fullscreen preview",children:e?r.jsx(cc,{size:14}):r.jsx(cn,{size:14})})}function Ol({messages:e}){const[t,s]=d.useState(!1),i=e.slice(-5),n=i.some(o=>o.level==="error");return i.length===0?null:r.jsxs("div",{className:`border-t border-border bg-card ${t?"":"cursor-pointer"}`,children:[r.jsxs("button",{onClick:()=>s(o=>!o),className:"w-full flex items-center gap-2 px-3 py-1.5 text-[11px] font-mono hover:bg-hover transition-colors",children:[n?r.jsx(_s,{size:12,className:"text-danger"}):r.jsx("span",{className:"w-3 h-3 rounded-full border border-muted/40 flex items-center justify-center text-[8px] text-muted",children:"i"}),r.jsxs("span",{className:`font-medium ${n?"text-danger":"text-muted"}`,children:["Console (",i.length,")"]}),r.jsx("div",{className:"flex-1"}),t?r.jsx(ms,{size:12}):r.jsx(mr,{size:12})]}),t&&r.jsx("div",{className:"max-h-32 overflow-y-auto terminal-scroll border-t border-border",children:i.map((o,a)=>r.jsxs("div",{className:`px-3 py-1 text-[11px] font-mono border-b border-border/50 last:border-b-0 ${o.level==="error"?"bg-danger/5 text-danger":o.level==="warn"?"bg-warning/5 text-warning":"text-muted"}`,children:[r.jsx("span",{className:"uppercase text-[9px] font-semibold mr-2 opacity-60",children:o.level}),o.message]},a))})]})}function ov({onClick:e,isRefreshing:t}){const[s,i]=d.useState(!1),n=d.useCallback(()=>{i(!0),e(),setTimeout(()=>i(!1),600)},[e]);return r.jsx("button",{onClick:n,className:"p-1.5 rounded text-muted hover:text-ink hover:bg-hover transition-colors",title:"Refresh preview",children:r.jsx(Md,{size:14,className:s||t?"animate-spin-once":""})})}function $l(){return r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center bg-card p-8",children:[r.jsxs("div",{className:"w-full max-w-md space-y-4",children:[r.jsx("div",{className:"skeleton-shimmer h-10 w-full rounded"}),r.jsx("div",{className:"skeleton-shimmer h-32 w-full rounded"}),r.jsxs("div",{className:"flex gap-4",children:[r.jsx("div",{className:"skeleton-shimmer h-20 flex-1 rounded"}),r.jsx("div",{className:"skeleton-shimmer h-20 flex-1 rounded"}),r.jsx("div",{className:"skeleton-shimmer h-20 flex-1 rounded"})]}),r.jsx("div",{className:"skeleton-shimmer h-8 w-48 rounded mx-auto"})]}),r.jsx("p",{className:"text-xs text-muted mt-6 animate-pulse",children:"Loading preview..."})]})}const Il={create:"bg-primary/8 text-primary border-primary/15 hover:bg-primary/15",improve:"bg-info/8 text-info border-info/15 hover:bg-info/15",fix:"bg-danger/8 text-danger border-danger/15 hover:bg-danger/15",test:"bg-teal/8 text-teal border-teal/15 hover:bg-teal/15",deploy:"bg-warning/8 text-warning border-warning/15 hover:bg-warning/15"};function av(e){const{projectState:t,hasSession:s,files:i,lastError:n,phase:o}=e;if(!s||t==="empty")return[{label:"Build a SaaS dashboard",prompt:"Build a modern SaaS analytics dashboard with charts and dark mode",category:"create"},{label:"Create a CLI tool",prompt:"Create a CLI tool with commands, flags, and help text",category:"create"},{label:"Build a REST API",prompt:"Build a REST API with CRUD endpoints, authentication, and database",category:"create"},{label:"Make a landing page",prompt:"Create a beautiful landing page with hero, features, pricing, and CTA sections",category:"create"}];if(t==="failed"){const a=[{label:"Fix the build errors",prompt:"Fix all build errors and get the project to compile successfully",category:"fix"},{label:"Try a different approach",prompt:"The current approach has issues. Try an alternative implementation strategy",category:"fix"}];if(n){const l=n.length>60?n.slice(0,60)+"...":n;a.unshift({label:`Fix: ${l}`,prompt:`Fix this error: ${n}`,category:"fix"})}return a.push({label:"Add error handling",prompt:"Add comprehensive error handling and fallbacks throughout the codebase",category:"improve"}),a.slice(0,4)}if(t==="building")return[];if(t==="completed"||t==="idle"){const a=[],l=i==null?void 0:i.some(p=>p.path.toLowerCase().includes("auth")),h=i==null?void 0:i.some(p=>p.path.includes(".test.")||p.path.includes(".spec.")||p.path.includes("__tests__")),c=i==null?void 0:i.some(p=>p.path.endsWith(".css")||p.path.endsWith(".scss")),f=i==null?void 0:i.some(p=>p.path.includes("Dockerfile")||p.path.includes("docker-compose"));return l||a.push({label:"Add authentication",prompt:"Add user authentication with login, signup, and session management",category:"improve"}),h||a.push({label:"Add test suite",prompt:"Add comprehensive unit tests and integration tests for all major features",category:"test"}),a.push({label:"Improve the UI",prompt:"Improve the UI with better styling, animations, and responsive design",category:"improve"}),f||a.push({label:"Add Docker support",prompt:"Add Dockerfile and docker-compose.yml for containerized deployment",category:"deploy"}),l&&a.push({label:"Add role-based access",prompt:"Add role-based access control with admin, editor, and viewer roles",category:"improve"}),c||a.push({label:"Add dark mode",prompt:"Add a dark mode toggle with proper theme support across all components",category:"improve"}),a.push({label:"Add API docs",prompt:"Add OpenAPI/Swagger documentation for all API endpoints",category:"improve"}),a.push({label:"Performance optimization",prompt:"Optimize performance: add lazy loading, caching, code splitting, and minimize bundle size",category:"improve"}),a.slice(0,4)}return[]}function lv(e){const{onSelect:t,className:s=""}=e,[i,n]=d.useState(!0),[o,a]=d.useState(!1),l=d.useMemo(()=>av(e),[e.projectState,e.hasSession,e.files,e.lastError,e.phase]),[h,c]=d.useState(0);if(d.useEffect(()=>{if(l.length<=4)return;const p=setInterval(()=>{a(!0),setTimeout(()=>{c(u=>(u+1)%l.length),a(!1)},300)},3e4);return()=>clearInterval(p)},[l.length]),l.length===0||!i)return null;const f=l.slice(h,h+4).concat(h+4>l.length?l.slice(0,h+4-l.length):[]).slice(0,4);return r.jsxs("div",{className:`${s}`,children:[r.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[r.jsx(kd,{size:12,className:"text-primary"}),r.jsx("span",{className:"text-[11px] font-semibold text-muted uppercase tracking-wider",children:"Suggestions"})]}),r.jsx("div",{className:`flex flex-wrap gap-1.5 transition-opacity duration-300 ${o?"opacity-0":"opacity-100"}`,children:f.map((p,u)=>r.jsxs("button",{onClick:()=>t(p.prompt),className:`inline-flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium
231
+ border rounded-pill transition-all duration-200 cursor-pointer
232
+ ${Il[p.category]||Il.create}
233
+ `,children:[p.label,r.jsx(to,{size:10,className:"opacity-50"})]},`${p.label}-${u}`))})]})}function es(e,t){if(e.length===0)return e;const s=[...e],i=s[s.length-1];return s[s.length-1]={...i,...t(i)},s}function cv(e){const t=[],s=[],i=[];for(const n of e.split(`
234
+ `))n.startsWith("__FILE_CHANGE__")?s.push(n.replace("__FILE_CHANGE__","")):n.startsWith("__COMMAND__")?i.push(n.replace("__COMMAND__","")):t.push(n);return{textLines:t,fileChanges:s,commands:i}}function hv({msgIndex:e}){const[t,s]=d.useState(null),i=n=>{s(t===n?null:n)};return r.jsxs("div",{className:"flex items-center gap-1 mt-1",children:[r.jsx("button",{onClick:()=>i("up"),className:`p-1 rounded transition-colors ${t==="up"?"text-primary bg-primary/10":"text-muted/40 hover:text-primary hover:bg-primary/5"}`,title:"Helpful response","aria-label":"Thumbs up",children:r.jsx(Id,{size:12})}),r.jsx("button",{onClick:()=>i("down"),className:`p-1 rounded transition-colors ${t==="down"?"text-red-400 bg-red-400/10":"text-muted/40 hover:text-red-400 hover:bg-red-400/5"}`,title:"Not helpful","aria-label":"Thumbs down",children:r.jsx(Au,{size:12})})]})}const Zn=[{id:"@file",label:"@file",description:"Reference a file in your project",icon:Q},{id:"@template",label:"@template",description:"Reference a template",icon:Nd},{id:"@docs",label:"@docs",description:"Reference documentation",icon:Js}];function dv({visible:e,filter:t,onSelect:s,onClose:i,selectedIndex:n}){if(!e)return null;const o=Zn.filter(a=>a.label.toLowerCase().includes(t.toLowerCase()));return o.length===0?null:r.jsxs("div",{className:"absolute bottom-full left-0 right-0 mb-1 bg-card border border-border rounded-lg shadow-lg py-1 z-50",children:[r.jsx("div",{className:"px-3 py-1",children:r.jsxs("span",{className:"text-[10px] text-muted font-semibold uppercase tracking-wider flex items-center gap-1",children:[r.jsx(Vd,{size:10}),"Mentions"]})}),o.map((a,l)=>{const h=a.icon;return r.jsxs("button",{onClick:()=>s(a.label),className:`w-full flex items-center gap-2 px-3 py-2 text-xs transition-colors text-left ${l===n?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[r.jsx(h,{size:14,className:l===n?"text-primary":"text-muted"}),r.jsx("span",{className:"font-medium",children:a.label}),r.jsx("span",{className:"text-muted text-[11px]",children:a.description})]},a.id)})]})}function uv(){return r.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-primary animate-bounce",style:{animationDelay:"0ms"}}),r.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-primary animate-bounce",style:{animationDelay:"150ms"}}),r.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-primary animate-bounce",style:{animationDelay:"300ms"}})]}),r.jsx("span",{className:"text-[11px] text-muted italic",children:"Loki is thinking..."})]})}function fv({msg:e,msgIndex:t}){var l;const[s,i]=d.useState(!1),n=d.useMemo(()=>e.role==="system"?cv(e.content):null,[e.role,e.content]);if(e.role==="user")return r.jsx("div",{className:"flex justify-end",children:r.jsxs("div",{className:"max-w-[80%] rounded-lg px-3 py-2 text-xs bg-primary/10 text-ink",children:[e.imageUrl&&r.jsxs("div",{className:"mb-2",children:[r.jsx("img",{src:e.imageUrl,alt:e.imageName||"Uploaded image",className:"max-w-full max-h-48 rounded border border-border object-contain"}),e.imageName&&r.jsx("span",{className:"text-[10px] text-muted mt-0.5 block",children:e.imageName})]}),r.jsx("pre",{className:"whitespace-pre-wrap font-mono text-xs leading-relaxed overflow-x-auto",children:e.content})]})});const o=n?n.textLines.join(`
235
+ `).trim():e.content,a=o.split(`
236
+ `).length>30;return r.jsxs("div",{className:"flex justify-start gap-2",children:[r.jsx("div",{className:"bg-primary text-white w-6 h-6 rounded-full flex items-center justify-center text-xs font-bold flex-shrink-0",children:"L"}),r.jsxs("div",{className:"max-w-[80%] rounded-lg px-3 py-2 text-xs bg-hover text-ink border-l-2 border-primary/40",children:[n&&n.commands.length>0&&r.jsx("div",{className:"mb-2 space-y-0.5",children:n.commands.map((h,c)=>r.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] font-mono text-muted bg-card/50 px-2 py-0.5 rounded",children:[r.jsx(os,{size:10,className:"text-muted/60 flex-shrink-0"}),r.jsx("span",{className:"truncate",children:h})]},c))}),r.jsxs("pre",{className:"whitespace-pre-wrap font-mono text-xs leading-relaxed overflow-x-auto",children:[a&&!s?o.split(`
237
+ `).slice(0,30).join(`
238
+ `)+`
239
+ ...`:o,e.isStreaming&&r.jsx("span",{className:"inline-block w-1.5 h-3.5 bg-primary/60 animate-pulse ml-0.5 align-text-bottom"})]}),a&&!e.isStreaming&&r.jsx("button",{onClick:()=>i(h=>!h),className:"text-[10px] text-primary hover:text-primary/80 mt-1 font-medium",children:s?"Show less":`Show all (${o.split(`
240
+ `).length} lines)`}),n&&n.fileChanges.length>0&&r.jsxs("div",{className:"mt-2 pt-2 border-t border-border",children:[r.jsxs("span",{className:"text-[11px] text-muted font-semibold uppercase flex items-center gap-1",children:[r.jsx(Q,{size:11}),"Files modified (",n.fileChanges.length,")"]}),r.jsx("ul",{className:"mt-1 space-y-0.5",children:n.fileChanges.map((h,c)=>r.jsx("li",{className:"text-[11px] font-mono text-primary/80",children:h},c))})]}),e.filesChanged&&e.filesChanged.length>0&&r.jsxs("div",{className:"mt-2 pt-2 border-t border-border",children:[r.jsxs("span",{className:"text-[11px] text-muted font-semibold uppercase flex items-center gap-1",children:[r.jsx(Q,{size:11}),"Changed files (",e.filesChanged.length,")"]}),r.jsx("ul",{className:"mt-1 space-y-0.5",children:e.filesChanged.map((h,c)=>r.jsx("li",{className:"text-[11px] font-mono text-muted",children:h},c))})]}),e.role==="system"&&!e.isStreaming&&e.returncode!==void 0&&r.jsx("div",{className:"mt-1 text-[10px] text-muted",children:e.returncode===0?r.jsxs("span",{children:["Done",n&&(n.fileChanges.length>0||e.filesChanged&&e.filesChanged.length>0)?` -- ${n.fileChanges.length+(((l=e.filesChanged)==null?void 0:l.length)||0)} files changed`:"",n&&n.commands.length>0?`, ${n.commands.length} commands run`:""]}):r.jsxs("span",{className:"text-red-400",children:["Task failed. ",e.returncode===124?"Timed out.":"Check the output above for error details."]})}),e.role==="system"&&!e.isStreaming&&e.content&&r.jsx(hv,{msgIndex:t})]})]})}const mv={quick:"Quick: Fast single-task fix (3 iterations max)",standard:"Standard: Thorough implementation with testing",max:"Max: Full autonomous build from your description"},pv=10*1024*1024,_v=new Set(["image/png","image/jpeg","image/gif","image/webp"]);function gv(e){return _v.has(e.type.toLowerCase())?e.size>pv?"This attachment was not added because it exceeds the 10 MiB limit.":null:"This attachment was not added. Use a PNG, JPEG, GIF, or WebP image."}function xv(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KiB`:`${(e/(1024*1024)).toFixed(1)} MiB`}function vv(e){return new Promise((t,s)=>{const i=new FileReader;i.onload=()=>t(String(i.result)),i.onerror=()=>s(i.error),i.readAsDataURL(e)})}function bv({sessionId:e,defaultMode:t,onFilesChanged:s,services:i}){var xe;const[n,o]=d.useState([]),[a,l]=d.useState(""),[h,c]=d.useState(t||"quick"),[f,p]=d.useState(!1),[u,g]=d.useState(!1),[m,_]=d.useState(null),[x,y]=d.useState(!1),[v,j]=d.useState(null),k=d.useRef(null),w=d.useRef(null),N=d.useRef(null),M=d.useRef(null),U=d.useRef(null),Y=d.useRef(null),V=d.useRef(null),$=d.useRef(new Set);d.useEffect(()=>{const T=sessionStorage.getItem(`chat_${e}`);if(T)try{o(JSON.parse(T))}catch{}},[e]),d.useEffect(()=>{if(n.length>0){const T=n.slice(-50).map(G=>({...G,imageUrl:void 0}));sessionStorage.setItem(`chat_${e}`,JSON.stringify(T))}},[n,e]),d.useEffect(()=>{k.current&&(k.current.scrollTop=k.current.scrollHeight)},[n]),d.useEffect(()=>{const T=$.current;return()=>{U.current&&U.current.abort();for(const G of T)URL.revokeObjectURL(G);T.clear()}},[]);const P=d.useCallback(T=>{$.current.delete(T)&&URL.revokeObjectURL(T)},[]),E=d.useCallback(T=>{if(f)return;const G=gv(T);if(G){j(G);return}j(null),m!=null&&m.previewUrl&&P(m.previewUrl);const K=URL.createObjectURL(T);$.current.add(K),_({file:T,previewUrl:K})},[m==null?void 0:m.previewUrl,P,f]),B=d.useCallback(()=>{var T;m!=null&&m.previewUrl&&P(m.previewUrl),_(null),j(null),N.current&&(N.current.value=""),(T=M.current)==null||T.focus()},[m==null?void 0:m.previewUrl,P]);d.useEffect(()=>{const T=G=>{var ne;const K=(ne=G.clipboardData)==null?void 0:ne.items;if(K){for(const He of K)if(He.type.startsWith("image/")){G.preventDefault();const be=He.getAsFile();be&&E(be);return}}};return document.addEventListener("paste",T),()=>document.removeEventListener("paste",T)},[E]);const[S,C]=d.useState(!1),[D,L]=d.useState(!1),[Z,oe]=d.useState(""),[q,J]=d.useState(0),se=d.useCallback(T=>{T.preventDefault(),T.stopPropagation(),T.dataTransfer.types.includes("Files")&&C(!0)},[]),de=d.useCallback(T=>{T.preventDefault(),T.stopPropagation(),C(!1)},[]),ue=d.useCallback(T=>{T.preventDefault(),T.stopPropagation(),C(!1);const G=T.dataTransfer.files;if(G.length>0){const K=G[0];K.type.startsWith("image/")&&E(K)}},[E]),ce=d.useCallback(async()=>{var T;if(U.current&&(U.current.abort(),U.current=null),Y.current){try{await W.chatCancel(e,Y.current)}catch{}Y.current=null}g(!1),p(!1),o(G=>es(G,K=>K.isStreaming?{isStreaming:!1,content:K.content+`
241
+ [cancelled]`}:{})),(T=w.current)==null||T.focus()},[e]),ge=d.useCallback(async T=>{var He;let K=0,ne;do{if(await new Promise(be=>setTimeout(be,2e3)),ne=await W.chatPoll(e,T),K++,ne.output_lines.length>0){const be=ne.output_lines.join(`
242
+ `);o(he=>es(he,Ae=>Ae.role==="system"&&Ae.isStreaming?{content:be}:{}))}K>=150&&(ne={complete:!0,output_lines:["Task timed out after 5 minutes. The AI may still be working in the background. Try checking the terminal or refreshing."],files_changed:[],returncode:1})}while(!ne.complete);o(be=>es(be,he=>he.role==="system"?{isStreaming:!1,content:ne.output_lines.join(`
243
+ `)||"Done.",filesChanged:ne.files_changed,returncode:ne.returncode}:{})),((He=ne.files_changed)==null?void 0:He.length)>0&&s&&s(ne.files_changed)},[e,s]),Fe=d.useCallback(async T=>{var K;const G=new AbortController;U.current=G,Y.current=T,g(!0);try{const ne=W.chatStreamUrl(e,T),He=await fetch(ne,{signal:G.signal});if(!He.ok||!He.body)throw new Error(`Stream failed: ${He.status}`);const be=He.body.getReader(),he=new TextDecoder;let Ae="";for(;;){const{done:pe,value:wt}=await be.read();if(pe)break;Ae+=he.decode(wt,{stream:!0});const We=Ae.split(`
244
+
245
+ `);Ae=We.pop()||"";for(const Xt of We){if(!Xt.trim())continue;const Ue=Xt.split(`
246
+ `);let bs="",Ct="";for(const Xe of Ue)Xe.startsWith("event:")?bs=Xe.slice(6).trim():Xe.startsWith("data:")&&(Ct=Xe.slice(5).trim());if(bs==="output"&&Ct)try{const{line:Xe}=JSON.parse(Ct);o(Ke=>es(Ke,Je=>Je.role==="system"&&Je.isStreaming?{content:Je.content?Je.content+`
247
+ `+Xe:Xe}:{}))}catch{}else if(bs==="complete"&&Ct)try{const{returncode:Xe,files_changed:Ke}=JSON.parse(Ct);o(Je=>es(Je,kt=>kt.role==="system"&&kt.isStreaming?{isStreaming:!1,filesChanged:Ke,returncode:Xe,content:kt.content||"Done."}:{})),(Ke==null?void 0:Ke.length)>0&&s&&s(Ke)}catch{}else if(bs==="error"&&Ct)try{const{error:Xe}=JSON.parse(Ct);o(Ke=>es(Ke,Je=>Je.role==="system"&&Je.isStreaming?{isStreaming:!1,content:`Error: ${Xe}`}:{}))}catch{}}}}catch(ne){if(ne instanceof DOMException&&ne.name==="AbortError")return;await ge(T)}finally{g(!1),p(!1),U.current=null,Y.current=null,(K=w.current)==null||K.focus()}},[e,s,ge]),z=async()=>{var Ae;const T=a.trim();if(!T&&!m||f)return;p(!0),j(null);let G,K,ne="";if(m){y(!0);try{G=await vv(m.file);const pe=await W.chatImageUpload(e,m.file);K=pe.filename,ne=`[Attached image: ${pe.filename} (id: ${pe.image_id})] Make it look like this. `}catch{j("The attachment was refused and no message was sent. Use a valid PNG, JPEG, GIF, or WebP image up to 10 MiB."),y(!1),p(!1);return}y(!1)}const He=ne+(T||"Make changes based on this screenshot."),be={role:"user",content:T||"Make changes based on this screenshot.",timestamp:new Date().toISOString(),imageUrl:G,imageName:K},he={role:"system",content:"",timestamp:new Date().toISOString(),isStreaming:!0};o(pe=>[...pe,be,he]),l(""),m&&P(m.previewUrl),_(null);try{const pe=n.filter(We=>We.role==="user"||We.role==="system"&&!We.isStreaming&&We.content).slice(-10).map(We=>({role:We.role==="user"?"user":"assistant",content:We.content})),{task_id:wt}=await W.chatStart(e,He,h,pe.length>0?pe:void 0);await Fe(wt)}catch(pe){o(wt=>es(wt,We=>We.role==="system"&&We.isStreaming?{isStreaming:!1,content:`Error: ${pe instanceof Error?pe.message:"Request failed"}`}:{})),p(!1),(Ae=w.current)==null||Ae.focus()}};return r.jsxs("div",{ref:V,className:`flex flex-col h-full relative ${S?"ring-2 ring-primary ring-inset":""}`,onDragOver:se,onDragLeave:de,onDrop:ue,children:[S&&r.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-primary/5 backdrop-blur-sm",children:r.jsxs("div",{className:"flex flex-col items-center gap-2 text-primary",children:[r.jsx(ha,{size:32}),r.jsx("span",{className:"text-sm font-medium",children:"Drop image here"})]})}),r.jsxs("div",{ref:k,className:"flex-1 overflow-y-auto p-3 space-y-3 terminal-scroll",children:[n.length===0&&r.jsxs("div",{className:"flex items-start gap-2 py-6 px-2",children:[r.jsx("div",{className:"bg-primary text-white w-6 h-6 rounded-full flex items-center justify-center text-xs font-bold flex-shrink-0",children:"L"}),r.jsx("div",{className:"max-w-[80%] rounded-lg px-3 py-2 text-xs bg-hover text-ink border-l-2 border-primary/40",children:r.jsx("p",{className:"leading-relaxed",children:"Hey! I'm Loki, your AI coding companion. Tell me what you want to build and I'll make it happen."})})]}),n.map((T,G)=>r.jsx(fv,{msg:T,msgIndex:G},G)),u&&r.jsx(uv,{})]}),r.jsxs("div",{className:"border-t border-border p-2 flex-shrink-0",children:[u&&r.jsxs("div",{className:"flex items-center justify-between mb-2 px-1",children:[r.jsxs("span",{className:"text-[10px] text-muted font-mono flex items-center gap-1.5",children:["Loki is thinking",r.jsxs("span",{className:"inline-flex items-center gap-0.5",children:[r.jsx("span",{className:"w-1 h-1 rounded-full bg-primary animate-bounce",style:{animationDelay:"0ms"}}),r.jsx("span",{className:"w-1 h-1 rounded-full bg-primary animate-bounce",style:{animationDelay:"150ms"}}),r.jsx("span",{className:"w-1 h-1 rounded-full bg-primary animate-bounce",style:{animationDelay:"300ms"}})]})]}),r.jsxs("button",{onClick:ce,className:"flex items-center gap-1 text-[10px] text-red-400 hover:text-red-300 transition-colors",children:[r.jsx(ir,{className:"w-2.5 h-2.5"}),"Stop"]})]}),!u&&(i==null?void 0:i.some(T=>T.fix_status==="fixing"))&&r.jsxs("div",{className:"flex items-center gap-1.5 mb-2 px-1",children:[r.jsx(Vl,{size:10,className:"text-yellow-400 animate-spin"}),r.jsxs("span",{className:"text-[10px] text-yellow-400 font-mono",children:["Auto-fixing: ",(xe=i.find(T=>T.fix_status==="fixing"))==null?void 0:xe.name]})]}),r.jsx("div",{className:"flex items-center gap-1 mb-2",children:["quick","standard","max"].map(T=>r.jsx("button",{onClick:()=>c(T),title:mv[T],className:`text-xs font-semibold px-3 py-1.5 rounded-btn transition-colors capitalize ${h===T?"bg-primary text-white":"text-muted hover:text-ink"}`,children:T},T))}),m&&r.jsxs("div",{role:"group","aria-label":"Selected attachment","aria-live":"polite",className:"flex items-center gap-2 mb-2 px-1",children:[r.jsxs("div",{className:"relative",children:[r.jsx("img",{src:m.previewUrl,alt:`Preview of ${m.file.name}`,className:"h-16 max-w-[120px] rounded border border-border object-cover"}),r.jsx("button",{onClick:B,className:"absolute -top-1.5 -right-1.5 w-4 h-4 bg-red-500 text-white rounded-full flex items-center justify-center hover:bg-red-600",title:"Remove image","aria-label":`Remove ${m.file.name}`,children:r.jsx(gt,{size:10})})]}),r.jsxs("div",{className:"min-w-0 text-[10px] text-muted",children:[r.jsx("p",{className:"truncate max-w-[180px] text-ink",title:m.file.name,children:m.file.name}),r.jsxs("p",{children:[m.file.type," · ",xv(m.file.size)]})]}),x&&r.jsx("span",{className:"text-[10px] text-primary animate-pulse",children:"Uploading..."})]}),v&&r.jsx("p",{role:"alert",className:"mb-2 px-1 text-[11px] text-red-400",children:v}),!u&&r.jsx(lv,{projectState:n.length===0?"empty":"idle",hasSession:!!e,onSelect:T=>l(T),className:"mb-2"}),r.jsx("p",{id:"chat-attachment-guidance",className:"mb-1 px-1 text-[10px] text-muted",children:"Attach one PNG, JPEG, GIF, or WebP image up to 10 MiB."}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("input",{ref:N,type:"file",accept:"image/png,image/jpeg,image/gif,image/webp",className:"hidden",onChange:T=>{var K;const G=(K=T.target.files)==null?void 0:K[0];G&&E(G),T.target.value=""}}),r.jsx("button",{ref:M,onClick:()=>{var T;return(T=N.current)==null?void 0:T.click()},disabled:f,className:"p-1.5 text-muted hover:text-primary rounded transition-colors disabled:opacity-50",title:"Attach image (or paste/drag-and-drop)","aria-label":"Attach image","aria-describedby":"chat-attachment-guidance",children:r.jsx(ha,{size:16})}),r.jsxs("div",{className:"flex-1 relative",children:[r.jsx(dv,{visible:D,filter:Z,selectedIndex:q,onSelect:T=>{var ne;const G=a.lastIndexOf("@"),K=G>=0?a.slice(0,G):a;l(K+T+" "),L(!1),J(0),(ne=w.current)==null||ne.focus()},onClose:()=>L(!1)}),r.jsx("textarea",{ref:w,value:a,onChange:T=>{const G=T.target.value;l(G);const K=G.lastIndexOf("@");if(K>=0){const ne=G.slice(K);/^@\w*$/.test(ne)?(L(!0),oe(ne),J(0)):L(!1)}else L(!1)},onKeyDown:T=>{if(D){if(T.key==="ArrowDown"){T.preventDefault(),J(G=>Math.min(G+1,Zn.length-1));return}if(T.key==="ArrowUp"){T.preventDefault(),J(G=>Math.max(G-1,0));return}if(T.key==="Tab"||T.key==="Enter"&&!T.shiftKey){T.preventDefault();const G=Zn.filter(K=>K.label.toLowerCase().includes(Z.toLowerCase()));if(G[q]){const K=a.lastIndexOf("@"),ne=K>=0?a.slice(0,K):a;l(ne+G[q].label+" "),L(!1),J(0)}return}if(T.key==="Escape"){L(!1);return}}T.key==="Enter"&&!T.shiftKey&&(T.preventDefault(),z())},placeholder:"Ask AI to modify your project... (Shift+Enter for new line)",rows:1,className:"w-full px-3 py-1.5 text-xs bg-card border border-border rounded-btn outline-none focus:border-primary transition-colors resize-none",style:{maxHeight:"120px",overflow:"auto"},disabled:f})]}),u?r.jsx(le,{size:"sm",icon:ir,onClick:ce,"aria-label":"Stop streaming",className:"bg-red-500/10 hover:bg-red-500/20 text-red-400",children:"Stop"}):r.jsx(le,{size:"sm",icon:Du,onClick:z,disabled:f||!a.trim()&&!m,"aria-label":"Send message",children:"Send"})]})]})]})}function Qi(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function er(e){return e<60?`${e}s`:e<3600?`${Math.floor(e/60)}m ${e%60}s`:`${Math.floor(e/3600)}h ${Math.floor(e%3600/60)}m`}function yv(e){return e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}const tr="Not recorded";function rt(e,t){return e===null?tr:t(e)}function Sv(e){return e>=90?{label:"Excellent",color:"text-success"}:e>=75?{label:"Good",color:"text-teal"}:e>=60?{label:"Fair",color:"text-warning"}:{label:"Needs Work",color:"text-danger"}}function js({icon:e,label:t,value:s,subtext:i,iconColor:n="text-primary"}){return r.jsxs("div",{className:"bg-hover/40 rounded-card p-3 flex flex-col items-center text-center",children:[r.jsx(e,{size:18,className:`${n} mb-1.5`}),r.jsx("div",{className:"text-lg font-bold font-mono text-ink leading-tight",children:s}),r.jsx("div",{className:"text-[11px] text-muted font-medium mt-0.5",children:t}),i&&r.jsx("div",{className:"text-[11px] text-muted/60 mt-0.5",children:i})]})}function wv({phase:e,maxDuration:t}){const s=t>0?e.durationSecs/t*100:0,i={planning:"bg-info",building:"bg-primary",testing:"bg-teal",reviewing:"bg-warning"};return r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-[11px] text-secondary w-16 text-right flex-shrink-0",children:e.label}),r.jsxs("div",{className:"flex-1 h-4 bg-border rounded-sm overflow-hidden relative",children:[r.jsx("div",{className:`h-full rounded-sm transition-all duration-700 ease-out ${i[e.phase]||"bg-primary"}`,style:{width:`${s}%`}}),r.jsxs("span",{className:"absolute inset-0 flex items-center px-2 text-[10px] font-mono text-white mix-blend-difference",children:[er(e.durationSecs)," | ",Qi(e.tokenCount)," tokens"]})]}),r.jsxs("span",{className:"text-[11px] font-mono text-muted w-10 text-right flex-shrink-0",children:[Math.round(e.percentage),"%"]})]})}function Cv({filesCreated:e,filesModified:t,linesGenerated:s,testsGenerated:i,testPassRate:n,totalTokens:o,phaseBreakdown:a,totalTimeSecs:l,qualityScore:h,totalCost:c,iterations:f,provider:p,onShare:u,className:g=""}){const[m,_]=d.useState(!0),x=h===null?null:Sv(h),y=Math.max(...a.map(N=>N.durationSecs),1),v=c!==null?`$${c.toFixed(2)}`:tr,j=rt(n,N=>`${Math.round(N*100)}%`),k=h===null||x===null?tr:`${h}/100 (${x.label})`,w=()=>{const N=["Build Insights Summary","=====================",`Provider: ${p}`,`Total Time: ${rt(l,er)}`,`Iterations: ${rt(f,String)}`,`Cost: ${v}`,"","Output:",` Files Created: ${rt(e,String)}`,` Files Modified: ${rt(t,String)}`,` Lines Generated: ${rt(s,String)}`,` Tests Generated: ${rt(i,String)}`,` Test Pass Rate: ${j}`,"","Resources:",` Total Tokens: ${rt(o,Qi)}`,` Quality Score: ${k}`,"","Time Breakdown:",...a.map(M=>` ${M.label}: ${er(M.durationSecs)} (${Math.round(M.percentage)}%)`)].join(`
248
+ `);u==null||u(N)};return r.jsxs("div",{className:`card overflow-hidden ${g}`,children:[r.jsxs("button",{onClick:()=>_(!m),className:"w-full flex items-center justify-between px-4 py-3 hover:bg-hover/30 transition-colors",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(rn,{size:14,className:"text-primary"}),r.jsx("h3",{className:"text-sm font-semibold text-ink uppercase tracking-wider",children:"Build Insights"}),h!==null&&x!==null&&r.jsx("span",{className:`text-[11px] font-medium px-2 py-0.5 rounded-pill ${h>=80?"bg-success/10 text-success":h>=60?"bg-warning/10 text-warning":"bg-danger/10 text-danger"}`,children:x.label})]}),r.jsx("span",{className:"text-muted",children:m?r.jsx(mr,{size:16}):r.jsx(ms,{size:16})})]}),m&&r.jsxs("div",{className:"px-4 pb-4 space-y-4",children:[r.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[r.jsx(js,{icon:Q,label:"Files",value:e===null?tr:String(t===null?e:e+t),subtext:e===null?void 0:t===null?`${e} new, modified not recorded`:`${e} new, ${t} modified`,iconColor:"text-primary"}),r.jsx(js,{icon:ln,label:"Lines of Code",value:rt(s,yv),iconColor:"text-info"}),r.jsx(js,{icon:ai,label:"Tests",value:rt(i,String),subtext:n===null?"pass rate not recorded":`${j} passing`,iconColor:"text-teal"})]}),r.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[r.jsx(js,{icon:Ls,label:"Tokens Used",value:rt(o,Qi),iconColor:"text-warning"}),r.jsx(js,{icon:ut,label:"Build Time",value:rt(l,er),subtext:f===null?"iterations not recorded":`${f} iterations`,iconColor:"text-muted"}),r.jsx(js,{icon:jd,label:"Quality",value:rt(h,String),subtext:x==null?void 0:x.label,iconColor:(x==null?void 0:x.color)??"text-muted"})]}),r.jsxs("div",{className:"flex items-center justify-between bg-hover/40 rounded-card px-3 py-2.5",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(Hd,{size:14,className:"text-primary"}),r.jsx("span",{className:"text-xs font-medium text-ink",children:"Total Cost"})]}),r.jsx("span",{className:"text-sm font-bold font-mono text-ink",children:v})]}),a.length>0&&r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[r.jsx(Wd,{size:12,className:"text-muted"}),r.jsx("span",{className:"text-[11px] font-semibold text-muted uppercase tracking-wider",children:"Time Breakdown"})]}),r.jsx("div",{className:"space-y-1.5",children:a.map(N=>r.jsx(wv,{phase:N,maxDuration:y},N.phase))})]}),a.length>0&&r.jsxs("div",{children:[r.jsxs("div",{className:"flex items-center gap-1.5 mb-2",children:[r.jsx(Ls,{size:12,className:"text-muted"}),r.jsx("span",{className:"text-[11px] font-semibold text-muted uppercase tracking-wider",children:"Token Distribution"})]}),r.jsx("div",{className:"flex h-3 rounded-full overflow-hidden bg-border",children:a.map(N=>{const M={planning:"bg-info",building:"bg-primary",testing:"bg-teal",reviewing:"bg-warning"};return r.jsx("div",{className:`h-full transition-all duration-700 ${M[N.phase]||"bg-primary"}`,style:{width:`${N.percentage}%`},title:`${N.label}: ${Qi(N.tokenCount)} tokens (${Math.round(N.percentage)}%)`},N.phase)})}),r.jsx("div",{className:"flex items-center justify-between mt-1",children:a.map(N=>{const M={planning:"bg-info",building:"bg-primary",testing:"bg-teal",reviewing:"bg-warning"};return r.jsxs("span",{className:"flex items-center gap-1 text-[11px] text-muted",children:[r.jsx("span",{className:`w-2 h-2 rounded-full ${M[N.phase]||"bg-primary"}`}),N.label]},N.phase)})})]}),u&&r.jsx("div",{className:"flex justify-end pt-1",children:r.jsxs("button",{onClick:w,className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium
249
+ text-primary hover:bg-primary/5 rounded-card transition-colors`,children:[r.jsx(hc,{size:12}),"Share Insights"]})})]})]})}const kv=800,Fl=[1,2,5];function Nv(e){const t=new Date(e);return e&&!Number.isNaN(t.getTime())?t.toLocaleTimeString():"--"}function jv({sessionId:e}){const[t,s]=d.useState(null),[i,n]=d.useState(null),[o,a]=d.useState(0),[l,h]=d.useState(!1),[c,f]=d.useState(0),p=Fl[c],u=(t==null?void 0:t.length)??0;if(d.useEffect(()=>{let m=!1;return W.getCheckpoints(e).then(_=>{m||s(_)}).catch(()=>{m||n("Failed to load checkpoints")}),()=>{m=!0}},[e]),d.useEffect(()=>{if(!l)return;if(o>=u){h(!1);return}const m=setTimeout(()=>a(_=>_+1),kv/p);return()=>clearTimeout(m)},[l,o,u,p]),i)return r.jsx("div",{className:"text-xs text-danger py-6 text-center",children:i});if(t===null)return r.jsx("div",{className:"text-xs text-muted py-6 text-center",children:"Loading checkpoints..."});if(u===0)return r.jsx("div",{className:"text-xs text-muted py-6 text-center",children:"No checkpoints recorded for this build."});const g=t.slice(0,o);return r.jsxs("div",{className:"card overflow-hidden",children:[r.jsx("div",{className:"p-3 overflow-y-auto terminal-scroll max-h-[300px] space-y-1",children:g.length===0?r.jsxs("div",{className:"text-xs text-muted py-4 text-center",children:["Press play to step through ",u," recorded checkpoint",u!==1?"s":"","."]}):g.map(m=>r.jsxs("div",{className:"flex items-center gap-2 text-xs animate-fade-in",children:[r.jsx(rr,{size:11,className:"text-muted flex-shrink-0"}),r.jsx("span",{className:"font-mono text-muted flex-shrink-0",children:Nv(m.timestamp)}),r.jsx("span",{className:"truncate text-secondary",children:m.description}),(m.iteration??0)>0&&r.jsxs("span",{className:"font-mono text-muted flex-shrink-0",children:["Iter ",m.iteration]}),(m.files_changed??0)>0&&r.jsxs("span",{className:"text-muted flex-shrink-0",children:[m.files_changed," file",m.files_changed!==1?"s":""]})]},m.id))}),r.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-t border-border",children:[r.jsxs("div",{className:"flex items-center gap-1",children:[r.jsx("button",{onClick:()=>{o>=u&&a(0),h(!l)},className:"p-1.5 rounded-card hover:bg-hover transition-colors text-ink",title:l?"Pause":"Play",children:l?r.jsx(Zl,{size:16}):r.jsx(rs,{size:16})}),r.jsx("button",{onClick:()=>{h(!1),a(0)},className:"p-1.5 rounded-card hover:bg-hover transition-colors text-muted",title:"Reset",children:r.jsx(nc,{size:14})}),r.jsxs("button",{onClick:()=>f((c+1)%Fl.length),className:"px-2 py-1 rounded-card hover:bg-hover transition-colors text-xs font-mono text-muted",title:"Playback speed",children:[p,"x"]})]}),r.jsxs("span",{className:"text-xs font-mono text-muted",children:["Checkpoint ",o,"/",u]})]})]})}function Ev(e){const t=e.toLowerCase().trim(),s=[];let i;const n=t.match(/where (?:is|are) (?:the )?(.+?)(?:\?|$)/);n&&s.push(...n[1].split(/\s+/).filter(l=>!["the","a","an","my"].includes(l)));const o=t.match(/show (?:me )?(?:all )?(.+?)(?:\?|$)/);o&&s.length===0&&s.push(...o[1].split(/\s+/).filter(l=>!["the","a","an","my","all"].includes(l)));const a=t.match(/find (?:the )?(.+?)(?:\?|$)/);return a&&s.length===0&&s.push(...a[1].split(/\s+/).filter(l=>!["the","a","an","my"].includes(l))),(t.includes("api endpoint")||t.includes("route")||t.includes("handler"))&&(i="api",s.length===0&&s.push("app.get","app.post","router","@app.route","endpoint")),(t.includes("database")||t.includes("db connection")||t.includes("schema"))&&s.length===0&&s.push("database","connection","schema","model","migration"),(t.includes("login")||t.includes("auth")||t.includes("authentication"))&&s.length===0&&s.push("auth","login","session","token","password"),(t.includes("test")||t.includes("spec"))&&(i="test",s.length===0&&s.push("describe","it(","test(","expect")),(t.includes("style")||t.includes("css")||t.includes("theme"))&&(i="css",s.length===0&&s.push("style","theme","color","font")),(t.includes("config")||t.includes("configuration")||t.includes("settings"))&&s.length===0&&s.push("config","settings","env","options"),s.length===0&&s.push(...t.split(/\s+/).filter(l=>l.length>2&&!["the","a","an","my","all","show","me","find","where","is","are","how"].includes(l))),{terms:s,filePattern:i}}function Dv(e,t){let s=0;const i=e.path.toLowerCase(),n=e.name.toLowerCase();for(const o of t){const a=o.toLowerCase();n===a?s+=100:n.includes(a)?s+=60:i.includes(a)&&(s+=30)}return s+=Math.max(0,20-e.path.split("/").length*2),s}const Rv=["Where is the login function?","Show me all API endpoints","Find the database connection","Where are the tests?","Show me the configuration files"];function Pv({sessionId:e,onOpenFile:t,className:s=""}){const[i,n]=d.useState(""),[o,a]=d.useState([]),[l,h]=d.useState(!1),[c,f]=d.useState(!1),[p,u]=d.useState(!1),g=d.useRef(null),m=d.useRef(null),_=d.useCallback(async w=>{if(!w.trim()||!e){a([]),u(!1);return}h(!0),u(!0);try{const{terms:N}=Ev(w),M=N.join(" "),Y=(await W.searchFiles(e,M)).map(V=>({path:V.path,name:V.name,relevanceScore:Dv(V,N)}));Y.sort((V,$)=>$.relevanceScore-V.relevanceScore),a(Y.slice(0,15))}catch{a([])}finally{h(!1)}},[e]),x=w=>{n(w),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>_(w),400)},y=w=>{w.preventDefault(),m.current&&clearTimeout(m.current),_(i)},v=()=>{var w;n(""),a([]),u(!1),(w=g.current)==null||w.focus()},j=w=>{n(w),_(w)};d.useEffect(()=>()=>{m.current&&clearTimeout(m.current)},[]);const k=w=>w.includes(".test.")||w.includes(".spec.")?"text-teal":w.endsWith(".css")||w.endsWith(".scss")?"text-pink":w.endsWith(".json")||w.endsWith(".yaml")?"text-warning":w.endsWith(".md")?"text-muted":"text-primary";return r.jsxs("div",{className:`card overflow-hidden ${s}`,children:[r.jsxs("div",{className:"px-4 pt-4 pb-2",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[r.jsx(as,{size:14,className:"text-primary"}),r.jsx("h3",{className:"text-sm font-semibold text-ink uppercase tracking-wider",children:"Code Search"})]}),r.jsx("p",{className:"text-[11px] text-muted mb-3",children:'Search in natural language -- "Where is the login function?"'}),r.jsxs("form",{onSubmit:y,className:"relative",children:[r.jsx(as,{size:14,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted"}),r.jsx("input",{ref:g,type:"text",value:i,onChange:w=>x(w.target.value),onFocus:()=>f(!0),onBlur:()=>setTimeout(()=>f(!1),200),placeholder:"Ask about your code...",className:`w-full pl-9 pr-8 py-2 text-sm bg-hover/50 border border-border rounded-card
250
+ focus:border-primary focus:ring-1 focus:ring-primary/20 outline-none
251
+ text-ink placeholder:text-muted`}),i&&r.jsx("button",{type:"button",onClick:v,className:"absolute right-2.5 top-1/2 -translate-y-1/2 text-muted hover:text-ink transition-colors",children:r.jsx(gt,{size:14})})]})]}),!p&&c&&r.jsxs("div",{className:"px-4 pb-3",children:[r.jsx("div",{className:"text-[11px] text-muted mb-1.5",children:"Try searching for:"}),r.jsx("div",{className:"flex flex-wrap gap-1",children:Rv.map(w=>r.jsx("button",{onClick:()=>j(w),className:`text-[11px] text-primary bg-primary/5 hover:bg-primary/10
252
+ px-2 py-1 rounded-pill border border-primary/10 transition-colors`,children:w},w))})]}),l&&r.jsxs("div",{className:"flex items-center justify-center gap-2 py-6 text-xs text-muted",children:[r.jsx(gi,{size:14,className:"animate-spin"}),"Searching..."]}),p&&!l&&r.jsx("div",{className:"border-t border-border",children:o.length===0?r.jsx("div",{className:"text-center py-6 text-xs text-muted",children:"No results found. Try a different query."}):r.jsxs("div",{className:"max-h-[320px] overflow-y-auto terminal-scroll",children:[r.jsxs("div",{className:"text-[11px] text-muted px-4 py-1.5 bg-hover/30 border-b border-border",children:[o.length," result",o.length!==1?"s":""," found"]}),o.map((w,N)=>r.jsxs("button",{onClick:()=>t(w.path,w.lineNumber),className:`w-full flex items-center gap-3 px-4 py-2.5 text-left
253
+ hover:bg-hover/50 transition-colors border-b border-border last:border-b-0
254
+ group cursor-pointer`,children:[r.jsx(Q,{size:14,className:k(w.path)}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("div",{className:"text-xs font-medium text-ink group-hover:text-primary transition-colors truncate",children:w.name}),r.jsx("div",{className:"text-[11px] text-muted font-mono truncate",children:w.path}),w.matchContext&&r.jsx("div",{className:"text-[11px] text-secondary mt-0.5 truncate font-mono",children:w.matchContext})]}),r.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[w.lineNumber&&r.jsxs("span",{className:"flex items-center gap-0.5 text-[11px] text-muted font-mono",children:[r.jsx(du,{size:10}),w.lineNumber]}),r.jsx(to,{size:12,className:"text-muted group-hover:text-primary transition-colors"})]})]},`${w.path}-${N}`))]})})]})}const ur={claude:{input:.003,output:.015,label:"Claude (Sonnet)"},codex:{input:.002,output:.008,label:"Codex (GPT-4o)"},gemini:{input:.00125,output:.005,label:"Gemini Pro"}},fr={simple:{tokens:5e4,label:"Simple",iters:3},standard:{tokens:15e4,label:"Standard",iters:8},complex:{tokens:4e5,label:"Complex",iters:15}};function Mv(e,t,s){const i=ur[t]||ur.claude,n=fr[e]||fr.standard,o=s||n.iters,a=[{phase:"planning",label:"Planning",pct:.15},{phase:"building",label:"Building",pct:.55},{phase:"testing",label:"Testing",pct:.2},{phase:"reviewing",label:"Review",pct:.1}],l=n.tokens*(o/n.iters),h=Math.round(l),c=a.map(m=>{const _=Math.round(h*m.pct),x=_*.4,y=_*.6,v=(x*i.input+y*i.output)/1e3;return{phase:m.phase,label:m.label,estimatedCost:v,estimatedTokens:_}}),f=c.reduce((m,_)=>m+_.estimatedCost,0),u=o*(e==="complex"?40:e==="simple"?15:25),g=u<60?`${u}s`:u<3600?`${Math.round(u/60)}min`:`${(u/3600).toFixed(1)}hr`;return{total:{low:f*.7,high:f*1.4},breakdown:c,totalTokens:h,estimatedTime:g}}function Hl(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(0)}K`:String(e)}function Lv({complexity:e,provider:t,templateType:s,estimatedIterations:i,onConfirm:n,onCancel:o,historicalAvgCost:a}){const[l,h]=d.useState(!1),c=Mv(e,t,i),f=ur[t]||ur.claude,p=fr[e]||fr.standard,u=c.total.high>5;return r.jsxs("div",{className:"card overflow-hidden max-w-md mx-auto",children:[r.jsxs("div",{className:"px-5 pt-5 pb-3",children:[r.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[r.jsx(ec,{size:18,className:"text-primary"}),r.jsx("h3",{className:"text-sm font-semibold text-ink uppercase tracking-wider",children:"Build Cost Estimate"})]}),r.jsx("p",{className:"text-xs text-muted",children:"Estimated cost before starting your build"})]}),r.jsxs("div",{className:"px-5 py-4",children:[r.jsxs("div",{className:"text-center mb-4",children:[r.jsxs("div",{className:"text-3xl font-bold font-mono text-ink tracking-tight",children:["$",c.total.low.toFixed(2)," -- $",c.total.high.toFixed(2)]}),r.jsx("p",{className:"text-xs text-muted mt-1",children:"Estimated total cost"})]}),r.jsxs("div",{className:"grid grid-cols-3 gap-3 text-center",children:[r.jsxs("div",{className:"bg-hover/50 rounded-card px-2 py-2",children:[r.jsx(Ls,{size:14,className:"text-primary mx-auto mb-1"}),r.jsx("div",{className:"text-xs font-mono font-semibold text-ink",children:Hl(c.totalTokens)}),r.jsx("div",{className:"text-[11px] text-muted",children:"Tokens"})]}),r.jsxs("div",{className:"bg-hover/50 rounded-card px-2 py-2",children:[r.jsx(ut,{size:14,className:"text-info mx-auto mb-1"}),r.jsx("div",{className:"text-xs font-mono font-semibold text-ink",children:c.estimatedTime}),r.jsx("div",{className:"text-[11px] text-muted",children:"Est. Time"})]}),r.jsxs("div",{className:"bg-hover/50 rounded-card px-2 py-2",children:[r.jsx(Ls,{size:14,className:"text-warning mx-auto mb-1"}),r.jsx("div",{className:"text-xs font-mono font-semibold text-ink",children:i||p.iters}),r.jsx("div",{className:"text-[11px] text-muted",children:"Iterations"})]})]})]}),r.jsxs("div",{className:"px-5 py-2 bg-hover/30 border-t border-b border-border",children:[r.jsxs("div",{className:"flex items-center justify-between text-xs",children:[r.jsx("span",{className:"text-muted",children:"Provider"}),r.jsx("span",{className:"font-medium text-ink",children:f.label})]}),r.jsxs("div",{className:"flex items-center justify-between text-xs mt-1",children:[r.jsx("span",{className:"text-muted",children:"Complexity"}),r.jsx("span",{className:"font-medium text-ink",children:p.label})]}),s&&r.jsxs("div",{className:"flex items-center justify-between text-xs mt-1",children:[r.jsx("span",{className:"text-muted",children:"Template"}),r.jsx("span",{className:"font-medium text-ink",children:s})]})]}),a!==void 0&&a>0&&r.jsx("div",{className:"px-5 py-2.5 bg-primary/5 border-b border-border",children:r.jsxs("div",{className:"flex items-center gap-1.5 text-xs",children:[r.jsx(Ud,{size:12,className:"text-primary"}),r.jsxs("span",{className:"text-secondary",children:["Similar projects cost ",r.jsxs("span",{className:"font-mono font-semibold text-ink",children:["$",a.toFixed(2)]})," on average"]})]})}),r.jsxs("div",{className:"px-5 py-2",children:[r.jsxs("button",{onClick:()=>h(!l),className:"flex items-center gap-1.5 w-full text-xs font-medium text-primary py-1.5",children:[l?r.jsx(mr,{size:12}):r.jsx(ms,{size:12}),"Cost breakdown by phase"]}),l&&r.jsx("div",{className:"space-y-2 mt-1 mb-2",children:c.breakdown.map(g=>r.jsxs("div",{className:"flex items-center justify-between",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-xs text-secondary",children:g.label}),r.jsxs("span",{className:"text-[11px] text-muted font-mono",children:[Hl(g.estimatedTokens)," tokens"]})]}),r.jsxs("span",{className:"text-xs font-mono font-semibold text-ink",children:["$",g.estimatedCost.toFixed(2)]})]},g.phase))})]}),u&&r.jsx("div",{className:"px-5 py-2 bg-warning/8 border-t border-warning/15",children:r.jsxs("div",{className:"flex items-start gap-2",children:[r.jsx(Ut,{size:14,className:"text-warning mt-0.5 flex-shrink-0"}),r.jsx("p",{className:"text-xs text-secondary",children:"This build may be expensive. Consider using a simpler complexity level or a more cost-effective provider."})]})}),r.jsxs("div",{className:"flex items-center justify-end gap-2 px-5 py-3 border-t border-border",children:[r.jsx(le,{variant:"ghost",size:"sm",onClick:o,children:"Cancel"}),r.jsx(le,{variant:"primary",size:"sm",onClick:n,icon:Ls,children:"Start Build"})]})]})}function Bv({sessionId:e}){return r.jsx(Dh,{sessionId:e})}function Qn(e,t,s){var o;if(t==="directory")return s?r.jsx(on,{size:14}):r.jsx(ao,{size:14});const i=((o=e.split(".").pop())==null?void 0:o.toLowerCase())||"";return{js:r.jsx(Q,{size:14,className:"text-yellow-600"}),ts:r.jsx(Q,{size:14,className:"text-blue-500"}),tsx:r.jsx(Q,{size:14,className:"text-blue-400"}),jsx:r.jsx(Q,{size:14,className:"text-yellow-500"}),py:r.jsx(Q,{size:14,className:"text-green-600"}),html:r.jsx(ac,{size:14,className:"text-orange-500"}),css:r.jsx(no,{size:14,className:"text-purple-500"}),json:r.jsx(ro,{size:14,className:"text-green-500"}),md:r.jsx(_i,{size:14,className:"text-muted"}),go:r.jsx(Q,{size:14,className:"text-cyan-600"}),rs:r.jsx(Q,{size:14,className:"text-orange-600"}),rb:r.jsx(Q,{size:14,className:"text-red-500"}),sh:r.jsx(Q,{size:14,className:"text-green-600"})}[i]||r.jsx(oo,{size:14})}function Tv(e){var n;const t=((n=e.split(".").pop())==null?void 0:n.toLowerCase())||"",s={js:"javascript",jsx:"javascript",ts:"typescript",tsx:"typescript",py:"python",html:"html",htm:"html",css:"css",scss:"scss",less:"less",json:"json",md:"markdown",go:"go",rs:"rust",sh:"shell",bash:"shell",yml:"yaml",yaml:"yaml",xml:"xml",svg:"xml",sql:"sql",java:"java",kt:"kotlin",rb:"ruby",dockerfile:"dockerfile"},i=e.toLowerCase();return i==="dockerfile"?"dockerfile":i==="makefile"?"makefile":s[t]||"plaintext"}function Rh(e,t){for(const s of e){if(s.path===t)return s.size;if(s.children){const i=Rh(s.children,t);if(i!==void 0)return i}}}function Ph(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Mh({nodes:e,selectedPath:t,onSelect:s,onDelete:i,onContextMenu:n,depth:o=0}){const[a,l]=d.useState(()=>{const h=new Set;return o<2&&e.filter(c=>c.type==="directory").forEach(c=>h.add(c.path)),h});return r.jsx("div",{role:o===0?"tree":"group",children:e.map(h=>{const c=h.type==="directory",f=a.has(h.path),p=h.path===t;return r.jsxs("div",{className:"group/file",children:[r.jsxs("button",{role:"treeitem","aria-label":h.name,"aria-selected":p,...c?{"aria-expanded":f}:{},onContextMenu:u=>{u.preventDefault(),n==null||n(u,h.path,h.name,h.type)},onClick:()=>{c?l(u=>{const g=new Set(u);return g.has(h.path)?g.delete(h.path):g.add(h.path),g}):s(h.path,h.name)},className:`w-full text-left flex items-center gap-1.5 px-2 py-1 text-xs font-mono rounded transition-colors ${p?"bg-primary/10 text-primary":"text-ink/70 hover:bg-hover"}`,style:{paddingLeft:`${o*14+8}px`},children:[c?r.jsx("span",{className:"w-3 flex items-center justify-center flex-shrink-0 text-muted",children:f?r.jsx(ms,{size:14}):r.jsx(pr,{size:14})}):r.jsx("span",{className:"w-3 flex-shrink-0"}),r.jsx("span",{className:`w-5 flex items-center justify-center flex-shrink-0 ${c?"text-primary":""}`,children:Qn(h.name,h.type,f)}),r.jsxs("span",{className:"truncate",children:[h.name,c?"/":""]}),!c&&h.size!=null&&h.size>0&&r.jsx("span",{className:"text-xs text-muted ml-auto flex-shrink-0",children:Ph(h.size)}),!c&&i&&r.jsx("span",{role:"button",tabIndex:-1,onClick:u=>{u.stopPropagation(),i(h.path,h.name)},onKeyDown:u=>{u.key==="Enter"&&(u.stopPropagation(),i(h.path,h.name))},className:"text-muted hover:text-danger ml-1 flex-shrink-0 opacity-0 group-hover/file:opacity-100 transition-opacity cursor-pointer",title:"Delete file",children:r.jsx(gt,{size:12})})]}),c&&f&&h.children&&r.jsx(Mh,{nodes:h.children,selectedPath:t,onSelect:s,onDelete:i,onContextMenu:n,depth:o+1})]},h.path)})})}function Lh(e,t=""){const s=[];for(const i of e)i.type==="file"&&s.push({path:i.path,name:i.name}),i.children&&s.push(...Lh(i.children,i.path+"/"));return s}function zv(){const[e,t]=d.useState({}),[s,i]=d.useState(""),[n,o]=d.useState(""),[a,l]=d.useState(!0),[h,c]=d.useState(null),[f,p]=d.useState(new Set),u=d.useCallback(async()=>{try{const y=await W.getSecrets();t(y)}catch{}l(!1)},[]);d.useEffect(()=>{u()},[u]);const g=async()=>{const y=s.trim();if(y){if(!/^[A-Z_][A-Z0-9_]*$/.test(y)){c("Key must be a valid ENV_VAR name (uppercase letters, digits, underscores)");return}c(null);try{await W.setSecret(y,n),i(""),o(""),await u()}catch(v){c(v instanceof Error?v.message:"Failed to set secret")}}},m=async y=>{if(window.confirm(`Delete secret "${y}"?`))try{await W.deleteSecret(y),await u()}catch(v){c(v instanceof Error?v.message:"Failed to delete secret")}},_=y=>{p(v=>{const j=new Set(v);return j.has(y)?j.delete(y):j.add(y),j})},x=Object.keys(e);return a?r.jsxs("div",{className:"p-6 space-y-4",children:[r.jsx(oi,{variant:"text",width:"180px",height:"16px"}),r.jsx(oi,{variant:"block",width:"100%",height:"60px"}),r.jsx(oi,{variant:"block",width:"100%",height:"80px"})]}):r.jsx("div",{className:"h-full flex flex-col",children:r.jsxs("div",{className:"p-6 overflow-y-auto",children:[r.jsx("h3",{className:"text-h3 font-heading text-ink mb-2",children:"Environment Secrets"}),r.jsxs("div",{className:"flex items-start gap-2 px-4 py-3 rounded-btn border border-warning/30 bg-warning/5 mb-6",children:[r.jsx(Ut,{size:16,className:"text-warning flex-shrink-0 mt-0.5"}),r.jsx("p",{className:"text-xs text-warning leading-relaxed",children:"Secrets are stored locally in plaintext and injected as environment variables during builds. They are never committed to the project repository."})]}),x.length>0&&r.jsx("div",{className:"card mb-6",children:r.jsxs("table",{className:"w-full text-sm",children:[r.jsx("thead",{children:r.jsxs("tr",{className:"border-b border-border",children:[r.jsx("th",{className:"text-left px-4 py-2 text-xs font-semibold text-muted-accessible uppercase tracking-wider",children:"Key"}),r.jsx("th",{className:"text-left px-4 py-2 text-xs font-semibold text-muted-accessible uppercase tracking-wider",children:"Value"}),r.jsx("th",{className:"w-20 px-4 py-2"})]})}),r.jsx("tbody",{children:x.map(y=>r.jsxs("tr",{className:"border-b border-border last:border-b-0",children:[r.jsx("td",{className:"px-4 py-2.5 font-mono text-xs text-ink",children:y}),r.jsx("td",{className:"px-4 py-2.5 font-mono text-xs text-muted-accessible",children:r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx("span",{children:f.has(y)?e[y]:"***"}),r.jsx("button",{onClick:()=>_(y),className:"text-muted hover:text-ink transition-colors",title:f.has(y)?"Hide value":"Show value",children:f.has(y)?r.jsx(Fd,{size:14}):r.jsx(Es,{size:14})})]})}),r.jsx("td",{className:"px-4 py-2.5 text-right",children:r.jsx("button",{onClick:()=>m(y),className:"text-muted hover:text-danger transition-colors",title:"Delete secret",children:r.jsx(io,{size:14})})})]},y))})]})}),x.length===0&&r.jsx("div",{className:"card p-4 mb-6",children:r.jsx("p",{className:"text-sm text-muted-accessible text-center py-4",children:"No secrets configured yet. Add your first secret below."})}),r.jsxs("div",{className:"card p-4",children:[r.jsx("label",{className:"block text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-3",children:"Add Secret"}),h&&r.jsx("div",{className:"text-xs text-danger mb-3 px-1",children:h}),r.jsxs("div",{className:"flex items-end gap-3",children:[r.jsxs("div",{className:"flex-1",children:[r.jsx("label",{className:"block text-xs text-muted-accessible mb-1",children:"Key"}),r.jsx("input",{type:"text",value:s,onChange:y=>i(y.target.value.toUpperCase()),placeholder:"API_KEY",className:"w-full px-3 py-2 text-sm font-mono bg-hover border border-border rounded-btn text-ink placeholder:text-muted"})]}),r.jsxs("div",{className:"flex-1",children:[r.jsx("label",{className:"block text-xs text-muted-accessible mb-1",children:"Value"}),r.jsx("input",{type:"password",value:n,onChange:y=>o(y.target.value),placeholder:"secret value",className:"w-full px-3 py-2 text-sm font-mono bg-hover border border-border rounded-btn text-ink placeholder:text-muted"})]}),r.jsxs("button",{onClick:g,disabled:!s.trim(),className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium rounded-btn border border-primary bg-primary/10 text-primary hover:bg-primary/20 transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:[r.jsx(gr,{size:14}),"Add"]})]})]})]})})}function Av({sessionId:e}){const[t,s]=d.useState(null),[i,n]=d.useState([]),[o,a]=d.useState(null),[l,h]=d.useState(""),[c,f]=d.useState(!0),[p,u]=d.useState(!1),[g,m]=d.useState(null),_=d.useCallback(async()=>{try{const v=await W.getDocsStatus(e);if(s(v),v.has_docs){const j=await W.getDocFiles(e);n(j.files)}}catch{}f(!1)},[e]);d.useEffect(()=>{_()},[_]);const x=async()=>{u(!0),m(null);try{await W.generateDocs(e);const v=setInterval(async()=>{try{const j=await W.getDocsStatus(e);if(j.has_docs){s(j);const k=await W.getDocFiles(e);n(k.files),u(!1),clearInterval(v)}}catch{}},3e3);setTimeout(()=>{clearInterval(v),u(!1)},3e5)}catch(v){m(v instanceof Error?v.message:"Failed to start doc generation"),u(!1)}},y=async v=>{try{const j=await W.getDocFileContent(e,v);a(v),h(j)}catch(j){m(j instanceof Error?j.message:"Failed to load doc file")}};return c?r.jsxs("div",{className:"p-6 space-y-4",children:[r.jsx(oi,{variant:"text",width:"180px",height:"16px"}),r.jsx(oi,{variant:"block",width:"100%",height:"60px"})]}):o?r.jsxs("div",{className:"h-full flex flex-col",children:[r.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-border bg-hover",children:[r.jsxs("button",{onClick:()=>{a(null),h("")},className:"text-xs text-muted hover:text-ink flex items-center gap-1",children:[r.jsx(Jl,{size:14}),"Back to docs"]}),r.jsx("span",{className:"text-xs font-mono text-ink",children:o})]}),r.jsx("div",{className:"flex-1 overflow-y-auto p-6",children:r.jsx("pre",{className:"text-sm text-ink whitespace-pre-wrap font-mono leading-relaxed",children:l})})]}):r.jsx("div",{className:"h-full flex flex-col",children:r.jsxs("div",{className:"p-6 overflow-y-auto",children:[r.jsx("h3",{className:"text-h3 font-heading text-ink mb-2",children:"Documentation"}),g&&r.jsx("div",{className:"px-4 py-3 rounded-btn border border-error/30 bg-error/5 mb-4",children:r.jsx("p",{className:"text-xs text-error",children:g})}),(t==null?void 0:t.has_docs)&&t.coverage_pct>0&&r.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("span",{className:"text-xs text-muted",children:"Coverage:"}),r.jsx("div",{className:"w-32 h-2 bg-border rounded-full overflow-hidden",children:r.jsx("div",{className:"h-full bg-primary rounded-full transition-all",style:{width:`${Math.min(100,t.coverage_pct)}%`}})}),r.jsxs("span",{className:"text-xs font-mono text-ink",children:[t.coverage_pct,"%"]})]}),t.commits_behind>0&&r.jsxs("span",{className:"text-xs text-warning",children:[t.commits_behind," commit",t.commits_behind!==1?"s":""," behind"]})]}),r.jsx("div",{className:"flex gap-2 mb-6",children:t!=null&&t.has_docs?r.jsxs(le,{onClick:x,disabled:p,size:"sm",variant:"secondary",children:[r.jsx(bt,{size:14,className:p?"animate-spin":""}),p?"Updating...":"Update Docs"]}):r.jsx(le,{onClick:x,disabled:p,size:"sm",children:p?"Generating...":"Generate Documentation"})}),i.length>0?r.jsx("div",{className:"space-y-1",children:i.map(v=>r.jsxs("button",{onClick:()=>y(v.name),className:"w-full flex items-center gap-3 px-3 py-2 rounded-btn hover:bg-hover text-left transition-colors group",children:[r.jsx(_i,{size:14,className:"text-muted group-hover:text-ink flex-shrink-0"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("span",{className:"text-sm text-ink font-mono truncate block",children:v.name}),r.jsx("span",{className:"text-xs text-muted",children:v.size<1024?`${v.size} B`:`${(v.size/1024).toFixed(1)} KB`})]}),r.jsx("span",{className:"text-xs text-muted opacity-0 group-hover:opacity-100",children:"View"})]},v.name))}):t!=null&&t.has_docs?null:r.jsx("p",{className:"text-sm text-muted",children:'No documentation generated yet. Click "Generate Documentation" to create docs for this project.'}),(t==null?void 0:t.last_generated)&&r.jsxs("p",{className:"text-xs text-muted mt-4",children:["Last generated: ",new Date(t.last_generated).toLocaleString()]})]})})}function Ov({session:e,onClose:t}){var sa;const[s,i]=d.useState(null),[n,o]=d.useState(""),[a,l]=d.useState(null),[h,c]=d.useState(null),[f,p]=d.useState(!1),[u,g]=d.useState("code"),[m,_]=d.useState(!1),[x,y]=d.useState(!1),[v,j]=d.useState(e),k=d.useRef(null),[w,N]=d.useState([]),[M,U]=d.useState(!1),[Y,V]=d.useState(""),$=d.useRef(null),P=d.useRef(null),[E,B]=d.useState(0),[S,C]=d.useState(null),[D,L]=d.useState(!0),[Z,oe]=d.useState(!0),[q,J]=d.useState(!1),[se,de]=d.useState("overview"),ue=57374,[ce,ge]=d.useState(null),Fe=d.useCallback(()=>{J(b=>{const A=!b;return L(!A),oe(!A),A})},[]),[z,xe]=d.useState(()=>sessionStorage.getItem(`pl_buildmode_${v.id}`)||"standard"),[T,G]=d.useState(()=>sessionStorage.getItem(`pl_provider_${v.id}`)||"claude"),[K,ne]=d.useState(null),[He,be]=d.useState(null),[he,Ae]=d.useState(null),[pe,wt]=d.useState(!1),[We,Xt]=d.useState(!1),[Ue,bs]=d.useState({phase:"idle",iteration:null,maxIterations:null,cost:null,startTime:0}),[Ct,Xe]=d.useState(!1),[Ke,Je]=d.useState(null),kt=d.useRef(null),[Bh,Do]=d.useState(!1),[Th,Ro]=d.useState([]),[Po,Is]=d.useState(null),[zh,Cr]=d.useState(!1),[Ah,wi]=d.useState(!1),[Oh,Fs]=d.useState(!1),[Ci,Mo]=d.useState("files"),{history:Lo,recordTokens:Bo}=Yx(),[$h,Ih]=d.useState(null),[To,Fh]=d.useState({line:1,column:1}),[Hh,zo]=d.useState(0),{device:Wh,setDevice:Uh,frameClass:Ao}=ev(),[kr,Kh]=d.useState(100),[Oo,qh]=d.useState(!1),[ki,Nr]=d.useState(!1),[$o,Iv]=d.useState([]),ys=d.useRef(null),[Vh,Io]=d.useState(0),{subscribe:Fo}=Ed(),tt=d.useCallback(async()=>{try{const b=await W.getSessionDetail(v.id);j(b)}catch{}},[v.id]),Ho=d.useCallback(async()=>{try{await W.stopSession(),wt(!1),Xt(!1)}catch{}},[]),Gh=d.useCallback(async()=>{try{await W.pauseSession(),Xt(!0)}catch{}},[]),Yh=d.useCallback(async()=>{try{await W.resumeSession(),Xt(!1)}catch{}},[]),Wo=d.useRef("idle");d.useEffect(()=>{const b=async()=>{try{const F=await W.getStatus();wt(F.running),Xt(F.paused),F.provider&&G(F.provider);const te=F.phase||"idle";if(te!==Wo.current&&te!=="idle"){const ot=new Date().toISOString(),Tt={starting:"Initialising build session",planning:"Planning phase started",building:"Building your project",testing:"Running tests",reviewing:"Reviewing code quality",complete:"Build complete"},zt={id:`phase-${Date.now()}`,type:"phase_change",message:Tt[te]||`Phase: ${te}`,timestamp:ot};Ro(Mi=>[...Mi,zt]),Wo.current=te}bs({phase:te,iteration:typeof F.iteration=="number"?F.iteration:null,maxIterations:typeof F.max_iterations=="number"&&F.max_iterations>0?F.max_iterations:null,cost:typeof F.cost=="number"?F.cost:null,startTime:F.start_time?F.start_time*1e3:0});const Ze=F.tokens_used;Ze!=null&&Bo(Ze)}catch{}};b();const A=setInterval(b,pe?3e3:1e4);return()=>clearInterval(A)},[pe,Bo]),d.useEffect(()=>{if(!(he!=null&&he.loading))return;const b=setInterval(()=>{Ae(A=>A?{...A,elapsed:Math.floor((Date.now()-A.startTime)/1e3)}:null)},1e3);return()=>clearInterval(b)},[he==null?void 0:he.loading]);const[ee,Xh]=d.useState(null);d.useEffect(()=>{W.getPreviewInfo(v.id).then(Xh).catch(()=>{})},[v.id]);const[I,Ni]=d.useState(null),[Hs,Uo]=d.useState(!1),[Ko,qo]=d.useState(!1),[Vo,ji]=d.useState(null),[Jt,Jh]=d.useState("");d.useEffect(()=>{const b=Fo("file_changed",A=>{const F=A;if(!F.paths||F.paths.length===0)return;const te=new Date().toISOString(),Ze=F.paths.map((ot,Tt)=>{var ia;const zt=(ia=F.event_types)==null?void 0:ia[Tt],Mi=zt==="created"||zt==="IN_CREATE";return{id:`file-${Date.now()}-${Tt}`,type:Mi?"file_created":"file_modified",message:Mi?`Created ${ot.split("/").pop()}`:`Modified ${ot.split("/").pop()}`,timestamp:te,filePath:ot}});if(Ro(ot=>[...ot,...Ze]),Xe(!0),kt.current&&clearTimeout(kt.current),kt.current=setTimeout(()=>Xe(!1),2e3),tt(),s&&F.paths.some(Tt=>Tt===s||s.endsWith(Tt))&&Je(s),u==="preview"){const ot=["react","vite","next","nuxt","svelte","remix"];(I==null?void 0:I.running)&&(I==null?void 0:I.framework)&&ot.some(zt=>I.framework.toLowerCase().includes(zt))||B(zt=>zt+1)}});return()=>{b(),kt.current&&clearTimeout(kt.current)}},[Fo,s,u,I==null?void 0:I.running,tt]);const Zh=d.useCallback(async()=>{if(!(!Ke||!v.id)){try{const b=await W.getSessionFileContent(v.id,Ke);l(b.content),c(b.content),_(!1),N(A=>A.map(F=>F.path===Ke?{...F,content:b.content,modified:!1}:F))}catch{}Je(null)}},[Ke,v.id]);d.useEffect(()=>{if(u!=="preview")return;let b=!1;const A=async()=>{try{const te=await W.devserver.status(v.id);b||Ni(te)}catch{}};A();const F=setInterval(A,3e3);return()=>{b=!0,clearInterval(F)}},[u,v.id]),d.useEffect(()=>{u==="dashboard"&&fetch(`http://127.0.0.1:${ue}/health`).then(b=>ge(b.ok)).catch(()=>ge(!1))},[u]);const Ss=d.useCallback(async b=>{Uo(!0),ji(null);try{const A=await W.devserver.start(v.id,b);if(A.status==="error")ji(A.message||"Failed to start dev server");else{const F=await W.devserver.status(v.id);Ni(F)}}catch(A){ji(A instanceof Error?A.message:"Failed to start dev server")}Uo(!1)},[v.id]),Go=d.useRef(!1);d.useEffect(()=>{Go.current||ee!=null&&ee.dev_command&&(I!=null&&I.running||(I==null?void 0:I.status)==="starting"||Hs||(Go.current=!0,Ss(ee.dev_command)))},[ee==null?void 0:ee.dev_command,I==null?void 0:I.running,I==null?void 0:I.status,Hs,Ss]);const Qh=d.useCallback(async()=>{try{await W.devserver.stop(v.id);const b=await W.devserver.status(v.id);Ni(b)}catch{}},[v.id]),ed=d.useCallback(async()=>{qo(!0);try{const b=await W.fixProject(v.id);if(b.task_id){let F=0,te;do await new Promise(ot=>setTimeout(ot,2e3)),te=await W.chatPoll(v.id,b.task_id),F++;while(!te.complete&&F<150);const Ze=await W.devserver.status(v.id);Ni(Ze)}}catch(b){ji(b instanceof Error?b.message:"Fix failed")}qo(!1)},[v.id]),ws=I!=null&&I.running&&(I!=null&&I.port)?I.framework==="expo"?`${sn}/api/sessions/${encodeURIComponent(v.id)}/expo-qr`:I.portless_url||`http://localhost:${I.port}/`:null,td=(ee==null?void 0:ee.preview_url)||`${sn}/api/sessions/${encodeURIComponent(v.id)}/preview/index.html`,sd=ws||td,[Ei,Yo]=d.useState([]),[Nt,Di]=d.useState(0);d.useEffect(()=>{const b=ws||(ee==null?void 0:ee.preview_url);b&&(Yo([b]),Di(0))},[ws,ee==null?void 0:ee.preview_url]);const Lt=Ei[Nt]||sd,[Xo,jr]=d.useState(Lt),id=d.useCallback((b,A,F,te)=>{b.preventDefault(),C({x:b.clientX,y:b.clientY,path:A,name:F,type:te})},[]),rd=d.useCallback(()=>{Nt>0&&(Di(b=>b-1),B(b=>b+1))},[Nt]),nd=d.useCallback(()=>{Nt<Ei.length-1&&(Di(b=>b+1),B(b=>b+1))},[Nt,Ei.length]),od=d.useCallback(b=>{let A=b;if(b.startsWith("/")&&ws)try{A=`${new URL(ws).origin}${b}`}catch{const F=I==null?void 0:I.port;F&&(A=`http://localhost:${F}${b}`)}Yo(F=>[...F.slice(0,Nt+1),A]),Di(F=>F+1),B(F=>F+1)},[Nt,ws,I==null?void 0:I.port]);d.useEffect(()=>{try{const b=new URL(Lt,window.location.origin);jr(b.pathname+b.search+b.hash||"/")}catch{jr(Lt)}},[Lt]);const Ri=d.useCallback(async()=>{Ae({type:"review",loading:!0,startTime:Date.now(),elapsed:0}),be(null);try{const b=await W.reviewProject(v.id);be(b.output)}catch(b){be(`Error: ${b instanceof Error?b.message:"Unknown"}`)}finally{Ae(null)}},[v.id]),Pi=d.useCallback(async()=>{Ae({type:"test",loading:!0,startTime:Date.now(),elapsed:0}),be(null);try{const b=await W.testProject(v.id);be(b.output)}catch(b){be(`Error: ${b instanceof Error?b.message:"Unknown"}`)}finally{Ae(null)}},[v.id]),Er=d.useCallback(async()=>{Ae({type:"explain",loading:!0,startTime:Date.now(),elapsed:0}),be(null);try{const b=await W.explainProject(v.id);be(b.output)}catch(b){be(`Error: ${b instanceof Error?b.message:"Unknown"}`)}finally{Ae(null)}},[v.id]),Dr=d.useCallback(async(b,A)=>{if(window.confirm(`Delete "${A}"?`))try{await W.deleteSessionFile(v.id,b),s===b&&(i(null),o(""),l(null),c(null),_(!1)),await tt()}catch(te){const Ze=te instanceof Error?te.message:"Unknown error";window.alert(`Delete failed: ${Ze}`)}},[v.id,s,tt]),ad=d.useCallback(b=>b.type==="file"?[{label:"Review",icon:Es,onClick:()=>{Ri()}},{label:"Generate Tests",icon:ai,onClick:()=>{Pi()}},{label:"Explain",icon:Js,onClick:()=>{Er()}},{label:"Delete",icon:io,onClick:()=>{Dr(b.path,b.name)},variant:"danger"}]:[{label:"Review Project",icon:Es,onClick:()=>{Ri()}},{label:"Run Tests",icon:ai,onClick:()=>{Pi()}}],[Ri,Pi,Er,Dr]),Bt=d.useCallback(async(b,A)=>{Je(null),m&&s&&h!==null&&N(te=>te.map(Ze=>Ze.path===s?{...Ze,content:h,modified:!0}:Ze));const F=w.find(te=>te.path===b);if(F){i(b),o(A),l(F.content),c(F.content),_(F.modified);return}i(b),o(A),p(!0),_(!1);try{const te=v.id?await W.getSessionFileContent(v.id,b):await W.getFileContent(b);l(te.content),c(te.content),N(Ze=>[...Ze,{path:b,name:A,content:te.content,modified:!1}])}catch{l("[Error loading file]"),c("[Error loading file]")}finally{p(!1)}},[v.id,m,s,h,w]),Rr=d.useCallback(async()=>{var b;if(!(!s||h===null||!v.id)){y(!0);try{await W.saveSessionFile(v.id,s,h),l(h),_(!1),Ih(Date.now()),N(F=>F.map(te=>te.path===s?{...te,content:h,modified:!1}:te));const A=((b=s.split(".").pop())==null?void 0:b.toLowerCase())||"";["html","css","js","jsx","ts","tsx"].includes(A)&&B(F=>F+1)}catch(A){const F=A instanceof Error?A.message:"Unknown error";window.alert(`Save failed: ${F}`)}finally{y(!1)}}},[s,h,v.id]),Jo=d.useCallback(b=>{const A=w.find(F=>F.path===b);if(!(A!=null&&A.modified&&!window.confirm("Unsaved changes. Close anyway?"))&&(N(F=>F.filter(te=>te.path!==b)),s===b)){const F=w.filter(te=>te.path!==b);if(F.length>0){const te=F[F.length-1];i(te.path),o(te.name),l(te.content),c(te.content),_(te.modified)}else i(null),o(""),l(null),c(null),_(!1)}},[w,s]);d.useEffect(()=>{const b=A=>{(A.metaKey||A.ctrlKey)&&A.key==="s"&&(A.preventDefault(),m&&s&&Rr()),(A.metaKey||A.ctrlKey)&&A.key==="p"&&(A.preventDefault(),U(F=>!F),V("")),(A.metaKey||A.ctrlKey)&&A.key==="k"&&(A.preventDefault(),Do(F=>!F)),A.key==="Escape"&&M&&U(!1)};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[m,s,Rr,M]),d.useEffect(()=>{M&&$.current&&$.current.focus()},[M]);const Zo=Lh(v.files),Ws=Y?Zo.filter(b=>b.path.toLowerCase().includes(Y.toLowerCase())):Zo;d.useEffect(()=>{const b=v.files.find(A=>A.name==="index.html"&&A.type==="file");b&&Bt(b.path,b.name)},[]);const ld=d.useCallback(b=>{b!==void 0&&(c(b),_(b!==a),zo(b.split(`
255
+ `).length))},[a]),cd=d.useCallback(b=>{k.current=b;const A=b;if(A!=null&&A.onDidChangeCursorPosition&&A.onDidChangeCursorPosition(F=>{Fh({line:F.position.lineNumber,column:F.position.column})}),A!=null&&A.getModel){const F=A.getModel();F!=null&&F.getLineCount&&zo(F.getLineCount())}},[]),hd=d.useCallback(async()=>{const b=window.prompt("New file name (e.g. src/utils.ts):");if(!(!b||!b.trim()))try{await W.createSessionFile(v.id,b.trim()),await tt()}catch(A){const F=A instanceof Error?A.message:"Unknown error";window.alert(`Create file failed: ${F}`)}},[v.id,tt]),dd=d.useCallback(async()=>{const b=window.prompt("New folder name (e.g. src/components):");if(!(!b||!b.trim()))try{await W.createSessionDirectory(v.id,b.trim()),await tt()}catch(A){const F=A instanceof Error?A.message:"Unknown error";window.alert(`Create folder failed: ${F}`)}},[v.id,tt]),Qo=d.useCallback(async()=>{try{const b=await W.previewChanges(v.id,"preview current changes");Is(b)}catch{}},[v.id]),ud=d.useCallback(()=>{Is(null),tt()},[tt]),fd=d.useCallback(b=>{Is(null),tt()},[tt]),md=d.useCallback(()=>{Is(null)},[]),ea=s?Rh(v.files,s):void 0,pd=((sa=n.split(".").pop())==null?void 0:sa.toUpperCase())||"",{showHelp:_d,setShowHelp:ta}=vx({onToggleBuild:()=>{pe&&Ho()}}),gd=d.useMemo(()=>[{id:"preview",label:"Open Preview",category:"command",icon:Es,action:()=>g("preview"),shortcut:""},{id:"code",label:"Open Code Editor",category:"command",icon:ln,action:()=>g("code")},{id:"terminal",label:"Open Terminal",category:"command",icon:os,action:()=>oe(!0)},{id:"dashboard",label:"Open Dashboard",category:"command",icon:Mr,action:()=>g("dashboard")},{id:"deploy",label:"Deploy Project",category:"command",icon:Kt,action:()=>g("deploy")},{id:"git",label:"Git Status",category:"command",icon:Te,action:()=>g("git")},{id:"settings",label:"Settings / Config",category:"setting",icon:la,action:()=>g("config")},{id:"quick-open",label:"Quick Open File",category:"file",icon:Q,action:()=>{U(!0),V("")},shortcut:"Cmd+P"},{id:"zen",label:"Toggle Zen Mode",category:"setting",icon:cn,action:()=>Fe()},{id:"sidebar",label:"Toggle File Tree",category:"setting",icon:ca,action:()=>L(b=>!b)},{id:"preview-changes",label:"Preview Pending Changes",category:"command",icon:Te,action:()=>Qo()},{id:"insights",label:"Build Insights",category:"command",icon:rn,action:()=>g("insights")},{id:"docs",label:"Documentation",category:"command",icon:Js,action:()=>g("docs")},{id:"nl-search",label:"Natural Language Search",category:"command",icon:as,action:()=>Fs(!0)}],[g,Fe,Qo]),Pr=d.useMemo(()=>{if(!pe)return"idle";const b=(Ue.phase||v.status||"").toLowerCase();return b.includes("starting")||b.includes("plan")||b.includes("bootstrap")?"planning":b.includes("review")||b.includes("council")?"reviewing":b.includes("test")||b.includes("verify")?"testing":b.includes("complete")||b.includes("fulfilled")?"complete":"building"},[pe,Ue.phase,v.status]);return r.jsxs("div",{className:"flex flex-col h-full relative",children:[r.jsxs("div",{className:"bg-card px-3 py-2 flex items-center gap-3 flex-shrink-0 border-b border-border",children:[r.jsx("button",{onClick:()=>{m&&!window.confirm("Unsaved changes. Discard?")||t()},className:"text-xs font-medium px-3 py-1.5 rounded-btn border border-border text-muted hover:text-ink hover:bg-hover transition-colors",children:"Back"}),r.jsxs("div",{className:"flex-1 min-w-0",children:[r.jsx("h2",{className:"text-sm font-bold text-ink truncate",children:v.id}),r.jsx("p",{className:"text-xs font-mono text-muted-accessible truncate",children:v.path})]}),r.jsx("span",{className:`text-xs font-semibold px-2 py-0.5 rounded-full ${v.status==="completed"||v.status==="completion_promise_fulfilled"?"bg-success/10 text-success":"bg-muted/10 text-muted"}`,children:v.status}),Lo.length>=2&&r.jsx("div",{className:"flex items-center gap-1 border-l border-border pl-2 ml-1",children:r.jsx(Gx,{tokenHistory:Lo})}),r.jsxs("div",{className:"flex items-center gap-0.5 border-l border-border pl-2 ml-1",children:[r.jsx("button",{onClick:()=>L(b=>!b),title:D?"Hide file tree":"Show file tree",className:"p-1.5 rounded hover:bg-hover text-muted hover:text-ink transition-colors",children:D?r.jsx(ca,{size:16}):r.jsx(ku,{size:16})}),r.jsx("button",{onClick:()=>oe(b=>!b),title:Z?"Hide terminal/chat":"Show terminal/chat",className:"p-1.5 rounded hover:bg-hover text-muted hover:text-ink transition-colors",children:Z?r.jsx(yu,{size:16}):r.jsx(wu,{size:16})}),r.jsx("button",{onClick:Fe,title:q?"Exit zen mode":"Zen mode (hide all panels)",className:`p-1.5 rounded hover:bg-hover transition-colors ${q?"text-primary":"text-muted hover:text-ink"}`,children:q?r.jsx(cc,{size:16}):r.jsx(cn,{size:16})})]}),!pe&&r.jsx(le,{variant:"primary",size:"sm",icon:rs,onClick:()=>{if(!(v.prd||"").trim()){window.alert("No spec found for this project. Go to Home to start a new build.");return}wi(!0)},title:"Start build for this project",children:"Build"}),!pe&&Pr==="complete"&&r.jsx(le,{variant:"ghost",size:"sm",icon:rr,onClick:()=>Cr(!0),title:"Replay the build timeline",children:"Replay Build"}),r.jsx(At,{icon:as,label:"Natural language search",size:"sm",onClick:()=>Fs(!0)}),pe&&r.jsxs("div",{className:"flex items-center gap-1 border-l border-border pl-3 ml-1",children:[We?r.jsx(le,{variant:"ghost",size:"sm",icon:rs,onClick:Yh,title:"Resume build",children:"Resume"}):r.jsx(le,{variant:"ghost",size:"sm",icon:Zl,onClick:Gh,title:"Pause build",children:"Pause"}),r.jsx(le,{variant:"danger",size:"sm",icon:ir,onClick:Ho,title:"Stop build",children:"Stop"})]}),r.jsx(At,{icon:Es,label:"Review project",size:"sm",onClick:Ri,disabled:!!(he!=null&&he.loading)}),r.jsx(At,{icon:ai,label:"Run tests",size:"sm",onClick:Pi,disabled:!!(he!=null&&he.loading)}),r.jsx(At,{icon:Js,label:"Explain project",size:"sm",onClick:Er,disabled:!!(he!=null&&he.loading)}),r.jsx(le,{variant:"secondary",size:"sm",icon:Kt,onClick:()=>g("deploy"),title:"Deploy project",children:"Deploy"}),r.jsx(yx,{onClick:()=>ta(!0)})]}),r.jsx("div",{className:"flex items-center gap-2",children:r.jsx("div",{className:"flex-1",children:r.jsx(lx,{phase:Pr,iteration:Ue.iteration,maxIterations:Ue.maxIterations,cost:Ue.cost,startTime:Ue.startTime,isRunning:pe})})}),r.jsx(Tx,{sessionId:v.id,onRestore:tt}),r.jsx("div",{className:"flex-1 min-h-0",children:r.jsxs(un,{orientation:"vertical",children:[r.jsx(ei,{defaultSize:70,minSize:40,children:r.jsxs(un,{orientation:"horizontal",className:"h-full",children:[D&&r.jsx(ei,{defaultSize:20,minSize:15,children:r.jsxs("div",{className:"h-full flex flex-col border-r border-border bg-card",children:[r.jsxs("div",{className:"flex items-center border-b border-border flex-shrink-0",children:[r.jsxs("button",{onClick:()=>Mo("files"),className:`flex items-center gap-1.5 px-3 py-2 text-xs font-medium transition-colors border-b-2 ${Ci==="files"?"text-primary border-primary":"text-muted hover:text-ink border-transparent"}`,children:[r.jsx(ao,{size:14}),"Files",Ct&&r.jsx("span",{className:"ml-1 text-[10px] font-normal text-primary animate-pulse",children:"changed"})]}),r.jsxs("button",{onClick:()=>Mo("chat"),className:`flex items-center gap-1.5 px-3 py-2 text-xs font-medium transition-colors border-b-2 ${Ci==="chat"?"text-primary border-primary":"text-muted hover:text-ink border-transparent"}`,children:[r.jsx(Gl,{size:14}),"Chat"]}),Ci==="files"&&r.jsxs("div",{className:"ml-auto flex items-center gap-1 pr-2",children:[r.jsxs("button",{onClick:hd,title:"New File",className:"flex items-center gap-1 text-xs text-muted-accessible hover:text-primary px-2.5 py-1 rounded border border-border hover:border-primary/30 transition-colors",children:[r.jsx(_r,{size:12})," New"]}),r.jsxs("button",{onClick:dd,title:"New Folder",className:"flex items-center gap-1 text-xs text-muted-accessible hover:text-primary px-2.5 py-1 rounded border border-border hover:border-primary/30 transition-colors",children:[r.jsx(Bd,{size:12})," New"]})]})]}),Ci==="files"?r.jsx("div",{className:"flex-1 overflow-y-auto terminal-scroll",children:v.files.length>0?r.jsx(Mh,{nodes:v.files,selectedPath:s,onSelect:Bt,onDelete:Dr,onContextMenu:id}):r.jsxs("div",{className:"flex flex-col items-center justify-center p-6 text-center h-full",children:[r.jsx(on,{size:28,className:"text-muted/40 mb-2"}),r.jsx("p",{className:"text-xs text-muted font-medium",children:"No files yet"}),r.jsx("p",{className:"text-[11px] text-muted/70 mt-0.5",children:"Start a build to generate your project."})]})}):r.jsx("div",{className:"flex-1 flex flex-col min-h-0",children:r.jsx("div",{className:"flex-1 min-h-0",children:r.jsx(bv,{sessionId:v.id,defaultMode:z})})})]})}),D&&r.jsx(fn,{className:"w-1 bg-border hover:bg-primary/30 transition-colors cursor-col-resize"}),r.jsx(ei,{defaultSize:80,minSize:40,children:r.jsxs("div",{className:"h-full flex flex-col min-w-0",children:[r.jsx("div",{className:"flex items-center border-b border-border bg-hover px-1 flex-shrink-0",role:"tablist",children:[{id:"code",label:"Code",icon:ln},{id:"preview",label:"Preview",icon:Es},{id:"deploy",label:"Deploy",icon:Kt},{id:"config",label:"Config",icon:la},{id:"secrets",label:"Secrets",icon:mu},{id:"prd",label:"Spec",icon:_i},{id:"dashboard",label:"Dashboard",icon:Mr},{id:"git",label:"Git",icon:Te},{id:"cicd",label:"CI/CD",icon:Te},{id:"insights",label:"Insights",icon:rn},{id:"docs",label:"Docs",icon:Js}].map(b=>r.jsxs("button",{role:"tab","aria-selected":u===b.id,onClick:()=>g(b.id),className:`flex items-center gap-1.5 px-4 py-2 text-xs font-medium border-b-2 transition-colors ${u===b.id?"border-primary text-primary":"border-transparent text-muted hover:text-ink hover:border-border"}`,children:[r.jsx(b.icon,{size:14}),b.label]},b.id))}),r.jsxs("div",{className:"flex-1 min-h-0",role:"tabpanel",children:[u==="code"&&r.jsxs("div",{className:"h-full flex flex-col min-w-0",children:[w.length>0&&r.jsx("div",{className:"flex items-center border-b border-border bg-hover overflow-x-auto flex-shrink-0",children:w.map(b=>r.jsxs("button",{onClick:()=>Bt(b.path,b.name),className:`flex items-center gap-1.5 px-3 py-1.5 text-[11px] font-mono border-r border-border whitespace-nowrap transition-colors ${b.path===s?"bg-card text-ink":"text-muted hover:text-ink hover:bg-card"}`,children:[r.jsx("span",{className:"w-4 flex items-center justify-center",children:Qn(b.name,"file")}),b.name,b.modified&&r.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-primary"}),r.jsx("span",{role:"button",tabIndex:-1,title:"Close tab",onClick:A=>{A.stopPropagation(),Jo(b.path)},onKeyDown:A=>{A.key==="Enter"&&(A.stopPropagation(),Jo(b.path))},className:"text-muted hover:text-danger ml-1 cursor-pointer",children:r.jsx(gt,{size:12})})]},b.path))}),s?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"px-4 py-1.5 border-b border-border flex items-center gap-2 flex-shrink-0 bg-hover",children:[r.jsx("span",{className:"text-xs font-mono text-secondary truncate",children:s}),x&&r.jsx("span",{className:"text-xs text-primary animate-pulse flex-shrink-0",children:"Saving..."}),r.jsx("span",{className:"ml-auto text-xs text-muted/50 font-mono",children:ea!=null?Ph(ea):""}),r.jsx("span",{className:"text-xs text-muted font-mono uppercase",children:pd}),m&&r.jsx("button",{onClick:Rr,className:"text-xs font-medium px-2 py-0.5 rounded border border-primary/40 bg-primary/10 text-primary hover:bg-primary/20 transition-colors",children:"Save"})]}),Ke===s&&r.jsxs("div",{className:"px-4 py-1.5 border-b border-border flex items-center gap-2 flex-shrink-0 bg-warning/10",children:[r.jsx(bt,{size:12,className:"text-warning"}),r.jsx("span",{className:"text-xs text-warning font-medium",children:"File changed externally"}),r.jsxs("div",{className:"ml-auto flex items-center gap-1.5",children:[r.jsx("button",{onClick:Zh,className:"text-xs font-medium px-2 py-0.5 rounded border border-warning/40 bg-warning/10 text-warning hover:bg-warning/20 transition-colors",children:"Reload"}),r.jsx("button",{onClick:()=>Je(null),className:"text-xs font-medium px-2 py-0.5 rounded border border-border text-muted hover:text-ink hover:bg-hover transition-colors",children:"Dismiss"})]})]}),r.jsx("div",{className:"flex-1 min-h-0",children:f?r.jsx(Dd,{}):r.jsx(Wi,{name:"Editor",children:r.jsx(Xf,{value:h??"",language:Tv(n),theme:"vs",onChange:ld,onMount:cd,options:{minimap:{enabled:!1},fontSize:13,lineNumbers:"on",wordWrap:"on",scrollBeyondLastLine:!1,automaticLayout:!0,padding:{top:8},renderLineHighlight:"line",smoothScrolling:!0,cursorBlinking:"smooth",folding:!0,bracketPairColorization:{enabled:!0}}})})}),r.jsx(Zx,{selectedFile:s,fileName:n,isModified:m,isSaving:x,lastSavedAt:$h,lineCount:Hh,cursorLine:To.line,cursorColumn:To.column,sessionId:v.id,prd:v.prd})]}):r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-center p-8",children:[r.jsx(Q,{size:32,className:"text-muted/30 mb-3"}),r.jsx("p",{className:"text-sm text-muted",children:"Select a file to view its contents"}),r.jsxs("p",{className:"text-xs text-muted/60 mt-1",children:["Use the file tree or press ",r.jsx("kbd",{className:"px-1.5 py-0.5 text-[10px] font-mono bg-hover border border-border rounded",children:"Cmd+P"})," to quick open"]})]})]}),u==="preview"&&r.jsx(Wi,{name:"Preview",children:r.jsxs("div",{className:`h-full flex flex-col ${Oo?"preview-fullscreen":""}`,children:[r.jsx("div",{className:"px-3 py-1.5 border-b border-border flex items-center gap-2 bg-hover flex-shrink-0",children:I!=null&&I.running||ee!=null&&ee.preview_url?r.jsxs(r.Fragment,{children:[r.jsx(At,{icon:Jl,label:"Back",size:"sm",onClick:rd,disabled:Nt<=0}),r.jsx(At,{icon:to,label:"Forward",size:"sm",onClick:nd,disabled:Nt>=Ei.length-1}),r.jsx(ov,{onClick:()=>{Nr(!0),B(b=>b+1)}}),r.jsx("input",{value:Xo,onChange:b=>jr(b.target.value),onKeyDown:b=>{b.key==="Enter"&&od(Xo)},className:"flex-1 px-3 py-1 text-xs font-mono bg-card border border-border rounded-btn"}),r.jsx(Qx,{selectedDevice:Wh,onDeviceChange:Uh,containerWidth:Vh}),r.jsx(sv,{zoom:kr,onZoomChange:Kh}),r.jsx(rv,{url:Lt}),r.jsx(iv,{}),r.jsx(At,{icon:ls,label:"Open in new tab",size:"sm",onClick:()=>window.open(Lt,"_blank")}),r.jsx(nv,{isFullscreen:Oo,onToggle:()=>qh(b=>!b)}),(I==null?void 0:I.running)&&r.jsxs("button",{onClick:Qh,className:"flex items-center gap-1 px-2 py-1 text-xs font-medium rounded border border-danger/40 bg-danger/10 text-danger hover:bg-danger/20 transition-colors",children:[r.jsx(ir,{size:12}),"Stop"]})]}):ee?r.jsx("div",{className:"flex-1 flex items-center gap-2 text-sm text-muted",children:r.jsx("span",{className:"font-medium text-ink",children:ee.description})}):r.jsx("div",{className:"flex-1 flex items-center text-sm text-muted",children:"Detecting project type..."})}),I&&I.status!=="stopped"&&r.jsxs("div",{className:`px-3 py-1 border-b flex items-center gap-2 text-xs flex-shrink-0 ${I.running?"bg-green-50 border-green-200 text-green-700":I.status==="starting"?"bg-yellow-50 border-yellow-200 text-yellow-700":I.status==="error"?"bg-red-50 border-red-200 text-red-700":"bg-gray-50 border-border text-muted"}`,children:[r.jsx("span",{className:`w-2 h-2 rounded-full ${I.running?"bg-green-500":I.status==="starting"?"bg-yellow-500 animate-pulse":I.status==="error"?"bg-red-500":"bg-gray-400"}`}),I.running&&I.portless_url&&r.jsxs("span",{children:["Running at ",I.portless_url]}),I.running&&I.port&&!I.portless_url&&r.jsxs("span",{children:["Running on port ",I.port]}),I.status==="starting"&&r.jsx("span",{children:"Starting dev server..."}),I.status==="error"&&!I.auto_fix_status&&r.jsx("span",{children:"Dev server crashed"}),I.status==="error"&&I.auto_fix_status&&r.jsxs("span",{children:["Auto-fixing: ",I.auto_fix_status]}),I.command&&r.jsx("span",{className:"text-xs font-mono opacity-60 ml-auto truncate max-w-xs",children:I.command})]}),I!=null&&I.running?r.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",children:[ki&&r.jsx($l,{}),r.jsx("div",{ref:ys,className:`flex-1 bg-white overflow-auto flex justify-center ${ki?"hidden":""}`,children:r.jsx("div",{className:`${Ao} h-full preview-zoom-${kr}`,children:r.jsx("iframe",{ref:P,src:Lt,title:"Project Preview",className:"w-full h-full border-0",sandbox:"allow-scripts allow-same-origin allow-forms allow-popups",onLoad:()=>{Nr(!1),ys.current&&Io(ys.current.clientWidth)}},E)})}),r.jsx(Ol,{messages:$o})]}):ee!=null&&ee.preview_url?r.jsxs("div",{className:"flex-1 min-h-0 flex flex-col",children:[ki&&r.jsx($l,{}),r.jsx("div",{ref:ys,className:`flex-1 bg-white overflow-auto flex justify-center ${ki?"hidden":""}`,children:r.jsx("div",{className:`${Ao} h-full preview-zoom-${kr}`,children:r.jsx("iframe",{ref:P,src:Lt,title:"Project Preview",className:"w-full h-full border-0",sandbox:"allow-scripts allow-same-origin allow-forms allow-popups",onLoad:()=>{Nr(!1),ys.current&&Io(ys.current.clientWidth)}},E)})}),r.jsx(Ol,{messages:$o})]}):ee?r.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-4 p-8 text-center",children:[r.jsx("div",{className:"w-16 h-16 rounded-full bg-primary/10 flex items-center justify-center",children:ee.type==="api"||ee.type==="python-api"?r.jsx(Kd,{size:28,className:"text-primary"}):ee.type==="library"?r.jsx(Ql,{size:28,className:"text-primary"}):ee.type==="go-app"||ee.type==="rust-app"?r.jsx(os,{size:28,className:"text-primary"}):r.jsx(on,{size:28,className:"text-primary"})}),r.jsxs("div",{children:[r.jsx("h3",{className:"text-lg font-heading text-ink mb-1",children:ee.type.replace(/-/g," ").replace(/\b\w/g,b=>b.toUpperCase())}),r.jsx("p",{className:"text-sm text-muted",children:ee.description})]}),r.jsxs("div",{className:"card p-4 max-w-md w-full space-y-3",children:[ee.dev_command&&r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"text-xs font-semibold text-muted-accessible uppercase tracking-wider",children:"Dev Server"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("code",{className:"text-sm font-mono text-primary bg-hover px-3 py-2 rounded-btn flex-1 text-left truncate",children:ee.dev_command}),r.jsxs("button",{onClick:()=>Ss(ee.dev_command||void 0),disabled:Hs,className:"flex items-center gap-1.5 px-3 py-2 text-xs font-medium rounded-btn bg-primary text-white hover:bg-primary/90 transition-colors disabled:opacity-50",children:[r.jsx(rs,{size:12}),Hs?"Starting...":"Start"]})]})]}),r.jsxs("div",{className:ee.dev_command?"pt-2 border-t border-border":"",children:[r.jsx("p",{className:"text-xs text-muted mb-2",children:ee.dev_command?"Or use a custom command:":"Start a dev server:"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("input",{value:Jt,onChange:b=>Jh(b.target.value),onKeyDown:b=>{b.key==="Enter"&&Jt.trim()&&Ss(Jt.trim())},placeholder:"e.g. npm run dev",className:"flex-1 px-3 py-1.5 text-xs font-mono bg-card border border-border rounded-btn"}),r.jsx("button",{onClick:()=>Jt.trim()&&Ss(Jt.trim()),disabled:Hs||!Jt.trim(),className:"px-3 py-1.5 text-xs font-medium rounded-btn border border-primary/40 bg-primary/10 text-primary hover:bg-primary/20 transition-colors disabled:opacity-50",children:"Run"})]})]})]}),Vo&&r.jsxs("div",{className:"card p-3 max-w-md w-full border-danger/30 bg-danger/5",children:[r.jsx("p",{className:"text-xs text-danger font-medium mb-1",children:"Dev server error"}),r.jsx("p",{className:"text-xs text-danger/80",children:Vo})]}),(I==null?void 0:I.status)==="error"&&r.jsxs("div",{className:"card p-3 max-w-md w-full border-danger/30 bg-danger/5",children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsx("p",{className:"text-xs text-danger font-medium",children:"Dev server crashed"}),r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("button",{onClick:ed,disabled:Ko,className:"text-xs px-2 py-1 rounded border border-primary/40 bg-primary/10 text-primary hover:bg-primary/20 transition-colors disabled:opacity-50",children:Ko?"Fixing...":"Fix Error"}),r.jsx("button",{onClick:()=>Ss(ee.dev_command||Jt||void 0),className:"text-xs px-2 py-1 rounded border border-danger/40 text-danger hover:bg-danger/10 transition-colors",children:"Restart"})]})]}),I.auto_fix_status&&r.jsxs("div",{className:"flex items-center gap-2 mb-2 px-2 py-1 rounded bg-primary/5 border border-primary/20",children:[r.jsx("div",{className:"w-2 h-2 rounded-full bg-primary animate-pulse"}),r.jsxs("span",{className:"text-[11px] text-primary font-medium",children:["Auto-fix: ",I.auto_fix_status]}),I.auto_fix_attempts!==void 0&&I.auto_fix_attempts>0&&r.jsxs("span",{className:"text-[10px] text-muted ml-auto",children:["Attempt ",I.auto_fix_attempts,"/3"]})]}),I.output.length>0&&r.jsx("pre",{className:"text-[11px] font-mono text-danger/70 bg-danger/5 p-2 rounded max-h-32 overflow-y-auto whitespace-pre-wrap",children:I.output.slice(-10).join(`
256
+ `)})]}),ee.port&&!(I!=null&&I.running)&&r.jsxs("p",{className:"text-xs text-muted",children:["Server will run on port ",ee.port]})]}):r.jsx("div",{className:"flex-1 flex items-center justify-center text-muted text-sm",children:"Detecting project type..."})]})}),u==="config"&&r.jsx("div",{className:"h-full flex flex-col",children:r.jsxs("div",{className:"p-6 overflow-y-auto",children:[r.jsx("h3",{className:"text-h3 font-heading text-ink mb-4",children:"Project Configuration"}),r.jsxs("div",{className:"space-y-4",children:[r.jsxs("div",{className:"card p-4",children:[r.jsx("label",{className:"block text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-2",children:"Provider"}),r.jsxs("p",{className:"text-xs text-muted mb-2",children:["Provider for the next build: ",r.jsx("span",{className:"font-semibold text-ink capitalize",children:T})]}),r.jsx("div",{className:"flex gap-2",children:["claude","codex","gemini"].map(b=>r.jsx("button",{disabled:pe,title:pe?"Stop the build to change the provider":void 0,onClick:()=>{W.setProvider(b).then(()=>{G(b),sessionStorage.setItem(`pl_provider_${v.id}`,b),ne(null)}).catch(A=>ne(`Could not set provider: ${A instanceof Error?A.message:"unknown error"}`))},className:`px-4 py-2 rounded-btn text-sm font-medium border transition-colors capitalize disabled:opacity-50 disabled:cursor-not-allowed ${T===b?"border-primary bg-primary/10 text-primary":"border-border text-secondary hover:bg-hover"}`,children:b},b))}),K&&r.jsx("p",{className:"text-xs text-danger mt-2",children:K})]}),r.jsxs("div",{className:"card p-4",children:[r.jsx("label",{className:"block text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-2",children:"Build Mode"}),r.jsx("p",{className:"text-xs text-muted mb-2",children:"Used by chat and the cost estimate in this browser tab. Not sent to the build."}),r.jsx("div",{className:"flex gap-2",children:["quick","standard","max"].map(b=>r.jsx("button",{onClick:()=>{xe(b),sessionStorage.setItem(`pl_buildmode_${v.id}`,b)},className:`px-4 py-2 rounded-btn text-sm font-medium border transition-colors capitalize ${z===b?"border-primary bg-primary/10 text-primary":"border-border text-secondary hover:bg-hover"}`,children:b},b))})]}),r.jsxs("div",{className:"card p-4",children:[r.jsx("label",{className:"block text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-2",children:"Project Path"}),r.jsx("input",{value:v.path,readOnly:!0,className:"w-full px-3 py-2 text-sm font-mono bg-hover border border-border rounded-btn text-ink"})]}),r.jsxs("div",{className:"card p-4",children:[r.jsx("label",{className:"block text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-2",children:"Session ID"}),r.jsx("input",{value:v.id,readOnly:!0,className:"w-full px-3 py-2 text-sm font-mono bg-hover border border-border rounded-btn text-ink"})]})]})]})}),u==="secrets"&&r.jsx(zv,{}),u==="prd"&&r.jsx("div",{className:"h-full flex flex-col",children:r.jsxs("div",{className:"p-6 overflow-y-auto",children:[r.jsx("h3",{className:"text-h3 font-heading text-ink mb-4",children:"Product Requirements"}),v.prd?r.jsx("pre",{className:"text-sm font-mono text-ink whitespace-pre-wrap bg-hover border border-border rounded-card p-4 leading-relaxed",children:v.prd}):r.jsx("div",{className:"text-sm text-muted text-center py-8",children:"No spec found for this project."})]})}),u==="deploy"&&r.jsx(_x,{sessionId:v.id}),u==="dashboard"&&(ce===!1?r.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-center p-8 gap-4",children:[r.jsx(Mr,{size:48,className:"text-muted/30"}),r.jsx("h3",{className:"text-lg font-heading font-bold text-ink",children:"Dashboard Not Running"}),r.jsx("p",{className:"text-sm text-muted max-w-md",children:"The Loki Dashboard provides task boards, RARV timeline, quality gates, and cost tracking. Start it to see project analytics."}),r.jsx("button",{onClick:async()=>{ge(null);try{const b=await fetch(`http://127.0.0.1:${ue}/health`);ge(b.ok)}catch{ge(!1)}},className:"px-4 py-2 text-sm font-medium rounded-btn bg-primary text-white hover:bg-primary-hover",children:"Check Again"})]}):r.jsxs("div",{className:"h-full flex flex-col",children:[r.jsxs("div",{className:"flex items-center gap-1 px-3 py-2 border-b border-border bg-hover flex-shrink-0",children:[[{id:"overview",label:"Overview"},{id:"tasks",label:"Tasks"},{id:"timeline",label:"RARV Timeline"},{id:"quality",label:"Quality"},{id:"cost",label:"Cost"}].map(b=>r.jsx("button",{onClick:()=>de(b.id),className:`px-3 py-1.5 text-xs font-medium rounded-btn transition-colors ${se===b.id?"bg-primary/10 text-primary":"text-muted hover:text-ink hover:bg-hover"}`,children:b.label},b.id)),r.jsx("div",{className:"flex-1"}),r.jsxs("a",{href:`http://127.0.0.1:${ue}/`,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted hover:text-primary flex items-center gap-1",children:["Open full dashboard ",r.jsx(ls,{size:12})]})]}),r.jsx("iframe",{src:`http://127.0.0.1:${ue}/#${se}`,className:"flex-1 w-full border-none",title:"Loki Dashboard",sandbox:"allow-same-origin allow-scripts allow-popups allow-forms"})]})),u==="git"&&r.jsx(Bx,{sessionId:v.id}),u==="cicd"&&r.jsx("div",{className:"h-full overflow-y-auto p-4",children:r.jsx(Bv,{sessionId:e.id})}),u==="docs"&&r.jsx("div",{className:"h-full overflow-y-auto p-4",children:r.jsx(Av,{sessionId:v.id})}),u==="insights"&&r.jsx("div",{className:"h-full overflow-y-auto p-4",children:r.jsx(Cv,{filesCreated:null,filesModified:null,linesGenerated:null,testsGenerated:null,testPassRate:null,totalTokens:null,phaseBreakdown:[],totalTimeSecs:pe&&Ue.startTime?Math.floor((Date.now()-Ue.startTime)/1e3):null,qualityScore:null,totalCost:Ue.cost,iterations:Ue.iteration,provider:T})})]})]})})]})}),Z&&r.jsx(fn,{className:"h-1 bg-border hover:bg-primary/30 cursor-row-resize"}),Z&&r.jsx(ei,{defaultSize:30,minSize:15,collapsible:!0,children:r.jsx(Wi,{name:"ActivityPanel",children:r.jsx(ox,{logs:null,logsLoading:!1,agents:null,checklist:null,sessionId:e.id,isRunning:v.status==="running"||v.status==="in_progress",buildMode:z,buildEvents:Th,onFileClick:b=>Bt(b,b.split("/").pop()||b)})})})]})}),(he==null?void 0:he.loading)&&r.jsx("div",{className:"absolute inset-x-0 bottom-0 z-20 bg-card border-t border-border p-4",children:r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("div",{className:"w-4 h-4 border-2 border-primary border-t-transparent rounded-full animate-spin"}),r.jsxs("span",{className:"text-sm font-medium text-ink",children:[he.type==="review"?"Reviewing project":he.type==="test"?"Generating tests":"Analyzing project","..."]}),r.jsxs("span",{className:"text-xs font-mono text-muted",children:[he.elapsed,"s"]})]})}),He&&r.jsxs("div",{className:"absolute inset-x-0 bottom-0 z-20 bg-card border-t border-border p-4 max-h-64 overflow-y-auto",children:[r.jsxs("div",{className:"flex items-center justify-between mb-2",children:[r.jsx("span",{className:"text-xs font-semibold text-ink",children:"Action Output"}),r.jsx(At,{icon:gt,label:"Close",size:"sm",onClick:()=>be(null)})]}),r.jsx("pre",{className:"text-xs font-mono text-ink whitespace-pre-wrap",children:He})]}),S&&r.jsx(Lm,{x:S.x,y:S.y,items:ad(S),onClose:()=>C(null)}),M&&r.jsx("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[20vh]",role:"dialog","aria-modal":"true","aria-label":"Quick open file search",onClick:()=>U(!1),children:r.jsxs("div",{className:"bg-card rounded-card shadow-2xl border border-border w-full max-w-lg",onClick:b=>b.stopPropagation(),children:[r.jsx("input",{ref:$,type:"text",value:Y,onChange:b=>V(b.target.value),placeholder:"Search files by name...",className:"w-full px-4 py-3 text-sm font-mono border-b border-border outline-none rounded-t-card bg-transparent",onKeyDown:b=>{b.key==="Enter"&&Ws.length>0&&(Bt(Ws[0].path,Ws[0].name),U(!1)),b.key==="Escape"&&U(!1)}}),r.jsxs("div",{className:"max-h-64 overflow-y-auto",children:[Ws.slice(0,20).map(b=>r.jsxs("button",{onClick:()=>{Bt(b.path,b.name),U(!1)},className:"w-full text-left px-4 py-2 text-xs font-mono hover:bg-primary/5 flex items-center gap-2",children:[r.jsx("span",{className:"w-5 flex items-center justify-center",children:Qn(b.name,"file")}),r.jsx("span",{className:"text-ink",children:b.name}),r.jsx("span",{className:"text-muted ml-auto truncate text-xs",children:b.path})]},b.path)),Ws.length===0&&r.jsx("div",{className:"px-4 py-3 text-xs text-muted",children:"No matching files"})]})]})}),r.jsx(bx,{open:_d,onClose:()=>ta(!1)}),r.jsx(kx,{isOpen:Bh,onClose:()=>Do(!1),commands:gd,sessionId:v.id,onFileSelect:Bt}),Po&&r.jsx(Ox,{data:Po,onAcceptAll:ud,onAcceptSelected:fd,onReject:md,onClose:()=>Is(null)}),r.jsx(Vx,{phase:Pr,buildTime:Ue.startTime?Math.floor((Date.now()-Ue.startTime)/1e3):void 0}),zh&&r.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>Cr(!1),children:r.jsxs("div",{className:"bg-card rounded-card shadow-2xl border border-border w-full max-w-3xl max-h-[80vh] overflow-y-auto",onClick:b=>b.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[r.jsx("h3",{className:"text-sm font-bold text-ink",children:"Build Replay"}),r.jsx("button",{onClick:()=>Cr(!1),className:"text-muted hover:text-ink p-1 rounded hover:bg-hover transition-colors",children:r.jsx(gt,{size:16})})]}),r.jsx("div",{className:"p-4",children:r.jsx(jv,{sessionId:v.id})})]})}),Oh&&r.jsx("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[15vh]",onClick:()=>Fs(!1),children:r.jsxs("div",{className:"bg-card rounded-card shadow-2xl border border-border w-full max-w-lg",onClick:b=>b.stopPropagation(),children:[r.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border",children:[r.jsx("h3",{className:"text-sm font-bold text-ink",children:"Search Files"}),r.jsx("button",{onClick:()=>Fs(!1),className:"text-muted hover:text-ink p-1 rounded hover:bg-hover transition-colors",children:r.jsx(gt,{size:16})})]}),r.jsx(Pv,{sessionId:v.id,onOpenFile:(b,A)=>{Bt(b,b.split("/").pop()||b),Fs(!1)},className:"p-4"})]})}),Ah&&r.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50",onClick:()=>wi(!1),children:r.jsx("div",{className:"bg-card rounded-card shadow-2xl border border-border w-full max-w-md",onClick:b=>b.stopPropagation(),children:r.jsx(Lv,{complexity:z==="quick"?"simple":z==="max"?"complex":"standard",provider:T,estimatedIterations:Ue.maxIterations??0,onConfirm:async()=>{wi(!1);try{const b=v.prd||"";await W.startSession({prd:b,provider:T,projectDir:v.path}),wt(!0)}catch(b){window.alert(`Failed to start: ${b instanceof Error?b.message:"Unknown error"}`)}},onCancel:()=>wi(!1)})})})]})}function $v(){const{sessionId:e}=Rd(),t=Pd(),[s,i]=d.useState(null),[n,o]=d.useState(!0),[a,l]=d.useState(null);return d.useEffect(()=>{e&&(o(!0),l(null),W.getSessionDetail(e).then(h=>{i(h),o(!1)}).catch(h=>{l(h instanceof Error?h.message:"Failed to load session"),o(!1)}))},[e]),n?r.jsx("div",{className:"h-screen bg-background flex items-center justify-center",children:r.jsxs("div",{className:"text-center",children:[r.jsx("div",{className:"text-muted animate-pulse text-sm",children:"Loading project..."}),r.jsx("div",{className:"text-xs font-mono text-muted/50 mt-2",children:e})]})}):a||!s?r.jsx("div",{className:"h-screen bg-background flex items-center justify-center",children:r.jsxs("div",{className:"text-center",children:[r.jsx("p",{className:"text-danger text-sm font-medium",children:"Project not found"}),r.jsx("p",{className:"text-xs text-muted mt-1",children:a||`Session ${e} does not exist`}),r.jsx("button",{onClick:()=>t("/"),className:"mt-4 px-4 py-2 rounded-btn text-sm font-semibold border border-primary/30 text-primary hover:bg-primary/5 transition-all",children:"Back to Home"})]})}):r.jsx("div",{className:"h-screen bg-background flex flex-col",children:r.jsx("div",{className:"flex-1 min-h-0",children:r.jsx(Wi,{name:"ProjectWorkspace",children:r.jsx(Ov,{session:s,onClose:()=>t("/")})})})})}const bb=Object.freeze(Object.defineProperty({__proto__:null,default:$v},Symbol.toStringTag,{value:"Module"}));export{xr as L,bb as P,Du as S};